1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Universal Interface for Intel High Definition Audio Codec
4  *
5  * HD audio interface patch for Realtek ALC codecs
6  *
7  * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
8  *                    PeiSen Hou <pshou@realtek.com.tw>
9  *                    Takashi Iwai <tiwai@suse.de>
10  *                    Jonathan Woithe <jwoithe@just42.net>
11  */
12 
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/slab.h>
16 #include <linux/pci.h>
17 #include <linux/dmi.h>
18 #include <linux/module.h>
19 #include <linux/input.h>
20 #include <linux/leds.h>
21 #include <sound/core.h>
22 #include <sound/jack.h>
23 #include <sound/hda_codec.h>
24 #include "hda_local.h"
25 #include "hda_auto_parser.h"
26 #include "hda_jack.h"
27 #include "hda_generic.h"
28 #include "hda_component.h"
29 
30 /* keep halting ALC5505 DSP, for power saving */
31 #define HALT_REALTEK_ALC5505
32 
33 /* extra amp-initialization sequence types */
34 enum {
35 	ALC_INIT_UNDEFINED,
36 	ALC_INIT_NONE,
37 	ALC_INIT_DEFAULT,
38 };
39 
40 enum {
41 	ALC_HEADSET_MODE_UNKNOWN,
42 	ALC_HEADSET_MODE_UNPLUGGED,
43 	ALC_HEADSET_MODE_HEADSET,
44 	ALC_HEADSET_MODE_MIC,
45 	ALC_HEADSET_MODE_HEADPHONE,
46 };
47 
48 enum {
49 	ALC_HEADSET_TYPE_UNKNOWN,
50 	ALC_HEADSET_TYPE_CTIA,
51 	ALC_HEADSET_TYPE_OMTP,
52 };
53 
54 enum {
55 	ALC_KEY_MICMUTE_INDEX,
56 };
57 
58 struct alc_customize_define {
59 	unsigned int  sku_cfg;
60 	unsigned char port_connectivity;
61 	unsigned char check_sum;
62 	unsigned char customization;
63 	unsigned char external_amp;
64 	unsigned int  enable_pcbeep:1;
65 	unsigned int  platform_type:1;
66 	unsigned int  swap:1;
67 	unsigned int  override:1;
68 	unsigned int  fixup:1; /* Means that this sku is set by driver, not read from hw */
69 };
70 
71 struct alc_coef_led {
72 	unsigned int idx;
73 	unsigned int mask;
74 	unsigned int on;
75 	unsigned int off;
76 };
77 
78 struct alc_spec {
79 	struct hda_gen_spec gen; /* must be at head */
80 
81 	/* codec parameterization */
82 	struct alc_customize_define cdefine;
83 	unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
84 
85 	/* GPIO bits */
86 	unsigned int gpio_mask;
87 	unsigned int gpio_dir;
88 	unsigned int gpio_data;
89 	bool gpio_write_delay;	/* add a delay before writing gpio_data */
90 
91 	/* mute LED for HP laptops, see vref_mute_led_set() */
92 	int mute_led_polarity;
93 	int micmute_led_polarity;
94 	hda_nid_t mute_led_nid;
95 	hda_nid_t cap_mute_led_nid;
96 
97 	unsigned int gpio_mute_led_mask;
98 	unsigned int gpio_mic_led_mask;
99 	struct alc_coef_led mute_led_coef;
100 	struct alc_coef_led mic_led_coef;
101 	struct mutex coef_mutex;
102 
103 	hda_nid_t headset_mic_pin;
104 	hda_nid_t headphone_mic_pin;
105 	int current_headset_mode;
106 	int current_headset_type;
107 
108 	/* hooks */
109 	void (*init_hook)(struct hda_codec *codec);
110 #ifdef CONFIG_PM
111 	void (*power_hook)(struct hda_codec *codec);
112 #endif
113 	void (*shutup)(struct hda_codec *codec);
114 
115 	int init_amp;
116 	int codec_variant;	/* flag for other variants */
117 	unsigned int has_alc5505_dsp:1;
118 	unsigned int no_depop_delay:1;
119 	unsigned int done_hp_init:1;
120 	unsigned int no_shutup_pins:1;
121 	unsigned int ultra_low_power:1;
122 	unsigned int has_hs_key:1;
123 	unsigned int no_internal_mic_pin:1;
124 
125 	/* for PLL fix */
126 	hda_nid_t pll_nid;
127 	unsigned int pll_coef_idx, pll_coef_bit;
128 	unsigned int coef0;
129 	struct input_dev *kb_dev;
130 	u8 alc_mute_keycode_map[1];
131 
132 	/* component binding */
133 	struct component_match *match;
134 	struct hda_component comps[HDA_MAX_COMPONENTS];
135 };
136 
137 /*
138  * COEF access helper functions
139  */
140 
coef_mutex_lock(struct hda_codec * codec)141 static void coef_mutex_lock(struct hda_codec *codec)
142 {
143 	struct alc_spec *spec = codec->spec;
144 
145 	snd_hda_power_up_pm(codec);
146 	mutex_lock(&spec->coef_mutex);
147 }
148 
coef_mutex_unlock(struct hda_codec * codec)149 static void coef_mutex_unlock(struct hda_codec *codec)
150 {
151 	struct alc_spec *spec = codec->spec;
152 
153 	mutex_unlock(&spec->coef_mutex);
154 	snd_hda_power_down_pm(codec);
155 }
156 
__alc_read_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx)157 static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
158 				 unsigned int coef_idx)
159 {
160 	unsigned int val;
161 
162 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
163 	val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
164 	return val;
165 }
166 
alc_read_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx)167 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
168 			       unsigned int coef_idx)
169 {
170 	unsigned int val;
171 
172 	coef_mutex_lock(codec);
173 	val = __alc_read_coefex_idx(codec, nid, coef_idx);
174 	coef_mutex_unlock(codec);
175 	return val;
176 }
177 
178 #define alc_read_coef_idx(codec, coef_idx) \
179 	alc_read_coefex_idx(codec, 0x20, coef_idx)
180 
__alc_write_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int coef_val)181 static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
182 				   unsigned int coef_idx, unsigned int coef_val)
183 {
184 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
185 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
186 }
187 
alc_write_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int coef_val)188 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
189 				 unsigned int coef_idx, unsigned int coef_val)
190 {
191 	coef_mutex_lock(codec);
192 	__alc_write_coefex_idx(codec, nid, coef_idx, coef_val);
193 	coef_mutex_unlock(codec);
194 }
195 
196 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
197 	alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
198 
__alc_update_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int mask,unsigned int bits_set)199 static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
200 				    unsigned int coef_idx, unsigned int mask,
201 				    unsigned int bits_set)
202 {
203 	unsigned int val = __alc_read_coefex_idx(codec, nid, coef_idx);
204 
205 	if (val != -1)
206 		__alc_write_coefex_idx(codec, nid, coef_idx,
207 				       (val & ~mask) | bits_set);
208 }
209 
alc_update_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int mask,unsigned int bits_set)210 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
211 				  unsigned int coef_idx, unsigned int mask,
212 				  unsigned int bits_set)
213 {
214 	coef_mutex_lock(codec);
215 	__alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set);
216 	coef_mutex_unlock(codec);
217 }
218 
219 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set)	\
220 	alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
221 
222 /* a special bypass for COEF 0; read the cached value at the second time */
alc_get_coef0(struct hda_codec * codec)223 static unsigned int alc_get_coef0(struct hda_codec *codec)
224 {
225 	struct alc_spec *spec = codec->spec;
226 
227 	if (!spec->coef0)
228 		spec->coef0 = alc_read_coef_idx(codec, 0);
229 	return spec->coef0;
230 }
231 
232 /* coef writes/updates batch */
233 struct coef_fw {
234 	unsigned char nid;
235 	unsigned char idx;
236 	unsigned short mask;
237 	unsigned short val;
238 };
239 
240 #define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
241 	{ .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
242 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
243 #define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
244 #define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
245 
alc_process_coef_fw(struct hda_codec * codec,const struct coef_fw * fw)246 static void alc_process_coef_fw(struct hda_codec *codec,
247 				const struct coef_fw *fw)
248 {
249 	coef_mutex_lock(codec);
250 	for (; fw->nid; fw++) {
251 		if (fw->mask == (unsigned short)-1)
252 			__alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
253 		else
254 			__alc_update_coefex_idx(codec, fw->nid, fw->idx,
255 						fw->mask, fw->val);
256 	}
257 	coef_mutex_unlock(codec);
258 }
259 
260 /*
261  * GPIO setup tables, used in initialization
262  */
263 
264 /* Enable GPIO mask and set output */
alc_setup_gpio(struct hda_codec * codec,unsigned int mask)265 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
266 {
267 	struct alc_spec *spec = codec->spec;
268 
269 	spec->gpio_mask |= mask;
270 	spec->gpio_dir |= mask;
271 	spec->gpio_data |= mask;
272 }
273 
alc_write_gpio_data(struct hda_codec * codec)274 static void alc_write_gpio_data(struct hda_codec *codec)
275 {
276 	struct alc_spec *spec = codec->spec;
277 
278 	snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
279 			    spec->gpio_data);
280 }
281 
alc_update_gpio_data(struct hda_codec * codec,unsigned int mask,bool on)282 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
283 				 bool on)
284 {
285 	struct alc_spec *spec = codec->spec;
286 	unsigned int oldval = spec->gpio_data;
287 
288 	if (on)
289 		spec->gpio_data |= mask;
290 	else
291 		spec->gpio_data &= ~mask;
292 	if (oldval != spec->gpio_data)
293 		alc_write_gpio_data(codec);
294 }
295 
alc_write_gpio(struct hda_codec * codec)296 static void alc_write_gpio(struct hda_codec *codec)
297 {
298 	struct alc_spec *spec = codec->spec;
299 
300 	if (!spec->gpio_mask)
301 		return;
302 
303 	snd_hda_codec_write(codec, codec->core.afg, 0,
304 			    AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
305 	snd_hda_codec_write(codec, codec->core.afg, 0,
306 			    AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
307 	if (spec->gpio_write_delay)
308 		msleep(1);
309 	alc_write_gpio_data(codec);
310 }
311 
alc_fixup_gpio(struct hda_codec * codec,int action,unsigned int mask)312 static void alc_fixup_gpio(struct hda_codec *codec, int action,
313 			   unsigned int mask)
314 {
315 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
316 		alc_setup_gpio(codec, mask);
317 }
318 
alc_fixup_gpio1(struct hda_codec * codec,const struct hda_fixup * fix,int action)319 static void alc_fixup_gpio1(struct hda_codec *codec,
320 			    const struct hda_fixup *fix, int action)
321 {
322 	alc_fixup_gpio(codec, action, 0x01);
323 }
324 
alc_fixup_gpio2(struct hda_codec * codec,const struct hda_fixup * fix,int action)325 static void alc_fixup_gpio2(struct hda_codec *codec,
326 			    const struct hda_fixup *fix, int action)
327 {
328 	alc_fixup_gpio(codec, action, 0x02);
329 }
330 
alc_fixup_gpio3(struct hda_codec * codec,const struct hda_fixup * fix,int action)331 static void alc_fixup_gpio3(struct hda_codec *codec,
332 			    const struct hda_fixup *fix, int action)
333 {
334 	alc_fixup_gpio(codec, action, 0x03);
335 }
336 
alc_fixup_gpio4(struct hda_codec * codec,const struct hda_fixup * fix,int action)337 static void alc_fixup_gpio4(struct hda_codec *codec,
338 			    const struct hda_fixup *fix, int action)
339 {
340 	alc_fixup_gpio(codec, action, 0x04);
341 }
342 
alc_fixup_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)343 static void alc_fixup_micmute_led(struct hda_codec *codec,
344 				  const struct hda_fixup *fix, int action)
345 {
346 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
347 		snd_hda_gen_add_micmute_led_cdev(codec, NULL);
348 }
349 
350 /*
351  * Fix hardware PLL issue
352  * On some codecs, the analog PLL gating control must be off while
353  * the default value is 1.
354  */
alc_fix_pll(struct hda_codec * codec)355 static void alc_fix_pll(struct hda_codec *codec)
356 {
357 	struct alc_spec *spec = codec->spec;
358 
359 	if (spec->pll_nid)
360 		alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
361 				      1 << spec->pll_coef_bit, 0);
362 }
363 
alc_fix_pll_init(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int coef_bit)364 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
365 			     unsigned int coef_idx, unsigned int coef_bit)
366 {
367 	struct alc_spec *spec = codec->spec;
368 	spec->pll_nid = nid;
369 	spec->pll_coef_idx = coef_idx;
370 	spec->pll_coef_bit = coef_bit;
371 	alc_fix_pll(codec);
372 }
373 
374 /* update the master volume per volume-knob's unsol event */
alc_update_knob_master(struct hda_codec * codec,struct hda_jack_callback * jack)375 static void alc_update_knob_master(struct hda_codec *codec,
376 				   struct hda_jack_callback *jack)
377 {
378 	unsigned int val;
379 	struct snd_kcontrol *kctl;
380 	struct snd_ctl_elem_value *uctl;
381 
382 	kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
383 	if (!kctl)
384 		return;
385 	uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
386 	if (!uctl)
387 		return;
388 	val = snd_hda_codec_read(codec, jack->nid, 0,
389 				 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
390 	val &= HDA_AMP_VOLMASK;
391 	uctl->value.integer.value[0] = val;
392 	uctl->value.integer.value[1] = val;
393 	kctl->put(kctl, uctl);
394 	kfree(uctl);
395 }
396 
alc880_unsol_event(struct hda_codec * codec,unsigned int res)397 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
398 {
399 	/* For some reason, the res given from ALC880 is broken.
400 	   Here we adjust it properly. */
401 	snd_hda_jack_unsol_event(codec, res >> 2);
402 }
403 
404 /* Change EAPD to verb control */
alc_fill_eapd_coef(struct hda_codec * codec)405 static void alc_fill_eapd_coef(struct hda_codec *codec)
406 {
407 	int coef;
408 
409 	coef = alc_get_coef0(codec);
410 
411 	switch (codec->core.vendor_id) {
412 	case 0x10ec0262:
413 		alc_update_coef_idx(codec, 0x7, 0, 1<<5);
414 		break;
415 	case 0x10ec0267:
416 	case 0x10ec0268:
417 		alc_update_coef_idx(codec, 0x7, 0, 1<<13);
418 		break;
419 	case 0x10ec0269:
420 		if ((coef & 0x00f0) == 0x0010)
421 			alc_update_coef_idx(codec, 0xd, 0, 1<<14);
422 		if ((coef & 0x00f0) == 0x0020)
423 			alc_update_coef_idx(codec, 0x4, 1<<15, 0);
424 		if ((coef & 0x00f0) == 0x0030)
425 			alc_update_coef_idx(codec, 0x10, 1<<9, 0);
426 		break;
427 	case 0x10ec0280:
428 	case 0x10ec0284:
429 	case 0x10ec0290:
430 	case 0x10ec0292:
431 		alc_update_coef_idx(codec, 0x4, 1<<15, 0);
432 		break;
433 	case 0x10ec0225:
434 	case 0x10ec0295:
435 	case 0x10ec0299:
436 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
437 		fallthrough;
438 	case 0x10ec0215:
439 	case 0x10ec0230:
440 	case 0x10ec0233:
441 	case 0x10ec0235:
442 	case 0x10ec0236:
443 	case 0x10ec0245:
444 	case 0x10ec0255:
445 	case 0x10ec0256:
446 	case 0x19e58326:
447 	case 0x10ec0257:
448 	case 0x10ec0282:
449 	case 0x10ec0283:
450 	case 0x10ec0286:
451 	case 0x10ec0288:
452 	case 0x10ec0285:
453 	case 0x10ec0298:
454 	case 0x10ec0289:
455 	case 0x10ec0300:
456 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
457 		break;
458 	case 0x10ec0275:
459 		alc_update_coef_idx(codec, 0xe, 0, 1<<0);
460 		break;
461 	case 0x10ec0287:
462 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
463 		alc_write_coef_idx(codec, 0x8, 0x4ab7);
464 		break;
465 	case 0x10ec0293:
466 		alc_update_coef_idx(codec, 0xa, 1<<13, 0);
467 		break;
468 	case 0x10ec0234:
469 	case 0x10ec0274:
470 	case 0x10ec0294:
471 	case 0x10ec0700:
472 	case 0x10ec0701:
473 	case 0x10ec0703:
474 	case 0x10ec0711:
475 		alc_update_coef_idx(codec, 0x10, 1<<15, 0);
476 		break;
477 	case 0x10ec0662:
478 		if ((coef & 0x00f0) == 0x0030)
479 			alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
480 		break;
481 	case 0x10ec0272:
482 	case 0x10ec0273:
483 	case 0x10ec0663:
484 	case 0x10ec0665:
485 	case 0x10ec0670:
486 	case 0x10ec0671:
487 	case 0x10ec0672:
488 		alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
489 		break;
490 	case 0x10ec0222:
491 	case 0x10ec0623:
492 		alc_update_coef_idx(codec, 0x19, 1<<13, 0);
493 		break;
494 	case 0x10ec0668:
495 		alc_update_coef_idx(codec, 0x7, 3<<13, 0);
496 		break;
497 	case 0x10ec0867:
498 		alc_update_coef_idx(codec, 0x4, 1<<10, 0);
499 		break;
500 	case 0x10ec0888:
501 		if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
502 			alc_update_coef_idx(codec, 0x7, 1<<5, 0);
503 		break;
504 	case 0x10ec0892:
505 	case 0x10ec0897:
506 		alc_update_coef_idx(codec, 0x7, 1<<5, 0);
507 		break;
508 	case 0x10ec0899:
509 	case 0x10ec0900:
510 	case 0x10ec0b00:
511 	case 0x10ec1168:
512 	case 0x10ec1220:
513 		alc_update_coef_idx(codec, 0x7, 1<<1, 0);
514 		break;
515 	}
516 }
517 
518 /* additional initialization for ALC888 variants */
alc888_coef_init(struct hda_codec * codec)519 static void alc888_coef_init(struct hda_codec *codec)
520 {
521 	switch (alc_get_coef0(codec) & 0x00f0) {
522 	/* alc888-VA */
523 	case 0x00:
524 	/* alc888-VB */
525 	case 0x10:
526 		alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
527 		break;
528 	}
529 }
530 
531 /* turn on/off EAPD control (only if available) */
set_eapd(struct hda_codec * codec,hda_nid_t nid,int on)532 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
533 {
534 	if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
535 		return;
536 	if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
537 		snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
538 				    on ? 2 : 0);
539 }
540 
541 /* turn on/off EAPD controls of the codec */
alc_auto_setup_eapd(struct hda_codec * codec,bool on)542 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
543 {
544 	/* We currently only handle front, HP */
545 	static const hda_nid_t pins[] = {
546 		0x0f, 0x10, 0x14, 0x15, 0x17, 0
547 	};
548 	const hda_nid_t *p;
549 	for (p = pins; *p; p++)
550 		set_eapd(codec, *p, on);
551 }
552 
553 static int find_ext_mic_pin(struct hda_codec *codec);
554 
alc_headset_mic_no_shutup(struct hda_codec * codec)555 static void alc_headset_mic_no_shutup(struct hda_codec *codec)
556 {
557 	const struct hda_pincfg *pin;
558 	int mic_pin = find_ext_mic_pin(codec);
559 	int i;
560 
561 	/* don't shut up pins when unloading the driver; otherwise it breaks
562 	 * the default pin setup at the next load of the driver
563 	 */
564 	if (codec->bus->shutdown)
565 		return;
566 
567 	snd_array_for_each(&codec->init_pins, i, pin) {
568 		/* use read here for syncing after issuing each verb */
569 		if (pin->nid != mic_pin)
570 			snd_hda_codec_read(codec, pin->nid, 0,
571 					AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
572 	}
573 
574 	codec->pins_shutup = 1;
575 }
576 
alc_shutup_pins(struct hda_codec * codec)577 static void alc_shutup_pins(struct hda_codec *codec)
578 {
579 	struct alc_spec *spec = codec->spec;
580 
581 	switch (codec->core.vendor_id) {
582 	case 0x10ec0236:
583 	case 0x10ec0256:
584 	case 0x19e58326:
585 	case 0x10ec0283:
586 	case 0x10ec0286:
587 	case 0x10ec0288:
588 	case 0x10ec0298:
589 		alc_headset_mic_no_shutup(codec);
590 		break;
591 	default:
592 		if (!spec->no_shutup_pins)
593 			snd_hda_shutup_pins(codec);
594 		break;
595 	}
596 }
597 
598 /* generic shutup callback;
599  * just turning off EAPD and a little pause for avoiding pop-noise
600  */
alc_eapd_shutup(struct hda_codec * codec)601 static void alc_eapd_shutup(struct hda_codec *codec)
602 {
603 	struct alc_spec *spec = codec->spec;
604 
605 	alc_auto_setup_eapd(codec, false);
606 	if (!spec->no_depop_delay)
607 		msleep(200);
608 	alc_shutup_pins(codec);
609 }
610 
611 /* generic EAPD initialization */
alc_auto_init_amp(struct hda_codec * codec,int type)612 static void alc_auto_init_amp(struct hda_codec *codec, int type)
613 {
614 	alc_auto_setup_eapd(codec, true);
615 	alc_write_gpio(codec);
616 	switch (type) {
617 	case ALC_INIT_DEFAULT:
618 		switch (codec->core.vendor_id) {
619 		case 0x10ec0260:
620 			alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
621 			break;
622 		case 0x10ec0880:
623 		case 0x10ec0882:
624 		case 0x10ec0883:
625 		case 0x10ec0885:
626 			alc_update_coef_idx(codec, 7, 0, 0x2030);
627 			break;
628 		case 0x10ec0888:
629 			alc888_coef_init(codec);
630 			break;
631 		}
632 		break;
633 	}
634 }
635 
636 /* get a primary headphone pin if available */
alc_get_hp_pin(struct alc_spec * spec)637 static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
638 {
639 	if (spec->gen.autocfg.hp_pins[0])
640 		return spec->gen.autocfg.hp_pins[0];
641 	if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
642 		return spec->gen.autocfg.line_out_pins[0];
643 	return 0;
644 }
645 
646 /*
647  * Realtek SSID verification
648  */
649 
650 /* Could be any non-zero and even value. When used as fixup, tells
651  * the driver to ignore any present sku defines.
652  */
653 #define ALC_FIXUP_SKU_IGNORE (2)
654 
alc_fixup_sku_ignore(struct hda_codec * codec,const struct hda_fixup * fix,int action)655 static void alc_fixup_sku_ignore(struct hda_codec *codec,
656 				 const struct hda_fixup *fix, int action)
657 {
658 	struct alc_spec *spec = codec->spec;
659 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
660 		spec->cdefine.fixup = 1;
661 		spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
662 	}
663 }
664 
alc_fixup_no_depop_delay(struct hda_codec * codec,const struct hda_fixup * fix,int action)665 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
666 				    const struct hda_fixup *fix, int action)
667 {
668 	struct alc_spec *spec = codec->spec;
669 
670 	if (action == HDA_FIXUP_ACT_PROBE) {
671 		spec->no_depop_delay = 1;
672 		codec->depop_delay = 0;
673 	}
674 }
675 
alc_auto_parse_customize_define(struct hda_codec * codec)676 static int alc_auto_parse_customize_define(struct hda_codec *codec)
677 {
678 	unsigned int ass, tmp, i;
679 	unsigned nid = 0;
680 	struct alc_spec *spec = codec->spec;
681 
682 	spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
683 
684 	if (spec->cdefine.fixup) {
685 		ass = spec->cdefine.sku_cfg;
686 		if (ass == ALC_FIXUP_SKU_IGNORE)
687 			return -1;
688 		goto do_sku;
689 	}
690 
691 	if (!codec->bus->pci)
692 		return -1;
693 	ass = codec->core.subsystem_id & 0xffff;
694 	if (ass != codec->bus->pci->subsystem_device && (ass & 1))
695 		goto do_sku;
696 
697 	nid = 0x1d;
698 	if (codec->core.vendor_id == 0x10ec0260)
699 		nid = 0x17;
700 	ass = snd_hda_codec_get_pincfg(codec, nid);
701 
702 	if (!(ass & 1)) {
703 		codec_info(codec, "%s: SKU not ready 0x%08x\n",
704 			   codec->core.chip_name, ass);
705 		return -1;
706 	}
707 
708 	/* check sum */
709 	tmp = 0;
710 	for (i = 1; i < 16; i++) {
711 		if ((ass >> i) & 1)
712 			tmp++;
713 	}
714 	if (((ass >> 16) & 0xf) != tmp)
715 		return -1;
716 
717 	spec->cdefine.port_connectivity = ass >> 30;
718 	spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
719 	spec->cdefine.check_sum = (ass >> 16) & 0xf;
720 	spec->cdefine.customization = ass >> 8;
721 do_sku:
722 	spec->cdefine.sku_cfg = ass;
723 	spec->cdefine.external_amp = (ass & 0x38) >> 3;
724 	spec->cdefine.platform_type = (ass & 0x4) >> 2;
725 	spec->cdefine.swap = (ass & 0x2) >> 1;
726 	spec->cdefine.override = ass & 0x1;
727 
728 	codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
729 		   nid, spec->cdefine.sku_cfg);
730 	codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
731 		   spec->cdefine.port_connectivity);
732 	codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
733 	codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
734 	codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
735 	codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
736 	codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
737 	codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
738 	codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
739 
740 	return 0;
741 }
742 
743 /* return the position of NID in the list, or -1 if not found */
find_idx_in_nid_list(hda_nid_t nid,const hda_nid_t * list,int nums)744 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
745 {
746 	int i;
747 	for (i = 0; i < nums; i++)
748 		if (list[i] == nid)
749 			return i;
750 	return -1;
751 }
752 /* return true if the given NID is found in the list */
found_in_nid_list(hda_nid_t nid,const hda_nid_t * list,int nums)753 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
754 {
755 	return find_idx_in_nid_list(nid, list, nums) >= 0;
756 }
757 
758 /* check subsystem ID and set up device-specific initialization;
759  * return 1 if initialized, 0 if invalid SSID
760  */
761 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
762  *	31 ~ 16 :	Manufacture ID
763  *	15 ~ 8	:	SKU ID
764  *	7  ~ 0	:	Assembly ID
765  *	port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
766  */
alc_subsystem_id(struct hda_codec * codec,const hda_nid_t * ports)767 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
768 {
769 	unsigned int ass, tmp, i;
770 	unsigned nid;
771 	struct alc_spec *spec = codec->spec;
772 
773 	if (spec->cdefine.fixup) {
774 		ass = spec->cdefine.sku_cfg;
775 		if (ass == ALC_FIXUP_SKU_IGNORE)
776 			return 0;
777 		goto do_sku;
778 	}
779 
780 	ass = codec->core.subsystem_id & 0xffff;
781 	if (codec->bus->pci &&
782 	    ass != codec->bus->pci->subsystem_device && (ass & 1))
783 		goto do_sku;
784 
785 	/* invalid SSID, check the special NID pin defcfg instead */
786 	/*
787 	 * 31~30	: port connectivity
788 	 * 29~21	: reserve
789 	 * 20		: PCBEEP input
790 	 * 19~16	: Check sum (15:1)
791 	 * 15~1		: Custom
792 	 * 0		: override
793 	*/
794 	nid = 0x1d;
795 	if (codec->core.vendor_id == 0x10ec0260)
796 		nid = 0x17;
797 	ass = snd_hda_codec_get_pincfg(codec, nid);
798 	codec_dbg(codec,
799 		  "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
800 		   ass, nid);
801 	if (!(ass & 1))
802 		return 0;
803 	if ((ass >> 30) != 1)	/* no physical connection */
804 		return 0;
805 
806 	/* check sum */
807 	tmp = 0;
808 	for (i = 1; i < 16; i++) {
809 		if ((ass >> i) & 1)
810 			tmp++;
811 	}
812 	if (((ass >> 16) & 0xf) != tmp)
813 		return 0;
814 do_sku:
815 	codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
816 		   ass & 0xffff, codec->core.vendor_id);
817 	/*
818 	 * 0 : override
819 	 * 1 :	Swap Jack
820 	 * 2 : 0 --> Desktop, 1 --> Laptop
821 	 * 3~5 : External Amplifier control
822 	 * 7~6 : Reserved
823 	*/
824 	tmp = (ass & 0x38) >> 3;	/* external Amp control */
825 	if (spec->init_amp == ALC_INIT_UNDEFINED) {
826 		switch (tmp) {
827 		case 1:
828 			alc_setup_gpio(codec, 0x01);
829 			break;
830 		case 3:
831 			alc_setup_gpio(codec, 0x02);
832 			break;
833 		case 7:
834 			alc_setup_gpio(codec, 0x03);
835 			break;
836 		case 5:
837 		default:
838 			spec->init_amp = ALC_INIT_DEFAULT;
839 			break;
840 		}
841 	}
842 
843 	/* is laptop or Desktop and enable the function "Mute internal speaker
844 	 * when the external headphone out jack is plugged"
845 	 */
846 	if (!(ass & 0x8000))
847 		return 1;
848 	/*
849 	 * 10~8 : Jack location
850 	 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
851 	 * 14~13: Resvered
852 	 * 15   : 1 --> enable the function "Mute internal speaker
853 	 *	        when the external headphone out jack is plugged"
854 	 */
855 	if (!alc_get_hp_pin(spec)) {
856 		hda_nid_t nid;
857 		tmp = (ass >> 11) & 0x3;	/* HP to chassis */
858 		nid = ports[tmp];
859 		if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
860 				      spec->gen.autocfg.line_outs))
861 			return 1;
862 		spec->gen.autocfg.hp_pins[0] = nid;
863 	}
864 	return 1;
865 }
866 
867 /* Check the validity of ALC subsystem-id
868  * ports contains an array of 4 pin NIDs for port-A, E, D and I */
alc_ssid_check(struct hda_codec * codec,const hda_nid_t * ports)869 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
870 {
871 	if (!alc_subsystem_id(codec, ports)) {
872 		struct alc_spec *spec = codec->spec;
873 		if (spec->init_amp == ALC_INIT_UNDEFINED) {
874 			codec_dbg(codec,
875 				  "realtek: Enable default setup for auto mode as fallback\n");
876 			spec->init_amp = ALC_INIT_DEFAULT;
877 		}
878 	}
879 }
880 
881 /*
882  */
883 
alc_fixup_inv_dmic(struct hda_codec * codec,const struct hda_fixup * fix,int action)884 static void alc_fixup_inv_dmic(struct hda_codec *codec,
885 			       const struct hda_fixup *fix, int action)
886 {
887 	struct alc_spec *spec = codec->spec;
888 
889 	spec->gen.inv_dmic_split = 1;
890 }
891 
892 
alc_build_controls(struct hda_codec * codec)893 static int alc_build_controls(struct hda_codec *codec)
894 {
895 	int err;
896 
897 	err = snd_hda_gen_build_controls(codec);
898 	if (err < 0)
899 		return err;
900 
901 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
902 	return 0;
903 }
904 
905 
906 /*
907  * Common callbacks
908  */
909 
alc_pre_init(struct hda_codec * codec)910 static void alc_pre_init(struct hda_codec *codec)
911 {
912 	alc_fill_eapd_coef(codec);
913 }
914 
915 #define is_s3_resume(codec) \
916 	((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
917 #define is_s4_resume(codec) \
918 	((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
919 
alc_init(struct hda_codec * codec)920 static int alc_init(struct hda_codec *codec)
921 {
922 	struct alc_spec *spec = codec->spec;
923 
924 	/* hibernation resume needs the full chip initialization */
925 	if (is_s4_resume(codec))
926 		alc_pre_init(codec);
927 
928 	if (spec->init_hook)
929 		spec->init_hook(codec);
930 
931 	spec->gen.skip_verbs = 1; /* applied in below */
932 	snd_hda_gen_init(codec);
933 	alc_fix_pll(codec);
934 	alc_auto_init_amp(codec, spec->init_amp);
935 	snd_hda_apply_verbs(codec); /* apply verbs here after own init */
936 
937 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
938 
939 	return 0;
940 }
941 
942 #define alc_free	snd_hda_gen_free
943 
944 #ifdef CONFIG_PM
alc_shutup(struct hda_codec * codec)945 static inline void alc_shutup(struct hda_codec *codec)
946 {
947 	struct alc_spec *spec = codec->spec;
948 
949 	if (!snd_hda_get_bool_hint(codec, "shutup"))
950 		return; /* disabled explicitly by hints */
951 
952 	if (spec && spec->shutup)
953 		spec->shutup(codec);
954 	else
955 		alc_shutup_pins(codec);
956 }
957 
alc_power_eapd(struct hda_codec * codec)958 static void alc_power_eapd(struct hda_codec *codec)
959 {
960 	alc_auto_setup_eapd(codec, false);
961 }
962 
alc_suspend(struct hda_codec * codec)963 static int alc_suspend(struct hda_codec *codec)
964 {
965 	struct alc_spec *spec = codec->spec;
966 	alc_shutup(codec);
967 	if (spec && spec->power_hook)
968 		spec->power_hook(codec);
969 	return 0;
970 }
971 
alc_resume(struct hda_codec * codec)972 static int alc_resume(struct hda_codec *codec)
973 {
974 	struct alc_spec *spec = codec->spec;
975 
976 	if (!spec->no_depop_delay)
977 		msleep(150); /* to avoid pop noise */
978 	codec->patch_ops.init(codec);
979 	snd_hda_regmap_sync(codec);
980 	hda_call_check_power_status(codec, 0x01);
981 	return 0;
982 }
983 #endif
984 
985 /*
986  */
987 static const struct hda_codec_ops alc_patch_ops = {
988 	.build_controls = alc_build_controls,
989 	.build_pcms = snd_hda_gen_build_pcms,
990 	.init = alc_init,
991 	.free = alc_free,
992 	.unsol_event = snd_hda_jack_unsol_event,
993 #ifdef CONFIG_PM
994 	.resume = alc_resume,
995 	.suspend = alc_suspend,
996 	.check_power_status = snd_hda_gen_check_power_status,
997 #endif
998 };
999 
1000 
1001 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
1002 
1003 /*
1004  * Rename codecs appropriately from COEF value or subvendor id
1005  */
1006 struct alc_codec_rename_table {
1007 	unsigned int vendor_id;
1008 	unsigned short coef_mask;
1009 	unsigned short coef_bits;
1010 	const char *name;
1011 };
1012 
1013 struct alc_codec_rename_pci_table {
1014 	unsigned int codec_vendor_id;
1015 	unsigned short pci_subvendor;
1016 	unsigned short pci_subdevice;
1017 	const char *name;
1018 };
1019 
1020 static const struct alc_codec_rename_table rename_tbl[] = {
1021 	{ 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
1022 	{ 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
1023 	{ 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
1024 	{ 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
1025 	{ 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
1026 	{ 0x10ec0269, 0xffff, 0xa023, "ALC259" },
1027 	{ 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
1028 	{ 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
1029 	{ 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
1030 	{ 0x10ec0662, 0xffff, 0x4020, "ALC656" },
1031 	{ 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
1032 	{ 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
1033 	{ 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
1034 	{ 0x10ec0899, 0x2000, 0x2000, "ALC899" },
1035 	{ 0x10ec0892, 0xffff, 0x8020, "ALC661" },
1036 	{ 0x10ec0892, 0xffff, 0x8011, "ALC661" },
1037 	{ 0x10ec0892, 0xffff, 0x4011, "ALC656" },
1038 	{ } /* terminator */
1039 };
1040 
1041 static const struct alc_codec_rename_pci_table rename_pci_tbl[] = {
1042 	{ 0x10ec0280, 0x1028, 0, "ALC3220" },
1043 	{ 0x10ec0282, 0x1028, 0, "ALC3221" },
1044 	{ 0x10ec0283, 0x1028, 0, "ALC3223" },
1045 	{ 0x10ec0288, 0x1028, 0, "ALC3263" },
1046 	{ 0x10ec0292, 0x1028, 0, "ALC3226" },
1047 	{ 0x10ec0293, 0x1028, 0, "ALC3235" },
1048 	{ 0x10ec0255, 0x1028, 0, "ALC3234" },
1049 	{ 0x10ec0668, 0x1028, 0, "ALC3661" },
1050 	{ 0x10ec0275, 0x1028, 0, "ALC3260" },
1051 	{ 0x10ec0899, 0x1028, 0, "ALC3861" },
1052 	{ 0x10ec0298, 0x1028, 0, "ALC3266" },
1053 	{ 0x10ec0236, 0x1028, 0, "ALC3204" },
1054 	{ 0x10ec0256, 0x1028, 0, "ALC3246" },
1055 	{ 0x10ec0225, 0x1028, 0, "ALC3253" },
1056 	{ 0x10ec0295, 0x1028, 0, "ALC3254" },
1057 	{ 0x10ec0299, 0x1028, 0, "ALC3271" },
1058 	{ 0x10ec0670, 0x1025, 0, "ALC669X" },
1059 	{ 0x10ec0676, 0x1025, 0, "ALC679X" },
1060 	{ 0x10ec0282, 0x1043, 0, "ALC3229" },
1061 	{ 0x10ec0233, 0x1043, 0, "ALC3236" },
1062 	{ 0x10ec0280, 0x103c, 0, "ALC3228" },
1063 	{ 0x10ec0282, 0x103c, 0, "ALC3227" },
1064 	{ 0x10ec0286, 0x103c, 0, "ALC3242" },
1065 	{ 0x10ec0290, 0x103c, 0, "ALC3241" },
1066 	{ 0x10ec0668, 0x103c, 0, "ALC3662" },
1067 	{ 0x10ec0283, 0x17aa, 0, "ALC3239" },
1068 	{ 0x10ec0292, 0x17aa, 0, "ALC3232" },
1069 	{ } /* terminator */
1070 };
1071 
alc_codec_rename_from_preset(struct hda_codec * codec)1072 static int alc_codec_rename_from_preset(struct hda_codec *codec)
1073 {
1074 	const struct alc_codec_rename_table *p;
1075 	const struct alc_codec_rename_pci_table *q;
1076 
1077 	for (p = rename_tbl; p->vendor_id; p++) {
1078 		if (p->vendor_id != codec->core.vendor_id)
1079 			continue;
1080 		if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1081 			return alc_codec_rename(codec, p->name);
1082 	}
1083 
1084 	if (!codec->bus->pci)
1085 		return 0;
1086 	for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
1087 		if (q->codec_vendor_id != codec->core.vendor_id)
1088 			continue;
1089 		if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1090 			continue;
1091 		if (!q->pci_subdevice ||
1092 		    q->pci_subdevice == codec->bus->pci->subsystem_device)
1093 			return alc_codec_rename(codec, q->name);
1094 	}
1095 
1096 	return 0;
1097 }
1098 
1099 
1100 /*
1101  * Digital-beep handlers
1102  */
1103 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1104 
1105 /* additional beep mixers; private_value will be overwritten */
1106 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1107 	HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1108 	HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1109 };
1110 
1111 /* set up and create beep controls */
set_beep_amp(struct alc_spec * spec,hda_nid_t nid,int idx,int dir)1112 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
1113 			int idx, int dir)
1114 {
1115 	struct snd_kcontrol_new *knew;
1116 	unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
1117 	int i;
1118 
1119 	for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
1120 		knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1121 					    &alc_beep_mixer[i]);
1122 		if (!knew)
1123 			return -ENOMEM;
1124 		knew->private_value = beep_amp;
1125 	}
1126 	return 0;
1127 }
1128 
1129 static const struct snd_pci_quirk beep_allow_list[] = {
1130 	SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1131 	SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1132 	SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1133 	SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1134 	SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1135 	SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1136 	SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1137 	SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1138 	SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1139 	/* denylist -- no beep available */
1140 	SND_PCI_QUIRK(0x17aa, 0x309e, "Lenovo ThinkCentre M73", 0),
1141 	SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0),
1142 	{}
1143 };
1144 
has_cdefine_beep(struct hda_codec * codec)1145 static inline int has_cdefine_beep(struct hda_codec *codec)
1146 {
1147 	struct alc_spec *spec = codec->spec;
1148 	const struct snd_pci_quirk *q;
1149 	q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list);
1150 	if (q)
1151 		return q->value;
1152 	return spec->cdefine.enable_pcbeep;
1153 }
1154 #else
1155 #define set_beep_amp(spec, nid, idx, dir)	0
1156 #define has_cdefine_beep(codec)		0
1157 #endif
1158 
1159 /* parse the BIOS configuration and set up the alc_spec */
1160 /* return 1 if successful, 0 if the proper config is not found,
1161  * or a negative error code
1162  */
alc_parse_auto_config(struct hda_codec * codec,const hda_nid_t * ignore_nids,const hda_nid_t * ssid_nids)1163 static int alc_parse_auto_config(struct hda_codec *codec,
1164 				 const hda_nid_t *ignore_nids,
1165 				 const hda_nid_t *ssid_nids)
1166 {
1167 	struct alc_spec *spec = codec->spec;
1168 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1169 	int err;
1170 
1171 	err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1172 				       spec->parse_flags);
1173 	if (err < 0)
1174 		return err;
1175 
1176 	if (ssid_nids)
1177 		alc_ssid_check(codec, ssid_nids);
1178 
1179 	err = snd_hda_gen_parse_auto_config(codec, cfg);
1180 	if (err < 0)
1181 		return err;
1182 
1183 	return 1;
1184 }
1185 
1186 /* common preparation job for alc_spec */
alc_alloc_spec(struct hda_codec * codec,hda_nid_t mixer_nid)1187 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1188 {
1189 	struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1190 	int err;
1191 
1192 	if (!spec)
1193 		return -ENOMEM;
1194 	codec->spec = spec;
1195 	snd_hda_gen_spec_init(&spec->gen);
1196 	spec->gen.mixer_nid = mixer_nid;
1197 	spec->gen.own_eapd_ctl = 1;
1198 	codec->single_adc_amp = 1;
1199 	/* FIXME: do we need this for all Realtek codec models? */
1200 	codec->spdif_status_reset = 1;
1201 	codec->forced_resume = 1;
1202 	codec->patch_ops = alc_patch_ops;
1203 	mutex_init(&spec->coef_mutex);
1204 
1205 	err = alc_codec_rename_from_preset(codec);
1206 	if (err < 0) {
1207 		kfree(spec);
1208 		return err;
1209 	}
1210 	return 0;
1211 }
1212 
alc880_parse_auto_config(struct hda_codec * codec)1213 static int alc880_parse_auto_config(struct hda_codec *codec)
1214 {
1215 	static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1216 	static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1217 	return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1218 }
1219 
1220 /*
1221  * ALC880 fix-ups
1222  */
1223 enum {
1224 	ALC880_FIXUP_GPIO1,
1225 	ALC880_FIXUP_GPIO2,
1226 	ALC880_FIXUP_MEDION_RIM,
1227 	ALC880_FIXUP_LG,
1228 	ALC880_FIXUP_LG_LW25,
1229 	ALC880_FIXUP_W810,
1230 	ALC880_FIXUP_EAPD_COEF,
1231 	ALC880_FIXUP_TCL_S700,
1232 	ALC880_FIXUP_VOL_KNOB,
1233 	ALC880_FIXUP_FUJITSU,
1234 	ALC880_FIXUP_F1734,
1235 	ALC880_FIXUP_UNIWILL,
1236 	ALC880_FIXUP_UNIWILL_DIG,
1237 	ALC880_FIXUP_Z71V,
1238 	ALC880_FIXUP_ASUS_W5A,
1239 	ALC880_FIXUP_3ST_BASE,
1240 	ALC880_FIXUP_3ST,
1241 	ALC880_FIXUP_3ST_DIG,
1242 	ALC880_FIXUP_5ST_BASE,
1243 	ALC880_FIXUP_5ST,
1244 	ALC880_FIXUP_5ST_DIG,
1245 	ALC880_FIXUP_6ST_BASE,
1246 	ALC880_FIXUP_6ST,
1247 	ALC880_FIXUP_6ST_DIG,
1248 	ALC880_FIXUP_6ST_AUTOMUTE,
1249 };
1250 
1251 /* enable the volume-knob widget support on NID 0x21 */
alc880_fixup_vol_knob(struct hda_codec * codec,const struct hda_fixup * fix,int action)1252 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1253 				  const struct hda_fixup *fix, int action)
1254 {
1255 	if (action == HDA_FIXUP_ACT_PROBE)
1256 		snd_hda_jack_detect_enable_callback(codec, 0x21,
1257 						    alc_update_knob_master);
1258 }
1259 
1260 static const struct hda_fixup alc880_fixups[] = {
1261 	[ALC880_FIXUP_GPIO1] = {
1262 		.type = HDA_FIXUP_FUNC,
1263 		.v.func = alc_fixup_gpio1,
1264 	},
1265 	[ALC880_FIXUP_GPIO2] = {
1266 		.type = HDA_FIXUP_FUNC,
1267 		.v.func = alc_fixup_gpio2,
1268 	},
1269 	[ALC880_FIXUP_MEDION_RIM] = {
1270 		.type = HDA_FIXUP_VERBS,
1271 		.v.verbs = (const struct hda_verb[]) {
1272 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1273 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1274 			{ }
1275 		},
1276 		.chained = true,
1277 		.chain_id = ALC880_FIXUP_GPIO2,
1278 	},
1279 	[ALC880_FIXUP_LG] = {
1280 		.type = HDA_FIXUP_PINS,
1281 		.v.pins = (const struct hda_pintbl[]) {
1282 			/* disable bogus unused pins */
1283 			{ 0x16, 0x411111f0 },
1284 			{ 0x18, 0x411111f0 },
1285 			{ 0x1a, 0x411111f0 },
1286 			{ }
1287 		}
1288 	},
1289 	[ALC880_FIXUP_LG_LW25] = {
1290 		.type = HDA_FIXUP_PINS,
1291 		.v.pins = (const struct hda_pintbl[]) {
1292 			{ 0x1a, 0x0181344f }, /* line-in */
1293 			{ 0x1b, 0x0321403f }, /* headphone */
1294 			{ }
1295 		}
1296 	},
1297 	[ALC880_FIXUP_W810] = {
1298 		.type = HDA_FIXUP_PINS,
1299 		.v.pins = (const struct hda_pintbl[]) {
1300 			/* disable bogus unused pins */
1301 			{ 0x17, 0x411111f0 },
1302 			{ }
1303 		},
1304 		.chained = true,
1305 		.chain_id = ALC880_FIXUP_GPIO2,
1306 	},
1307 	[ALC880_FIXUP_EAPD_COEF] = {
1308 		.type = HDA_FIXUP_VERBS,
1309 		.v.verbs = (const struct hda_verb[]) {
1310 			/* change to EAPD mode */
1311 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1312 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1313 			{}
1314 		},
1315 	},
1316 	[ALC880_FIXUP_TCL_S700] = {
1317 		.type = HDA_FIXUP_VERBS,
1318 		.v.verbs = (const struct hda_verb[]) {
1319 			/* change to EAPD mode */
1320 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1321 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3070 },
1322 			{}
1323 		},
1324 		.chained = true,
1325 		.chain_id = ALC880_FIXUP_GPIO2,
1326 	},
1327 	[ALC880_FIXUP_VOL_KNOB] = {
1328 		.type = HDA_FIXUP_FUNC,
1329 		.v.func = alc880_fixup_vol_knob,
1330 	},
1331 	[ALC880_FIXUP_FUJITSU] = {
1332 		/* override all pins as BIOS on old Amilo is broken */
1333 		.type = HDA_FIXUP_PINS,
1334 		.v.pins = (const struct hda_pintbl[]) {
1335 			{ 0x14, 0x0121401f }, /* HP */
1336 			{ 0x15, 0x99030120 }, /* speaker */
1337 			{ 0x16, 0x99030130 }, /* bass speaker */
1338 			{ 0x17, 0x411111f0 }, /* N/A */
1339 			{ 0x18, 0x411111f0 }, /* N/A */
1340 			{ 0x19, 0x01a19950 }, /* mic-in */
1341 			{ 0x1a, 0x411111f0 }, /* N/A */
1342 			{ 0x1b, 0x411111f0 }, /* N/A */
1343 			{ 0x1c, 0x411111f0 }, /* N/A */
1344 			{ 0x1d, 0x411111f0 }, /* N/A */
1345 			{ 0x1e, 0x01454140 }, /* SPDIF out */
1346 			{ }
1347 		},
1348 		.chained = true,
1349 		.chain_id = ALC880_FIXUP_VOL_KNOB,
1350 	},
1351 	[ALC880_FIXUP_F1734] = {
1352 		/* almost compatible with FUJITSU, but no bass and SPDIF */
1353 		.type = HDA_FIXUP_PINS,
1354 		.v.pins = (const struct hda_pintbl[]) {
1355 			{ 0x14, 0x0121401f }, /* HP */
1356 			{ 0x15, 0x99030120 }, /* speaker */
1357 			{ 0x16, 0x411111f0 }, /* N/A */
1358 			{ 0x17, 0x411111f0 }, /* N/A */
1359 			{ 0x18, 0x411111f0 }, /* N/A */
1360 			{ 0x19, 0x01a19950 }, /* mic-in */
1361 			{ 0x1a, 0x411111f0 }, /* N/A */
1362 			{ 0x1b, 0x411111f0 }, /* N/A */
1363 			{ 0x1c, 0x411111f0 }, /* N/A */
1364 			{ 0x1d, 0x411111f0 }, /* N/A */
1365 			{ 0x1e, 0x411111f0 }, /* N/A */
1366 			{ }
1367 		},
1368 		.chained = true,
1369 		.chain_id = ALC880_FIXUP_VOL_KNOB,
1370 	},
1371 	[ALC880_FIXUP_UNIWILL] = {
1372 		/* need to fix HP and speaker pins to be parsed correctly */
1373 		.type = HDA_FIXUP_PINS,
1374 		.v.pins = (const struct hda_pintbl[]) {
1375 			{ 0x14, 0x0121411f }, /* HP */
1376 			{ 0x15, 0x99030120 }, /* speaker */
1377 			{ 0x16, 0x99030130 }, /* bass speaker */
1378 			{ }
1379 		},
1380 	},
1381 	[ALC880_FIXUP_UNIWILL_DIG] = {
1382 		.type = HDA_FIXUP_PINS,
1383 		.v.pins = (const struct hda_pintbl[]) {
1384 			/* disable bogus unused pins */
1385 			{ 0x17, 0x411111f0 },
1386 			{ 0x19, 0x411111f0 },
1387 			{ 0x1b, 0x411111f0 },
1388 			{ 0x1f, 0x411111f0 },
1389 			{ }
1390 		}
1391 	},
1392 	[ALC880_FIXUP_Z71V] = {
1393 		.type = HDA_FIXUP_PINS,
1394 		.v.pins = (const struct hda_pintbl[]) {
1395 			/* set up the whole pins as BIOS is utterly broken */
1396 			{ 0x14, 0x99030120 }, /* speaker */
1397 			{ 0x15, 0x0121411f }, /* HP */
1398 			{ 0x16, 0x411111f0 }, /* N/A */
1399 			{ 0x17, 0x411111f0 }, /* N/A */
1400 			{ 0x18, 0x01a19950 }, /* mic-in */
1401 			{ 0x19, 0x411111f0 }, /* N/A */
1402 			{ 0x1a, 0x01813031 }, /* line-in */
1403 			{ 0x1b, 0x411111f0 }, /* N/A */
1404 			{ 0x1c, 0x411111f0 }, /* N/A */
1405 			{ 0x1d, 0x411111f0 }, /* N/A */
1406 			{ 0x1e, 0x0144111e }, /* SPDIF */
1407 			{ }
1408 		}
1409 	},
1410 	[ALC880_FIXUP_ASUS_W5A] = {
1411 		.type = HDA_FIXUP_PINS,
1412 		.v.pins = (const struct hda_pintbl[]) {
1413 			/* set up the whole pins as BIOS is utterly broken */
1414 			{ 0x14, 0x0121411f }, /* HP */
1415 			{ 0x15, 0x411111f0 }, /* N/A */
1416 			{ 0x16, 0x411111f0 }, /* N/A */
1417 			{ 0x17, 0x411111f0 }, /* N/A */
1418 			{ 0x18, 0x90a60160 }, /* mic */
1419 			{ 0x19, 0x411111f0 }, /* N/A */
1420 			{ 0x1a, 0x411111f0 }, /* N/A */
1421 			{ 0x1b, 0x411111f0 }, /* N/A */
1422 			{ 0x1c, 0x411111f0 }, /* N/A */
1423 			{ 0x1d, 0x411111f0 }, /* N/A */
1424 			{ 0x1e, 0xb743111e }, /* SPDIF out */
1425 			{ }
1426 		},
1427 		.chained = true,
1428 		.chain_id = ALC880_FIXUP_GPIO1,
1429 	},
1430 	[ALC880_FIXUP_3ST_BASE] = {
1431 		.type = HDA_FIXUP_PINS,
1432 		.v.pins = (const struct hda_pintbl[]) {
1433 			{ 0x14, 0x01014010 }, /* line-out */
1434 			{ 0x15, 0x411111f0 }, /* N/A */
1435 			{ 0x16, 0x411111f0 }, /* N/A */
1436 			{ 0x17, 0x411111f0 }, /* N/A */
1437 			{ 0x18, 0x01a19c30 }, /* mic-in */
1438 			{ 0x19, 0x0121411f }, /* HP */
1439 			{ 0x1a, 0x01813031 }, /* line-in */
1440 			{ 0x1b, 0x02a19c40 }, /* front-mic */
1441 			{ 0x1c, 0x411111f0 }, /* N/A */
1442 			{ 0x1d, 0x411111f0 }, /* N/A */
1443 			/* 0x1e is filled in below */
1444 			{ 0x1f, 0x411111f0 }, /* N/A */
1445 			{ }
1446 		}
1447 	},
1448 	[ALC880_FIXUP_3ST] = {
1449 		.type = HDA_FIXUP_PINS,
1450 		.v.pins = (const struct hda_pintbl[]) {
1451 			{ 0x1e, 0x411111f0 }, /* N/A */
1452 			{ }
1453 		},
1454 		.chained = true,
1455 		.chain_id = ALC880_FIXUP_3ST_BASE,
1456 	},
1457 	[ALC880_FIXUP_3ST_DIG] = {
1458 		.type = HDA_FIXUP_PINS,
1459 		.v.pins = (const struct hda_pintbl[]) {
1460 			{ 0x1e, 0x0144111e }, /* SPDIF */
1461 			{ }
1462 		},
1463 		.chained = true,
1464 		.chain_id = ALC880_FIXUP_3ST_BASE,
1465 	},
1466 	[ALC880_FIXUP_5ST_BASE] = {
1467 		.type = HDA_FIXUP_PINS,
1468 		.v.pins = (const struct hda_pintbl[]) {
1469 			{ 0x14, 0x01014010 }, /* front */
1470 			{ 0x15, 0x411111f0 }, /* N/A */
1471 			{ 0x16, 0x01011411 }, /* CLFE */
1472 			{ 0x17, 0x01016412 }, /* surr */
1473 			{ 0x18, 0x01a19c30 }, /* mic-in */
1474 			{ 0x19, 0x0121411f }, /* HP */
1475 			{ 0x1a, 0x01813031 }, /* line-in */
1476 			{ 0x1b, 0x02a19c40 }, /* front-mic */
1477 			{ 0x1c, 0x411111f0 }, /* N/A */
1478 			{ 0x1d, 0x411111f0 }, /* N/A */
1479 			/* 0x1e is filled in below */
1480 			{ 0x1f, 0x411111f0 }, /* N/A */
1481 			{ }
1482 		}
1483 	},
1484 	[ALC880_FIXUP_5ST] = {
1485 		.type = HDA_FIXUP_PINS,
1486 		.v.pins = (const struct hda_pintbl[]) {
1487 			{ 0x1e, 0x411111f0 }, /* N/A */
1488 			{ }
1489 		},
1490 		.chained = true,
1491 		.chain_id = ALC880_FIXUP_5ST_BASE,
1492 	},
1493 	[ALC880_FIXUP_5ST_DIG] = {
1494 		.type = HDA_FIXUP_PINS,
1495 		.v.pins = (const struct hda_pintbl[]) {
1496 			{ 0x1e, 0x0144111e }, /* SPDIF */
1497 			{ }
1498 		},
1499 		.chained = true,
1500 		.chain_id = ALC880_FIXUP_5ST_BASE,
1501 	},
1502 	[ALC880_FIXUP_6ST_BASE] = {
1503 		.type = HDA_FIXUP_PINS,
1504 		.v.pins = (const struct hda_pintbl[]) {
1505 			{ 0x14, 0x01014010 }, /* front */
1506 			{ 0x15, 0x01016412 }, /* surr */
1507 			{ 0x16, 0x01011411 }, /* CLFE */
1508 			{ 0x17, 0x01012414 }, /* side */
1509 			{ 0x18, 0x01a19c30 }, /* mic-in */
1510 			{ 0x19, 0x02a19c40 }, /* front-mic */
1511 			{ 0x1a, 0x01813031 }, /* line-in */
1512 			{ 0x1b, 0x0121411f }, /* HP */
1513 			{ 0x1c, 0x411111f0 }, /* N/A */
1514 			{ 0x1d, 0x411111f0 }, /* N/A */
1515 			/* 0x1e is filled in below */
1516 			{ 0x1f, 0x411111f0 }, /* N/A */
1517 			{ }
1518 		}
1519 	},
1520 	[ALC880_FIXUP_6ST] = {
1521 		.type = HDA_FIXUP_PINS,
1522 		.v.pins = (const struct hda_pintbl[]) {
1523 			{ 0x1e, 0x411111f0 }, /* N/A */
1524 			{ }
1525 		},
1526 		.chained = true,
1527 		.chain_id = ALC880_FIXUP_6ST_BASE,
1528 	},
1529 	[ALC880_FIXUP_6ST_DIG] = {
1530 		.type = HDA_FIXUP_PINS,
1531 		.v.pins = (const struct hda_pintbl[]) {
1532 			{ 0x1e, 0x0144111e }, /* SPDIF */
1533 			{ }
1534 		},
1535 		.chained = true,
1536 		.chain_id = ALC880_FIXUP_6ST_BASE,
1537 	},
1538 	[ALC880_FIXUP_6ST_AUTOMUTE] = {
1539 		.type = HDA_FIXUP_PINS,
1540 		.v.pins = (const struct hda_pintbl[]) {
1541 			{ 0x1b, 0x0121401f }, /* HP with jack detect */
1542 			{ }
1543 		},
1544 		.chained_before = true,
1545 		.chain_id = ALC880_FIXUP_6ST_BASE,
1546 	},
1547 };
1548 
1549 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1550 	SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1551 	SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1552 	SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1553 	SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1554 	SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1555 	SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1556 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1557 	SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1558 	SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1559 	SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1560 	SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1561 	SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1562 	SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1563 	SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1564 	SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1565 	SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1566 	SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1567 	SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1568 	SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1569 	SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1570 	SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1571 	SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1572 	SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1573 
1574 	/* Below is the copied entries from alc880_quirks.c.
1575 	 * It's not quite sure whether BIOS sets the correct pin-config table
1576 	 * on these machines, thus they are kept to be compatible with
1577 	 * the old static quirks.  Once when it's confirmed to work without
1578 	 * these overrides, it'd be better to remove.
1579 	 */
1580 	SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1581 	SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1582 	SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1583 	SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1584 	SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1585 	SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1586 	SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1587 	SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1588 	SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1589 	SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1590 	SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1591 	SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1592 	SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1593 	SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1594 	SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1595 	SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1596 	SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1597 	SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1598 	SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1599 	SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1600 	SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1601 	SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1602 	SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1603 	SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1604 	SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1605 	SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1606 	SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1607 	SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1608 	SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1609 	SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1610 	SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1611 	SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1612 	SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1613 	/* default Intel */
1614 	SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1615 	SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1616 	SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1617 	{}
1618 };
1619 
1620 static const struct hda_model_fixup alc880_fixup_models[] = {
1621 	{.id = ALC880_FIXUP_3ST, .name = "3stack"},
1622 	{.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1623 	{.id = ALC880_FIXUP_5ST, .name = "5stack"},
1624 	{.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1625 	{.id = ALC880_FIXUP_6ST, .name = "6stack"},
1626 	{.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1627 	{.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1628 	{}
1629 };
1630 
1631 
1632 /*
1633  * OK, here we have finally the patch for ALC880
1634  */
patch_alc880(struct hda_codec * codec)1635 static int patch_alc880(struct hda_codec *codec)
1636 {
1637 	struct alc_spec *spec;
1638 	int err;
1639 
1640 	err = alc_alloc_spec(codec, 0x0b);
1641 	if (err < 0)
1642 		return err;
1643 
1644 	spec = codec->spec;
1645 	spec->gen.need_dac_fix = 1;
1646 	spec->gen.beep_nid = 0x01;
1647 
1648 	codec->patch_ops.unsol_event = alc880_unsol_event;
1649 
1650 	alc_pre_init(codec);
1651 
1652 	snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1653 		       alc880_fixups);
1654 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1655 
1656 	/* automatic parse from the BIOS config */
1657 	err = alc880_parse_auto_config(codec);
1658 	if (err < 0)
1659 		goto error;
1660 
1661 	if (!spec->gen.no_analog) {
1662 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1663 		if (err < 0)
1664 			goto error;
1665 	}
1666 
1667 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1668 
1669 	return 0;
1670 
1671  error:
1672 	alc_free(codec);
1673 	return err;
1674 }
1675 
1676 
1677 /*
1678  * ALC260 support
1679  */
alc260_parse_auto_config(struct hda_codec * codec)1680 static int alc260_parse_auto_config(struct hda_codec *codec)
1681 {
1682 	static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1683 	static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1684 	return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1685 }
1686 
1687 /*
1688  * Pin config fixes
1689  */
1690 enum {
1691 	ALC260_FIXUP_HP_DC5750,
1692 	ALC260_FIXUP_HP_PIN_0F,
1693 	ALC260_FIXUP_COEF,
1694 	ALC260_FIXUP_GPIO1,
1695 	ALC260_FIXUP_GPIO1_TOGGLE,
1696 	ALC260_FIXUP_REPLACER,
1697 	ALC260_FIXUP_HP_B1900,
1698 	ALC260_FIXUP_KN1,
1699 	ALC260_FIXUP_FSC_S7020,
1700 	ALC260_FIXUP_FSC_S7020_JWSE,
1701 	ALC260_FIXUP_VAIO_PINS,
1702 };
1703 
alc260_gpio1_automute(struct hda_codec * codec)1704 static void alc260_gpio1_automute(struct hda_codec *codec)
1705 {
1706 	struct alc_spec *spec = codec->spec;
1707 
1708 	alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1709 }
1710 
alc260_fixup_gpio1_toggle(struct hda_codec * codec,const struct hda_fixup * fix,int action)1711 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1712 				      const struct hda_fixup *fix, int action)
1713 {
1714 	struct alc_spec *spec = codec->spec;
1715 	if (action == HDA_FIXUP_ACT_PROBE) {
1716 		/* although the machine has only one output pin, we need to
1717 		 * toggle GPIO1 according to the jack state
1718 		 */
1719 		spec->gen.automute_hook = alc260_gpio1_automute;
1720 		spec->gen.detect_hp = 1;
1721 		spec->gen.automute_speaker = 1;
1722 		spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1723 		snd_hda_jack_detect_enable_callback(codec, 0x0f,
1724 						    snd_hda_gen_hp_automute);
1725 		alc_setup_gpio(codec, 0x01);
1726 	}
1727 }
1728 
alc260_fixup_kn1(struct hda_codec * codec,const struct hda_fixup * fix,int action)1729 static void alc260_fixup_kn1(struct hda_codec *codec,
1730 			     const struct hda_fixup *fix, int action)
1731 {
1732 	struct alc_spec *spec = codec->spec;
1733 	static const struct hda_pintbl pincfgs[] = {
1734 		{ 0x0f, 0x02214000 }, /* HP/speaker */
1735 		{ 0x12, 0x90a60160 }, /* int mic */
1736 		{ 0x13, 0x02a19000 }, /* ext mic */
1737 		{ 0x18, 0x01446000 }, /* SPDIF out */
1738 		/* disable bogus I/O pins */
1739 		{ 0x10, 0x411111f0 },
1740 		{ 0x11, 0x411111f0 },
1741 		{ 0x14, 0x411111f0 },
1742 		{ 0x15, 0x411111f0 },
1743 		{ 0x16, 0x411111f0 },
1744 		{ 0x17, 0x411111f0 },
1745 		{ 0x19, 0x411111f0 },
1746 		{ }
1747 	};
1748 
1749 	switch (action) {
1750 	case HDA_FIXUP_ACT_PRE_PROBE:
1751 		snd_hda_apply_pincfgs(codec, pincfgs);
1752 		spec->init_amp = ALC_INIT_NONE;
1753 		break;
1754 	}
1755 }
1756 
alc260_fixup_fsc_s7020(struct hda_codec * codec,const struct hda_fixup * fix,int action)1757 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1758 				   const struct hda_fixup *fix, int action)
1759 {
1760 	struct alc_spec *spec = codec->spec;
1761 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
1762 		spec->init_amp = ALC_INIT_NONE;
1763 }
1764 
alc260_fixup_fsc_s7020_jwse(struct hda_codec * codec,const struct hda_fixup * fix,int action)1765 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1766 				   const struct hda_fixup *fix, int action)
1767 {
1768 	struct alc_spec *spec = codec->spec;
1769 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1770 		spec->gen.add_jack_modes = 1;
1771 		spec->gen.hp_mic = 1;
1772 	}
1773 }
1774 
1775 static const struct hda_fixup alc260_fixups[] = {
1776 	[ALC260_FIXUP_HP_DC5750] = {
1777 		.type = HDA_FIXUP_PINS,
1778 		.v.pins = (const struct hda_pintbl[]) {
1779 			{ 0x11, 0x90130110 }, /* speaker */
1780 			{ }
1781 		}
1782 	},
1783 	[ALC260_FIXUP_HP_PIN_0F] = {
1784 		.type = HDA_FIXUP_PINS,
1785 		.v.pins = (const struct hda_pintbl[]) {
1786 			{ 0x0f, 0x01214000 }, /* HP */
1787 			{ }
1788 		}
1789 	},
1790 	[ALC260_FIXUP_COEF] = {
1791 		.type = HDA_FIXUP_VERBS,
1792 		.v.verbs = (const struct hda_verb[]) {
1793 			{ 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1794 			{ 0x1a, AC_VERB_SET_PROC_COEF,  0x3040 },
1795 			{ }
1796 		},
1797 	},
1798 	[ALC260_FIXUP_GPIO1] = {
1799 		.type = HDA_FIXUP_FUNC,
1800 		.v.func = alc_fixup_gpio1,
1801 	},
1802 	[ALC260_FIXUP_GPIO1_TOGGLE] = {
1803 		.type = HDA_FIXUP_FUNC,
1804 		.v.func = alc260_fixup_gpio1_toggle,
1805 		.chained = true,
1806 		.chain_id = ALC260_FIXUP_HP_PIN_0F,
1807 	},
1808 	[ALC260_FIXUP_REPLACER] = {
1809 		.type = HDA_FIXUP_VERBS,
1810 		.v.verbs = (const struct hda_verb[]) {
1811 			{ 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1812 			{ 0x1a, AC_VERB_SET_PROC_COEF,  0x3050 },
1813 			{ }
1814 		},
1815 		.chained = true,
1816 		.chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1817 	},
1818 	[ALC260_FIXUP_HP_B1900] = {
1819 		.type = HDA_FIXUP_FUNC,
1820 		.v.func = alc260_fixup_gpio1_toggle,
1821 		.chained = true,
1822 		.chain_id = ALC260_FIXUP_COEF,
1823 	},
1824 	[ALC260_FIXUP_KN1] = {
1825 		.type = HDA_FIXUP_FUNC,
1826 		.v.func = alc260_fixup_kn1,
1827 	},
1828 	[ALC260_FIXUP_FSC_S7020] = {
1829 		.type = HDA_FIXUP_FUNC,
1830 		.v.func = alc260_fixup_fsc_s7020,
1831 	},
1832 	[ALC260_FIXUP_FSC_S7020_JWSE] = {
1833 		.type = HDA_FIXUP_FUNC,
1834 		.v.func = alc260_fixup_fsc_s7020_jwse,
1835 		.chained = true,
1836 		.chain_id = ALC260_FIXUP_FSC_S7020,
1837 	},
1838 	[ALC260_FIXUP_VAIO_PINS] = {
1839 		.type = HDA_FIXUP_PINS,
1840 		.v.pins = (const struct hda_pintbl[]) {
1841 			/* Pin configs are missing completely on some VAIOs */
1842 			{ 0x0f, 0x01211020 },
1843 			{ 0x10, 0x0001003f },
1844 			{ 0x11, 0x411111f0 },
1845 			{ 0x12, 0x01a15930 },
1846 			{ 0x13, 0x411111f0 },
1847 			{ 0x14, 0x411111f0 },
1848 			{ 0x15, 0x411111f0 },
1849 			{ 0x16, 0x411111f0 },
1850 			{ 0x17, 0x411111f0 },
1851 			{ 0x18, 0x411111f0 },
1852 			{ 0x19, 0x411111f0 },
1853 			{ }
1854 		}
1855 	},
1856 };
1857 
1858 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1859 	SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1860 	SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1861 	SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1862 	SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1863 	SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1864 	SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1865 	SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1866 	SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1867 	SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1868 	SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1869 	SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1870 	SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1871 	{}
1872 };
1873 
1874 static const struct hda_model_fixup alc260_fixup_models[] = {
1875 	{.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1876 	{.id = ALC260_FIXUP_COEF, .name = "coef"},
1877 	{.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1878 	{.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1879 	{}
1880 };
1881 
1882 /*
1883  */
patch_alc260(struct hda_codec * codec)1884 static int patch_alc260(struct hda_codec *codec)
1885 {
1886 	struct alc_spec *spec;
1887 	int err;
1888 
1889 	err = alc_alloc_spec(codec, 0x07);
1890 	if (err < 0)
1891 		return err;
1892 
1893 	spec = codec->spec;
1894 	/* as quite a few machines require HP amp for speaker outputs,
1895 	 * it's easier to enable it unconditionally; even if it's unneeded,
1896 	 * it's almost harmless.
1897 	 */
1898 	spec->gen.prefer_hp_amp = 1;
1899 	spec->gen.beep_nid = 0x01;
1900 
1901 	spec->shutup = alc_eapd_shutup;
1902 
1903 	alc_pre_init(codec);
1904 
1905 	snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1906 			   alc260_fixups);
1907 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1908 
1909 	/* automatic parse from the BIOS config */
1910 	err = alc260_parse_auto_config(codec);
1911 	if (err < 0)
1912 		goto error;
1913 
1914 	if (!spec->gen.no_analog) {
1915 		err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1916 		if (err < 0)
1917 			goto error;
1918 	}
1919 
1920 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1921 
1922 	return 0;
1923 
1924  error:
1925 	alc_free(codec);
1926 	return err;
1927 }
1928 
1929 
1930 /*
1931  * ALC882/883/885/888/889 support
1932  *
1933  * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1934  * configuration.  Each pin widget can choose any input DACs and a mixer.
1935  * Each ADC is connected from a mixer of all inputs.  This makes possible
1936  * 6-channel independent captures.
1937  *
1938  * In addition, an independent DAC for the multi-playback (not used in this
1939  * driver yet).
1940  */
1941 
1942 /*
1943  * Pin config fixes
1944  */
1945 enum {
1946 	ALC882_FIXUP_ABIT_AW9D_MAX,
1947 	ALC882_FIXUP_LENOVO_Y530,
1948 	ALC882_FIXUP_PB_M5210,
1949 	ALC882_FIXUP_ACER_ASPIRE_7736,
1950 	ALC882_FIXUP_ASUS_W90V,
1951 	ALC889_FIXUP_CD,
1952 	ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1953 	ALC889_FIXUP_VAIO_TT,
1954 	ALC888_FIXUP_EEE1601,
1955 	ALC886_FIXUP_EAPD,
1956 	ALC882_FIXUP_EAPD,
1957 	ALC883_FIXUP_EAPD,
1958 	ALC883_FIXUP_ACER_EAPD,
1959 	ALC882_FIXUP_GPIO1,
1960 	ALC882_FIXUP_GPIO2,
1961 	ALC882_FIXUP_GPIO3,
1962 	ALC889_FIXUP_COEF,
1963 	ALC882_FIXUP_ASUS_W2JC,
1964 	ALC882_FIXUP_ACER_ASPIRE_4930G,
1965 	ALC882_FIXUP_ACER_ASPIRE_8930G,
1966 	ALC882_FIXUP_ASPIRE_8930G_VERBS,
1967 	ALC885_FIXUP_MACPRO_GPIO,
1968 	ALC889_FIXUP_DAC_ROUTE,
1969 	ALC889_FIXUP_MBP_VREF,
1970 	ALC889_FIXUP_IMAC91_VREF,
1971 	ALC889_FIXUP_MBA11_VREF,
1972 	ALC889_FIXUP_MBA21_VREF,
1973 	ALC889_FIXUP_MP11_VREF,
1974 	ALC889_FIXUP_MP41_VREF,
1975 	ALC882_FIXUP_INV_DMIC,
1976 	ALC882_FIXUP_NO_PRIMARY_HP,
1977 	ALC887_FIXUP_ASUS_BASS,
1978 	ALC887_FIXUP_BASS_CHMAP,
1979 	ALC1220_FIXUP_GB_DUAL_CODECS,
1980 	ALC1220_FIXUP_GB_X570,
1981 	ALC1220_FIXUP_CLEVO_P950,
1982 	ALC1220_FIXUP_CLEVO_PB51ED,
1983 	ALC1220_FIXUP_CLEVO_PB51ED_PINS,
1984 	ALC887_FIXUP_ASUS_AUDIO,
1985 	ALC887_FIXUP_ASUS_HMIC,
1986 	ALCS1200A_FIXUP_MIC_VREF,
1987 };
1988 
alc889_fixup_coef(struct hda_codec * codec,const struct hda_fixup * fix,int action)1989 static void alc889_fixup_coef(struct hda_codec *codec,
1990 			      const struct hda_fixup *fix, int action)
1991 {
1992 	if (action != HDA_FIXUP_ACT_INIT)
1993 		return;
1994 	alc_update_coef_idx(codec, 7, 0, 0x2030);
1995 }
1996 
1997 /* set up GPIO at initialization */
alc885_fixup_macpro_gpio(struct hda_codec * codec,const struct hda_fixup * fix,int action)1998 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1999 				     const struct hda_fixup *fix, int action)
2000 {
2001 	struct alc_spec *spec = codec->spec;
2002 
2003 	spec->gpio_write_delay = true;
2004 	alc_fixup_gpio3(codec, fix, action);
2005 }
2006 
2007 /* Fix the connection of some pins for ALC889:
2008  * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
2009  * work correctly (bko#42740)
2010  */
alc889_fixup_dac_route(struct hda_codec * codec,const struct hda_fixup * fix,int action)2011 static void alc889_fixup_dac_route(struct hda_codec *codec,
2012 				   const struct hda_fixup *fix, int action)
2013 {
2014 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2015 		/* fake the connections during parsing the tree */
2016 		static const hda_nid_t conn1[] = { 0x0c, 0x0d };
2017 		static const hda_nid_t conn2[] = { 0x0e, 0x0f };
2018 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2019 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
2020 		snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
2021 		snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
2022 	} else if (action == HDA_FIXUP_ACT_PROBE) {
2023 		/* restore the connections */
2024 		static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
2025 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
2026 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
2027 		snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
2028 		snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
2029 	}
2030 }
2031 
2032 /* Set VREF on HP pin */
alc889_fixup_mbp_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2033 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
2034 				  const struct hda_fixup *fix, int action)
2035 {
2036 	static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
2037 	struct alc_spec *spec = codec->spec;
2038 	int i;
2039 
2040 	if (action != HDA_FIXUP_ACT_INIT)
2041 		return;
2042 	for (i = 0; i < ARRAY_SIZE(nids); i++) {
2043 		unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
2044 		if (get_defcfg_device(val) != AC_JACK_HP_OUT)
2045 			continue;
2046 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
2047 		val |= AC_PINCTL_VREF_80;
2048 		snd_hda_set_pin_ctl(codec, nids[i], val);
2049 		spec->gen.keep_vref_in_automute = 1;
2050 		break;
2051 	}
2052 }
2053 
alc889_fixup_mac_pins(struct hda_codec * codec,const hda_nid_t * nids,int num_nids)2054 static void alc889_fixup_mac_pins(struct hda_codec *codec,
2055 				  const hda_nid_t *nids, int num_nids)
2056 {
2057 	struct alc_spec *spec = codec->spec;
2058 	int i;
2059 
2060 	for (i = 0; i < num_nids; i++) {
2061 		unsigned int val;
2062 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
2063 		val |= AC_PINCTL_VREF_50;
2064 		snd_hda_set_pin_ctl(codec, nids[i], val);
2065 	}
2066 	spec->gen.keep_vref_in_automute = 1;
2067 }
2068 
2069 /* Set VREF on speaker pins on imac91 */
alc889_fixup_imac91_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2070 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2071 				     const struct hda_fixup *fix, int action)
2072 {
2073 	static const hda_nid_t nids[] = { 0x18, 0x1a };
2074 
2075 	if (action == HDA_FIXUP_ACT_INIT)
2076 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2077 }
2078 
2079 /* Set VREF on speaker pins on mba11 */
alc889_fixup_mba11_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2080 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2081 				    const struct hda_fixup *fix, int action)
2082 {
2083 	static const hda_nid_t nids[] = { 0x18 };
2084 
2085 	if (action == HDA_FIXUP_ACT_INIT)
2086 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2087 }
2088 
2089 /* Set VREF on speaker pins on mba21 */
alc889_fixup_mba21_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2090 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2091 				    const struct hda_fixup *fix, int action)
2092 {
2093 	static const hda_nid_t nids[] = { 0x18, 0x19 };
2094 
2095 	if (action == HDA_FIXUP_ACT_INIT)
2096 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2097 }
2098 
2099 /* Don't take HP output as primary
2100  * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
2101  * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2102  */
alc882_fixup_no_primary_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)2103 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2104 				       const struct hda_fixup *fix, int action)
2105 {
2106 	struct alc_spec *spec = codec->spec;
2107 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2108 		spec->gen.no_primary_hp = 1;
2109 		spec->gen.no_multi_io = 1;
2110 	}
2111 }
2112 
2113 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2114 				 const struct hda_fixup *fix, int action);
2115 
2116 /* For dual-codec configuration, we need to disable some features to avoid
2117  * conflicts of kctls and PCM streams
2118  */
alc_fixup_dual_codecs(struct hda_codec * codec,const struct hda_fixup * fix,int action)2119 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2120 				  const struct hda_fixup *fix, int action)
2121 {
2122 	struct alc_spec *spec = codec->spec;
2123 
2124 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
2125 		return;
2126 	/* disable vmaster */
2127 	spec->gen.suppress_vmaster = 1;
2128 	/* auto-mute and auto-mic switch don't work with multiple codecs */
2129 	spec->gen.suppress_auto_mute = 1;
2130 	spec->gen.suppress_auto_mic = 1;
2131 	/* disable aamix as well */
2132 	spec->gen.mixer_nid = 0;
2133 	/* add location prefix to avoid conflicts */
2134 	codec->force_pin_prefix = 1;
2135 }
2136 
rename_ctl(struct hda_codec * codec,const char * oldname,const char * newname)2137 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2138 		       const char *newname)
2139 {
2140 	struct snd_kcontrol *kctl;
2141 
2142 	kctl = snd_hda_find_mixer_ctl(codec, oldname);
2143 	if (kctl)
2144 		strcpy(kctl->id.name, newname);
2145 }
2146 
alc1220_fixup_gb_dual_codecs(struct hda_codec * codec,const struct hda_fixup * fix,int action)2147 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2148 					 const struct hda_fixup *fix,
2149 					 int action)
2150 {
2151 	alc_fixup_dual_codecs(codec, fix, action);
2152 	switch (action) {
2153 	case HDA_FIXUP_ACT_PRE_PROBE:
2154 		/* override card longname to provide a unique UCM profile */
2155 		strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2156 		break;
2157 	case HDA_FIXUP_ACT_BUILD:
2158 		/* rename Capture controls depending on the codec */
2159 		rename_ctl(codec, "Capture Volume",
2160 			   codec->addr == 0 ?
2161 			   "Rear-Panel Capture Volume" :
2162 			   "Front-Panel Capture Volume");
2163 		rename_ctl(codec, "Capture Switch",
2164 			   codec->addr == 0 ?
2165 			   "Rear-Panel Capture Switch" :
2166 			   "Front-Panel Capture Switch");
2167 		break;
2168 	}
2169 }
2170 
alc1220_fixup_gb_x570(struct hda_codec * codec,const struct hda_fixup * fix,int action)2171 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
2172 				     const struct hda_fixup *fix,
2173 				     int action)
2174 {
2175 	static const hda_nid_t conn1[] = { 0x0c };
2176 	static const struct coef_fw gb_x570_coefs[] = {
2177 		WRITE_COEF(0x07, 0x03c0),
2178 		WRITE_COEF(0x1a, 0x01c1),
2179 		WRITE_COEF(0x1b, 0x0202),
2180 		WRITE_COEF(0x43, 0x3005),
2181 		{}
2182 	};
2183 
2184 	switch (action) {
2185 	case HDA_FIXUP_ACT_PRE_PROBE:
2186 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2187 		snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2188 		break;
2189 	case HDA_FIXUP_ACT_INIT:
2190 		alc_process_coef_fw(codec, gb_x570_coefs);
2191 		break;
2192 	}
2193 }
2194 
alc1220_fixup_clevo_p950(struct hda_codec * codec,const struct hda_fixup * fix,int action)2195 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2196 				     const struct hda_fixup *fix,
2197 				     int action)
2198 {
2199 	static const hda_nid_t conn1[] = { 0x0c };
2200 
2201 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
2202 		return;
2203 
2204 	alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2205 	/* We therefore want to make sure 0x14 (front headphone) and
2206 	 * 0x1b (speakers) use the stereo DAC 0x02
2207 	 */
2208 	snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2209 	snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2210 }
2211 
2212 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2213 				const struct hda_fixup *fix, int action);
2214 
alc1220_fixup_clevo_pb51ed(struct hda_codec * codec,const struct hda_fixup * fix,int action)2215 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2216 				     const struct hda_fixup *fix,
2217 				     int action)
2218 {
2219 	alc1220_fixup_clevo_p950(codec, fix, action);
2220 	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2221 }
2222 
alc887_asus_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)2223 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2224 					 struct hda_jack_callback *jack)
2225 {
2226 	struct alc_spec *spec = codec->spec;
2227 	unsigned int vref;
2228 
2229 	snd_hda_gen_hp_automute(codec, jack);
2230 
2231 	if (spec->gen.hp_jack_present)
2232 		vref = AC_PINCTL_VREF_80;
2233 	else
2234 		vref = AC_PINCTL_VREF_HIZ;
2235 	snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2236 }
2237 
alc887_fixup_asus_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)2238 static void alc887_fixup_asus_jack(struct hda_codec *codec,
2239 				     const struct hda_fixup *fix, int action)
2240 {
2241 	struct alc_spec *spec = codec->spec;
2242 	if (action != HDA_FIXUP_ACT_PROBE)
2243 		return;
2244 	snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2245 	spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
2246 }
2247 
2248 static const struct hda_fixup alc882_fixups[] = {
2249 	[ALC882_FIXUP_ABIT_AW9D_MAX] = {
2250 		.type = HDA_FIXUP_PINS,
2251 		.v.pins = (const struct hda_pintbl[]) {
2252 			{ 0x15, 0x01080104 }, /* side */
2253 			{ 0x16, 0x01011012 }, /* rear */
2254 			{ 0x17, 0x01016011 }, /* clfe */
2255 			{ }
2256 		}
2257 	},
2258 	[ALC882_FIXUP_LENOVO_Y530] = {
2259 		.type = HDA_FIXUP_PINS,
2260 		.v.pins = (const struct hda_pintbl[]) {
2261 			{ 0x15, 0x99130112 }, /* rear int speakers */
2262 			{ 0x16, 0x99130111 }, /* subwoofer */
2263 			{ }
2264 		}
2265 	},
2266 	[ALC882_FIXUP_PB_M5210] = {
2267 		.type = HDA_FIXUP_PINCTLS,
2268 		.v.pins = (const struct hda_pintbl[]) {
2269 			{ 0x19, PIN_VREF50 },
2270 			{}
2271 		}
2272 	},
2273 	[ALC882_FIXUP_ACER_ASPIRE_7736] = {
2274 		.type = HDA_FIXUP_FUNC,
2275 		.v.func = alc_fixup_sku_ignore,
2276 	},
2277 	[ALC882_FIXUP_ASUS_W90V] = {
2278 		.type = HDA_FIXUP_PINS,
2279 		.v.pins = (const struct hda_pintbl[]) {
2280 			{ 0x16, 0x99130110 }, /* fix sequence for CLFE */
2281 			{ }
2282 		}
2283 	},
2284 	[ALC889_FIXUP_CD] = {
2285 		.type = HDA_FIXUP_PINS,
2286 		.v.pins = (const struct hda_pintbl[]) {
2287 			{ 0x1c, 0x993301f0 }, /* CD */
2288 			{ }
2289 		}
2290 	},
2291 	[ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2292 		.type = HDA_FIXUP_PINS,
2293 		.v.pins = (const struct hda_pintbl[]) {
2294 			{ 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2295 			{ }
2296 		},
2297 		.chained = true,
2298 		.chain_id = ALC889_FIXUP_CD,
2299 	},
2300 	[ALC889_FIXUP_VAIO_TT] = {
2301 		.type = HDA_FIXUP_PINS,
2302 		.v.pins = (const struct hda_pintbl[]) {
2303 			{ 0x17, 0x90170111 }, /* hidden surround speaker */
2304 			{ }
2305 		}
2306 	},
2307 	[ALC888_FIXUP_EEE1601] = {
2308 		.type = HDA_FIXUP_VERBS,
2309 		.v.verbs = (const struct hda_verb[]) {
2310 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2311 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
2312 			{ }
2313 		}
2314 	},
2315 	[ALC886_FIXUP_EAPD] = {
2316 		.type = HDA_FIXUP_VERBS,
2317 		.v.verbs = (const struct hda_verb[]) {
2318 			/* change to EAPD mode */
2319 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2320 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0068 },
2321 			{ }
2322 		}
2323 	},
2324 	[ALC882_FIXUP_EAPD] = {
2325 		.type = HDA_FIXUP_VERBS,
2326 		.v.verbs = (const struct hda_verb[]) {
2327 			/* change to EAPD mode */
2328 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2329 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2330 			{ }
2331 		}
2332 	},
2333 	[ALC883_FIXUP_EAPD] = {
2334 		.type = HDA_FIXUP_VERBS,
2335 		.v.verbs = (const struct hda_verb[]) {
2336 			/* change to EAPD mode */
2337 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2338 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2339 			{ }
2340 		}
2341 	},
2342 	[ALC883_FIXUP_ACER_EAPD] = {
2343 		.type = HDA_FIXUP_VERBS,
2344 		.v.verbs = (const struct hda_verb[]) {
2345 			/* eanable EAPD on Acer laptops */
2346 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2347 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2348 			{ }
2349 		}
2350 	},
2351 	[ALC882_FIXUP_GPIO1] = {
2352 		.type = HDA_FIXUP_FUNC,
2353 		.v.func = alc_fixup_gpio1,
2354 	},
2355 	[ALC882_FIXUP_GPIO2] = {
2356 		.type = HDA_FIXUP_FUNC,
2357 		.v.func = alc_fixup_gpio2,
2358 	},
2359 	[ALC882_FIXUP_GPIO3] = {
2360 		.type = HDA_FIXUP_FUNC,
2361 		.v.func = alc_fixup_gpio3,
2362 	},
2363 	[ALC882_FIXUP_ASUS_W2JC] = {
2364 		.type = HDA_FIXUP_FUNC,
2365 		.v.func = alc_fixup_gpio1,
2366 		.chained = true,
2367 		.chain_id = ALC882_FIXUP_EAPD,
2368 	},
2369 	[ALC889_FIXUP_COEF] = {
2370 		.type = HDA_FIXUP_FUNC,
2371 		.v.func = alc889_fixup_coef,
2372 	},
2373 	[ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2374 		.type = HDA_FIXUP_PINS,
2375 		.v.pins = (const struct hda_pintbl[]) {
2376 			{ 0x16, 0x99130111 }, /* CLFE speaker */
2377 			{ 0x17, 0x99130112 }, /* surround speaker */
2378 			{ }
2379 		},
2380 		.chained = true,
2381 		.chain_id = ALC882_FIXUP_GPIO1,
2382 	},
2383 	[ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2384 		.type = HDA_FIXUP_PINS,
2385 		.v.pins = (const struct hda_pintbl[]) {
2386 			{ 0x16, 0x99130111 }, /* CLFE speaker */
2387 			{ 0x1b, 0x99130112 }, /* surround speaker */
2388 			{ }
2389 		},
2390 		.chained = true,
2391 		.chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2392 	},
2393 	[ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2394 		/* additional init verbs for Acer Aspire 8930G */
2395 		.type = HDA_FIXUP_VERBS,
2396 		.v.verbs = (const struct hda_verb[]) {
2397 			/* Enable all DACs */
2398 			/* DAC DISABLE/MUTE 1? */
2399 			/*  setting bits 1-5 disables DAC nids 0x02-0x06
2400 			 *  apparently. Init=0x38 */
2401 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2402 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2403 			/* DAC DISABLE/MUTE 2? */
2404 			/*  some bit here disables the other DACs.
2405 			 *  Init=0x4900 */
2406 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2407 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2408 			/* DMIC fix
2409 			 * This laptop has a stereo digital microphone.
2410 			 * The mics are only 1cm apart which makes the stereo
2411 			 * useless. However, either the mic or the ALC889
2412 			 * makes the signal become a difference/sum signal
2413 			 * instead of standard stereo, which is annoying.
2414 			 * So instead we flip this bit which makes the
2415 			 * codec replicate the sum signal to both channels,
2416 			 * turning it into a normal mono mic.
2417 			 */
2418 			/* DMIC_CONTROL? Init value = 0x0001 */
2419 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2420 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2421 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2422 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2423 			{ }
2424 		},
2425 		.chained = true,
2426 		.chain_id = ALC882_FIXUP_GPIO1,
2427 	},
2428 	[ALC885_FIXUP_MACPRO_GPIO] = {
2429 		.type = HDA_FIXUP_FUNC,
2430 		.v.func = alc885_fixup_macpro_gpio,
2431 	},
2432 	[ALC889_FIXUP_DAC_ROUTE] = {
2433 		.type = HDA_FIXUP_FUNC,
2434 		.v.func = alc889_fixup_dac_route,
2435 	},
2436 	[ALC889_FIXUP_MBP_VREF] = {
2437 		.type = HDA_FIXUP_FUNC,
2438 		.v.func = alc889_fixup_mbp_vref,
2439 		.chained = true,
2440 		.chain_id = ALC882_FIXUP_GPIO1,
2441 	},
2442 	[ALC889_FIXUP_IMAC91_VREF] = {
2443 		.type = HDA_FIXUP_FUNC,
2444 		.v.func = alc889_fixup_imac91_vref,
2445 		.chained = true,
2446 		.chain_id = ALC882_FIXUP_GPIO1,
2447 	},
2448 	[ALC889_FIXUP_MBA11_VREF] = {
2449 		.type = HDA_FIXUP_FUNC,
2450 		.v.func = alc889_fixup_mba11_vref,
2451 		.chained = true,
2452 		.chain_id = ALC889_FIXUP_MBP_VREF,
2453 	},
2454 	[ALC889_FIXUP_MBA21_VREF] = {
2455 		.type = HDA_FIXUP_FUNC,
2456 		.v.func = alc889_fixup_mba21_vref,
2457 		.chained = true,
2458 		.chain_id = ALC889_FIXUP_MBP_VREF,
2459 	},
2460 	[ALC889_FIXUP_MP11_VREF] = {
2461 		.type = HDA_FIXUP_FUNC,
2462 		.v.func = alc889_fixup_mba11_vref,
2463 		.chained = true,
2464 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
2465 	},
2466 	[ALC889_FIXUP_MP41_VREF] = {
2467 		.type = HDA_FIXUP_FUNC,
2468 		.v.func = alc889_fixup_mbp_vref,
2469 		.chained = true,
2470 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
2471 	},
2472 	[ALC882_FIXUP_INV_DMIC] = {
2473 		.type = HDA_FIXUP_FUNC,
2474 		.v.func = alc_fixup_inv_dmic,
2475 	},
2476 	[ALC882_FIXUP_NO_PRIMARY_HP] = {
2477 		.type = HDA_FIXUP_FUNC,
2478 		.v.func = alc882_fixup_no_primary_hp,
2479 	},
2480 	[ALC887_FIXUP_ASUS_BASS] = {
2481 		.type = HDA_FIXUP_PINS,
2482 		.v.pins = (const struct hda_pintbl[]) {
2483 			{0x16, 0x99130130}, /* bass speaker */
2484 			{}
2485 		},
2486 		.chained = true,
2487 		.chain_id = ALC887_FIXUP_BASS_CHMAP,
2488 	},
2489 	[ALC887_FIXUP_BASS_CHMAP] = {
2490 		.type = HDA_FIXUP_FUNC,
2491 		.v.func = alc_fixup_bass_chmap,
2492 	},
2493 	[ALC1220_FIXUP_GB_DUAL_CODECS] = {
2494 		.type = HDA_FIXUP_FUNC,
2495 		.v.func = alc1220_fixup_gb_dual_codecs,
2496 	},
2497 	[ALC1220_FIXUP_GB_X570] = {
2498 		.type = HDA_FIXUP_FUNC,
2499 		.v.func = alc1220_fixup_gb_x570,
2500 	},
2501 	[ALC1220_FIXUP_CLEVO_P950] = {
2502 		.type = HDA_FIXUP_FUNC,
2503 		.v.func = alc1220_fixup_clevo_p950,
2504 	},
2505 	[ALC1220_FIXUP_CLEVO_PB51ED] = {
2506 		.type = HDA_FIXUP_FUNC,
2507 		.v.func = alc1220_fixup_clevo_pb51ed,
2508 	},
2509 	[ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
2510 		.type = HDA_FIXUP_PINS,
2511 		.v.pins = (const struct hda_pintbl[]) {
2512 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2513 			{}
2514 		},
2515 		.chained = true,
2516 		.chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
2517 	},
2518 	[ALC887_FIXUP_ASUS_AUDIO] = {
2519 		.type = HDA_FIXUP_PINS,
2520 		.v.pins = (const struct hda_pintbl[]) {
2521 			{ 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
2522 			{ 0x19, 0x22219420 },
2523 			{}
2524 		},
2525 	},
2526 	[ALC887_FIXUP_ASUS_HMIC] = {
2527 		.type = HDA_FIXUP_FUNC,
2528 		.v.func = alc887_fixup_asus_jack,
2529 		.chained = true,
2530 		.chain_id = ALC887_FIXUP_ASUS_AUDIO,
2531 	},
2532 	[ALCS1200A_FIXUP_MIC_VREF] = {
2533 		.type = HDA_FIXUP_PINCTLS,
2534 		.v.pins = (const struct hda_pintbl[]) {
2535 			{ 0x18, PIN_VREF50 }, /* rear mic */
2536 			{ 0x19, PIN_VREF50 }, /* front mic */
2537 			{}
2538 		}
2539 	},
2540 };
2541 
2542 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2543 	SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2544 	SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2545 	SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2546 	SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2547 	SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2548 	SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2549 	SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2550 	SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2551 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2552 	SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2553 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2554 	SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2555 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
2556 	SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2557 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
2558 	SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2559 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2560 	SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2561 	SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2562 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2563 	SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2564 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2565 	SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2566 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2567 	SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2568 	SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2569 	SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2570 	SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2571 	SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2572 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2573 	SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
2574 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2575 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2576 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2577 	SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF),
2578 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2579 	SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2580 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2581 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2582 	SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2583 
2584 	/* All Apple entries are in codec SSIDs */
2585 	SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2586 	SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2587 	SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2588 	SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2589 	SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2590 	SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2591 	SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2592 	SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2593 	SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2594 	SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2595 	SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2596 	SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2597 	SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2598 	SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2599 	SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2600 	SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2601 	SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2602 	SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2603 	SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2604 	SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2605 	SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2606 	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2607 
2608 	SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2609 	SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
2610 	SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2611 	SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2612 	SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570),
2613 	SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570),
2614 	SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570),
2615 	SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
2616 	SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
2617 	SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
2618 	SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
2619 	SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
2620 	SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
2621 	SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2622 	SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS),
2623 	SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2624 	SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2625 	SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2626 	SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2627 	SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2628 	SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2629 	SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2630 	SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2631 	SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2632 	SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2633 	SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2634 	SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2635 	SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2636 	SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2637 	SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2638 	SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2639 	SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2640 	SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
2641 	SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2642 	SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
2643 	SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
2644 	SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2645 	SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2646 	SND_PCI_QUIRK(0x1558, 0x95e3, "Clevo P955[ER]T", ALC1220_FIXUP_CLEVO_P950),
2647 	SND_PCI_QUIRK(0x1558, 0x95e4, "Clevo P955ER", ALC1220_FIXUP_CLEVO_P950),
2648 	SND_PCI_QUIRK(0x1558, 0x95e5, "Clevo P955EE6", ALC1220_FIXUP_CLEVO_P950),
2649 	SND_PCI_QUIRK(0x1558, 0x95e6, "Clevo P950R[CDF]", ALC1220_FIXUP_CLEVO_P950),
2650 	SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2651 	SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2652 	SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
2653 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2654 	SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2655 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2656 	SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2657 	{}
2658 };
2659 
2660 static const struct hda_model_fixup alc882_fixup_models[] = {
2661 	{.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2662 	{.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2663 	{.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2664 	{.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2665 	{.id = ALC889_FIXUP_CD, .name = "cd"},
2666 	{.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2667 	{.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2668 	{.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2669 	{.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2670 	{.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2671 	{.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2672 	{.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2673 	{.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2674 	{.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2675 	{.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2676 	{.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2677 	{.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2678 	{.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2679 	{.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2680 	{.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2681 	{.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2682 	{.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2683 	{.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2684 	{.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2685 	{.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2686 	{.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2687 	{.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2688 	{.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2689 	{.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2690 	{.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2691 	{.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
2692 	{.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2693 	{}
2694 };
2695 
2696 static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = {
2697 	SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950,
2698 		{0x14, 0x01014010},
2699 		{0x15, 0x01011012},
2700 		{0x16, 0x01016011},
2701 		{0x18, 0x01a19040},
2702 		{0x19, 0x02a19050},
2703 		{0x1a, 0x0181304f},
2704 		{0x1b, 0x0221401f},
2705 		{0x1e, 0x01456130}),
2706 	SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
2707 		{0x14, 0x01015010},
2708 		{0x15, 0x01011012},
2709 		{0x16, 0x01011011},
2710 		{0x18, 0x01a11040},
2711 		{0x19, 0x02a19050},
2712 		{0x1a, 0x0181104f},
2713 		{0x1b, 0x0221401f},
2714 		{0x1e, 0x01451130}),
2715 	{}
2716 };
2717 
2718 /*
2719  * BIOS auto configuration
2720  */
2721 /* almost identical with ALC880 parser... */
alc882_parse_auto_config(struct hda_codec * codec)2722 static int alc882_parse_auto_config(struct hda_codec *codec)
2723 {
2724 	static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2725 	static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2726 	return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2727 }
2728 
2729 /*
2730  */
patch_alc882(struct hda_codec * codec)2731 static int patch_alc882(struct hda_codec *codec)
2732 {
2733 	struct alc_spec *spec;
2734 	int err;
2735 
2736 	err = alc_alloc_spec(codec, 0x0b);
2737 	if (err < 0)
2738 		return err;
2739 
2740 	spec = codec->spec;
2741 
2742 	switch (codec->core.vendor_id) {
2743 	case 0x10ec0882:
2744 	case 0x10ec0885:
2745 	case 0x10ec0900:
2746 	case 0x10ec0b00:
2747 	case 0x10ec1220:
2748 		break;
2749 	default:
2750 		/* ALC883 and variants */
2751 		alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2752 		break;
2753 	}
2754 
2755 	alc_pre_init(codec);
2756 
2757 	snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2758 		       alc882_fixups);
2759 	snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
2760 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2761 
2762 	alc_auto_parse_customize_define(codec);
2763 
2764 	if (has_cdefine_beep(codec))
2765 		spec->gen.beep_nid = 0x01;
2766 
2767 	/* automatic parse from the BIOS config */
2768 	err = alc882_parse_auto_config(codec);
2769 	if (err < 0)
2770 		goto error;
2771 
2772 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
2773 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2774 		if (err < 0)
2775 			goto error;
2776 	}
2777 
2778 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2779 
2780 	return 0;
2781 
2782  error:
2783 	alc_free(codec);
2784 	return err;
2785 }
2786 
2787 
2788 /*
2789  * ALC262 support
2790  */
alc262_parse_auto_config(struct hda_codec * codec)2791 static int alc262_parse_auto_config(struct hda_codec *codec)
2792 {
2793 	static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2794 	static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2795 	return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2796 }
2797 
2798 /*
2799  * Pin config fixes
2800  */
2801 enum {
2802 	ALC262_FIXUP_FSC_H270,
2803 	ALC262_FIXUP_FSC_S7110,
2804 	ALC262_FIXUP_HP_Z200,
2805 	ALC262_FIXUP_TYAN,
2806 	ALC262_FIXUP_LENOVO_3000,
2807 	ALC262_FIXUP_BENQ,
2808 	ALC262_FIXUP_BENQ_T31,
2809 	ALC262_FIXUP_INV_DMIC,
2810 	ALC262_FIXUP_INTEL_BAYLEYBAY,
2811 };
2812 
2813 static const struct hda_fixup alc262_fixups[] = {
2814 	[ALC262_FIXUP_FSC_H270] = {
2815 		.type = HDA_FIXUP_PINS,
2816 		.v.pins = (const struct hda_pintbl[]) {
2817 			{ 0x14, 0x99130110 }, /* speaker */
2818 			{ 0x15, 0x0221142f }, /* front HP */
2819 			{ 0x1b, 0x0121141f }, /* rear HP */
2820 			{ }
2821 		}
2822 	},
2823 	[ALC262_FIXUP_FSC_S7110] = {
2824 		.type = HDA_FIXUP_PINS,
2825 		.v.pins = (const struct hda_pintbl[]) {
2826 			{ 0x15, 0x90170110 }, /* speaker */
2827 			{ }
2828 		},
2829 		.chained = true,
2830 		.chain_id = ALC262_FIXUP_BENQ,
2831 	},
2832 	[ALC262_FIXUP_HP_Z200] = {
2833 		.type = HDA_FIXUP_PINS,
2834 		.v.pins = (const struct hda_pintbl[]) {
2835 			{ 0x16, 0x99130120 }, /* internal speaker */
2836 			{ }
2837 		}
2838 	},
2839 	[ALC262_FIXUP_TYAN] = {
2840 		.type = HDA_FIXUP_PINS,
2841 		.v.pins = (const struct hda_pintbl[]) {
2842 			{ 0x14, 0x1993e1f0 }, /* int AUX */
2843 			{ }
2844 		}
2845 	},
2846 	[ALC262_FIXUP_LENOVO_3000] = {
2847 		.type = HDA_FIXUP_PINCTLS,
2848 		.v.pins = (const struct hda_pintbl[]) {
2849 			{ 0x19, PIN_VREF50 },
2850 			{}
2851 		},
2852 		.chained = true,
2853 		.chain_id = ALC262_FIXUP_BENQ,
2854 	},
2855 	[ALC262_FIXUP_BENQ] = {
2856 		.type = HDA_FIXUP_VERBS,
2857 		.v.verbs = (const struct hda_verb[]) {
2858 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2859 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2860 			{}
2861 		}
2862 	},
2863 	[ALC262_FIXUP_BENQ_T31] = {
2864 		.type = HDA_FIXUP_VERBS,
2865 		.v.verbs = (const struct hda_verb[]) {
2866 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2867 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2868 			{}
2869 		}
2870 	},
2871 	[ALC262_FIXUP_INV_DMIC] = {
2872 		.type = HDA_FIXUP_FUNC,
2873 		.v.func = alc_fixup_inv_dmic,
2874 	},
2875 	[ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2876 		.type = HDA_FIXUP_FUNC,
2877 		.v.func = alc_fixup_no_depop_delay,
2878 	},
2879 };
2880 
2881 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2882 	SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2883 	SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2884 	SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2885 	SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2886 	SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2887 	SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2888 	SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2889 	SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2890 	SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2891 	SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2892 	{}
2893 };
2894 
2895 static const struct hda_model_fixup alc262_fixup_models[] = {
2896 	{.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2897 	{.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2898 	{.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2899 	{.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2900 	{.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2901 	{.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2902 	{.id = ALC262_FIXUP_BENQ, .name = "benq"},
2903 	{.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2904 	{.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2905 	{}
2906 };
2907 
2908 /*
2909  */
patch_alc262(struct hda_codec * codec)2910 static int patch_alc262(struct hda_codec *codec)
2911 {
2912 	struct alc_spec *spec;
2913 	int err;
2914 
2915 	err = alc_alloc_spec(codec, 0x0b);
2916 	if (err < 0)
2917 		return err;
2918 
2919 	spec = codec->spec;
2920 	spec->gen.shared_mic_vref_pin = 0x18;
2921 
2922 	spec->shutup = alc_eapd_shutup;
2923 
2924 #if 0
2925 	/* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is
2926 	 * under-run
2927 	 */
2928 	alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2929 #endif
2930 	alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2931 
2932 	alc_pre_init(codec);
2933 
2934 	snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2935 		       alc262_fixups);
2936 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2937 
2938 	alc_auto_parse_customize_define(codec);
2939 
2940 	if (has_cdefine_beep(codec))
2941 		spec->gen.beep_nid = 0x01;
2942 
2943 	/* automatic parse from the BIOS config */
2944 	err = alc262_parse_auto_config(codec);
2945 	if (err < 0)
2946 		goto error;
2947 
2948 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
2949 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2950 		if (err < 0)
2951 			goto error;
2952 	}
2953 
2954 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2955 
2956 	return 0;
2957 
2958  error:
2959 	alc_free(codec);
2960 	return err;
2961 }
2962 
2963 /*
2964  *  ALC268
2965  */
2966 /* bind Beep switches of both NID 0x0f and 0x10 */
alc268_beep_switch_put(struct snd_kcontrol * kcontrol,struct snd_ctl_elem_value * ucontrol)2967 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2968 				  struct snd_ctl_elem_value *ucontrol)
2969 {
2970 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2971 	unsigned long pval;
2972 	int err;
2973 
2974 	mutex_lock(&codec->control_mutex);
2975 	pval = kcontrol->private_value;
2976 	kcontrol->private_value = (pval & ~0xff) | 0x0f;
2977 	err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2978 	if (err >= 0) {
2979 		kcontrol->private_value = (pval & ~0xff) | 0x10;
2980 		err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2981 	}
2982 	kcontrol->private_value = pval;
2983 	mutex_unlock(&codec->control_mutex);
2984 	return err;
2985 }
2986 
2987 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2988 	HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2989 	{
2990 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2991 		.name = "Beep Playback Switch",
2992 		.subdevice = HDA_SUBDEV_AMP_FLAG,
2993 		.info = snd_hda_mixer_amp_switch_info,
2994 		.get = snd_hda_mixer_amp_switch_get,
2995 		.put = alc268_beep_switch_put,
2996 		.private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2997 	},
2998 };
2999 
3000 /* set PCBEEP vol = 0, mute connections */
3001 static const struct hda_verb alc268_beep_init_verbs[] = {
3002 	{0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3003 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3004 	{0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3005 	{ }
3006 };
3007 
3008 enum {
3009 	ALC268_FIXUP_INV_DMIC,
3010 	ALC268_FIXUP_HP_EAPD,
3011 	ALC268_FIXUP_SPDIF,
3012 };
3013 
3014 static const struct hda_fixup alc268_fixups[] = {
3015 	[ALC268_FIXUP_INV_DMIC] = {
3016 		.type = HDA_FIXUP_FUNC,
3017 		.v.func = alc_fixup_inv_dmic,
3018 	},
3019 	[ALC268_FIXUP_HP_EAPD] = {
3020 		.type = HDA_FIXUP_VERBS,
3021 		.v.verbs = (const struct hda_verb[]) {
3022 			{0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
3023 			{}
3024 		}
3025 	},
3026 	[ALC268_FIXUP_SPDIF] = {
3027 		.type = HDA_FIXUP_PINS,
3028 		.v.pins = (const struct hda_pintbl[]) {
3029 			{ 0x1e, 0x014b1180 }, /* enable SPDIF out */
3030 			{}
3031 		}
3032 	},
3033 };
3034 
3035 static const struct hda_model_fixup alc268_fixup_models[] = {
3036 	{.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
3037 	{.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
3038 	{.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
3039 	{}
3040 };
3041 
3042 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
3043 	SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
3044 	SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
3045 	/* below is codec SSID since multiple Toshiba laptops have the
3046 	 * same PCI SSID 1179:ff00
3047 	 */
3048 	SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
3049 	{}
3050 };
3051 
3052 /*
3053  * BIOS auto configuration
3054  */
alc268_parse_auto_config(struct hda_codec * codec)3055 static int alc268_parse_auto_config(struct hda_codec *codec)
3056 {
3057 	static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3058 	return alc_parse_auto_config(codec, NULL, alc268_ssids);
3059 }
3060 
3061 /*
3062  */
patch_alc268(struct hda_codec * codec)3063 static int patch_alc268(struct hda_codec *codec)
3064 {
3065 	struct alc_spec *spec;
3066 	int i, err;
3067 
3068 	/* ALC268 has no aa-loopback mixer */
3069 	err = alc_alloc_spec(codec, 0);
3070 	if (err < 0)
3071 		return err;
3072 
3073 	spec = codec->spec;
3074 	if (has_cdefine_beep(codec))
3075 		spec->gen.beep_nid = 0x01;
3076 
3077 	spec->shutup = alc_eapd_shutup;
3078 
3079 	alc_pre_init(codec);
3080 
3081 	snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
3082 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3083 
3084 	/* automatic parse from the BIOS config */
3085 	err = alc268_parse_auto_config(codec);
3086 	if (err < 0)
3087 		goto error;
3088 
3089 	if (err > 0 && !spec->gen.no_analog &&
3090 	    spec->gen.autocfg.speaker_pins[0] != 0x1d) {
3091 		for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
3092 			if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
3093 						  &alc268_beep_mixer[i])) {
3094 				err = -ENOMEM;
3095 				goto error;
3096 			}
3097 		}
3098 		snd_hda_add_verbs(codec, alc268_beep_init_verbs);
3099 		if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
3100 			/* override the amp caps for beep generator */
3101 			snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
3102 					  (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
3103 					  (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
3104 					  (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3105 					  (0 << AC_AMPCAP_MUTE_SHIFT));
3106 	}
3107 
3108 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3109 
3110 	return 0;
3111 
3112  error:
3113 	alc_free(codec);
3114 	return err;
3115 }
3116 
3117 /*
3118  * ALC269
3119  */
3120 
3121 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
3122 	.rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3123 };
3124 
3125 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
3126 	.rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3127 };
3128 
3129 /* different alc269-variants */
3130 enum {
3131 	ALC269_TYPE_ALC269VA,
3132 	ALC269_TYPE_ALC269VB,
3133 	ALC269_TYPE_ALC269VC,
3134 	ALC269_TYPE_ALC269VD,
3135 	ALC269_TYPE_ALC280,
3136 	ALC269_TYPE_ALC282,
3137 	ALC269_TYPE_ALC283,
3138 	ALC269_TYPE_ALC284,
3139 	ALC269_TYPE_ALC293,
3140 	ALC269_TYPE_ALC286,
3141 	ALC269_TYPE_ALC298,
3142 	ALC269_TYPE_ALC255,
3143 	ALC269_TYPE_ALC256,
3144 	ALC269_TYPE_ALC257,
3145 	ALC269_TYPE_ALC215,
3146 	ALC269_TYPE_ALC225,
3147 	ALC269_TYPE_ALC245,
3148 	ALC269_TYPE_ALC287,
3149 	ALC269_TYPE_ALC294,
3150 	ALC269_TYPE_ALC300,
3151 	ALC269_TYPE_ALC623,
3152 	ALC269_TYPE_ALC700,
3153 };
3154 
3155 /*
3156  * BIOS auto configuration
3157  */
alc269_parse_auto_config(struct hda_codec * codec)3158 static int alc269_parse_auto_config(struct hda_codec *codec)
3159 {
3160 	static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3161 	static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
3162 	static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3163 	struct alc_spec *spec = codec->spec;
3164 	const hda_nid_t *ssids;
3165 
3166 	switch (spec->codec_variant) {
3167 	case ALC269_TYPE_ALC269VA:
3168 	case ALC269_TYPE_ALC269VC:
3169 	case ALC269_TYPE_ALC280:
3170 	case ALC269_TYPE_ALC284:
3171 	case ALC269_TYPE_ALC293:
3172 		ssids = alc269va_ssids;
3173 		break;
3174 	case ALC269_TYPE_ALC269VB:
3175 	case ALC269_TYPE_ALC269VD:
3176 	case ALC269_TYPE_ALC282:
3177 	case ALC269_TYPE_ALC283:
3178 	case ALC269_TYPE_ALC286:
3179 	case ALC269_TYPE_ALC298:
3180 	case ALC269_TYPE_ALC255:
3181 	case ALC269_TYPE_ALC256:
3182 	case ALC269_TYPE_ALC257:
3183 	case ALC269_TYPE_ALC215:
3184 	case ALC269_TYPE_ALC225:
3185 	case ALC269_TYPE_ALC245:
3186 	case ALC269_TYPE_ALC287:
3187 	case ALC269_TYPE_ALC294:
3188 	case ALC269_TYPE_ALC300:
3189 	case ALC269_TYPE_ALC623:
3190 	case ALC269_TYPE_ALC700:
3191 		ssids = alc269_ssids;
3192 		break;
3193 	default:
3194 		ssids = alc269_ssids;
3195 		break;
3196 	}
3197 
3198 	return alc_parse_auto_config(codec, alc269_ignore, ssids);
3199 }
3200 
3201 static const struct hda_jack_keymap alc_headset_btn_keymap[] = {
3202 	{ SND_JACK_BTN_0, KEY_PLAYPAUSE },
3203 	{ SND_JACK_BTN_1, KEY_VOICECOMMAND },
3204 	{ SND_JACK_BTN_2, KEY_VOLUMEUP },
3205 	{ SND_JACK_BTN_3, KEY_VOLUMEDOWN },
3206 	{}
3207 };
3208 
alc_headset_btn_callback(struct hda_codec * codec,struct hda_jack_callback * jack)3209 static void alc_headset_btn_callback(struct hda_codec *codec,
3210 				     struct hda_jack_callback *jack)
3211 {
3212 	int report = 0;
3213 
3214 	if (jack->unsol_res & (7 << 13))
3215 		report |= SND_JACK_BTN_0;
3216 
3217 	if (jack->unsol_res  & (1 << 16 | 3 << 8))
3218 		report |= SND_JACK_BTN_1;
3219 
3220 	/* Volume up key */
3221 	if (jack->unsol_res & (7 << 23))
3222 		report |= SND_JACK_BTN_2;
3223 
3224 	/* Volume down key */
3225 	if (jack->unsol_res & (7 << 10))
3226 		report |= SND_JACK_BTN_3;
3227 
3228 	snd_hda_jack_set_button_state(codec, jack->nid, report);
3229 }
3230 
alc_disable_headset_jack_key(struct hda_codec * codec)3231 static void alc_disable_headset_jack_key(struct hda_codec *codec)
3232 {
3233 	struct alc_spec *spec = codec->spec;
3234 
3235 	if (!spec->has_hs_key)
3236 		return;
3237 
3238 	switch (codec->core.vendor_id) {
3239 	case 0x10ec0215:
3240 	case 0x10ec0225:
3241 	case 0x10ec0285:
3242 	case 0x10ec0287:
3243 	case 0x10ec0295:
3244 	case 0x10ec0289:
3245 	case 0x10ec0299:
3246 		alc_write_coef_idx(codec, 0x48, 0x0);
3247 		alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3248 		alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
3249 		break;
3250 	case 0x10ec0230:
3251 	case 0x10ec0236:
3252 	case 0x10ec0256:
3253 	case 0x19e58326:
3254 		alc_write_coef_idx(codec, 0x48, 0x0);
3255 		alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3256 		break;
3257 	}
3258 }
3259 
alc_enable_headset_jack_key(struct hda_codec * codec)3260 static void alc_enable_headset_jack_key(struct hda_codec *codec)
3261 {
3262 	struct alc_spec *spec = codec->spec;
3263 
3264 	if (!spec->has_hs_key)
3265 		return;
3266 
3267 	switch (codec->core.vendor_id) {
3268 	case 0x10ec0215:
3269 	case 0x10ec0225:
3270 	case 0x10ec0285:
3271 	case 0x10ec0287:
3272 	case 0x10ec0295:
3273 	case 0x10ec0289:
3274 	case 0x10ec0299:
3275 		alc_write_coef_idx(codec, 0x48, 0xd011);
3276 		alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3277 		alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
3278 		break;
3279 	case 0x10ec0230:
3280 	case 0x10ec0236:
3281 	case 0x10ec0256:
3282 	case 0x19e58326:
3283 		alc_write_coef_idx(codec, 0x48, 0xd011);
3284 		alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3285 		break;
3286 	}
3287 }
3288 
alc_fixup_headset_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)3289 static void alc_fixup_headset_jack(struct hda_codec *codec,
3290 				    const struct hda_fixup *fix, int action)
3291 {
3292 	struct alc_spec *spec = codec->spec;
3293 	hda_nid_t hp_pin;
3294 
3295 	switch (action) {
3296 	case HDA_FIXUP_ACT_PRE_PROBE:
3297 		spec->has_hs_key = 1;
3298 		snd_hda_jack_detect_enable_callback(codec, 0x55,
3299 						    alc_headset_btn_callback);
3300 		break;
3301 	case HDA_FIXUP_ACT_BUILD:
3302 		hp_pin = alc_get_hp_pin(spec);
3303 		if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55,
3304 							alc_headset_btn_keymap,
3305 							hp_pin))
3306 			snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack",
3307 					      false, SND_JACK_HEADSET,
3308 					      alc_headset_btn_keymap);
3309 
3310 		alc_enable_headset_jack_key(codec);
3311 		break;
3312 	}
3313 }
3314 
alc269vb_toggle_power_output(struct hda_codec * codec,int power_up)3315 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3316 {
3317 	alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3318 }
3319 
alc269_shutup(struct hda_codec * codec)3320 static void alc269_shutup(struct hda_codec *codec)
3321 {
3322 	struct alc_spec *spec = codec->spec;
3323 
3324 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3325 		alc269vb_toggle_power_output(codec, 0);
3326 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3327 			(alc_get_coef0(codec) & 0x00ff) == 0x018) {
3328 		msleep(150);
3329 	}
3330 	alc_shutup_pins(codec);
3331 }
3332 
3333 static const struct coef_fw alc282_coefs[] = {
3334 	WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3335 	UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3336 	WRITE_COEF(0x07, 0x0200), /* DMIC control */
3337 	UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3338 	UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3339 	WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3340 	WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3341 	WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
3342 	UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3343 	UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3344 	WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
3345 	UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
3346 	WRITE_COEF(0x34, 0xa0c0), /* ANC */
3347 	UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
3348 	UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3349 	UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3350 	WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3351 	WRITE_COEF(0x63, 0x2902), /* PLL */
3352 	WRITE_COEF(0x68, 0xa080), /* capless control 2 */
3353 	WRITE_COEF(0x69, 0x3400), /* capless control 3 */
3354 	WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
3355 	WRITE_COEF(0x6b, 0x0), /* capless control 5 */
3356 	UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
3357 	WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
3358 	UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
3359 	WRITE_COEF(0x71, 0x0014), /* class D test 6 */
3360 	WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
3361 	UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
3362 	WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
3363 	{}
3364 };
3365 
alc282_restore_default_value(struct hda_codec * codec)3366 static void alc282_restore_default_value(struct hda_codec *codec)
3367 {
3368 	alc_process_coef_fw(codec, alc282_coefs);
3369 }
3370 
alc282_init(struct hda_codec * codec)3371 static void alc282_init(struct hda_codec *codec)
3372 {
3373 	struct alc_spec *spec = codec->spec;
3374 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3375 	bool hp_pin_sense;
3376 	int coef78;
3377 
3378 	alc282_restore_default_value(codec);
3379 
3380 	if (!hp_pin)
3381 		return;
3382 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3383 	coef78 = alc_read_coef_idx(codec, 0x78);
3384 
3385 	/* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3386 	/* Headphone capless set to high power mode */
3387 	alc_write_coef_idx(codec, 0x78, 0x9004);
3388 
3389 	if (hp_pin_sense)
3390 		msleep(2);
3391 
3392 	snd_hda_codec_write(codec, hp_pin, 0,
3393 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3394 
3395 	if (hp_pin_sense)
3396 		msleep(85);
3397 
3398 	snd_hda_codec_write(codec, hp_pin, 0,
3399 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3400 
3401 	if (hp_pin_sense)
3402 		msleep(100);
3403 
3404 	/* Headphone capless set to normal mode */
3405 	alc_write_coef_idx(codec, 0x78, coef78);
3406 }
3407 
alc282_shutup(struct hda_codec * codec)3408 static void alc282_shutup(struct hda_codec *codec)
3409 {
3410 	struct alc_spec *spec = codec->spec;
3411 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3412 	bool hp_pin_sense;
3413 	int coef78;
3414 
3415 	if (!hp_pin) {
3416 		alc269_shutup(codec);
3417 		return;
3418 	}
3419 
3420 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3421 	coef78 = alc_read_coef_idx(codec, 0x78);
3422 	alc_write_coef_idx(codec, 0x78, 0x9004);
3423 
3424 	if (hp_pin_sense)
3425 		msleep(2);
3426 
3427 	snd_hda_codec_write(codec, hp_pin, 0,
3428 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3429 
3430 	if (hp_pin_sense)
3431 		msleep(85);
3432 
3433 	if (!spec->no_shutup_pins)
3434 		snd_hda_codec_write(codec, hp_pin, 0,
3435 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3436 
3437 	if (hp_pin_sense)
3438 		msleep(100);
3439 
3440 	alc_auto_setup_eapd(codec, false);
3441 	alc_shutup_pins(codec);
3442 	alc_write_coef_idx(codec, 0x78, coef78);
3443 }
3444 
3445 static const struct coef_fw alc283_coefs[] = {
3446 	WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3447 	UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3448 	WRITE_COEF(0x07, 0x0200), /* DMIC control */
3449 	UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3450 	UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3451 	WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3452 	WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3453 	WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3454 	UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3455 	UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3456 	WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3457 	UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3458 	WRITE_COEF(0x22, 0xa0c0), /* ANC */
3459 	UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3460 	UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3461 	UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3462 	WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3463 	WRITE_COEF(0x2e, 0x2902), /* PLL */
3464 	WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3465 	WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3466 	WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3467 	WRITE_COEF(0x36, 0x0), /* capless control 5 */
3468 	UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3469 	WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3470 	UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3471 	WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3472 	WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3473 	UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3474 	WRITE_COEF(0x49, 0x0), /* test mode */
3475 	UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3476 	UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3477 	WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3478 	UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3479 	{}
3480 };
3481 
alc283_restore_default_value(struct hda_codec * codec)3482 static void alc283_restore_default_value(struct hda_codec *codec)
3483 {
3484 	alc_process_coef_fw(codec, alc283_coefs);
3485 }
3486 
alc283_init(struct hda_codec * codec)3487 static void alc283_init(struct hda_codec *codec)
3488 {
3489 	struct alc_spec *spec = codec->spec;
3490 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3491 	bool hp_pin_sense;
3492 
3493 	alc283_restore_default_value(codec);
3494 
3495 	if (!hp_pin)
3496 		return;
3497 
3498 	msleep(30);
3499 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3500 
3501 	/* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3502 	/* Headphone capless set to high power mode */
3503 	alc_write_coef_idx(codec, 0x43, 0x9004);
3504 
3505 	snd_hda_codec_write(codec, hp_pin, 0,
3506 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3507 
3508 	if (hp_pin_sense)
3509 		msleep(85);
3510 
3511 	snd_hda_codec_write(codec, hp_pin, 0,
3512 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3513 
3514 	if (hp_pin_sense)
3515 		msleep(85);
3516 	/* Index 0x46 Combo jack auto switch control 2 */
3517 	/* 3k pull low control for Headset jack. */
3518 	alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3519 	/* Headphone capless set to normal mode */
3520 	alc_write_coef_idx(codec, 0x43, 0x9614);
3521 }
3522 
alc283_shutup(struct hda_codec * codec)3523 static void alc283_shutup(struct hda_codec *codec)
3524 {
3525 	struct alc_spec *spec = codec->spec;
3526 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3527 	bool hp_pin_sense;
3528 
3529 	if (!hp_pin) {
3530 		alc269_shutup(codec);
3531 		return;
3532 	}
3533 
3534 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3535 
3536 	alc_write_coef_idx(codec, 0x43, 0x9004);
3537 
3538 	/*depop hp during suspend*/
3539 	alc_write_coef_idx(codec, 0x06, 0x2100);
3540 
3541 	snd_hda_codec_write(codec, hp_pin, 0,
3542 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3543 
3544 	if (hp_pin_sense)
3545 		msleep(100);
3546 
3547 	if (!spec->no_shutup_pins)
3548 		snd_hda_codec_write(codec, hp_pin, 0,
3549 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3550 
3551 	alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3552 
3553 	if (hp_pin_sense)
3554 		msleep(100);
3555 	alc_auto_setup_eapd(codec, false);
3556 	alc_shutup_pins(codec);
3557 	alc_write_coef_idx(codec, 0x43, 0x9614);
3558 }
3559 
alc256_init(struct hda_codec * codec)3560 static void alc256_init(struct hda_codec *codec)
3561 {
3562 	struct alc_spec *spec = codec->spec;
3563 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3564 	bool hp_pin_sense;
3565 
3566 	if (!hp_pin)
3567 		hp_pin = 0x21;
3568 
3569 	msleep(30);
3570 
3571 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3572 
3573 	if (hp_pin_sense)
3574 		msleep(2);
3575 
3576 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3577 	if (spec->ultra_low_power) {
3578 		alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3579 		alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3580 		alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3581 		alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3582 		alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3583 		msleep(30);
3584 	}
3585 
3586 	snd_hda_codec_write(codec, hp_pin, 0,
3587 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3588 
3589 	if (hp_pin_sense || spec->ultra_low_power)
3590 		msleep(85);
3591 
3592 	snd_hda_codec_write(codec, hp_pin, 0,
3593 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3594 
3595 	if (hp_pin_sense || spec->ultra_low_power)
3596 		msleep(100);
3597 
3598 	alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3599 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3600 	alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3601 	alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3602 	/*
3603 	 * Expose headphone mic (or possibly Line In on some machines) instead
3604 	 * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3605 	 * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3606 	 * this register.
3607 	 */
3608 	alc_write_coef_idx(codec, 0x36, 0x5757);
3609 }
3610 
alc256_shutup(struct hda_codec * codec)3611 static void alc256_shutup(struct hda_codec *codec)
3612 {
3613 	struct alc_spec *spec = codec->spec;
3614 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3615 	bool hp_pin_sense;
3616 
3617 	if (!hp_pin)
3618 		hp_pin = 0x21;
3619 
3620 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3621 
3622 	if (hp_pin_sense)
3623 		msleep(2);
3624 
3625 	snd_hda_codec_write(codec, hp_pin, 0,
3626 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3627 
3628 	if (hp_pin_sense || spec->ultra_low_power)
3629 		msleep(85);
3630 
3631 	/* 3k pull low control for Headset jack. */
3632 	/* NOTE: call this before clearing the pin, otherwise codec stalls */
3633 	/* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
3634 	 * when booting with headset plugged. So skip setting it for the codec alc257
3635 	 */
3636 	if (codec->core.vendor_id != 0x10ec0236 &&
3637 	    codec->core.vendor_id != 0x10ec0257)
3638 		alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3639 
3640 	if (!spec->no_shutup_pins)
3641 		snd_hda_codec_write(codec, hp_pin, 0,
3642 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3643 
3644 	if (hp_pin_sense || spec->ultra_low_power)
3645 		msleep(100);
3646 
3647 	alc_auto_setup_eapd(codec, false);
3648 	alc_shutup_pins(codec);
3649 	if (spec->ultra_low_power) {
3650 		msleep(50);
3651 		alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3652 		alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3653 		alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3654 		alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3655 		alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3656 		msleep(30);
3657 	}
3658 }
3659 
alc285_hp_init(struct hda_codec * codec)3660 static void alc285_hp_init(struct hda_codec *codec)
3661 {
3662 	struct alc_spec *spec = codec->spec;
3663 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3664 	int i, val;
3665 	int coef38, coef0d, coef36;
3666 
3667 	alc_update_coef_idx(codec, 0x4a, 1<<15, 1<<15); /* Reset HP JD */
3668 	coef38 = alc_read_coef_idx(codec, 0x38); /* Amp control */
3669 	coef0d = alc_read_coef_idx(codec, 0x0d); /* Digital Misc control */
3670 	coef36 = alc_read_coef_idx(codec, 0x36); /* Passthrough Control */
3671 	alc_update_coef_idx(codec, 0x38, 1<<4, 0x0);
3672 	alc_update_coef_idx(codec, 0x0d, 0x110, 0x0);
3673 
3674 	alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
3675 
3676 	if (hp_pin)
3677 		snd_hda_codec_write(codec, hp_pin, 0,
3678 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3679 
3680 	msleep(130);
3681 	alc_update_coef_idx(codec, 0x36, 1<<14, 1<<14);
3682 	alc_update_coef_idx(codec, 0x36, 1<<13, 0x0);
3683 
3684 	if (hp_pin)
3685 		snd_hda_codec_write(codec, hp_pin, 0,
3686 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3687 	msleep(10);
3688 	alc_write_coef_idx(codec, 0x67, 0x0); /* Set HP depop to manual mode */
3689 	alc_write_coefex_idx(codec, 0x58, 0x00, 0x7880);
3690 	alc_write_coefex_idx(codec, 0x58, 0x0f, 0xf049);
3691 	alc_update_coefex_idx(codec, 0x58, 0x03, 0x00f0, 0x00c0);
3692 
3693 	alc_write_coefex_idx(codec, 0x58, 0x00, 0xf888); /* HP depop procedure start */
3694 	val = alc_read_coefex_idx(codec, 0x58, 0x00);
3695 	for (i = 0; i < 20 && val & 0x8000; i++) {
3696 		msleep(50);
3697 		val = alc_read_coefex_idx(codec, 0x58, 0x00);
3698 	} /* Wait for depop procedure finish  */
3699 
3700 	alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the result */
3701 	alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
3702 	alc_update_coef_idx(codec, 0x0d, 0x110, coef0d);
3703 	alc_update_coef_idx(codec, 0x36, 3<<13, coef36);
3704 
3705 	msleep(50);
3706 	alc_update_coef_idx(codec, 0x4a, 1<<15, 0);
3707 }
3708 
alc225_init(struct hda_codec * codec)3709 static void alc225_init(struct hda_codec *codec)
3710 {
3711 	struct alc_spec *spec = codec->spec;
3712 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3713 	bool hp1_pin_sense, hp2_pin_sense;
3714 
3715 	if (spec->codec_variant != ALC269_TYPE_ALC287 &&
3716 		spec->codec_variant != ALC269_TYPE_ALC245)
3717 		/* required only at boot or S3 and S4 resume time */
3718 		if (!spec->done_hp_init ||
3719 			is_s3_resume(codec) ||
3720 			is_s4_resume(codec)) {
3721 			alc285_hp_init(codec);
3722 			spec->done_hp_init = true;
3723 		}
3724 
3725 	if (!hp_pin)
3726 		hp_pin = 0x21;
3727 	msleep(30);
3728 
3729 	hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3730 	hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3731 
3732 	if (hp1_pin_sense || hp2_pin_sense)
3733 		msleep(2);
3734 
3735 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3736 	if (spec->ultra_low_power) {
3737 		alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3738 		alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3739 		alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3740 		msleep(30);
3741 	}
3742 
3743 	if (hp1_pin_sense || spec->ultra_low_power)
3744 		snd_hda_codec_write(codec, hp_pin, 0,
3745 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3746 	if (hp2_pin_sense)
3747 		snd_hda_codec_write(codec, 0x16, 0,
3748 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3749 
3750 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3751 		msleep(85);
3752 
3753 	if (hp1_pin_sense || spec->ultra_low_power)
3754 		snd_hda_codec_write(codec, hp_pin, 0,
3755 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3756 	if (hp2_pin_sense)
3757 		snd_hda_codec_write(codec, 0x16, 0,
3758 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3759 
3760 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3761 		msleep(100);
3762 
3763 	alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3764 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3765 }
3766 
alc225_shutup(struct hda_codec * codec)3767 static void alc225_shutup(struct hda_codec *codec)
3768 {
3769 	struct alc_spec *spec = codec->spec;
3770 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3771 	bool hp1_pin_sense, hp2_pin_sense;
3772 
3773 	if (!hp_pin)
3774 		hp_pin = 0x21;
3775 
3776 	alc_disable_headset_jack_key(codec);
3777 	/* 3k pull low control for Headset jack. */
3778 	alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3779 
3780 	hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3781 	hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3782 
3783 	if (hp1_pin_sense || hp2_pin_sense)
3784 		msleep(2);
3785 
3786 	if (hp1_pin_sense || spec->ultra_low_power)
3787 		snd_hda_codec_write(codec, hp_pin, 0,
3788 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3789 	if (hp2_pin_sense)
3790 		snd_hda_codec_write(codec, 0x16, 0,
3791 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3792 
3793 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3794 		msleep(85);
3795 
3796 	if (hp1_pin_sense || spec->ultra_low_power)
3797 		snd_hda_codec_write(codec, hp_pin, 0,
3798 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3799 	if (hp2_pin_sense)
3800 		snd_hda_codec_write(codec, 0x16, 0,
3801 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3802 
3803 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3804 		msleep(100);
3805 
3806 	alc_auto_setup_eapd(codec, false);
3807 	alc_shutup_pins(codec);
3808 	if (spec->ultra_low_power) {
3809 		msleep(50);
3810 		alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3811 		alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3812 		alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3813 		alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3814 		msleep(30);
3815 	}
3816 
3817 	alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3818 	alc_enable_headset_jack_key(codec);
3819 }
3820 
alc_default_init(struct hda_codec * codec)3821 static void alc_default_init(struct hda_codec *codec)
3822 {
3823 	struct alc_spec *spec = codec->spec;
3824 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3825 	bool hp_pin_sense;
3826 
3827 	if (!hp_pin)
3828 		return;
3829 
3830 	msleep(30);
3831 
3832 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3833 
3834 	if (hp_pin_sense)
3835 		msleep(2);
3836 
3837 	snd_hda_codec_write(codec, hp_pin, 0,
3838 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3839 
3840 	if (hp_pin_sense)
3841 		msleep(85);
3842 
3843 	snd_hda_codec_write(codec, hp_pin, 0,
3844 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3845 
3846 	if (hp_pin_sense)
3847 		msleep(100);
3848 }
3849 
alc_default_shutup(struct hda_codec * codec)3850 static void alc_default_shutup(struct hda_codec *codec)
3851 {
3852 	struct alc_spec *spec = codec->spec;
3853 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3854 	bool hp_pin_sense;
3855 
3856 	if (!hp_pin) {
3857 		alc269_shutup(codec);
3858 		return;
3859 	}
3860 
3861 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3862 
3863 	if (hp_pin_sense)
3864 		msleep(2);
3865 
3866 	snd_hda_codec_write(codec, hp_pin, 0,
3867 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3868 
3869 	if (hp_pin_sense)
3870 		msleep(85);
3871 
3872 	if (!spec->no_shutup_pins)
3873 		snd_hda_codec_write(codec, hp_pin, 0,
3874 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3875 
3876 	if (hp_pin_sense)
3877 		msleep(100);
3878 
3879 	alc_auto_setup_eapd(codec, false);
3880 	alc_shutup_pins(codec);
3881 }
3882 
alc294_hp_init(struct hda_codec * codec)3883 static void alc294_hp_init(struct hda_codec *codec)
3884 {
3885 	struct alc_spec *spec = codec->spec;
3886 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3887 	int i, val;
3888 
3889 	if (!hp_pin)
3890 		return;
3891 
3892 	snd_hda_codec_write(codec, hp_pin, 0,
3893 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3894 
3895 	msleep(100);
3896 
3897 	if (!spec->no_shutup_pins)
3898 		snd_hda_codec_write(codec, hp_pin, 0,
3899 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3900 
3901 	alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3902 	alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3903 
3904 	/* Wait for depop procedure finish  */
3905 	val = alc_read_coefex_idx(codec, 0x58, 0x01);
3906 	for (i = 0; i < 20 && val & 0x0080; i++) {
3907 		msleep(50);
3908 		val = alc_read_coefex_idx(codec, 0x58, 0x01);
3909 	}
3910 	/* Set HP depop to auto mode */
3911 	alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3912 	msleep(50);
3913 }
3914 
alc294_init(struct hda_codec * codec)3915 static void alc294_init(struct hda_codec *codec)
3916 {
3917 	struct alc_spec *spec = codec->spec;
3918 
3919 	/* required only at boot or S4 resume time */
3920 	if (!spec->done_hp_init ||
3921 	    codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3922 		alc294_hp_init(codec);
3923 		spec->done_hp_init = true;
3924 	}
3925 	alc_default_init(codec);
3926 }
3927 
alc5505_coef_set(struct hda_codec * codec,unsigned int index_reg,unsigned int val)3928 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3929 			     unsigned int val)
3930 {
3931 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3932 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3933 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3934 }
3935 
alc5505_coef_get(struct hda_codec * codec,unsigned int index_reg)3936 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3937 {
3938 	unsigned int val;
3939 
3940 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3941 	val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3942 		& 0xffff;
3943 	val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3944 		<< 16;
3945 	return val;
3946 }
3947 
alc5505_dsp_halt(struct hda_codec * codec)3948 static void alc5505_dsp_halt(struct hda_codec *codec)
3949 {
3950 	unsigned int val;
3951 
3952 	alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3953 	alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3954 	alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3955 	alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3956 	alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3957 	alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3958 	alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3959 	val = alc5505_coef_get(codec, 0x6220);
3960 	alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3961 }
3962 
alc5505_dsp_back_from_halt(struct hda_codec * codec)3963 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3964 {
3965 	alc5505_coef_set(codec, 0x61b8, 0x04133302);
3966 	alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3967 	alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3968 	alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3969 	alc5505_coef_set(codec, 0x6220, 0x2002010f);
3970 	alc5505_coef_set(codec, 0x880c, 0x00000004);
3971 }
3972 
alc5505_dsp_init(struct hda_codec * codec)3973 static void alc5505_dsp_init(struct hda_codec *codec)
3974 {
3975 	unsigned int val;
3976 
3977 	alc5505_dsp_halt(codec);
3978 	alc5505_dsp_back_from_halt(codec);
3979 	alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3980 	alc5505_coef_set(codec, 0x61b0, 0x5b16);
3981 	alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3982 	alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3983 	alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3984 	alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3985 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3986 	alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3987 	alc5505_coef_set(codec, 0x61b8, 0x04173302);
3988 	alc5505_coef_set(codec, 0x61b8, 0x04163302);
3989 	alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3990 	alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3991 	alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3992 
3993 	val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3994 	if (val <= 3)
3995 		alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3996 	else
3997 		alc5505_coef_set(codec, 0x6220, 0x6002018f);
3998 
3999 	alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
4000 	alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
4001 	alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
4002 	alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
4003 	alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
4004 	alc5505_coef_set(codec, 0x880c, 0x00000003);
4005 	alc5505_coef_set(codec, 0x880c, 0x00000010);
4006 
4007 #ifdef HALT_REALTEK_ALC5505
4008 	alc5505_dsp_halt(codec);
4009 #endif
4010 }
4011 
4012 #ifdef HALT_REALTEK_ALC5505
4013 #define alc5505_dsp_suspend(codec)	do { } while (0) /* NOP */
4014 #define alc5505_dsp_resume(codec)	do { } while (0) /* NOP */
4015 #else
4016 #define alc5505_dsp_suspend(codec)	alc5505_dsp_halt(codec)
4017 #define alc5505_dsp_resume(codec)	alc5505_dsp_back_from_halt(codec)
4018 #endif
4019 
4020 #ifdef CONFIG_PM
alc269_suspend(struct hda_codec * codec)4021 static int alc269_suspend(struct hda_codec *codec)
4022 {
4023 	struct alc_spec *spec = codec->spec;
4024 
4025 	if (spec->has_alc5505_dsp)
4026 		alc5505_dsp_suspend(codec);
4027 	return alc_suspend(codec);
4028 }
4029 
alc269_resume(struct hda_codec * codec)4030 static int alc269_resume(struct hda_codec *codec)
4031 {
4032 	struct alc_spec *spec = codec->spec;
4033 
4034 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4035 		alc269vb_toggle_power_output(codec, 0);
4036 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4037 			(alc_get_coef0(codec) & 0x00ff) == 0x018) {
4038 		msleep(150);
4039 	}
4040 
4041 	codec->patch_ops.init(codec);
4042 
4043 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4044 		alc269vb_toggle_power_output(codec, 1);
4045 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4046 			(alc_get_coef0(codec) & 0x00ff) == 0x017) {
4047 		msleep(200);
4048 	}
4049 
4050 	snd_hda_regmap_sync(codec);
4051 	hda_call_check_power_status(codec, 0x01);
4052 
4053 	/* on some machine, the BIOS will clear the codec gpio data when enter
4054 	 * suspend, and won't restore the data after resume, so we restore it
4055 	 * in the driver.
4056 	 */
4057 	if (spec->gpio_data)
4058 		alc_write_gpio_data(codec);
4059 
4060 	if (spec->has_alc5505_dsp)
4061 		alc5505_dsp_resume(codec);
4062 
4063 	return 0;
4064 }
4065 #endif /* CONFIG_PM */
4066 
alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec * codec,const struct hda_fixup * fix,int action)4067 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
4068 						 const struct hda_fixup *fix, int action)
4069 {
4070 	struct alc_spec *spec = codec->spec;
4071 
4072 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4073 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4074 }
4075 
alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4076 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
4077 						 const struct hda_fixup *fix,
4078 						 int action)
4079 {
4080 	unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
4081 	unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
4082 
4083 	if (cfg_headphone && cfg_headset_mic == 0x411111f0)
4084 		snd_hda_codec_set_pincfg(codec, 0x19,
4085 			(cfg_headphone & ~AC_DEFCFG_DEVICE) |
4086 			(AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
4087 }
4088 
alc269_fixup_hweq(struct hda_codec * codec,const struct hda_fixup * fix,int action)4089 static void alc269_fixup_hweq(struct hda_codec *codec,
4090 			       const struct hda_fixup *fix, int action)
4091 {
4092 	if (action == HDA_FIXUP_ACT_INIT)
4093 		alc_update_coef_idx(codec, 0x1e, 0, 0x80);
4094 }
4095 
alc269_fixup_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4096 static void alc269_fixup_headset_mic(struct hda_codec *codec,
4097 				       const struct hda_fixup *fix, int action)
4098 {
4099 	struct alc_spec *spec = codec->spec;
4100 
4101 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4102 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4103 }
4104 
alc271_fixup_dmic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4105 static void alc271_fixup_dmic(struct hda_codec *codec,
4106 			      const struct hda_fixup *fix, int action)
4107 {
4108 	static const struct hda_verb verbs[] = {
4109 		{0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
4110 		{0x20, AC_VERB_SET_PROC_COEF, 0x4000},
4111 		{}
4112 	};
4113 	unsigned int cfg;
4114 
4115 	if (strcmp(codec->core.chip_name, "ALC271X") &&
4116 	    strcmp(codec->core.chip_name, "ALC269VB"))
4117 		return;
4118 	cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4119 	if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
4120 		snd_hda_sequence_write(codec, verbs);
4121 }
4122 
4123 /* Fix the speaker amp after resume, etc */
alc269vb_fixup_aspire_e1_coef(struct hda_codec * codec,const struct hda_fixup * fix,int action)4124 static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4125 					  const struct hda_fixup *fix,
4126 					  int action)
4127 {
4128 	if (action == HDA_FIXUP_ACT_INIT)
4129 		alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4130 }
4131 
alc269_fixup_pcm_44k(struct hda_codec * codec,const struct hda_fixup * fix,int action)4132 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4133 				 const struct hda_fixup *fix, int action)
4134 {
4135 	struct alc_spec *spec = codec->spec;
4136 
4137 	if (action != HDA_FIXUP_ACT_PROBE)
4138 		return;
4139 
4140 	/* Due to a hardware problem on Lenovo Ideadpad, we need to
4141 	 * fix the sample rate of analog I/O to 44.1kHz
4142 	 */
4143 	spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
4144 	spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
4145 }
4146 
alc269_fixup_stereo_dmic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4147 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4148 				     const struct hda_fixup *fix, int action)
4149 {
4150 	/* The digital-mic unit sends PDM (differential signal) instead of
4151 	 * the standard PCM, thus you can't record a valid mono stream as is.
4152 	 * Below is a workaround specific to ALC269 to control the dmic
4153 	 * signal source as mono.
4154 	 */
4155 	if (action == HDA_FIXUP_ACT_INIT)
4156 		alc_update_coef_idx(codec, 0x07, 0, 0x80);
4157 }
4158 
alc269_quanta_automute(struct hda_codec * codec)4159 static void alc269_quanta_automute(struct hda_codec *codec)
4160 {
4161 	snd_hda_gen_update_outputs(codec);
4162 
4163 	alc_write_coef_idx(codec, 0x0c, 0x680);
4164 	alc_write_coef_idx(codec, 0x0c, 0x480);
4165 }
4166 
alc269_fixup_quanta_mute(struct hda_codec * codec,const struct hda_fixup * fix,int action)4167 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4168 				     const struct hda_fixup *fix, int action)
4169 {
4170 	struct alc_spec *spec = codec->spec;
4171 	if (action != HDA_FIXUP_ACT_PROBE)
4172 		return;
4173 	spec->gen.automute_hook = alc269_quanta_automute;
4174 }
4175 
alc269_x101_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)4176 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4177 					 struct hda_jack_callback *jack)
4178 {
4179 	struct alc_spec *spec = codec->spec;
4180 	int vref;
4181 	msleep(200);
4182 	snd_hda_gen_hp_automute(codec, jack);
4183 
4184 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4185 	msleep(100);
4186 	snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4187 			    vref);
4188 	msleep(500);
4189 	snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4190 			    vref);
4191 }
4192 
4193 /*
4194  * Magic sequence to make Huawei Matebook X right speaker working (bko#197801)
4195  */
4196 struct hda_alc298_mbxinit {
4197 	unsigned char value_0x23;
4198 	unsigned char value_0x25;
4199 };
4200 
alc298_huawei_mbx_stereo_seq(struct hda_codec * codec,const struct hda_alc298_mbxinit * initval,bool first)4201 static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4202 					 const struct hda_alc298_mbxinit *initval,
4203 					 bool first)
4204 {
4205 	snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4206 	alc_write_coef_idx(codec, 0x26, 0xb000);
4207 
4208 	if (first)
4209 		snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4210 
4211 	snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4212 	alc_write_coef_idx(codec, 0x26, 0xf000);
4213 	alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4214 
4215 	if (initval->value_0x23 != 0x1e)
4216 		alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4217 
4218 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4219 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4220 }
4221 
alc298_fixup_huawei_mbx_stereo(struct hda_codec * codec,const struct hda_fixup * fix,int action)4222 static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4223 					   const struct hda_fixup *fix,
4224 					   int action)
4225 {
4226 	/* Initialization magic */
4227 	static const struct hda_alc298_mbxinit dac_init[] = {
4228 		{0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00},
4229 		{0x10, 0x00}, {0x1a, 0x40}, {0x1b, 0x82}, {0x1c, 0x00},
4230 		{0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00},
4231 		{0x20, 0xc2}, {0x21, 0xc8}, {0x22, 0x26}, {0x23, 0x24},
4232 		{0x27, 0xff}, {0x28, 0xff}, {0x29, 0xff}, {0x2a, 0x8f},
4233 		{0x2b, 0x02}, {0x2c, 0x48}, {0x2d, 0x34}, {0x2e, 0x00},
4234 		{0x2f, 0x00},
4235 		{0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00},
4236 		{0x34, 0x00}, {0x35, 0x01}, {0x36, 0x93}, {0x37, 0x0c},
4237 		{0x38, 0x00}, {0x39, 0x00}, {0x3a, 0xf8}, {0x38, 0x80},
4238 		{}
4239 	};
4240 	const struct hda_alc298_mbxinit *seq;
4241 
4242 	if (action != HDA_FIXUP_ACT_INIT)
4243 		return;
4244 
4245 	/* Start */
4246 	snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4247 	snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4248 	alc_write_coef_idx(codec, 0x26, 0xf000);
4249 	alc_write_coef_idx(codec, 0x22, 0x31);
4250 	alc_write_coef_idx(codec, 0x23, 0x0b);
4251 	alc_write_coef_idx(codec, 0x25, 0x00);
4252 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4253 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4254 
4255 	for (seq = dac_init; seq->value_0x23; seq++)
4256 		alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4257 }
4258 
alc269_fixup_x101_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4259 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4260 				     const struct hda_fixup *fix, int action)
4261 {
4262 	struct alc_spec *spec = codec->spec;
4263 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4264 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4265 		spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
4266 	}
4267 }
4268 
alc_update_vref_led(struct hda_codec * codec,hda_nid_t pin,bool polarity,bool on)4269 static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin,
4270 				bool polarity, bool on)
4271 {
4272 	unsigned int pinval;
4273 
4274 	if (!pin)
4275 		return;
4276 	if (polarity)
4277 		on = !on;
4278 	pinval = snd_hda_codec_get_pin_target(codec, pin);
4279 	pinval &= ~AC_PINCTL_VREFEN;
4280 	pinval |= on ? AC_PINCTL_VREF_80 : AC_PINCTL_VREF_HIZ;
4281 	/* temporarily power up/down for setting VREF */
4282 	snd_hda_power_up_pm(codec);
4283 	snd_hda_set_pin_ctl_cache(codec, pin, pinval);
4284 	snd_hda_power_down_pm(codec);
4285 }
4286 
4287 /* update mute-LED according to the speaker mute state via mic VREF pin */
vref_mute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4288 static int vref_mute_led_set(struct led_classdev *led_cdev,
4289 			     enum led_brightness brightness)
4290 {
4291 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4292 	struct alc_spec *spec = codec->spec;
4293 
4294 	alc_update_vref_led(codec, spec->mute_led_nid,
4295 			    spec->mute_led_polarity, brightness);
4296 	return 0;
4297 }
4298 
4299 /* Make sure the led works even in runtime suspend */
led_power_filter(struct hda_codec * codec,hda_nid_t nid,unsigned int power_state)4300 static unsigned int led_power_filter(struct hda_codec *codec,
4301 						  hda_nid_t nid,
4302 						  unsigned int power_state)
4303 {
4304 	struct alc_spec *spec = codec->spec;
4305 
4306 	if (power_state != AC_PWRST_D3 || nid == 0 ||
4307 	    (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
4308 		return power_state;
4309 
4310 	/* Set pin ctl again, it might have just been set to 0 */
4311 	snd_hda_set_pin_ctl(codec, nid,
4312 			    snd_hda_codec_get_pin_target(codec, nid));
4313 
4314 	return snd_hda_gen_path_power_filter(codec, nid, power_state);
4315 }
4316 
alc269_fixup_hp_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4317 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4318 				     const struct hda_fixup *fix, int action)
4319 {
4320 	struct alc_spec *spec = codec->spec;
4321 	const struct dmi_device *dev = NULL;
4322 
4323 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
4324 		return;
4325 
4326 	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
4327 		int pol, pin;
4328 		if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
4329 			continue;
4330 		if (pin < 0x0a || pin >= 0x10)
4331 			break;
4332 		spec->mute_led_polarity = pol;
4333 		spec->mute_led_nid = pin - 0x0a + 0x18;
4334 		snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4335 		codec->power_filter = led_power_filter;
4336 		codec_dbg(codec,
4337 			  "Detected mute LED for %x:%d\n", spec->mute_led_nid,
4338 			   spec->mute_led_polarity);
4339 		break;
4340 	}
4341 }
4342 
alc269_fixup_hp_mute_led_micx(struct hda_codec * codec,const struct hda_fixup * fix,int action,hda_nid_t pin)4343 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4344 					  const struct hda_fixup *fix,
4345 					  int action, hda_nid_t pin)
4346 {
4347 	struct alc_spec *spec = codec->spec;
4348 
4349 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4350 		spec->mute_led_polarity = 0;
4351 		spec->mute_led_nid = pin;
4352 		snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4353 		codec->power_filter = led_power_filter;
4354 	}
4355 }
4356 
alc269_fixup_hp_mute_led_mic1(struct hda_codec * codec,const struct hda_fixup * fix,int action)4357 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4358 				const struct hda_fixup *fix, int action)
4359 {
4360 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4361 }
4362 
alc269_fixup_hp_mute_led_mic2(struct hda_codec * codec,const struct hda_fixup * fix,int action)4363 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4364 				const struct hda_fixup *fix, int action)
4365 {
4366 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4367 }
4368 
alc269_fixup_hp_mute_led_mic3(struct hda_codec * codec,const struct hda_fixup * fix,int action)4369 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4370 				const struct hda_fixup *fix, int action)
4371 {
4372 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4373 }
4374 
4375 /* update LED status via GPIO */
alc_update_gpio_led(struct hda_codec * codec,unsigned int mask,int polarity,bool enabled)4376 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4377 				int polarity, bool enabled)
4378 {
4379 	if (polarity)
4380 		enabled = !enabled;
4381 	alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4382 }
4383 
4384 /* turn on/off mute LED via GPIO per vmaster hook */
gpio_mute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4385 static int gpio_mute_led_set(struct led_classdev *led_cdev,
4386 			     enum led_brightness brightness)
4387 {
4388 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4389 	struct alc_spec *spec = codec->spec;
4390 
4391 	alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
4392 			    spec->mute_led_polarity, !brightness);
4393 	return 0;
4394 }
4395 
4396 /* turn on/off mic-mute LED via GPIO per capture hook */
micmute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4397 static int micmute_led_set(struct led_classdev *led_cdev,
4398 			   enum led_brightness brightness)
4399 {
4400 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4401 	struct alc_spec *spec = codec->spec;
4402 
4403 	alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4404 			    spec->micmute_led_polarity, !brightness);
4405 	return 0;
4406 }
4407 
4408 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
alc_fixup_hp_gpio_led(struct hda_codec * codec,int action,unsigned int mute_mask,unsigned int micmute_mask)4409 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4410 				  int action,
4411 				  unsigned int mute_mask,
4412 				  unsigned int micmute_mask)
4413 {
4414 	struct alc_spec *spec = codec->spec;
4415 
4416 	alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4417 
4418 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
4419 		return;
4420 	if (mute_mask) {
4421 		spec->gpio_mute_led_mask = mute_mask;
4422 		snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set);
4423 	}
4424 	if (micmute_mask) {
4425 		spec->gpio_mic_led_mask = micmute_mask;
4426 		snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set);
4427 	}
4428 }
4429 
alc236_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4430 static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
4431 				const struct hda_fixup *fix, int action)
4432 {
4433 	alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
4434 }
4435 
alc269_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4436 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4437 				const struct hda_fixup *fix, int action)
4438 {
4439 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4440 }
4441 
alc285_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4442 static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4443 				const struct hda_fixup *fix, int action)
4444 {
4445 	alc_fixup_hp_gpio_led(codec, action, 0x04, 0x01);
4446 }
4447 
alc286_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4448 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4449 				const struct hda_fixup *fix, int action)
4450 {
4451 	alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4452 }
4453 
alc287_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4454 static void alc287_fixup_hp_gpio_led(struct hda_codec *codec,
4455 				const struct hda_fixup *fix, int action)
4456 {
4457 	alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
4458 }
4459 
alc245_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4460 static void alc245_fixup_hp_gpio_led(struct hda_codec *codec,
4461 				const struct hda_fixup *fix, int action)
4462 {
4463 	struct alc_spec *spec = codec->spec;
4464 
4465 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4466 		spec->micmute_led_polarity = 1;
4467 	alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4468 }
4469 
4470 /* turn on/off mic-mute LED per capture hook via VREF change */
vref_micmute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4471 static int vref_micmute_led_set(struct led_classdev *led_cdev,
4472 				enum led_brightness brightness)
4473 {
4474 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4475 	struct alc_spec *spec = codec->spec;
4476 
4477 	alc_update_vref_led(codec, spec->cap_mute_led_nid,
4478 			    spec->micmute_led_polarity, brightness);
4479 	return 0;
4480 }
4481 
alc269_fixup_hp_gpio_mic1_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4482 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4483 				const struct hda_fixup *fix, int action)
4484 {
4485 	struct alc_spec *spec = codec->spec;
4486 
4487 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4488 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4489 		/* Like hp_gpio_mic1_led, but also needs GPIO4 low to
4490 		 * enable headphone amp
4491 		 */
4492 		spec->gpio_mask |= 0x10;
4493 		spec->gpio_dir |= 0x10;
4494 		spec->cap_mute_led_nid = 0x18;
4495 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4496 		codec->power_filter = led_power_filter;
4497 	}
4498 }
4499 
alc280_fixup_hp_gpio4(struct hda_codec * codec,const struct hda_fixup * fix,int action)4500 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4501 				   const struct hda_fixup *fix, int action)
4502 {
4503 	struct alc_spec *spec = codec->spec;
4504 
4505 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4506 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4507 		spec->cap_mute_led_nid = 0x18;
4508 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4509 		codec->power_filter = led_power_filter;
4510 	}
4511 }
4512 
4513 /* HP Spectre x360 14 model needs a unique workaround for enabling the amp;
4514  * it needs to toggle the GPIO0 once on and off at each time (bko#210633)
4515  */
alc245_fixup_hp_x360_amp(struct hda_codec * codec,const struct hda_fixup * fix,int action)4516 static void alc245_fixup_hp_x360_amp(struct hda_codec *codec,
4517 				     const struct hda_fixup *fix, int action)
4518 {
4519 	struct alc_spec *spec = codec->spec;
4520 
4521 	switch (action) {
4522 	case HDA_FIXUP_ACT_PRE_PROBE:
4523 		spec->gpio_mask |= 0x01;
4524 		spec->gpio_dir |= 0x01;
4525 		break;
4526 	case HDA_FIXUP_ACT_INIT:
4527 		/* need to toggle GPIO to enable the amp */
4528 		alc_update_gpio_data(codec, 0x01, true);
4529 		msleep(100);
4530 		alc_update_gpio_data(codec, 0x01, false);
4531 		break;
4532 	}
4533 }
4534 
4535 /* toggle GPIO2 at each time stream is started; we use PREPARE state instead */
alc274_hp_envy_pcm_hook(struct hda_pcm_stream * hinfo,struct hda_codec * codec,struct snd_pcm_substream * substream,int action)4536 static void alc274_hp_envy_pcm_hook(struct hda_pcm_stream *hinfo,
4537 				    struct hda_codec *codec,
4538 				    struct snd_pcm_substream *substream,
4539 				    int action)
4540 {
4541 	switch (action) {
4542 	case HDA_GEN_PCM_ACT_PREPARE:
4543 		alc_update_gpio_data(codec, 0x04, true);
4544 		break;
4545 	case HDA_GEN_PCM_ACT_CLEANUP:
4546 		alc_update_gpio_data(codec, 0x04, false);
4547 		break;
4548 	}
4549 }
4550 
alc274_fixup_hp_envy_gpio(struct hda_codec * codec,const struct hda_fixup * fix,int action)4551 static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec,
4552 				      const struct hda_fixup *fix,
4553 				      int action)
4554 {
4555 	struct alc_spec *spec = codec->spec;
4556 
4557 	if (action == HDA_FIXUP_ACT_PROBE) {
4558 		spec->gpio_mask |= 0x04;
4559 		spec->gpio_dir |= 0x04;
4560 		spec->gen.pcm_playback_hook = alc274_hp_envy_pcm_hook;
4561 	}
4562 }
4563 
alc_update_coef_led(struct hda_codec * codec,struct alc_coef_led * led,bool polarity,bool on)4564 static void alc_update_coef_led(struct hda_codec *codec,
4565 				struct alc_coef_led *led,
4566 				bool polarity, bool on)
4567 {
4568 	if (polarity)
4569 		on = !on;
4570 	/* temporarily power up/down for setting COEF bit */
4571 	alc_update_coef_idx(codec, led->idx, led->mask,
4572 			    on ? led->on : led->off);
4573 }
4574 
4575 /* update mute-LED according to the speaker mute state via COEF bit */
coef_mute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4576 static int coef_mute_led_set(struct led_classdev *led_cdev,
4577 			     enum led_brightness brightness)
4578 {
4579 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4580 	struct alc_spec *spec = codec->spec;
4581 
4582 	alc_update_coef_led(codec, &spec->mute_led_coef,
4583 			    spec->mute_led_polarity, brightness);
4584 	return 0;
4585 }
4586 
alc285_fixup_hp_mute_led_coefbit(struct hda_codec * codec,const struct hda_fixup * fix,int action)4587 static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4588 					  const struct hda_fixup *fix,
4589 					  int action)
4590 {
4591 	struct alc_spec *spec = codec->spec;
4592 
4593 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4594 		spec->mute_led_polarity = 0;
4595 		spec->mute_led_coef.idx = 0x0b;
4596 		spec->mute_led_coef.mask = 1 << 3;
4597 		spec->mute_led_coef.on = 1 << 3;
4598 		spec->mute_led_coef.off = 0;
4599 		snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4600 	}
4601 }
4602 
alc236_fixup_hp_mute_led_coefbit(struct hda_codec * codec,const struct hda_fixup * fix,int action)4603 static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4604 					  const struct hda_fixup *fix,
4605 					  int action)
4606 {
4607 	struct alc_spec *spec = codec->spec;
4608 
4609 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4610 		spec->mute_led_polarity = 0;
4611 		spec->mute_led_coef.idx = 0x34;
4612 		spec->mute_led_coef.mask = 1 << 5;
4613 		spec->mute_led_coef.on = 0;
4614 		spec->mute_led_coef.off = 1 << 5;
4615 		snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4616 	}
4617 }
4618 
4619 /* turn on/off mic-mute LED per capture hook by coef bit */
coef_micmute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4620 static int coef_micmute_led_set(struct led_classdev *led_cdev,
4621 				enum led_brightness brightness)
4622 {
4623 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4624 	struct alc_spec *spec = codec->spec;
4625 
4626 	alc_update_coef_led(codec, &spec->mic_led_coef,
4627 			    spec->micmute_led_polarity, brightness);
4628 	return 0;
4629 }
4630 
alc285_fixup_hp_coef_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4631 static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4632 				const struct hda_fixup *fix, int action)
4633 {
4634 	struct alc_spec *spec = codec->spec;
4635 
4636 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4637 		spec->mic_led_coef.idx = 0x19;
4638 		spec->mic_led_coef.mask = 1 << 13;
4639 		spec->mic_led_coef.on = 1 << 13;
4640 		spec->mic_led_coef.off = 0;
4641 		snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4642 	}
4643 }
4644 
alc236_fixup_hp_coef_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4645 static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4646 				const struct hda_fixup *fix, int action)
4647 {
4648 	struct alc_spec *spec = codec->spec;
4649 
4650 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4651 		spec->mic_led_coef.idx = 0x35;
4652 		spec->mic_led_coef.mask = 3 << 2;
4653 		spec->mic_led_coef.on = 2 << 2;
4654 		spec->mic_led_coef.off = 1 << 2;
4655 		snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4656 	}
4657 }
4658 
alc285_fixup_hp_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4659 static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4660 				const struct hda_fixup *fix, int action)
4661 {
4662 	alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4663 	alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4664 }
4665 
alc236_fixup_hp_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4666 static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4667 				const struct hda_fixup *fix, int action)
4668 {
4669 	alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4670 	alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4671 }
4672 
alc236_fixup_hp_micmute_led_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)4673 static void alc236_fixup_hp_micmute_led_vref(struct hda_codec *codec,
4674 				const struct hda_fixup *fix, int action)
4675 {
4676 	struct alc_spec *spec = codec->spec;
4677 
4678 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4679 		spec->cap_mute_led_nid = 0x1a;
4680 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4681 		codec->power_filter = led_power_filter;
4682 	}
4683 }
4684 
alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)4685 static void alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec *codec,
4686 				const struct hda_fixup *fix, int action)
4687 {
4688 	alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4689 	alc236_fixup_hp_micmute_led_vref(codec, fix, action);
4690 }
4691 
alc298_samsung_write_coef_pack(struct hda_codec * codec,const unsigned short coefs[2])4692 static inline void alc298_samsung_write_coef_pack(struct hda_codec *codec,
4693 						  const unsigned short coefs[2])
4694 {
4695 	alc_write_coef_idx(codec, 0x23, coefs[0]);
4696 	alc_write_coef_idx(codec, 0x25, coefs[1]);
4697 	alc_write_coef_idx(codec, 0x26, 0xb011);
4698 }
4699 
4700 struct alc298_samsung_amp_desc {
4701 	unsigned char nid;
4702 	unsigned short init_seq[2][2];
4703 };
4704 
alc298_fixup_samsung_amp(struct hda_codec * codec,const struct hda_fixup * fix,int action)4705 static void alc298_fixup_samsung_amp(struct hda_codec *codec,
4706 				     const struct hda_fixup *fix, int action)
4707 {
4708 	int i, j;
4709 	static const unsigned short init_seq[][2] = {
4710 		{ 0x19, 0x00 }, { 0x20, 0xc0 }, { 0x22, 0x44 }, { 0x23, 0x08 },
4711 		{ 0x24, 0x85 }, { 0x25, 0x41 }, { 0x35, 0x40 }, { 0x36, 0x01 },
4712 		{ 0x38, 0x81 }, { 0x3a, 0x03 }, { 0x3b, 0x81 }, { 0x40, 0x3e },
4713 		{ 0x41, 0x07 }, { 0x400, 0x1 }
4714 	};
4715 	static const struct alc298_samsung_amp_desc amps[] = {
4716 		{ 0x3a, { { 0x18, 0x1 }, { 0x26, 0x0 } } },
4717 		{ 0x39, { { 0x18, 0x2 }, { 0x26, 0x1 } } }
4718 	};
4719 
4720 	if (action != HDA_FIXUP_ACT_INIT)
4721 		return;
4722 
4723 	for (i = 0; i < ARRAY_SIZE(amps); i++) {
4724 		alc_write_coef_idx(codec, 0x22, amps[i].nid);
4725 
4726 		for (j = 0; j < ARRAY_SIZE(amps[i].init_seq); j++)
4727 			alc298_samsung_write_coef_pack(codec, amps[i].init_seq[j]);
4728 
4729 		for (j = 0; j < ARRAY_SIZE(init_seq); j++)
4730 			alc298_samsung_write_coef_pack(codec, init_seq[j]);
4731 	}
4732 }
4733 
4734 #if IS_REACHABLE(CONFIG_INPUT)
gpio2_mic_hotkey_event(struct hda_codec * codec,struct hda_jack_callback * event)4735 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4736 				   struct hda_jack_callback *event)
4737 {
4738 	struct alc_spec *spec = codec->spec;
4739 
4740 	/* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4741 	   send both key on and key off event for every interrupt. */
4742 	input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4743 	input_sync(spec->kb_dev);
4744 	input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4745 	input_sync(spec->kb_dev);
4746 }
4747 
alc_register_micmute_input_device(struct hda_codec * codec)4748 static int alc_register_micmute_input_device(struct hda_codec *codec)
4749 {
4750 	struct alc_spec *spec = codec->spec;
4751 	int i;
4752 
4753 	spec->kb_dev = input_allocate_device();
4754 	if (!spec->kb_dev) {
4755 		codec_err(codec, "Out of memory (input_allocate_device)\n");
4756 		return -ENOMEM;
4757 	}
4758 
4759 	spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4760 
4761 	spec->kb_dev->name = "Microphone Mute Button";
4762 	spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4763 	spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4764 	spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4765 	spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4766 	for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4767 		set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4768 
4769 	if (input_register_device(spec->kb_dev)) {
4770 		codec_err(codec, "input_register_device failed\n");
4771 		input_free_device(spec->kb_dev);
4772 		spec->kb_dev = NULL;
4773 		return -ENOMEM;
4774 	}
4775 
4776 	return 0;
4777 }
4778 
4779 /* GPIO1 = set according to SKU external amp
4780  * GPIO2 = mic mute hotkey
4781  * GPIO3 = mute LED
4782  * GPIO4 = mic mute LED
4783  */
alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec * codec,const struct hda_fixup * fix,int action)4784 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4785 					     const struct hda_fixup *fix, int action)
4786 {
4787 	struct alc_spec *spec = codec->spec;
4788 
4789 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4790 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4791 		spec->init_amp = ALC_INIT_DEFAULT;
4792 		if (alc_register_micmute_input_device(codec) != 0)
4793 			return;
4794 
4795 		spec->gpio_mask |= 0x06;
4796 		spec->gpio_dir |= 0x02;
4797 		spec->gpio_data |= 0x02;
4798 		snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4799 					  AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
4800 		snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4801 						    gpio2_mic_hotkey_event);
4802 		return;
4803 	}
4804 
4805 	if (!spec->kb_dev)
4806 		return;
4807 
4808 	switch (action) {
4809 	case HDA_FIXUP_ACT_FREE:
4810 		input_unregister_device(spec->kb_dev);
4811 		spec->kb_dev = NULL;
4812 	}
4813 }
4814 
4815 /* Line2 = mic mute hotkey
4816  * GPIO2 = mic mute LED
4817  */
alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec * codec,const struct hda_fixup * fix,int action)4818 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4819 					     const struct hda_fixup *fix, int action)
4820 {
4821 	struct alc_spec *spec = codec->spec;
4822 
4823 	alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4824 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4825 		spec->init_amp = ALC_INIT_DEFAULT;
4826 		if (alc_register_micmute_input_device(codec) != 0)
4827 			return;
4828 
4829 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
4830 						    gpio2_mic_hotkey_event);
4831 		return;
4832 	}
4833 
4834 	if (!spec->kb_dev)
4835 		return;
4836 
4837 	switch (action) {
4838 	case HDA_FIXUP_ACT_FREE:
4839 		input_unregister_device(spec->kb_dev);
4840 		spec->kb_dev = NULL;
4841 	}
4842 }
4843 #else /* INPUT */
4844 #define alc280_fixup_hp_gpio2_mic_hotkey	NULL
4845 #define alc233_fixup_lenovo_line2_mic_hotkey	NULL
4846 #endif /* INPUT */
4847 
alc269_fixup_hp_line1_mic1_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4848 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4849 				const struct hda_fixup *fix, int action)
4850 {
4851 	struct alc_spec *spec = codec->spec;
4852 
4853 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4854 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4855 		spec->cap_mute_led_nid = 0x18;
4856 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4857 	}
4858 }
4859 
4860 static const struct coef_fw alc225_pre_hsmode[] = {
4861 	UPDATE_COEF(0x4a, 1<<8, 0),
4862 	UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4863 	UPDATE_COEF(0x63, 3<<14, 3<<14),
4864 	UPDATE_COEF(0x4a, 3<<4, 2<<4),
4865 	UPDATE_COEF(0x4a, 3<<10, 3<<10),
4866 	UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4867 	UPDATE_COEF(0x4a, 3<<10, 0),
4868 	{}
4869 };
4870 
alc_headset_mode_unplugged(struct hda_codec * codec)4871 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4872 {
4873 	struct alc_spec *spec = codec->spec;
4874 	static const struct coef_fw coef0255[] = {
4875 		WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4876 		WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4877 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4878 		WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4879 		WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4880 		{}
4881 	};
4882 	static const struct coef_fw coef0256[] = {
4883 		WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4884 		WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4885 		WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4886 		WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4887 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4888 		{}
4889 	};
4890 	static const struct coef_fw coef0233[] = {
4891 		WRITE_COEF(0x1b, 0x0c0b),
4892 		WRITE_COEF(0x45, 0xc429),
4893 		UPDATE_COEF(0x35, 0x4000, 0),
4894 		WRITE_COEF(0x06, 0x2104),
4895 		WRITE_COEF(0x1a, 0x0001),
4896 		WRITE_COEF(0x26, 0x0004),
4897 		WRITE_COEF(0x32, 0x42a3),
4898 		{}
4899 	};
4900 	static const struct coef_fw coef0288[] = {
4901 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4902 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4903 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4904 		UPDATE_COEF(0x66, 0x0008, 0),
4905 		UPDATE_COEF(0x67, 0x2000, 0),
4906 		{}
4907 	};
4908 	static const struct coef_fw coef0298[] = {
4909 		UPDATE_COEF(0x19, 0x1300, 0x0300),
4910 		{}
4911 	};
4912 	static const struct coef_fw coef0292[] = {
4913 		WRITE_COEF(0x76, 0x000e),
4914 		WRITE_COEF(0x6c, 0x2400),
4915 		WRITE_COEF(0x18, 0x7308),
4916 		WRITE_COEF(0x6b, 0xc429),
4917 		{}
4918 	};
4919 	static const struct coef_fw coef0293[] = {
4920 		UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4921 		UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4922 		UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4923 		UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4924 		WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4925 		UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4926 		{}
4927 	};
4928 	static const struct coef_fw coef0668[] = {
4929 		WRITE_COEF(0x15, 0x0d40),
4930 		WRITE_COEF(0xb7, 0x802b),
4931 		{}
4932 	};
4933 	static const struct coef_fw coef0225[] = {
4934 		UPDATE_COEF(0x63, 3<<14, 0),
4935 		{}
4936 	};
4937 	static const struct coef_fw coef0274[] = {
4938 		UPDATE_COEF(0x4a, 0x0100, 0),
4939 		UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4940 		UPDATE_COEF(0x6b, 0xf000, 0x5000),
4941 		UPDATE_COEF(0x4a, 0x0010, 0),
4942 		UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4943 		WRITE_COEF(0x45, 0x5289),
4944 		UPDATE_COEF(0x4a, 0x0c00, 0),
4945 		{}
4946 	};
4947 
4948 	if (spec->no_internal_mic_pin) {
4949 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
4950 		return;
4951 	}
4952 
4953 	switch (codec->core.vendor_id) {
4954 	case 0x10ec0255:
4955 		alc_process_coef_fw(codec, coef0255);
4956 		break;
4957 	case 0x10ec0230:
4958 	case 0x10ec0236:
4959 	case 0x10ec0256:
4960 	case 0x19e58326:
4961 		alc_process_coef_fw(codec, coef0256);
4962 		break;
4963 	case 0x10ec0234:
4964 	case 0x10ec0274:
4965 	case 0x10ec0294:
4966 		alc_process_coef_fw(codec, coef0274);
4967 		break;
4968 	case 0x10ec0233:
4969 	case 0x10ec0283:
4970 		alc_process_coef_fw(codec, coef0233);
4971 		break;
4972 	case 0x10ec0286:
4973 	case 0x10ec0288:
4974 		alc_process_coef_fw(codec, coef0288);
4975 		break;
4976 	case 0x10ec0298:
4977 		alc_process_coef_fw(codec, coef0298);
4978 		alc_process_coef_fw(codec, coef0288);
4979 		break;
4980 	case 0x10ec0292:
4981 		alc_process_coef_fw(codec, coef0292);
4982 		break;
4983 	case 0x10ec0293:
4984 		alc_process_coef_fw(codec, coef0293);
4985 		break;
4986 	case 0x10ec0668:
4987 		alc_process_coef_fw(codec, coef0668);
4988 		break;
4989 	case 0x10ec0215:
4990 	case 0x10ec0225:
4991 	case 0x10ec0285:
4992 	case 0x10ec0295:
4993 	case 0x10ec0289:
4994 	case 0x10ec0299:
4995 		alc_process_coef_fw(codec, alc225_pre_hsmode);
4996 		alc_process_coef_fw(codec, coef0225);
4997 		break;
4998 	case 0x10ec0867:
4999 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5000 		break;
5001 	}
5002 	codec_dbg(codec, "Headset jack set to unplugged mode.\n");
5003 }
5004 
5005 
alc_headset_mode_mic_in(struct hda_codec * codec,hda_nid_t hp_pin,hda_nid_t mic_pin)5006 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5007 				    hda_nid_t mic_pin)
5008 {
5009 	static const struct coef_fw coef0255[] = {
5010 		WRITE_COEFEX(0x57, 0x03, 0x8aa6),
5011 		WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
5012 		{}
5013 	};
5014 	static const struct coef_fw coef0256[] = {
5015 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
5016 		WRITE_COEFEX(0x57, 0x03, 0x09a3),
5017 		WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
5018 		{}
5019 	};
5020 	static const struct coef_fw coef0233[] = {
5021 		UPDATE_COEF(0x35, 0, 1<<14),
5022 		WRITE_COEF(0x06, 0x2100),
5023 		WRITE_COEF(0x1a, 0x0021),
5024 		WRITE_COEF(0x26, 0x008c),
5025 		{}
5026 	};
5027 	static const struct coef_fw coef0288[] = {
5028 		UPDATE_COEF(0x4f, 0x00c0, 0),
5029 		UPDATE_COEF(0x50, 0x2000, 0),
5030 		UPDATE_COEF(0x56, 0x0006, 0),
5031 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
5032 		UPDATE_COEF(0x66, 0x0008, 0x0008),
5033 		UPDATE_COEF(0x67, 0x2000, 0x2000),
5034 		{}
5035 	};
5036 	static const struct coef_fw coef0292[] = {
5037 		WRITE_COEF(0x19, 0xa208),
5038 		WRITE_COEF(0x2e, 0xacf0),
5039 		{}
5040 	};
5041 	static const struct coef_fw coef0293[] = {
5042 		UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
5043 		UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
5044 		UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5045 		{}
5046 	};
5047 	static const struct coef_fw coef0688[] = {
5048 		WRITE_COEF(0xb7, 0x802b),
5049 		WRITE_COEF(0xb5, 0x1040),
5050 		UPDATE_COEF(0xc3, 0, 1<<12),
5051 		{}
5052 	};
5053 	static const struct coef_fw coef0225[] = {
5054 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
5055 		UPDATE_COEF(0x4a, 3<<4, 2<<4),
5056 		UPDATE_COEF(0x63, 3<<14, 0),
5057 		{}
5058 	};
5059 	static const struct coef_fw coef0274[] = {
5060 		UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
5061 		UPDATE_COEF(0x4a, 0x0010, 0),
5062 		UPDATE_COEF(0x6b, 0xf000, 0),
5063 		{}
5064 	};
5065 
5066 	switch (codec->core.vendor_id) {
5067 	case 0x10ec0255:
5068 		alc_write_coef_idx(codec, 0x45, 0xc489);
5069 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5070 		alc_process_coef_fw(codec, coef0255);
5071 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5072 		break;
5073 	case 0x10ec0230:
5074 	case 0x10ec0236:
5075 	case 0x10ec0256:
5076 	case 0x19e58326:
5077 		alc_write_coef_idx(codec, 0x45, 0xc489);
5078 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5079 		alc_process_coef_fw(codec, coef0256);
5080 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5081 		break;
5082 	case 0x10ec0234:
5083 	case 0x10ec0274:
5084 	case 0x10ec0294:
5085 		alc_write_coef_idx(codec, 0x45, 0x4689);
5086 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5087 		alc_process_coef_fw(codec, coef0274);
5088 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5089 		break;
5090 	case 0x10ec0233:
5091 	case 0x10ec0283:
5092 		alc_write_coef_idx(codec, 0x45, 0xc429);
5093 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5094 		alc_process_coef_fw(codec, coef0233);
5095 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5096 		break;
5097 	case 0x10ec0286:
5098 	case 0x10ec0288:
5099 	case 0x10ec0298:
5100 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5101 		alc_process_coef_fw(codec, coef0288);
5102 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5103 		break;
5104 	case 0x10ec0292:
5105 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5106 		alc_process_coef_fw(codec, coef0292);
5107 		break;
5108 	case 0x10ec0293:
5109 		/* Set to TRS mode */
5110 		alc_write_coef_idx(codec, 0x45, 0xc429);
5111 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5112 		alc_process_coef_fw(codec, coef0293);
5113 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5114 		break;
5115 	case 0x10ec0867:
5116 		alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
5117 		fallthrough;
5118 	case 0x10ec0221:
5119 	case 0x10ec0662:
5120 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5121 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5122 		break;
5123 	case 0x10ec0668:
5124 		alc_write_coef_idx(codec, 0x11, 0x0001);
5125 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5126 		alc_process_coef_fw(codec, coef0688);
5127 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5128 		break;
5129 	case 0x10ec0215:
5130 	case 0x10ec0225:
5131 	case 0x10ec0285:
5132 	case 0x10ec0295:
5133 	case 0x10ec0289:
5134 	case 0x10ec0299:
5135 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5136 		alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
5137 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5138 		alc_process_coef_fw(codec, coef0225);
5139 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5140 		break;
5141 	}
5142 	codec_dbg(codec, "Headset jack set to mic-in mode.\n");
5143 }
5144 
alc_headset_mode_default(struct hda_codec * codec)5145 static void alc_headset_mode_default(struct hda_codec *codec)
5146 {
5147 	static const struct coef_fw coef0225[] = {
5148 		UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
5149 		UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
5150 		UPDATE_COEF(0x49, 3<<8, 0<<8),
5151 		UPDATE_COEF(0x4a, 3<<4, 3<<4),
5152 		UPDATE_COEF(0x63, 3<<14, 0),
5153 		UPDATE_COEF(0x67, 0xf000, 0x3000),
5154 		{}
5155 	};
5156 	static const struct coef_fw coef0255[] = {
5157 		WRITE_COEF(0x45, 0xc089),
5158 		WRITE_COEF(0x45, 0xc489),
5159 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5160 		WRITE_COEF(0x49, 0x0049),
5161 		{}
5162 	};
5163 	static const struct coef_fw coef0256[] = {
5164 		WRITE_COEF(0x45, 0xc489),
5165 		WRITE_COEFEX(0x57, 0x03, 0x0da3),
5166 		WRITE_COEF(0x49, 0x0049),
5167 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
5168 		WRITE_COEF(0x06, 0x6100),
5169 		{}
5170 	};
5171 	static const struct coef_fw coef0233[] = {
5172 		WRITE_COEF(0x06, 0x2100),
5173 		WRITE_COEF(0x32, 0x4ea3),
5174 		{}
5175 	};
5176 	static const struct coef_fw coef0288[] = {
5177 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
5178 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5179 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5180 		UPDATE_COEF(0x66, 0x0008, 0),
5181 		UPDATE_COEF(0x67, 0x2000, 0),
5182 		{}
5183 	};
5184 	static const struct coef_fw coef0292[] = {
5185 		WRITE_COEF(0x76, 0x000e),
5186 		WRITE_COEF(0x6c, 0x2400),
5187 		WRITE_COEF(0x6b, 0xc429),
5188 		WRITE_COEF(0x18, 0x7308),
5189 		{}
5190 	};
5191 	static const struct coef_fw coef0293[] = {
5192 		UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
5193 		WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
5194 		UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5195 		{}
5196 	};
5197 	static const struct coef_fw coef0688[] = {
5198 		WRITE_COEF(0x11, 0x0041),
5199 		WRITE_COEF(0x15, 0x0d40),
5200 		WRITE_COEF(0xb7, 0x802b),
5201 		{}
5202 	};
5203 	static const struct coef_fw coef0274[] = {
5204 		WRITE_COEF(0x45, 0x4289),
5205 		UPDATE_COEF(0x4a, 0x0010, 0x0010),
5206 		UPDATE_COEF(0x6b, 0x0f00, 0),
5207 		UPDATE_COEF(0x49, 0x0300, 0x0300),
5208 		{}
5209 	};
5210 
5211 	switch (codec->core.vendor_id) {
5212 	case 0x10ec0215:
5213 	case 0x10ec0225:
5214 	case 0x10ec0285:
5215 	case 0x10ec0295:
5216 	case 0x10ec0289:
5217 	case 0x10ec0299:
5218 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5219 		alc_process_coef_fw(codec, coef0225);
5220 		break;
5221 	case 0x10ec0255:
5222 		alc_process_coef_fw(codec, coef0255);
5223 		break;
5224 	case 0x10ec0230:
5225 	case 0x10ec0236:
5226 	case 0x10ec0256:
5227 	case 0x19e58326:
5228 		alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5229 		alc_write_coef_idx(codec, 0x45, 0xc089);
5230 		msleep(50);
5231 		alc_process_coef_fw(codec, coef0256);
5232 		break;
5233 	case 0x10ec0234:
5234 	case 0x10ec0274:
5235 	case 0x10ec0294:
5236 		alc_process_coef_fw(codec, coef0274);
5237 		break;
5238 	case 0x10ec0233:
5239 	case 0x10ec0283:
5240 		alc_process_coef_fw(codec, coef0233);
5241 		break;
5242 	case 0x10ec0286:
5243 	case 0x10ec0288:
5244 	case 0x10ec0298:
5245 		alc_process_coef_fw(codec, coef0288);
5246 		break;
5247 	case 0x10ec0292:
5248 		alc_process_coef_fw(codec, coef0292);
5249 		break;
5250 	case 0x10ec0293:
5251 		alc_process_coef_fw(codec, coef0293);
5252 		break;
5253 	case 0x10ec0668:
5254 		alc_process_coef_fw(codec, coef0688);
5255 		break;
5256 	case 0x10ec0867:
5257 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5258 		break;
5259 	}
5260 	codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5261 }
5262 
5263 /* Iphone type */
alc_headset_mode_ctia(struct hda_codec * codec)5264 static void alc_headset_mode_ctia(struct hda_codec *codec)
5265 {
5266 	int val;
5267 
5268 	static const struct coef_fw coef0255[] = {
5269 		WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5270 		WRITE_COEF(0x1b, 0x0c2b),
5271 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5272 		{}
5273 	};
5274 	static const struct coef_fw coef0256[] = {
5275 		WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5276 		WRITE_COEF(0x1b, 0x0e6b),
5277 		{}
5278 	};
5279 	static const struct coef_fw coef0233[] = {
5280 		WRITE_COEF(0x45, 0xd429),
5281 		WRITE_COEF(0x1b, 0x0c2b),
5282 		WRITE_COEF(0x32, 0x4ea3),
5283 		{}
5284 	};
5285 	static const struct coef_fw coef0288[] = {
5286 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5287 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5288 		UPDATE_COEF(0x66, 0x0008, 0),
5289 		UPDATE_COEF(0x67, 0x2000, 0),
5290 		{}
5291 	};
5292 	static const struct coef_fw coef0292[] = {
5293 		WRITE_COEF(0x6b, 0xd429),
5294 		WRITE_COEF(0x76, 0x0008),
5295 		WRITE_COEF(0x18, 0x7388),
5296 		{}
5297 	};
5298 	static const struct coef_fw coef0293[] = {
5299 		WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
5300 		UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5301 		{}
5302 	};
5303 	static const struct coef_fw coef0688[] = {
5304 		WRITE_COEF(0x11, 0x0001),
5305 		WRITE_COEF(0x15, 0x0d60),
5306 		WRITE_COEF(0xc3, 0x0000),
5307 		{}
5308 	};
5309 	static const struct coef_fw coef0225_1[] = {
5310 		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5311 		UPDATE_COEF(0x63, 3<<14, 2<<14),
5312 		{}
5313 	};
5314 	static const struct coef_fw coef0225_2[] = {
5315 		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5316 		UPDATE_COEF(0x63, 3<<14, 1<<14),
5317 		{}
5318 	};
5319 
5320 	switch (codec->core.vendor_id) {
5321 	case 0x10ec0255:
5322 		alc_process_coef_fw(codec, coef0255);
5323 		break;
5324 	case 0x10ec0230:
5325 	case 0x10ec0236:
5326 	case 0x10ec0256:
5327 	case 0x19e58326:
5328 		alc_process_coef_fw(codec, coef0256);
5329 		break;
5330 	case 0x10ec0234:
5331 	case 0x10ec0274:
5332 	case 0x10ec0294:
5333 		alc_write_coef_idx(codec, 0x45, 0xd689);
5334 		break;
5335 	case 0x10ec0233:
5336 	case 0x10ec0283:
5337 		alc_process_coef_fw(codec, coef0233);
5338 		break;
5339 	case 0x10ec0298:
5340 		val = alc_read_coef_idx(codec, 0x50);
5341 		if (val & (1 << 12)) {
5342 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5343 			alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5344 			msleep(300);
5345 		} else {
5346 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5347 			alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5348 			msleep(300);
5349 		}
5350 		break;
5351 	case 0x10ec0286:
5352 	case 0x10ec0288:
5353 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5354 		msleep(300);
5355 		alc_process_coef_fw(codec, coef0288);
5356 		break;
5357 	case 0x10ec0292:
5358 		alc_process_coef_fw(codec, coef0292);
5359 		break;
5360 	case 0x10ec0293:
5361 		alc_process_coef_fw(codec, coef0293);
5362 		break;
5363 	case 0x10ec0668:
5364 		alc_process_coef_fw(codec, coef0688);
5365 		break;
5366 	case 0x10ec0215:
5367 	case 0x10ec0225:
5368 	case 0x10ec0285:
5369 	case 0x10ec0295:
5370 	case 0x10ec0289:
5371 	case 0x10ec0299:
5372 		val = alc_read_coef_idx(codec, 0x45);
5373 		if (val & (1 << 9))
5374 			alc_process_coef_fw(codec, coef0225_2);
5375 		else
5376 			alc_process_coef_fw(codec, coef0225_1);
5377 		break;
5378 	case 0x10ec0867:
5379 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5380 		break;
5381 	}
5382 	codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5383 }
5384 
5385 /* Nokia type */
alc_headset_mode_omtp(struct hda_codec * codec)5386 static void alc_headset_mode_omtp(struct hda_codec *codec)
5387 {
5388 	static const struct coef_fw coef0255[] = {
5389 		WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5390 		WRITE_COEF(0x1b, 0x0c2b),
5391 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5392 		{}
5393 	};
5394 	static const struct coef_fw coef0256[] = {
5395 		WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5396 		WRITE_COEF(0x1b, 0x0e6b),
5397 		{}
5398 	};
5399 	static const struct coef_fw coef0233[] = {
5400 		WRITE_COEF(0x45, 0xe429),
5401 		WRITE_COEF(0x1b, 0x0c2b),
5402 		WRITE_COEF(0x32, 0x4ea3),
5403 		{}
5404 	};
5405 	static const struct coef_fw coef0288[] = {
5406 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5407 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5408 		UPDATE_COEF(0x66, 0x0008, 0),
5409 		UPDATE_COEF(0x67, 0x2000, 0),
5410 		{}
5411 	};
5412 	static const struct coef_fw coef0292[] = {
5413 		WRITE_COEF(0x6b, 0xe429),
5414 		WRITE_COEF(0x76, 0x0008),
5415 		WRITE_COEF(0x18, 0x7388),
5416 		{}
5417 	};
5418 	static const struct coef_fw coef0293[] = {
5419 		WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
5420 		UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5421 		{}
5422 	};
5423 	static const struct coef_fw coef0688[] = {
5424 		WRITE_COEF(0x11, 0x0001),
5425 		WRITE_COEF(0x15, 0x0d50),
5426 		WRITE_COEF(0xc3, 0x0000),
5427 		{}
5428 	};
5429 	static const struct coef_fw coef0225[] = {
5430 		UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5431 		UPDATE_COEF(0x63, 3<<14, 2<<14),
5432 		{}
5433 	};
5434 
5435 	switch (codec->core.vendor_id) {
5436 	case 0x10ec0255:
5437 		alc_process_coef_fw(codec, coef0255);
5438 		break;
5439 	case 0x10ec0230:
5440 	case 0x10ec0236:
5441 	case 0x10ec0256:
5442 	case 0x19e58326:
5443 		alc_process_coef_fw(codec, coef0256);
5444 		break;
5445 	case 0x10ec0234:
5446 	case 0x10ec0274:
5447 	case 0x10ec0294:
5448 		alc_write_coef_idx(codec, 0x45, 0xe689);
5449 		break;
5450 	case 0x10ec0233:
5451 	case 0x10ec0283:
5452 		alc_process_coef_fw(codec, coef0233);
5453 		break;
5454 	case 0x10ec0298:
5455 		alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5456 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5457 		msleep(300);
5458 		break;
5459 	case 0x10ec0286:
5460 	case 0x10ec0288:
5461 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5462 		msleep(300);
5463 		alc_process_coef_fw(codec, coef0288);
5464 		break;
5465 	case 0x10ec0292:
5466 		alc_process_coef_fw(codec, coef0292);
5467 		break;
5468 	case 0x10ec0293:
5469 		alc_process_coef_fw(codec, coef0293);
5470 		break;
5471 	case 0x10ec0668:
5472 		alc_process_coef_fw(codec, coef0688);
5473 		break;
5474 	case 0x10ec0215:
5475 	case 0x10ec0225:
5476 	case 0x10ec0285:
5477 	case 0x10ec0295:
5478 	case 0x10ec0289:
5479 	case 0x10ec0299:
5480 		alc_process_coef_fw(codec, coef0225);
5481 		break;
5482 	}
5483 	codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5484 }
5485 
alc_determine_headset_type(struct hda_codec * codec)5486 static void alc_determine_headset_type(struct hda_codec *codec)
5487 {
5488 	int val;
5489 	bool is_ctia = false;
5490 	struct alc_spec *spec = codec->spec;
5491 	static const struct coef_fw coef0255[] = {
5492 		WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
5493 		WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
5494  conteol) */
5495 		{}
5496 	};
5497 	static const struct coef_fw coef0288[] = {
5498 		UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
5499 		{}
5500 	};
5501 	static const struct coef_fw coef0298[] = {
5502 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5503 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5504 		UPDATE_COEF(0x66, 0x0008, 0),
5505 		UPDATE_COEF(0x67, 0x2000, 0),
5506 		UPDATE_COEF(0x19, 0x1300, 0x1300),
5507 		{}
5508 	};
5509 	static const struct coef_fw coef0293[] = {
5510 		UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
5511 		WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
5512 		{}
5513 	};
5514 	static const struct coef_fw coef0688[] = {
5515 		WRITE_COEF(0x11, 0x0001),
5516 		WRITE_COEF(0xb7, 0x802b),
5517 		WRITE_COEF(0x15, 0x0d60),
5518 		WRITE_COEF(0xc3, 0x0c00),
5519 		{}
5520 	};
5521 	static const struct coef_fw coef0274[] = {
5522 		UPDATE_COEF(0x4a, 0x0010, 0),
5523 		UPDATE_COEF(0x4a, 0x8000, 0),
5524 		WRITE_COEF(0x45, 0xd289),
5525 		UPDATE_COEF(0x49, 0x0300, 0x0300),
5526 		{}
5527 	};
5528 
5529 	if (spec->no_internal_mic_pin) {
5530 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5531 		return;
5532 	}
5533 
5534 	switch (codec->core.vendor_id) {
5535 	case 0x10ec0255:
5536 		alc_process_coef_fw(codec, coef0255);
5537 		msleep(300);
5538 		val = alc_read_coef_idx(codec, 0x46);
5539 		is_ctia = (val & 0x0070) == 0x0070;
5540 		break;
5541 	case 0x10ec0230:
5542 	case 0x10ec0236:
5543 	case 0x10ec0256:
5544 	case 0x19e58326:
5545 		alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5546 		alc_write_coef_idx(codec, 0x06, 0x6104);
5547 		alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5548 
5549 		snd_hda_codec_write(codec, 0x21, 0,
5550 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5551 		msleep(80);
5552 		snd_hda_codec_write(codec, 0x21, 0,
5553 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5554 
5555 		alc_process_coef_fw(codec, coef0255);
5556 		msleep(300);
5557 		val = alc_read_coef_idx(codec, 0x46);
5558 		is_ctia = (val & 0x0070) == 0x0070;
5559 
5560 		alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5561 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5562 
5563 		snd_hda_codec_write(codec, 0x21, 0,
5564 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5565 		msleep(80);
5566 		snd_hda_codec_write(codec, 0x21, 0,
5567 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5568 		break;
5569 	case 0x10ec0234:
5570 	case 0x10ec0274:
5571 	case 0x10ec0294:
5572 		alc_process_coef_fw(codec, coef0274);
5573 		msleep(850);
5574 		val = alc_read_coef_idx(codec, 0x46);
5575 		is_ctia = (val & 0x00f0) == 0x00f0;
5576 		break;
5577 	case 0x10ec0233:
5578 	case 0x10ec0283:
5579 		alc_write_coef_idx(codec, 0x45, 0xd029);
5580 		msleep(300);
5581 		val = alc_read_coef_idx(codec, 0x46);
5582 		is_ctia = (val & 0x0070) == 0x0070;
5583 		break;
5584 	case 0x10ec0298:
5585 		snd_hda_codec_write(codec, 0x21, 0,
5586 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5587 		msleep(100);
5588 		snd_hda_codec_write(codec, 0x21, 0,
5589 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5590 		msleep(200);
5591 
5592 		val = alc_read_coef_idx(codec, 0x50);
5593 		if (val & (1 << 12)) {
5594 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5595 			alc_process_coef_fw(codec, coef0288);
5596 			msleep(350);
5597 			val = alc_read_coef_idx(codec, 0x50);
5598 			is_ctia = (val & 0x0070) == 0x0070;
5599 		} else {
5600 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5601 			alc_process_coef_fw(codec, coef0288);
5602 			msleep(350);
5603 			val = alc_read_coef_idx(codec, 0x50);
5604 			is_ctia = (val & 0x0070) == 0x0070;
5605 		}
5606 		alc_process_coef_fw(codec, coef0298);
5607 		snd_hda_codec_write(codec, 0x21, 0,
5608 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
5609 		msleep(75);
5610 		snd_hda_codec_write(codec, 0x21, 0,
5611 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5612 		break;
5613 	case 0x10ec0286:
5614 	case 0x10ec0288:
5615 		alc_process_coef_fw(codec, coef0288);
5616 		msleep(350);
5617 		val = alc_read_coef_idx(codec, 0x50);
5618 		is_ctia = (val & 0x0070) == 0x0070;
5619 		break;
5620 	case 0x10ec0292:
5621 		alc_write_coef_idx(codec, 0x6b, 0xd429);
5622 		msleep(300);
5623 		val = alc_read_coef_idx(codec, 0x6c);
5624 		is_ctia = (val & 0x001c) == 0x001c;
5625 		break;
5626 	case 0x10ec0293:
5627 		alc_process_coef_fw(codec, coef0293);
5628 		msleep(300);
5629 		val = alc_read_coef_idx(codec, 0x46);
5630 		is_ctia = (val & 0x0070) == 0x0070;
5631 		break;
5632 	case 0x10ec0668:
5633 		alc_process_coef_fw(codec, coef0688);
5634 		msleep(300);
5635 		val = alc_read_coef_idx(codec, 0xbe);
5636 		is_ctia = (val & 0x1c02) == 0x1c02;
5637 		break;
5638 	case 0x10ec0215:
5639 	case 0x10ec0225:
5640 	case 0x10ec0285:
5641 	case 0x10ec0295:
5642 	case 0x10ec0289:
5643 	case 0x10ec0299:
5644 		snd_hda_codec_write(codec, 0x21, 0,
5645 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5646 		msleep(80);
5647 		snd_hda_codec_write(codec, 0x21, 0,
5648 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5649 
5650 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5651 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5652 		val = alc_read_coef_idx(codec, 0x45);
5653 		if (val & (1 << 9)) {
5654 			alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5655 			alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5656 			msleep(800);
5657 			val = alc_read_coef_idx(codec, 0x46);
5658 			is_ctia = (val & 0x00f0) == 0x00f0;
5659 		} else {
5660 			alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5661 			alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5662 			msleep(800);
5663 			val = alc_read_coef_idx(codec, 0x46);
5664 			is_ctia = (val & 0x00f0) == 0x00f0;
5665 		}
5666 		alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5667 		alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5668 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5669 
5670 		snd_hda_codec_write(codec, 0x21, 0,
5671 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5672 		msleep(80);
5673 		snd_hda_codec_write(codec, 0x21, 0,
5674 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5675 		break;
5676 	case 0x10ec0867:
5677 		is_ctia = true;
5678 		break;
5679 	}
5680 
5681 	codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5682 		    is_ctia ? "yes" : "no");
5683 	spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5684 }
5685 
alc_update_headset_mode(struct hda_codec * codec)5686 static void alc_update_headset_mode(struct hda_codec *codec)
5687 {
5688 	struct alc_spec *spec = codec->spec;
5689 
5690 	hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5691 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
5692 
5693 	int new_headset_mode;
5694 
5695 	if (!snd_hda_jack_detect(codec, hp_pin))
5696 		new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
5697 	else if (mux_pin == spec->headset_mic_pin)
5698 		new_headset_mode = ALC_HEADSET_MODE_HEADSET;
5699 	else if (mux_pin == spec->headphone_mic_pin)
5700 		new_headset_mode = ALC_HEADSET_MODE_MIC;
5701 	else
5702 		new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
5703 
5704 	if (new_headset_mode == spec->current_headset_mode) {
5705 		snd_hda_gen_update_outputs(codec);
5706 		return;
5707 	}
5708 
5709 	switch (new_headset_mode) {
5710 	case ALC_HEADSET_MODE_UNPLUGGED:
5711 		alc_headset_mode_unplugged(codec);
5712 		spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5713 		spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5714 		spec->gen.hp_jack_present = false;
5715 		break;
5716 	case ALC_HEADSET_MODE_HEADSET:
5717 		if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5718 			alc_determine_headset_type(codec);
5719 		if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5720 			alc_headset_mode_ctia(codec);
5721 		else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5722 			alc_headset_mode_omtp(codec);
5723 		spec->gen.hp_jack_present = true;
5724 		break;
5725 	case ALC_HEADSET_MODE_MIC:
5726 		alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5727 		spec->gen.hp_jack_present = false;
5728 		break;
5729 	case ALC_HEADSET_MODE_HEADPHONE:
5730 		alc_headset_mode_default(codec);
5731 		spec->gen.hp_jack_present = true;
5732 		break;
5733 	}
5734 	if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5735 		snd_hda_set_pin_ctl_cache(codec, hp_pin,
5736 					  AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5737 		if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5738 			snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5739 						  PIN_VREFHIZ);
5740 	}
5741 	spec->current_headset_mode = new_headset_mode;
5742 
5743 	snd_hda_gen_update_outputs(codec);
5744 }
5745 
alc_update_headset_mode_hook(struct hda_codec * codec,struct snd_kcontrol * kcontrol,struct snd_ctl_elem_value * ucontrol)5746 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5747 					 struct snd_kcontrol *kcontrol,
5748 					 struct snd_ctl_elem_value *ucontrol)
5749 {
5750 	alc_update_headset_mode(codec);
5751 }
5752 
alc_update_headset_jack_cb(struct hda_codec * codec,struct hda_jack_callback * jack)5753 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5754 				       struct hda_jack_callback *jack)
5755 {
5756 	snd_hda_gen_hp_automute(codec, jack);
5757 	alc_update_headset_mode(codec);
5758 }
5759 
alc_probe_headset_mode(struct hda_codec * codec)5760 static void alc_probe_headset_mode(struct hda_codec *codec)
5761 {
5762 	int i;
5763 	struct alc_spec *spec = codec->spec;
5764 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5765 
5766 	/* Find mic pins */
5767 	for (i = 0; i < cfg->num_inputs; i++) {
5768 		if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5769 			spec->headset_mic_pin = cfg->inputs[i].pin;
5770 		if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5771 			spec->headphone_mic_pin = cfg->inputs[i].pin;
5772 	}
5773 
5774 	WARN_ON(spec->gen.cap_sync_hook);
5775 	spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5776 	spec->gen.automute_hook = alc_update_headset_mode;
5777 	spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5778 }
5779 
alc_fixup_headset_mode(struct hda_codec * codec,const struct hda_fixup * fix,int action)5780 static void alc_fixup_headset_mode(struct hda_codec *codec,
5781 				const struct hda_fixup *fix, int action)
5782 {
5783 	struct alc_spec *spec = codec->spec;
5784 
5785 	switch (action) {
5786 	case HDA_FIXUP_ACT_PRE_PROBE:
5787 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5788 		break;
5789 	case HDA_FIXUP_ACT_PROBE:
5790 		alc_probe_headset_mode(codec);
5791 		break;
5792 	case HDA_FIXUP_ACT_INIT:
5793 		if (is_s3_resume(codec) || is_s4_resume(codec)) {
5794 			spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5795 			spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5796 		}
5797 		alc_update_headset_mode(codec);
5798 		break;
5799 	}
5800 }
5801 
alc_fixup_headset_mode_no_hp_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)5802 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5803 				const struct hda_fixup *fix, int action)
5804 {
5805 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5806 		struct alc_spec *spec = codec->spec;
5807 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5808 	}
5809 	else
5810 		alc_fixup_headset_mode(codec, fix, action);
5811 }
5812 
alc255_set_default_jack_type(struct hda_codec * codec)5813 static void alc255_set_default_jack_type(struct hda_codec *codec)
5814 {
5815 	/* Set to iphone type */
5816 	static const struct coef_fw alc255fw[] = {
5817 		WRITE_COEF(0x1b, 0x880b),
5818 		WRITE_COEF(0x45, 0xd089),
5819 		WRITE_COEF(0x1b, 0x080b),
5820 		WRITE_COEF(0x46, 0x0004),
5821 		WRITE_COEF(0x1b, 0x0c0b),
5822 		{}
5823 	};
5824 	static const struct coef_fw alc256fw[] = {
5825 		WRITE_COEF(0x1b, 0x884b),
5826 		WRITE_COEF(0x45, 0xd089),
5827 		WRITE_COEF(0x1b, 0x084b),
5828 		WRITE_COEF(0x46, 0x0004),
5829 		WRITE_COEF(0x1b, 0x0c4b),
5830 		{}
5831 	};
5832 	switch (codec->core.vendor_id) {
5833 	case 0x10ec0255:
5834 		alc_process_coef_fw(codec, alc255fw);
5835 		break;
5836 	case 0x10ec0230:
5837 	case 0x10ec0236:
5838 	case 0x10ec0256:
5839 	case 0x19e58326:
5840 		alc_process_coef_fw(codec, alc256fw);
5841 		break;
5842 	}
5843 	msleep(30);
5844 }
5845 
alc_fixup_headset_mode_alc255(struct hda_codec * codec,const struct hda_fixup * fix,int action)5846 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5847 				const struct hda_fixup *fix, int action)
5848 {
5849 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5850 		alc255_set_default_jack_type(codec);
5851 	}
5852 	alc_fixup_headset_mode(codec, fix, action);
5853 }
5854 
alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)5855 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5856 				const struct hda_fixup *fix, int action)
5857 {
5858 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5859 		struct alc_spec *spec = codec->spec;
5860 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5861 		alc255_set_default_jack_type(codec);
5862 	}
5863 	else
5864 		alc_fixup_headset_mode(codec, fix, action);
5865 }
5866 
alc288_update_headset_jack_cb(struct hda_codec * codec,struct hda_jack_callback * jack)5867 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5868 				       struct hda_jack_callback *jack)
5869 {
5870 	struct alc_spec *spec = codec->spec;
5871 
5872 	alc_update_headset_jack_cb(codec, jack);
5873 	/* Headset Mic enable or disable, only for Dell Dino */
5874 	alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5875 }
5876 
alc_fixup_headset_mode_dell_alc288(struct hda_codec * codec,const struct hda_fixup * fix,int action)5877 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5878 				const struct hda_fixup *fix, int action)
5879 {
5880 	alc_fixup_headset_mode(codec, fix, action);
5881 	if (action == HDA_FIXUP_ACT_PROBE) {
5882 		struct alc_spec *spec = codec->spec;
5883 		/* toggled via hp_automute_hook */
5884 		spec->gpio_mask |= 0x40;
5885 		spec->gpio_dir |= 0x40;
5886 		spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5887 	}
5888 }
5889 
alc_fixup_auto_mute_via_amp(struct hda_codec * codec,const struct hda_fixup * fix,int action)5890 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5891 					const struct hda_fixup *fix, int action)
5892 {
5893 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5894 		struct alc_spec *spec = codec->spec;
5895 		spec->gen.auto_mute_via_amp = 1;
5896 	}
5897 }
5898 
alc_fixup_no_shutup(struct hda_codec * codec,const struct hda_fixup * fix,int action)5899 static void alc_fixup_no_shutup(struct hda_codec *codec,
5900 				const struct hda_fixup *fix, int action)
5901 {
5902 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5903 		struct alc_spec *spec = codec->spec;
5904 		spec->no_shutup_pins = 1;
5905 	}
5906 }
5907 
alc_fixup_disable_aamix(struct hda_codec * codec,const struct hda_fixup * fix,int action)5908 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5909 				    const struct hda_fixup *fix, int action)
5910 {
5911 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5912 		struct alc_spec *spec = codec->spec;
5913 		/* Disable AA-loopback as it causes white noise */
5914 		spec->gen.mixer_nid = 0;
5915 	}
5916 }
5917 
5918 /* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
alc_fixup_tpt440_dock(struct hda_codec * codec,const struct hda_fixup * fix,int action)5919 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5920 				  const struct hda_fixup *fix, int action)
5921 {
5922 	static const struct hda_pintbl pincfgs[] = {
5923 		{ 0x16, 0x21211010 }, /* dock headphone */
5924 		{ 0x19, 0x21a11010 }, /* dock mic */
5925 		{ }
5926 	};
5927 	struct alc_spec *spec = codec->spec;
5928 
5929 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5930 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5931 		codec->power_save_node = 0; /* avoid click noises */
5932 		snd_hda_apply_pincfgs(codec, pincfgs);
5933 	}
5934 }
5935 
alc_fixup_tpt470_dock(struct hda_codec * codec,const struct hda_fixup * fix,int action)5936 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5937 				  const struct hda_fixup *fix, int action)
5938 {
5939 	static const struct hda_pintbl pincfgs[] = {
5940 		{ 0x17, 0x21211010 }, /* dock headphone */
5941 		{ 0x19, 0x21a11010 }, /* dock mic */
5942 		{ }
5943 	};
5944 	struct alc_spec *spec = codec->spec;
5945 
5946 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5947 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5948 		snd_hda_apply_pincfgs(codec, pincfgs);
5949 	} else if (action == HDA_FIXUP_ACT_INIT) {
5950 		/* Enable DOCK device */
5951 		snd_hda_codec_write(codec, 0x17, 0,
5952 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5953 		/* Enable DOCK device */
5954 		snd_hda_codec_write(codec, 0x19, 0,
5955 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5956 	}
5957 }
5958 
alc_fixup_tpt470_dacs(struct hda_codec * codec,const struct hda_fixup * fix,int action)5959 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
5960 				  const struct hda_fixup *fix, int action)
5961 {
5962 	/* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5963 	 * the speaker output becomes too low by some reason on Thinkpads with
5964 	 * ALC298 codec
5965 	 */
5966 	static const hda_nid_t preferred_pairs[] = {
5967 		0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5968 		0
5969 	};
5970 	struct alc_spec *spec = codec->spec;
5971 
5972 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
5973 		spec->gen.preferred_dacs = preferred_pairs;
5974 }
5975 
alc295_fixup_asus_dacs(struct hda_codec * codec,const struct hda_fixup * fix,int action)5976 static void alc295_fixup_asus_dacs(struct hda_codec *codec,
5977 				   const struct hda_fixup *fix, int action)
5978 {
5979 	static const hda_nid_t preferred_pairs[] = {
5980 		0x17, 0x02, 0x21, 0x03, 0
5981 	};
5982 	struct alc_spec *spec = codec->spec;
5983 
5984 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
5985 		spec->gen.preferred_dacs = preferred_pairs;
5986 }
5987 
alc_shutup_dell_xps13(struct hda_codec * codec)5988 static void alc_shutup_dell_xps13(struct hda_codec *codec)
5989 {
5990 	struct alc_spec *spec = codec->spec;
5991 	int hp_pin = alc_get_hp_pin(spec);
5992 
5993 	/* Prevent pop noises when headphones are plugged in */
5994 	snd_hda_codec_write(codec, hp_pin, 0,
5995 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5996 	msleep(20);
5997 }
5998 
alc_fixup_dell_xps13(struct hda_codec * codec,const struct hda_fixup * fix,int action)5999 static void alc_fixup_dell_xps13(struct hda_codec *codec,
6000 				const struct hda_fixup *fix, int action)
6001 {
6002 	struct alc_spec *spec = codec->spec;
6003 	struct hda_input_mux *imux = &spec->gen.input_mux;
6004 	int i;
6005 
6006 	switch (action) {
6007 	case HDA_FIXUP_ACT_PRE_PROBE:
6008 		/* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
6009 		 * it causes a click noise at start up
6010 		 */
6011 		snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6012 		spec->shutup = alc_shutup_dell_xps13;
6013 		break;
6014 	case HDA_FIXUP_ACT_PROBE:
6015 		/* Make the internal mic the default input source. */
6016 		for (i = 0; i < imux->num_items; i++) {
6017 			if (spec->gen.imux_pins[i] == 0x12) {
6018 				spec->gen.cur_mux[0] = i;
6019 				break;
6020 			}
6021 		}
6022 		break;
6023 	}
6024 }
6025 
alc_fixup_headset_mode_alc662(struct hda_codec * codec,const struct hda_fixup * fix,int action)6026 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
6027 				const struct hda_fixup *fix, int action)
6028 {
6029 	struct alc_spec *spec = codec->spec;
6030 
6031 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6032 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
6033 		spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
6034 
6035 		/* Disable boost for mic-in permanently. (This code is only called
6036 		   from quirks that guarantee that the headphone is at NID 0x1b.) */
6037 		snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
6038 		snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
6039 	} else
6040 		alc_fixup_headset_mode(codec, fix, action);
6041 }
6042 
alc_fixup_headset_mode_alc668(struct hda_codec * codec,const struct hda_fixup * fix,int action)6043 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
6044 				const struct hda_fixup *fix, int action)
6045 {
6046 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6047 		alc_write_coef_idx(codec, 0xc4, 0x8000);
6048 		alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
6049 		snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
6050 	}
6051 	alc_fixup_headset_mode(codec, fix, action);
6052 }
6053 
6054 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
find_ext_mic_pin(struct hda_codec * codec)6055 static int find_ext_mic_pin(struct hda_codec *codec)
6056 {
6057 	struct alc_spec *spec = codec->spec;
6058 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6059 	hda_nid_t nid;
6060 	unsigned int defcfg;
6061 	int i;
6062 
6063 	for (i = 0; i < cfg->num_inputs; i++) {
6064 		if (cfg->inputs[i].type != AUTO_PIN_MIC)
6065 			continue;
6066 		nid = cfg->inputs[i].pin;
6067 		defcfg = snd_hda_codec_get_pincfg(codec, nid);
6068 		if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
6069 			continue;
6070 		return nid;
6071 	}
6072 
6073 	return 0;
6074 }
6075 
alc271_hp_gate_mic_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)6076 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
6077 				    const struct hda_fixup *fix,
6078 				    int action)
6079 {
6080 	struct alc_spec *spec = codec->spec;
6081 
6082 	if (action == HDA_FIXUP_ACT_PROBE) {
6083 		int mic_pin = find_ext_mic_pin(codec);
6084 		int hp_pin = alc_get_hp_pin(spec);
6085 
6086 		if (snd_BUG_ON(!mic_pin || !hp_pin))
6087 			return;
6088 		snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
6089 	}
6090 }
6091 
alc269_fixup_limit_int_mic_boost(struct hda_codec * codec,const struct hda_fixup * fix,int action)6092 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
6093 					     const struct hda_fixup *fix,
6094 					     int action)
6095 {
6096 	struct alc_spec *spec = codec->spec;
6097 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6098 	int i;
6099 
6100 	/* The mic boosts on level 2 and 3 are too noisy
6101 	   on the internal mic input.
6102 	   Therefore limit the boost to 0 or 1. */
6103 
6104 	if (action != HDA_FIXUP_ACT_PROBE)
6105 		return;
6106 
6107 	for (i = 0; i < cfg->num_inputs; i++) {
6108 		hda_nid_t nid = cfg->inputs[i].pin;
6109 		unsigned int defcfg;
6110 		if (cfg->inputs[i].type != AUTO_PIN_MIC)
6111 			continue;
6112 		defcfg = snd_hda_codec_get_pincfg(codec, nid);
6113 		if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
6114 			continue;
6115 
6116 		snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
6117 					  (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
6118 					  (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6119 					  (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
6120 					  (0 << AC_AMPCAP_MUTE_SHIFT));
6121 	}
6122 }
6123 
alc283_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)6124 static void alc283_hp_automute_hook(struct hda_codec *codec,
6125 				    struct hda_jack_callback *jack)
6126 {
6127 	struct alc_spec *spec = codec->spec;
6128 	int vref;
6129 
6130 	msleep(200);
6131 	snd_hda_gen_hp_automute(codec, jack);
6132 
6133 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
6134 
6135 	msleep(600);
6136 	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6137 			    vref);
6138 }
6139 
alc283_fixup_chromebook(struct hda_codec * codec,const struct hda_fixup * fix,int action)6140 static void alc283_fixup_chromebook(struct hda_codec *codec,
6141 				    const struct hda_fixup *fix, int action)
6142 {
6143 	struct alc_spec *spec = codec->spec;
6144 
6145 	switch (action) {
6146 	case HDA_FIXUP_ACT_PRE_PROBE:
6147 		snd_hda_override_wcaps(codec, 0x03, 0);
6148 		/* Disable AA-loopback as it causes white noise */
6149 		spec->gen.mixer_nid = 0;
6150 		break;
6151 	case HDA_FIXUP_ACT_INIT:
6152 		/* MIC2-VREF control */
6153 		/* Set to manual mode */
6154 		alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6155 		/* Enable Line1 input control by verb */
6156 		alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
6157 		break;
6158 	}
6159 }
6160 
alc283_fixup_sense_combo_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)6161 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
6162 				    const struct hda_fixup *fix, int action)
6163 {
6164 	struct alc_spec *spec = codec->spec;
6165 
6166 	switch (action) {
6167 	case HDA_FIXUP_ACT_PRE_PROBE:
6168 		spec->gen.hp_automute_hook = alc283_hp_automute_hook;
6169 		break;
6170 	case HDA_FIXUP_ACT_INIT:
6171 		/* MIC2-VREF control */
6172 		/* Set to manual mode */
6173 		alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6174 		break;
6175 	}
6176 }
6177 
6178 /* mute tablet speaker pin (0x14) via dock plugging in addition */
asus_tx300_automute(struct hda_codec * codec)6179 static void asus_tx300_automute(struct hda_codec *codec)
6180 {
6181 	struct alc_spec *spec = codec->spec;
6182 	snd_hda_gen_update_outputs(codec);
6183 	if (snd_hda_jack_detect(codec, 0x1b))
6184 		spec->gen.mute_bits |= (1ULL << 0x14);
6185 }
6186 
alc282_fixup_asus_tx300(struct hda_codec * codec,const struct hda_fixup * fix,int action)6187 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
6188 				    const struct hda_fixup *fix, int action)
6189 {
6190 	struct alc_spec *spec = codec->spec;
6191 	static const struct hda_pintbl dock_pins[] = {
6192 		{ 0x1b, 0x21114000 }, /* dock speaker pin */
6193 		{}
6194 	};
6195 
6196 	switch (action) {
6197 	case HDA_FIXUP_ACT_PRE_PROBE:
6198 		spec->init_amp = ALC_INIT_DEFAULT;
6199 		/* TX300 needs to set up GPIO2 for the speaker amp */
6200 		alc_setup_gpio(codec, 0x04);
6201 		snd_hda_apply_pincfgs(codec, dock_pins);
6202 		spec->gen.auto_mute_via_amp = 1;
6203 		spec->gen.automute_hook = asus_tx300_automute;
6204 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
6205 						    snd_hda_gen_hp_automute);
6206 		break;
6207 	case HDA_FIXUP_ACT_PROBE:
6208 		spec->init_amp = ALC_INIT_DEFAULT;
6209 		break;
6210 	case HDA_FIXUP_ACT_BUILD:
6211 		/* this is a bit tricky; give more sane names for the main
6212 		 * (tablet) speaker and the dock speaker, respectively
6213 		 */
6214 		rename_ctl(codec, "Speaker Playback Switch",
6215 			   "Dock Speaker Playback Switch");
6216 		rename_ctl(codec, "Bass Speaker Playback Switch",
6217 			   "Speaker Playback Switch");
6218 		break;
6219 	}
6220 }
6221 
alc290_fixup_mono_speakers(struct hda_codec * codec,const struct hda_fixup * fix,int action)6222 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
6223 				       const struct hda_fixup *fix, int action)
6224 {
6225 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6226 		/* DAC node 0x03 is giving mono output. We therefore want to
6227 		   make sure 0x14 (front speaker) and 0x15 (headphones) use the
6228 		   stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
6229 		static const hda_nid_t conn1[] = { 0x0c };
6230 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
6231 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
6232 	}
6233 }
6234 
alc298_fixup_speaker_volume(struct hda_codec * codec,const struct hda_fixup * fix,int action)6235 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
6236 					const struct hda_fixup *fix, int action)
6237 {
6238 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6239 		/* The speaker is routed to the Node 0x06 by a mistake, as a result
6240 		   we can't adjust the speaker's volume since this node does not has
6241 		   Amp-out capability. we change the speaker's route to:
6242 		   Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
6243 		   Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
6244 		   speaker's volume now. */
6245 
6246 		static const hda_nid_t conn1[] = { 0x0c };
6247 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
6248 	}
6249 }
6250 
6251 /* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
alc295_fixup_disable_dac3(struct hda_codec * codec,const struct hda_fixup * fix,int action)6252 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
6253 				      const struct hda_fixup *fix, int action)
6254 {
6255 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6256 		static const hda_nid_t conn[] = { 0x02, 0x03 };
6257 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6258 	}
6259 }
6260 
6261 /* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
alc285_fixup_speaker2_to_dac1(struct hda_codec * codec,const struct hda_fixup * fix,int action)6262 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6263 					  const struct hda_fixup *fix, int action)
6264 {
6265 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6266 		static const hda_nid_t conn[] = { 0x02 };
6267 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6268 	}
6269 }
6270 
6271 /* Hook to update amp GPIO4 for automute */
alc280_hp_gpio4_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)6272 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6273 					  struct hda_jack_callback *jack)
6274 {
6275 	struct alc_spec *spec = codec->spec;
6276 
6277 	snd_hda_gen_hp_automute(codec, jack);
6278 	/* mute_led_polarity is set to 0, so we pass inverted value here */
6279 	alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6280 			    !spec->gen.hp_jack_present);
6281 }
6282 
6283 /* Manage GPIOs for HP EliteBook Folio 9480m.
6284  *
6285  * GPIO4 is the headphone amplifier power control
6286  * GPIO3 is the audio output mute indicator LED
6287  */
6288 
alc280_fixup_hp_9480m(struct hda_codec * codec,const struct hda_fixup * fix,int action)6289 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6290 				  const struct hda_fixup *fix,
6291 				  int action)
6292 {
6293 	struct alc_spec *spec = codec->spec;
6294 
6295 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6296 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6297 		/* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
6298 		spec->gpio_mask |= 0x10;
6299 		spec->gpio_dir |= 0x10;
6300 		spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
6301 	}
6302 }
6303 
alc275_fixup_gpio4_off(struct hda_codec * codec,const struct hda_fixup * fix,int action)6304 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6305 				   const struct hda_fixup *fix,
6306 				   int action)
6307 {
6308 	struct alc_spec *spec = codec->spec;
6309 
6310 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6311 		spec->gpio_mask |= 0x04;
6312 		spec->gpio_dir |= 0x04;
6313 		/* set data bit low */
6314 	}
6315 }
6316 
6317 /* Quirk for Thinkpad X1 7th and 8th Gen
6318  * The following fixed routing needed
6319  * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
6320  * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
6321  * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
6322  */
alc285_fixup_thinkpad_x1_gen7(struct hda_codec * codec,const struct hda_fixup * fix,int action)6323 static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6324 					  const struct hda_fixup *fix, int action)
6325 {
6326 	static const hda_nid_t conn[] = { 0x02, 0x03 }; /* exclude 0x06 */
6327 	static const hda_nid_t preferred_pairs[] = {
6328 		0x14, 0x02, 0x17, 0x03, 0x21, 0x03, 0
6329 	};
6330 	struct alc_spec *spec = codec->spec;
6331 
6332 	switch (action) {
6333 	case HDA_FIXUP_ACT_PRE_PROBE:
6334 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6335 		spec->gen.preferred_dacs = preferred_pairs;
6336 		break;
6337 	case HDA_FIXUP_ACT_BUILD:
6338 		/* The generic parser creates somewhat unintuitive volume ctls
6339 		 * with the fixed routing above, and the shared DAC2 may be
6340 		 * confusing for PA.
6341 		 * Rename those to unique names so that PA doesn't touch them
6342 		 * and use only Master volume.
6343 		 */
6344 		rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6345 		rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6346 		break;
6347 	}
6348 }
6349 
alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec * codec,const struct hda_fixup * fix,int action)6350 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6351 					 const struct hda_fixup *fix,
6352 					 int action)
6353 {
6354 	alc_fixup_dual_codecs(codec, fix, action);
6355 	switch (action) {
6356 	case HDA_FIXUP_ACT_PRE_PROBE:
6357 		/* override card longname to provide a unique UCM profile */
6358 		strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6359 		break;
6360 	case HDA_FIXUP_ACT_BUILD:
6361 		/* rename Capture controls depending on the codec */
6362 		rename_ctl(codec, "Capture Volume",
6363 			   codec->addr == 0 ?
6364 			   "Rear-Panel Capture Volume" :
6365 			   "Front-Panel Capture Volume");
6366 		rename_ctl(codec, "Capture Switch",
6367 			   codec->addr == 0 ?
6368 			   "Rear-Panel Capture Switch" :
6369 			   "Front-Panel Capture Switch");
6370 		break;
6371 	}
6372 }
6373 
alc225_fixup_s3_pop_noise(struct hda_codec * codec,const struct hda_fixup * fix,int action)6374 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6375 				      const struct hda_fixup *fix, int action)
6376 {
6377 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
6378 		return;
6379 
6380 	codec->power_save_node = 1;
6381 }
6382 
6383 /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
alc274_fixup_bind_dacs(struct hda_codec * codec,const struct hda_fixup * fix,int action)6384 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6385 				    const struct hda_fixup *fix, int action)
6386 {
6387 	struct alc_spec *spec = codec->spec;
6388 	static const hda_nid_t preferred_pairs[] = {
6389 		0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
6390 		0
6391 	};
6392 
6393 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
6394 		return;
6395 
6396 	spec->gen.preferred_dacs = preferred_pairs;
6397 	spec->gen.auto_mute_via_amp = 1;
6398 	codec->power_save_node = 0;
6399 }
6400 
6401 /* avoid DAC 0x06 for bass speaker 0x17; it has no volume control */
alc289_fixup_asus_ga401(struct hda_codec * codec,const struct hda_fixup * fix,int action)6402 static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6403 				    const struct hda_fixup *fix, int action)
6404 {
6405 	static const hda_nid_t preferred_pairs[] = {
6406 		0x14, 0x02, 0x17, 0x02, 0x21, 0x03, 0
6407 	};
6408 	struct alc_spec *spec = codec->spec;
6409 
6410 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6411 		spec->gen.preferred_dacs = preferred_pairs;
6412 		spec->gen.obey_preferred_dacs = 1;
6413 	}
6414 }
6415 
6416 /* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
alc285_fixup_invalidate_dacs(struct hda_codec * codec,const struct hda_fixup * fix,int action)6417 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6418 			      const struct hda_fixup *fix, int action)
6419 {
6420 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
6421 		return;
6422 
6423 	snd_hda_override_wcaps(codec, 0x03, 0);
6424 }
6425 
alc_combo_jack_hp_jd_restart(struct hda_codec * codec)6426 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6427 {
6428 	switch (codec->core.vendor_id) {
6429 	case 0x10ec0274:
6430 	case 0x10ec0294:
6431 	case 0x10ec0225:
6432 	case 0x10ec0295:
6433 	case 0x10ec0299:
6434 		alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6435 		alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6436 		break;
6437 	case 0x10ec0230:
6438 	case 0x10ec0235:
6439 	case 0x10ec0236:
6440 	case 0x10ec0255:
6441 	case 0x10ec0256:
6442 	case 0x19e58326:
6443 		alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6444 		alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6445 		break;
6446 	}
6447 }
6448 
alc295_fixup_chromebook(struct hda_codec * codec,const struct hda_fixup * fix,int action)6449 static void alc295_fixup_chromebook(struct hda_codec *codec,
6450 				    const struct hda_fixup *fix, int action)
6451 {
6452 	struct alc_spec *spec = codec->spec;
6453 
6454 	switch (action) {
6455 	case HDA_FIXUP_ACT_PRE_PROBE:
6456 		spec->ultra_low_power = true;
6457 		break;
6458 	case HDA_FIXUP_ACT_INIT:
6459 		alc_combo_jack_hp_jd_restart(codec);
6460 		break;
6461 	}
6462 }
6463 
alc_fixup_disable_mic_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)6464 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6465 				  const struct hda_fixup *fix, int action)
6466 {
6467 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
6468 		snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6469 }
6470 
6471 
alc294_gx502_toggle_output(struct hda_codec * codec,struct hda_jack_callback * cb)6472 static void alc294_gx502_toggle_output(struct hda_codec *codec,
6473 					struct hda_jack_callback *cb)
6474 {
6475 	/* The Windows driver sets the codec up in a very different way where
6476 	 * it appears to leave 0x10 = 0x8a20 set. For Linux we need to toggle it
6477 	 */
6478 	if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6479 		alc_write_coef_idx(codec, 0x10, 0x8a20);
6480 	else
6481 		alc_write_coef_idx(codec, 0x10, 0x0a20);
6482 }
6483 
alc294_fixup_gx502_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)6484 static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6485 					const struct hda_fixup *fix, int action)
6486 {
6487 	/* Pin 0x21: headphones/headset mic */
6488 	if (!is_jack_detectable(codec, 0x21))
6489 		return;
6490 
6491 	switch (action) {
6492 	case HDA_FIXUP_ACT_PRE_PROBE:
6493 		snd_hda_jack_detect_enable_callback(codec, 0x21,
6494 				alc294_gx502_toggle_output);
6495 		break;
6496 	case HDA_FIXUP_ACT_INIT:
6497 		/* Make sure to start in a correct state, i.e. if
6498 		 * headphones have been plugged in before powering up the system
6499 		 */
6500 		alc294_gx502_toggle_output(codec, NULL);
6501 		break;
6502 	}
6503 }
6504 
alc294_gu502_toggle_output(struct hda_codec * codec,struct hda_jack_callback * cb)6505 static void alc294_gu502_toggle_output(struct hda_codec *codec,
6506 				       struct hda_jack_callback *cb)
6507 {
6508 	/* Windows sets 0x10 to 0x8420 for Node 0x20 which is
6509 	 * responsible from changes between speakers and headphones
6510 	 */
6511 	if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6512 		alc_write_coef_idx(codec, 0x10, 0x8420);
6513 	else
6514 		alc_write_coef_idx(codec, 0x10, 0x0a20);
6515 }
6516 
alc294_fixup_gu502_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)6517 static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6518 				  const struct hda_fixup *fix, int action)
6519 {
6520 	if (!is_jack_detectable(codec, 0x21))
6521 		return;
6522 
6523 	switch (action) {
6524 	case HDA_FIXUP_ACT_PRE_PROBE:
6525 		snd_hda_jack_detect_enable_callback(codec, 0x21,
6526 				alc294_gu502_toggle_output);
6527 		break;
6528 	case HDA_FIXUP_ACT_INIT:
6529 		alc294_gu502_toggle_output(codec, NULL);
6530 		break;
6531 	}
6532 }
6533 
alc285_fixup_hp_gpio_amp_init(struct hda_codec * codec,const struct hda_fixup * fix,int action)6534 static void  alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6535 			      const struct hda_fixup *fix, int action)
6536 {
6537 	if (action != HDA_FIXUP_ACT_INIT)
6538 		return;
6539 
6540 	msleep(100);
6541 	alc_write_coef_idx(codec, 0x65, 0x0);
6542 }
6543 
alc274_fixup_hp_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)6544 static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6545 				    const struct hda_fixup *fix, int action)
6546 {
6547 	switch (action) {
6548 	case HDA_FIXUP_ACT_INIT:
6549 		alc_combo_jack_hp_jd_restart(codec);
6550 		break;
6551 	}
6552 }
6553 
alc_fixup_no_int_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)6554 static void alc_fixup_no_int_mic(struct hda_codec *codec,
6555 				    const struct hda_fixup *fix, int action)
6556 {
6557 	struct alc_spec *spec = codec->spec;
6558 
6559 	switch (action) {
6560 	case HDA_FIXUP_ACT_PRE_PROBE:
6561 		/* Mic RING SLEEVE swap for combo jack */
6562 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
6563 		spec->no_internal_mic_pin = true;
6564 		break;
6565 	case HDA_FIXUP_ACT_INIT:
6566 		alc_combo_jack_hp_jd_restart(codec);
6567 		break;
6568 	}
6569 }
6570 
6571 /* GPIO1 = amplifier on/off
6572  * GPIO3 = mic mute LED
6573  */
alc285_fixup_hp_spectre_x360_eb1(struct hda_codec * codec,const struct hda_fixup * fix,int action)6574 static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
6575 					  const struct hda_fixup *fix, int action)
6576 {
6577 	static const hda_nid_t conn[] = { 0x02 };
6578 
6579 	struct alc_spec *spec = codec->spec;
6580 	static const struct hda_pintbl pincfgs[] = {
6581 		{ 0x14, 0x90170110 },  /* front/high speakers */
6582 		{ 0x17, 0x90170130 },  /* back/bass speakers */
6583 		{ }
6584 	};
6585 
6586 	//enable micmute led
6587 	alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
6588 
6589 	switch (action) {
6590 	case HDA_FIXUP_ACT_PRE_PROBE:
6591 		spec->micmute_led_polarity = 1;
6592 		/* needed for amp of back speakers */
6593 		spec->gpio_mask |= 0x01;
6594 		spec->gpio_dir |= 0x01;
6595 		snd_hda_apply_pincfgs(codec, pincfgs);
6596 		/* share DAC to have unified volume control */
6597 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
6598 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6599 		break;
6600 	case HDA_FIXUP_ACT_INIT:
6601 		/* need to toggle GPIO to enable the amp of back speakers */
6602 		alc_update_gpio_data(codec, 0x01, true);
6603 		msleep(100);
6604 		alc_update_gpio_data(codec, 0x01, false);
6605 		break;
6606 	}
6607 }
6608 
alc285_fixup_hp_spectre_x360(struct hda_codec * codec,const struct hda_fixup * fix,int action)6609 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6610 					  const struct hda_fixup *fix, int action)
6611 {
6612 	static const hda_nid_t conn[] = { 0x02 };
6613 	static const struct hda_pintbl pincfgs[] = {
6614 		{ 0x14, 0x90170110 },  /* rear speaker */
6615 		{ }
6616 	};
6617 
6618 	switch (action) {
6619 	case HDA_FIXUP_ACT_PRE_PROBE:
6620 		snd_hda_apply_pincfgs(codec, pincfgs);
6621 		/* force front speaker to DAC1 */
6622 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6623 		break;
6624 	}
6625 }
6626 
6627 /* for hda_fixup_thinkpad_acpi() */
6628 #include "thinkpad_helper.c"
6629 
alc_fixup_thinkpad_acpi(struct hda_codec * codec,const struct hda_fixup * fix,int action)6630 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6631 				    const struct hda_fixup *fix, int action)
6632 {
6633 	alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6634 	hda_fixup_thinkpad_acpi(codec, fix, action);
6635 }
6636 
6637 /* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
alc287_fixup_legion_15imhg05_speakers(struct hda_codec * codec,const struct hda_fixup * fix,int action)6638 static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6639 						  const struct hda_fixup *fix,
6640 						  int action)
6641 {
6642 	struct alc_spec *spec = codec->spec;
6643 
6644 	switch (action) {
6645 	case HDA_FIXUP_ACT_PRE_PROBE:
6646 		spec->gen.suppress_auto_mute = 1;
6647 		break;
6648 	}
6649 }
6650 
comp_bind(struct device * dev)6651 static int comp_bind(struct device *dev)
6652 {
6653 	struct hda_codec *cdc = dev_to_hda_codec(dev);
6654 	struct alc_spec *spec = cdc->spec;
6655 
6656 	return component_bind_all(dev, spec->comps);
6657 }
6658 
comp_unbind(struct device * dev)6659 static void comp_unbind(struct device *dev)
6660 {
6661 	struct hda_codec *cdc = dev_to_hda_codec(dev);
6662 	struct alc_spec *spec = cdc->spec;
6663 
6664 	component_unbind_all(dev, spec->comps);
6665 }
6666 
6667 static const struct component_master_ops comp_master_ops = {
6668 	.bind = comp_bind,
6669 	.unbind = comp_unbind,
6670 };
6671 
comp_generic_playback_hook(struct hda_pcm_stream * hinfo,struct hda_codec * cdc,struct snd_pcm_substream * sub,int action)6672 static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_codec *cdc,
6673 				       struct snd_pcm_substream *sub, int action)
6674 {
6675 	struct alc_spec *spec = cdc->spec;
6676 	int i;
6677 
6678 	for (i = 0; i < HDA_MAX_COMPONENTS; i++) {
6679 		if (spec->comps[i].dev)
6680 			spec->comps[i].playback_hook(spec->comps[i].dev, action);
6681 	}
6682 }
6683 
cs35l41_generic_fixup(struct hda_codec * cdc,int action,const char * bus,const char * hid,int count)6684 static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char *bus,
6685 				  const char *hid, int count)
6686 {
6687 	struct device *dev = hda_codec_dev(cdc);
6688 	struct alc_spec *spec = cdc->spec;
6689 	char *name;
6690 	int ret, i;
6691 
6692 	switch (action) {
6693 	case HDA_FIXUP_ACT_PRE_PROBE:
6694 		for (i = 0; i < count; i++) {
6695 			name = devm_kasprintf(dev, GFP_KERNEL,
6696 					      "%s-%s:00-cs35l41-hda.%d", bus, hid, i);
6697 			if (!name)
6698 				return;
6699 			component_match_add(dev, &spec->match, component_compare_dev_name, name);
6700 		}
6701 		ret = component_master_add_with_match(dev, &comp_master_ops, spec->match);
6702 		if (ret)
6703 			codec_err(cdc, "Fail to register component aggregator %d\n", ret);
6704 		else
6705 			spec->gen.pcm_playback_hook = comp_generic_playback_hook;
6706 		break;
6707 	}
6708 }
6709 
cs35l41_fixup_i2c_two(struct hda_codec * cdc,const struct hda_fixup * fix,int action)6710 static void cs35l41_fixup_i2c_two(struct hda_codec *cdc, const struct hda_fixup *fix, int action)
6711 {
6712 	cs35l41_generic_fixup(cdc, action, "i2c", "CSC3551", 2);
6713 }
6714 
cs35l41_fixup_spi_two(struct hda_codec * codec,const struct hda_fixup * fix,int action)6715 static void cs35l41_fixup_spi_two(struct hda_codec *codec, const struct hda_fixup *fix, int action)
6716 {
6717 	cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 2);
6718 }
6719 
cs35l41_fixup_spi_four(struct hda_codec * codec,const struct hda_fixup * fix,int action)6720 static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action)
6721 {
6722 	cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 4);
6723 }
6724 
alc287_fixup_legion_16achg6_speakers(struct hda_codec * cdc,const struct hda_fixup * fix,int action)6725 static void alc287_fixup_legion_16achg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix,
6726 						 int action)
6727 {
6728 	cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0100", 2);
6729 }
6730 
6731 /* for alc295_fixup_hp_top_speakers */
6732 #include "hp_x360_helper.c"
6733 
6734 /* for alc285_fixup_ideapad_s740_coef() */
6735 #include "ideapad_s740_helper.c"
6736 
6737 static const struct coef_fw alc256_fixup_set_coef_defaults_coefs[] = {
6738 	WRITE_COEF(0x10, 0x0020), WRITE_COEF(0x24, 0x0000),
6739 	WRITE_COEF(0x26, 0x0000), WRITE_COEF(0x29, 0x3000),
6740 	WRITE_COEF(0x37, 0xfe05), WRITE_COEF(0x45, 0x5089),
6741 	{}
6742 };
6743 
alc256_fixup_set_coef_defaults(struct hda_codec * codec,const struct hda_fixup * fix,int action)6744 static void alc256_fixup_set_coef_defaults(struct hda_codec *codec,
6745 					   const struct hda_fixup *fix,
6746 					   int action)
6747 {
6748 	/*
6749 	 * A certain other OS sets these coeffs to different values. On at least
6750 	 * one TongFang barebone these settings might survive even a cold
6751 	 * reboot. So to restore a clean slate the values are explicitly reset
6752 	 * to default here. Without this, the external microphone is always in a
6753 	 * plugged-in state, while the internal microphone is always in an
6754 	 * unplugged state, breaking the ability to use the internal microphone.
6755 	 */
6756 	alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs);
6757 }
6758 
6759 static const struct coef_fw alc233_fixup_no_audio_jack_coefs[] = {
6760 	WRITE_COEF(0x1a, 0x9003), WRITE_COEF(0x1b, 0x0e2b), WRITE_COEF(0x37, 0xfe06),
6761 	WRITE_COEF(0x38, 0x4981), WRITE_COEF(0x45, 0xd489), WRITE_COEF(0x46, 0x0074),
6762 	WRITE_COEF(0x49, 0x0149),
6763 	{}
6764 };
6765 
alc233_fixup_no_audio_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)6766 static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
6767 				       const struct hda_fixup *fix,
6768 				       int action)
6769 {
6770 	/*
6771 	 * The audio jack input and output is not detected on the ASRock NUC Box
6772 	 * 1100 series when cold booting without this fix. Warm rebooting from a
6773 	 * certain other OS makes the audio functional, as COEF settings are
6774 	 * preserved in this case. This fix sets these altered COEF values as
6775 	 * the default.
6776 	 */
6777 	alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
6778 }
6779 
alc256_fixup_mic_no_presence_and_resume(struct hda_codec * codec,const struct hda_fixup * fix,int action)6780 static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
6781 						    const struct hda_fixup *fix,
6782 						    int action)
6783 {
6784 	/*
6785 	 * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
6786 	 * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
6787 	 * needs an additional quirk for sound working after suspend and resume.
6788 	 */
6789 	if (codec->core.vendor_id == 0x10ec0256) {
6790 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
6791 		snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
6792 	} else {
6793 		snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
6794 	}
6795 }
6796 
alc_fixup_dell4_mic_no_presence_quiet(struct hda_codec * codec,const struct hda_fixup * fix,int action)6797 static void alc_fixup_dell4_mic_no_presence_quiet(struct hda_codec *codec,
6798 						  const struct hda_fixup *fix,
6799 						  int action)
6800 {
6801 	struct alc_spec *spec = codec->spec;
6802 	struct hda_input_mux *imux = &spec->gen.input_mux;
6803 	int i;
6804 
6805 	alc269_fixup_limit_int_mic_boost(codec, fix, action);
6806 
6807 	switch (action) {
6808 	case HDA_FIXUP_ACT_PRE_PROBE:
6809 		/**
6810 		 * Set the vref of pin 0x19 (Headset Mic) and pin 0x1b (Headphone Mic)
6811 		 * to Hi-Z to avoid pop noises at startup and when plugging and
6812 		 * unplugging headphones.
6813 		 */
6814 		snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6815 		snd_hda_codec_set_pin_target(codec, 0x1b, PIN_VREFHIZ);
6816 		break;
6817 	case HDA_FIXUP_ACT_PROBE:
6818 		/**
6819 		 * Make the internal mic (0x12) the default input source to
6820 		 * prevent pop noises on cold boot.
6821 		 */
6822 		for (i = 0; i < imux->num_items; i++) {
6823 			if (spec->gen.imux_pins[i] == 0x12) {
6824 				spec->gen.cur_mux[0] = i;
6825 				break;
6826 			}
6827 		}
6828 		break;
6829 	}
6830 }
6831 
alc287_fixup_yoga9_14iap7_bass_spk_pin(struct hda_codec * codec,const struct hda_fixup * fix,int action)6832 static void alc287_fixup_yoga9_14iap7_bass_spk_pin(struct hda_codec *codec,
6833 					  const struct hda_fixup *fix, int action)
6834 {
6835 	/*
6836 	 * The Pin Complex 0x17 for the bass speakers is wrongly reported as
6837 	 * unconnected.
6838 	 */
6839 	static const struct hda_pintbl pincfgs[] = {
6840 		{ 0x17, 0x90170121 },
6841 		{ }
6842 	};
6843 	/*
6844 	 * Avoid DAC 0x06 and 0x08, as they have no volume controls.
6845 	 * DAC 0x02 and 0x03 would be fine.
6846 	 */
6847 	static const hda_nid_t conn[] = { 0x02, 0x03 };
6848 	/*
6849 	 * Prefer both speakerbar (0x14) and bass speakers (0x17) connected to DAC 0x02.
6850 	 * Headphones (0x21) are connected to DAC 0x03.
6851 	 */
6852 	static const hda_nid_t preferred_pairs[] = {
6853 		0x14, 0x02,
6854 		0x17, 0x02,
6855 		0x21, 0x03,
6856 		0
6857 	};
6858 	struct alc_spec *spec = codec->spec;
6859 
6860 	switch (action) {
6861 	case HDA_FIXUP_ACT_PRE_PROBE:
6862 		snd_hda_apply_pincfgs(codec, pincfgs);
6863 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6864 		spec->gen.preferred_dacs = preferred_pairs;
6865 		break;
6866 	}
6867 }
6868 
6869 enum {
6870 	ALC269_FIXUP_GPIO2,
6871 	ALC269_FIXUP_SONY_VAIO,
6872 	ALC275_FIXUP_SONY_VAIO_GPIO2,
6873 	ALC269_FIXUP_DELL_M101Z,
6874 	ALC269_FIXUP_SKU_IGNORE,
6875 	ALC269_FIXUP_ASUS_G73JW,
6876 	ALC269_FIXUP_LENOVO_EAPD,
6877 	ALC275_FIXUP_SONY_HWEQ,
6878 	ALC275_FIXUP_SONY_DISABLE_AAMIX,
6879 	ALC271_FIXUP_DMIC,
6880 	ALC269_FIXUP_PCM_44K,
6881 	ALC269_FIXUP_STEREO_DMIC,
6882 	ALC269_FIXUP_HEADSET_MIC,
6883 	ALC269_FIXUP_QUANTA_MUTE,
6884 	ALC269_FIXUP_LIFEBOOK,
6885 	ALC269_FIXUP_LIFEBOOK_EXTMIC,
6886 	ALC269_FIXUP_LIFEBOOK_HP_PIN,
6887 	ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
6888 	ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
6889 	ALC269_FIXUP_AMIC,
6890 	ALC269_FIXUP_DMIC,
6891 	ALC269VB_FIXUP_AMIC,
6892 	ALC269VB_FIXUP_DMIC,
6893 	ALC269_FIXUP_HP_MUTE_LED,
6894 	ALC269_FIXUP_HP_MUTE_LED_MIC1,
6895 	ALC269_FIXUP_HP_MUTE_LED_MIC2,
6896 	ALC269_FIXUP_HP_MUTE_LED_MIC3,
6897 	ALC269_FIXUP_HP_GPIO_LED,
6898 	ALC269_FIXUP_HP_GPIO_MIC1_LED,
6899 	ALC269_FIXUP_HP_LINE1_MIC1_LED,
6900 	ALC269_FIXUP_INV_DMIC,
6901 	ALC269_FIXUP_LENOVO_DOCK,
6902 	ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
6903 	ALC269_FIXUP_NO_SHUTUP,
6904 	ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
6905 	ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
6906 	ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6907 	ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
6908 	ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6909 	ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6910 	ALC269_FIXUP_DELL4_MIC_NO_PRESENCE_QUIET,
6911 	ALC269_FIXUP_HEADSET_MODE,
6912 	ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
6913 	ALC269_FIXUP_ASPIRE_HEADSET_MIC,
6914 	ALC269_FIXUP_ASUS_X101_FUNC,
6915 	ALC269_FIXUP_ASUS_X101_VERB,
6916 	ALC269_FIXUP_ASUS_X101,
6917 	ALC271_FIXUP_AMIC_MIC2,
6918 	ALC271_FIXUP_HP_GATE_MIC_JACK,
6919 	ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
6920 	ALC269_FIXUP_ACER_AC700,
6921 	ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
6922 	ALC269VB_FIXUP_ASUS_ZENBOOK,
6923 	ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
6924 	ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE,
6925 	ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
6926 	ALC269VB_FIXUP_ORDISSIMO_EVE2,
6927 	ALC283_FIXUP_CHROME_BOOK,
6928 	ALC283_FIXUP_SENSE_COMBO_JACK,
6929 	ALC282_FIXUP_ASUS_TX300,
6930 	ALC283_FIXUP_INT_MIC,
6931 	ALC290_FIXUP_MONO_SPEAKERS,
6932 	ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6933 	ALC290_FIXUP_SUBWOOFER,
6934 	ALC290_FIXUP_SUBWOOFER_HSJACK,
6935 	ALC269_FIXUP_THINKPAD_ACPI,
6936 	ALC269_FIXUP_DMIC_THINKPAD_ACPI,
6937 	ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6938 	ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6939 	ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6940 	ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
6941 	ALC255_FIXUP_HEADSET_MODE,
6942 	ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
6943 	ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
6944 	ALC292_FIXUP_TPT440_DOCK,
6945 	ALC292_FIXUP_TPT440,
6946 	ALC283_FIXUP_HEADSET_MIC,
6947 	ALC255_FIXUP_MIC_MUTE_LED,
6948 	ALC282_FIXUP_ASPIRE_V5_PINS,
6949 	ALC269VB_FIXUP_ASPIRE_E1_COEF,
6950 	ALC280_FIXUP_HP_GPIO4,
6951 	ALC286_FIXUP_HP_GPIO_LED,
6952 	ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
6953 	ALC280_FIXUP_HP_DOCK_PINS,
6954 	ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
6955 	ALC280_FIXUP_HP_9480M,
6956 	ALC245_FIXUP_HP_X360_AMP,
6957 	ALC285_FIXUP_HP_SPECTRE_X360_EB1,
6958 	ALC288_FIXUP_DELL_HEADSET_MODE,
6959 	ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
6960 	ALC288_FIXUP_DELL_XPS_13,
6961 	ALC288_FIXUP_DISABLE_AAMIX,
6962 	ALC292_FIXUP_DELL_E7X_AAMIX,
6963 	ALC292_FIXUP_DELL_E7X,
6964 	ALC292_FIXUP_DISABLE_AAMIX,
6965 	ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
6966 	ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
6967 	ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6968 	ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6969 	ALC275_FIXUP_DELL_XPS,
6970 	ALC293_FIXUP_LENOVO_SPK_NOISE,
6971 	ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
6972 	ALC255_FIXUP_DELL_SPK_NOISE,
6973 	ALC225_FIXUP_DISABLE_MIC_VREF,
6974 	ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6975 	ALC295_FIXUP_DISABLE_DAC3,
6976 	ALC285_FIXUP_SPEAKER2_TO_DAC1,
6977 	ALC280_FIXUP_HP_HEADSET_MIC,
6978 	ALC221_FIXUP_HP_FRONT_MIC,
6979 	ALC292_FIXUP_TPT460,
6980 	ALC298_FIXUP_SPK_VOLUME,
6981 	ALC298_FIXUP_LENOVO_SPK_VOLUME,
6982 	ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
6983 	ALC269_FIXUP_ATIV_BOOK_8,
6984 	ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE,
6985 	ALC221_FIXUP_HP_MIC_NO_PRESENCE,
6986 	ALC256_FIXUP_ASUS_HEADSET_MODE,
6987 	ALC256_FIXUP_ASUS_MIC,
6988 	ALC256_FIXUP_ASUS_AIO_GPIO2,
6989 	ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
6990 	ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
6991 	ALC233_FIXUP_LENOVO_MULTI_CODECS,
6992 	ALC233_FIXUP_ACER_HEADSET_MIC,
6993 	ALC294_FIXUP_LENOVO_MIC_LOCATION,
6994 	ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
6995 	ALC225_FIXUP_S3_POP_NOISE,
6996 	ALC700_FIXUP_INTEL_REFERENCE,
6997 	ALC274_FIXUP_DELL_BIND_DACS,
6998 	ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6999 	ALC298_FIXUP_TPT470_DOCK_FIX,
7000 	ALC298_FIXUP_TPT470_DOCK,
7001 	ALC255_FIXUP_DUMMY_LINEOUT_VERB,
7002 	ALC255_FIXUP_DELL_HEADSET_MIC,
7003 	ALC256_FIXUP_HUAWEI_MACH_WX9_PINS,
7004 	ALC298_FIXUP_HUAWEI_MBX_STEREO,
7005 	ALC295_FIXUP_HP_X360,
7006 	ALC221_FIXUP_HP_HEADSET_MIC,
7007 	ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
7008 	ALC295_FIXUP_HP_AUTO_MUTE,
7009 	ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
7010 	ALC294_FIXUP_ASUS_MIC,
7011 	ALC294_FIXUP_ASUS_HEADSET_MIC,
7012 	ALC294_FIXUP_ASUS_SPK,
7013 	ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
7014 	ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
7015 	ALC255_FIXUP_ACER_HEADSET_MIC,
7016 	ALC295_FIXUP_CHROME_BOOK,
7017 	ALC225_FIXUP_HEADSET_JACK,
7018 	ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
7019 	ALC225_FIXUP_WYSE_AUTO_MUTE,
7020 	ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
7021 	ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
7022 	ALC256_FIXUP_ASUS_HEADSET_MIC,
7023 	ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7024 	ALC299_FIXUP_PREDATOR_SPK,
7025 	ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
7026 	ALC289_FIXUP_DELL_SPK2,
7027 	ALC289_FIXUP_DUAL_SPK,
7028 	ALC294_FIXUP_SPK2_TO_DAC1,
7029 	ALC294_FIXUP_ASUS_DUAL_SPK,
7030 	ALC285_FIXUP_THINKPAD_X1_GEN7,
7031 	ALC285_FIXUP_THINKPAD_HEADSET_JACK,
7032 	ALC294_FIXUP_ASUS_HPE,
7033 	ALC294_FIXUP_ASUS_COEF_1B,
7034 	ALC294_FIXUP_ASUS_GX502_HP,
7035 	ALC294_FIXUP_ASUS_GX502_PINS,
7036 	ALC294_FIXUP_ASUS_GX502_VERBS,
7037 	ALC294_FIXUP_ASUS_GU502_HP,
7038 	ALC294_FIXUP_ASUS_GU502_PINS,
7039 	ALC294_FIXUP_ASUS_GU502_VERBS,
7040 	ALC285_FIXUP_HP_GPIO_LED,
7041 	ALC285_FIXUP_HP_MUTE_LED,
7042 	ALC236_FIXUP_HP_GPIO_LED,
7043 	ALC236_FIXUP_HP_MUTE_LED,
7044 	ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
7045 	ALC298_FIXUP_SAMSUNG_AMP,
7046 	ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
7047 	ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
7048 	ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
7049 	ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
7050 	ALC269VC_FIXUP_ACER_HEADSET_MIC,
7051 	ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE,
7052 	ALC289_FIXUP_ASUS_GA401,
7053 	ALC289_FIXUP_ASUS_GA502,
7054 	ALC256_FIXUP_ACER_MIC_NO_PRESENCE,
7055 	ALC285_FIXUP_HP_GPIO_AMP_INIT,
7056 	ALC269_FIXUP_CZC_B20,
7057 	ALC269_FIXUP_CZC_TMI,
7058 	ALC269_FIXUP_CZC_L101,
7059 	ALC269_FIXUP_LEMOTE_A1802,
7060 	ALC269_FIXUP_LEMOTE_A190X,
7061 	ALC256_FIXUP_INTEL_NUC8_RUGGED,
7062 	ALC233_FIXUP_INTEL_NUC8_DMIC,
7063 	ALC233_FIXUP_INTEL_NUC8_BOOST,
7064 	ALC256_FIXUP_INTEL_NUC10,
7065 	ALC255_FIXUP_XIAOMI_HEADSET_MIC,
7066 	ALC274_FIXUP_HP_MIC,
7067 	ALC274_FIXUP_HP_HEADSET_MIC,
7068 	ALC274_FIXUP_HP_ENVY_GPIO,
7069 	ALC256_FIXUP_ASUS_HPE,
7070 	ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
7071 	ALC287_FIXUP_HP_GPIO_LED,
7072 	ALC256_FIXUP_HP_HEADSET_MIC,
7073 	ALC245_FIXUP_HP_GPIO_LED,
7074 	ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
7075 	ALC282_FIXUP_ACER_DISABLE_LINEOUT,
7076 	ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST,
7077 	ALC256_FIXUP_ACER_HEADSET_MIC,
7078 	ALC285_FIXUP_IDEAPAD_S740_COEF,
7079 	ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST,
7080 	ALC295_FIXUP_ASUS_DACS,
7081 	ALC295_FIXUP_HP_OMEN,
7082 	ALC285_FIXUP_HP_SPECTRE_X360,
7083 	ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP,
7084 	ALC623_FIXUP_LENOVO_THINKSTATION_P340,
7085 	ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
7086 	ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
7087 	ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
7088 	ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
7089 	ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
7090 	ALC298_FIXUP_LENOVO_C940_DUET7,
7091 	ALC287_FIXUP_13S_GEN2_SPEAKERS,
7092 	ALC256_FIXUP_SET_COEF_DEFAULTS,
7093 	ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
7094 	ALC233_FIXUP_NO_AUDIO_JACK,
7095 	ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME,
7096 	ALC285_FIXUP_LEGION_Y9000X_SPEAKERS,
7097 	ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
7098 	ALC287_FIXUP_LEGION_16ACHG6,
7099 	ALC287_FIXUP_CS35L41_I2C_2,
7100 	ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED,
7101 	ALC245_FIXUP_CS35L41_SPI_2,
7102 	ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED,
7103 	ALC245_FIXUP_CS35L41_SPI_4,
7104 	ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED,
7105 	ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED,
7106 	ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE,
7107 	ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK,
7108 	ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN,
7109 };
7110 
7111 /* A special fixup for Lenovo C940 and Yoga Duet 7;
7112  * both have the very same PCI SSID, and we need to apply different fixups
7113  * depending on the codec ID
7114  */
alc298_fixup_lenovo_c940_duet7(struct hda_codec * codec,const struct hda_fixup * fix,int action)7115 static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
7116 					   const struct hda_fixup *fix,
7117 					   int action)
7118 {
7119 	int id;
7120 
7121 	if (codec->core.vendor_id == 0x10ec0298)
7122 		id = ALC298_FIXUP_LENOVO_SPK_VOLUME; /* C940 */
7123 	else
7124 		id = ALC287_FIXUP_YOGA7_14ITL_SPEAKERS; /* Duet 7 */
7125 	__snd_hda_apply_fixup(codec, id, action, 0);
7126 }
7127 
7128 static const struct hda_fixup alc269_fixups[] = {
7129 	[ALC269_FIXUP_GPIO2] = {
7130 		.type = HDA_FIXUP_FUNC,
7131 		.v.func = alc_fixup_gpio2,
7132 	},
7133 	[ALC269_FIXUP_SONY_VAIO] = {
7134 		.type = HDA_FIXUP_PINCTLS,
7135 		.v.pins = (const struct hda_pintbl[]) {
7136 			{0x19, PIN_VREFGRD},
7137 			{}
7138 		}
7139 	},
7140 	[ALC275_FIXUP_SONY_VAIO_GPIO2] = {
7141 		.type = HDA_FIXUP_FUNC,
7142 		.v.func = alc275_fixup_gpio4_off,
7143 		.chained = true,
7144 		.chain_id = ALC269_FIXUP_SONY_VAIO
7145 	},
7146 	[ALC269_FIXUP_DELL_M101Z] = {
7147 		.type = HDA_FIXUP_VERBS,
7148 		.v.verbs = (const struct hda_verb[]) {
7149 			/* Enables internal speaker */
7150 			{0x20, AC_VERB_SET_COEF_INDEX, 13},
7151 			{0x20, AC_VERB_SET_PROC_COEF, 0x4040},
7152 			{}
7153 		}
7154 	},
7155 	[ALC269_FIXUP_SKU_IGNORE] = {
7156 		.type = HDA_FIXUP_FUNC,
7157 		.v.func = alc_fixup_sku_ignore,
7158 	},
7159 	[ALC269_FIXUP_ASUS_G73JW] = {
7160 		.type = HDA_FIXUP_PINS,
7161 		.v.pins = (const struct hda_pintbl[]) {
7162 			{ 0x17, 0x99130111 }, /* subwoofer */
7163 			{ }
7164 		}
7165 	},
7166 	[ALC269_FIXUP_LENOVO_EAPD] = {
7167 		.type = HDA_FIXUP_VERBS,
7168 		.v.verbs = (const struct hda_verb[]) {
7169 			{0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
7170 			{}
7171 		}
7172 	},
7173 	[ALC275_FIXUP_SONY_HWEQ] = {
7174 		.type = HDA_FIXUP_FUNC,
7175 		.v.func = alc269_fixup_hweq,
7176 		.chained = true,
7177 		.chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
7178 	},
7179 	[ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
7180 		.type = HDA_FIXUP_FUNC,
7181 		.v.func = alc_fixup_disable_aamix,
7182 		.chained = true,
7183 		.chain_id = ALC269_FIXUP_SONY_VAIO
7184 	},
7185 	[ALC271_FIXUP_DMIC] = {
7186 		.type = HDA_FIXUP_FUNC,
7187 		.v.func = alc271_fixup_dmic,
7188 	},
7189 	[ALC269_FIXUP_PCM_44K] = {
7190 		.type = HDA_FIXUP_FUNC,
7191 		.v.func = alc269_fixup_pcm_44k,
7192 		.chained = true,
7193 		.chain_id = ALC269_FIXUP_QUANTA_MUTE
7194 	},
7195 	[ALC269_FIXUP_STEREO_DMIC] = {
7196 		.type = HDA_FIXUP_FUNC,
7197 		.v.func = alc269_fixup_stereo_dmic,
7198 	},
7199 	[ALC269_FIXUP_HEADSET_MIC] = {
7200 		.type = HDA_FIXUP_FUNC,
7201 		.v.func = alc269_fixup_headset_mic,
7202 	},
7203 	[ALC269_FIXUP_QUANTA_MUTE] = {
7204 		.type = HDA_FIXUP_FUNC,
7205 		.v.func = alc269_fixup_quanta_mute,
7206 	},
7207 	[ALC269_FIXUP_LIFEBOOK] = {
7208 		.type = HDA_FIXUP_PINS,
7209 		.v.pins = (const struct hda_pintbl[]) {
7210 			{ 0x1a, 0x2101103f }, /* dock line-out */
7211 			{ 0x1b, 0x23a11040 }, /* dock mic-in */
7212 			{ }
7213 		},
7214 		.chained = true,
7215 		.chain_id = ALC269_FIXUP_QUANTA_MUTE
7216 	},
7217 	[ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
7218 		.type = HDA_FIXUP_PINS,
7219 		.v.pins = (const struct hda_pintbl[]) {
7220 			{ 0x19, 0x01a1903c }, /* headset mic, with jack detect */
7221 			{ }
7222 		},
7223 	},
7224 	[ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
7225 		.type = HDA_FIXUP_PINS,
7226 		.v.pins = (const struct hda_pintbl[]) {
7227 			{ 0x21, 0x0221102f }, /* HP out */
7228 			{ }
7229 		},
7230 	},
7231 	[ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
7232 		.type = HDA_FIXUP_FUNC,
7233 		.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
7234 	},
7235 	[ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
7236 		.type = HDA_FIXUP_FUNC,
7237 		.v.func = alc269_fixup_pincfg_U7x7_headset_mic,
7238 	},
7239 	[ALC269_FIXUP_AMIC] = {
7240 		.type = HDA_FIXUP_PINS,
7241 		.v.pins = (const struct hda_pintbl[]) {
7242 			{ 0x14, 0x99130110 }, /* speaker */
7243 			{ 0x15, 0x0121401f }, /* HP out */
7244 			{ 0x18, 0x01a19c20 }, /* mic */
7245 			{ 0x19, 0x99a3092f }, /* int-mic */
7246 			{ }
7247 		},
7248 	},
7249 	[ALC269_FIXUP_DMIC] = {
7250 		.type = HDA_FIXUP_PINS,
7251 		.v.pins = (const struct hda_pintbl[]) {
7252 			{ 0x12, 0x99a3092f }, /* int-mic */
7253 			{ 0x14, 0x99130110 }, /* speaker */
7254 			{ 0x15, 0x0121401f }, /* HP out */
7255 			{ 0x18, 0x01a19c20 }, /* mic */
7256 			{ }
7257 		},
7258 	},
7259 	[ALC269VB_FIXUP_AMIC] = {
7260 		.type = HDA_FIXUP_PINS,
7261 		.v.pins = (const struct hda_pintbl[]) {
7262 			{ 0x14, 0x99130110 }, /* speaker */
7263 			{ 0x18, 0x01a19c20 }, /* mic */
7264 			{ 0x19, 0x99a3092f }, /* int-mic */
7265 			{ 0x21, 0x0121401f }, /* HP out */
7266 			{ }
7267 		},
7268 	},
7269 	[ALC269VB_FIXUP_DMIC] = {
7270 		.type = HDA_FIXUP_PINS,
7271 		.v.pins = (const struct hda_pintbl[]) {
7272 			{ 0x12, 0x99a3092f }, /* int-mic */
7273 			{ 0x14, 0x99130110 }, /* speaker */
7274 			{ 0x18, 0x01a19c20 }, /* mic */
7275 			{ 0x21, 0x0121401f }, /* HP out */
7276 			{ }
7277 		},
7278 	},
7279 	[ALC269_FIXUP_HP_MUTE_LED] = {
7280 		.type = HDA_FIXUP_FUNC,
7281 		.v.func = alc269_fixup_hp_mute_led,
7282 	},
7283 	[ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
7284 		.type = HDA_FIXUP_FUNC,
7285 		.v.func = alc269_fixup_hp_mute_led_mic1,
7286 	},
7287 	[ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
7288 		.type = HDA_FIXUP_FUNC,
7289 		.v.func = alc269_fixup_hp_mute_led_mic2,
7290 	},
7291 	[ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
7292 		.type = HDA_FIXUP_FUNC,
7293 		.v.func = alc269_fixup_hp_mute_led_mic3,
7294 		.chained = true,
7295 		.chain_id = ALC295_FIXUP_HP_AUTO_MUTE
7296 	},
7297 	[ALC269_FIXUP_HP_GPIO_LED] = {
7298 		.type = HDA_FIXUP_FUNC,
7299 		.v.func = alc269_fixup_hp_gpio_led,
7300 	},
7301 	[ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
7302 		.type = HDA_FIXUP_FUNC,
7303 		.v.func = alc269_fixup_hp_gpio_mic1_led,
7304 	},
7305 	[ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
7306 		.type = HDA_FIXUP_FUNC,
7307 		.v.func = alc269_fixup_hp_line1_mic1_led,
7308 	},
7309 	[ALC269_FIXUP_INV_DMIC] = {
7310 		.type = HDA_FIXUP_FUNC,
7311 		.v.func = alc_fixup_inv_dmic,
7312 	},
7313 	[ALC269_FIXUP_NO_SHUTUP] = {
7314 		.type = HDA_FIXUP_FUNC,
7315 		.v.func = alc_fixup_no_shutup,
7316 	},
7317 	[ALC269_FIXUP_LENOVO_DOCK] = {
7318 		.type = HDA_FIXUP_PINS,
7319 		.v.pins = (const struct hda_pintbl[]) {
7320 			{ 0x19, 0x23a11040 }, /* dock mic */
7321 			{ 0x1b, 0x2121103f }, /* dock headphone */
7322 			{ }
7323 		},
7324 		.chained = true,
7325 		.chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
7326 	},
7327 	[ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
7328 		.type = HDA_FIXUP_FUNC,
7329 		.v.func = alc269_fixup_limit_int_mic_boost,
7330 		.chained = true,
7331 		.chain_id = ALC269_FIXUP_LENOVO_DOCK,
7332 	},
7333 	[ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
7334 		.type = HDA_FIXUP_FUNC,
7335 		.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
7336 		.chained = true,
7337 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7338 	},
7339 	[ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7340 		.type = HDA_FIXUP_PINS,
7341 		.v.pins = (const struct hda_pintbl[]) {
7342 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7343 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7344 			{ }
7345 		},
7346 		.chained = true,
7347 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7348 	},
7349 	[ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7350 		.type = HDA_FIXUP_PINS,
7351 		.v.pins = (const struct hda_pintbl[]) {
7352 			{ 0x16, 0x21014020 }, /* dock line out */
7353 			{ 0x19, 0x21a19030 }, /* dock mic */
7354 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7355 			{ }
7356 		},
7357 		.chained = true,
7358 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7359 	},
7360 	[ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
7361 		.type = HDA_FIXUP_PINS,
7362 		.v.pins = (const struct hda_pintbl[]) {
7363 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7364 			{ }
7365 		},
7366 		.chained = true,
7367 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7368 	},
7369 	[ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
7370 		.type = HDA_FIXUP_PINS,
7371 		.v.pins = (const struct hda_pintbl[]) {
7372 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7373 			{ 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7374 			{ }
7375 		},
7376 		.chained = true,
7377 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7378 	},
7379 	[ALC269_FIXUP_HEADSET_MODE] = {
7380 		.type = HDA_FIXUP_FUNC,
7381 		.v.func = alc_fixup_headset_mode,
7382 		.chained = true,
7383 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7384 	},
7385 	[ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7386 		.type = HDA_FIXUP_FUNC,
7387 		.v.func = alc_fixup_headset_mode_no_hp_mic,
7388 	},
7389 	[ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
7390 		.type = HDA_FIXUP_PINS,
7391 		.v.pins = (const struct hda_pintbl[]) {
7392 			{ 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
7393 			{ }
7394 		},
7395 		.chained = true,
7396 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
7397 	},
7398 	[ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
7399 		.type = HDA_FIXUP_PINS,
7400 		.v.pins = (const struct hda_pintbl[]) {
7401 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7402 			{ }
7403 		},
7404 		.chained = true,
7405 		.chain_id = ALC269_FIXUP_HEADSET_MIC
7406 	},
7407 	[ALC256_FIXUP_HUAWEI_MACH_WX9_PINS] = {
7408 		.type = HDA_FIXUP_PINS,
7409 		.v.pins = (const struct hda_pintbl[]) {
7410 			{0x12, 0x90a60130},
7411 			{0x13, 0x40000000},
7412 			{0x14, 0x90170110},
7413 			{0x18, 0x411111f0},
7414 			{0x19, 0x04a11040},
7415 			{0x1a, 0x411111f0},
7416 			{0x1b, 0x90170112},
7417 			{0x1d, 0x40759a05},
7418 			{0x1e, 0x411111f0},
7419 			{0x21, 0x04211020},
7420 			{ }
7421 		},
7422 		.chained = true,
7423 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7424 	},
7425 	[ALC298_FIXUP_HUAWEI_MBX_STEREO] = {
7426 		.type = HDA_FIXUP_FUNC,
7427 		.v.func = alc298_fixup_huawei_mbx_stereo,
7428 		.chained = true,
7429 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7430 	},
7431 	[ALC269_FIXUP_ASUS_X101_FUNC] = {
7432 		.type = HDA_FIXUP_FUNC,
7433 		.v.func = alc269_fixup_x101_headset_mic,
7434 	},
7435 	[ALC269_FIXUP_ASUS_X101_VERB] = {
7436 		.type = HDA_FIXUP_VERBS,
7437 		.v.verbs = (const struct hda_verb[]) {
7438 			{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
7439 			{0x20, AC_VERB_SET_COEF_INDEX, 0x08},
7440 			{0x20, AC_VERB_SET_PROC_COEF,  0x0310},
7441 			{ }
7442 		},
7443 		.chained = true,
7444 		.chain_id = ALC269_FIXUP_ASUS_X101_FUNC
7445 	},
7446 	[ALC269_FIXUP_ASUS_X101] = {
7447 		.type = HDA_FIXUP_PINS,
7448 		.v.pins = (const struct hda_pintbl[]) {
7449 			{ 0x18, 0x04a1182c }, /* Headset mic */
7450 			{ }
7451 		},
7452 		.chained = true,
7453 		.chain_id = ALC269_FIXUP_ASUS_X101_VERB
7454 	},
7455 	[ALC271_FIXUP_AMIC_MIC2] = {
7456 		.type = HDA_FIXUP_PINS,
7457 		.v.pins = (const struct hda_pintbl[]) {
7458 			{ 0x14, 0x99130110 }, /* speaker */
7459 			{ 0x19, 0x01a19c20 }, /* mic */
7460 			{ 0x1b, 0x99a7012f }, /* int-mic */
7461 			{ 0x21, 0x0121401f }, /* HP out */
7462 			{ }
7463 		},
7464 	},
7465 	[ALC271_FIXUP_HP_GATE_MIC_JACK] = {
7466 		.type = HDA_FIXUP_FUNC,
7467 		.v.func = alc271_hp_gate_mic_jack,
7468 		.chained = true,
7469 		.chain_id = ALC271_FIXUP_AMIC_MIC2,
7470 	},
7471 	[ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
7472 		.type = HDA_FIXUP_FUNC,
7473 		.v.func = alc269_fixup_limit_int_mic_boost,
7474 		.chained = true,
7475 		.chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
7476 	},
7477 	[ALC269_FIXUP_ACER_AC700] = {
7478 		.type = HDA_FIXUP_PINS,
7479 		.v.pins = (const struct hda_pintbl[]) {
7480 			{ 0x12, 0x99a3092f }, /* int-mic */
7481 			{ 0x14, 0x99130110 }, /* speaker */
7482 			{ 0x18, 0x03a11c20 }, /* mic */
7483 			{ 0x1e, 0x0346101e }, /* SPDIF1 */
7484 			{ 0x21, 0x0321101f }, /* HP out */
7485 			{ }
7486 		},
7487 		.chained = true,
7488 		.chain_id = ALC271_FIXUP_DMIC,
7489 	},
7490 	[ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
7491 		.type = HDA_FIXUP_FUNC,
7492 		.v.func = alc269_fixup_limit_int_mic_boost,
7493 		.chained = true,
7494 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7495 	},
7496 	[ALC269VB_FIXUP_ASUS_ZENBOOK] = {
7497 		.type = HDA_FIXUP_FUNC,
7498 		.v.func = alc269_fixup_limit_int_mic_boost,
7499 		.chained = true,
7500 		.chain_id = ALC269VB_FIXUP_DMIC,
7501 	},
7502 	[ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
7503 		.type = HDA_FIXUP_VERBS,
7504 		.v.verbs = (const struct hda_verb[]) {
7505 			/* class-D output amp +5dB */
7506 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
7507 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
7508 			{}
7509 		},
7510 		.chained = true,
7511 		.chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
7512 	},
7513 	[ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7514 		.type = HDA_FIXUP_PINS,
7515 		.v.pins = (const struct hda_pintbl[]) {
7516 			{ 0x18, 0x01a110f0 },  /* use as headset mic */
7517 			{ }
7518 		},
7519 		.chained = true,
7520 		.chain_id = ALC269_FIXUP_HEADSET_MIC
7521 	},
7522 	[ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
7523 		.type = HDA_FIXUP_FUNC,
7524 		.v.func = alc269_fixup_limit_int_mic_boost,
7525 		.chained = true,
7526 		.chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
7527 	},
7528 	[ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
7529 		.type = HDA_FIXUP_PINS,
7530 		.v.pins = (const struct hda_pintbl[]) {
7531 			{ 0x12, 0x99a3092f }, /* int-mic */
7532 			{ 0x18, 0x03a11d20 }, /* mic */
7533 			{ 0x19, 0x411111f0 }, /* Unused bogus pin */
7534 			{ }
7535 		},
7536 	},
7537 	[ALC283_FIXUP_CHROME_BOOK] = {
7538 		.type = HDA_FIXUP_FUNC,
7539 		.v.func = alc283_fixup_chromebook,
7540 	},
7541 	[ALC283_FIXUP_SENSE_COMBO_JACK] = {
7542 		.type = HDA_FIXUP_FUNC,
7543 		.v.func = alc283_fixup_sense_combo_jack,
7544 		.chained = true,
7545 		.chain_id = ALC283_FIXUP_CHROME_BOOK,
7546 	},
7547 	[ALC282_FIXUP_ASUS_TX300] = {
7548 		.type = HDA_FIXUP_FUNC,
7549 		.v.func = alc282_fixup_asus_tx300,
7550 	},
7551 	[ALC283_FIXUP_INT_MIC] = {
7552 		.type = HDA_FIXUP_VERBS,
7553 		.v.verbs = (const struct hda_verb[]) {
7554 			{0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
7555 			{0x20, AC_VERB_SET_PROC_COEF, 0x0011},
7556 			{ }
7557 		},
7558 		.chained = true,
7559 		.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7560 	},
7561 	[ALC290_FIXUP_SUBWOOFER_HSJACK] = {
7562 		.type = HDA_FIXUP_PINS,
7563 		.v.pins = (const struct hda_pintbl[]) {
7564 			{ 0x17, 0x90170112 }, /* subwoofer */
7565 			{ }
7566 		},
7567 		.chained = true,
7568 		.chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
7569 	},
7570 	[ALC290_FIXUP_SUBWOOFER] = {
7571 		.type = HDA_FIXUP_PINS,
7572 		.v.pins = (const struct hda_pintbl[]) {
7573 			{ 0x17, 0x90170112 }, /* subwoofer */
7574 			{ }
7575 		},
7576 		.chained = true,
7577 		.chain_id = ALC290_FIXUP_MONO_SPEAKERS,
7578 	},
7579 	[ALC290_FIXUP_MONO_SPEAKERS] = {
7580 		.type = HDA_FIXUP_FUNC,
7581 		.v.func = alc290_fixup_mono_speakers,
7582 	},
7583 	[ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
7584 		.type = HDA_FIXUP_FUNC,
7585 		.v.func = alc290_fixup_mono_speakers,
7586 		.chained = true,
7587 		.chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
7588 	},
7589 	[ALC269_FIXUP_THINKPAD_ACPI] = {
7590 		.type = HDA_FIXUP_FUNC,
7591 		.v.func = alc_fixup_thinkpad_acpi,
7592 		.chained = true,
7593 		.chain_id = ALC269_FIXUP_SKU_IGNORE,
7594 	},
7595 	[ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
7596 		.type = HDA_FIXUP_FUNC,
7597 		.v.func = alc_fixup_inv_dmic,
7598 		.chained = true,
7599 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7600 	},
7601 	[ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
7602 		.type = HDA_FIXUP_PINS,
7603 		.v.pins = (const struct hda_pintbl[]) {
7604 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7605 			{ }
7606 		},
7607 		.chained = true,
7608 		.chain_id = ALC255_FIXUP_HEADSET_MODE
7609 	},
7610 	[ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7611 		.type = HDA_FIXUP_PINS,
7612 		.v.pins = (const struct hda_pintbl[]) {
7613 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7614 			{ }
7615 		},
7616 		.chained = true,
7617 		.chain_id = ALC255_FIXUP_HEADSET_MODE
7618 	},
7619 	[ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7620 		.type = HDA_FIXUP_PINS,
7621 		.v.pins = (const struct hda_pintbl[]) {
7622 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7623 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7624 			{ }
7625 		},
7626 		.chained = true,
7627 		.chain_id = ALC255_FIXUP_HEADSET_MODE
7628 	},
7629 	[ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7630 		.type = HDA_FIXUP_PINS,
7631 		.v.pins = (const struct hda_pintbl[]) {
7632 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7633 			{ }
7634 		},
7635 		.chained = true,
7636 		.chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7637 	},
7638 	[ALC255_FIXUP_HEADSET_MODE] = {
7639 		.type = HDA_FIXUP_FUNC,
7640 		.v.func = alc_fixup_headset_mode_alc255,
7641 		.chained = true,
7642 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7643 	},
7644 	[ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7645 		.type = HDA_FIXUP_FUNC,
7646 		.v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
7647 	},
7648 	[ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7649 		.type = HDA_FIXUP_PINS,
7650 		.v.pins = (const struct hda_pintbl[]) {
7651 			{ 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7652 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7653 			{ }
7654 		},
7655 		.chained = true,
7656 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7657 	},
7658 	[ALC292_FIXUP_TPT440_DOCK] = {
7659 		.type = HDA_FIXUP_FUNC,
7660 		.v.func = alc_fixup_tpt440_dock,
7661 		.chained = true,
7662 		.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7663 	},
7664 	[ALC292_FIXUP_TPT440] = {
7665 		.type = HDA_FIXUP_FUNC,
7666 		.v.func = alc_fixup_disable_aamix,
7667 		.chained = true,
7668 		.chain_id = ALC292_FIXUP_TPT440_DOCK,
7669 	},
7670 	[ALC283_FIXUP_HEADSET_MIC] = {
7671 		.type = HDA_FIXUP_PINS,
7672 		.v.pins = (const struct hda_pintbl[]) {
7673 			{ 0x19, 0x04a110f0 },
7674 			{ },
7675 		},
7676 	},
7677 	[ALC255_FIXUP_MIC_MUTE_LED] = {
7678 		.type = HDA_FIXUP_FUNC,
7679 		.v.func = alc_fixup_micmute_led,
7680 	},
7681 	[ALC282_FIXUP_ASPIRE_V5_PINS] = {
7682 		.type = HDA_FIXUP_PINS,
7683 		.v.pins = (const struct hda_pintbl[]) {
7684 			{ 0x12, 0x90a60130 },
7685 			{ 0x14, 0x90170110 },
7686 			{ 0x17, 0x40000008 },
7687 			{ 0x18, 0x411111f0 },
7688 			{ 0x19, 0x01a1913c },
7689 			{ 0x1a, 0x411111f0 },
7690 			{ 0x1b, 0x411111f0 },
7691 			{ 0x1d, 0x40f89b2d },
7692 			{ 0x1e, 0x411111f0 },
7693 			{ 0x21, 0x0321101f },
7694 			{ },
7695 		},
7696 	},
7697 	[ALC269VB_FIXUP_ASPIRE_E1_COEF] = {
7698 		.type = HDA_FIXUP_FUNC,
7699 		.v.func = alc269vb_fixup_aspire_e1_coef,
7700 	},
7701 	[ALC280_FIXUP_HP_GPIO4] = {
7702 		.type = HDA_FIXUP_FUNC,
7703 		.v.func = alc280_fixup_hp_gpio4,
7704 	},
7705 	[ALC286_FIXUP_HP_GPIO_LED] = {
7706 		.type = HDA_FIXUP_FUNC,
7707 		.v.func = alc286_fixup_hp_gpio_led,
7708 	},
7709 	[ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
7710 		.type = HDA_FIXUP_FUNC,
7711 		.v.func = alc280_fixup_hp_gpio2_mic_hotkey,
7712 	},
7713 	[ALC280_FIXUP_HP_DOCK_PINS] = {
7714 		.type = HDA_FIXUP_PINS,
7715 		.v.pins = (const struct hda_pintbl[]) {
7716 			{ 0x1b, 0x21011020 }, /* line-out */
7717 			{ 0x1a, 0x01a1903c }, /* headset mic */
7718 			{ 0x18, 0x2181103f }, /* line-in */
7719 			{ },
7720 		},
7721 		.chained = true,
7722 		.chain_id = ALC280_FIXUP_HP_GPIO4
7723 	},
7724 	[ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
7725 		.type = HDA_FIXUP_PINS,
7726 		.v.pins = (const struct hda_pintbl[]) {
7727 			{ 0x1b, 0x21011020 }, /* line-out */
7728 			{ 0x18, 0x2181103f }, /* line-in */
7729 			{ },
7730 		},
7731 		.chained = true,
7732 		.chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
7733 	},
7734 	[ALC280_FIXUP_HP_9480M] = {
7735 		.type = HDA_FIXUP_FUNC,
7736 		.v.func = alc280_fixup_hp_9480m,
7737 	},
7738 	[ALC245_FIXUP_HP_X360_AMP] = {
7739 		.type = HDA_FIXUP_FUNC,
7740 		.v.func = alc245_fixup_hp_x360_amp,
7741 		.chained = true,
7742 		.chain_id = ALC245_FIXUP_HP_GPIO_LED
7743 	},
7744 	[ALC288_FIXUP_DELL_HEADSET_MODE] = {
7745 		.type = HDA_FIXUP_FUNC,
7746 		.v.func = alc_fixup_headset_mode_dell_alc288,
7747 		.chained = true,
7748 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7749 	},
7750 	[ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7751 		.type = HDA_FIXUP_PINS,
7752 		.v.pins = (const struct hda_pintbl[]) {
7753 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7754 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7755 			{ }
7756 		},
7757 		.chained = true,
7758 		.chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
7759 	},
7760 	[ALC288_FIXUP_DISABLE_AAMIX] = {
7761 		.type = HDA_FIXUP_FUNC,
7762 		.v.func = alc_fixup_disable_aamix,
7763 		.chained = true,
7764 		.chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
7765 	},
7766 	[ALC288_FIXUP_DELL_XPS_13] = {
7767 		.type = HDA_FIXUP_FUNC,
7768 		.v.func = alc_fixup_dell_xps13,
7769 		.chained = true,
7770 		.chain_id = ALC288_FIXUP_DISABLE_AAMIX
7771 	},
7772 	[ALC292_FIXUP_DISABLE_AAMIX] = {
7773 		.type = HDA_FIXUP_FUNC,
7774 		.v.func = alc_fixup_disable_aamix,
7775 		.chained = true,
7776 		.chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
7777 	},
7778 	[ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
7779 		.type = HDA_FIXUP_FUNC,
7780 		.v.func = alc_fixup_disable_aamix,
7781 		.chained = true,
7782 		.chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
7783 	},
7784 	[ALC292_FIXUP_DELL_E7X_AAMIX] = {
7785 		.type = HDA_FIXUP_FUNC,
7786 		.v.func = alc_fixup_dell_xps13,
7787 		.chained = true,
7788 		.chain_id = ALC292_FIXUP_DISABLE_AAMIX
7789 	},
7790 	[ALC292_FIXUP_DELL_E7X] = {
7791 		.type = HDA_FIXUP_FUNC,
7792 		.v.func = alc_fixup_micmute_led,
7793 		/* micmute fixup must be applied at last */
7794 		.chained_before = true,
7795 		.chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
7796 	},
7797 	[ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = {
7798 		.type = HDA_FIXUP_PINS,
7799 		.v.pins = (const struct hda_pintbl[]) {
7800 			{ 0x18, 0x01a1913c }, /* headset mic w/o jack detect */
7801 			{ }
7802 		},
7803 		.chained_before = true,
7804 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
7805 	},
7806 	[ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7807 		.type = HDA_FIXUP_PINS,
7808 		.v.pins = (const struct hda_pintbl[]) {
7809 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7810 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7811 			{ }
7812 		},
7813 		.chained = true,
7814 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7815 	},
7816 	[ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
7817 		.type = HDA_FIXUP_PINS,
7818 		.v.pins = (const struct hda_pintbl[]) {
7819 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7820 			{ }
7821 		},
7822 		.chained = true,
7823 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7824 	},
7825 	[ALC275_FIXUP_DELL_XPS] = {
7826 		.type = HDA_FIXUP_VERBS,
7827 		.v.verbs = (const struct hda_verb[]) {
7828 			/* Enables internal speaker */
7829 			{0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
7830 			{0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
7831 			{0x20, AC_VERB_SET_COEF_INDEX, 0x30},
7832 			{0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
7833 			{}
7834 		}
7835 	},
7836 	[ALC293_FIXUP_LENOVO_SPK_NOISE] = {
7837 		.type = HDA_FIXUP_FUNC,
7838 		.v.func = alc_fixup_disable_aamix,
7839 		.chained = true,
7840 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
7841 	},
7842 	[ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
7843 		.type = HDA_FIXUP_FUNC,
7844 		.v.func = alc233_fixup_lenovo_line2_mic_hotkey,
7845 	},
7846 	[ALC233_FIXUP_INTEL_NUC8_DMIC] = {
7847 		.type = HDA_FIXUP_FUNC,
7848 		.v.func = alc_fixup_inv_dmic,
7849 		.chained = true,
7850 		.chain_id = ALC233_FIXUP_INTEL_NUC8_BOOST,
7851 	},
7852 	[ALC233_FIXUP_INTEL_NUC8_BOOST] = {
7853 		.type = HDA_FIXUP_FUNC,
7854 		.v.func = alc269_fixup_limit_int_mic_boost
7855 	},
7856 	[ALC255_FIXUP_DELL_SPK_NOISE] = {
7857 		.type = HDA_FIXUP_FUNC,
7858 		.v.func = alc_fixup_disable_aamix,
7859 		.chained = true,
7860 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7861 	},
7862 	[ALC225_FIXUP_DISABLE_MIC_VREF] = {
7863 		.type = HDA_FIXUP_FUNC,
7864 		.v.func = alc_fixup_disable_mic_vref,
7865 		.chained = true,
7866 		.chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7867 	},
7868 	[ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7869 		.type = HDA_FIXUP_VERBS,
7870 		.v.verbs = (const struct hda_verb[]) {
7871 			/* Disable pass-through path for FRONT 14h */
7872 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7873 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7874 			{}
7875 		},
7876 		.chained = true,
7877 		.chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
7878 	},
7879 	[ALC280_FIXUP_HP_HEADSET_MIC] = {
7880 		.type = HDA_FIXUP_FUNC,
7881 		.v.func = alc_fixup_disable_aamix,
7882 		.chained = true,
7883 		.chain_id = ALC269_FIXUP_HEADSET_MIC,
7884 	},
7885 	[ALC221_FIXUP_HP_FRONT_MIC] = {
7886 		.type = HDA_FIXUP_PINS,
7887 		.v.pins = (const struct hda_pintbl[]) {
7888 			{ 0x19, 0x02a19020 }, /* Front Mic */
7889 			{ }
7890 		},
7891 	},
7892 	[ALC292_FIXUP_TPT460] = {
7893 		.type = HDA_FIXUP_FUNC,
7894 		.v.func = alc_fixup_tpt440_dock,
7895 		.chained = true,
7896 		.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
7897 	},
7898 	[ALC298_FIXUP_SPK_VOLUME] = {
7899 		.type = HDA_FIXUP_FUNC,
7900 		.v.func = alc298_fixup_speaker_volume,
7901 		.chained = true,
7902 		.chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
7903 	},
7904 	[ALC298_FIXUP_LENOVO_SPK_VOLUME] = {
7905 		.type = HDA_FIXUP_FUNC,
7906 		.v.func = alc298_fixup_speaker_volume,
7907 	},
7908 	[ALC295_FIXUP_DISABLE_DAC3] = {
7909 		.type = HDA_FIXUP_FUNC,
7910 		.v.func = alc295_fixup_disable_dac3,
7911 	},
7912 	[ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
7913 		.type = HDA_FIXUP_FUNC,
7914 		.v.func = alc285_fixup_speaker2_to_dac1,
7915 		.chained = true,
7916 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
7917 	},
7918 	[ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
7919 		.type = HDA_FIXUP_PINS,
7920 		.v.pins = (const struct hda_pintbl[]) {
7921 			{ 0x1b, 0x90170151 },
7922 			{ }
7923 		},
7924 		.chained = true,
7925 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7926 	},
7927 	[ALC269_FIXUP_ATIV_BOOK_8] = {
7928 		.type = HDA_FIXUP_FUNC,
7929 		.v.func = alc_fixup_auto_mute_via_amp,
7930 		.chained = true,
7931 		.chain_id = ALC269_FIXUP_NO_SHUTUP
7932 	},
7933 	[ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE] = {
7934 		.type = HDA_FIXUP_PINS,
7935 		.v.pins = (const struct hda_pintbl[]) {
7936 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7937 			{ 0x1a, 0x01813030 }, /* use as headphone mic, without its own jack detect */
7938 			{ }
7939 		},
7940 		.chained = true,
7941 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7942 	},
7943 	[ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
7944 		.type = HDA_FIXUP_PINS,
7945 		.v.pins = (const struct hda_pintbl[]) {
7946 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7947 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7948 			{ }
7949 		},
7950 		.chained = true,
7951 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7952 	},
7953 	[ALC256_FIXUP_ASUS_HEADSET_MODE] = {
7954 		.type = HDA_FIXUP_FUNC,
7955 		.v.func = alc_fixup_headset_mode,
7956 	},
7957 	[ALC256_FIXUP_ASUS_MIC] = {
7958 		.type = HDA_FIXUP_PINS,
7959 		.v.pins = (const struct hda_pintbl[]) {
7960 			{ 0x13, 0x90a60160 }, /* use as internal mic */
7961 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7962 			{ }
7963 		},
7964 		.chained = true,
7965 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7966 	},
7967 	[ALC256_FIXUP_ASUS_AIO_GPIO2] = {
7968 		.type = HDA_FIXUP_FUNC,
7969 		/* Set up GPIO2 for the speaker amp */
7970 		.v.func = alc_fixup_gpio4,
7971 	},
7972 	[ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7973 		.type = HDA_FIXUP_PINS,
7974 		.v.pins = (const struct hda_pintbl[]) {
7975 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7976 			{ }
7977 		},
7978 		.chained = true,
7979 		.chain_id = ALC269_FIXUP_HEADSET_MIC
7980 	},
7981 	[ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
7982 		.type = HDA_FIXUP_VERBS,
7983 		.v.verbs = (const struct hda_verb[]) {
7984 			/* Enables internal speaker */
7985 			{0x20, AC_VERB_SET_COEF_INDEX, 0x40},
7986 			{0x20, AC_VERB_SET_PROC_COEF, 0x8800},
7987 			{}
7988 		},
7989 		.chained = true,
7990 		.chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7991 	},
7992 	[ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
7993 		.type = HDA_FIXUP_FUNC,
7994 		.v.func = alc233_alc662_fixup_lenovo_dual_codecs,
7995 		.chained = true,
7996 		.chain_id = ALC269_FIXUP_GPIO2
7997 	},
7998 	[ALC233_FIXUP_ACER_HEADSET_MIC] = {
7999 		.type = HDA_FIXUP_VERBS,
8000 		.v.verbs = (const struct hda_verb[]) {
8001 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8002 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8003 			{ }
8004 		},
8005 		.chained = true,
8006 		.chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
8007 	},
8008 	[ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
8009 		.type = HDA_FIXUP_PINS,
8010 		.v.pins = (const struct hda_pintbl[]) {
8011 			/* Change the mic location from front to right, otherwise there are
8012 			   two front mics with the same name, pulseaudio can't handle them.
8013 			   This is just a temporary workaround, after applying this fixup,
8014 			   there will be one "Front Mic" and one "Mic" in this machine.
8015 			 */
8016 			{ 0x1a, 0x04a19040 },
8017 			{ }
8018 		},
8019 	},
8020 	[ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
8021 		.type = HDA_FIXUP_PINS,
8022 		.v.pins = (const struct hda_pintbl[]) {
8023 			{ 0x16, 0x0101102f }, /* Rear Headset HP */
8024 			{ 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
8025 			{ 0x1a, 0x01a19030 }, /* Rear Headset MIC */
8026 			{ 0x1b, 0x02011020 },
8027 			{ }
8028 		},
8029 		.chained = true,
8030 		.chain_id = ALC225_FIXUP_S3_POP_NOISE
8031 	},
8032 	[ALC225_FIXUP_S3_POP_NOISE] = {
8033 		.type = HDA_FIXUP_FUNC,
8034 		.v.func = alc225_fixup_s3_pop_noise,
8035 		.chained = true,
8036 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8037 	},
8038 	[ALC700_FIXUP_INTEL_REFERENCE] = {
8039 		.type = HDA_FIXUP_VERBS,
8040 		.v.verbs = (const struct hda_verb[]) {
8041 			/* Enables internal speaker */
8042 			{0x20, AC_VERB_SET_COEF_INDEX, 0x45},
8043 			{0x20, AC_VERB_SET_PROC_COEF, 0x5289},
8044 			{0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
8045 			{0x20, AC_VERB_SET_PROC_COEF, 0x001b},
8046 			{0x58, AC_VERB_SET_COEF_INDEX, 0x00},
8047 			{0x58, AC_VERB_SET_PROC_COEF, 0x3888},
8048 			{0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
8049 			{0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
8050 			{}
8051 		}
8052 	},
8053 	[ALC274_FIXUP_DELL_BIND_DACS] = {
8054 		.type = HDA_FIXUP_FUNC,
8055 		.v.func = alc274_fixup_bind_dacs,
8056 		.chained = true,
8057 		.chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
8058 	},
8059 	[ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
8060 		.type = HDA_FIXUP_PINS,
8061 		.v.pins = (const struct hda_pintbl[]) {
8062 			{ 0x1b, 0x0401102f },
8063 			{ }
8064 		},
8065 		.chained = true,
8066 		.chain_id = ALC274_FIXUP_DELL_BIND_DACS
8067 	},
8068 	[ALC298_FIXUP_TPT470_DOCK_FIX] = {
8069 		.type = HDA_FIXUP_FUNC,
8070 		.v.func = alc_fixup_tpt470_dock,
8071 		.chained = true,
8072 		.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
8073 	},
8074 	[ALC298_FIXUP_TPT470_DOCK] = {
8075 		.type = HDA_FIXUP_FUNC,
8076 		.v.func = alc_fixup_tpt470_dacs,
8077 		.chained = true,
8078 		.chain_id = ALC298_FIXUP_TPT470_DOCK_FIX
8079 	},
8080 	[ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
8081 		.type = HDA_FIXUP_PINS,
8082 		.v.pins = (const struct hda_pintbl[]) {
8083 			{ 0x14, 0x0201101f },
8084 			{ }
8085 		},
8086 		.chained = true,
8087 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
8088 	},
8089 	[ALC255_FIXUP_DELL_HEADSET_MIC] = {
8090 		.type = HDA_FIXUP_PINS,
8091 		.v.pins = (const struct hda_pintbl[]) {
8092 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8093 			{ }
8094 		},
8095 		.chained = true,
8096 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8097 	},
8098 	[ALC295_FIXUP_HP_X360] = {
8099 		.type = HDA_FIXUP_FUNC,
8100 		.v.func = alc295_fixup_hp_top_speakers,
8101 		.chained = true,
8102 		.chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
8103 	},
8104 	[ALC221_FIXUP_HP_HEADSET_MIC] = {
8105 		.type = HDA_FIXUP_PINS,
8106 		.v.pins = (const struct hda_pintbl[]) {
8107 			{ 0x19, 0x0181313f},
8108 			{ }
8109 		},
8110 		.chained = true,
8111 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8112 	},
8113 	[ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
8114 		.type = HDA_FIXUP_FUNC,
8115 		.v.func = alc285_fixup_invalidate_dacs,
8116 		.chained = true,
8117 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
8118 	},
8119 	[ALC295_FIXUP_HP_AUTO_MUTE] = {
8120 		.type = HDA_FIXUP_FUNC,
8121 		.v.func = alc_fixup_auto_mute_via_amp,
8122 	},
8123 	[ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
8124 		.type = HDA_FIXUP_PINS,
8125 		.v.pins = (const struct hda_pintbl[]) {
8126 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8127 			{ }
8128 		},
8129 		.chained = true,
8130 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8131 	},
8132 	[ALC294_FIXUP_ASUS_MIC] = {
8133 		.type = HDA_FIXUP_PINS,
8134 		.v.pins = (const struct hda_pintbl[]) {
8135 			{ 0x13, 0x90a60160 }, /* use as internal mic */
8136 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
8137 			{ }
8138 		},
8139 		.chained = true,
8140 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8141 	},
8142 	[ALC294_FIXUP_ASUS_HEADSET_MIC] = {
8143 		.type = HDA_FIXUP_PINS,
8144 		.v.pins = (const struct hda_pintbl[]) {
8145 			{ 0x19, 0x01a1103c }, /* use as headset mic */
8146 			{ }
8147 		},
8148 		.chained = true,
8149 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8150 	},
8151 	[ALC294_FIXUP_ASUS_SPK] = {
8152 		.type = HDA_FIXUP_VERBS,
8153 		.v.verbs = (const struct hda_verb[]) {
8154 			/* Set EAPD high */
8155 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
8156 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
8157 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8158 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
8159 			{ }
8160 		},
8161 		.chained = true,
8162 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8163 	},
8164 	[ALC295_FIXUP_CHROME_BOOK] = {
8165 		.type = HDA_FIXUP_FUNC,
8166 		.v.func = alc295_fixup_chromebook,
8167 		.chained = true,
8168 		.chain_id = ALC225_FIXUP_HEADSET_JACK
8169 	},
8170 	[ALC225_FIXUP_HEADSET_JACK] = {
8171 		.type = HDA_FIXUP_FUNC,
8172 		.v.func = alc_fixup_headset_jack,
8173 	},
8174 	[ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
8175 		.type = HDA_FIXUP_PINS,
8176 		.v.pins = (const struct hda_pintbl[]) {
8177 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8178 			{ }
8179 		},
8180 		.chained = true,
8181 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8182 	},
8183 	[ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
8184 		.type = HDA_FIXUP_VERBS,
8185 		.v.verbs = (const struct hda_verb[]) {
8186 			/* Disable PCBEEP-IN passthrough */
8187 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
8188 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
8189 			{ }
8190 		},
8191 		.chained = true,
8192 		.chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
8193 	},
8194 	[ALC255_FIXUP_ACER_HEADSET_MIC] = {
8195 		.type = HDA_FIXUP_PINS,
8196 		.v.pins = (const struct hda_pintbl[]) {
8197 			{ 0x19, 0x03a11130 },
8198 			{ 0x1a, 0x90a60140 }, /* use as internal mic */
8199 			{ }
8200 		},
8201 		.chained = true,
8202 		.chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
8203 	},
8204 	[ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
8205 		.type = HDA_FIXUP_PINS,
8206 		.v.pins = (const struct hda_pintbl[]) {
8207 			{ 0x16, 0x01011020 }, /* Rear Line out */
8208 			{ 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
8209 			{ }
8210 		},
8211 		.chained = true,
8212 		.chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
8213 	},
8214 	[ALC225_FIXUP_WYSE_AUTO_MUTE] = {
8215 		.type = HDA_FIXUP_FUNC,
8216 		.v.func = alc_fixup_auto_mute_via_amp,
8217 		.chained = true,
8218 		.chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
8219 	},
8220 	[ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
8221 		.type = HDA_FIXUP_FUNC,
8222 		.v.func = alc_fixup_disable_mic_vref,
8223 		.chained = true,
8224 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8225 	},
8226 	[ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
8227 		.type = HDA_FIXUP_VERBS,
8228 		.v.verbs = (const struct hda_verb[]) {
8229 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
8230 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
8231 			{ }
8232 		},
8233 		.chained = true,
8234 		.chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
8235 	},
8236 	[ALC256_FIXUP_ASUS_HEADSET_MIC] = {
8237 		.type = HDA_FIXUP_PINS,
8238 		.v.pins = (const struct hda_pintbl[]) {
8239 			{ 0x19, 0x03a11020 }, /* headset mic with jack detect */
8240 			{ }
8241 		},
8242 		.chained = true,
8243 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8244 	},
8245 	[ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8246 		.type = HDA_FIXUP_PINS,
8247 		.v.pins = (const struct hda_pintbl[]) {
8248 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
8249 			{ }
8250 		},
8251 		.chained = true,
8252 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8253 	},
8254 	[ALC299_FIXUP_PREDATOR_SPK] = {
8255 		.type = HDA_FIXUP_PINS,
8256 		.v.pins = (const struct hda_pintbl[]) {
8257 			{ 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
8258 			{ }
8259 		}
8260 	},
8261 	[ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
8262 		.type = HDA_FIXUP_PINS,
8263 		.v.pins = (const struct hda_pintbl[]) {
8264 			{ 0x19, 0x04a11040 },
8265 			{ 0x21, 0x04211020 },
8266 			{ }
8267 		},
8268 		.chained = true,
8269 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8270 	},
8271 	[ALC289_FIXUP_DELL_SPK2] = {
8272 		.type = HDA_FIXUP_PINS,
8273 		.v.pins = (const struct hda_pintbl[]) {
8274 			{ 0x17, 0x90170130 }, /* bass spk */
8275 			{ }
8276 		},
8277 		.chained = true,
8278 		.chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
8279 	},
8280 	[ALC289_FIXUP_DUAL_SPK] = {
8281 		.type = HDA_FIXUP_FUNC,
8282 		.v.func = alc285_fixup_speaker2_to_dac1,
8283 		.chained = true,
8284 		.chain_id = ALC289_FIXUP_DELL_SPK2
8285 	},
8286 	[ALC294_FIXUP_SPK2_TO_DAC1] = {
8287 		.type = HDA_FIXUP_FUNC,
8288 		.v.func = alc285_fixup_speaker2_to_dac1,
8289 		.chained = true,
8290 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8291 	},
8292 	[ALC294_FIXUP_ASUS_DUAL_SPK] = {
8293 		.type = HDA_FIXUP_FUNC,
8294 		/* The GPIO must be pulled to initialize the AMP */
8295 		.v.func = alc_fixup_gpio4,
8296 		.chained = true,
8297 		.chain_id = ALC294_FIXUP_SPK2_TO_DAC1
8298 	},
8299 	[ALC285_FIXUP_THINKPAD_X1_GEN7] = {
8300 		.type = HDA_FIXUP_FUNC,
8301 		.v.func = alc285_fixup_thinkpad_x1_gen7,
8302 		.chained = true,
8303 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
8304 	},
8305 	[ALC285_FIXUP_THINKPAD_HEADSET_JACK] = {
8306 		.type = HDA_FIXUP_FUNC,
8307 		.v.func = alc_fixup_headset_jack,
8308 		.chained = true,
8309 		.chain_id = ALC285_FIXUP_THINKPAD_X1_GEN7
8310 	},
8311 	[ALC294_FIXUP_ASUS_HPE] = {
8312 		.type = HDA_FIXUP_VERBS,
8313 		.v.verbs = (const struct hda_verb[]) {
8314 			/* Set EAPD high */
8315 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8316 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
8317 			{ }
8318 		},
8319 		.chained = true,
8320 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8321 	},
8322 	[ALC294_FIXUP_ASUS_GX502_PINS] = {
8323 		.type = HDA_FIXUP_PINS,
8324 		.v.pins = (const struct hda_pintbl[]) {
8325 			{ 0x19, 0x03a11050 }, /* front HP mic */
8326 			{ 0x1a, 0x01a11830 }, /* rear external mic */
8327 			{ 0x21, 0x03211020 }, /* front HP out */
8328 			{ }
8329 		},
8330 		.chained = true,
8331 		.chain_id = ALC294_FIXUP_ASUS_GX502_VERBS
8332 	},
8333 	[ALC294_FIXUP_ASUS_GX502_VERBS] = {
8334 		.type = HDA_FIXUP_VERBS,
8335 		.v.verbs = (const struct hda_verb[]) {
8336 			/* set 0x15 to HP-OUT ctrl */
8337 			{ 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8338 			/* unmute the 0x15 amp */
8339 			{ 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
8340 			{ }
8341 		},
8342 		.chained = true,
8343 		.chain_id = ALC294_FIXUP_ASUS_GX502_HP
8344 	},
8345 	[ALC294_FIXUP_ASUS_GX502_HP] = {
8346 		.type = HDA_FIXUP_FUNC,
8347 		.v.func = alc294_fixup_gx502_hp,
8348 	},
8349 	[ALC294_FIXUP_ASUS_GU502_PINS] = {
8350 		.type = HDA_FIXUP_PINS,
8351 		.v.pins = (const struct hda_pintbl[]) {
8352 			{ 0x19, 0x01a11050 }, /* rear HP mic */
8353 			{ 0x1a, 0x01a11830 }, /* rear external mic */
8354 			{ 0x21, 0x012110f0 }, /* rear HP out */
8355 			{ }
8356 		},
8357 		.chained = true,
8358 		.chain_id = ALC294_FIXUP_ASUS_GU502_VERBS
8359 	},
8360 	[ALC294_FIXUP_ASUS_GU502_VERBS] = {
8361 		.type = HDA_FIXUP_VERBS,
8362 		.v.verbs = (const struct hda_verb[]) {
8363 			/* set 0x15 to HP-OUT ctrl */
8364 			{ 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8365 			/* unmute the 0x15 amp */
8366 			{ 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
8367 			/* set 0x1b to HP-OUT */
8368 			{ 0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8369 			{ }
8370 		},
8371 		.chained = true,
8372 		.chain_id = ALC294_FIXUP_ASUS_GU502_HP
8373 	},
8374 	[ALC294_FIXUP_ASUS_GU502_HP] = {
8375 		.type = HDA_FIXUP_FUNC,
8376 		.v.func = alc294_fixup_gu502_hp,
8377 	},
8378 	[ALC294_FIXUP_ASUS_COEF_1B] = {
8379 		.type = HDA_FIXUP_VERBS,
8380 		.v.verbs = (const struct hda_verb[]) {
8381 			/* Set bit 10 to correct noisy output after reboot from
8382 			 * Windows 10 (due to pop noise reduction?)
8383 			 */
8384 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
8385 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
8386 			{ }
8387 		},
8388 		.chained = true,
8389 		.chain_id = ALC289_FIXUP_ASUS_GA401,
8390 	},
8391 	[ALC285_FIXUP_HP_GPIO_LED] = {
8392 		.type = HDA_FIXUP_FUNC,
8393 		.v.func = alc285_fixup_hp_gpio_led,
8394 	},
8395 	[ALC285_FIXUP_HP_MUTE_LED] = {
8396 		.type = HDA_FIXUP_FUNC,
8397 		.v.func = alc285_fixup_hp_mute_led,
8398 	},
8399 	[ALC236_FIXUP_HP_GPIO_LED] = {
8400 		.type = HDA_FIXUP_FUNC,
8401 		.v.func = alc236_fixup_hp_gpio_led,
8402 	},
8403 	[ALC236_FIXUP_HP_MUTE_LED] = {
8404 		.type = HDA_FIXUP_FUNC,
8405 		.v.func = alc236_fixup_hp_mute_led,
8406 	},
8407 	[ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF] = {
8408 		.type = HDA_FIXUP_FUNC,
8409 		.v.func = alc236_fixup_hp_mute_led_micmute_vref,
8410 	},
8411 	[ALC298_FIXUP_SAMSUNG_AMP] = {
8412 		.type = HDA_FIXUP_FUNC,
8413 		.v.func = alc298_fixup_samsung_amp,
8414 		.chained = true,
8415 		.chain_id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET
8416 	},
8417 	[ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
8418 		.type = HDA_FIXUP_VERBS,
8419 		.v.verbs = (const struct hda_verb[]) {
8420 			{ 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
8421 			{ }
8422 		},
8423 	},
8424 	[ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
8425 		.type = HDA_FIXUP_VERBS,
8426 		.v.verbs = (const struct hda_verb[]) {
8427 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x08},
8428 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf},
8429 			{ }
8430 		},
8431 	},
8432 	[ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8433 		.type = HDA_FIXUP_PINS,
8434 		.v.pins = (const struct hda_pintbl[]) {
8435 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8436 			{ }
8437 		},
8438 		.chained = true,
8439 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8440 	},
8441 	[ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS] = {
8442 		.type = HDA_FIXUP_PINS,
8443 		.v.pins = (const struct hda_pintbl[]) {
8444 			{ 0x14, 0x90100120 }, /* use as internal speaker */
8445 			{ 0x18, 0x02a111f0 }, /* use as headset mic, without its own jack detect */
8446 			{ 0x1a, 0x01011020 }, /* use as line out */
8447 			{ },
8448 		},
8449 		.chained = true,
8450 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8451 	},
8452 	[ALC269VC_FIXUP_ACER_HEADSET_MIC] = {
8453 		.type = HDA_FIXUP_PINS,
8454 		.v.pins = (const struct hda_pintbl[]) {
8455 			{ 0x18, 0x02a11030 }, /* use as headset mic */
8456 			{ }
8457 		},
8458 		.chained = true,
8459 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8460 	},
8461 	[ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE] = {
8462 		.type = HDA_FIXUP_PINS,
8463 		.v.pins = (const struct hda_pintbl[]) {
8464 			{ 0x18, 0x01a11130 }, /* use as headset mic, without its own jack detect */
8465 			{ }
8466 		},
8467 		.chained = true,
8468 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8469 	},
8470 	[ALC289_FIXUP_ASUS_GA401] = {
8471 		.type = HDA_FIXUP_FUNC,
8472 		.v.func = alc289_fixup_asus_ga401,
8473 		.chained = true,
8474 		.chain_id = ALC289_FIXUP_ASUS_GA502,
8475 	},
8476 	[ALC289_FIXUP_ASUS_GA502] = {
8477 		.type = HDA_FIXUP_PINS,
8478 		.v.pins = (const struct hda_pintbl[]) {
8479 			{ 0x19, 0x03a11020 }, /* headset mic with jack detect */
8480 			{ }
8481 		},
8482 	},
8483 	[ALC256_FIXUP_ACER_MIC_NO_PRESENCE] = {
8484 		.type = HDA_FIXUP_PINS,
8485 		.v.pins = (const struct hda_pintbl[]) {
8486 			{ 0x19, 0x02a11120 }, /* use as headset mic, without its own jack detect */
8487 			{ }
8488 		},
8489 		.chained = true,
8490 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8491 	},
8492 	[ALC285_FIXUP_HP_GPIO_AMP_INIT] = {
8493 		.type = HDA_FIXUP_FUNC,
8494 		.v.func = alc285_fixup_hp_gpio_amp_init,
8495 		.chained = true,
8496 		.chain_id = ALC285_FIXUP_HP_GPIO_LED
8497 	},
8498 	[ALC269_FIXUP_CZC_B20] = {
8499 		.type = HDA_FIXUP_PINS,
8500 		.v.pins = (const struct hda_pintbl[]) {
8501 			{ 0x12, 0x411111f0 },
8502 			{ 0x14, 0x90170110 }, /* speaker */
8503 			{ 0x15, 0x032f1020 }, /* HP out */
8504 			{ 0x17, 0x411111f0 },
8505 			{ 0x18, 0x03ab1040 }, /* mic */
8506 			{ 0x19, 0xb7a7013f },
8507 			{ 0x1a, 0x0181305f },
8508 			{ 0x1b, 0x411111f0 },
8509 			{ 0x1d, 0x411111f0 },
8510 			{ 0x1e, 0x411111f0 },
8511 			{ }
8512 		},
8513 		.chain_id = ALC269_FIXUP_DMIC,
8514 	},
8515 	[ALC269_FIXUP_CZC_TMI] = {
8516 		.type = HDA_FIXUP_PINS,
8517 		.v.pins = (const struct hda_pintbl[]) {
8518 			{ 0x12, 0x4000c000 },
8519 			{ 0x14, 0x90170110 }, /* speaker */
8520 			{ 0x15, 0x0421401f }, /* HP out */
8521 			{ 0x17, 0x411111f0 },
8522 			{ 0x18, 0x04a19020 }, /* mic */
8523 			{ 0x19, 0x411111f0 },
8524 			{ 0x1a, 0x411111f0 },
8525 			{ 0x1b, 0x411111f0 },
8526 			{ 0x1d, 0x40448505 },
8527 			{ 0x1e, 0x411111f0 },
8528 			{ 0x20, 0x8000ffff },
8529 			{ }
8530 		},
8531 		.chain_id = ALC269_FIXUP_DMIC,
8532 	},
8533 	[ALC269_FIXUP_CZC_L101] = {
8534 		.type = HDA_FIXUP_PINS,
8535 		.v.pins = (const struct hda_pintbl[]) {
8536 			{ 0x12, 0x40000000 },
8537 			{ 0x14, 0x01014010 }, /* speaker */
8538 			{ 0x15, 0x411111f0 }, /* HP out */
8539 			{ 0x16, 0x411111f0 },
8540 			{ 0x18, 0x01a19020 }, /* mic */
8541 			{ 0x19, 0x02a19021 },
8542 			{ 0x1a, 0x0181302f },
8543 			{ 0x1b, 0x0221401f },
8544 			{ 0x1c, 0x411111f0 },
8545 			{ 0x1d, 0x4044c601 },
8546 			{ 0x1e, 0x411111f0 },
8547 			{ }
8548 		},
8549 		.chain_id = ALC269_FIXUP_DMIC,
8550 	},
8551 	[ALC269_FIXUP_LEMOTE_A1802] = {
8552 		.type = HDA_FIXUP_PINS,
8553 		.v.pins = (const struct hda_pintbl[]) {
8554 			{ 0x12, 0x40000000 },
8555 			{ 0x14, 0x90170110 }, /* speaker */
8556 			{ 0x17, 0x411111f0 },
8557 			{ 0x18, 0x03a19040 }, /* mic1 */
8558 			{ 0x19, 0x90a70130 }, /* mic2 */
8559 			{ 0x1a, 0x411111f0 },
8560 			{ 0x1b, 0x411111f0 },
8561 			{ 0x1d, 0x40489d2d },
8562 			{ 0x1e, 0x411111f0 },
8563 			{ 0x20, 0x0003ffff },
8564 			{ 0x21, 0x03214020 },
8565 			{ }
8566 		},
8567 		.chain_id = ALC269_FIXUP_DMIC,
8568 	},
8569 	[ALC269_FIXUP_LEMOTE_A190X] = {
8570 		.type = HDA_FIXUP_PINS,
8571 		.v.pins = (const struct hda_pintbl[]) {
8572 			{ 0x14, 0x99130110 }, /* speaker */
8573 			{ 0x15, 0x0121401f }, /* HP out */
8574 			{ 0x18, 0x01a19c20 }, /* rear  mic */
8575 			{ 0x19, 0x99a3092f }, /* front mic */
8576 			{ 0x1b, 0x0201401f }, /* front lineout */
8577 			{ }
8578 		},
8579 		.chain_id = ALC269_FIXUP_DMIC,
8580 	},
8581 	[ALC256_FIXUP_INTEL_NUC8_RUGGED] = {
8582 		.type = HDA_FIXUP_PINS,
8583 		.v.pins = (const struct hda_pintbl[]) {
8584 			{ 0x1b, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8585 			{ }
8586 		},
8587 		.chained = true,
8588 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8589 	},
8590 	[ALC256_FIXUP_INTEL_NUC10] = {
8591 		.type = HDA_FIXUP_PINS,
8592 		.v.pins = (const struct hda_pintbl[]) {
8593 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8594 			{ }
8595 		},
8596 		.chained = true,
8597 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8598 	},
8599 	[ALC255_FIXUP_XIAOMI_HEADSET_MIC] = {
8600 		.type = HDA_FIXUP_VERBS,
8601 		.v.verbs = (const struct hda_verb[]) {
8602 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8603 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8604 			{ }
8605 		},
8606 		.chained = true,
8607 		.chain_id = ALC289_FIXUP_ASUS_GA502
8608 	},
8609 	[ALC274_FIXUP_HP_MIC] = {
8610 		.type = HDA_FIXUP_VERBS,
8611 		.v.verbs = (const struct hda_verb[]) {
8612 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8613 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8614 			{ }
8615 		},
8616 	},
8617 	[ALC274_FIXUP_HP_HEADSET_MIC] = {
8618 		.type = HDA_FIXUP_FUNC,
8619 		.v.func = alc274_fixup_hp_headset_mic,
8620 		.chained = true,
8621 		.chain_id = ALC274_FIXUP_HP_MIC
8622 	},
8623 	[ALC274_FIXUP_HP_ENVY_GPIO] = {
8624 		.type = HDA_FIXUP_FUNC,
8625 		.v.func = alc274_fixup_hp_envy_gpio,
8626 	},
8627 	[ALC256_FIXUP_ASUS_HPE] = {
8628 		.type = HDA_FIXUP_VERBS,
8629 		.v.verbs = (const struct hda_verb[]) {
8630 			/* Set EAPD high */
8631 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8632 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x7778 },
8633 			{ }
8634 		},
8635 		.chained = true,
8636 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8637 	},
8638 	[ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK] = {
8639 		.type = HDA_FIXUP_FUNC,
8640 		.v.func = alc_fixup_headset_jack,
8641 		.chained = true,
8642 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
8643 	},
8644 	[ALC287_FIXUP_HP_GPIO_LED] = {
8645 		.type = HDA_FIXUP_FUNC,
8646 		.v.func = alc287_fixup_hp_gpio_led,
8647 	},
8648 	[ALC256_FIXUP_HP_HEADSET_MIC] = {
8649 		.type = HDA_FIXUP_FUNC,
8650 		.v.func = alc274_fixup_hp_headset_mic,
8651 	},
8652 	[ALC236_FIXUP_DELL_AIO_HEADSET_MIC] = {
8653 		.type = HDA_FIXUP_FUNC,
8654 		.v.func = alc_fixup_no_int_mic,
8655 		.chained = true,
8656 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
8657 	},
8658 	[ALC282_FIXUP_ACER_DISABLE_LINEOUT] = {
8659 		.type = HDA_FIXUP_PINS,
8660 		.v.pins = (const struct hda_pintbl[]) {
8661 			{ 0x1b, 0x411111f0 },
8662 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8663 			{ },
8664 		},
8665 		.chained = true,
8666 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8667 	},
8668 	[ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST] = {
8669 		.type = HDA_FIXUP_FUNC,
8670 		.v.func = alc269_fixup_limit_int_mic_boost,
8671 		.chained = true,
8672 		.chain_id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
8673 	},
8674 	[ALC256_FIXUP_ACER_HEADSET_MIC] = {
8675 		.type = HDA_FIXUP_PINS,
8676 		.v.pins = (const struct hda_pintbl[]) {
8677 			{ 0x19, 0x02a1113c }, /* use as headset mic, without its own jack detect */
8678 			{ 0x1a, 0x90a1092f }, /* use as internal mic */
8679 			{ }
8680 		},
8681 		.chained = true,
8682 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8683 	},
8684 	[ALC285_FIXUP_IDEAPAD_S740_COEF] = {
8685 		.type = HDA_FIXUP_FUNC,
8686 		.v.func = alc285_fixup_ideapad_s740_coef,
8687 		.chained = true,
8688 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8689 	},
8690 	[ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8691 		.type = HDA_FIXUP_FUNC,
8692 		.v.func = alc269_fixup_limit_int_mic_boost,
8693 		.chained = true,
8694 		.chain_id = ALC285_FIXUP_HP_MUTE_LED,
8695 	},
8696 	[ALC295_FIXUP_ASUS_DACS] = {
8697 		.type = HDA_FIXUP_FUNC,
8698 		.v.func = alc295_fixup_asus_dacs,
8699 	},
8700 	[ALC295_FIXUP_HP_OMEN] = {
8701 		.type = HDA_FIXUP_PINS,
8702 		.v.pins = (const struct hda_pintbl[]) {
8703 			{ 0x12, 0xb7a60130 },
8704 			{ 0x13, 0x40000000 },
8705 			{ 0x14, 0x411111f0 },
8706 			{ 0x16, 0x411111f0 },
8707 			{ 0x17, 0x90170110 },
8708 			{ 0x18, 0x411111f0 },
8709 			{ 0x19, 0x02a11030 },
8710 			{ 0x1a, 0x411111f0 },
8711 			{ 0x1b, 0x04a19030 },
8712 			{ 0x1d, 0x40600001 },
8713 			{ 0x1e, 0x411111f0 },
8714 			{ 0x21, 0x03211020 },
8715 			{}
8716 		},
8717 		.chained = true,
8718 		.chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
8719 	},
8720 	[ALC285_FIXUP_HP_SPECTRE_X360] = {
8721 		.type = HDA_FIXUP_FUNC,
8722 		.v.func = alc285_fixup_hp_spectre_x360,
8723 	},
8724 	[ALC285_FIXUP_HP_SPECTRE_X360_EB1] = {
8725 		.type = HDA_FIXUP_FUNC,
8726 		.v.func = alc285_fixup_hp_spectre_x360_eb1
8727 	},
8728 	[ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = {
8729 		.type = HDA_FIXUP_FUNC,
8730 		.v.func = alc285_fixup_ideapad_s740_coef,
8731 		.chained = true,
8732 		.chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK,
8733 	},
8734 	[ALC623_FIXUP_LENOVO_THINKSTATION_P340] = {
8735 		.type = HDA_FIXUP_FUNC,
8736 		.v.func = alc_fixup_no_shutup,
8737 		.chained = true,
8738 		.chain_id = ALC283_FIXUP_HEADSET_MIC,
8739 	},
8740 	[ALC255_FIXUP_ACER_HEADPHONE_AND_MIC] = {
8741 		.type = HDA_FIXUP_PINS,
8742 		.v.pins = (const struct hda_pintbl[]) {
8743 			{ 0x21, 0x03211030 }, /* Change the Headphone location to Left */
8744 			{ }
8745 		},
8746 		.chained = true,
8747 		.chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC
8748 	},
8749 	[ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8750 		.type = HDA_FIXUP_FUNC,
8751 		.v.func = alc269_fixup_limit_int_mic_boost,
8752 		.chained = true,
8753 		.chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
8754 	},
8755 	[ALC285_FIXUP_LEGION_Y9000X_SPEAKERS] = {
8756 		.type = HDA_FIXUP_FUNC,
8757 		.v.func = alc285_fixup_ideapad_s740_coef,
8758 		.chained = true,
8759 		.chain_id = ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
8760 	},
8761 	[ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE] = {
8762 		.type = HDA_FIXUP_FUNC,
8763 		.v.func = alc287_fixup_legion_15imhg05_speakers,
8764 		.chained = true,
8765 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8766 	},
8767 	[ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
8768 		.type = HDA_FIXUP_VERBS,
8769 		//.v.verbs = legion_15imhg05_coefs,
8770 		.v.verbs = (const struct hda_verb[]) {
8771 			 // set left speaker Legion 7i.
8772 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8773 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8774 
8775 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8776 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8777 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8778 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8779 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8780 
8781 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8782 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8783 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8784 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8785 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8786 
8787 			 // set right speaker Legion 7i.
8788 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8789 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8790 
8791 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8792 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8793 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8794 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8795 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8796 
8797 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8798 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8799 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8800 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8801 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8802 			 {}
8803 		},
8804 		.chained = true,
8805 		.chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
8806 	},
8807 	[ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
8808 		.type = HDA_FIXUP_FUNC,
8809 		.v.func = alc287_fixup_legion_15imhg05_speakers,
8810 		.chained = true,
8811 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
8812 	},
8813 	[ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
8814 		.type = HDA_FIXUP_VERBS,
8815 		.v.verbs = (const struct hda_verb[]) {
8816 			 // set left speaker Yoga 7i.
8817 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8818 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8819 
8820 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8821 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8822 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8823 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8824 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8825 
8826 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8827 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8828 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8829 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8830 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8831 
8832 			 // set right speaker Yoga 7i.
8833 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8834 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
8835 
8836 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8837 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8838 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8839 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8840 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8841 
8842 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8843 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8844 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8845 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8846 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8847 			 {}
8848 		},
8849 		.chained = true,
8850 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
8851 	},
8852 	[ALC298_FIXUP_LENOVO_C940_DUET7] = {
8853 		.type = HDA_FIXUP_FUNC,
8854 		.v.func = alc298_fixup_lenovo_c940_duet7,
8855 	},
8856 	[ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
8857 		.type = HDA_FIXUP_VERBS,
8858 		.v.verbs = (const struct hda_verb[]) {
8859 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8860 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8861 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8862 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8863 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8864 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8865 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8866 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8867 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8868 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8869 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8870 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8871 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8872 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8873 			{}
8874 		},
8875 		.chained = true,
8876 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
8877 	},
8878 	[ALC256_FIXUP_SET_COEF_DEFAULTS] = {
8879 		.type = HDA_FIXUP_FUNC,
8880 		.v.func = alc256_fixup_set_coef_defaults,
8881 	},
8882 	[ALC245_FIXUP_HP_GPIO_LED] = {
8883 		.type = HDA_FIXUP_FUNC,
8884 		.v.func = alc245_fixup_hp_gpio_led,
8885 	},
8886 	[ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
8887 		.type = HDA_FIXUP_PINS,
8888 		.v.pins = (const struct hda_pintbl[]) {
8889 			{ 0x19, 0x03a11120 }, /* use as headset mic, without its own jack detect */
8890 			{ }
8891 		},
8892 		.chained = true,
8893 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
8894 	},
8895 	[ALC233_FIXUP_NO_AUDIO_JACK] = {
8896 		.type = HDA_FIXUP_FUNC,
8897 		.v.func = alc233_fixup_no_audio_jack,
8898 	},
8899 	[ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME] = {
8900 		.type = HDA_FIXUP_FUNC,
8901 		.v.func = alc256_fixup_mic_no_presence_and_resume,
8902 		.chained = true,
8903 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8904 	},
8905 	[ALC287_FIXUP_LEGION_16ACHG6] = {
8906 		.type = HDA_FIXUP_FUNC,
8907 		.v.func = alc287_fixup_legion_16achg6_speakers,
8908 	},
8909 	[ALC287_FIXUP_CS35L41_I2C_2] = {
8910 		.type = HDA_FIXUP_FUNC,
8911 		.v.func = cs35l41_fixup_i2c_two,
8912 		.chained = true,
8913 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8914 	},
8915 	[ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED] = {
8916 		.type = HDA_FIXUP_FUNC,
8917 		.v.func = cs35l41_fixup_i2c_two,
8918 		.chained = true,
8919 		.chain_id = ALC285_FIXUP_HP_MUTE_LED,
8920 	},
8921 	[ALC245_FIXUP_CS35L41_SPI_2] = {
8922 		.type = HDA_FIXUP_FUNC,
8923 		.v.func = cs35l41_fixup_spi_two,
8924 	},
8925 	[ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED] = {
8926 		.type = HDA_FIXUP_FUNC,
8927 		.v.func = cs35l41_fixup_spi_two,
8928 		.chained = true,
8929 		.chain_id = ALC285_FIXUP_HP_GPIO_LED,
8930 	},
8931 	[ALC245_FIXUP_CS35L41_SPI_4] = {
8932 		.type = HDA_FIXUP_FUNC,
8933 		.v.func = cs35l41_fixup_spi_four,
8934 	},
8935 	[ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED] = {
8936 		.type = HDA_FIXUP_FUNC,
8937 		.v.func = cs35l41_fixup_spi_four,
8938 		.chained = true,
8939 		.chain_id = ALC285_FIXUP_HP_GPIO_LED,
8940 	},
8941 	[ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED] = {
8942 		.type = HDA_FIXUP_VERBS,
8943 		.v.verbs = (const struct hda_verb[]) {
8944 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x19 },
8945 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x8e11 },
8946 			 { }
8947 		},
8948 		.chained = true,
8949 		.chain_id = ALC285_FIXUP_HP_MUTE_LED,
8950 	},
8951 	[ALC269_FIXUP_DELL4_MIC_NO_PRESENCE_QUIET] = {
8952 		.type = HDA_FIXUP_FUNC,
8953 		.v.func = alc_fixup_dell4_mic_no_presence_quiet,
8954 		.chained = true,
8955 		.chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
8956 	},
8957 	[ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE] = {
8958 		.type = HDA_FIXUP_PINS,
8959 		.v.pins = (const struct hda_pintbl[]) {
8960 			{ 0x19, 0x02a1112c }, /* use as headset mic, without its own jack detect */
8961 			{ }
8962 		},
8963 		.chained = true,
8964 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8965 	},
8966 	[ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK] = {
8967 		.type = HDA_FIXUP_VERBS,
8968 		.v.verbs = (const struct hda_verb[]) {
8969 			// enable left speaker
8970 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8971 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8972 
8973 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8974 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8975 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8976 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8977 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8978 
8979 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8980 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xf },
8981 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8982 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8983 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8984 
8985 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8986 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x10 },
8987 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8988 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x40 },
8989 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8990 
8991 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8992 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8993 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8994 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8995 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8996 
8997 			// enable right speaker
8998 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8999 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
9000 
9001 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
9002 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xc },
9003 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
9004 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
9005 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
9006 
9007 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
9008 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xf },
9009 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
9010 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
9011 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
9012 
9013 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
9014 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x10 },
9015 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
9016 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x44 },
9017 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
9018 
9019 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
9020 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
9021 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
9022 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
9023 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
9024 
9025 			{ },
9026 		},
9027 	},
9028 	[ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN] = {
9029 		.type = HDA_FIXUP_FUNC,
9030 		.v.func = alc287_fixup_yoga9_14iap7_bass_spk_pin,
9031 		.chained = true,
9032 		.chain_id = ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK,
9033 	},
9034 };
9035 
9036 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
9037 	SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
9038 	SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
9039 	SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
9040 	SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
9041 	SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
9042 	SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
9043 	SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
9044 	SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
9045 	SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
9046 	SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
9047 	SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
9048 	SND_PCI_QUIRK(0x1025, 0x0840, "Acer Aspire E1", ALC269VB_FIXUP_ASPIRE_E1_COEF),
9049 	SND_PCI_QUIRK(0x1025, 0x101c, "Acer Veriton N2510G", ALC269_FIXUP_LIFEBOOK),
9050 	SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
9051 	SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
9052 	SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
9053 	SND_PCI_QUIRK(0x1025, 0x1094, "Acer Aspire E5-575T", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST),
9054 	SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9055 	SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9056 	SND_PCI_QUIRK(0x1025, 0x1166, "Acer Veriton N4640G", ALC269_FIXUP_LIFEBOOK),
9057 	SND_PCI_QUIRK(0x1025, 0x1167, "Acer Veriton N6640G", ALC269_FIXUP_LIFEBOOK),
9058 	SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
9059 	SND_PCI_QUIRK(0x1025, 0x1247, "Acer vCopperbox", ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS),
9060 	SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
9061 	SND_PCI_QUIRK(0x1025, 0x1269, "Acer SWIFT SF314-54", ALC256_FIXUP_ACER_HEADSET_MIC),
9062 	SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
9063 	SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
9064 	SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
9065 	SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
9066 	SND_PCI_QUIRK(0x1025, 0x129d, "Acer SWIFT SF313-51", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9067 	SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9068 	SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
9069 	SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
9070 	SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
9071 	SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9072 	SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9073 	SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9074 	SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
9075 	SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
9076 	SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
9077 	SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
9078 	SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
9079 	SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
9080 	SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
9081 	SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
9082 	SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
9083 	SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
9084 	SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
9085 	SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
9086 	SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
9087 	SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
9088 	SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
9089 	SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
9090 	SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
9091 	SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
9092 	SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
9093 	SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
9094 	SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
9095 	SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
9096 	SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
9097 	SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
9098 	SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
9099 	SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
9100 	SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
9101 	SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
9102 	SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
9103 	SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
9104 	SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
9105 	SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
9106 	SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
9107 	SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
9108 	SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
9109 	SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
9110 	SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
9111 	SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
9112 	SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
9113 	SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
9114 	SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
9115 	SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
9116 	SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
9117 	SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
9118 	SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
9119 	SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
9120 	SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
9121 	SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
9122 	SND_PCI_QUIRK(0x1028, 0x098d, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
9123 	SND_PCI_QUIRK(0x1028, 0x09bf, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
9124 	SND_PCI_QUIRK(0x1028, 0x0a2e, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
9125 	SND_PCI_QUIRK(0x1028, 0x0a30, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
9126 	SND_PCI_QUIRK(0x1028, 0x0a38, "Dell Latitude 7520", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE_QUIET),
9127 	SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC),
9128 	SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK),
9129 	SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK),
9130 	SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
9131 	SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
9132 	SND_PCI_QUIRK(0x1028, 0x0b19, "Dell XPS 15 9520", ALC289_FIXUP_DUAL_SPK),
9133 	SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
9134 	SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
9135 	SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9136 	SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
9137 	SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
9138 	SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9139 	SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9140 	SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9141 	SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9142 	SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
9143 	SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9144 	SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9145 	SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9146 	SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9147 	SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9148 	SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9149 	SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9150 	SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9151 	SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9152 	SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9153 	SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9154 	SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9155 	SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9156 	SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
9157 	SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
9158 	SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9159 	SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9160 	SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9161 	SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9162 	SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9163 	SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9164 	SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9165 	SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9166 	SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
9167 	SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9168 	SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
9169 	SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9170 	SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
9171 	SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9172 	SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9173 	SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9174 	SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9175 	SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9176 	SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9177 	SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9178 	SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9179 	SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9180 	SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9181 	SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9182 	SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9183 	SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9184 	SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9185 	SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
9186 	SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9187 	SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9188 	SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9189 	SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9190 	SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9191 	SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9192 	SND_PCI_QUIRK(0x103c, 0x2b5e, "HP 288 Pro G2 MT", ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE),
9193 	SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9194 	SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9195 	SND_PCI_QUIRK(0x103c, 0x8077, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
9196 	SND_PCI_QUIRK(0x103c, 0x8158, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
9197 	SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9198 	SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
9199 	SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
9200 	SND_PCI_QUIRK(0x103c, 0x827f, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9201 	SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9202 	SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9203 	SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9204 	SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9205 	SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9206 	SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
9207 	SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9208 	SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
9209 	SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9210 	SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9211 	SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
9212 	SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO),
9213 	SND_PCI_QUIRK(0x103c, 0x86e7, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9214 	SND_PCI_QUIRK(0x103c, 0x86e8, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9215 	SND_PCI_QUIRK(0x103c, 0x8716, "HP Elite Dragonfly G2 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9216 	SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9217 	SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
9218 	SND_PCI_QUIRK(0x103c, 0x8728, "HP EliteBook 840 G7", ALC285_FIXUP_HP_GPIO_LED),
9219 	SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
9220 	SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9221 	SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9222 	SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9223 	SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
9224 	SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
9225 	SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
9226 	SND_PCI_QUIRK(0x103c, 0x8780, "HP ZBook Fury 17 G7 Mobile Workstation",
9227 		      ALC285_FIXUP_HP_GPIO_AMP_INIT),
9228 	SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation",
9229 		      ALC285_FIXUP_HP_GPIO_AMP_INIT),
9230 	SND_PCI_QUIRK(0x103c, 0x8786, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
9231 	SND_PCI_QUIRK(0x103c, 0x8787, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
9232 	SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
9233 	SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
9234 	SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9235 	SND_PCI_QUIRK(0x103c, 0x87e7, "HP ProBook 450 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9236 	SND_PCI_QUIRK(0x103c, 0x87f1, "HP ProBook 630 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9237 	SND_PCI_QUIRK(0x103c, 0x87f2, "HP ProBook 640 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9238 	SND_PCI_QUIRK(0x103c, 0x87f4, "HP", ALC287_FIXUP_HP_GPIO_LED),
9239 	SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED),
9240 	SND_PCI_QUIRK(0x103c, 0x87f6, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
9241 	SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
9242 	SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9243 	SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9244 	SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9245 	SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9246 	SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9247 	SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9248 	SND_PCI_QUIRK(0x103c, 0x884b, "HP EliteBook 840 Aero G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9249 	SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9250 	SND_PCI_QUIRK(0x103c, 0x8862, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9251 	SND_PCI_QUIRK(0x103c, 0x8863, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9252 	SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9253 	SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9254 	SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9255 	SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED),
9256 	SND_PCI_QUIRK(0x103c, 0x8895, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED),
9257 	SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
9258 	SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9259 	SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
9260 	SND_PCI_QUIRK(0x103c, 0x896e, "HP EliteBook x360 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9261 	SND_PCI_QUIRK(0x103c, 0x8971, "HP EliteBook 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9262 	SND_PCI_QUIRK(0x103c, 0x8972, "HP EliteBook 840 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9263 	SND_PCI_QUIRK(0x103c, 0x8973, "HP EliteBook 860 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9264 	SND_PCI_QUIRK(0x103c, 0x8974, "HP EliteBook 840 Aero G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9265 	SND_PCI_QUIRK(0x103c, 0x8975, "HP EliteBook x360 840 Aero G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9266 	SND_PCI_QUIRK(0x103c, 0x8981, "HP Elite Dragonfly G3", ALC245_FIXUP_CS35L41_SPI_4),
9267 	SND_PCI_QUIRK(0x103c, 0x898e, "HP EliteBook 835 G9", ALC287_FIXUP_CS35L41_I2C_2),
9268 	SND_PCI_QUIRK(0x103c, 0x898f, "HP EliteBook 835 G9", ALC287_FIXUP_CS35L41_I2C_2),
9269 	SND_PCI_QUIRK(0x103c, 0x8991, "HP EliteBook 845 G9", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED),
9270 	SND_PCI_QUIRK(0x103c, 0x8992, "HP EliteBook 845 G9", ALC287_FIXUP_CS35L41_I2C_2),
9271 	SND_PCI_QUIRK(0x103c, 0x8994, "HP EliteBook 855 G9", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED),
9272 	SND_PCI_QUIRK(0x103c, 0x8995, "HP EliteBook 855 G9", ALC287_FIXUP_CS35L41_I2C_2),
9273 	SND_PCI_QUIRK(0x103c, 0x89a4, "HP ProBook 440 G9", ALC236_FIXUP_HP_GPIO_LED),
9274 	SND_PCI_QUIRK(0x103c, 0x89a6, "HP ProBook 450 G9", ALC236_FIXUP_HP_GPIO_LED),
9275 	SND_PCI_QUIRK(0x103c, 0x89aa, "HP EliteBook 630 G9", ALC236_FIXUP_HP_GPIO_LED),
9276 	SND_PCI_QUIRK(0x103c, 0x89ac, "HP EliteBook 640 G9", ALC236_FIXUP_HP_GPIO_LED),
9277 	SND_PCI_QUIRK(0x103c, 0x89ae, "HP EliteBook 650 G9", ALC236_FIXUP_HP_GPIO_LED),
9278 	SND_PCI_QUIRK(0x103c, 0x89c3, "Zbook Studio G9", ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED),
9279 	SND_PCI_QUIRK(0x103c, 0x89c6, "Zbook Fury 17 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9280 	SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9281 	SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9282 	SND_PCI_QUIRK(0x103c, 0x8aa0, "HP ProBook 440 G9 (MB 8A9E)", ALC236_FIXUP_HP_GPIO_LED),
9283 	SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED),
9284 	SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED),
9285 	SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED),
9286 	SND_PCI_QUIRK(0x103c, 0x8ad1, "HP EliteBook 840 14 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9287 	SND_PCI_QUIRK(0x103c, 0x8ad2, "HP EliteBook 860 16 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
9288 	SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
9289 	SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
9290 	SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9291 	SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
9292 	SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
9293 	SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9294 	SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9295 	SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9296 	SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9297 	SND_PCI_QUIRK(0x1043, 0x1271, "ASUS X430UN", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
9298 	SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9299 	SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9300 	SND_PCI_QUIRK(0x1043, 0x12af, "ASUS UX582ZS", ALC245_FIXUP_CS35L41_SPI_2),
9301 	SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
9302 	SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
9303 	SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE),
9304 	SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
9305 	SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
9306 	SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
9307 	SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
9308 	SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS),
9309 	SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
9310 	SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK),
9311 	SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
9312 	SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
9313 	SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
9314 	SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE),
9315 	SND_PCI_QUIRK(0x1043, 0x1970, "ASUS UX550VE", ALC289_FIXUP_ASUS_GA401),
9316 	SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE),
9317 	SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
9318 	SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
9319 	SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
9320 	SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
9321 	SND_PCI_QUIRK(0x1043, 0x1a8f, "ASUS UX582ZS", ALC245_FIXUP_CS35L41_SPI_2),
9322 	SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
9323 	SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
9324 	SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9325 	SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9326 	SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
9327 	SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
9328 	SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
9329 	SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS),
9330 	SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
9331 	SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
9332 	SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401),
9333 	SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
9334 	SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
9335 	SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
9336 	SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
9337 	SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
9338 	SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
9339 	SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
9340 	SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
9341 	SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
9342 	SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
9343 	SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
9344 	SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9345 	SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9346 	SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
9347 	SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
9348 	SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
9349 	SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
9350 	SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
9351 	SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
9352 	SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
9353 	SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
9354 	SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9355 	SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9356 	SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9357 	SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
9358 	SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
9359 	SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9360 	SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_AMP),
9361 	SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_AMP),
9362 	SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9363 	SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
9364 	SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_AMP),
9365 	SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
9366 	SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9367 	SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
9368 	SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
9369 	SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
9370 	SND_PCI_QUIRK(0x152d, 0x1082, "Quanta NL3", ALC269_FIXUP_LIFEBOOK),
9371 	SND_PCI_QUIRK(0x1558, 0x1323, "Clevo N130ZU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9372 	SND_PCI_QUIRK(0x1558, 0x1325, "Clevo N15[01][CW]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9373 	SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9374 	SND_PCI_QUIRK(0x1558, 0x1403, "Clevo N140CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9375 	SND_PCI_QUIRK(0x1558, 0x1404, "Clevo N150CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9376 	SND_PCI_QUIRK(0x1558, 0x14a1, "Clevo L141MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9377 	SND_PCI_QUIRK(0x1558, 0x4018, "Clevo NV40M[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9378 	SND_PCI_QUIRK(0x1558, 0x4019, "Clevo NV40MZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9379 	SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9380 	SND_PCI_QUIRK(0x1558, 0x4041, "Clevo NV4[15]PZ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9381 	SND_PCI_QUIRK(0x1558, 0x40a1, "Clevo NL40GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9382 	SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9383 	SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9384 	SND_PCI_QUIRK(0x1558, 0x5015, "Clevo NH5[58]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9385 	SND_PCI_QUIRK(0x1558, 0x5017, "Clevo NH7[79]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9386 	SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9387 	SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9388 	SND_PCI_QUIRK(0x1558, 0x50b6, "Clevo NK50S5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9389 	SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9390 	SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9391 	SND_PCI_QUIRK(0x1558, 0x50e1, "Clevo NH5[58]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9392 	SND_PCI_QUIRK(0x1558, 0x50e2, "Clevo NH7[79]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9393 	SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9394 	SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9395 	SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9396 	SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9397 	SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9398 	SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9399 	SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9400 	SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9401 	SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9402 	SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9403 	SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9404 	SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9405 	SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9406 	SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9407 	SND_PCI_QUIRK(0x1558, 0x7716, "Clevo NS50PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9408 	SND_PCI_QUIRK(0x1558, 0x7717, "Clevo NS70PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9409 	SND_PCI_QUIRK(0x1558, 0x7718, "Clevo L140PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9410 	SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9411 	SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9412 	SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9413 	SND_PCI_QUIRK(0x1558, 0x8535, "Clevo NH50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9414 	SND_PCI_QUIRK(0x1558, 0x8536, "Clevo NH79D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9415 	SND_PCI_QUIRK(0x1558, 0x8550, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9416 	SND_PCI_QUIRK(0x1558, 0x8551, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9417 	SND_PCI_QUIRK(0x1558, 0x8560, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
9418 	SND_PCI_QUIRK(0x1558, 0x8561, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
9419 	SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
9420 	SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9421 	SND_PCI_QUIRK(0x1558, 0x866d, "Clevo NP5[05]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9422 	SND_PCI_QUIRK(0x1558, 0x867c, "Clevo NP7[01]PNP", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9423 	SND_PCI_QUIRK(0x1558, 0x867d, "Clevo NP7[01]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9424 	SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9425 	SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME),
9426 	SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9427 	SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9428 	SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9429 	SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9430 	SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9431 	SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9432 	SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9433 	SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL5[03]RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9434 	SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL50NU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9435 	SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9436 	SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9437 	SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9438 	SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9439 	SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9440 	SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9441 	SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
9442 	SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
9443 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
9444 	SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
9445 	SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
9446 	SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
9447 	SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
9448 	SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
9449 	SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
9450 	SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
9451 	SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
9452 	SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
9453 	SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
9454 	SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
9455 	SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
9456 	SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
9457 	SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
9458 	SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
9459 	SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
9460 	SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9461 	SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
9462 	SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
9463 	SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
9464 	SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9465 	SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9466 	SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
9467 	SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
9468 	SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
9469 	SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9470 	SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9471 	SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
9472 	SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9473 	SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9474 	SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9475 	SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9476 	SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
9477 	SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
9478 	SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
9479 	SND_PCI_QUIRK(0x17aa, 0x22c2, "Thinkpad X1 Extreme Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
9480 	SND_PCI_QUIRK(0x17aa, 0x22f1, "Thinkpad", ALC287_FIXUP_CS35L41_I2C_2),
9481 	SND_PCI_QUIRK(0x17aa, 0x22f2, "Thinkpad", ALC287_FIXUP_CS35L41_I2C_2),
9482 	SND_PCI_QUIRK(0x17aa, 0x22f3, "Thinkpad", ALC287_FIXUP_CS35L41_I2C_2),
9483 	SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
9484 	SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
9485 	SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9486 	SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9487 	SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9488 	SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9489 	SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9490 	SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9491 	SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9492 	SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9493 	SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
9494 	SND_PCI_QUIRK(0x17aa, 0x3801, "Lenovo Yoga9 14IAP7", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
9495 	SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo Yoga DuetITL 2021", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9496 	SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9497 	SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940 / Yoga Duet 7", ALC298_FIXUP_LENOVO_C940_DUET7),
9498 	SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
9499 	SND_PCI_QUIRK(0x17aa, 0x3820, "Yoga Duet 7 13ITL6", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9500 	SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
9501 	SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
9502 	SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9503 	SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
9504 	SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
9505 	SND_PCI_QUIRK(0x17aa, 0x3847, "Legion 7 16ACHG6", ALC287_FIXUP_LEGION_16ACHG6),
9506 	SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9507 	SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9508 	SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9509 	SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
9510 	SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
9511 	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
9512 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
9513 	SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9514 	SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
9515 	SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
9516 	SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9517 	SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
9518 	SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
9519 	SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
9520 	SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
9521 	SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
9522 	SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
9523 	SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
9524 	SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
9525 	SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9526 	SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9527 	SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9528 	SND_PCI_QUIRK(0x17aa, 0x508b, "Thinkpad X12 Gen 1", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9529 	SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9530 	SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9531 	SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9532 	SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
9533 	SND_PCI_QUIRK(0x1849, 0x1233, "ASRock NUC Box 1100", ALC233_FIXUP_NO_AUDIO_JACK),
9534 	SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
9535 	SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20),
9536 	SND_PCI_QUIRK(0x1b35, 0x1236, "CZC TMI", ALC269_FIXUP_CZC_TMI),
9537 	SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
9538 	SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
9539 	SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
9540 	SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
9541 	SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_SET_COEF_DEFAULTS),
9542 	SND_PCI_QUIRK(0x1d05, 0x1096, "TongFang GMxMRxx", ALC269_FIXUP_NO_SHUTUP),
9543 	SND_PCI_QUIRK(0x1d05, 0x1100, "TongFang GKxNRxx", ALC269_FIXUP_NO_SHUTUP),
9544 	SND_PCI_QUIRK(0x1d05, 0x1111, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9545 	SND_PCI_QUIRK(0x1d05, 0x1119, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9546 	SND_PCI_QUIRK(0x1d05, 0x1129, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9547 	SND_PCI_QUIRK(0x1d05, 0x1147, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
9548 	SND_PCI_QUIRK(0x1d05, 0x115c, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
9549 	SND_PCI_QUIRK(0x1d05, 0x121b, "TongFang GMxAGxx", ALC269_FIXUP_NO_SHUTUP),
9550 	SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
9551 	SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
9552 	SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
9553 	SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC),
9554 	SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
9555 	SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
9556 	SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
9557 	SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10),
9558 	SND_PCI_QUIRK(0xf111, 0x0001, "Framework Laptop", ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE),
9559 
9560 #if 0
9561 	/* Below is a quirk table taken from the old code.
9562 	 * Basically the device should work as is without the fixup table.
9563 	 * If BIOS doesn't give a proper info, enable the corresponding
9564 	 * fixup entry.
9565 	 */
9566 	SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
9567 		      ALC269_FIXUP_AMIC),
9568 	SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
9569 	SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
9570 	SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
9571 	SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
9572 	SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
9573 	SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
9574 	SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
9575 	SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
9576 	SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
9577 	SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
9578 	SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
9579 	SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
9580 	SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
9581 	SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
9582 	SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
9583 	SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
9584 	SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
9585 	SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
9586 	SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
9587 	SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
9588 	SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
9589 	SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
9590 	SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
9591 	SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
9592 	SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
9593 	SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
9594 	SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
9595 	SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
9596 	SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
9597 	SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
9598 	SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
9599 	SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
9600 	SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
9601 	SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
9602 	SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
9603 	SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
9604 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
9605 	SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
9606 	SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
9607 #endif
9608 	{}
9609 };
9610 
9611 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
9612 	SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
9613 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
9614 	SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
9615 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
9616 	SND_PCI_QUIRK_VENDOR(0x19e5, "Huawei Matebook", ALC255_FIXUP_MIC_MUTE_LED),
9617 	{}
9618 };
9619 
9620 static const struct hda_model_fixup alc269_fixup_models[] = {
9621 	{.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
9622 	{.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
9623 	{.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
9624 	{.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
9625 	{.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
9626 	{.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
9627 	{.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
9628 	{.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
9629 	{.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9630 	{.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
9631 	{.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9632 	{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
9633 	{.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
9634 	{.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
9635 	{.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
9636 	{.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
9637 	{.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
9638 	{.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
9639 	{.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
9640 	{.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
9641 	{.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
9642 	{.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
9643 	{.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
9644 	{.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
9645 	{.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
9646 	{.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
9647 	{.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
9648 	{.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
9649 	{.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
9650 	{.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
9651 	{.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
9652 	{.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
9653 	{.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
9654 	{.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
9655 	{.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
9656 	{.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
9657 	{.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
9658 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
9659 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
9660 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
9661 	{.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
9662 	{.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
9663 	{.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
9664 	{.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
9665 	{.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
9666 	{.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
9667 	{.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
9668 	{.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
9669 	{.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
9670 	{.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
9671 	{.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
9672 	{.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
9673 	{.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
9674 	{.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
9675 	{.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
9676 	{.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
9677 	{.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
9678 	{.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
9679 	{.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
9680 	{.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
9681 	{.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
9682 	{.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
9683 	{.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
9684 	{.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
9685 	{.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
9686 	{.id = ALC255_FIXUP_MIC_MUTE_LED, .name = "alc255-dell-mute"},
9687 	{.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
9688 	{.id = ALC269VB_FIXUP_ASPIRE_E1_COEF, .name = "aspire-e1-coef"},
9689 	{.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
9690 	{.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9691 	{.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
9692 	{.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
9693 	{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
9694 	{.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
9695 	{.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
9696 	{.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
9697 	{.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
9698 	{.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
9699 	{.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
9700 	{.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
9701 	{.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
9702 	{.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
9703 	{.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
9704 	{.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
9705 	{.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
9706 	{.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
9707 	{.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
9708 	{.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
9709 	{.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
9710 	{.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
9711 	{.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
9712 	{.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
9713 	{.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
9714 	{.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
9715 	{.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
9716 	{.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
9717 	{.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
9718 	{.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
9719 	{.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
9720 	{.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
9721 	{.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
9722 	{.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
9723 	{.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
9724 	{.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
9725 	{.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
9726 	{.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
9727 	{.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
9728 	{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
9729 	{.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
9730 	{.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
9731 	{.id = ALC298_FIXUP_SAMSUNG_AMP, .name = "alc298-samsung-amp"},
9732 	{.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
9733 	{.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
9734 	{.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
9735 	{.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
9736 	{.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
9737 	{.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
9738 	{.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"},
9739 	{.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
9740 	{.id = ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN, .name = "alc287-yoga9-bass-spk-pin"},
9741 	{.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
9742 	{.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
9743 	{.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"},
9744 	{}
9745 };
9746 #define ALC225_STANDARD_PINS \
9747 	{0x21, 0x04211020}
9748 
9749 #define ALC256_STANDARD_PINS \
9750 	{0x12, 0x90a60140}, \
9751 	{0x14, 0x90170110}, \
9752 	{0x21, 0x02211020}
9753 
9754 #define ALC282_STANDARD_PINS \
9755 	{0x14, 0x90170110}
9756 
9757 #define ALC290_STANDARD_PINS \
9758 	{0x12, 0x99a30130}
9759 
9760 #define ALC292_STANDARD_PINS \
9761 	{0x14, 0x90170110}, \
9762 	{0x15, 0x0221401f}
9763 
9764 #define ALC295_STANDARD_PINS \
9765 	{0x12, 0xb7a60130}, \
9766 	{0x14, 0x90170110}, \
9767 	{0x21, 0x04211020}
9768 
9769 #define ALC298_STANDARD_PINS \
9770 	{0x12, 0x90a60130}, \
9771 	{0x21, 0x03211020}
9772 
9773 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
9774 	SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
9775 		{0x14, 0x01014020},
9776 		{0x17, 0x90170110},
9777 		{0x18, 0x02a11030},
9778 		{0x19, 0x0181303F},
9779 		{0x21, 0x0221102f}),
9780 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
9781 		{0x12, 0x90a601c0},
9782 		{0x14, 0x90171120},
9783 		{0x21, 0x02211030}),
9784 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9785 		{0x14, 0x90170110},
9786 		{0x1b, 0x90a70130},
9787 		{0x21, 0x03211020}),
9788 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9789 		{0x1a, 0x90a70130},
9790 		{0x1b, 0x90170110},
9791 		{0x21, 0x03211020}),
9792 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9793 		ALC225_STANDARD_PINS,
9794 		{0x12, 0xb7a60130},
9795 		{0x14, 0x901701a0}),
9796 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9797 		ALC225_STANDARD_PINS,
9798 		{0x12, 0xb7a60130},
9799 		{0x14, 0x901701b0}),
9800 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9801 		ALC225_STANDARD_PINS,
9802 		{0x12, 0xb7a60150},
9803 		{0x14, 0x901701a0}),
9804 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9805 		ALC225_STANDARD_PINS,
9806 		{0x12, 0xb7a60150},
9807 		{0x14, 0x901701b0}),
9808 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9809 		ALC225_STANDARD_PINS,
9810 		{0x12, 0xb7a60130},
9811 		{0x1b, 0x90170110}),
9812 	SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9813 		{0x1b, 0x01111010},
9814 		{0x1e, 0x01451130},
9815 		{0x21, 0x02211020}),
9816 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
9817 		{0x12, 0x90a60140},
9818 		{0x14, 0x90170110},
9819 		{0x19, 0x02a11030},
9820 		{0x21, 0x02211020}),
9821 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9822 		{0x14, 0x90170110},
9823 		{0x19, 0x02a11030},
9824 		{0x1a, 0x02a11040},
9825 		{0x1b, 0x01014020},
9826 		{0x21, 0x0221101f}),
9827 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9828 		{0x14, 0x90170110},
9829 		{0x19, 0x02a11030},
9830 		{0x1a, 0x02a11040},
9831 		{0x1b, 0x01011020},
9832 		{0x21, 0x0221101f}),
9833 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9834 		{0x14, 0x90170110},
9835 		{0x19, 0x02a11020},
9836 		{0x1a, 0x02a11030},
9837 		{0x21, 0x0221101f}),
9838 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
9839 		{0x21, 0x02211010}),
9840 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9841 		{0x14, 0x90170110},
9842 		{0x19, 0x02a11020},
9843 		{0x21, 0x02211030}),
9844 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9845 		{0x14, 0x90170110},
9846 		{0x21, 0x02211020}),
9847 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9848 		{0x14, 0x90170130},
9849 		{0x21, 0x02211040}),
9850 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9851 		{0x12, 0x90a60140},
9852 		{0x14, 0x90170110},
9853 		{0x21, 0x02211020}),
9854 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9855 		{0x12, 0x90a60160},
9856 		{0x14, 0x90170120},
9857 		{0x21, 0x02211030}),
9858 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9859 		{0x14, 0x90170110},
9860 		{0x1b, 0x02011020},
9861 		{0x21, 0x0221101f}),
9862 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9863 		{0x14, 0x90170110},
9864 		{0x1b, 0x01011020},
9865 		{0x21, 0x0221101f}),
9866 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9867 		{0x14, 0x90170130},
9868 		{0x1b, 0x01014020},
9869 		{0x21, 0x0221103f}),
9870 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9871 		{0x14, 0x90170130},
9872 		{0x1b, 0x01011020},
9873 		{0x21, 0x0221103f}),
9874 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9875 		{0x14, 0x90170130},
9876 		{0x1b, 0x02011020},
9877 		{0x21, 0x0221103f}),
9878 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9879 		{0x14, 0x90170150},
9880 		{0x1b, 0x02011020},
9881 		{0x21, 0x0221105f}),
9882 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9883 		{0x14, 0x90170110},
9884 		{0x1b, 0x01014020},
9885 		{0x21, 0x0221101f}),
9886 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9887 		{0x12, 0x90a60160},
9888 		{0x14, 0x90170120},
9889 		{0x17, 0x90170140},
9890 		{0x21, 0x0321102f}),
9891 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9892 		{0x12, 0x90a60160},
9893 		{0x14, 0x90170130},
9894 		{0x21, 0x02211040}),
9895 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9896 		{0x12, 0x90a60160},
9897 		{0x14, 0x90170140},
9898 		{0x21, 0x02211050}),
9899 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9900 		{0x12, 0x90a60170},
9901 		{0x14, 0x90170120},
9902 		{0x21, 0x02211030}),
9903 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9904 		{0x12, 0x90a60170},
9905 		{0x14, 0x90170130},
9906 		{0x21, 0x02211040}),
9907 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9908 		{0x12, 0x90a60170},
9909 		{0x14, 0x90171130},
9910 		{0x21, 0x02211040}),
9911 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9912 		{0x12, 0x90a60170},
9913 		{0x14, 0x90170140},
9914 		{0x21, 0x02211050}),
9915 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9916 		{0x12, 0x90a60180},
9917 		{0x14, 0x90170130},
9918 		{0x21, 0x02211040}),
9919 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9920 		{0x12, 0x90a60180},
9921 		{0x14, 0x90170120},
9922 		{0x21, 0x02211030}),
9923 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9924 		{0x1b, 0x01011020},
9925 		{0x21, 0x02211010}),
9926 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9927 		{0x14, 0x90170110},
9928 		{0x1b, 0x90a70130},
9929 		{0x21, 0x04211020}),
9930 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9931 		{0x14, 0x90170110},
9932 		{0x1b, 0x90a70130},
9933 		{0x21, 0x03211020}),
9934 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9935 		{0x12, 0x90a60130},
9936 		{0x14, 0x90170110},
9937 		{0x21, 0x03211020}),
9938 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9939 		{0x12, 0x90a60130},
9940 		{0x14, 0x90170110},
9941 		{0x21, 0x04211020}),
9942 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9943 		{0x1a, 0x90a70130},
9944 		{0x1b, 0x90170110},
9945 		{0x21, 0x03211020}),
9946        SND_HDA_PIN_QUIRK(0x10ec0256, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9947 		{0x14, 0x90170110},
9948 		{0x19, 0x02a11020},
9949 		{0x21, 0x0221101f}),
9950        SND_HDA_PIN_QUIRK(0x10ec0274, 0x103c, "HP", ALC274_FIXUP_HP_HEADSET_MIC,
9951 		{0x17, 0x90170110},
9952 		{0x19, 0x03a11030},
9953 		{0x21, 0x03211020}),
9954 	SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
9955 		{0x12, 0x90a60130},
9956 		{0x14, 0x90170110},
9957 		{0x15, 0x0421101f},
9958 		{0x1a, 0x04a11020}),
9959 	SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
9960 		{0x12, 0x90a60140},
9961 		{0x14, 0x90170110},
9962 		{0x15, 0x0421101f},
9963 		{0x18, 0x02811030},
9964 		{0x1a, 0x04a1103f},
9965 		{0x1b, 0x02011020}),
9966 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9967 		ALC282_STANDARD_PINS,
9968 		{0x12, 0x99a30130},
9969 		{0x19, 0x03a11020},
9970 		{0x21, 0x0321101f}),
9971 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9972 		ALC282_STANDARD_PINS,
9973 		{0x12, 0x99a30130},
9974 		{0x19, 0x03a11020},
9975 		{0x21, 0x03211040}),
9976 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9977 		ALC282_STANDARD_PINS,
9978 		{0x12, 0x99a30130},
9979 		{0x19, 0x03a11030},
9980 		{0x21, 0x03211020}),
9981 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9982 		ALC282_STANDARD_PINS,
9983 		{0x12, 0x99a30130},
9984 		{0x19, 0x04a11020},
9985 		{0x21, 0x0421101f}),
9986 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
9987 		ALC282_STANDARD_PINS,
9988 		{0x12, 0x90a60140},
9989 		{0x19, 0x04a11030},
9990 		{0x21, 0x04211020}),
9991 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9992 		ALC282_STANDARD_PINS,
9993 		{0x12, 0x90a609c0},
9994 		{0x18, 0x03a11830},
9995 		{0x19, 0x04a19831},
9996 		{0x1a, 0x0481303f},
9997 		{0x1b, 0x04211020},
9998 		{0x21, 0x0321101f}),
9999 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
10000 		ALC282_STANDARD_PINS,
10001 		{0x12, 0x90a60940},
10002 		{0x18, 0x03a11830},
10003 		{0x19, 0x04a19831},
10004 		{0x1a, 0x0481303f},
10005 		{0x1b, 0x04211020},
10006 		{0x21, 0x0321101f}),
10007 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
10008 		ALC282_STANDARD_PINS,
10009 		{0x12, 0x90a60130},
10010 		{0x21, 0x0321101f}),
10011 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
10012 		{0x12, 0x90a60160},
10013 		{0x14, 0x90170120},
10014 		{0x21, 0x02211030}),
10015 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
10016 		ALC282_STANDARD_PINS,
10017 		{0x12, 0x90a60130},
10018 		{0x19, 0x03a11020},
10019 		{0x21, 0x0321101f}),
10020 	SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
10021 		{0x12, 0x90a60130},
10022 		{0x14, 0x90170110},
10023 		{0x19, 0x04a11040},
10024 		{0x21, 0x04211020}),
10025 	SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
10026 		{0x14, 0x90170110},
10027 		{0x19, 0x04a11040},
10028 		{0x1d, 0x40600001},
10029 		{0x21, 0x04211020}),
10030 	SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
10031 		{0x14, 0x90170110},
10032 		{0x19, 0x04a11040},
10033 		{0x21, 0x04211020}),
10034 	SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_HEADSET_JACK,
10035 		{0x14, 0x90170110},
10036 		{0x17, 0x90170111},
10037 		{0x19, 0x03a11030},
10038 		{0x21, 0x03211020}),
10039 	SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
10040 		{0x12, 0x90a60130},
10041 		{0x17, 0x90170110},
10042 		{0x21, 0x02211020}),
10043 	SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
10044 		{0x12, 0x90a60120},
10045 		{0x14, 0x90170110},
10046 		{0x21, 0x0321101f}),
10047 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10048 		ALC290_STANDARD_PINS,
10049 		{0x15, 0x04211040},
10050 		{0x18, 0x90170112},
10051 		{0x1a, 0x04a11020}),
10052 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10053 		ALC290_STANDARD_PINS,
10054 		{0x15, 0x04211040},
10055 		{0x18, 0x90170110},
10056 		{0x1a, 0x04a11020}),
10057 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10058 		ALC290_STANDARD_PINS,
10059 		{0x15, 0x0421101f},
10060 		{0x1a, 0x04a11020}),
10061 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10062 		ALC290_STANDARD_PINS,
10063 		{0x15, 0x04211020},
10064 		{0x1a, 0x04a11040}),
10065 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10066 		ALC290_STANDARD_PINS,
10067 		{0x14, 0x90170110},
10068 		{0x15, 0x04211020},
10069 		{0x1a, 0x04a11040}),
10070 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10071 		ALC290_STANDARD_PINS,
10072 		{0x14, 0x90170110},
10073 		{0x15, 0x04211020},
10074 		{0x1a, 0x04a11020}),
10075 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
10076 		ALC290_STANDARD_PINS,
10077 		{0x14, 0x90170110},
10078 		{0x15, 0x0421101f},
10079 		{0x1a, 0x04a11020}),
10080 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
10081 		ALC292_STANDARD_PINS,
10082 		{0x12, 0x90a60140},
10083 		{0x16, 0x01014020},
10084 		{0x19, 0x01a19030}),
10085 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
10086 		ALC292_STANDARD_PINS,
10087 		{0x12, 0x90a60140},
10088 		{0x16, 0x01014020},
10089 		{0x18, 0x02a19031},
10090 		{0x19, 0x01a1903e}),
10091 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
10092 		ALC292_STANDARD_PINS,
10093 		{0x12, 0x90a60140}),
10094 	SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
10095 		ALC292_STANDARD_PINS,
10096 		{0x13, 0x90a60140},
10097 		{0x16, 0x21014020},
10098 		{0x19, 0x21a19030}),
10099 	SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
10100 		ALC292_STANDARD_PINS,
10101 		{0x13, 0x90a60140}),
10102 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_HPE,
10103 		{0x17, 0x90170110},
10104 		{0x21, 0x04211020}),
10105 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
10106 		{0x14, 0x90170110},
10107 		{0x1b, 0x90a70130},
10108 		{0x21, 0x04211020}),
10109 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
10110 		{0x12, 0x90a60130},
10111 		{0x17, 0x90170110},
10112 		{0x21, 0x03211020}),
10113 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
10114 		{0x12, 0x90a60130},
10115 		{0x17, 0x90170110},
10116 		{0x21, 0x04211020}),
10117 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
10118 		{0x12, 0x90a60130},
10119 		{0x17, 0x90170110},
10120 		{0x21, 0x03211020}),
10121 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
10122 		{0x12, 0x90a60120},
10123 		{0x17, 0x90170110},
10124 		{0x21, 0x04211030}),
10125 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
10126 		{0x12, 0x90a60130},
10127 		{0x17, 0x90170110},
10128 		{0x21, 0x03211020}),
10129 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
10130 		{0x12, 0x90a60130},
10131 		{0x17, 0x90170110},
10132 		{0x21, 0x03211020}),
10133 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10134 		{0x14, 0x90170110},
10135 		{0x21, 0x04211020}),
10136 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10137 		{0x14, 0x90170110},
10138 		{0x21, 0x04211030}),
10139 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
10140 		ALC295_STANDARD_PINS,
10141 		{0x17, 0x21014020},
10142 		{0x18, 0x21a19030}),
10143 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
10144 		ALC295_STANDARD_PINS,
10145 		{0x17, 0x21014040},
10146 		{0x18, 0x21a19050}),
10147 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
10148 		ALC295_STANDARD_PINS),
10149 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
10150 		ALC298_STANDARD_PINS,
10151 		{0x17, 0x90170110}),
10152 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
10153 		ALC298_STANDARD_PINS,
10154 		{0x17, 0x90170140}),
10155 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
10156 		ALC298_STANDARD_PINS,
10157 		{0x17, 0x90170150}),
10158 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
10159 		{0x12, 0xb7a60140},
10160 		{0x13, 0xb7a60150},
10161 		{0x17, 0x90170110},
10162 		{0x1a, 0x03011020},
10163 		{0x21, 0x03211030}),
10164 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
10165 		{0x12, 0xb7a60140},
10166 		{0x17, 0x90170110},
10167 		{0x1a, 0x03a11030},
10168 		{0x21, 0x03211020}),
10169 	SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10170 		ALC225_STANDARD_PINS,
10171 		{0x12, 0xb7a60130},
10172 		{0x17, 0x90170110}),
10173 	SND_HDA_PIN_QUIRK(0x10ec0623, 0x17aa, "Lenovo", ALC283_FIXUP_HEADSET_MIC,
10174 		{0x14, 0x01014010},
10175 		{0x17, 0x90170120},
10176 		{0x18, 0x02a11030},
10177 		{0x19, 0x02a1103f},
10178 		{0x21, 0x0221101f}),
10179 	{}
10180 };
10181 
10182 /* This is the fallback pin_fixup_tbl for alc269 family, to make the tbl match
10183  * more machines, don't need to match all valid pins, just need to match
10184  * all the pins defined in the tbl. Just because of this reason, it is possible
10185  * that a single machine matches multiple tbls, so there is one limitation:
10186  *   at most one tbl is allowed to define for the same vendor and same codec
10187  */
10188 static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
10189 	SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10190 		{0x19, 0x40000000},
10191 		{0x1b, 0x40000000}),
10192 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
10193 		{0x19, 0x40000000},
10194 		{0x1a, 0x40000000}),
10195 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
10196 		{0x19, 0x40000000},
10197 		{0x1a, 0x40000000}),
10198 	SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
10199 		{0x19, 0x40000000},
10200 		{0x1a, 0x40000000}),
10201 	{}
10202 };
10203 
alc269_fill_coef(struct hda_codec * codec)10204 static void alc269_fill_coef(struct hda_codec *codec)
10205 {
10206 	struct alc_spec *spec = codec->spec;
10207 	int val;
10208 
10209 	if (spec->codec_variant != ALC269_TYPE_ALC269VB)
10210 		return;
10211 
10212 	if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
10213 		alc_write_coef_idx(codec, 0xf, 0x960b);
10214 		alc_write_coef_idx(codec, 0xe, 0x8817);
10215 	}
10216 
10217 	if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
10218 		alc_write_coef_idx(codec, 0xf, 0x960b);
10219 		alc_write_coef_idx(codec, 0xe, 0x8814);
10220 	}
10221 
10222 	if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
10223 		/* Power up output pin */
10224 		alc_update_coef_idx(codec, 0x04, 0, 1<<11);
10225 	}
10226 
10227 	if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
10228 		val = alc_read_coef_idx(codec, 0xd);
10229 		if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
10230 			/* Capless ramp up clock control */
10231 			alc_write_coef_idx(codec, 0xd, val | (1<<10));
10232 		}
10233 		val = alc_read_coef_idx(codec, 0x17);
10234 		if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
10235 			/* Class D power on reset */
10236 			alc_write_coef_idx(codec, 0x17, val | (1<<7));
10237 		}
10238 	}
10239 
10240 	/* HP */
10241 	alc_update_coef_idx(codec, 0x4, 0, 1<<11);
10242 }
10243 
10244 /*
10245  */
patch_alc269(struct hda_codec * codec)10246 static int patch_alc269(struct hda_codec *codec)
10247 {
10248 	struct alc_spec *spec;
10249 	int err;
10250 
10251 	err = alc_alloc_spec(codec, 0x0b);
10252 	if (err < 0)
10253 		return err;
10254 
10255 	spec = codec->spec;
10256 	spec->gen.shared_mic_vref_pin = 0x18;
10257 	codec->power_save_node = 0;
10258 
10259 #ifdef CONFIG_PM
10260 	codec->patch_ops.suspend = alc269_suspend;
10261 	codec->patch_ops.resume = alc269_resume;
10262 #endif
10263 	spec->shutup = alc_default_shutup;
10264 	spec->init_hook = alc_default_init;
10265 
10266 	switch (codec->core.vendor_id) {
10267 	case 0x10ec0269:
10268 		spec->codec_variant = ALC269_TYPE_ALC269VA;
10269 		switch (alc_get_coef0(codec) & 0x00f0) {
10270 		case 0x0010:
10271 			if (codec->bus->pci &&
10272 			    codec->bus->pci->subsystem_vendor == 0x1025 &&
10273 			    spec->cdefine.platform_type == 1)
10274 				err = alc_codec_rename(codec, "ALC271X");
10275 			spec->codec_variant = ALC269_TYPE_ALC269VB;
10276 			break;
10277 		case 0x0020:
10278 			if (codec->bus->pci &&
10279 			    codec->bus->pci->subsystem_vendor == 0x17aa &&
10280 			    codec->bus->pci->subsystem_device == 0x21f3)
10281 				err = alc_codec_rename(codec, "ALC3202");
10282 			spec->codec_variant = ALC269_TYPE_ALC269VC;
10283 			break;
10284 		case 0x0030:
10285 			spec->codec_variant = ALC269_TYPE_ALC269VD;
10286 			break;
10287 		default:
10288 			alc_fix_pll_init(codec, 0x20, 0x04, 15);
10289 		}
10290 		if (err < 0)
10291 			goto error;
10292 		spec->shutup = alc269_shutup;
10293 		spec->init_hook = alc269_fill_coef;
10294 		alc269_fill_coef(codec);
10295 		break;
10296 
10297 	case 0x10ec0280:
10298 	case 0x10ec0290:
10299 		spec->codec_variant = ALC269_TYPE_ALC280;
10300 		break;
10301 	case 0x10ec0282:
10302 		spec->codec_variant = ALC269_TYPE_ALC282;
10303 		spec->shutup = alc282_shutup;
10304 		spec->init_hook = alc282_init;
10305 		break;
10306 	case 0x10ec0233:
10307 	case 0x10ec0283:
10308 		spec->codec_variant = ALC269_TYPE_ALC283;
10309 		spec->shutup = alc283_shutup;
10310 		spec->init_hook = alc283_init;
10311 		break;
10312 	case 0x10ec0284:
10313 	case 0x10ec0292:
10314 		spec->codec_variant = ALC269_TYPE_ALC284;
10315 		break;
10316 	case 0x10ec0293:
10317 		spec->codec_variant = ALC269_TYPE_ALC293;
10318 		break;
10319 	case 0x10ec0286:
10320 	case 0x10ec0288:
10321 		spec->codec_variant = ALC269_TYPE_ALC286;
10322 		break;
10323 	case 0x10ec0298:
10324 		spec->codec_variant = ALC269_TYPE_ALC298;
10325 		break;
10326 	case 0x10ec0235:
10327 	case 0x10ec0255:
10328 		spec->codec_variant = ALC269_TYPE_ALC255;
10329 		spec->shutup = alc256_shutup;
10330 		spec->init_hook = alc256_init;
10331 		break;
10332 	case 0x10ec0230:
10333 	case 0x10ec0236:
10334 	case 0x10ec0256:
10335 	case 0x19e58326:
10336 		spec->codec_variant = ALC269_TYPE_ALC256;
10337 		spec->shutup = alc256_shutup;
10338 		spec->init_hook = alc256_init;
10339 		spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
10340 		break;
10341 	case 0x10ec0257:
10342 		spec->codec_variant = ALC269_TYPE_ALC257;
10343 		spec->shutup = alc256_shutup;
10344 		spec->init_hook = alc256_init;
10345 		spec->gen.mixer_nid = 0;
10346 		break;
10347 	case 0x10ec0215:
10348 	case 0x10ec0245:
10349 	case 0x10ec0285:
10350 	case 0x10ec0289:
10351 		if (alc_get_coef0(codec) & 0x0010)
10352 			spec->codec_variant = ALC269_TYPE_ALC245;
10353 		else
10354 			spec->codec_variant = ALC269_TYPE_ALC215;
10355 		spec->shutup = alc225_shutup;
10356 		spec->init_hook = alc225_init;
10357 		spec->gen.mixer_nid = 0;
10358 		break;
10359 	case 0x10ec0225:
10360 	case 0x10ec0295:
10361 	case 0x10ec0299:
10362 		spec->codec_variant = ALC269_TYPE_ALC225;
10363 		spec->shutup = alc225_shutup;
10364 		spec->init_hook = alc225_init;
10365 		spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
10366 		break;
10367 	case 0x10ec0287:
10368 		spec->codec_variant = ALC269_TYPE_ALC287;
10369 		spec->shutup = alc225_shutup;
10370 		spec->init_hook = alc225_init;
10371 		spec->gen.mixer_nid = 0; /* no loopback on ALC287 */
10372 		break;
10373 	case 0x10ec0234:
10374 	case 0x10ec0274:
10375 	case 0x10ec0294:
10376 		spec->codec_variant = ALC269_TYPE_ALC294;
10377 		spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
10378 		alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
10379 		spec->init_hook = alc294_init;
10380 		break;
10381 	case 0x10ec0300:
10382 		spec->codec_variant = ALC269_TYPE_ALC300;
10383 		spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
10384 		break;
10385 	case 0x10ec0623:
10386 		spec->codec_variant = ALC269_TYPE_ALC623;
10387 		break;
10388 	case 0x10ec0700:
10389 	case 0x10ec0701:
10390 	case 0x10ec0703:
10391 	case 0x10ec0711:
10392 		spec->codec_variant = ALC269_TYPE_ALC700;
10393 		spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
10394 		alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
10395 		spec->init_hook = alc294_init;
10396 		break;
10397 
10398 	}
10399 
10400 	if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
10401 		spec->has_alc5505_dsp = 1;
10402 		spec->init_hook = alc5505_dsp_init;
10403 	}
10404 
10405 	alc_pre_init(codec);
10406 
10407 	snd_hda_pick_fixup(codec, alc269_fixup_models,
10408 		       alc269_fixup_tbl, alc269_fixups);
10409 	/* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
10410 	 * the quirk breaks the latter (bko#214101).
10411 	 * Clear the wrong entry.
10412 	 */
10413 	if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
10414 	    codec->core.vendor_id == 0x10ec0294) {
10415 		codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
10416 		codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
10417 	}
10418 
10419 	snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
10420 	snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
10421 	snd_hda_pick_fixup(codec, NULL,	alc269_fixup_vendor_tbl,
10422 			   alc269_fixups);
10423 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10424 
10425 	alc_auto_parse_customize_define(codec);
10426 
10427 	if (has_cdefine_beep(codec))
10428 		spec->gen.beep_nid = 0x01;
10429 
10430 	/* automatic parse from the BIOS config */
10431 	err = alc269_parse_auto_config(codec);
10432 	if (err < 0)
10433 		goto error;
10434 
10435 	if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
10436 		err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
10437 		if (err < 0)
10438 			goto error;
10439 	}
10440 
10441 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10442 
10443 	return 0;
10444 
10445  error:
10446 	alc_free(codec);
10447 	return err;
10448 }
10449 
10450 /*
10451  * ALC861
10452  */
10453 
alc861_parse_auto_config(struct hda_codec * codec)10454 static int alc861_parse_auto_config(struct hda_codec *codec)
10455 {
10456 	static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10457 	static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
10458 	return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
10459 }
10460 
10461 /* Pin config fixes */
10462 enum {
10463 	ALC861_FIXUP_FSC_AMILO_PI1505,
10464 	ALC861_FIXUP_AMP_VREF_0F,
10465 	ALC861_FIXUP_NO_JACK_DETECT,
10466 	ALC861_FIXUP_ASUS_A6RP,
10467 	ALC660_FIXUP_ASUS_W7J,
10468 };
10469 
10470 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
alc861_fixup_asus_amp_vref_0f(struct hda_codec * codec,const struct hda_fixup * fix,int action)10471 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
10472 			const struct hda_fixup *fix, int action)
10473 {
10474 	struct alc_spec *spec = codec->spec;
10475 	unsigned int val;
10476 
10477 	if (action != HDA_FIXUP_ACT_INIT)
10478 		return;
10479 	val = snd_hda_codec_get_pin_target(codec, 0x0f);
10480 	if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
10481 		val |= AC_PINCTL_IN_EN;
10482 	val |= AC_PINCTL_VREF_50;
10483 	snd_hda_set_pin_ctl(codec, 0x0f, val);
10484 	spec->gen.keep_vref_in_automute = 1;
10485 }
10486 
10487 /* suppress the jack-detection */
alc_fixup_no_jack_detect(struct hda_codec * codec,const struct hda_fixup * fix,int action)10488 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
10489 				     const struct hda_fixup *fix, int action)
10490 {
10491 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
10492 		codec->no_jack_detect = 1;
10493 }
10494 
10495 static const struct hda_fixup alc861_fixups[] = {
10496 	[ALC861_FIXUP_FSC_AMILO_PI1505] = {
10497 		.type = HDA_FIXUP_PINS,
10498 		.v.pins = (const struct hda_pintbl[]) {
10499 			{ 0x0b, 0x0221101f }, /* HP */
10500 			{ 0x0f, 0x90170310 }, /* speaker */
10501 			{ }
10502 		}
10503 	},
10504 	[ALC861_FIXUP_AMP_VREF_0F] = {
10505 		.type = HDA_FIXUP_FUNC,
10506 		.v.func = alc861_fixup_asus_amp_vref_0f,
10507 	},
10508 	[ALC861_FIXUP_NO_JACK_DETECT] = {
10509 		.type = HDA_FIXUP_FUNC,
10510 		.v.func = alc_fixup_no_jack_detect,
10511 	},
10512 	[ALC861_FIXUP_ASUS_A6RP] = {
10513 		.type = HDA_FIXUP_FUNC,
10514 		.v.func = alc861_fixup_asus_amp_vref_0f,
10515 		.chained = true,
10516 		.chain_id = ALC861_FIXUP_NO_JACK_DETECT,
10517 	},
10518 	[ALC660_FIXUP_ASUS_W7J] = {
10519 		.type = HDA_FIXUP_VERBS,
10520 		.v.verbs = (const struct hda_verb[]) {
10521 			/* ASUS W7J needs a magic pin setup on unused NID 0x10
10522 			 * for enabling outputs
10523 			 */
10524 			{0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10525 			{ }
10526 		},
10527 	}
10528 };
10529 
10530 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
10531 	SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
10532 	SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
10533 	SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
10534 	SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
10535 	SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
10536 	SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
10537 	SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
10538 	{}
10539 };
10540 
10541 /*
10542  */
patch_alc861(struct hda_codec * codec)10543 static int patch_alc861(struct hda_codec *codec)
10544 {
10545 	struct alc_spec *spec;
10546 	int err;
10547 
10548 	err = alc_alloc_spec(codec, 0x15);
10549 	if (err < 0)
10550 		return err;
10551 
10552 	spec = codec->spec;
10553 	if (has_cdefine_beep(codec))
10554 		spec->gen.beep_nid = 0x23;
10555 
10556 #ifdef CONFIG_PM
10557 	spec->power_hook = alc_power_eapd;
10558 #endif
10559 
10560 	alc_pre_init(codec);
10561 
10562 	snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
10563 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10564 
10565 	/* automatic parse from the BIOS config */
10566 	err = alc861_parse_auto_config(codec);
10567 	if (err < 0)
10568 		goto error;
10569 
10570 	if (!spec->gen.no_analog) {
10571 		err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
10572 		if (err < 0)
10573 			goto error;
10574 	}
10575 
10576 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10577 
10578 	return 0;
10579 
10580  error:
10581 	alc_free(codec);
10582 	return err;
10583 }
10584 
10585 /*
10586  * ALC861-VD support
10587  *
10588  * Based on ALC882
10589  *
10590  * In addition, an independent DAC
10591  */
alc861vd_parse_auto_config(struct hda_codec * codec)10592 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10593 {
10594 	static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10595 	static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10596 	return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
10597 }
10598 
10599 enum {
10600 	ALC660VD_FIX_ASUS_GPIO1,
10601 	ALC861VD_FIX_DALLAS,
10602 };
10603 
10604 /* exclude VREF80 */
alc861vd_fixup_dallas(struct hda_codec * codec,const struct hda_fixup * fix,int action)10605 static void alc861vd_fixup_dallas(struct hda_codec *codec,
10606 				  const struct hda_fixup *fix, int action)
10607 {
10608 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10609 		snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
10610 		snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
10611 	}
10612 }
10613 
10614 /* reset GPIO1 */
alc660vd_fixup_asus_gpio1(struct hda_codec * codec,const struct hda_fixup * fix,int action)10615 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
10616 				      const struct hda_fixup *fix, int action)
10617 {
10618 	struct alc_spec *spec = codec->spec;
10619 
10620 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
10621 		spec->gpio_mask |= 0x02;
10622 	alc_fixup_gpio(codec, action, 0x01);
10623 }
10624 
10625 static const struct hda_fixup alc861vd_fixups[] = {
10626 	[ALC660VD_FIX_ASUS_GPIO1] = {
10627 		.type = HDA_FIXUP_FUNC,
10628 		.v.func = alc660vd_fixup_asus_gpio1,
10629 	},
10630 	[ALC861VD_FIX_DALLAS] = {
10631 		.type = HDA_FIXUP_FUNC,
10632 		.v.func = alc861vd_fixup_dallas,
10633 	},
10634 };
10635 
10636 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
10637 	SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
10638 	SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
10639 	SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
10640 	{}
10641 };
10642 
10643 /*
10644  */
patch_alc861vd(struct hda_codec * codec)10645 static int patch_alc861vd(struct hda_codec *codec)
10646 {
10647 	struct alc_spec *spec;
10648 	int err;
10649 
10650 	err = alc_alloc_spec(codec, 0x0b);
10651 	if (err < 0)
10652 		return err;
10653 
10654 	spec = codec->spec;
10655 	if (has_cdefine_beep(codec))
10656 		spec->gen.beep_nid = 0x23;
10657 
10658 	spec->shutup = alc_eapd_shutup;
10659 
10660 	alc_pre_init(codec);
10661 
10662 	snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
10663 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10664 
10665 	/* automatic parse from the BIOS config */
10666 	err = alc861vd_parse_auto_config(codec);
10667 	if (err < 0)
10668 		goto error;
10669 
10670 	if (!spec->gen.no_analog) {
10671 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10672 		if (err < 0)
10673 			goto error;
10674 	}
10675 
10676 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10677 
10678 	return 0;
10679 
10680  error:
10681 	alc_free(codec);
10682 	return err;
10683 }
10684 
10685 /*
10686  * ALC662 support
10687  *
10688  * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10689  * configuration.  Each pin widget can choose any input DACs and a mixer.
10690  * Each ADC is connected from a mixer of all inputs.  This makes possible
10691  * 6-channel independent captures.
10692  *
10693  * In addition, an independent DAC for the multi-playback (not used in this
10694  * driver yet).
10695  */
10696 
10697 /*
10698  * BIOS auto configuration
10699  */
10700 
alc662_parse_auto_config(struct hda_codec * codec)10701 static int alc662_parse_auto_config(struct hda_codec *codec)
10702 {
10703 	static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10704 	static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
10705 	static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10706 	const hda_nid_t *ssids;
10707 
10708 	if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
10709 	    codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
10710 	    codec->core.vendor_id == 0x10ec0671)
10711 		ssids = alc663_ssids;
10712 	else
10713 		ssids = alc662_ssids;
10714 	return alc_parse_auto_config(codec, alc662_ignore, ssids);
10715 }
10716 
alc272_fixup_mario(struct hda_codec * codec,const struct hda_fixup * fix,int action)10717 static void alc272_fixup_mario(struct hda_codec *codec,
10718 			       const struct hda_fixup *fix, int action)
10719 {
10720 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
10721 		return;
10722 	if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
10723 				      (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
10724 				      (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
10725 				      (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10726 				      (0 << AC_AMPCAP_MUTE_SHIFT)))
10727 		codec_warn(codec, "failed to override amp caps for NID 0x2\n");
10728 }
10729 
10730 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
10731 	{ .channels = 2,
10732 	  .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
10733 	{ .channels = 4,
10734 	  .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
10735 		   SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
10736 	{ }
10737 };
10738 
10739 /* override the 2.1 chmap */
alc_fixup_bass_chmap(struct hda_codec * codec,const struct hda_fixup * fix,int action)10740 static void alc_fixup_bass_chmap(struct hda_codec *codec,
10741 				    const struct hda_fixup *fix, int action)
10742 {
10743 	if (action == HDA_FIXUP_ACT_BUILD) {
10744 		struct alc_spec *spec = codec->spec;
10745 		spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
10746 	}
10747 }
10748 
10749 /* avoid D3 for keeping GPIO up */
gpio_led_power_filter(struct hda_codec * codec,hda_nid_t nid,unsigned int power_state)10750 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
10751 					  hda_nid_t nid,
10752 					  unsigned int power_state)
10753 {
10754 	struct alc_spec *spec = codec->spec;
10755 	if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
10756 		return AC_PWRST_D0;
10757 	return power_state;
10758 }
10759 
alc662_fixup_led_gpio1(struct hda_codec * codec,const struct hda_fixup * fix,int action)10760 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
10761 				   const struct hda_fixup *fix, int action)
10762 {
10763 	struct alc_spec *spec = codec->spec;
10764 
10765 	alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
10766 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10767 		spec->mute_led_polarity = 1;
10768 		codec->power_filter = gpio_led_power_filter;
10769 	}
10770 }
10771 
alc662_usi_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)10772 static void alc662_usi_automute_hook(struct hda_codec *codec,
10773 					 struct hda_jack_callback *jack)
10774 {
10775 	struct alc_spec *spec = codec->spec;
10776 	int vref;
10777 	msleep(200);
10778 	snd_hda_gen_hp_automute(codec, jack);
10779 
10780 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
10781 	msleep(100);
10782 	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10783 			    vref);
10784 }
10785 
alc662_fixup_usi_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)10786 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
10787 				     const struct hda_fixup *fix, int action)
10788 {
10789 	struct alc_spec *spec = codec->spec;
10790 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10791 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10792 		spec->gen.hp_automute_hook = alc662_usi_automute_hook;
10793 	}
10794 }
10795 
alc662_aspire_ethos_mute_speakers(struct hda_codec * codec,struct hda_jack_callback * cb)10796 static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
10797 					struct hda_jack_callback *cb)
10798 {
10799 	/* surround speakers at 0x1b already get muted automatically when
10800 	 * headphones are plugged in, but we have to mute/unmute the remaining
10801 	 * channels manually:
10802 	 * 0x15 - front left/front right
10803 	 * 0x18 - front center/ LFE
10804 	 */
10805 	if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
10806 		snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
10807 		snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
10808 	} else {
10809 		snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
10810 		snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
10811 	}
10812 }
10813 
alc662_fixup_aspire_ethos_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)10814 static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
10815 					const struct hda_fixup *fix, int action)
10816 {
10817     /* Pin 0x1b: shared headphones jack and surround speakers */
10818 	if (!is_jack_detectable(codec, 0x1b))
10819 		return;
10820 
10821 	switch (action) {
10822 	case HDA_FIXUP_ACT_PRE_PROBE:
10823 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
10824 				alc662_aspire_ethos_mute_speakers);
10825 		/* subwoofer needs an extra GPIO setting to become audible */
10826 		alc_setup_gpio(codec, 0x02);
10827 		break;
10828 	case HDA_FIXUP_ACT_INIT:
10829 		/* Make sure to start in a correct state, i.e. if
10830 		 * headphones have been plugged in before powering up the system
10831 		 */
10832 		alc662_aspire_ethos_mute_speakers(codec, NULL);
10833 		break;
10834 	}
10835 }
10836 
alc671_fixup_hp_headset_mic2(struct hda_codec * codec,const struct hda_fixup * fix,int action)10837 static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
10838 					     const struct hda_fixup *fix, int action)
10839 {
10840 	struct alc_spec *spec = codec->spec;
10841 
10842 	static const struct hda_pintbl pincfgs[] = {
10843 		{ 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */
10844 		{ 0x1b, 0x0181304f },
10845 		{ }
10846 	};
10847 
10848 	switch (action) {
10849 	case HDA_FIXUP_ACT_PRE_PROBE:
10850 		spec->gen.mixer_nid = 0;
10851 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10852 		snd_hda_apply_pincfgs(codec, pincfgs);
10853 		break;
10854 	case HDA_FIXUP_ACT_INIT:
10855 		alc_write_coef_idx(codec, 0x19, 0xa054);
10856 		break;
10857 	}
10858 }
10859 
alc897_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)10860 static void alc897_hp_automute_hook(struct hda_codec *codec,
10861 					 struct hda_jack_callback *jack)
10862 {
10863 	struct alc_spec *spec = codec->spec;
10864 	int vref;
10865 
10866 	snd_hda_gen_hp_automute(codec, jack);
10867 	vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP;
10868 	snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10869 			    vref);
10870 }
10871 
alc897_fixup_lenovo_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)10872 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
10873 				     const struct hda_fixup *fix, int action)
10874 {
10875 	struct alc_spec *spec = codec->spec;
10876 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10877 		spec->gen.hp_automute_hook = alc897_hp_automute_hook;
10878 	}
10879 }
10880 
10881 static const struct coef_fw alc668_coefs[] = {
10882 	WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
10883 	WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
10884 	WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
10885 	WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
10886 	WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
10887 	WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
10888 	WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
10889 	WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
10890 	WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
10891 	WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
10892 	WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
10893 	WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
10894 	WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
10895 	WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
10896 	WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
10897 	WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
10898 	WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
10899 	WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
10900 	WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
10901 	WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
10902 	{}
10903 };
10904 
alc668_restore_default_value(struct hda_codec * codec)10905 static void alc668_restore_default_value(struct hda_codec *codec)
10906 {
10907 	alc_process_coef_fw(codec, alc668_coefs);
10908 }
10909 
10910 enum {
10911 	ALC662_FIXUP_ASPIRE,
10912 	ALC662_FIXUP_LED_GPIO1,
10913 	ALC662_FIXUP_IDEAPAD,
10914 	ALC272_FIXUP_MARIO,
10915 	ALC662_FIXUP_CZC_ET26,
10916 	ALC662_FIXUP_CZC_P10T,
10917 	ALC662_FIXUP_SKU_IGNORE,
10918 	ALC662_FIXUP_HP_RP5800,
10919 	ALC662_FIXUP_ASUS_MODE1,
10920 	ALC662_FIXUP_ASUS_MODE2,
10921 	ALC662_FIXUP_ASUS_MODE3,
10922 	ALC662_FIXUP_ASUS_MODE4,
10923 	ALC662_FIXUP_ASUS_MODE5,
10924 	ALC662_FIXUP_ASUS_MODE6,
10925 	ALC662_FIXUP_ASUS_MODE7,
10926 	ALC662_FIXUP_ASUS_MODE8,
10927 	ALC662_FIXUP_NO_JACK_DETECT,
10928 	ALC662_FIXUP_ZOTAC_Z68,
10929 	ALC662_FIXUP_INV_DMIC,
10930 	ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
10931 	ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
10932 	ALC662_FIXUP_HEADSET_MODE,
10933 	ALC668_FIXUP_HEADSET_MODE,
10934 	ALC662_FIXUP_BASS_MODE4_CHMAP,
10935 	ALC662_FIXUP_BASS_16,
10936 	ALC662_FIXUP_BASS_1A,
10937 	ALC662_FIXUP_BASS_CHMAP,
10938 	ALC668_FIXUP_AUTO_MUTE,
10939 	ALC668_FIXUP_DELL_DISABLE_AAMIX,
10940 	ALC668_FIXUP_DELL_XPS13,
10941 	ALC662_FIXUP_ASUS_Nx50,
10942 	ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10943 	ALC668_FIXUP_ASUS_Nx51,
10944 	ALC668_FIXUP_MIC_COEF,
10945 	ALC668_FIXUP_ASUS_G751,
10946 	ALC891_FIXUP_HEADSET_MODE,
10947 	ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10948 	ALC662_FIXUP_ACER_VERITON,
10949 	ALC892_FIXUP_ASROCK_MOBO,
10950 	ALC662_FIXUP_USI_FUNC,
10951 	ALC662_FIXUP_USI_HEADSET_MODE,
10952 	ALC662_FIXUP_LENOVO_MULTI_CODECS,
10953 	ALC669_FIXUP_ACER_ASPIRE_ETHOS,
10954 	ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET,
10955 	ALC671_FIXUP_HP_HEADSET_MIC2,
10956 	ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
10957 	ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
10958 	ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
10959 	ALC668_FIXUP_HEADSET_MIC,
10960 	ALC668_FIXUP_MIC_DET_COEF,
10961 	ALC897_FIXUP_LENOVO_HEADSET_MIC,
10962 	ALC897_FIXUP_HEADSET_MIC_PIN,
10963 	ALC897_FIXUP_HP_HSMIC_VERB,
10964 };
10965 
10966 static const struct hda_fixup alc662_fixups[] = {
10967 	[ALC662_FIXUP_ASPIRE] = {
10968 		.type = HDA_FIXUP_PINS,
10969 		.v.pins = (const struct hda_pintbl[]) {
10970 			{ 0x15, 0x99130112 }, /* subwoofer */
10971 			{ }
10972 		}
10973 	},
10974 	[ALC662_FIXUP_LED_GPIO1] = {
10975 		.type = HDA_FIXUP_FUNC,
10976 		.v.func = alc662_fixup_led_gpio1,
10977 	},
10978 	[ALC662_FIXUP_IDEAPAD] = {
10979 		.type = HDA_FIXUP_PINS,
10980 		.v.pins = (const struct hda_pintbl[]) {
10981 			{ 0x17, 0x99130112 }, /* subwoofer */
10982 			{ }
10983 		},
10984 		.chained = true,
10985 		.chain_id = ALC662_FIXUP_LED_GPIO1,
10986 	},
10987 	[ALC272_FIXUP_MARIO] = {
10988 		.type = HDA_FIXUP_FUNC,
10989 		.v.func = alc272_fixup_mario,
10990 	},
10991 	[ALC662_FIXUP_CZC_ET26] = {
10992 		.type = HDA_FIXUP_PINS,
10993 		.v.pins = (const struct hda_pintbl[]) {
10994 			{0x12, 0x403cc000},
10995 			{0x14, 0x90170110}, /* speaker */
10996 			{0x15, 0x411111f0},
10997 			{0x16, 0x411111f0},
10998 			{0x18, 0x01a19030}, /* mic */
10999 			{0x19, 0x90a7013f}, /* int-mic */
11000 			{0x1a, 0x01014020},
11001 			{0x1b, 0x0121401f},
11002 			{0x1c, 0x411111f0},
11003 			{0x1d, 0x411111f0},
11004 			{0x1e, 0x40478e35},
11005 			{}
11006 		},
11007 		.chained = true,
11008 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11009 	},
11010 	[ALC662_FIXUP_CZC_P10T] = {
11011 		.type = HDA_FIXUP_VERBS,
11012 		.v.verbs = (const struct hda_verb[]) {
11013 			{0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
11014 			{}
11015 		}
11016 	},
11017 	[ALC662_FIXUP_SKU_IGNORE] = {
11018 		.type = HDA_FIXUP_FUNC,
11019 		.v.func = alc_fixup_sku_ignore,
11020 	},
11021 	[ALC662_FIXUP_HP_RP5800] = {
11022 		.type = HDA_FIXUP_PINS,
11023 		.v.pins = (const struct hda_pintbl[]) {
11024 			{ 0x14, 0x0221201f }, /* HP out */
11025 			{ }
11026 		},
11027 		.chained = true,
11028 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11029 	},
11030 	[ALC662_FIXUP_ASUS_MODE1] = {
11031 		.type = HDA_FIXUP_PINS,
11032 		.v.pins = (const struct hda_pintbl[]) {
11033 			{ 0x14, 0x99130110 }, /* speaker */
11034 			{ 0x18, 0x01a19c20 }, /* mic */
11035 			{ 0x19, 0x99a3092f }, /* int-mic */
11036 			{ 0x21, 0x0121401f }, /* HP out */
11037 			{ }
11038 		},
11039 		.chained = true,
11040 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11041 	},
11042 	[ALC662_FIXUP_ASUS_MODE2] = {
11043 		.type = HDA_FIXUP_PINS,
11044 		.v.pins = (const struct hda_pintbl[]) {
11045 			{ 0x14, 0x99130110 }, /* speaker */
11046 			{ 0x18, 0x01a19820 }, /* mic */
11047 			{ 0x19, 0x99a3092f }, /* int-mic */
11048 			{ 0x1b, 0x0121401f }, /* HP out */
11049 			{ }
11050 		},
11051 		.chained = true,
11052 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11053 	},
11054 	[ALC662_FIXUP_ASUS_MODE3] = {
11055 		.type = HDA_FIXUP_PINS,
11056 		.v.pins = (const struct hda_pintbl[]) {
11057 			{ 0x14, 0x99130110 }, /* speaker */
11058 			{ 0x15, 0x0121441f }, /* HP */
11059 			{ 0x18, 0x01a19840 }, /* mic */
11060 			{ 0x19, 0x99a3094f }, /* int-mic */
11061 			{ 0x21, 0x01211420 }, /* HP2 */
11062 			{ }
11063 		},
11064 		.chained = true,
11065 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11066 	},
11067 	[ALC662_FIXUP_ASUS_MODE4] = {
11068 		.type = HDA_FIXUP_PINS,
11069 		.v.pins = (const struct hda_pintbl[]) {
11070 			{ 0x14, 0x99130110 }, /* speaker */
11071 			{ 0x16, 0x99130111 }, /* speaker */
11072 			{ 0x18, 0x01a19840 }, /* mic */
11073 			{ 0x19, 0x99a3094f }, /* int-mic */
11074 			{ 0x21, 0x0121441f }, /* HP */
11075 			{ }
11076 		},
11077 		.chained = true,
11078 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11079 	},
11080 	[ALC662_FIXUP_ASUS_MODE5] = {
11081 		.type = HDA_FIXUP_PINS,
11082 		.v.pins = (const struct hda_pintbl[]) {
11083 			{ 0x14, 0x99130110 }, /* speaker */
11084 			{ 0x15, 0x0121441f }, /* HP */
11085 			{ 0x16, 0x99130111 }, /* speaker */
11086 			{ 0x18, 0x01a19840 }, /* mic */
11087 			{ 0x19, 0x99a3094f }, /* int-mic */
11088 			{ }
11089 		},
11090 		.chained = true,
11091 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11092 	},
11093 	[ALC662_FIXUP_ASUS_MODE6] = {
11094 		.type = HDA_FIXUP_PINS,
11095 		.v.pins = (const struct hda_pintbl[]) {
11096 			{ 0x14, 0x99130110 }, /* speaker */
11097 			{ 0x15, 0x01211420 }, /* HP2 */
11098 			{ 0x18, 0x01a19840 }, /* mic */
11099 			{ 0x19, 0x99a3094f }, /* int-mic */
11100 			{ 0x1b, 0x0121441f }, /* HP */
11101 			{ }
11102 		},
11103 		.chained = true,
11104 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11105 	},
11106 	[ALC662_FIXUP_ASUS_MODE7] = {
11107 		.type = HDA_FIXUP_PINS,
11108 		.v.pins = (const struct hda_pintbl[]) {
11109 			{ 0x14, 0x99130110 }, /* speaker */
11110 			{ 0x17, 0x99130111 }, /* speaker */
11111 			{ 0x18, 0x01a19840 }, /* mic */
11112 			{ 0x19, 0x99a3094f }, /* int-mic */
11113 			{ 0x1b, 0x01214020 }, /* HP */
11114 			{ 0x21, 0x0121401f }, /* HP */
11115 			{ }
11116 		},
11117 		.chained = true,
11118 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11119 	},
11120 	[ALC662_FIXUP_ASUS_MODE8] = {
11121 		.type = HDA_FIXUP_PINS,
11122 		.v.pins = (const struct hda_pintbl[]) {
11123 			{ 0x14, 0x99130110 }, /* speaker */
11124 			{ 0x12, 0x99a30970 }, /* int-mic */
11125 			{ 0x15, 0x01214020 }, /* HP */
11126 			{ 0x17, 0x99130111 }, /* speaker */
11127 			{ 0x18, 0x01a19840 }, /* mic */
11128 			{ 0x21, 0x0121401f }, /* HP */
11129 			{ }
11130 		},
11131 		.chained = true,
11132 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11133 	},
11134 	[ALC662_FIXUP_NO_JACK_DETECT] = {
11135 		.type = HDA_FIXUP_FUNC,
11136 		.v.func = alc_fixup_no_jack_detect,
11137 	},
11138 	[ALC662_FIXUP_ZOTAC_Z68] = {
11139 		.type = HDA_FIXUP_PINS,
11140 		.v.pins = (const struct hda_pintbl[]) {
11141 			{ 0x1b, 0x02214020 }, /* Front HP */
11142 			{ }
11143 		}
11144 	},
11145 	[ALC662_FIXUP_INV_DMIC] = {
11146 		.type = HDA_FIXUP_FUNC,
11147 		.v.func = alc_fixup_inv_dmic,
11148 	},
11149 	[ALC668_FIXUP_DELL_XPS13] = {
11150 		.type = HDA_FIXUP_FUNC,
11151 		.v.func = alc_fixup_dell_xps13,
11152 		.chained = true,
11153 		.chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
11154 	},
11155 	[ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
11156 		.type = HDA_FIXUP_FUNC,
11157 		.v.func = alc_fixup_disable_aamix,
11158 		.chained = true,
11159 		.chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
11160 	},
11161 	[ALC668_FIXUP_AUTO_MUTE] = {
11162 		.type = HDA_FIXUP_FUNC,
11163 		.v.func = alc_fixup_auto_mute_via_amp,
11164 		.chained = true,
11165 		.chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
11166 	},
11167 	[ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
11168 		.type = HDA_FIXUP_PINS,
11169 		.v.pins = (const struct hda_pintbl[]) {
11170 			{ 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11171 			/* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
11172 			{ }
11173 		},
11174 		.chained = true,
11175 		.chain_id = ALC662_FIXUP_HEADSET_MODE
11176 	},
11177 	[ALC662_FIXUP_HEADSET_MODE] = {
11178 		.type = HDA_FIXUP_FUNC,
11179 		.v.func = alc_fixup_headset_mode_alc662,
11180 	},
11181 	[ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
11182 		.type = HDA_FIXUP_PINS,
11183 		.v.pins = (const struct hda_pintbl[]) {
11184 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
11185 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11186 			{ }
11187 		},
11188 		.chained = true,
11189 		.chain_id = ALC668_FIXUP_HEADSET_MODE
11190 	},
11191 	[ALC668_FIXUP_HEADSET_MODE] = {
11192 		.type = HDA_FIXUP_FUNC,
11193 		.v.func = alc_fixup_headset_mode_alc668,
11194 	},
11195 	[ALC662_FIXUP_BASS_MODE4_CHMAP] = {
11196 		.type = HDA_FIXUP_FUNC,
11197 		.v.func = alc_fixup_bass_chmap,
11198 		.chained = true,
11199 		.chain_id = ALC662_FIXUP_ASUS_MODE4
11200 	},
11201 	[ALC662_FIXUP_BASS_16] = {
11202 		.type = HDA_FIXUP_PINS,
11203 		.v.pins = (const struct hda_pintbl[]) {
11204 			{0x16, 0x80106111}, /* bass speaker */
11205 			{}
11206 		},
11207 		.chained = true,
11208 		.chain_id = ALC662_FIXUP_BASS_CHMAP,
11209 	},
11210 	[ALC662_FIXUP_BASS_1A] = {
11211 		.type = HDA_FIXUP_PINS,
11212 		.v.pins = (const struct hda_pintbl[]) {
11213 			{0x1a, 0x80106111}, /* bass speaker */
11214 			{}
11215 		},
11216 		.chained = true,
11217 		.chain_id = ALC662_FIXUP_BASS_CHMAP,
11218 	},
11219 	[ALC662_FIXUP_BASS_CHMAP] = {
11220 		.type = HDA_FIXUP_FUNC,
11221 		.v.func = alc_fixup_bass_chmap,
11222 	},
11223 	[ALC662_FIXUP_ASUS_Nx50] = {
11224 		.type = HDA_FIXUP_FUNC,
11225 		.v.func = alc_fixup_auto_mute_via_amp,
11226 		.chained = true,
11227 		.chain_id = ALC662_FIXUP_BASS_1A
11228 	},
11229 	[ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
11230 		.type = HDA_FIXUP_FUNC,
11231 		.v.func = alc_fixup_headset_mode_alc668,
11232 		.chain_id = ALC662_FIXUP_BASS_CHMAP
11233 	},
11234 	[ALC668_FIXUP_ASUS_Nx51] = {
11235 		.type = HDA_FIXUP_PINS,
11236 		.v.pins = (const struct hda_pintbl[]) {
11237 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
11238 			{ 0x1a, 0x90170151 }, /* bass speaker */
11239 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11240 			{}
11241 		},
11242 		.chained = true,
11243 		.chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
11244 	},
11245 	[ALC668_FIXUP_MIC_COEF] = {
11246 		.type = HDA_FIXUP_VERBS,
11247 		.v.verbs = (const struct hda_verb[]) {
11248 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
11249 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
11250 			{}
11251 		},
11252 	},
11253 	[ALC668_FIXUP_ASUS_G751] = {
11254 		.type = HDA_FIXUP_PINS,
11255 		.v.pins = (const struct hda_pintbl[]) {
11256 			{ 0x16, 0x0421101f }, /* HP */
11257 			{}
11258 		},
11259 		.chained = true,
11260 		.chain_id = ALC668_FIXUP_MIC_COEF
11261 	},
11262 	[ALC891_FIXUP_HEADSET_MODE] = {
11263 		.type = HDA_FIXUP_FUNC,
11264 		.v.func = alc_fixup_headset_mode,
11265 	},
11266 	[ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
11267 		.type = HDA_FIXUP_PINS,
11268 		.v.pins = (const struct hda_pintbl[]) {
11269 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
11270 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11271 			{ }
11272 		},
11273 		.chained = true,
11274 		.chain_id = ALC891_FIXUP_HEADSET_MODE
11275 	},
11276 	[ALC662_FIXUP_ACER_VERITON] = {
11277 		.type = HDA_FIXUP_PINS,
11278 		.v.pins = (const struct hda_pintbl[]) {
11279 			{ 0x15, 0x50170120 }, /* no internal speaker */
11280 			{ }
11281 		}
11282 	},
11283 	[ALC892_FIXUP_ASROCK_MOBO] = {
11284 		.type = HDA_FIXUP_PINS,
11285 		.v.pins = (const struct hda_pintbl[]) {
11286 			{ 0x15, 0x40f000f0 }, /* disabled */
11287 			{ 0x16, 0x40f000f0 }, /* disabled */
11288 			{ }
11289 		}
11290 	},
11291 	[ALC662_FIXUP_USI_FUNC] = {
11292 		.type = HDA_FIXUP_FUNC,
11293 		.v.func = alc662_fixup_usi_headset_mic,
11294 	},
11295 	[ALC662_FIXUP_USI_HEADSET_MODE] = {
11296 		.type = HDA_FIXUP_PINS,
11297 		.v.pins = (const struct hda_pintbl[]) {
11298 			{ 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
11299 			{ 0x18, 0x01a1903d },
11300 			{ }
11301 		},
11302 		.chained = true,
11303 		.chain_id = ALC662_FIXUP_USI_FUNC
11304 	},
11305 	[ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
11306 		.type = HDA_FIXUP_FUNC,
11307 		.v.func = alc233_alc662_fixup_lenovo_dual_codecs,
11308 	},
11309 	[ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET] = {
11310 		.type = HDA_FIXUP_FUNC,
11311 		.v.func = alc662_fixup_aspire_ethos_hp,
11312 	},
11313 	[ALC669_FIXUP_ACER_ASPIRE_ETHOS] = {
11314 		.type = HDA_FIXUP_PINS,
11315 		.v.pins = (const struct hda_pintbl[]) {
11316 			{ 0x15, 0x92130110 }, /* front speakers */
11317 			{ 0x18, 0x99130111 }, /* center/subwoofer */
11318 			{ 0x1b, 0x11130012 }, /* surround plus jack for HP */
11319 			{ }
11320 		},
11321 		.chained = true,
11322 		.chain_id = ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET
11323 	},
11324 	[ALC671_FIXUP_HP_HEADSET_MIC2] = {
11325 		.type = HDA_FIXUP_FUNC,
11326 		.v.func = alc671_fixup_hp_headset_mic2,
11327 	},
11328 	[ALC662_FIXUP_ACER_X2660G_HEADSET_MODE] = {
11329 		.type = HDA_FIXUP_PINS,
11330 		.v.pins = (const struct hda_pintbl[]) {
11331 			{ 0x1a, 0x02a1113c }, /* use as headset mic, without its own jack detect */
11332 			{ }
11333 		},
11334 		.chained = true,
11335 		.chain_id = ALC662_FIXUP_USI_FUNC
11336 	},
11337 	[ALC662_FIXUP_ACER_NITRO_HEADSET_MODE] = {
11338 		.type = HDA_FIXUP_PINS,
11339 		.v.pins = (const struct hda_pintbl[]) {
11340 			{ 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
11341 			{ 0x1b, 0x0221144f },
11342 			{ }
11343 		},
11344 		.chained = true,
11345 		.chain_id = ALC662_FIXUP_USI_FUNC
11346 	},
11347 	[ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
11348 		.type = HDA_FIXUP_PINS,
11349 		.v.pins = (const struct hda_pintbl[]) {
11350 			{ 0x1b, 0x04a1112c },
11351 			{ }
11352 		},
11353 		.chained = true,
11354 		.chain_id = ALC668_FIXUP_HEADSET_MIC
11355 	},
11356 	[ALC668_FIXUP_HEADSET_MIC] = {
11357 		.type = HDA_FIXUP_FUNC,
11358 		.v.func = alc269_fixup_headset_mic,
11359 		.chained = true,
11360 		.chain_id = ALC668_FIXUP_MIC_DET_COEF
11361 	},
11362 	[ALC668_FIXUP_MIC_DET_COEF] = {
11363 		.type = HDA_FIXUP_VERBS,
11364 		.v.verbs = (const struct hda_verb[]) {
11365 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
11366 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
11367 			{}
11368 		},
11369 	},
11370 	[ALC897_FIXUP_LENOVO_HEADSET_MIC] = {
11371 		.type = HDA_FIXUP_FUNC,
11372 		.v.func = alc897_fixup_lenovo_headset_mic,
11373 	},
11374 	[ALC897_FIXUP_HEADSET_MIC_PIN] = {
11375 		.type = HDA_FIXUP_PINS,
11376 		.v.pins = (const struct hda_pintbl[]) {
11377 			{ 0x1a, 0x03a11050 },
11378 			{ }
11379 		},
11380 		.chained = true,
11381 		.chain_id = ALC897_FIXUP_LENOVO_HEADSET_MIC
11382 	},
11383 	[ALC897_FIXUP_HP_HSMIC_VERB] = {
11384 		.type = HDA_FIXUP_PINS,
11385 		.v.pins = (const struct hda_pintbl[]) {
11386 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
11387 			{ }
11388 		},
11389 	},
11390 };
11391 
11392 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
11393 	SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
11394 	SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
11395 	SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
11396 	SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
11397 	SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
11398 	SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
11399 	SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
11400 	SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
11401 	SND_PCI_QUIRK(0x1025, 0x0566, "Acer Aspire Ethos 8951G", ALC669_FIXUP_ACER_ASPIRE_ETHOS),
11402 	SND_PCI_QUIRK(0x1025, 0x123c, "Acer Nitro N50-600", ALC662_FIXUP_ACER_NITRO_HEADSET_MODE),
11403 	SND_PCI_QUIRK(0x1025, 0x124e, "Acer 2660G", ALC662_FIXUP_ACER_X2660G_HEADSET_MODE),
11404 	SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11405 	SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11406 	SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
11407 	SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
11408 	SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
11409 	SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11410 	SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11411 	SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11412 	SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11413 	SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11414 	SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
11415 	SND_PCI_QUIRK(0x103c, 0x8719, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
11416 	SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
11417 	SND_PCI_QUIRK(0x103c, 0x877e, "HP 288 Pro G6", ALC671_FIXUP_HP_HEADSET_MIC2),
11418 	SND_PCI_QUIRK(0x103c, 0x885f, "HP 288 Pro G8", ALC671_FIXUP_HP_HEADSET_MIC2),
11419 	SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
11420 	SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
11421 	SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
11422 	SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
11423 	SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
11424 	SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
11425 	SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
11426 	SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
11427 	SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
11428 	SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
11429 	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
11430 	SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
11431 	SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
11432 	SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
11433 	SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
11434 	SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
11435 	SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
11436 	SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
11437 	SND_PCI_QUIRK(0x17aa, 0x1057, "Lenovo P360", ALC897_FIXUP_HEADSET_MIC_PIN),
11438 	SND_PCI_QUIRK(0x17aa, 0x32ca, "Lenovo ThinkCentre M80", ALC897_FIXUP_HEADSET_MIC_PIN),
11439 	SND_PCI_QUIRK(0x17aa, 0x32cb, "Lenovo ThinkCentre M70", ALC897_FIXUP_HEADSET_MIC_PIN),
11440 	SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN),
11441 	SND_PCI_QUIRK(0x17aa, 0x32f7, "Lenovo ThinkCentre M90", ALC897_FIXUP_HEADSET_MIC_PIN),
11442 	SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
11443 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
11444 	SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
11445 	SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
11446 	SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
11447 	SND_PCI_QUIRK(0x1b35, 0x1234, "CZC ET26", ALC662_FIXUP_CZC_ET26),
11448 	SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
11449 
11450 #if 0
11451 	/* Below is a quirk table taken from the old code.
11452 	 * Basically the device should work as is without the fixup table.
11453 	 * If BIOS doesn't give a proper info, enable the corresponding
11454 	 * fixup entry.
11455 	 */
11456 	SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
11457 	SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
11458 	SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
11459 	SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
11460 	SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11461 	SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11462 	SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11463 	SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
11464 	SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
11465 	SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11466 	SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
11467 	SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
11468 	SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
11469 	SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
11470 	SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
11471 	SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11472 	SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
11473 	SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
11474 	SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11475 	SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11476 	SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11477 	SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11478 	SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
11479 	SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
11480 	SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
11481 	SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11482 	SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
11483 	SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11484 	SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11485 	SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
11486 	SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11487 	SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11488 	SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
11489 	SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
11490 	SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
11491 	SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
11492 	SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
11493 	SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
11494 	SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
11495 	SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11496 	SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
11497 	SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
11498 	SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11499 	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
11500 	SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
11501 	SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
11502 	SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
11503 	SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
11504 	SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11505 	SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
11506 #endif
11507 	{}
11508 };
11509 
11510 static const struct hda_model_fixup alc662_fixup_models[] = {
11511 	{.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
11512 	{.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
11513 	{.id = ALC272_FIXUP_MARIO, .name = "mario"},
11514 	{.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
11515 	{.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
11516 	{.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
11517 	{.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
11518 	{.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
11519 	{.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
11520 	{.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
11521 	{.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
11522 	{.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
11523 	{.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
11524 	{.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
11525 	{.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
11526 	{.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
11527 	{.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
11528 	{.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
11529 	{.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
11530 	{.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
11531 	{.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
11532 	{.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
11533 	{.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
11534 	{.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
11535 	{.id = ALC668_FIXUP_ASUS_G751, .name = "asus-g751"},
11536 	{.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
11537 	{.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
11538 	{.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
11539 	{.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
11540 	{.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
11541 	{.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
11542 	{.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
11543 	{}
11544 };
11545 
11546 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
11547 	SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
11548 		{0x17, 0x02211010},
11549 		{0x18, 0x01a19030},
11550 		{0x1a, 0x01813040},
11551 		{0x21, 0x01014020}),
11552 	SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
11553 		{0x16, 0x01813030},
11554 		{0x17, 0x02211010},
11555 		{0x18, 0x01a19040},
11556 		{0x21, 0x01014020}),
11557 	SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
11558 		{0x14, 0x01014010},
11559 		{0x18, 0x01a19020},
11560 		{0x1a, 0x0181302f},
11561 		{0x1b, 0x0221401f}),
11562 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11563 		{0x12, 0x99a30130},
11564 		{0x14, 0x90170110},
11565 		{0x15, 0x0321101f},
11566 		{0x16, 0x03011020}),
11567 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11568 		{0x12, 0x99a30140},
11569 		{0x14, 0x90170110},
11570 		{0x15, 0x0321101f},
11571 		{0x16, 0x03011020}),
11572 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11573 		{0x12, 0x99a30150},
11574 		{0x14, 0x90170110},
11575 		{0x15, 0x0321101f},
11576 		{0x16, 0x03011020}),
11577 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11578 		{0x14, 0x90170110},
11579 		{0x15, 0x0321101f},
11580 		{0x16, 0x03011020}),
11581 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
11582 		{0x12, 0x90a60130},
11583 		{0x14, 0x90170110},
11584 		{0x15, 0x0321101f}),
11585 	SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11586 		{0x14, 0x01014010},
11587 		{0x17, 0x90170150},
11588 		{0x19, 0x02a11060},
11589 		{0x1b, 0x01813030},
11590 		{0x21, 0x02211020}),
11591 	SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11592 		{0x14, 0x01014010},
11593 		{0x18, 0x01a19040},
11594 		{0x1b, 0x01813030},
11595 		{0x21, 0x02211020}),
11596 	SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11597 		{0x14, 0x01014020},
11598 		{0x17, 0x90170110},
11599 		{0x18, 0x01a19050},
11600 		{0x1b, 0x01813040},
11601 		{0x21, 0x02211030}),
11602 	{}
11603 };
11604 
11605 /*
11606  */
patch_alc662(struct hda_codec * codec)11607 static int patch_alc662(struct hda_codec *codec)
11608 {
11609 	struct alc_spec *spec;
11610 	int err;
11611 
11612 	err = alc_alloc_spec(codec, 0x0b);
11613 	if (err < 0)
11614 		return err;
11615 
11616 	spec = codec->spec;
11617 
11618 	spec->shutup = alc_eapd_shutup;
11619 
11620 	/* handle multiple HPs as is */
11621 	spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
11622 
11623 	alc_fix_pll_init(codec, 0x20, 0x04, 15);
11624 
11625 	switch (codec->core.vendor_id) {
11626 	case 0x10ec0668:
11627 		spec->init_hook = alc668_restore_default_value;
11628 		break;
11629 	}
11630 
11631 	alc_pre_init(codec);
11632 
11633 	snd_hda_pick_fixup(codec, alc662_fixup_models,
11634 		       alc662_fixup_tbl, alc662_fixups);
11635 	snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
11636 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11637 
11638 	alc_auto_parse_customize_define(codec);
11639 
11640 	if (has_cdefine_beep(codec))
11641 		spec->gen.beep_nid = 0x01;
11642 
11643 	if ((alc_get_coef0(codec) & (1 << 14)) &&
11644 	    codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
11645 	    spec->cdefine.platform_type == 1) {
11646 		err = alc_codec_rename(codec, "ALC272X");
11647 		if (err < 0)
11648 			goto error;
11649 	}
11650 
11651 	/* automatic parse from the BIOS config */
11652 	err = alc662_parse_auto_config(codec);
11653 	if (err < 0)
11654 		goto error;
11655 
11656 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
11657 		switch (codec->core.vendor_id) {
11658 		case 0x10ec0662:
11659 			err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11660 			break;
11661 		case 0x10ec0272:
11662 		case 0x10ec0663:
11663 		case 0x10ec0665:
11664 		case 0x10ec0668:
11665 			err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
11666 			break;
11667 		case 0x10ec0273:
11668 			err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
11669 			break;
11670 		}
11671 		if (err < 0)
11672 			goto error;
11673 	}
11674 
11675 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11676 
11677 	return 0;
11678 
11679  error:
11680 	alc_free(codec);
11681 	return err;
11682 }
11683 
11684 /*
11685  * ALC680 support
11686  */
11687 
alc680_parse_auto_config(struct hda_codec * codec)11688 static int alc680_parse_auto_config(struct hda_codec *codec)
11689 {
11690 	return alc_parse_auto_config(codec, NULL, NULL);
11691 }
11692 
11693 /*
11694  */
patch_alc680(struct hda_codec * codec)11695 static int patch_alc680(struct hda_codec *codec)
11696 {
11697 	int err;
11698 
11699 	/* ALC680 has no aa-loopback mixer */
11700 	err = alc_alloc_spec(codec, 0);
11701 	if (err < 0)
11702 		return err;
11703 
11704 	/* automatic parse from the BIOS config */
11705 	err = alc680_parse_auto_config(codec);
11706 	if (err < 0) {
11707 		alc_free(codec);
11708 		return err;
11709 	}
11710 
11711 	return 0;
11712 }
11713 
11714 /*
11715  * patch entries
11716  */
11717 static const struct hda_device_id snd_hda_id_realtek[] = {
11718 	HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
11719 	HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
11720 	HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
11721 	HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
11722 	HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
11723 	HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
11724 	HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
11725 	HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
11726 	HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
11727 	HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
11728 	HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
11729 	HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
11730 	HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
11731 	HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
11732 	HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
11733 	HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
11734 	HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
11735 	HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
11736 	HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
11737 	HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
11738 	HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
11739 	HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
11740 	HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
11741 	HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
11742 	HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
11743 	HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
11744 	HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
11745 	HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
11746 	HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
11747 	HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
11748 	HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
11749 	HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
11750 	HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
11751 	HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
11752 	HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
11753 	HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
11754 	HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
11755 	HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
11756 	HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
11757 	HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
11758 	HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
11759 	HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
11760 	HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
11761 	HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
11762 	HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
11763 	HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
11764 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
11765 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
11766 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
11767 	HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
11768 	HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
11769 	HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
11770 	HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
11771 	HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
11772 	HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
11773 	HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
11774 	HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
11775 	HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
11776 	HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
11777 	HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
11778 	HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
11779 	HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
11780 	HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
11781 	HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
11782 	HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
11783 	HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
11784 	HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
11785 	HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
11786 	HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
11787 	HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
11788 	HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
11789 	HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
11790 	HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
11791 	HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
11792 	HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
11793 	HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
11794 	HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
11795 	HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
11796 	HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269),
11797 	{} /* terminator */
11798 };
11799 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
11800 
11801 MODULE_LICENSE("GPL");
11802 MODULE_DESCRIPTION("Realtek HD-audio codec");
11803 
11804 static struct hda_codec_driver realtek_driver = {
11805 	.id = snd_hda_id_realtek,
11806 };
11807 
11808 module_hda_codec_driver(realtek_driver);
11809