Takashi Iwai b0ff56
From 71db96ddfa72671bd43cacdcc99ca178d90ba267 Mon Sep 17 00:00:00 2001
Takashi Iwai b0ff56
From: Takashi Iwai <tiwai@suse.de>
Takashi Iwai b0ff56
Date: Mon, 26 Feb 2018 15:36:38 +0100
Takashi Iwai b0ff56
Subject: [PATCH] ALSA: hda - Fix pincfg at resume on Lenovo T470 dock
Takashi Iwai b0ff56
Git-commit: 71db96ddfa72671bd43cacdcc99ca178d90ba267
Takashi Iwai b0ff56
Patch-mainline: v4.16-rc4
Takashi Iwai b0ff56
References: bsc#1052235
Takashi Iwai b0ff56
Takashi Iwai b0ff56
We've added a quirk to enable the recent Lenovo dock support, where it
Takashi Iwai b0ff56
overwrites the pin configs of NID 0x17 and 19, not only updating the
Takashi Iwai b0ff56
pin config cache.  It works right after the boot, but the problem is
Takashi Iwai b0ff56
that the pin configs are occasionally cleared when the machine goes to
Takashi Iwai b0ff56
PM.  Meanwhile the quirk writes the pin configs only at the pre-probe,
Takashi Iwai b0ff56
so this won't be applied any longer.
Takashi Iwai b0ff56
Takashi Iwai b0ff56
For addressing that issue, this patch moves the code to overwrite the
Takashi Iwai b0ff56
pin configs into HDA_FIXUP_ACT_INIT section so that it's always
Takashi Iwai b0ff56
applied at both probe and resume time.
Takashi Iwai b0ff56
Takashi Iwai b0ff56
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195161
Takashi Iwai b0ff56
Fixes: 61fcf8ece9b6 ("ALSA: hda/realtek - Enable Thinkpad Dock device for ALC298 platform")
Takashi Iwai b0ff56
Cc: <stable@vger.kernel.org>
Takashi Iwai b0ff56
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai b0ff56
Takashi Iwai b0ff56
---
Takashi Iwai b0ff56
 sound/pci/hda/patch_realtek.c |    3 ++-
Takashi Iwai b0ff56
 1 file changed, 2 insertions(+), 1 deletion(-)
Takashi Iwai b0ff56
Takashi Iwai b0ff56
--- a/sound/pci/hda/patch_realtek.c
Takashi Iwai b0ff56
+++ b/sound/pci/hda/patch_realtek.c
Takashi Iwai b0ff56
@@ -4997,13 +4997,14 @@ static void alc_fixup_tpt470_dock(struct
Takashi Iwai b0ff56
 
Takashi Iwai b0ff56
 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai b0ff56
 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
Takashi Iwai b0ff56
+		snd_hda_apply_pincfgs(codec, pincfgs);
Takashi Iwai b0ff56
+	} else if (action == HDA_FIXUP_ACT_INIT) {
Takashi Iwai b0ff56
 		/* Enable DOCK device */
Takashi Iwai b0ff56
 		snd_hda_codec_write(codec, 0x17, 0,
Takashi Iwai b0ff56
 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
Takashi Iwai b0ff56
 		/* Enable DOCK device */
Takashi Iwai b0ff56
 		snd_hda_codec_write(codec, 0x19, 0,
Takashi Iwai b0ff56
 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
Takashi Iwai b0ff56
-		snd_hda_apply_pincfgs(codec, pincfgs);
Takashi Iwai b0ff56
 	}
Takashi Iwai b0ff56
 }
Takashi Iwai b0ff56