diff -Naur linux-source-4.15.0-orig/sound/pci/hda/patch_realtek.c linux-source-4.15.0/sound/pci/hda/patch_realtek.c --- linux-source-4.15.0-orig/sound/pci/hda/patch_realtek.c 2019-01-29 17:27:42.000000000 +0100 +++ linux-source-4.15.0/sound/pci/hda/patch_realtek.c 2019-02-24 19:38:11.315339146 +0100 @@ -3578,6 +3578,64 @@ vref); } +struct hda_alc298_mbxinit { + unsigned char value_0x23; + unsigned char value_0x25; +}; + +void alc298_stereo_seq(struct hda_codec *codec, + struct hda_alc298_mbxinit *initval, int first) +{ + snd_hda_codec_write(codec, 0x6, 0, 0x73e, 0x0); + alc_write_coef_idx(codec, 0x26, 0xb000); + + if (first) + snd_hda_codec_write(codec, 0x21, 0, 0xf09, 0x0); + + snd_hda_codec_write(codec, 0x6, 0, 0x73e, 0x80); + alc_write_coef_idx(codec, 0x26, 0xf000); + alc_write_coef_idx(codec, 0x23, initval->value_0x23); + + if (initval->value_0x23 != 0x1e) + alc_write_coef_idx(codec, 0x25, initval->value_0x25); + + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26); + snd_hda_codec_write(codec, 0x20, 0, 0x4b0, 0x10); +} + +void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + // Initialization magic + static struct hda_alc298_mbxinit dac_init[] = { + {0xc, 0x0}, {0xd, 0x0}, {0xe, 0x0}, {0xf, 0x0}, + {0x10, 0x0}, {0x1a, 0x40}, {0x1b, 0x82}, {0x1c, 0x0}, + {0x1d, 0x0}, {0x1e, 0x0}, {0x1f, 0x0}, + {0x20, 0xc2}, {0x21, 0xc8}, {0x22, 0x26}, {0x23, 0x24}, + {0x27, 0xff}, {0x28, 0xff}, {0x29, 0xff}, {0x2a, 0x8f}, + {0x2b, 0x2}, {0x2c, 0x48}, {0x2d, 0x34}, {0x2e, 0x0}, + {0x2f, 0x0}, + {0x30, 0x0}, {0x31, 0x0}, {0x32, 0x0}, {0x33, 0x0}, + {0x34, 0x0}, {0x35, 0x1}, {0x36, 0x93}, {0x37, 0xc}, + {0x38, 0x0}, {0x39, 0x0}, {0x3a, 0xf8}, {0x38, 0x80}, + {} + }; + struct hda_alc298_mbxinit *seq = dac_init; + + // Start + snd_hda_codec_write(codec, 0x6, 0, 0x73e, 0x0); + snd_hda_codec_write(codec, 0x6, 0, 0x73e, 0x80); + alc_write_coef_idx(codec, 0x26, 0xf000); + alc_write_coef_idx(codec, 0x22, 0x31); + alc_write_coef_idx(codec, 0x23, 0xb); + alc_write_coef_idx(codec, 0x25, 0x0); + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26); + snd_hda_codec_write(codec, 0x20, 0, 0x4b0, 0x10); + + for (; seq->value_0x23; seq++) + alc298_stereo_seq(codec, seq, seq == dac_init); +} + static void alc269_fixup_x101_headset_mic(struct hda_codec *codec, const struct hda_fixup *fix, int action) { @@ -5522,6 +5580,7 @@ ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, ALC298_FIXUP_TPT470_DOCK, ALC255_FIXUP_DUMMY_LINEOUT_VERB, + ALC298_FIXUP_HUAWEI_MBX_STEREO, ALC255_FIXUP_DELL_HEADSET_MIC, ALC221_FIXUP_HP_HEADSET_MIC, ALC285_FIXUP_LENOVO_HEADPHONE_NOISE, @@ -5795,6 +5854,12 @@ .chained = true, .chain_id = ALC269_FIXUP_HEADSET_MIC }, + [ALC298_FIXUP_HUAWEI_MBX_STEREO] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc298_fixup_huawei_mbx_stereo, + .chained = true, + .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED + }, [ALC269_FIXUP_ASUS_X101_FUNC] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_x101_headset_mic, @@ -6638,6 +6703,8 @@ 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", ALC298_FIXUP_HUAWEI_MBX_STEREO), + SND_PCI_QUIRK(0x19e5, 0x3201, "Huawei MBX", ALC298_FIXUP_HUAWEI_MBX_STEREO), SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ #if 0