The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
@ 2026-08-25  2:38 songxiebing
  2026-08-25  8:22 ` Takashi Iwai
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: songxiebing @ 2026-08-25  2:38 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

From: Bob Song <songxiebing@kylinos.cn>

For 3-pole headset microphones, the mic pin VREF must always be
configured to 0x24 regardless of the headset type, otherwise the
mic will not be able to record audio. Move the setting of the mic
pin widget control to a common path.

Signed-off-by: Bob Song <songxiebing@kylinos.cn>
---
 sound/hda/codecs/conexant.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/hda/codecs/conexant.c b/sound/hda/codecs/conexant.c
index 40da2832ba66..a18091a2866f 100644
--- a/sound/hda/codecs/conexant.c
+++ b/sound/hda/codecs/conexant.c
@@ -225,13 +225,12 @@ static void cx_process_headset_plugin(struct hda_codec *codec)
 	val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0);
 	if (val & 0x800) {
 		codec_dbg(codec, "headset plugin, type is CTIA\n");
-		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
 	} else if (val & 0x400) {
 		codec_dbg(codec, "headset plugin, type is OMTP\n");
-		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
 	} else {
-		codec_dbg(codec, "headphone plugin\n");
+		codec_dbg(codec, "mic plugin\n");
 	}
+	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
 }
 
 static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_callback *event)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
  2026-08-25  2:38 [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug songxiebing
@ 2026-08-25  8:22 ` Takashi Iwai
  2026-08-25  9:13 ` songxiebing
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2026-08-25  8:22 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Tue, 25 Aug 2026 04:38:55 +0200,
songxiebing wrote:
> 
> From: Bob Song <songxiebing@kylinos.cn>
> 
> For 3-pole headset microphones, the mic pin VREF must always be
> configured to 0x24 regardless of the headset type, otherwise the
> mic will not be able to record audio. Move the setting of the mic
> pin widget control to a common path.
> 
> Signed-off-by: Bob Song <songxiebing@kylinos.cn>
> ---
>  sound/hda/codecs/conexant.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/hda/codecs/conexant.c b/sound/hda/codecs/conexant.c
> index 40da2832ba66..a18091a2866f 100644
> --- a/sound/hda/codecs/conexant.c
> +++ b/sound/hda/codecs/conexant.c
> @@ -225,13 +225,12 @@ static void cx_process_headset_plugin(struct hda_codec *codec)
>  	val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0);
>  	if (val & 0x800) {
>  		codec_dbg(codec, "headset plugin, type is CTIA\n");
> -		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
>  	} else if (val & 0x400) {
>  		codec_dbg(codec, "headset plugin, type is OMTP\n");
> -		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
>  	} else {
> -		codec_dbg(codec, "headphone plugin\n");
> +		codec_dbg(codec, "mic plugin\n");
>  	}
> +	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
>  }


Hmm, it's a headset plug check code, and the fallback case you
modified was supposed to be a headphone jack, no microphone.  That is,
the state where a headphone is plugged without microphone into the
headset jack, and in this case, it's wrong to enable the mic pin --
you shouldn't be able to record from the mic at all in this particular
case.

So, there must be other case -- mic-only plug -- and that is where the
mic pin is set up, too.


Takashi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
  2026-08-25  2:38 [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug songxiebing
  2026-08-25  8:22 ` Takashi Iwai
@ 2026-08-25  9:13 ` songxiebing
  2026-08-25  9:28   ` Takashi Iwai
  2026-08-25  9:45 ` songxiebing
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: songxiebing @ 2026-08-25  9:13 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

Hi Takashi,

0x19 is configured as a mic pin, in cx_update_headset_mic_vref, it
executes cx_process_headset_plugin only after confirming that a mic
present is detected. A 4-pole headset is detected as either CTIA or
OMTP and sets 0x24, but the 3-pole mic case is not handled, so a
setting of 0x24 is added here.

>Hmm, it's a headset plug check code, and the fallback case you
>modified was supposed to be a headphone jack, no microphone.  That is,
>the state where a headphone is plugged without microphone into the
>headset jack, and in this case, it's wrong to enable the mic pin --
>you shouldn't be able to record from the mic at all in this particular
>case.
>
>So, there must be other case -- mic-only plug -- and that is where the
>mic pin is set up, too.
>
>
>Takashi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
  2026-08-25  9:13 ` songxiebing
