1 From c0ca5eced22215c1e03e3ad479f8fab0bbb30772 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Wed, 20 Feb 2019 16:15:45 +0100
4 Subject: ALSA: hda/realtek - Reduce click noise on Dell Precision 5820 headphone
6 From: Takashi Iwai <tiwai@suse.de>
8 commit c0ca5eced22215c1e03e3ad479f8fab0bbb30772 upstream.
10 Dell Precision 5820 with ALC3234 codec (which is equivalent with
11 ALC255) shows click noises at (runtime) PM resume on the headphone.
12 The biggest source of the noise comes from the cleared headphone pin
13 control at resume, which is done via the standard shutup procedure.
15 Although we have an override of the standard shutup callback to
16 replace with NOP, this would skip other needed stuff (e.g. the pull
17 down of headset power). So, instead, this "fixes" the behavior of
18 alc_fixup_no_shutup() by introducing spec->no_shutup_pins flag.
19 When this flag is set, Realtek codec won't call the standard
20 snd_hda_shutup_pins() & co. Now alc_fixup_no_shutup() just sets this
21 flag instead of overriding spec->shutup callback itself. This allows
22 us to apply the similar fix for other entries easily if needed in
25 Cc: <stable@vger.kernel.org>
26 Signed-off-by: Takashi Iwai <tiwai@suse.de>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 sound/pci/hda/patch_realtek.c | 57 +++++++++++++++++++++++++-----------------
31 1 file changed, 34 insertions(+), 23 deletions(-)
33 --- a/sound/pci/hda/patch_realtek.c
34 +++ b/sound/pci/hda/patch_realtek.c
35 @@ -118,6 +118,7 @@ struct alc_spec {
36 unsigned int has_alc5505_dsp:1;
37 unsigned int no_depop_delay:1;
38 unsigned int done_hp_init:1;
39 + unsigned int no_shutup_pins:1;
43 @@ -476,6 +477,14 @@ static void alc_auto_setup_eapd(struct h
44 set_eapd(codec, *p, on);
47 +static void alc_shutup_pins(struct hda_codec *codec)
49 + struct alc_spec *spec = codec->spec;
51 + if (!spec->no_shutup_pins)
52 + snd_hda_shutup_pins(codec);
55 /* generic shutup callback;
56 * just turning off EAPD and a little pause for avoiding pop-noise
58 @@ -486,7 +495,7 @@ static void alc_eapd_shutup(struct hda_c
59 alc_auto_setup_eapd(codec, false);
60 if (!spec->no_depop_delay)
62 - snd_hda_shutup_pins(codec);
63 + alc_shutup_pins(codec);
66 /* generic EAPD initialization */
67 @@ -814,7 +823,7 @@ static inline void alc_shutup(struct hda
68 if (spec && spec->shutup)
71 - snd_hda_shutup_pins(codec);
72 + alc_shutup_pins(codec);
75 static void alc_reboot_notify(struct hda_codec *codec)
76 @@ -2950,7 +2959,7 @@ static void alc269_shutup(struct hda_cod
77 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
80 - snd_hda_shutup_pins(codec);
81 + alc_shutup_pins(codec);
84 static struct coef_fw alc282_coefs[] = {
85 @@ -3053,14 +3062,15 @@ static void alc282_shutup(struct hda_cod
89 - snd_hda_codec_write(codec, hp_pin, 0,
90 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
91 + if (!spec->no_shutup_pins)
92 + snd_hda_codec_write(codec, hp_pin, 0,
93 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
98 alc_auto_setup_eapd(codec, false);
99 - snd_hda_shutup_pins(codec);
100 + alc_shutup_pins(codec);
101 alc_write_coef_idx(codec, 0x78, coef78);
104 @@ -3166,15 +3176,16 @@ static void alc283_shutup(struct hda_cod
108 - snd_hda_codec_write(codec, hp_pin, 0,
109 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
110 + if (!spec->no_shutup_pins)
111 + snd_hda_codec_write(codec, hp_pin, 0,
112 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
114 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
118 alc_auto_setup_eapd(codec, false);
119 - snd_hda_shutup_pins(codec);
120 + alc_shutup_pins(codec);
121 alc_write_coef_idx(codec, 0x43, 0x9614);
124 @@ -3240,14 +3251,15 @@ static void alc256_shutup(struct hda_cod
125 /* NOTE: call this before clearing the pin, otherwise codec stalls */
126 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
128 - snd_hda_codec_write(codec, hp_pin, 0,
129 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
130 + if (!spec->no_shutup_pins)
131 + snd_hda_codec_write(codec, hp_pin, 0,
132 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
137 alc_auto_setup_eapd(codec, false);
138 - snd_hda_shutup_pins(codec);
139 + alc_shutup_pins(codec);
142 static void alc225_init(struct hda_codec *codec)
143 @@ -3334,7 +3346,7 @@ static void alc225_shutup(struct hda_cod
146 alc_auto_setup_eapd(codec, false);
147 - snd_hda_shutup_pins(codec);
148 + alc_shutup_pins(codec);
151 static void alc_default_init(struct hda_codec *codec)
152 @@ -3388,14 +3400,15 @@ static void alc_default_shutup(struct hd
156 - snd_hda_codec_write(codec, hp_pin, 0,
157 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
158 + if (!spec->no_shutup_pins)
159 + snd_hda_codec_write(codec, hp_pin, 0,
160 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
165 alc_auto_setup_eapd(codec, false);
166 - snd_hda_shutup_pins(codec);
167 + alc_shutup_pins(codec);
170 static void alc294_hp_init(struct hda_codec *codec)
171 @@ -3412,8 +3425,9 @@ static void alc294_hp_init(struct hda_co
175 - snd_hda_codec_write(codec, hp_pin, 0,
176 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
177 + if (!spec->no_shutup_pins)
178 + snd_hda_codec_write(codec, hp_pin, 0,
179 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
181 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
182 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
183 @@ -5007,16 +5021,12 @@ static void alc_fixup_auto_mute_via_amp(
187 -static void alc_no_shutup(struct hda_codec *codec)
191 static void alc_fixup_no_shutup(struct hda_codec *codec,
192 const struct hda_fixup *fix, int action)
194 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
195 struct alc_spec *spec = codec->spec;
196 - spec->shutup = alc_no_shutup;
197 + spec->no_shutup_pins = 1;
201 @@ -6596,6 +6606,7 @@ static const struct snd_pci_quirk alc269
202 SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
203 SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
204 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
205 + SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
206 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
207 SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
208 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),