ALSA: hda - Fix headset mic support for Asus X101CH
authorDavid Henningsson <david.henningsson@canonical.com>
Mon, 15 Apr 2013 10:50:02 +0000 (12:50 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 15 Apr 2013 14:03:53 +0000 (16:03 +0200)
With this patch, a TRRS headset mic cannot be successfully detected
on the Asus X101CH, and we can also distinguish between headphone
and headset automatically.

Buglink: https://bugs.launchpad.net/bugs/1169138
Co-authored-by: Kailang <kailang@realtek.com>
Tested-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_realtek.c

index cd5f9e9f8838bc4b6d9ad81fa170b1016fb64e50..cba9dc6dc38b2ad4316ce743b0b02998946a775f 100644 (file)
@@ -2699,6 +2699,34 @@ static void alc269_fixup_quanta_mute(struct hda_codec *codec,
        spec->gen.automute_hook = alc269_quanta_automute;
 }
 
+static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
+                                        struct hda_jack_tbl *jack)
+{
+       struct alc_spec *spec = codec->spec;
+       int vref;
+       msleep(200);
+       snd_hda_gen_hp_automute(codec, jack);
+
+       vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
+       msleep(100);
+       snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
+                           vref);
+       msleep(500);
+       snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
+                           vref);
+}
+
+static void alc269_fixup_x101_headset_mic(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_automute_hook = alc269_x101_hp_automute_hook;
+       }
+}
+
+
 /* update mute-LED according to the speaker mute state via mic VREF pin */
 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
 {
@@ -3156,6 +3184,9 @@ enum {
        ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
        ALC269_FIXUP_HEADSET_MODE,
        ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
+       ALC269_FIXUP_ASUS_X101_FUNC,
+       ALC269_FIXUP_ASUS_X101_VERB,
+       ALC269_FIXUP_ASUS_X101,
        ALC271_FIXUP_AMIC_MIC2,
        ALC271_FIXUP_HP_GATE_MIC_JACK,
        ALC269_FIXUP_ACER_AC700,
@@ -3344,6 +3375,30 @@ static const struct hda_fixup alc269_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_headset_mode_no_hp_mic,
        },
+       [ALC269_FIXUP_ASUS_X101_FUNC] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc269_fixup_x101_headset_mic,
+       },
+       [ALC269_FIXUP_ASUS_X101_VERB] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
+                       {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
+                       {0x20, AC_VERB_SET_PROC_COEF,  0x0310},
+                       { }
+               },
+               .chained = true,
+               .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
+       },
+       [ALC269_FIXUP_ASUS_X101] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x18, 0x04a1182c }, /* Headset mic */
+                       { }
+               },
+               .chained = true,
+               .chain_id = ALC269_FIXUP_ASUS_X101_VERB
+       },
        [ALC271_FIXUP_AMIC_MIC2] = {
                .type = HDA_FIXUP_PINS,
                .v.pins = (const struct hda_pintbl[]) {
@@ -3412,6 +3467,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
+       SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
        SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
        SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
        SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),