@ 2026-08-25  9:28   ` Takashi Iwai
  0 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2026-08-25  9:28 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Tue, 25 Aug 2026 11:13:03 +0200,
songxiebing wrote:
> 
> Hi Takashi,
> 
> 0x19 is configured as a mic pin, in cx_update_headset_mic_vref, it
> executes cx_process_headset_plugin only after confirming that a mic
> present is detected. A 4-pole headset is detected as either CTIA or
> OMTP and sets 0x24, but the 3-pole mic case is not handled, so a
> setting of 0x24 is added here.

OK, then you'd need to explain more in the patch description.
It implies that the patch corrects the debug output, too.

And, this also opens another door: why do we read those registers at
all?  Now you always set the pin control 0x24 no matter what the
connection type is.  So the whole headset type detection becomes
practically moot; it's used only for showing a debug print.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
  2026-08-25  2:38 [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug songxiebing
  2026-08-25  8:22 ` Takashi Iwai
  2026-08-25  9:13 ` songxiebing
@ 2026-08-25  9:45 ` songxiebing
  2026-08-25  9:55   ` Takashi Iwai
  2026-08-26  1:12 ` songxiebing
  2026-08-26  1:45 ` [PATCH v2] ALSA: hda/conexant: Refactor headset plug detection songxiebing
  4 siblings, 1 reply; 9+ messages in thread
From: songxiebing @ 2026-08-25  9:45 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

Hi Takashi,

Yes, reading these registers is just to print out debugging information
for problem analysis.

>On Tue, 25 Aug 2026 11:13:03 +0200,
>songxiebing wrote:
>>
>> Hi Takashi,
>>
>> 0x19 is configured as a mic pin, in cx_update_headset_mic_vref, it
>> executes cx_process_headset_plugin only after confirming that a mic
>> present is detected. A 4-pole headset is detected as either CTIA or
>> OMTP and sets 0x24, but the 3-pole mic case is not handled, so a
>> setting of 0x24 is added here.
>
>OK, then you'd need to explain more in the patch description.
>It implies that the patch corrects the debug output, too.
>
>And, this also opens another door: why do we read those registers at
>all?  Now you always set the pin control 0x24 no matter what the
>connection type is.  So the whole headset type detection becomes
>practically moot; it's used only for showing a debug print.
>
>
>thanks,
>
>Takashi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
  2026-08-25  9:45 ` songxiebing
@ 2026-08-25  9:55   ` Takashi Iwai
  0 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2026-08-25  9:55 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Tue, 25 Aug 2026 11:45:36 +0200,
songxiebing wrote:
> 
> Hi Takashi,
> 
> Yes, reading these registers is just to print out debugging information
> for problem analysis.

Then it's better to move the pin setup to the caller; it makes the
setup more consistent.  While we're at it, rename the function to be
more intuitive one.  So the change would be something like below.


Takashi

> 
> >On Tue, 25 Aug 2026 11:13:03 +0200,
> >songxiebing wrote:
> >>
> >> Hi Takashi,
> >>
> >> 0x19 is configured as a mic pin, in cx_update_headset_mic_vref, it
> >> executes cx_process_headset_plugin only after confirming that a mic
> >> present is detected. A 4-pole headset is detected as either CTIA or
> >> OMTP and sets 0x24, but the 3-pole mic case is not handled, so a
> >> setting of 0x24 is added here.
> >
> >OK, then you'd need to explain more in the patch description.
> >It implies that the patch corrects the debug output, too.
> >
> >And, this also opens another door: why do we read those registers at
> >all?  Now you always set the pin control 0x24 no matter what the
> >connection type is.  So the whole headset type detection becomes
> >practically moot; it's used only for showing a debug print.
> >
> >
> >thanks,
> >
> >Takashi

-- 8< --
--- a/sound/hda/codecs/conexant.c
+++ b/sound/hda/codecs/conexant.c
@@ -207,7 +207,7 @@ static void cx_remove(struct hda_codec *codec)
 	snd_hda_gen_remove(codec);
 }
 
-static void cx_process_headset_plugin(struct hda_codec *codec)
+static void cx_process_headset_detect_plug_type(struct hda_codec *codec)
 {
 	unsigned int val;
 	unsigned int count = 0;
@@ -226,9 +226,8 @@ static void cx_process_headset_plugin(struct hda_codec *codec)
 	if (val & 0xc00) {
 		codec_dbg(codec, "headset plugin, type is %s\n",
 			  val & 0x800 ? "CTIA" : "OMTP");
-		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
 	} else {
-		codec_dbg(codec, "headphone plugin\n");
+		codec_dbg(codec, "headphone or mic plugin\n");
 	}
 }
 
@@ -241,10 +240,12 @@ static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_
 	 * Check hp&mic tag to process headset plugin & plugout.
 	 */
 	mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
-	if (!(mic_present & AC_PINSENSE_PRESENCE)) /* mic plugout */
+	if (!(mic_present & AC_PINSENSE_PRESENCE)) { /* mic plugout */
 		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
-	else
-		cx_process_headset_plugin(codec);
+	} else {
+		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
+		cx_process_headset_detect_plug_type(codec);
+	}
 }
 
 static int cx_suspend(struct hda_codec *codec)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug
  2026-08-25  2:38 [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug songxiebing
                   ` (2 preceding siblings ...)
  2026-08-25  9:45 ` songxiebing
@ 2026-08-26  1:12 ` songxiebing
  2026-08-26  1:45 ` [PATCH v2] ALSA: hda/conexant: Refactor headset plug detection songxiebing
  4 siblings, 0 replies; 9+ messages in thread
From: songxiebing @ 2026-08-26  1:12 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

Hi Takashi,

Thank you very much for your suggestion, but some adjustments are
still needed. Setting 0x24 first will cause headphone type recognition,
which will be executed later. I will provide a second version patch,
thank you.

>Then it's better to move the pin setup to the caller; it makes the
>setup more consistent.  While we're at it, rename the function to be
>more intuitive one.  So the change would be something like below.
>
>
>Takashi
>

>+	} else {
>+		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
>+		cx_process_headset_detect_plug_type(codec);
>+	}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] ALSA: hda/conexant: Refactor headset plug detection
  2026-08-25  2:38 [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug songxiebing
                   ` (3 preceding siblings ...)
  2026-08-26  1:12 ` songxiebing
@ 2026-08-26  1:45 ` songxiebing
  2026-08-26  8:48   ` Takashi Iwai
  4 siblings, 1 reply; 9+ messages in thread
From: songxiebing @ 2026-08-26  1:45 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, Bob Song

From: Bob Song <songxiebing@kylinos.cn>

Rename cx_process_headset_plugin() to cx_process_headset_detect_plug_type()
to better describe what it does, and merge the duplicated CTIA/OMTP
branches since both select the same pin-widget control value for the mic
pin.

Move the AC_VERB_SET_PIN_WIDGET_CONTROL write into the caller
cx_update_headset_mic_vref() so that the mic pin control is applied
unconditionally while a mic is present, instead of only for CTIA/OMTP
headsets.

Signed-off-by: Bob Song <songxiebing@kylinos.cn>
---
changes in v2:
  - Optimize code logic and description
---
 sound/hda/codecs/conexant.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/sound/hda/codecs/conexant.c b/sound/hda/codecs/conexant.c
index 40da2832ba66..6ad44cd9287c 100644
--- a/sound/hda/codecs/conexant.c
+++ b/sound/hda/codecs/conexant.c
@@ -207,7 +207,7 @@ static void cx_remove(struct hda_codec *codec)
 	snd_hda_gen_remove(codec);
 }
 
-static void cx_process_headset_plugin(struct hda_codec *codec)
+static void cx_process_headset_detect_plug_type(struct hda_codec *codec)
 {
 	unsigned int val;
 	unsigned int count = 0;
@@ -223,14 +223,11 @@ static void cx_process_headset_plugin(struct hda_codec *codec)
 		count++;
 	} while (count < 3);
 	val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0);
-	if (val & 0x800) {
-		codec_dbg(codec, "headset plugin, type is CTIA\n");
-		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
-	} else if (val & 0x400) {
-		codec_dbg(codec, "headset plugin, type is OMTP\n");
-		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
+	if (val & 0xc00) {
+		codec_dbg(codec, "headset plugin, type is %s\n",
+			  val & 0x800 ? "CTIA" : "OMTP");
 	} else {
-		codec_dbg(codec, "headphone plugin\n");
+		codec_dbg(codec, "headphone or mic plugin\n");
 	}
 }
 
@@ -243,10 +240,12 @@ static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_
 	 * Check hp&mic tag to process headset plugin & plugout.
 	 */
 	mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
-	if (!(mic_present & AC_PINSENSE_PRESENCE)) /* mic plugout */
+	if (!(mic_present & AC_PINSENSE_PRESENCE)) { /* mic plugout */
 		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
-	else
-		cx_process_headset_plugin(codec);
+	} else {
+		cx_process_headset_detect_plug_type(codec);
+		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
+	}
 }
 
 static int cx_suspend(struct hda_codec *codec)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] ALSA: hda/conexant: Refactor headset plug detection
  2026-08-26  1:45 ` [PATCH v2] ALSA: hda/conexant: Refactor headset plug detection songxiebing
