]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.3/alsa-hda-realtek-reduce-click-noise-on-dell-precision-5820-headphone.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / releases / 5.0.3 / alsa-hda-realtek-reduce-click-noise-on-dell-precision-5820-headphone.patch
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
5
6 From: Takashi Iwai <tiwai@suse.de>
7
8 commit c0ca5eced22215c1e03e3ad479f8fab0bbb30772 upstream.
9
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.
14
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
23 future.
24
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>
28
29 ---
30 sound/pci/hda/patch_realtek.c | 57 +++++++++++++++++++++++++-----------------
31 1 file changed, 34 insertions(+), 23 deletions(-)
32
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;
40
41 /* for PLL fix */
42 hda_nid_t pll_nid;
43 @@ -476,6 +477,14 @@ static void alc_auto_setup_eapd(struct h
44 set_eapd(codec, *p, on);
45 }
46
47 +static void alc_shutup_pins(struct hda_codec *codec)
48 +{
49 + struct alc_spec *spec = codec->spec;
50 +
51 + if (!spec->no_shutup_pins)
52 + snd_hda_shutup_pins(codec);
53 +}
54 +
55 /* generic shutup callback;
56 * just turning off EAPD and a little pause for avoiding pop-noise
57 */
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)
61 msleep(200);
62 - snd_hda_shutup_pins(codec);
63 + alc_shutup_pins(codec);
64 }
65
66 /* generic EAPD initialization */
67 @@ -814,7 +823,7 @@ static inline void alc_shutup(struct hda
68 if (spec && spec->shutup)
69 spec->shutup(codec);
70 else
71 - snd_hda_shutup_pins(codec);
72 + alc_shutup_pins(codec);
73 }
74
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) {
78 msleep(150);
79 }
80 - snd_hda_shutup_pins(codec);
81 + alc_shutup_pins(codec);
82 }
83
84 static struct coef_fw alc282_coefs[] = {
85 @@ -3053,14 +3062,15 @@ static void alc282_shutup(struct hda_cod
86 if (hp_pin_sense)
87 msleep(85);
88
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);
94
95 if (hp_pin_sense)
96 msleep(100);
97
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);
102 }
103
104 @@ -3166,15 +3176,16 @@ static void alc283_shutup(struct hda_cod
105 if (hp_pin_sense)
106 msleep(100);
107
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);
113
114 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
115
116 if (hp_pin_sense)
117 msleep(100);
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);
122 }
123
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);
127
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);
133
134 if (hp_pin_sense)
135 msleep(100);
136
137 alc_auto_setup_eapd(codec, false);
138 - snd_hda_shutup_pins(codec);
139 + alc_shutup_pins(codec);
140 }
141
142 static void alc225_init(struct hda_codec *codec)
143 @@ -3334,7 +3346,7 @@ static void alc225_shutup(struct hda_cod
144 msleep(100);
145
146 alc_auto_setup_eapd(codec, false);
147 - snd_hda_shutup_pins(codec);
148 + alc_shutup_pins(codec);
149 }
150
151 static void alc_default_init(struct hda_codec *codec)
152 @@ -3388,14 +3400,15 @@ static void alc_default_shutup(struct hd
153 if (hp_pin_sense)
154 msleep(85);
155
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);
161
162 if (hp_pin_sense)
163 msleep(100);
164
165 alc_auto_setup_eapd(codec, false);
166 - snd_hda_shutup_pins(codec);
167 + alc_shutup_pins(codec);
168 }
169
170 static void alc294_hp_init(struct hda_codec *codec)
171 @@ -3412,8 +3425,9 @@ static void alc294_hp_init(struct hda_co
172
173 msleep(100);
174
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);
180
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(
184 }
185 }
186
187 -static void alc_no_shutup(struct hda_codec *codec)
188 -{
189 -}
190 -
191 static void alc_fixup_no_shutup(struct hda_codec *codec,
192 const struct hda_fixup *fix, int action)
193 {
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;
198 }
199 }
200
201 @@ -6677,6 +6687,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),