Skip to content

Commit 1e70776

Browse files
KailangYangtiwai
authored andcommitted
ALSA: hda/realtek - Set GPIO3 to default at S4 state for Thinkpad with ALC1318
There is a chance of damaging the IC when S4 resume. Add safe mode for no stream to disable GPIO3. Thinkpad with ALC1318 platform need to add this workaround. Signed-off-by: Kailang Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent c158cf9 commit 1e70776

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

sound/pci/hda/patch_realtek.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,8 @@ static void alc_pre_init(struct hda_codec *codec)
920920
((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
921921
#define is_s4_resume(codec) \
922922
((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
923+
#define is_s4_suspend(codec) \
924+
((codec)->core.dev.power.power_state.event == PM_EVENT_FREEZE)
923925

924926
static int alc_init(struct hda_codec *codec)
925927
{
@@ -7183,6 +7185,44 @@ static void alc245_fixup_hp_spectre_x360_eu0xxx(struct hda_codec *codec,
71837185
alc245_fixup_hp_gpio_led(codec, fix, action);
71847186
}
71857187

7188+
/*
7189+
* ALC287 PCM hooks
7190+
*/
7191+
static void alc287_alc1318_playback_pcm_hook(struct hda_pcm_stream *hinfo,
7192+
struct hda_codec *codec,
7193+
struct snd_pcm_substream *substream,
7194+
int action)
7195+
{
7196+
alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MLK to GPIO3 */
7197+
switch (action) {
7198+
case HDA_GEN_PCM_ACT_OPEN:
7199+
alc_write_coefex_idx(codec, 0x5a, 0x00, 0x954f); /* write gpio3 to high */
7200+
break;
7201+
case HDA_GEN_PCM_ACT_CLOSE:
7202+
alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
7203+
break;
7204+
}
7205+
}
7206+
7207+
static void alc287_s4_power_gpio3_default(struct hda_codec *codec)
7208+
{
7209+
if (is_s4_suspend(codec)) {
7210+
alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MLK to GPIO3 */
7211+
alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
7212+
}
7213+
}
7214+
7215+
static void alc287_fixup_lenovo_thinkpad_with_alc1318(struct hda_codec *codec,
7216+
const struct hda_fixup *fix, int action)
7217+
{
7218+
struct alc_spec *spec = codec->spec;
7219+
7220+
if (action != HDA_FIXUP_ACT_PRE_PROBE)
7221+
return;
7222+
spec->power_hook = alc287_s4_power_gpio3_default;
7223+
spec->gen.pcm_playback_hook = alc287_alc1318_playback_pcm_hook;
7224+
}
7225+
71867226

71877227
enum {
71887228
ALC269_FIXUP_GPIO2,
@@ -7470,7 +7510,8 @@ enum {
74707510
ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC,
74717511
ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1,
74727512
ALC285_FIXUP_ASUS_GU605_SPI_2_HEADSET_MIC,
7473-
ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1
7513+
ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1,
7514+
ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318,
74747515
};
74757516

74767517
/* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9726,6 +9767,12 @@ static const struct hda_fixup alc269_fixups[] = {
97269767
.chained = true,
97279768
.chain_id = ALC285_FIXUP_ASUS_GA403U,
97289769
},
9770+
[ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318] = {
9771+
.type = HDA_FIXUP_FUNC,
9772+
.v.func = alc287_fixup_lenovo_thinkpad_with_alc1318,
9773+
.chained = true,
9774+
.chain_id = ALC269_FIXUP_THINKPAD_ACPI
9775+
},
97299776
};
97309777

97319778
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -10394,6 +10441,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
1039410441
SND_PCI_QUIRK(0x17aa, 0x2318, "Thinkpad Z13 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
1039510442
SND_PCI_QUIRK(0x17aa, 0x2319, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
1039610443
SND_PCI_QUIRK(0x17aa, 0x231a, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
10444+
SND_PCI_QUIRK(0x17aa, 0x231e, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
10445+
SND_PCI_QUIRK(0x17aa, 0x231f, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
1039710446
SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
1039810447
SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
1039910448
SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),

0 commit comments

Comments
 (0)