]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - sound/pci/hda/patch_realtek.c
Merge tag 'sound-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
[linux.git] / sound / pci / hda / patch_realtek.c
index 2c1942dc6147d5623f7881970d9645de7d458b68..6f3a35949cdda72ad435187ccfe363964d7ea1e0 100644 (file)
@@ -821,6 +821,8 @@ static void alc_pre_init(struct hda_codec *codec)
        alc_fill_eapd_coef(codec);
 }
 
+#define is_s3_resume(codec) \
+       ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
 #define is_s4_resume(codec) \
        ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
 
@@ -2446,9 +2448,10 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
-       SND_PCI_QUIRK(0x1558, 0x96e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
-       SND_PCI_QUIRK(0x1558, 0x97e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
-       SND_PCI_QUIRK(0x1558, 0x65d1, "Tuxedo Book XC1509", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
+       SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
+       SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
        SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
        SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
@@ -4118,18 +4121,19 @@ static struct coef_fw alc225_pre_hsmode[] = {
 static void alc_headset_mode_unplugged(struct hda_codec *codec)
 {
        static struct coef_fw coef0255[] = {
+               WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
                WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
                UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
                WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
                WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
                {}
        };
-       static struct coef_fw coef0255_1[] = {
-               WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
-               {}
-       };
        static struct coef_fw coef0256[] = {
                WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
+               WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
+               WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
+               WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
+               UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
                {}
        };
        static struct coef_fw coef0233[] = {
@@ -4192,13 +4196,11 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
 
        switch (codec->core.vendor_id) {
        case 0x10ec0255:
-               alc_process_coef_fw(codec, coef0255_1);
                alc_process_coef_fw(codec, coef0255);
                break;
        case 0x10ec0236:
        case 0x10ec0256:
                alc_process_coef_fw(codec, coef0256);
-               alc_process_coef_fw(codec, coef0255);
                break;
        case 0x10ec0234:
        case 0x10ec0274:
@@ -4251,6 +4253,12 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
                WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
                {}
        };
+       static struct coef_fw coef0256[] = {
+               UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
+               WRITE_COEFEX(0x57, 0x03, 0x09a3),
+               WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
+               {}
+       };
        static struct coef_fw coef0233[] = {
                UPDATE_COEF(0x35, 0, 1<<14),
                WRITE_COEF(0x06, 0x2100),
@@ -4298,14 +4306,19 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
        };
 
        switch (codec->core.vendor_id) {
-       case 0x10ec0236:
        case 0x10ec0255:
-       case 0x10ec0256:
                alc_write_coef_idx(codec, 0x45, 0xc489);
                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
                alc_process_coef_fw(codec, coef0255);
                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
                break;
+       case 0x10ec0236:
+       case 0x10ec0256:
+               alc_write_coef_idx(codec, 0x45, 0xc489);
+               snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
+               alc_process_coef_fw(codec, coef0256);
+               snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
+               break;
        case 0x10ec0234:
        case 0x10ec0274:
        case 0x10ec0294:
@@ -4387,6 +4400,14 @@ static void alc_headset_mode_default(struct hda_codec *codec)
                WRITE_COEF(0x49, 0x0049),
                {}
        };
+       static struct coef_fw coef0256[] = {
+               WRITE_COEF(0x45, 0xc489),
+               WRITE_COEFEX(0x57, 0x03, 0x0da3),
+               WRITE_COEF(0x49, 0x0049),
+               UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
+               WRITE_COEF(0x06, 0x6100),
+               {}
+       };
        static struct coef_fw coef0233[] = {
                WRITE_COEF(0x06, 0x2100),
                WRITE_COEF(0x32, 0x4ea3),
@@ -4437,11 +4458,16 @@ static void alc_headset_mode_default(struct hda_codec *codec)
                alc_process_coef_fw(codec, alc225_pre_hsmode);
                alc_process_coef_fw(codec, coef0225);
                break;
-       case 0x10ec0236:
        case 0x10ec0255:
-       case 0x10ec0256:
                alc_process_coef_fw(codec, coef0255);
                break;
+       case 0x10ec0236:
+       case 0x10ec0256:
+               alc_write_coef_idx(codec, 0x1b, 0x0e4b);
+               alc_write_coef_idx(codec, 0x45, 0xc089);
+               msleep(50);
+               alc_process_coef_fw(codec, coef0256);
+               break;
        case 0x10ec0234:
        case 0x10ec0274:
        case 0x10ec0294:
@@ -4485,8 +4511,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
        };
        static struct coef_fw coef0256[] = {
                WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
-               WRITE_COEF(0x1b, 0x0c6b),
-               WRITE_COEFEX(0x57, 0x03, 0x8ea6),
+               WRITE_COEF(0x1b, 0x0e6b),
                {}
        };
        static struct coef_fw coef0233[] = {
@@ -4604,8 +4629,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
        };
        static struct coef_fw coef0256[] = {
                WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
-               WRITE_COEF(0x1b, 0x0c6b),
-               WRITE_COEFEX(0x57, 0x03, 0x8ea6),
+               WRITE_COEF(0x1b, 0x0e6b),
                {}
        };
        static struct coef_fw coef0233[] = {
@@ -4737,13 +4761,37 @@ static void alc_determine_headset_type(struct hda_codec *codec)
        };
 
        switch (codec->core.vendor_id) {
-       case 0x10ec0236:
        case 0x10ec0255:
+               alc_process_coef_fw(codec, coef0255);
+               msleep(300);
+               val = alc_read_coef_idx(codec, 0x46);
+               is_ctia = (val & 0x0070) == 0x0070;
+               break;
+       case 0x10ec0236:
        case 0x10ec0256:
+               alc_write_coef_idx(codec, 0x1b, 0x0e4b);
+               alc_write_coef_idx(codec, 0x06, 0x6104);
+               alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
+
+               snd_hda_codec_write(codec, 0x21, 0,
+                           AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
+               msleep(80);
+               snd_hda_codec_write(codec, 0x21, 0,
+                           AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
+
                alc_process_coef_fw(codec, coef0255);
                msleep(300);
                val = alc_read_coef_idx(codec, 0x46);
                is_ctia = (val & 0x0070) == 0x0070;
+
+               alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
+               alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
+
+               snd_hda_codec_write(codec, 0x21, 0,
+                           AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+               msleep(80);
+               snd_hda_codec_write(codec, 0x21, 0,
+                           AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
                break;
        case 0x10ec0234:
        case 0x10ec0274:
@@ -4888,6 +4936,8 @@ static void alc_update_headset_mode(struct hda_codec *codec)
        switch (new_headset_mode) {
        case ALC_HEADSET_MODE_UNPLUGGED:
                alc_headset_mode_unplugged(codec);
+               spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
+               spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
                spec->gen.hp_jack_present = false;
                break;
        case ALC_HEADSET_MODE_HEADSET:
@@ -4930,8 +4980,6 @@ static void alc_update_headset_mode_hook(struct hda_codec *codec,
 static void alc_update_headset_jack_cb(struct hda_codec *codec,
                                       struct hda_jack_callback *jack)
 {
-       struct alc_spec *spec = codec->spec;
-       spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
        snd_hda_gen_hp_automute(codec, jack);
 }
 
@@ -4968,7 +5016,10 @@ static void alc_fixup_headset_mode(struct hda_codec *codec,
                alc_probe_headset_mode(codec);
                break;
        case HDA_FIXUP_ACT_INIT:
-               spec->current_headset_mode = 0;
+               if (is_s3_resume(codec) || is_s4_resume(codec)) {
+                       spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
+                       spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
+               }
                alc_update_headset_mode(codec);
                break;
        }
@@ -5734,7 +5785,7 @@ enum {
        ALC298_FIXUP_TPT470_DOCK,
        ALC255_FIXUP_DUMMY_LINEOUT_VERB,
        ALC255_FIXUP_DELL_HEADSET_MIC,
-       ALC256_FIXUP_HUAWEI_MBXP_PINS,
+       ALC256_FIXUP_HUAWEI_MACH_WX9_PINS,
        ALC295_FIXUP_HP_X360,
        ALC221_FIXUP_HP_HEADSET_MIC,
        ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
@@ -6025,7 +6076,7 @@ static const struct hda_fixup alc269_fixups[] = {
                .chained = true,
                .chain_id = ALC269_FIXUP_HEADSET_MIC
        },
-       [ALC256_FIXUP_HUAWEI_MBXP_PINS] = {
+       [ALC256_FIXUP_HUAWEI_MACH_WX9_PINS] = {
                .type = HDA_FIXUP_PINS,
                .v.pins = (const struct hda_pintbl[]) {
                        {0x12, 0x90a60130},
@@ -7024,6 +7075,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
        SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
        SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
+       SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
        SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
        SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
        SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
@@ -7050,9 +7102,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
        SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
        SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
-       SND_PCI_QUIRK(0x19e5, 0x3200, "Huawei MBX", ALC255_FIXUP_MIC_MUTE_LED),
-       SND_PCI_QUIRK(0x19e5, 0x3201, "Huawei MBX", ALC255_FIXUP_MIC_MUTE_LED),
-       SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MBXP", ALC256_FIXUP_HUAWEI_MBXP_PINS),
+       SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
        SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
 
 #if 0
@@ -7111,6 +7161,7 @@ static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
        SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
        SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
        SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
+       SND_PCI_QUIRK_VENDOR(0x19e5, "Huawei Matebook", ALC255_FIXUP_MIC_MUTE_LED),
        {}
 };
 
@@ -7693,7 +7744,7 @@ static int patch_alc269(struct hda_codec *codec)
 
        spec = codec->spec;
        spec->gen.shared_mic_vref_pin = 0x18;
-       codec->power_save_node = 1;
+       codec->power_save_node = 0;
 
 #ifdef CONFIG_PM
        codec->patch_ops.suspend = alc269_suspend;