@ 2026-08-26  8:48   ` Takashi Iwai
  0 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2026-08-26  8:48 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Wed, 26 Aug 2026 03:45:12 +0200,
songxiebing wrote:
> 
> From: Bob Song <songxiebing@kylinos.cn>
> 
> Rename cx_process_headset_plugin() to cx_process_headset_detect_plug_type()
> to better describe what it does, and merge the duplicated CTIA/OMTP
> branches since both select the same pin-widget control value for the mic
> pin.
> 
> Move the AC_VERB_SET_PIN_WIDGET_CONTROL write into the caller
> cx_update_headset_mic_vref() so that the mic pin control is applied
> unconditionally while a mic is present, instead of only for CTIA/OMTP
> headsets.
> 
> Signed-off-by: Bob Song <songxiebing@kylinos.cn>
> ---
> changes in v2:
>   - Optimize code logic and description

This doesn't apply on the latest code, as there was already a cleanup
to achieve a part of your code changes.
Could you rebase to the latest sound.git for-linus branch and
resubmit?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-26  8:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  2:38 [PATCH] ALSA: hda/conexant: Set mic pin VREF to 0x24 on headset mic plug songxiebing
2026-08-25  8:22 ` Takashi Iwai
2026-08-25  9:13 ` songxiebing
2026-08-25  9:28   ` Takashi Iwai
2026-08-25  9:45 ` songxiebing
2026-08-25  9:55   ` Takashi Iwai
2026-08-26  1:12 ` songxiebing
2026-08-26  1:45 ` [PATCH v2] ALSA: hda/conexant: Refactor headset plug detection songxiebing
2026-08-26  8:48   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox