Fix headset jack on two Dell machines

Bug #1454235 reported by David Henningsson
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HWE Next
Fix Released
Undecided
David Henningsson
linux (Ubuntu)
Fix Released
Undecided
David Henningsson

Bug Description

This bug is for tracking purposes. Please do not triage.

Revision history for this message
David Henningsson (diwic) wrote : [PATCH] ALSA: hda - Fix headset mic and mic-in for a Dell desktop
Download full text (3.6 KiB)

ALC662 does not need any special verbs to change the jack functionality,
and enables mic in through the headphone jack mode by changing the
direction of the headphone pin node.

BugLink: https://bugs.launchpad.net/bugs/1454235
Signed-off-by: David Henningsson <email address hidden>
---
 sound/pci/hda/patch_realtek.c | 46 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ce41271..30ec30f 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3674,6 +3674,10 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
   alc_process_coef_fw(codec, coef0293);
   snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
   break;
+ case 0x10ec0662:
+ snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
+ snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
+ break;
  case 0x10ec0668:
   alc_write_coef_idx(codec, 0x11, 0x0001);
   snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
@@ -4012,7 +4016,7 @@ static void alc_update_headset_mode(struct hda_codec *codec)
  if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
   snd_hda_set_pin_ctl_cache(codec, hp_pin,
        AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
- if (spec->headphone_mic_pin)
+ if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
    snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
         PIN_VREFHIZ);
  }
@@ -4215,6 +4219,18 @@ static void alc_fixup_dell_xps13(struct hda_codec *codec,
  }
 }

+static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
+ const struct hda_fixup *fix, int action)
+{
+ struct alc_spec *spec = codec->spec;
+
+ if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+ spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
+ spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
+ } else
+ alc_fixup_headset_mode(codec, fix, action);
+}
+
 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
     const struct hda_fixup *fix, int action)
 {
@@ -6080,7 +6096,9 @@ enum {
  ALC662_FIXUP_NO_JACK_DETECT,
  ALC662_FIXUP_ZOTAC_Z68,
  ALC662_FIXUP_INV_DMIC,
+ ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
  ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
+ ALC662_FIXUP_HEADSET_MODE,
  ALC668_FIXUP_HEADSET_MODE,
  ALC662_FIXUP_BASS_MODE4_CHMAP,
  ALC662_FIXUP_BASS_16,
@@ -6273,6 +6291,20 @@ static const struct hda_fixup alc662_fixups[] = {
   .chained = true,
   .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
  },
+ [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
+ .type = HDA_FIXUP_PINS,
+ .v.pins = (const struct hda_pintbl[]) {
+ { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
+ /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
+ { }
+ },
+ .chained = true,
+ .chain_id = ALC662_FIXUP_HEADSET_MODE
+ },
+ [ALC662_FIXUP_HEADSET_MODE] = {
+ .type = HDA_FIXUP_FUNC,
+ .v.func = alc_fixup_headset_mode_alc662,
+ },
  [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
   .type = HDA_FIXUP_PINS,
   .v.pins = (const struct hda_pintbl[]) {
@@ -6432,6 +6464,18 @@ static const struct hda_model_fixup alc662_fixup_models[] = {
  {0x1f, 0x411111f0}

 static co...

Read more...

Changed in linux (Ubuntu):
status: New → In Progress
assignee: nobody → David Henningsson (diwic)
Revision history for this message
Takashi Iwai (tiwai) wrote :
Download full text (3.9 KiB)

At Tue, 12 May 2015 14:38:15 +0200,
David Henningsson wrote:
>
> ALC662 does not need any special verbs to change the jack functionality,
> and enables mic in through the headphone jack mode by changing the
> direction of the headphone pin node.
>
> BugLink: https://bugs.launchpad.net/bugs/1454235
> Signed-off-by: David Henningsson <email address hidden>

Applied, thanks.

Takashi

> ---
> sound/pci/hda/patch_realtek.c | 46 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index ce41271..30ec30f 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -3674,6 +3674,10 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
> alc_process_coef_fw(codec, coef0293);
> snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
> break;
> + case 0x10ec0662:
> + snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
> + snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
> + break;
> case 0x10ec0668:
> alc_write_coef_idx(codec, 0x11, 0x0001);
> snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
> @@ -4012,7 +4016,7 @@ static void alc_update_headset_mode(struct hda_codec *codec)
> if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
> snd_hda_set_pin_ctl_cache(codec, hp_pin,
> AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
> - if (spec->headphone_mic_pin)
> + if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
> snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
> PIN_VREFHIZ);
> }
> @@ -4215,6 +4219,18 @@ static void alc_fixup_dell_xps13(struct hda_codec *codec,
> }
> }
>
> +static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
> + const struct hda_fixup *fix, int action)
> +{
> + struct alc_spec *spec = codec->spec;
> +
> + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
> + spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
> + spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
> + } else
> + alc_fixup_headset_mode(codec, fix, action);
> +}
> +
> static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
> const struct hda_fixup *fix, int action)
> {
> @@ -6080,7 +6096,9 @@ enum {
> ALC662_FIXUP_NO_JACK_DETECT,
> ALC662_FIXUP_ZOTAC_Z68,
> ALC662_FIXUP_INV_DMIC,
> + ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
> ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
> + ALC662_FIXUP_HEADSET_MODE,
> ALC668_FIXUP_HEADSET_MODE,
> ALC662_FIXUP_BASS_MODE4_CHMAP,
> ALC662_FIXUP_BASS_16,
> @@ -6273,6 +6291,20 @@ static const struct hda_fixup alc662_fixups[] = {
> .chained = true,
> .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
> },
> + [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
> + .type = HDA_FIXUP_PINS,
> + .v.pins = (const struct hda_pintbl[]) {
> + { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
> + /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
> + { }
> + },
> + .chained = true,
> + .chain_id = ALC662_FIXUP_HEADSET_MODE
> + },
> + [ALC662_FIXUP_HEADSET_MODE] = {
> + .type = HDA_FIXUP_FUNC,
> + .v.func = alc_fixup_hea...

Read more...

Changed in linux (Ubuntu):
status: In Progress → Fix Committed
Keng-Yu Lin (lexical)
Changed in hwe-next:
status: New → Fix Committed
assignee: nobody → David Henningsson (diwic)
Revision history for this message
David Henningsson (diwic) wrote : Re: [PATCH] ALSA: hda - Disable Headphone Mic boost for ALC662

On 2015-05-28 09:18, Takashi Iwai wrote:
> At Thu, 28 May 2015 09:15:46 +0200,
> David Henningsson wrote:
>>
>> When headphone mic boost is above zero, some 10 - 20 second delay
>> might occur before the headphone mic is operational.
>> Therefore disable the headphone mic boost control (recording gain is
>> sufficient even without it).
>>
>> (Note: this patch is not about the headset mic, it's about the less
>> common mic-in only mode.)
>>
>> BugLink: https://bugs.launchpad.net/bugs/1454235
>> Suggested-by: Kailang Yang <email address hidden>
>> Signed-off-by: David Henningsson <email address hidden>
>> ---
>> sound/pci/hda/patch_realtek.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
>> index d0fa455..87605fc 100644
>> --- a/sound/pci/hda/patch_realtek.c
>> +++ b/sound/pci/hda/patch_realtek.c
>> @@ -4240,6 +4240,10 @@ static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
>> if (action == HDA_FIXUP_ACT_PRE_PROBE) {
>> spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
>> spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
>> +
>> + /* Disable boost for mic-in permanently */
>> + snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
>> + snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
>
> Can we really hard-code NID 0x1b here...?

alc_fixup_headset_mode_alc662 is currently only called from a pin fixup
quirk (via ALC662_FIXUP_DELL_MIC_NO_PRESENCE), and that pin quirk has
headphone at 0x1b, so yes.

It would we better if we could make it more generic, but I think doing
this at HDA_FIXUP_PROBE instead would be too late (the boost control,
paths, etc, would already be created)...?

Do you have a better suggestion?

--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic

Revision history for this message
Takashi Iwai (tiwai) wrote :

At Thu, 28 May 2015 09:25:41 +0200,
David Henningsson wrote:
>
>
>
> On 2015-05-28 09:18, Takashi Iwai wrote:
> > At Thu, 28 May 2015 09:15:46 +0200,
> > David Henningsson wrote:
> >>
> >> When headphone mic boost is above zero, some 10 - 20 second delay
> >> might occur before the headphone mic is operational.
> >> Therefore disable the headphone mic boost control (recording gain is
> >> sufficient even without it).
> >>
> >> (Note: this patch is not about the headset mic, it's about the less
> >> common mic-in only mode.)
> >>
> >> BugLink: https://bugs.launchpad.net/bugs/1454235
> >> Suggested-by: Kailang Yang <email address hidden>
> >> Signed-off-by: David Henningsson <email address hidden>
> >> ---
> >> sound/pci/hda/patch_realtek.c | 4 ++++
> >> 1 file changed, 4 insertions(+)
> >>
> >> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> >> index d0fa455..87605fc 100644
> >> --- a/sound/pci/hda/patch_realtek.c
> >> +++ b/sound/pci/hda/patch_realtek.c
> >> @@ -4240,6 +4240,10 @@ static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
> >> if (action == HDA_FIXUP_ACT_PRE_PROBE) {
> >> spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
> >> spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
> >> +
> >> + /* Disable boost for mic-in permanently */
> >> + snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
> >> + snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
> >
> > Can we really hard-code NID 0x1b here...?
>
> alc_fixup_headset_mode_alc662 is currently only called from a pin fixup
> quirk (via ALC662_FIXUP_DELL_MIC_NO_PRESENCE), and that pin quirk has
> headphone at 0x1b, so yes.

OK, then it'd be better to mention the assumption briefly in a
comment.

> It would we better if we could make it more generic, but I think doing
> this at HDA_FIXUP_PROBE instead would be too late (the boost control,
> paths, etc, would already be created)...?

Right.

> Do you have a better suggestion?

I think the current form is OK, but I wanted to make sure.

Takashi

Revision history for this message
David Henningsson (diwic) wrote :

When headphone mic boost is above zero, some 10 - 20 second delay
might occur before the headphone mic is operational.
Therefore disable the headphone mic boost control (recording gain is
sufficient even without it).

(Note: this patch is not about the headset mic, it's about the less
common mic-in only mode.)

BugLink: https://bugs.launchpad.net/bugs/1454235
Suggested-by: Kailang Yang <email address hidden>
Signed-off-by: David Henningsson <email address hidden>
---
 sound/pci/hda/patch_realtek.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d0fa455..da2d371 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4240,6 +4240,11 @@ static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
  if (action == HDA_FIXUP_ACT_PRE_PROBE) {
   spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
   spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
+
+ /* Disable boost for mic-in permanently. (This code is only called
+ from quirks that guarantee that the headphone is at NID 0x1b.) */
+ snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
+ snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
  } else
   alc_fixup_headset_mode(codec, fix, action);
 }
--
1.9.1

Revision history for this message
Takashi Iwai (tiwai) wrote :

At Thu, 28 May 2015 09:40:23 +0200,
David Henningsson wrote:
>
> When headphone mic boost is above zero, some 10 - 20 second delay
> might occur before the headphone mic is operational.
> Therefore disable the headphone mic boost control (recording gain is
> sufficient even without it).
>
> (Note: this patch is not about the headset mic, it's about the less
> common mic-in only mode.)
>
> BugLink: https://bugs.launchpad.net/bugs/1454235
> Suggested-by: Kailang Yang <email address hidden>
> Signed-off-by: David Henningsson <email address hidden>

Applied, thanks.

Takashi

> ---
> sound/pci/hda/patch_realtek.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index d0fa455..da2d371 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -4240,6 +4240,11 @@ static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
> if (action == HDA_FIXUP_ACT_PRE_PROBE) {
> spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
> spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
> +
> + /* Disable boost for mic-in permanently. (This code is only called
> + from quirks that guarantee that the headphone is at NID 0x1b.) */
> + snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
> + snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
> } else
> alc_fixup_headset_mode(codec, fix, action);
> }
> --
> 1.9.1
>

Changed in linux (Ubuntu):
status: Fix Committed → Fix Released
Changed in hwe-next:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.