diff --git a/sound/pci/hda/legion_15imhg05_helper.c b/sound/pci/hda/legion_15imhg05_helper.c new file mode 100644 index 000000000000..6ead999ec3c9 --- /dev/null +++ b/sound/pci/hda/legion_15imhg05_helper.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Fixes for Lenovo Legion 15IMHg05 speaker output. */ + +static const struct hda_verb legion_15imhg05_coefs[] = { +{0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x41 }, +{0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x2 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x0 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x0 }, +{0x20, 0x4b0, 0x20 }, + +// Set right speaker for Legion 7i. +{0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x42 }, + +{0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, +{0x20, AC_VERB_SET_PROC_COEF, 0xc }, +{0x20, AC_VERB_SET_PROC_COEF, 0x0 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x2a }, +{0x20, 0x4b0, 0x20 }, +{0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x2 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x0 }, +{0x20, AC_VERB_SET_PROC_COEF, 0x0 }, +{0x20, 0x4b0, 0x20 }, +{} +}; + +static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, + const struct hda_fixup *fix, + int action) +{ + struct alc_spec *spec = codec->spec; + + switch (action) { + case HDA_FIXUP_ACT_INIT: + spec->gen.automute_speaker = 0; + break; + } +} diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index e46e43dac6bf..eb7da12584db 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6352,6 +6352,9 @@ static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, /* for alc285_fixup_ideapad_s740_coef() */ #include "ideapad_s740_helper.c" +/* For alc287_fixup_legion_15imhg05_speakers() */ +#include "legion_15imhg05_helper.c" + enum { ALC269_FIXUP_GPIO2, ALC269_FIXUP_SONY_VAIO, @@ -6561,6 +6564,8 @@ enum { ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, ALC623_FIXUP_LENOVO_THINKSTATION_P340, ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, + ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS, + ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, }; static const struct hda_fixup alc269_fixups[] = { @@ -8142,6 +8147,18 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC }, + [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = legion_15imhg05_coefs, + .chained = true, + .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, + }, + [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc287_fixup_legion_15imhg05_speakers, + .chained = true, + .chain_id = ALC269_FIXUP_HEADSET_MODE, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -8520,6 +8537,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), + SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),