xref: /linux/sound/hda/codecs/realtek/alc882.c (revision 177bf8620cf4ed290ee170a6c5966adc0924b336)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 //
3 // Realtek ALC882/883/885/888/889 codec support
4 //
5 // ALC882 is almost identical with ALC880 but has cleaner and more flexible
6 // configuration.  Each pin widget can choose any input DACs and a mixer.
7 // Each ADC is connected from a mixer of all inputs.  This makes possible
8 // 6-channel independent captures.
9 //
10 // In addition, an independent DAC for the multi-playback (not used in this
11 // driver yet).
12 //
13 
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include "realtek.h"
17 
18 /*
19  * Pin config fixes
20  */
21 enum {
22 	ALC882_FIXUP_ABIT_AW9D_MAX,
23 	ALC882_FIXUP_LENOVO_Y530,
24 	ALC882_FIXUP_PB_M5210,
25 	ALC882_FIXUP_ACER_ASPIRE_7736,
26 	ALC882_FIXUP_ASUS_W90V,
27 	ALC889_FIXUP_CD,
28 	ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
29 	ALC889_FIXUP_VAIO_TT,
30 	ALC888_FIXUP_EEE1601,
31 	ALC886_FIXUP_EAPD,
32 	ALC882_FIXUP_EAPD,
33 	ALC883_FIXUP_EAPD,
34 	ALC883_FIXUP_ACER_EAPD,
35 	ALC882_FIXUP_GPIO1,
36 	ALC882_FIXUP_GPIO2,
37 	ALC882_FIXUP_GPIO3,
38 	ALC889_FIXUP_COEF,
39 	ALC882_FIXUP_ASUS_W2JC,
40 	ALC882_FIXUP_ACER_ASPIRE_4930G,
41 	ALC882_FIXUP_ACER_ASPIRE_8930G,
42 	ALC882_FIXUP_ASPIRE_8930G_VERBS,
43 	ALC885_FIXUP_MACPRO_GPIO,
44 	ALC889_FIXUP_DAC_ROUTE,
45 	ALC889_FIXUP_MBP_VREF,
46 	ALC889_FIXUP_IMAC91_VREF,
47 	ALC889_FIXUP_MBA11_VREF,
48 	ALC889_FIXUP_MBA21_VREF,
49 	ALC889_FIXUP_MP11_VREF,
50 	ALC889_FIXUP_MP41_VREF,
51 	ALC882_FIXUP_INV_DMIC,
52 	ALC882_FIXUP_NO_PRIMARY_HP,
53 	ALC887_FIXUP_ASUS_BASS,
54 	ALC887_FIXUP_BASS_CHMAP,
55 	ALC1220_FIXUP_GB_DUAL_CODECS,
56 	ALC1220_FIXUP_GB_X570,
57 	ALC1220_FIXUP_CLEVO_P950,
58 	ALC1220_FIXUP_CLEVO_PB51ED,
59 	ALC1220_FIXUP_CLEVO_PB51ED_PINS,
60 	ALC887_FIXUP_ASUS_AUDIO,
61 	ALC887_FIXUP_ASUS_HMIC,
62 	ALCS1200A_FIXUP_MIC_VREF,
63 	ALC888VD_FIXUP_MIC_100VREF,
64 };
65 
alc889_fixup_coef(struct hda_codec * codec,const struct hda_fixup * fix,int action)66 static void alc889_fixup_coef(struct hda_codec *codec,
67 			      const struct hda_fixup *fix, int action)
68 {
69 	if (action != HDA_FIXUP_ACT_INIT)
70 		return;
71 	alc_update_coef_idx(codec, 7, 0, 0x2030);
72 }
73 
74 /* set up GPIO at initialization */
alc885_fixup_macpro_gpio(struct hda_codec * codec,const struct hda_fixup * fix,int action)75 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
76 				     const struct hda_fixup *fix, int action)
77 {
78 	struct alc_spec *spec = codec->spec;
79 
80 	spec->gpio_write_delay = true;
81 	alc_fixup_gpio3(codec, fix, action);
82 }
83 
84 /* Fix the connection of some pins for ALC889:
85  * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
86  * work correctly (bko#42740)
87  */
alc889_fixup_dac_route(struct hda_codec * codec,const struct hda_fixup * fix,int action)88 static void alc889_fixup_dac_route(struct hda_codec *codec,
89 				   const struct hda_fixup *fix, int action)
90 {
91 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
92 		/* fake the connections during parsing the tree */
93 		static const hda_nid_t conn1[] = { 0x0c, 0x0d };
94 		static const hda_nid_t conn2[] = { 0x0e, 0x0f };
95 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
96 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
97 		snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
98 		snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
99 	} else if (action == HDA_FIXUP_ACT_PROBE) {
100 		/* restore the connections */
101 		static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
102 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
103 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
104 		snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
105 		snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
106 	}
107 }
108 
109 /* Set VREF on HP pin */
alc889_fixup_mbp_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)110 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
111 				  const struct hda_fixup *fix, int action)
112 {
113 	static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
114 	struct alc_spec *spec = codec->spec;
115 	int i;
116 
117 	if (action != HDA_FIXUP_ACT_INIT)
118 		return;
119 	for (i = 0; i < ARRAY_SIZE(nids); i++) {
120 		unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
121 		if (get_defcfg_device(val) != AC_JACK_HP_OUT)
122 			continue;
123 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
124 		val |= AC_PINCTL_VREF_80;
125 		snd_hda_set_pin_ctl(codec, nids[i], val);
126 		spec->gen.keep_vref_in_automute = 1;
127 		break;
128 	}
129 }
130 
alc889_fixup_mac_pins(struct hda_codec * codec,const hda_nid_t * nids,int num_nids)131 static void alc889_fixup_mac_pins(struct hda_codec *codec,
132 				  const hda_nid_t *nids, int num_nids)
133 {
134 	struct alc_spec *spec = codec->spec;
135 	int i;
136 
137 	for (i = 0; i < num_nids; i++) {
138 		unsigned int val;
139 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
140 		val |= AC_PINCTL_VREF_50;
141 		snd_hda_set_pin_ctl(codec, nids[i], val);
142 	}
143 	spec->gen.keep_vref_in_automute = 1;
144 }
145 
146 /* Set VREF on speaker pins on imac91 */
alc889_fixup_imac91_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)147 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
148 				     const struct hda_fixup *fix, int action)
149 {
150 	static const hda_nid_t nids[] = { 0x18, 0x1a };
151 
152 	if (action == HDA_FIXUP_ACT_INIT)
153 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
154 }
155 
156 /* Set VREF on speaker pins on mba11 */
alc889_fixup_mba11_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)157 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
158 				    const struct hda_fixup *fix, int action)
159 {
160 	static const hda_nid_t nids[] = { 0x18 };
161 
162 	if (action == HDA_FIXUP_ACT_INIT)
163 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
164 }
165 
166 /* Set VREF on speaker pins on mba21 */
alc889_fixup_mba21_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)167 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
168 				    const struct hda_fixup *fix, int action)
169 {
170 	static const hda_nid_t nids[] = { 0x18, 0x19 };
171 
172 	if (action == HDA_FIXUP_ACT_INIT)
173 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
174 }
175 
176 /* Don't take HP output as primary
177  * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
178  * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
179  */
alc882_fixup_no_primary_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)180 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
181 				       const struct hda_fixup *fix, int action)
182 {
183 	struct alc_spec *spec = codec->spec;
184 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
185 		spec->gen.no_primary_hp = 1;
186 		spec->gen.no_multi_io = 1;
187 	}
188 }
189 
alc1220_fixup_gb_x570(struct hda_codec * codec,const struct hda_fixup * fix,int action)190 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
191 				     const struct hda_fixup *fix,
192 				     int action)
193 {
194 	static const hda_nid_t conn1[] = { 0x0c };
195 	static const struct coef_fw gb_x570_coefs[] = {
196 		WRITE_COEF(0x07, 0x03c0),
197 		WRITE_COEF(0x1a, 0x01c1),
198 		WRITE_COEF(0x1b, 0x0202),
199 		WRITE_COEF(0x43, 0x3005),
200 		{}
201 	};
202 
203 	switch (action) {
204 	case HDA_FIXUP_ACT_PRE_PROBE:
205 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
206 		snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
207 		break;
208 	case HDA_FIXUP_ACT_INIT:
209 		alc_process_coef_fw(codec, gb_x570_coefs);
210 		break;
211 	}
212 }
213 
alc1220_fixup_clevo_p950(struct hda_codec * codec,const struct hda_fixup * fix,int action)214 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
215 				     const struct hda_fixup *fix,
216 				     int action)
217 {
218 	static const hda_nid_t conn1[] = { 0x0c };
219 
220 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
221 		return;
222 
223 	alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
224 	/* We therefore want to make sure 0x14 (front headphone) and
225 	 * 0x1b (speakers) use the stereo DAC 0x02
226 	 */
227 	snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
228 	snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
229 }
230 
alc1220_fixup_clevo_pb51ed(struct hda_codec * codec,const struct hda_fixup * fix,int action)231 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
232 				     const struct hda_fixup *fix,
233 				     int action)
234 {
235 	alc1220_fixup_clevo_p950(codec, fix, action);
236 	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
237 }
238 
alc887_asus_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)239 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
240 					 struct hda_jack_callback *jack)
241 {
242 	struct alc_spec *spec = codec->spec;
243 	unsigned int vref;
244 
245 	snd_hda_gen_hp_automute(codec, jack);
246 
247 	if (spec->gen.hp_jack_present)
248 		vref = AC_PINCTL_VREF_80;
249 	else
250 		vref = AC_PINCTL_VREF_HIZ;
251 	snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
252 }
253 
alc887_fixup_asus_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)254 static void alc887_fixup_asus_jack(struct hda_codec *codec,
255 				     const struct hda_fixup *fix, int action)
256 {
257 	struct alc_spec *spec = codec->spec;
258 	if (action != HDA_FIXUP_ACT_PROBE)
259 		return;
260 	snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
261 	spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
262 }
263 
264 static const struct hda_fixup alc882_fixups[] = {
265 	[ALC882_FIXUP_ABIT_AW9D_MAX] = {
266 		.type = HDA_FIXUP_PINS,
267 		.v.pins = (const struct hda_pintbl[]) {
268 			{ 0x15, 0x01080104 }, /* side */
269 			{ 0x16, 0x01011012 }, /* rear */
270 			{ 0x17, 0x01016011 }, /* clfe */
271 			{ }
272 		}
273 	},
274 	[ALC882_FIXUP_LENOVO_Y530] = {
275 		.type = HDA_FIXUP_PINS,
276 		.v.pins = (const struct hda_pintbl[]) {
277 			{ 0x15, 0x99130112 }, /* rear int speakers */
278 			{ 0x16, 0x99130111 }, /* subwoofer */
279 			{ }
280 		}
281 	},
282 	[ALC882_FIXUP_PB_M5210] = {
283 		.type = HDA_FIXUP_PINCTLS,
284 		.v.pins = (const struct hda_pintbl[]) {
285 			{ 0x19, PIN_VREF50 },
286 			{}
287 		}
288 	},
289 	[ALC882_FIXUP_ACER_ASPIRE_7736] = {
290 		.type = HDA_FIXUP_FUNC,
291 		.v.func = alc_fixup_sku_ignore,
292 	},
293 	[ALC882_FIXUP_ASUS_W90V] = {
294 		.type = HDA_FIXUP_PINS,
295 		.v.pins = (const struct hda_pintbl[]) {
296 			{ 0x16, 0x99130110 }, /* fix sequence for CLFE */
297 			{ }
298 		}
299 	},
300 	[ALC889_FIXUP_CD] = {
301 		.type = HDA_FIXUP_PINS,
302 		.v.pins = (const struct hda_pintbl[]) {
303 			{ 0x1c, 0x993301f0 }, /* CD */
304 			{ }
305 		}
306 	},
307 	[ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
308 		.type = HDA_FIXUP_PINS,
309 		.v.pins = (const struct hda_pintbl[]) {
310 			{ 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
311 			{ }
312 		},
313 		.chained = true,
314 		.chain_id = ALC889_FIXUP_CD,
315 	},
316 	[ALC889_FIXUP_VAIO_TT] = {
317 		.type = HDA_FIXUP_PINS,
318 		.v.pins = (const struct hda_pintbl[]) {
319 			{ 0x17, 0x90170111 }, /* hidden surround speaker */
320 			{ }
321 		}
322 	},
323 	[ALC888_FIXUP_EEE1601] = {
324 		.type = HDA_FIXUP_VERBS,
325 		.v.verbs = (const struct hda_verb[]) {
326 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
327 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
328 			{ }
329 		}
330 	},
331 	[ALC886_FIXUP_EAPD] = {
332 		.type = HDA_FIXUP_VERBS,
333 		.v.verbs = (const struct hda_verb[]) {
334 			/* change to EAPD mode */
335 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
336 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0068 },
337 			{ }
338 		}
339 	},
340 	[ALC882_FIXUP_EAPD] = {
341 		.type = HDA_FIXUP_VERBS,
342 		.v.verbs = (const struct hda_verb[]) {
343 			/* change to EAPD mode */
344 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
345 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
346 			{ }
347 		}
348 	},
349 	[ALC883_FIXUP_EAPD] = {
350 		.type = HDA_FIXUP_VERBS,
351 		.v.verbs = (const struct hda_verb[]) {
352 			/* change to EAPD mode */
353 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
354 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
355 			{ }
356 		}
357 	},
358 	[ALC883_FIXUP_ACER_EAPD] = {
359 		.type = HDA_FIXUP_VERBS,
360 		.v.verbs = (const struct hda_verb[]) {
361 			/* eanable EAPD on Acer laptops */
362 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
363 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
364 			{ }
365 		}
366 	},
367 	[ALC882_FIXUP_GPIO1] = {
368 		.type = HDA_FIXUP_FUNC,
369 		.v.func = alc_fixup_gpio1,
370 	},
371 	[ALC882_FIXUP_GPIO2] = {
372 		.type = HDA_FIXUP_FUNC,
373 		.v.func = alc_fixup_gpio2,
374 	},
375 	[ALC882_FIXUP_GPIO3] = {
376 		.type = HDA_FIXUP_FUNC,
377 		.v.func = alc_fixup_gpio3,
378 	},
379 	[ALC882_FIXUP_ASUS_W2JC] = {
380 		.type = HDA_FIXUP_FUNC,
381 		.v.func = alc_fixup_gpio1,
382 		.chained = true,
383 		.chain_id = ALC882_FIXUP_EAPD,
384 	},
385 	[ALC889_FIXUP_COEF] = {
386 		.type = HDA_FIXUP_FUNC,
387 		.v.func = alc889_fixup_coef,
388 	},
389 	[ALC882_FIXUP_ACER_ASPIRE_4930G] = {
390 		.type = HDA_FIXUP_PINS,
391 		.v.pins = (const struct hda_pintbl[]) {
392 			{ 0x16, 0x99130111 }, /* CLFE speaker */
393 			{ 0x17, 0x99130112 }, /* surround speaker */
394 			{ }
395 		},
396 		.chained = true,
397 		.chain_id = ALC882_FIXUP_GPIO1,
398 	},
399 	[ALC882_FIXUP_ACER_ASPIRE_8930G] = {
400 		.type = HDA_FIXUP_PINS,
401 		.v.pins = (const struct hda_pintbl[]) {
402 			{ 0x16, 0x99130111 }, /* CLFE speaker */
403 			{ 0x1b, 0x99130112 }, /* surround speaker */
404 			{ }
405 		},
406 		.chained = true,
407 		.chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
408 	},
409 	[ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
410 		/* additional init verbs for Acer Aspire 8930G */
411 		.type = HDA_FIXUP_VERBS,
412 		.v.verbs = (const struct hda_verb[]) {
413 			/* Enable all DACs */
414 			/* DAC DISABLE/MUTE 1? */
415 			/*  setting bits 1-5 disables DAC nids 0x02-0x06
416 			 *  apparently. Init=0x38 */
417 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
418 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
419 			/* DAC DISABLE/MUTE 2? */
420 			/*  some bit here disables the other DACs.
421 			 *  Init=0x4900 */
422 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
423 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
424 			/* DMIC fix
425 			 * This laptop has a stereo digital microphone.
426 			 * The mics are only 1cm apart which makes the stereo
427 			 * useless. However, either the mic or the ALC889
428 			 * makes the signal become a difference/sum signal
429 			 * instead of standard stereo, which is annoying.
430 			 * So instead we flip this bit which makes the
431 			 * codec replicate the sum signal to both channels,
432 			 * turning it into a normal mono mic.
433 			 */
434 			/* DMIC_CONTROL? Init value = 0x0001 */
435 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
436 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
437 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
438 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
439 			{ }
440 		},
441 		.chained = true,
442 		.chain_id = ALC882_FIXUP_GPIO1,
443 	},
444 	[ALC885_FIXUP_MACPRO_GPIO] = {
445 		.type = HDA_FIXUP_FUNC,
446 		.v.func = alc885_fixup_macpro_gpio,
447 	},
448 	[ALC889_FIXUP_DAC_ROUTE] = {
449 		.type = HDA_FIXUP_FUNC,
450 		.v.func = alc889_fixup_dac_route,
451 	},
452 	[ALC889_FIXUP_MBP_VREF] = {
453 		.type = HDA_FIXUP_FUNC,
454 		.v.func = alc889_fixup_mbp_vref,
455 		.chained = true,
456 		.chain_id = ALC882_FIXUP_GPIO1,
457 	},
458 	[ALC889_FIXUP_IMAC91_VREF] = {
459 		.type = HDA_FIXUP_FUNC,
460 		.v.func = alc889_fixup_imac91_vref,
461 		.chained = true,
462 		.chain_id = ALC882_FIXUP_GPIO1,
463 	},
464 	[ALC889_FIXUP_MBA11_VREF] = {
465 		.type = HDA_FIXUP_FUNC,
466 		.v.func = alc889_fixup_mba11_vref,
467 		.chained = true,
468 		.chain_id = ALC889_FIXUP_MBP_VREF,
469 	},
470 	[ALC889_FIXUP_MBA21_VREF] = {
471 		.type = HDA_FIXUP_FUNC,
472 		.v.func = alc889_fixup_mba21_vref,
473 		.chained = true,
474 		.chain_id = ALC889_FIXUP_MBP_VREF,
475 	},
476 	[ALC889_FIXUP_MP11_VREF] = {
477 		.type = HDA_FIXUP_FUNC,
478 		.v.func = alc889_fixup_mba11_vref,
479 		.chained = true,
480 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
481 	},
482 	[ALC889_FIXUP_MP41_VREF] = {
483 		.type = HDA_FIXUP_FUNC,
484 		.v.func = alc889_fixup_mbp_vref,
485 		.chained = true,
486 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
487 	},
488 	[ALC882_FIXUP_INV_DMIC] = {
489 		.type = HDA_FIXUP_FUNC,
490 		.v.func = alc_fixup_inv_dmic,
491 	},
492 	[ALC882_FIXUP_NO_PRIMARY_HP] = {
493 		.type = HDA_FIXUP_FUNC,
494 		.v.func = alc882_fixup_no_primary_hp,
495 	},
496 	[ALC887_FIXUP_ASUS_BASS] = {
497 		.type = HDA_FIXUP_PINS,
498 		.v.pins = (const struct hda_pintbl[]) {
499 			{0x16, 0x99130130}, /* bass speaker */
500 			{}
501 		},
502 		.chained = true,
503 		.chain_id = ALC887_FIXUP_BASS_CHMAP,
504 	},
505 	[ALC887_FIXUP_BASS_CHMAP] = {
506 		.type = HDA_FIXUP_FUNC,
507 		.v.func = alc_fixup_bass_chmap,
508 	},
509 	[ALC1220_FIXUP_GB_DUAL_CODECS] = {
510 		.type = HDA_FIXUP_FUNC,
511 		.v.func = alc1220_fixup_gb_dual_codecs,
512 	},
513 	[ALC1220_FIXUP_GB_X570] = {
514 		.type = HDA_FIXUP_FUNC,
515 		.v.func = alc1220_fixup_gb_x570,
516 	},
517 	[ALC1220_FIXUP_CLEVO_P950] = {
518 		.type = HDA_FIXUP_FUNC,
519 		.v.func = alc1220_fixup_clevo_p950,
520 	},
521 	[ALC1220_FIXUP_CLEVO_PB51ED] = {
522 		.type = HDA_FIXUP_FUNC,
523 		.v.func = alc1220_fixup_clevo_pb51ed,
524 	},
525 	[ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
526 		.type = HDA_FIXUP_PINS,
527 		.v.pins = (const struct hda_pintbl[]) {
528 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
529 			{}
530 		},
531 		.chained = true,
532 		.chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
533 	},
534 	[ALC887_FIXUP_ASUS_AUDIO] = {
535 		.type = HDA_FIXUP_PINS,
536 		.v.pins = (const struct hda_pintbl[]) {
537 			{ 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
538 			{ 0x19, 0x22219420 },
539 			{}
540 		},
541 	},
542 	[ALC887_FIXUP_ASUS_HMIC] = {
543 		.type = HDA_FIXUP_FUNC,
544 		.v.func = alc887_fixup_asus_jack,
545 		.chained = true,
546 		.chain_id = ALC887_FIXUP_ASUS_AUDIO,
547 	},
548 	[ALCS1200A_FIXUP_MIC_VREF] = {
549 		.type = HDA_FIXUP_PINCTLS,
550 		.v.pins = (const struct hda_pintbl[]) {
551 			{ 0x18, PIN_VREF50 }, /* rear mic */
552 			{ 0x19, PIN_VREF50 }, /* front mic */
553 			{}
554 		}
555 	},
556 	[ALC888VD_FIXUP_MIC_100VREF] = {
557 		.type = HDA_FIXUP_PINCTLS,
558 		.v.pins = (const struct hda_pintbl[]) {
559 			{ 0x18, PIN_VREF100 }, /* headset mic */
560 			{}
561 		}
562 	},
563 };
564 
565 static const struct hda_quirk alc882_fixup_tbl[] = {
566 	SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
567 	SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
568 	SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
569 	SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
570 	SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
571 	SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
572 	SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
573 	SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
574 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
575 	SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
576 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
577 	SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
578 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
579 	SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
580 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
581 	SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
582 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
583 	SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
584 	SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
585 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
586 	SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
587 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
588 	SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
589 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
590 	SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
591 	SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
592 	SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
593 	SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
594 	SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
595 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
596 	SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
597 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
598 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
599 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
600 	SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF),
601 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
602 	SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
603 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
604 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
605 	SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
606 
607 	/* All Apple entries are in codec SSIDs */
608 	SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
609 	SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
610 	SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
611 	SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
612 	SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
613 	SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
614 	SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
615 	SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
616 	SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
617 	SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
618 	SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
619 	SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
620 	SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
621 	SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
622 	SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
623 	SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
624 	SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
625 	SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
626 	SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
627 	SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
628 	SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
629 	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
630 
631 	SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
632 	SND_PCI_QUIRK(0x10ec, 0x12d8, "iBase Elo Touch", ALC888VD_FIXUP_MIC_100VREF),
633 	SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
634 	SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
635 	SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
636 	SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570),
637 	SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570),
638 	SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570),
639 	SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
640 	SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
641 	SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
642 	SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
643 	SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
644 	SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
645 	SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
646 	SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS),
647 	SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
648 	SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
649 	SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
650 	SND_PCI_QUIRK(0x1558, 0x3702, "Clevo X370SN[VW]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
651 	SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
652 	SND_PCI_QUIRK(0x1558, 0x5802, "Clevo X58[05]WN[RST]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
653 	SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
654 	SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
655 	SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
656 	SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
657 	SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
658 	SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
659 	SND_PCI_QUIRK(0x1558, 0x66a2, "Clevo PE60RNE", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
660 	SND_PCI_QUIRK(0x1558, 0x66a6, "Clevo PE60SN[CDE]-[GS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
661 	SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
662 	SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
663 	SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
664 	SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
665 	SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
666 	SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
667 	SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
668 	SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
669 	SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
670 	SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
671 	SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
672 	SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
673 	SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
674 	SND_PCI_QUIRK(0x1558, 0x95e3, "Clevo P955[ER]T", ALC1220_FIXUP_CLEVO_P950),
675 	SND_PCI_QUIRK(0x1558, 0x95e4, "Clevo P955ER", ALC1220_FIXUP_CLEVO_P950),
676 	SND_PCI_QUIRK(0x1558, 0x95e5, "Clevo P955EE6", ALC1220_FIXUP_CLEVO_P950),
677 	SND_PCI_QUIRK(0x1558, 0x95e6, "Clevo P950R[CDF]", ALC1220_FIXUP_CLEVO_P950),
678 	SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
679 	SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
680 	SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
681 	SND_PCI_QUIRK(0x1558, 0xd502, "Clevo PD50SNE", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
682 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
683 	SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
684 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
685 	SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
686 	{}
687 };
688 
689 static const struct hda_model_fixup alc882_fixup_models[] = {
690 	{.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
691 	{.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
692 	{.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
693 	{.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
694 	{.id = ALC889_FIXUP_CD, .name = "cd"},
695 	{.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
696 	{.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
697 	{.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
698 	{.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
699 	{.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
700 	{.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
701 	{.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
702 	{.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
703 	{.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
704 	{.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
705 	{.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
706 	{.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
707 	{.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
708 	{.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
709 	{.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
710 	{.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
711 	{.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
712 	{.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
713 	{.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
714 	{.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
715 	{.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
716 	{.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
717 	{.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
718 	{.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
719 	{.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
720 	{.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
721 	{.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
722 	{}
723 };
724 
725 static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = {
726 	SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950,
727 		{0x14, 0x01014010},
728 		{0x15, 0x01011012},
729 		{0x16, 0x01016011},
730 		{0x18, 0x01a19040},
731 		{0x19, 0x02a19050},
732 		{0x1a, 0x0181304f},
733 		{0x1b, 0x0221401f},
734 		{0x1e, 0x01456130}),
735 	SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
736 		{0x14, 0x01015010},
737 		{0x15, 0x01011012},
738 		{0x16, 0x01011011},
739 		{0x18, 0x01a11040},
740 		{0x19, 0x02a19050},
741 		{0x1a, 0x0181104f},
742 		{0x1b, 0x0221401f},
743 		{0x1e, 0x01451130}),
744 	{}
745 };
746 
747 /*
748  * BIOS auto configuration
749  */
750 /* almost identical with ALC880 parser... */
alc882_parse_auto_config(struct hda_codec * codec)751 static int alc882_parse_auto_config(struct hda_codec *codec)
752 {
753 	static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
754 	static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
755 	return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
756 }
757 
758 /*
759  */
alc882_probe(struct hda_codec * codec,const struct hda_device_id * id)760 static int alc882_probe(struct hda_codec *codec, const struct hda_device_id *id)
761 {
762 	struct alc_spec *spec;
763 	int err;
764 
765 	err = alc_alloc_spec(codec, 0x0b);
766 	if (err < 0)
767 		return err;
768 
769 	spec = codec->spec;
770 
771 	switch (codec->core.vendor_id) {
772 	case 0x10ec0882:
773 	case 0x10ec0885:
774 	case 0x10ec0900:
775 	case 0x10ec0b00:
776 	case 0x10ec1220:
777 		break;
778 	default:
779 		/* ALC883 and variants */
780 		alc_fix_pll_init(codec, 0x20, 0x0a, 10);
781 		break;
782 	}
783 
784 	alc_pre_init(codec);
785 
786 	snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
787 		       alc882_fixups);
788 	snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
789 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
790 
791 	alc_auto_parse_customize_define(codec);
792 
793 	if (has_cdefine_beep(codec))
794 		spec->gen.beep_nid = 0x01;
795 
796 	/* automatic parse from the BIOS config */
797 	err = alc882_parse_auto_config(codec);
798 	if (err < 0)
799 		goto error;
800 
801 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
802 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
803 		if (err < 0)
804 			goto error;
805 	}
806 
807 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
808 
809 	return 0;
810 
811  error:
812 	snd_hda_gen_remove(codec);
813 	return err;
814 }
815 
816 static const struct hda_codec_ops alc882_codec_ops = {
817 	.probe = alc882_probe,
818 	.remove = snd_hda_gen_remove,
819 	.build_controls = alc_build_controls,
820 	.build_pcms = snd_hda_gen_build_pcms,
821 	.init = alc_init,
822 	.unsol_event = snd_hda_jack_unsol_event,
823 	.resume = alc_resume,
824 	.suspend = alc_suspend,
825 	.check_power_status = snd_hda_gen_check_power_status,
826 	.stream_pm = snd_hda_gen_stream_pm,
827 };
828 
829 /*
830  * driver entries
831  */
832 static const struct hda_device_id snd_hda_id_alc882[] = {
833 	HDA_CODEC_ID_REV(0x10ec0662, 0x100002, "ALC662 rev2"),
834 	HDA_CODEC_ID(0x10ec0882, "ALC882"),
835 	HDA_CODEC_ID(0x10ec0883, "ALC883"),
836 	HDA_CODEC_ID_REV(0x10ec0885, 0x100101, "ALC889A"),
837 	HDA_CODEC_ID_REV(0x10ec0885, 0x100103, "ALC889A"),
838 	HDA_CODEC_ID(0x10ec0885, "ALC885"),
839 	HDA_CODEC_ID(0x10ec0887, "ALC887"),
840 	HDA_CODEC_ID_REV(0x10ec0888, 0x100101, "ALC1200"),
841 	HDA_CODEC_ID(0x10ec0888, "ALC888"),
842 	HDA_CODEC_ID(0x10ec0889, "ALC889"),
843 	HDA_CODEC_ID(0x10ec0899, "ALC898"),
844 	HDA_CODEC_ID(0x10ec0900, "ALC1150"),
845 	HDA_CODEC_ID(0x10ec0b00, "ALCS1200A"),
846 	HDA_CODEC_ID(0x10ec1168, "ALC1220"),
847 	HDA_CODEC_ID(0x10ec1220, "ALC1220"),
848 	{} /* terminator */
849 };
850 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc882);
851 
852 MODULE_LICENSE("GPL");
853 MODULE_DESCRIPTION("Realtek ALC882 and compatible HD-audio codecs");
854 MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");
855 
856 static struct hda_codec_driver alc882_driver = {
857 	.id = snd_hda_id_alc882,
858 	.ops = &alc882_codec_ops,
859 };
860 
861 module_hda_codec_driver(alc882_driver);
862