All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: Thinkpad with ALC1318 has a chance of damaging the IC
@ 2024-04-15  9:27 Kailang
  2024-04-18  6:21 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Kailang @ 2024-04-15  9:27 UTC (permalink / raw)
  To: Takashi Iwai (tiwai@suse.de); +Cc:  (alsa-devel@alsa-project.org)

Hi Takashi,

Please don't apply this patch.
They want to add stream open to enable GPIO3 functions.

BR,
Kailang

> -----Original Message-----
> From: Kailang
> Sent: Wednesday, April 10, 2024 5:23 PM
> To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: Thinkpad with ALC1318 has a chance of damaging the IC
> 
> Hi Takashi,
> 
> Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.
> 
> BR,
> Kailang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Thinkpad with ALC1318 has a chance of damaging the IC
  2024-04-15  9:27 Thinkpad with ALC1318 has a chance of damaging the IC Kailang
@ 2024-04-18  6:21 ` Takashi Iwai
  2024-04-18  6:33   ` Kailang
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2024-04-18  6:21 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Mon, 15 Apr 2024 11:27:50 +0200,
Kailang wrote:
> 
> Hi Takashi,
> 
> Please don't apply this patch.
> They want to add stream open to enable GPIO3 functions.

OK, let me know if the new patch is ready.


thanks,

Takashi

> 
> BR,
> Kailang
> 
> > -----Original Message-----
> > From: Kailang
> > Sent: Wednesday, April 10, 2024 5:23 PM
> > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > Subject: Thinkpad with ALC1318 has a chance of damaging the IC
> > 
> > Hi Takashi,
> > 
> > Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.
> > 
> > BR,
> > Kailang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Thinkpad with ALC1318 has a chance of damaging the IC
  2024-04-18  6:21 ` Takashi Iwai
@ 2024-04-18  6:33   ` Kailang
  2024-04-18 15:37     ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Kailang @ 2024-04-18  6:33 UTC (permalink / raw)
  To: Takashi Iwai; +Cc:  (alsa-devel@alsa-project.org)

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

Hi Takashi,

New patch was attached.
new additional function was request from Lenovo.

BR,
Kailang

> -----Original Message-----
> From: Takashi Iwai <tiwai@suse.de>
> Sent: Thursday, April 18, 2024 2:22 PM
> To: Kailang <kailang@realtek.com>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: Re: Thinkpad with ALC1318 has a chance of damaging the IC
> 
> 
> External mail.
> 
> 
> 
> On Mon, 15 Apr 2024 11:27:50 +0200,
> Kailang wrote:
> >
> > Hi Takashi,
> >
> > Please don't apply this patch.
> > They want to add stream open to enable GPIO3 functions.
> 
> OK, let me know if the new patch is ready.
> 
> 
> thanks,
> 
> Takashi
> 
> >
> > BR,
> > Kailang
> >
> > > -----Original Message-----
> > > From: Kailang
> > > Sent: Wednesday, April 10, 2024 5:23 PM
> > > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > Subject: Thinkpad with ALC1318 has a chance of damaging the IC
> > >
> > > Hi Takashi,
> > >
> > > Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.
> > >
> > > BR,
> > > Kailang

