Skip to contentSkip to conversation

Implement DMIC support in WM8903

PATCH In review Svyatoslav Ryhel 3 participants 13 messages Mar 25, 2023 – Mar 27, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Implement DMIC support in WM8903

According to comments in wm8903, driver lacks DMIC support. My wm8903 based devices (ASUS TF300T and TF101) require DMIC support for correct internal mic work. I have used downstream sources to implement DMIC input support for this driver and I can confirm that internal mic now works as intended.

Svyatoslav Ryhel (1):
ASoC: wm8903: implement DMIC support

 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.37.2
#1 lore raw

PATCH 1/1 ASoC: wm8903: implement DMIC support

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +4 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
 #include <linux/module.h>
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),
 
 SND_SOC_DAPM_OUTPUT("HPOUTL"),
@@ -996,6 +996,9 @@ static const struct snd_soc_dapm_route wm8903_intercon[] = {
 	{ "AIFTXL", NULL, "Left Capture Mux" },
 	{ "AIFTXR", NULL, "Right Capture Mux" },
 
+	{ "ADCL", NULL, "DMIC" },
+	{ "ADCR", NULL, "DMIC" },
+
 	{ "ADCL", NULL, "Left ADC Input" },
 	{ "ADCL", NULL, "CLK_DSP" },
 	{ "ADCR", NULL, "Right ADC Input" },
Signature · 1 line
2.37.2
#2 lore raw

Re: [PATCH v1 1/1] ASoC: wm8903: implement DMIC support

Quoted 21 lines · Svyatoslav Ryhel

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +0 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
 #include <linux/module.h>

sound/soc/codecs/wm8903.c SND_SOC_DAPM_INPUT("IN2L"), · line 819

Quoted 5 lines
sound/soc/codecs/wm8903.c +1 -0
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),

There is already a datapath for the DMIC here, DMICDAT. Are you sure you don't just need to set the "Left/Right ADC Input" muxes correctly through the ALSA controls?

