diff mbox series

ALSA: hda/realtek: Quirks to enable speaker output for Lenovo Legion 7i 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 laptops.

Message ID 20210912230715.156221-1-cam@neo-zeon.de
State Accepted
Commit ad7cc2d41b7a8d0c5c5ecff37c3de7a4e137b3a6
Headers show
Series ALSA: hda/realtek: Quirks to enable speaker output for Lenovo Legion 7i 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 laptops. | expand

Commit Message

Cameron Berkenpas Sept. 12, 2021, 11:07 p.m. UTC
This patch initializes and enables speaker output on the Lenovo Legion 7i
15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 series of laptops using the
HDA verb sequence specific to each model.

Speaker automute is disabled for the Lenovo Legion 7i 15IMHG05 to avoid
breaking speaker output on resume and when devices are unplugged from its
headphone jack.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=208555
Signed-off-by: Cameron Berkenpas <cam@neo-zeon.de>
---
 sound/pci/hda/patch_realtek.c | 129 ++++++++++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)

Comments

Takashi Iwai Sept. 13, 2021, 12:27 p.m. UTC | #1
On Mon, 13 Sep 2021 13:59:08 +0200,
Cameron Berkenpas wrote:
> 
> 
> I'll test thisĀ  and re-submit today or tomorrow. Should I re-submit
> the patch entirely? Ie, a new email thread with a [PATCH v2] subject?

Yes, a resubmission of a v2 patch would be appreciated.

> Thanks for the fast response! It actually made it to my inbox this time.

Heh :)


thanks,

Takashi

> 
> -Cameron
> 
> On 9/12/21 10:28 PM, Takashi Iwai wrote:
> > On Mon, 13 Sep 2021 01:07:16 +0200,
> > Cameron Berkenpas wrote:
> >> This patch initializes and enables speaker output on the Lenovo Legion 7i
> >> 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 series of laptops using the
> >> HDA verb sequence specific to each model.
> >>
> >> Speaker automute is disabled for the Lenovo Legion 7i 15IMHG05 to avoid
> >> breaking speaker output on resume and when devices are unplugged from its
> >> headphone jack.
> >>
> >> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=208555
> >> Signed-off-by: Cameron Berkenpas <cam@neo-zeon.de>
> > Thanks for the patch.  This version looks almost good, but just one
> > thing:
> >
> >> +/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
> >> +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;
> > This flag is effective only until "Auto-Mute Mode" mixer control is
> > changed, so it's not persistent.  If you'd need to disable the
> > auto-mute feature, set spec->gen.suppress_auto_mute=1 instead.
> >
> >
> > thanks,
> >
> > Takashi
>
Cameron Berkenpas Sept. 13, 2021, 6:51 p.m. UTC | #2
Alas,

Changing to:
spec->gen.suppress_auto_mute 0 =1

Results in audio output from the speakers after removal of the headset. Any ideas why or what we might do?

I'll changing the "Auto-Mute Mode" to confirm what happens when using:
spec->gen.automute_speaker = 0;

Thanks!



On 9/13/21 5:27 AM, Takashi Iwai wrote:
> This flag is effective only until "Auto-Mute Mode" mixer control is
> changed, so it's not persistent.  If you'd need to disable the
> auto-mute feature, set spec->gen.suppress_auto_mute=1 instead.
diff mbox series

Patch

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8b7a389b6aed..7e94107e8e59 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6429,6 +6429,20 @@  static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
 	hda_fixup_thinkpad_acpi(codec, fix, action);
 }
 
+/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
+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;
+	}
+}
+
 /* for alc295_fixup_hp_top_speakers */
 #include "hp_x360_helper.c"
 
@@ -6646,6 +6660,10 @@  enum {
 	ALC623_FIXUP_LENOVO_THINKSTATION_P340,
 	ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
 	ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
+	ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
+	ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
+	ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
+	ALC287_FIXUP_13S_GEN2_SPEAKERS
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -8236,6 +8254,113 @@  static const struct hda_fixup alc269_fixups[] = {
 		.chained = true,
 		.chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
 	},
+	[ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
+		.type = HDA_FIXUP_VERBS,
+		//.v.verbs = legion_15imhg05_coefs,
+		.v.verbs = (const struct hda_verb[]) {
+			 // set left speaker Legion 7i.
+			 {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, 0xc },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x0 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x1a },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
+
+			 {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, AC_VERB_SET_PROC_COEF, 0xb020 },
+
+			 // set right speaker 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, AC_VERB_SET_PROC_COEF, 0xb020 },
+
+			 {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, AC_VERB_SET_PROC_COEF, 0xb020 },
+			 {}
+		},
+		.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,
+	},
+	[ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
+		.type = HDA_FIXUP_VERBS,
+		.v.verbs = (const struct hda_verb[]) {
+			 // set left speaker Yoga 7i.
+			 {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, 0xc },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x0 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x1a },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
+
+			 {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, AC_VERB_SET_PROC_COEF, 0xb020 },
+
+			 // set right speaker Yoga 7i.
+			 {0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x46 },
+
+			 {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, AC_VERB_SET_PROC_COEF, 0xb020 },
+
+			 {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, AC_VERB_SET_PROC_COEF, 0xb020 },
+			 {}
+		},
+		.chained = true,
+		.chain_id = ALC269_FIXUP_HEADSET_MODE,
+	},
+	[ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
+		.type = HDA_FIXUP_VERBS,
+		.v.verbs = (const struct hda_verb[]) {
+		         {0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x41 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x2 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x0 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x0 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
+			 {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, 0x2 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x0 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0x0 },
+			 {0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
+			 {}
+		},
+		.chained = true,
+		.chain_id = ALC269_FIXUP_HEADSET_MODE,
+	},
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -8630,6 +8755,10 @@  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, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
+	SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
+	SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_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),