]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/alsa-hda-realtek-update-headset-mode-for-alc256.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / queue-4.14 / alsa-hda-realtek-update-headset-mode-for-alc256.patch
1 From 717f43d81afc1250300479075952a0e36d74ded3 Mon Sep 17 00:00:00 2001
2 From: Kailang Yang <kailang@realtek.com>
3 Date: Fri, 31 May 2019 17:16:53 +0800
4 Subject: ALSA: hda/realtek - Update headset mode for ALC256
5
6 From: Kailang Yang <kailang@realtek.com>
7
8 commit 717f43d81afc1250300479075952a0e36d74ded3 upstream.
9
10 ALC255 and ALC256 were some difference for hidden register.
11 This update was suitable for ALC256.
12
13 Fixes: e69e7e03ed22 ("ALSA: hda/realtek - ALC256 speaker noise issue")
14 Signed-off-by: Kailang Yang <kailang@realtek.com>
15 Cc: <stable@vger.kernel.org>
16 Signed-off-by: Takashi Iwai <tiwai@suse.de>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18
19 ---
20 sound/pci/hda/patch_realtek.c | 75 +++++++++++++++++++++++++++++++++---------
21 1 file changed, 60 insertions(+), 15 deletions(-)
22
23 --- a/sound/pci/hda/patch_realtek.c
24 +++ b/sound/pci/hda/patch_realtek.c
25 @@ -3936,18 +3936,19 @@ static struct coef_fw alc225_pre_hsmode[
26 static void alc_headset_mode_unplugged(struct hda_codec *codec)
27 {
28 static struct coef_fw coef0255[] = {
29 + WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
30 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
31 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
32 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
33 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
34 {}
35 };
36 - static struct coef_fw coef0255_1[] = {
37 - WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
38 - {}
39 - };
40 static struct coef_fw coef0256[] = {
41 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
42 + WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
43 + WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
44 + WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
45 + UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
46 {}
47 };
48 static struct coef_fw coef0233[] = {
49 @@ -4010,13 +4011,11 @@ static void alc_headset_mode_unplugged(s
50
51 switch (codec->core.vendor_id) {
52 case 0x10ec0255:
53 - alc_process_coef_fw(codec, coef0255_1);
54 alc_process_coef_fw(codec, coef0255);
55 break;
56 case 0x10ec0236:
57 case 0x10ec0256:
58 alc_process_coef_fw(codec, coef0256);
59 - alc_process_coef_fw(codec, coef0255);
60 break;
61 case 0x10ec0234:
62 case 0x10ec0274:
63 @@ -4066,6 +4065,12 @@ static void alc_headset_mode_mic_in(stru
64 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
65 {}
66 };
67 + static struct coef_fw coef0256[] = {
68 + UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
69 + WRITE_COEFEX(0x57, 0x03, 0x09a3),
70 + WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
71 + {}
72 + };
73 static struct coef_fw coef0233[] = {
74 UPDATE_COEF(0x35, 0, 1<<14),
75 WRITE_COEF(0x06, 0x2100),
76 @@ -4113,14 +4118,19 @@ static void alc_headset_mode_mic_in(stru
77 };
78
79 switch (codec->core.vendor_id) {
80 - case 0x10ec0236:
81 case 0x10ec0255:
82 - case 0x10ec0256:
83 alc_write_coef_idx(codec, 0x45, 0xc489);
84 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
85 alc_process_coef_fw(codec, coef0255);
86 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
87 break;
88 + case 0x10ec0236:
89 + case 0x10ec0256:
90 + alc_write_coef_idx(codec, 0x45, 0xc489);
91 + snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
92 + alc_process_coef_fw(codec, coef0256);
93 + snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
94 + break;
95 case 0x10ec0234:
96 case 0x10ec0274:
97 case 0x10ec0294:
98 @@ -4199,6 +4209,14 @@ static void alc_headset_mode_default(str
99 WRITE_COEF(0x49, 0x0049),
100 {}
101 };
102 + static struct coef_fw coef0256[] = {
103 + WRITE_COEF(0x45, 0xc489),
104 + WRITE_COEFEX(0x57, 0x03, 0x0da3),
105 + WRITE_COEF(0x49, 0x0049),
106 + UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
107 + WRITE_COEF(0x06, 0x6100),
108 + {}
109 + };
110 static struct coef_fw coef0233[] = {
111 WRITE_COEF(0x06, 0x2100),
112 WRITE_COEF(0x32, 0x4ea3),
113 @@ -4246,11 +4264,16 @@ static void alc_headset_mode_default(str
114 alc_process_coef_fw(codec, alc225_pre_hsmode);
115 alc_process_coef_fw(codec, coef0225);
116 break;
117 - case 0x10ec0236:
118 case 0x10ec0255:
119 - case 0x10ec0256:
120 alc_process_coef_fw(codec, coef0255);
121 break;
122 + case 0x10ec0236:
123 + case 0x10ec0256:
124 + alc_write_coef_idx(codec, 0x1b, 0x0e4b);
125 + alc_write_coef_idx(codec, 0x45, 0xc089);
126 + msleep(50);
127 + alc_process_coef_fw(codec, coef0256);
128 + break;
129 case 0x10ec0234:
130 case 0x10ec0274:
131 case 0x10ec0294:
132 @@ -4294,8 +4317,7 @@ static void alc_headset_mode_ctia(struct
133 };
134 static struct coef_fw coef0256[] = {
135 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
136 - WRITE_COEF(0x1b, 0x0c6b),
137 - WRITE_COEFEX(0x57, 0x03, 0x8ea6),
138 + WRITE_COEF(0x1b, 0x0e6b),
139 {}
140 };
141 static struct coef_fw coef0233[] = {
142 @@ -4410,8 +4432,7 @@ static void alc_headset_mode_omtp(struct
143 };
144 static struct coef_fw coef0256[] = {
145 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
146 - WRITE_COEF(0x1b, 0x0c6b),
147 - WRITE_COEFEX(0x57, 0x03, 0x8ea6),
148 + WRITE_COEF(0x1b, 0x0e6b),
149 {}
150 };
151 static struct coef_fw coef0233[] = {
152 @@ -4540,13 +4561,37 @@ static void alc_determine_headset_type(s
153 };
154
155 switch (codec->core.vendor_id) {
156 - case 0x10ec0236:
157 case 0x10ec0255:
158 + alc_process_coef_fw(codec, coef0255);
159 + msleep(300);
160 + val = alc_read_coef_idx(codec, 0x46);
161 + is_ctia = (val & 0x0070) == 0x0070;
162 + break;
163 + case 0x10ec0236:
164 case 0x10ec0256:
165 + alc_write_coef_idx(codec, 0x1b, 0x0e4b);
166 + alc_write_coef_idx(codec, 0x06, 0x6104);
167 + alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
168 +
169 + snd_hda_codec_write(codec, 0x21, 0,
170 + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
171 + msleep(80);
172 + snd_hda_codec_write(codec, 0x21, 0,
173 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
174 +
175 alc_process_coef_fw(codec, coef0255);
176 msleep(300);
177 val = alc_read_coef_idx(codec, 0x46);
178 is_ctia = (val & 0x0070) == 0x0070;
179 +
180 + alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
181 + alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
182 +
183 + snd_hda_codec_write(codec, 0x21, 0,
184 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
185 + msleep(80);
186 + snd_hda_codec_write(codec, 0x21, 0,
187 + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
188 break;
189 case 0x10ec0234:
190 case 0x10ec0274: