History

ALSA: hda/realtek: Apply fixup for Lenovo Yoga Duet 7 properly

It turned out that Lenovo shipped two completely different products with the very same PCI SSID, where both require different quirks; namely, Lenovo C940 has already the fixup for its speaker (ALC298_FIXUP_LENOVO_SPK_VOLUME) with the PCI SSID 17aa:3818, while Yoga Duet 7 has also the very same PCI SSID but requires a different quirk, ALC287_FIXUP_YOGA7_14TIL_SPEAKERS. Fortunately, both are with different codecs (C940 with ALC298 and Duet 7 with ALC287), hence we can apply different fixes by checking the codec ID. This patch implements that special fixup function. For easier handling, the internal function for applying a specific fixup entry is exported as __snd_hda_apply_fixup(), so that it can be called from the codec driver. The rest is simply calling it with a different fixup ID depending on the codec ID.

Takashi Iwai committed 4 years ago

Commit 56ec3e71 parent fe6900b3 files · +28 −4Browse files

Unified · Split

3 files
  1. sound/pci/hda/hda_auto_parser.c +4 −3
  2. sound/pci/hda/hda_local.h +1 −0
  3. sound/pci/hda/patch_realtek.c +23 −1
sound/pci/hda/hda_auto_parser.c+4−3
@@ -819,7 +819,7 @@ static void set_pin_targets(struct hda_codec *codec, · 818 unmodified lines
819819 snd_hda_set_pin_ctl_cache(codec, cfg->nid, cfg->val);
820820 }
821821
822−static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
822+void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth)
823823 {
824824 const char *modelname = codec->fixup_name;
825825
@@ -829,7 +829,7 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth) · 3 unmodified lines
829829 if (++depth > 10)
830830 break;
831831 if (fix->chained_before)
832− apply_fixup(codec, fix->chain_id, action, depth + 1);
832+ __snd_hda_apply_fixup(codec, fix->chain_id, action, depth + 1);
833833
834834 switch (fix->type) {
835835 case HDA_FIXUP_PINS:
@@ -870,6 +870,7 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth) · 34 unmodified lines
870870 id = fix->chain_id;
871871 }
872872 }
873+EXPORT_SYMBOL_GPL(__snd_hda_apply_fixup);
873874
874875 /**
875876 * snd_hda_apply_fixup - Apply the fixup chain with the given action
@@ -879,7 +880,7 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth) · 3 unmodified lines
879880 void snd_hda_apply_fixup(struct hda_codec *codec, int action)
880881 {
881882 if (codec->fixup_list)
882− apply_fixup(codec, codec->fixup_id, action, 0);
883+ __snd_hda_apply_fixup(codec, codec->fixup_id, action, 0);
883884 }
884885 EXPORT_SYMBOL_GPL(snd_hda_apply_fixup);
885886
sound/pci/hda/hda_local.h+1−0
@@ -348,6 +348,7 @@ void snd_hda_apply_verbs(struct hda_codec *codec); · 347 unmodified lines
348348 void snd_hda_apply_pincfgs(struct hda_codec *codec,
349349 const struct hda_pintbl *cfg);
350350 void snd_hda_apply_fixup(struct hda_codec *codec, int action);
351+void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth);
351352 void snd_hda_pick_fixup(struct hda_codec *codec,
352353 const struct hda_model_fixup *models,
353354 const struct snd_pci_quirk *quirk,
sound/pci/hda/patch_realtek.c+23−1
@@ -7004,6 +7004,7 @@ enum { · 7003 unmodified lines
70047004 ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
70057005 ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
70067006 ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
7007+ ALC298_FIXUP_LENOVO_C940_DUET7,
70077008 ALC287_FIXUP_13S_GEN2_SPEAKERS,
70087009 ALC256_FIXUP_SET_COEF_DEFAULTS,
70097010 ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
@@ -7022,6 +7023,23 @@ enum { · 12 unmodified lines
70227023 ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE,
70237024 };
70247025
7026+/* A special fixup for Lenovo C940 and Yoga Duet 7;
7027+ * both have the very same PCI SSID, and we need to apply different fixups
7028+ * depending on the codec ID
7029+ */
7030+static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
7031+ const struct hda_fixup *fix,
7032+ int action)
7033+{
7034+ int id;
7035+
7036+ if (codec->core.vendor_id == 0x10ec0298)
7037+ id = ALC298_FIXUP_LENOVO_SPK_VOLUME; /* C940 */
7038+ else
7039+ id = ALC287_FIXUP_YOGA7_14ITL_SPEAKERS; /* Duet 7 */
7040+ __snd_hda_apply_fixup(codec, id, action, 0);
7041+}
7042+
70257043 static const struct hda_fixup alc269_fixups[] = {
70267044 [ALC269_FIXUP_GPIO2] = {
70277045 .type = HDA_FIXUP_FUNC,
@@ -8721,6 +8739,10 @@ static const struct hda_fixup alc269_fixups[] = { · 1693 unmodified lines
87218739 .chained = true,
87228740 .chain_id = ALC269_FIXUP_HEADSET_MODE,
87238741 },
8742+ [ALC298_FIXUP_LENOVO_C940_DUET7] = {
8743+ .type = HDA_FIXUP_FUNC,
8744+ .v.func = alc298_fixup_lenovo_c940_duet7,
8745+ },
87248746 [ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
87258747 .type = HDA_FIXUP_VERBS,
87268748 .v.verbs = (const struct hda_verb[]) {
@@ -9274,7 +9296,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 547 unmodified lines
92749296 SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
92759297 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo Yoga DuetITL 2021", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
92769298 SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9277− SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
9299+ SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940 / Yoga Duet 7", ALC298_FIXUP_LENOVO_C940_DUET7),
92789300 SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
92799301 SND_PCI_QUIRK(0x17aa, 0x3820, "Yoga Duet 7 13ITL6", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
92809302 SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t