1 From ad7cc2d41b7a8d0c5c5ecff37c3de7a4e137b3a6 Mon Sep 17 00:00:00 2001
2 From: Cameron Berkenpas <cam@neo-zeon.de>
3 Date: Mon, 13 Sep 2021 14:26:29 -0700
4 Subject: ALSA: hda/realtek: Quirks to enable speaker output for Lenovo Legion 7i 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 laptops.
6 From: Cameron Berkenpas <cam@neo-zeon.de>
8 commit ad7cc2d41b7a8d0c5c5ecff37c3de7a4e137b3a6 upstream.
10 This patch initializes and enables speaker output on the Lenovo Legion 7i
11 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 series of laptops using the
12 HDA verb sequence specific to each model.
14 Speaker automute is suppressed for the Lenovo Legion 7i 15IMHG05 to avoid
15 breaking speaker output on resume and when devices are unplugged from its
18 Thanks to: Andreas Holzer, Vincent Morel, sycxyc, Max Christian Pohle and
19 all others that helped.
21 [ minor coding style fixes by tiwai ]
23 BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=208555
24 Signed-off-by: Cameron Berkenpas <cam@neo-zeon.de>
25 Cc: <stable@vger.kernel.org>
26 Link: https://lore.kernel.org/r/20210913212627.339362-1-cam@neo-zeon.de
27 Signed-off-by: Takashi Iwai <tiwai@suse.de>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 sound/pci/hda/patch_realtek.c | 129 ++++++++++++++++++++++++++++++++++++++++++
31 1 file changed, 129 insertions(+)
33 --- a/sound/pci/hda/patch_realtek.c
34 +++ b/sound/pci/hda/patch_realtek.c
35 @@ -6375,6 +6375,20 @@ static void alc_fixup_thinkpad_acpi(stru
36 hda_fixup_thinkpad_acpi(codec, fix, action);
39 +/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
40 +static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
41 + const struct hda_fixup *fix,
44 + struct alc_spec *spec = codec->spec;
47 + case HDA_FIXUP_ACT_PRE_PROBE:
48 + spec->gen.suppress_auto_mute = 1;
53 /* for alc295_fixup_hp_top_speakers */
54 #include "hp_x360_helper.c"
56 @@ -6591,6 +6605,10 @@ enum {
57 ALC623_FIXUP_LENOVO_THINKSTATION_P340,
58 ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
59 ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
60 + ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
61 + ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
62 + ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
63 + ALC287_FIXUP_13S_GEN2_SPEAKERS
66 static const struct hda_fixup alc269_fixups[] = {
67 @@ -8175,6 +8193,113 @@ static const struct hda_fixup alc269_fix
69 .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
71 + [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
72 + .type = HDA_FIXUP_VERBS,
73 + //.v.verbs = legion_15imhg05_coefs,
74 + .v.verbs = (const struct hda_verb[]) {
75 + // set left speaker Legion 7i.
76 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
77 + { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
79 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
80 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
81 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
82 + { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
83 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
85 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
86 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
87 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
88 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
89 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
91 + // set right speaker Legion 7i.
92 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
93 + { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
95 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
96 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
97 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
98 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
99 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
101 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
102 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
103 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
104 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
105 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
109 + .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
111 + [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
112 + .type = HDA_FIXUP_FUNC,
113 + .v.func = alc287_fixup_legion_15imhg05_speakers,
115 + .chain_id = ALC269_FIXUP_HEADSET_MODE,
117 + [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
118 + .type = HDA_FIXUP_VERBS,
119 + .v.verbs = (const struct hda_verb[]) {
120 + // set left speaker Yoga 7i.
121 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
122 + { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
124 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
125 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
126 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
127 + { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
128 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
130 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
131 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
132 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
133 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
134 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
136 + // set right speaker Yoga 7i.
137 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
138 + { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
140 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
141 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
142 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
143 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
144 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
146 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
147 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
148 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
149 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
150 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
154 + .chain_id = ALC269_FIXUP_HEADSET_MODE,
156 + [ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
157 + .type = HDA_FIXUP_VERBS,
158 + .v.verbs = (const struct hda_verb[]) {
159 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
160 + { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
161 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
162 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
163 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
164 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
165 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
166 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
167 + { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
168 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
169 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
170 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
171 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
172 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
176 + .chain_id = ALC269_FIXUP_HEADSET_MODE,
180 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
181 @@ -8567,6 +8692,10 @@ static const struct snd_pci_quirk alc269
182 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
183 SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
184 SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
185 + SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
186 + SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
187 + SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
188 + SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
189 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
190 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
191 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),