sound/soc/codecs/wm8903.c static const struct snd_soc_dapm_route wm8903_intercon[] = { · line 1001

Quoted 9 lines
sound/soc/codecs/wm8903.c +3 -0
 SND_SOC_DAPM_OUTPUT("HPOUTL"),
@@ -996,6 +996,9 @@ static const struct snd_soc_dapm_route wm8903_intercon[] = {
 	{ "AIFTXL", NULL, "Left Capture Mux" },
 	{ "AIFTXR", NULL, "Right Capture Mux" },
 
+	{ "ADCL", NULL, "DMIC" },
+	{ "ADCR", NULL, "DMIC" },
+

And at any rate these should not be directly connected to the ADC you need some muxing to indicate whether the DMIC or AMICs are active. Which the DMICDAT path appears to already have.

Thanks,
Charles

#3 lore raw

Re: [PATCH v1 1/1] ASoC: wm8903: implement DMIC support

In reply to Svyatoslav Ryhel
Quoted 21 lines · Svyatoslav Ryhel

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +0 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
 #include <linux/module.h>

sound/soc/codecs/wm8903.c SND_SOC_DAPM_INPUT("IN2L"), · line 819

Quoted 5 lines
sound/soc/codecs/wm8903.c +1 -0
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),

There is already a datapath for the DMIC here, DMICDAT. Are you sure you don't just need to set the "Left/Right ADC Input" muxes correctly through the ALSA controls?

sound/soc/codecs/wm8903.c static const struct snd_soc_dapm_route wm8903_intercon[] = { · line 1001

Quoted 9 lines
sound/soc/codecs/wm8903.c +3 -0
 SND_SOC_DAPM_OUTPUT("HPOUTL"),
@@ -996,6 +996,9 @@ static const struct snd_soc_dapm_route wm8903_intercon[] = {
 	{ "AIFTXL", NULL, "Left Capture Mux" },
 	{ "AIFTXR", NULL, "Right Capture Mux" },
 
+	{ "ADCL", NULL, "DMIC" },
+	{ "ADCR", NULL, "DMIC" },
+

And at any rate these should not be directly connected to the ADC you need some muxing to indicate whether the DMIC or AMICs are active. Which the DMICDAT path appears to already have.

Thanks,
Charles

#4 lore raw

Re: [PATCH v1 1/1] ASoC: wm8903: implement DMIC support

In reply to Charles Keepax

пн, 27 бер. 2023 р. о 11:32 Charles Keepax <[email protected]> пише:

Quoted 21 lines · Svyatoslav Ryhel
Quoted 19 lines

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +0 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
Quoted 12 lines

sound/soc/codecs/wm8903.c SND_SOC_DAPM_INPUT("IN2L"), · line 819

Quoted 7 lines
sound/soc/codecs/wm8903.c +1 -0
 #include <linux/module.h>
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),

There is already a datapath for the DMIC here, DMICDAT. Are you sure you don't just need to set the "Left/Right ADC Input" muxes correctly through the ALSA controls?

I will check once more, but so far I was not able to set the mic to work with DMICDAT. Only with this patch.

Best regards,
Svyatoslav R.

Quoted 16 lines

sound/soc/codecs/wm8903.c static const struct snd_soc_dapm_route wm8903_intercon[] = { · line 1001

Quoted 9 lines
sound/soc/codecs/wm8903.c +3 -0
 SND_SOC_DAPM_OUTPUT("HPOUTL"),
@@ -996,6 +996,9 @@ static const struct snd_soc_dapm_route wm8903_intercon[] = {
      { "AIFTXL", NULL, "Left Capture Mux" },
      { "AIFTXR", NULL, "Right Capture Mux" },
 
+     { "ADCL", NULL, "DMIC" },
+     { "ADCR", NULL, "DMIC" },
+

And at any rate these should not be directly connected to the ADC you need some muxing to indicate whether the DMIC or AMICs are active. Which the DMICDAT path appears to already have.

Thanks,
Charles

#10 lore raw
In reply to Charles Keepax

пн, 27 бер. 2023 р. о 11:33 Charles Keepax <[email protected]> пише:

Quoted 6 lines · Svyatoslav Ryhel
Quoted 1 line

According to comments in wm8903, driver lacks DMIC support.

Which comments? I am having some difficulty finding these?

Lines 10-12

* TODO:
* - TDM mode configuration.
* - Digital microphone support.

Quoted 2 lines

Thanks,
Charles

#11 lore raw
Quoted 5 lines · Svyatoslav Ryhel

пн, 27 бер. 2023 р. о 11:33 Charles Keepax <[email protected]> пише:

Quoted 4 lines · Svyatoslav Ryhel
Quoted 1 line

According to comments in wm8903, driver lacks DMIC support.

Quoted 9 lines
Quoted 2 lines

Which comments? I am having some difficulty finding these?

Lines 10-12

* TODO:
* - TDM mode configuration.
* - Digital microphone support.

Oops... thanks, I think that comment should have been removed in this patch:

commit 97945c46a23d ("ASoC: WM8903: Implement DMIC support")

Thanks,
Charles

#12 lore raw
In reply to Svyatoslav Ryhel
Quoted 5 lines · Svyatoslav Ryhel

пн, 27 бер. 2023 р. о 11:33 Charles Keepax <[email protected]> пише:

Quoted 4 lines · Svyatoslav Ryhel
Quoted 1 line

According to comments in wm8903, driver lacks DMIC support.

Quoted 9 lines
Quoted 2 lines

Which comments? I am having some difficulty finding these?

Lines 10-12

* TODO:
* - TDM mode configuration.
* - Digital microphone support.

Oops... thanks, I think that comment should have been removed in this patch:

commit 97945c46a23d ("ASoC: WM8903: Implement DMIC support")

Thanks,
Charles

#5 lore raw

Re: [PATCH v1 1/1] ASoC: wm8903: implement DMIC support

In reply to Svyatoslav Ryhel
Quoted 35 lines · Svyatoslav Ryhel

пн, 27 бер. 2023 р. о 11:32 Charles Keepax <[email protected]> пише:

Quoted 21 lines · Svyatoslav Ryhel
Quoted 19 lines

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +0 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
Quoted 12 lines

sound/soc/codecs/wm8903.c SND_SOC_DAPM_INPUT("IN2L"), · line 819

Quoted 7 lines
sound/soc/codecs/wm8903.c +1 -0
 #include <linux/module.h>
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),

There is already a datapath for the DMIC here, DMICDAT. Are you sure you don't just need to set the "Left/Right ADC Input" muxes correctly through the ALSA controls?

Quoted 3 lines

I will check once more, but so far I was not able to set the mic to work with DMICDAT. Only with this patch.

The two should be basically equivalent when the controls are set right, your patch has:

DMIC -> ADCL

The current code has

DMIC -> Left ADC Input -> ADCL

The only difference is that Left ADC Input sets the ADC_DIG_MIC bit, but the datasheet clearly indicates that should be necessary for digital mics to work. Does your system definitely have DMICs? Without that bit set the decimator should still be connected to the analogue front end.

Thanks,
Charles

#7 lore raw

Re: [PATCH v1 1/1] ASoC: wm8903: implement DMIC support

In reply to Svyatoslav Ryhel
Quoted 35 lines · Svyatoslav Ryhel

пн, 27 бер. 2023 р. о 11:32 Charles Keepax <[email protected]> пише:

Quoted 21 lines · Svyatoslav Ryhel
Quoted 19 lines

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +0 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
Quoted 12 lines

sound/soc/codecs/wm8903.c SND_SOC_DAPM_INPUT("IN2L"), · line 819

Quoted 7 lines
sound/soc/codecs/wm8903.c +1 -0
 #include <linux/module.h>
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),

There is already a datapath for the DMIC here, DMICDAT. Are you sure you don't just need to set the "Left/Right ADC Input" muxes correctly through the ALSA controls?

Quoted 3 lines

I will check once more, but so far I was not able to set the mic to work with DMICDAT. Only with this patch.

The two should be basically equivalent when the controls are set right, your patch has:

DMIC -> ADCL

The current code has

DMIC -> Left ADC Input -> ADCL

The only difference is that Left ADC Input sets the ADC_DIG_MIC bit, but the datasheet clearly indicates that should be necessary for digital mics to work. Does your system definitely have DMICs? Without that bit set the decimator should still be connected to the analogue front end.

Thanks,
Charles

#6 lore raw

Re: [PATCH v1 1/1] ASoC: wm8903: implement DMIC support

In reply to Charles Keepax

пн, 27 бер. 2023 р. о 13:14 Charles Keepax <[email protected]> пише:

Quoted 48 lines · Svyatoslav Ryhel
Quoted 35 lines

пн, 27 бер. 2023 р. о 11:32 Charles Keepax <[email protected]> пише:

Quoted 21 lines · Svyatoslav Ryhel
Quoted 19 lines

Add DMIC input and routing.

---
 sound/soc/codecs/wm8903.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +0 -1
index 41346e5ec5ad..9c2f0aadcff3 100644
@@ -9,7 +9,6 @@
  *
  * TODO:
  *  - TDM mode configuration.
- *  - Digital microphone support.
  */
 
Quoted 12 lines

sound/soc/codecs/wm8903.c SND_SOC_DAPM_INPUT("IN2L"), · line 819

Quoted 7 lines
sound/soc/codecs/wm8903.c +1 -0
 #include <linux/module.h>
@@ -816,6 +815,7 @@ SND_SOC_DAPM_INPUT("IN2L"),
 SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
+SND_SOC_DAPM_INPUT("DMIC"),
 SND_SOC_DAPM_INPUT("DMICDAT"),

There is already a datapath for the DMIC here, DMICDAT. Are you sure you don't just need to set the "Left/Right ADC Input" muxes correctly through the ALSA controls?

Quoted 3 lines

I will check once more, but so far I was not able to set the mic to work with DMICDAT. Only with this patch.

The two should be basically equivalent when the controls are set right, your patch has:

DMIC -> ADCL

The current code has

Quoted 8 lines

DMIC -> Left ADC Input -> ADCL

The only difference is that Left ADC Input sets the ADC_DIG_MIC bit, but the datasheet clearly indicates that should be necessary for digital mics to work. Does your system definitely have DMICs? Without that bit set the decimator should still be connected to the analogue front end.

You are correct, this patch is not needed. It appears that the issue was not in routing but in wm8903 gpio configuration.

DMICDAT works as intended.

Quoted 2 lines

Thanks,
Charles