All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/conexant: Fix missing headphone node after reboot from Windows
@ 2020-06-23  6:25 Takashi Iwai
  2020-06-23 10:11 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Iwai @ 2020-06-23  6:25 UTC (permalink / raw)
  To: alsa-devel

When Lenovo Thinkpad E495 is rebooted from Windows, the headphone
control is lost.  This seems because BIOS doesn't initialize the
headphone node (NID 0x16) properly after the reboot from Windows, as
Windows likely turns off the power at its exit.  The node is left
as a vendor-specific unknown node and ignored by the HD-audio parser.

This patch forcibly initializes the node at the probe time, by
overriding the widget caps and the connection list, so that the
headphone control is detected always at probe time.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207741
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/patch_conexant.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 396b5503038a..37c8add48791 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -215,6 +215,7 @@ enum {
 	CXT_FIXUP_MUTE_LED_GPIO,
 	CXT_FIXUP_HEADSET_MIC,
 	CXT_FIXUP_HP_MIC_NO_PRESENCE,
+	CXT_FIXUP_THINKPAD_E495,
 };
 
 /* for hda_fixup_thinkpad_acpi() */
@@ -673,6 +674,22 @@ static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
 				    spec->gpio_led);
 }
 
+static void cxt_fixup_thinkpad_e495(struct hda_codec *codec,
+				    const struct hda_fixup *fix,
+				    int action)
+{
+	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+		static const hda_nid_t conns[] = { 0x10, 0x11 };
+		/* BIOS invalidates the headphone pin NID 0x16 when rebooted
+		 * after Windows by some reason;
+		 * forcibly restoring the whole setup
+		 */
+		snd_hda_override_wcaps(codec, 0x16, 0x400581);
+		snd_hda_codec_set_pincfg(codec, 0x16, 0x03211040);
+		snd_hda_override_conn_list(codec, 0x16, ARRAY_SIZE(conns),
+					   conns);
+	}
+}
 
 /* ThinkPad X200 & co with cxt5051 */
 static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
@@ -846,6 +863,12 @@ static const struct hda_fixup cxt_fixups[] = {
 		.chained = true,
 		.chain_id = CXT_FIXUP_HEADSET_MIC,
 	},
+	[CXT_FIXUP_THINKPAD_E495] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = cxt_fixup_thinkpad_e495,
+		.chained = true,
+		.chain_id = CXT_FIXUP_THINKPAD_ACPI,
+	},
 };
 
 static const struct snd_pci_quirk cxt5045_fixups[] = {
@@ -932,6 +955,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
 	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
+	SND_PCI_QUIRK(0x17aa, 0x5124, "Lenovo Thinkpad E495", CXT_FIXUP_THINKPAD_E495),
 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
 	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
 	SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
-- 
2.16.4


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

* Re: [PATCH] ALSA: hda/conexant: Fix missing headphone node after reboot from Windows
  2020-06-23  6:25 [PATCH] ALSA: hda/conexant: Fix missing headphone node after reboot from Windows Takashi Iwai
@ 2020-06-23 10:11 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2020-06-23 10:11 UTC (permalink / raw)
  To: alsa-devel

On Tue, 23 Jun 2020 08:25:10 +0200,
Takashi Iwai wrote:
> 
> When Lenovo Thinkpad E495 is rebooted from Windows, the headphone
> control is lost.  This seems because BIOS doesn't initialize the
> headphone node (NID 0x16) properly after the reboot from Windows, as
> Windows likely turns off the power at its exit.  The node is left
> as a vendor-specific unknown node and ignored by the HD-audio parser.
> 
> This patch forcibly initializes the node at the probe time, by
> overriding the widget caps and the connection list, so that the
> headphone control is detected always at probe time.
> 
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207741
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

This turned out to be not effective, the audio stream itself doesn't
work as expected.


thanks,

Takashi

> ---
>  sound/pci/hda/patch_conexant.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
> index 396b5503038a..37c8add48791 100644
> --- a/sound/pci/hda/patch_conexant.c
> +++ b/sound/pci/hda/patch_conexant.c
> @@ -215,6 +215,7 @@ enum {
>  	CXT_FIXUP_MUTE_LED_GPIO,
>  	CXT_FIXUP_HEADSET_MIC,
>  	CXT_FIXUP_HP_MIC_NO_PRESENCE,
> +	CXT_FIXUP_THINKPAD_E495,
>  };
>  
>  /* for hda_fixup_thinkpad_acpi() */
> @@ -673,6 +674,22 @@ static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
>  				    spec->gpio_led);
>  }
>  
> +static void cxt_fixup_thinkpad_e495(struct hda_codec *codec,
> +				    const struct hda_fixup *fix,
> +				    int action)
> +{
> +	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
> +		static const hda_nid_t conns[] = { 0x10, 0x11 };
> +		/* BIOS invalidates the headphone pin NID 0x16 when rebooted
> +		 * after Windows by some reason;
> +		 * forcibly restoring the whole setup
> +		 */
> +		snd_hda_override_wcaps(codec, 0x16, 0x400581);
> +		snd_hda_codec_set_pincfg(codec, 0x16, 0x03211040);
> +		snd_hda_override_conn_list(codec, 0x16, ARRAY_SIZE(conns),
> +					   conns);
> +	}
> +}
>  
>  /* ThinkPad X200 & co with cxt5051 */
>  static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
> @@ -846,6 +863,12 @@ static const struct hda_fixup cxt_fixups[] = {
>  		.chained = true,
>  		.chain_id = CXT_FIXUP_HEADSET_MIC,
>  	},
> +	[CXT_FIXUP_THINKPAD_E495] = {
> +		.type = HDA_FIXUP_FUNC,
> +		.v.func = cxt_fixup_thinkpad_e495,
> +		.chained = true,
> +		.chain_id = CXT_FIXUP_THINKPAD_ACPI,
> +	},
>  };
>  
>  static const struct snd_pci_quirk cxt5045_fixups[] = {
> @@ -932,6 +955,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
>  	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
>  	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
>  	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
> +	SND_PCI_QUIRK(0x17aa, 0x5124, "Lenovo Thinkpad E495", CXT_FIXUP_THINKPAD_E495),
>  	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
>  	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
>  	SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
> -- 
> 2.16.4
> 

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

end of thread, other threads:[~2020-06-23 10:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23  6:25 [PATCH] ALSA: hda/conexant: Fix missing headphone node after reboot from Windows Takashi Iwai
2020-06-23 10:11 ` Takashi Iwai

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.