[-- Attachment #2: 0001-alc287-tp-with-alc1318.patch --]
[-- Type: application/octet-stream, Size: 3439 bytes --]

From ce9a0ee99b079e158c554cbc36933c24b16fa5ae Mon Sep 17 00:00:00 2001
From: Kailang Yang <kailang@realtek.com>
Date: Thu, 18 Apr 2024 14:23:57 +0800
Subject: [PATCH] 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 <kailang@realtek.com>
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d6940bc4ec39..8d43b79acb9b 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7182,6 +7182,43 @@ static void alc245_fixup_hp_spectre_x360_eu0xxx(struct hda_codec *codec,
 	alc245_fixup_hp_mute_led_coefbit(codec, fix, action);
 	alc245_fixup_hp_gpio_led(codec, fix, action);
 }
+/*
+ * ALC287 PCM hooks
+ */
+static void alc287_alc1318_playback_pcm_hook(struct hda_pcm_stream *hinfo,
+				   struct hda_codec *codec,
+				   struct snd_pcm_substream *substream,
+				   int action)
+{
+	alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MLK to GPIO3 */
+	switch (action) {
+	case HDA_GEN_PCM_ACT_OPEN:
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x954f); /* write gpio3 to high */
+		break;
+	case HDA_GEN_PCM_ACT_CLOSE:
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
+		break;
+	}
+}
+
+static void alc287_s4_power_gpio3_default(struct hda_codec *codec)
+{
+	if (codec->core.dev.power.power_state == PMSG_FREEZE) {
+		alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MLK to GPIO3 */
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
+	}
+}
+
+static void alc287_fixup_lenovo_thinkpad_with_alc1318(struct hda_codec *codec,
+			       const struct hda_fixup *fix, int action)
+{
+	struct alc_spec *spec = codec->spec;
+
+	if (action != HDA_FIXUP_ACT_PRE_PROBE)
+		return;
+	spec->power_hook = alc287_s4_power_gpio3_default;
+	spec->gen.pcm_playback_hook = alc287_alc1318_playback_pcm_hook;
+}
 
 
 enum {
@@ -7467,6 +7504,7 @@ enum {
 	ALC285_FIXUP_CS35L56_I2C_2,
 	ALC285_FIXUP_CS35L56_I2C_4,
 	ALC285_FIXUP_ASUS_GA403U,
+	ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318,
 };
 
 /* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9690,6 +9728,10 @@ static const struct hda_fixup alc269_fixups[] = {
 		.type = HDA_FIXUP_FUNC,
 		.v.func = alc285_fixup_asus_ga403u,
 	},
+	[ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = alc287_fixup_lenovo_thinkpad_with_alc1318,
+	},
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -10355,6 +10397,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x2318, "Thinkpad Z13 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
 	SND_PCI_QUIRK(0x17aa, 0x2319, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
 	SND_PCI_QUIRK(0x17aa, 0x231a, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
+	SND_PCI_QUIRK(0x17aa, 0x231e, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
+	SND_PCI_QUIRK(0x17aa, 0x231f, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
 	SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
 	SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
 	SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Thinkpad with ALC1318 has a chance of damaging the IC
  2024-04-18  6:33   ` Kailang
@ 2024-04-18 15:37     ` Takashi Iwai
  2024-04-30  9:19       ` Kailang
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2024-04-18 15:37 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Thu, 18 Apr 2024 08:33:42 +0200,
Kailang wrote:
> 
> Hi Takashi,
> 
> New patch was attached.
> new additional function was request from Lenovo.

I got a compile error.  The check should be rather

	if (codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)

Maybe better to define is_s4_suspend() just like is_s4_resume().

And, please rebase the patch to the latest for-linus branch of
sound.git tree.


thanks,

Takashi

> 
> BR,
> Kailang
> 
> > -----Original Message-----
> > From: Takashi Iwai <tiwai@suse.de>
> > Sent: Thursday, April 18, 2024 2:22 PM
> > To: Kailang <kailang@realtek.com>
> > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > Subject: Re: Thinkpad with ALC1318 has a chance of damaging the IC
> > 
> > 
> > External mail.
> > 
> > 
> > 
> > On Mon, 15 Apr 2024 11:27:50 +0200,
> > Kailang wrote:
> > >
> > > Hi Takashi,
> > >
> > > Please don't apply this patch.
> > > They want to add stream open to enable GPIO3 functions.
> > 
> > OK, let me know if the new patch is ready.
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> > >
> > > BR,
> > > Kailang
> > >
> > > > -----Original Message-----
> > > > From: Kailang
> > > > Sent: Wednesday, April 10, 2024 5:23 PM
> > > > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > > Subject: Thinkpad with ALC1318 has a chance of damaging the IC
> > > >
> > > > Hi Takashi,
> > > >
> > > > Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.
> > > >
> > > > BR,
> > > > Kailang
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Thinkpad with ALC1318 has a chance of damaging the IC
  2024-04-18 15:37     ` Takashi Iwai
@ 2024-04-30  9:19       ` Kailang
  2024-04-30  9:48         ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Kailang @ 2024-04-30  9:19 UTC (permalink / raw)
  To: Takashi Iwai; +Cc:  (alsa-devel@alsa-project.org)

[-- Attachment #1: Type: text/plain, Size: 2112 bytes --]

Attached new patch.

> -----Original Message-----
> From: Takashi Iwai <tiwai@suse.de>
> Sent: Thursday, April 18, 2024 11:37 PM
> To: Kailang <kailang@realtek.com>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: Re: Thinkpad with ALC1318 has a chance of damaging the IC
> 
> 
> External mail.
> 
> 
> 
> On Thu, 18 Apr 2024 08:33:42 +0200,
> Kailang wrote:
> >
> > Hi Takashi,
> >
> > New patch was attached.
> > new additional function was request from Lenovo.
> 
> I got a compile error.  The check should be rather
> 
>         if (codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
> 
> Maybe better to define is_s4_suspend() just like is_s4_resume().
> 
> And, please rebase the patch to the latest for-linus branch of sound.git tree.
> 
> 
> thanks,
> 
> Takashi
> 
> >
> > BR,
> > Kailang
> >
> > > -----Original Message-----
> > > From: Takashi Iwai <tiwai@suse.de>
> > > Sent: Thursday, April 18, 2024 2:22 PM
> > > To: Kailang <kailang@realtek.com>
> > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > Subject: Re: Thinkpad with ALC1318 has a chance of damaging the IC
> > >
> > >
> > > External mail.
> > >
> > >
> > >
> > > On Mon, 15 Apr 2024 11:27:50 +0200,
> > > Kailang wrote:
> > > >
> > > > Hi Takashi,
> > > >
> > > > Please don't apply this patch.
> > > > They want to add stream open to enable GPIO3 functions.
> > >
> > > OK, let me know if the new patch is ready.
> > >
> > >
> > > thanks,
> > >
> > > Takashi
> > >
> > > >
> > > > BR,
> > > > Kailang
> > > >
> > > > > -----Original Message-----
> > > > > From: Kailang
> > > > > Sent: Wednesday, April 10, 2024 5:23 PM
> > > > > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > > > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > > > Subject: Thinkpad with ALC1318 has a chance of damaging the IC
> > > > >
> > > > > Hi Takashi,
> > > > >
> > > > > Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.
> > > > >
> > > > > BR,
> > > > > Kailang
> >

[-- Attachment #2: 0002-alc287-tp-with-alc1318.patch --]
[-- Type: application/octet-stream, Size: 3989 bytes --]

From ced95661428318b42db146c4395e275cb8fb19e9 Mon Sep 17 00:00:00 2001
From: Kailang Yang <kailang@realtek.com>
Date: Tue, 30 Apr 2024 17:15:53 +0800
Subject: [PATCH] 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 <kailang@realtek.com>
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0898197cf8d3..fe72e3e0c75d 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -920,6 +920,8 @@ static void alc_pre_init(struct hda_codec *codec)
 	((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
 #define is_s4_resume(codec) \
 	((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
+#define is_s4_suspend(codec) \
+	((codec)->core.dev.power.power_state.event == PM_EVENT_FREEZE)
 
 static int alc_init(struct hda_codec *codec)
 {
@@ -7182,6 +7184,43 @@ static void alc245_fixup_hp_spectre_x360_eu0xxx(struct hda_codec *codec,
 	alc245_fixup_hp_mute_led_coefbit(codec, fix, action);
 	alc245_fixup_hp_gpio_led(codec, fix, action);
 }
+/*
+ * ALC287 PCM hooks
+ */
+static void alc287_alc1318_playback_pcm_hook(struct hda_pcm_stream *hinfo,
+				   struct hda_codec *codec,
+				   struct snd_pcm_substream *substream,
+				   int action)
+{
+	alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MLK to GPIO3 */
+	switch (action) {
+	case HDA_GEN_PCM_ACT_OPEN:
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x954f); /* write gpio3 to high */
+		break;
+	case HDA_GEN_PCM_ACT_CLOSE:
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
+		break;
+	}
+}
+
+static void alc287_s4_power_gpio3_default(struct hda_codec *codec)
+{
+	if (is_s4_suspend(codec)) {
+		alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MLK to GPIO3 */
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
+	}
+}
+
+static void alc287_fixup_lenovo_thinkpad_with_alc1318(struct hda_codec *codec,
+			       const struct hda_fixup *fix, int action)
+{
+	struct alc_spec *spec = codec->spec;
+
+	if (action != HDA_FIXUP_ACT_PRE_PROBE)
+		return;
+	spec->power_hook = alc287_s4_power_gpio3_default;
+	spec->gen.pcm_playback_hook = alc287_alc1318_playback_pcm_hook;
+}
 
 
 enum {
@@ -7470,7 +7509,8 @@ enum {
 	ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC,
 	ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1,
 	ALC285_FIXUP_ASUS_GU605_SPI_2_HEADSET_MIC,
-	ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1
+	ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1,
+	ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318,
 };
 
 /* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9726,6 +9766,12 @@ static const struct hda_fixup alc269_fixups[] = {
 		.chained = true,
 		.chain_id = ALC285_FIXUP_ASUS_GA403U,
 	},
+	[ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = alc287_fixup_lenovo_thinkpad_with_alc1318,
+		.chained = true,
+		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
+	},
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -10398,6 +10444,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x2318, "Thinkpad Z13 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
 	SND_PCI_QUIRK(0x17aa, 0x2319, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
 	SND_PCI_QUIRK(0x17aa, 0x231a, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
+	SND_PCI_QUIRK(0x17aa, 0x231e, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
+	SND_PCI_QUIRK(0x17aa, 0x231f, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
 	SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
 	SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
 	SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Thinkpad with ALC1318 has a chance of damaging the IC
  2024-04-30  9:19       ` Kailang
@ 2024-04-30  9:48         ` Takashi Iwai
  0 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2024-04-30  9:48 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Tue, 30 Apr 2024 11:19:40 +0200,
Kailang wrote:
> 
> Attached new patch.

OK, applied now.


thanks,

Takashi


> > -----Original Message-----
> > From: Takashi Iwai <tiwai@suse.de>
> > Sent: Thursday, April 18, 2024 11:37 PM
> > To: Kailang <kailang@realtek.com>
> > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > Subject: Re: Thinkpad with ALC1318 has a chance of damaging the IC
> > 
> > 
> > External mail.
> > 
> > 
> > 
> > On Thu, 18 Apr 2024 08:33:42 +0200,
> > Kailang wrote:
> > >
> > > Hi Takashi,
> > >
> > > New patch was attached.
> > > new additional function was request from Lenovo.
> > 
> > I got a compile error.  The check should be rather
> > 
> >         if (codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
> > 
> > Maybe better to define is_s4_suspend() just like is_s4_resume().
> > 
> > And, please rebase the patch to the latest for-linus branch of sound.git tree.
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> > >
> > > BR,
> > > Kailang
> > >
> > > > -----Original Message-----
> > > > From: Takashi Iwai <tiwai@suse.de>
> > > > Sent: Thursday, April 18, 2024 2:22 PM
> > > > To: Kailang <kailang@realtek.com>
> > > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > > Subject: Re: Thinkpad with ALC1318 has a chance of damaging the IC
> > > >
> > > >
> > > > External mail.
> > > >
> > > >
> > > >
> > > > On Mon, 15 Apr 2024 11:27:50 +0200,
> > > > Kailang wrote:
> > > > >
> > > > > Hi Takashi,
> > > > >
> > > > > Please don't apply this patch.
> > > > > They want to add stream open to enable GPIO3 functions.
> > > >
> > > > OK, let me know if the new patch is ready.
> > > >
> > > >
> > > > thanks,
> > > >
> > > > Takashi
> > > >
> > > > >
> > > > > BR,
> > > > > Kailang
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Kailang
> > > > > > Sent: Wednesday, April 10, 2024 5:23 PM
> > > > > > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > > > > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > > > > Subject: Thinkpad with ALC1318 has a chance of damaging the IC
> > > > > >
> > > > > > Hi Takashi,
> > > > > >
> > > > > > Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.
> > > > > >
> > > > > > BR,
> > > > > > Kailang
> > >
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Thinkpad with ALC1318 has a chance of damaging the IC
@ 2024-04-10  9:23 Kailang
  0 siblings, 0 replies; 7+ messages in thread
From: Kailang @ 2024-04-10  9:23 UTC (permalink / raw)
  To: Takashi Iwai (tiwai@suse.de); +Cc:  (alsa-devel@alsa-project.org)

[-- Attachment #1: Type: text/plain, Size: 100 bytes --]

Hi Takashi,

Thinkpad with ALC1318 has a chance of damaging the IC at S4 resume.

BR,
Kailang

[-- Attachment #2: 0000-alc287-tp-with-alc1318.patch --]
[-- Type: application/octet-stream, Size: 2747 bytes --]

From 14c51609c8c237e35bc7ed31ae28e33a726170f4 Mon Sep 17 00:00:00 2001
From: Kailang Yang <kailang@realtek.com>
Date: Wed, 10 Apr 2024 16:57:28 +0800
Subject: [PATCH] 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.
Thinkpad with ALC1318 platform need to add this workaround.

Signed-off-by: Kailang Yang <kailang@realtek.com>
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d6940bc4ec39..dbc7756eb980 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7183,6 +7183,24 @@ static void alc245_fixup_hp_spectre_x360_eu0xxx(struct hda_codec *codec,
 	alc245_fixup_hp_gpio_led(codec, fix, action);
 }
 
+static void alc287_s4_power_gpio3_default(struct hda_codec *codec)
+{
+	if (codec->core.dev.power.power_state == PMSG_FREEZE) {
+		alc_write_coef_idx(codec, 0x10, 0x8806); /* Change MCLK to GPIO3 */
+		alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
+	}
+}
+
+static void alc287_fixup_lenovo_thinkpad_with_alc1318(struct hda_codec *codec,
+			       const struct hda_fixup *fix, int action)
+{
+	struct alc_spec *spec = codec->spec;
+
+	if (action != HDA_FIXUP_ACT_PRE_PROBE)
+		return;
+	spec->power_hook = alc287_s4_power_gpio3_default;
+}
+
 
 enum {
 	ALC269_FIXUP_GPIO2,
@@ -7467,6 +7485,7 @@ enum {
 	ALC285_FIXUP_CS35L56_I2C_2,
 	ALC285_FIXUP_CS35L56_I2C_4,
 	ALC285_FIXUP_ASUS_GA403U,
+	ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318,
 };
 
 /* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9690,6 +9709,10 @@ static const struct hda_fixup alc269_fixups[] = {
 		.type = HDA_FIXUP_FUNC,
 		.v.func = alc285_fixup_asus_ga403u,
 	},
+	[ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = alc287_fixup_lenovo_thinkpad_with_alc1318,
+	},
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -10355,6 +10378,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x2318, "Thinkpad Z13 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
 	SND_PCI_QUIRK(0x17aa, 0x2319, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
 	SND_PCI_QUIRK(0x17aa, 0x231a, "Thinkpad Z16 Gen2", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
+	SND_PCI_QUIRK(0x17aa, 0x231e, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
+	SND_PCI_QUIRK(0x17aa, 0x231f, "Thinkpad", ALC287_FIXUP_LENOVO_THKPAD_WH_ALC1318),
 	SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
 	SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
 	SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-30  9:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15  9:27 Thinkpad with ALC1318 has a chance of damaging the IC Kailang
2024-04-18  6:21 ` Takashi Iwai
2024-04-18  6:33   ` Kailang
2024-04-18 15:37     ` Takashi Iwai
2024-04-30  9:19       ` Kailang
2024-04-30  9:48         ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2024-04-10  9:23 Kailang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.