• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
29 /* keep halting ALC5505 DSP, for power saving */
30 #define HALT_REALTEK_ALC5505
31 
32 /* extra amp-initialization sequence types */
33 enum {
34 	ALC_INIT_UNDEFINED,
35 	ALC_INIT_NONE,
36 	ALC_INIT_DEFAULT,
37 };
38 
39 enum {
40 	ALC_HEADSET_MODE_UNKNOWN,
41 	ALC_HEADSET_MODE_UNPLUGGED,
42 	ALC_HEADSET_MODE_HEADSET,
43 	ALC_HEADSET_MODE_MIC,
44 	ALC_HEADSET_MODE_HEADPHONE,
45 };
46 
47 enum {
48 	ALC_HEADSET_TYPE_UNKNOWN,
49 	ALC_HEADSET_TYPE_CTIA,
50 	ALC_HEADSET_TYPE_OMTP,
51 };
52 
53 enum {
54 	ALC_KEY_MICMUTE_INDEX,
55 };
56 
57 struct alc_customize_define {
58 	unsigned int  sku_cfg;
59 	unsigned char port_connectivity;
60 	unsigned char check_sum;
61 	unsigned char customization;
62 	unsigned char external_amp;
63 	unsigned int  enable_pcbeep:1;
64 	unsigned int  platform_type:1;
65 	unsigned int  swap:1;
66 	unsigned int  override:1;
67 	unsigned int  fixup:1; /* Means that this sku is set by driver, not read from hw */
68 };
69 
70 struct alc_coef_led {
71 	unsigned int idx;
72 	unsigned int mask;
73 	unsigned int on;
74 	unsigned int off;
75 };
76 
77 struct alc_spec {
78 	struct hda_gen_spec gen; /* must be at head */
79 
80 	/* codec parameterization */
81 	struct alc_customize_define cdefine;
82 	unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
83 
84 	/* GPIO bits */
85 	unsigned int gpio_mask;
86 	unsigned int gpio_dir;
87 	unsigned int gpio_data;
88 	bool gpio_write_delay;	/* add a delay before writing gpio_data */
89 
90 	/* mute LED for HP laptops, see vref_mute_led_set() */
91 	int mute_led_polarity;
92 	int micmute_led_polarity;
93 	hda_nid_t mute_led_nid;
94 	hda_nid_t cap_mute_led_nid;
95 
96 	unsigned int gpio_mute_led_mask;
97 	unsigned int gpio_mic_led_mask;
98 	struct alc_coef_led mute_led_coef;
99 	struct alc_coef_led mic_led_coef;
100 	struct mutex coef_mutex;
101 
102 	hda_nid_t headset_mic_pin;
103 	hda_nid_t headphone_mic_pin;
104 	int current_headset_mode;
105 	int current_headset_type;
106 
107 	/* hooks */
108 	void (*init_hook)(struct hda_codec *codec);
109 #ifdef CONFIG_PM
110 	void (*power_hook)(struct hda_codec *codec);
111 #endif
112 	void (*shutup)(struct hda_codec *codec);
113 
114 	int init_amp;
115 	int codec_variant;	/* flag for other variants */
116 	unsigned int has_alc5505_dsp:1;
117 	unsigned int no_depop_delay:1;
118 	unsigned int done_hp_init:1;
119 	unsigned int no_shutup_pins:1;
120 	unsigned int ultra_low_power:1;
121 	unsigned int has_hs_key:1;
122 	unsigned int no_internal_mic_pin:1;
123 	unsigned int en_3kpull_low: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 
133 /*
134  * COEF access helper functions
135  */
136 
coef_mutex_lock(struct hda_codec * codec)137 static void coef_mutex_lock(struct hda_codec *codec)
138 {
139 	struct alc_spec *spec = codec->spec;
140 
141 	snd_hda_power_up_pm(codec);
142 	mutex_lock(&spec->coef_mutex);
143 }
144 
coef_mutex_unlock(struct hda_codec * codec)145 static void coef_mutex_unlock(struct hda_codec *codec)
146 {
147 	struct alc_spec *spec = codec->spec;
148 
149 	mutex_unlock(&spec->coef_mutex);
150 	snd_hda_power_down_pm(codec);
151 }
152 
__alc_read_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx)153 static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
154 				 unsigned int coef_idx)
155 {
156 	unsigned int val;
157 
158 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
159 	val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
160 	return val;
161 }
162 
alc_read_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx)163 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
164 			       unsigned int coef_idx)
165 {
166 	unsigned int val;
167 
168 	coef_mutex_lock(codec);
169 	val = __alc_read_coefex_idx(codec, nid, coef_idx);
170 	coef_mutex_unlock(codec);
171 	return val;
172 }
173 
174 #define alc_read_coef_idx(codec, coef_idx) \
175 	alc_read_coefex_idx(codec, 0x20, coef_idx)
176 
__alc_write_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int coef_val)177 static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
178 				   unsigned int coef_idx, unsigned int coef_val)
179 {
180 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
181 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
182 }
183 
alc_write_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int coef_val)184 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
185 				 unsigned int coef_idx, unsigned int coef_val)
186 {
187 	coef_mutex_lock(codec);
188 	__alc_write_coefex_idx(codec, nid, coef_idx, coef_val);
189 	coef_mutex_unlock(codec);
190 }
191 
192 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
193 	alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
194 
__alc_update_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int mask,unsigned int bits_set)195 static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
196 				    unsigned int coef_idx, unsigned int mask,
197 				    unsigned int bits_set)
198 {
199 	unsigned int val = __alc_read_coefex_idx(codec, nid, coef_idx);
200 
201 	if (val != -1)
202 		__alc_write_coefex_idx(codec, nid, coef_idx,
203 				       (val & ~mask) | bits_set);
204 }
205 
alc_update_coefex_idx(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int mask,unsigned int bits_set)206 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
207 				  unsigned int coef_idx, unsigned int mask,
208 				  unsigned int bits_set)
209 {
210 	coef_mutex_lock(codec);
211 	__alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set);
212 	coef_mutex_unlock(codec);
213 }
214 
215 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set)	\
216 	alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
217 
218 /* a special bypass for COEF 0; read the cached value at the second time */
alc_get_coef0(struct hda_codec * codec)219 static unsigned int alc_get_coef0(struct hda_codec *codec)
220 {
221 	struct alc_spec *spec = codec->spec;
222 
223 	if (!spec->coef0)
224 		spec->coef0 = alc_read_coef_idx(codec, 0);
225 	return spec->coef0;
226 }
227 
228 /* coef writes/updates batch */
229 struct coef_fw {
230 	unsigned char nid;
231 	unsigned char idx;
232 	unsigned short mask;
233 	unsigned short val;
234 };
235 
236 #define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
237 	{ .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
238 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
239 #define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
240 #define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
241 
alc_process_coef_fw(struct hda_codec * codec,const struct coef_fw * fw)242 static void alc_process_coef_fw(struct hda_codec *codec,
243 				const struct coef_fw *fw)
244 {
245 	coef_mutex_lock(codec);
246 	for (; fw->nid; fw++) {
247 		if (fw->mask == (unsigned short)-1)
248 			__alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
249 		else
250 			__alc_update_coefex_idx(codec, fw->nid, fw->idx,
251 						fw->mask, fw->val);
252 	}
253 	coef_mutex_unlock(codec);
254 }
255 
256 /*
257  * GPIO setup tables, used in initialization
258  */
259 
260 /* Enable GPIO mask and set output */
alc_setup_gpio(struct hda_codec * codec,unsigned int mask)261 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
262 {
263 	struct alc_spec *spec = codec->spec;
264 
265 	spec->gpio_mask |= mask;
266 	spec->gpio_dir |= mask;
267 	spec->gpio_data |= mask;
268 }
269 
alc_write_gpio_data(struct hda_codec * codec)270 static void alc_write_gpio_data(struct hda_codec *codec)
271 {
272 	struct alc_spec *spec = codec->spec;
273 
274 	snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
275 			    spec->gpio_data);
276 }
277 
alc_update_gpio_data(struct hda_codec * codec,unsigned int mask,bool on)278 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
279 				 bool on)
280 {
281 	struct alc_spec *spec = codec->spec;
282 	unsigned int oldval = spec->gpio_data;
283 
284 	if (on)
285 		spec->gpio_data |= mask;
286 	else
287 		spec->gpio_data &= ~mask;
288 	if (oldval != spec->gpio_data)
289 		alc_write_gpio_data(codec);
290 }
291 
alc_write_gpio(struct hda_codec * codec)292 static void alc_write_gpio(struct hda_codec *codec)
293 {
294 	struct alc_spec *spec = codec->spec;
295 
296 	if (!spec->gpio_mask)
297 		return;
298 
299 	snd_hda_codec_write(codec, codec->core.afg, 0,
300 			    AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
301 	snd_hda_codec_write(codec, codec->core.afg, 0,
302 			    AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
303 	if (spec->gpio_write_delay)
304 		msleep(1);
305 	alc_write_gpio_data(codec);
306 }
307 
alc_fixup_gpio(struct hda_codec * codec,int action,unsigned int mask)308 static void alc_fixup_gpio(struct hda_codec *codec, int action,
309 			   unsigned int mask)
310 {
311 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
312 		alc_setup_gpio(codec, mask);
313 }
314 
alc_fixup_gpio1(struct hda_codec * codec,const struct hda_fixup * fix,int action)315 static void alc_fixup_gpio1(struct hda_codec *codec,
316 			    const struct hda_fixup *fix, int action)
317 {
318 	alc_fixup_gpio(codec, action, 0x01);
319 }
320 
alc_fixup_gpio2(struct hda_codec * codec,const struct hda_fixup * fix,int action)321 static void alc_fixup_gpio2(struct hda_codec *codec,
322 			    const struct hda_fixup *fix, int action)
323 {
324 	alc_fixup_gpio(codec, action, 0x02);
325 }
326 
alc_fixup_gpio3(struct hda_codec * codec,const struct hda_fixup * fix,int action)327 static void alc_fixup_gpio3(struct hda_codec *codec,
328 			    const struct hda_fixup *fix, int action)
329 {
330 	alc_fixup_gpio(codec, action, 0x03);
331 }
332 
alc_fixup_gpio4(struct hda_codec * codec,const struct hda_fixup * fix,int action)333 static void alc_fixup_gpio4(struct hda_codec *codec,
334 			    const struct hda_fixup *fix, int action)
335 {
336 	alc_fixup_gpio(codec, action, 0x04);
337 }
338 
alc_fixup_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)339 static void alc_fixup_micmute_led(struct hda_codec *codec,
340 				  const struct hda_fixup *fix, int action)
341 {
342 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
343 		snd_hda_gen_add_micmute_led_cdev(codec, NULL);
344 }
345 
346 /*
347  * Fix hardware PLL issue
348  * On some codecs, the analog PLL gating control must be off while
349  * the default value is 1.
350  */
alc_fix_pll(struct hda_codec * codec)351 static void alc_fix_pll(struct hda_codec *codec)
352 {
353 	struct alc_spec *spec = codec->spec;
354 
355 	if (spec->pll_nid)
356 		alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
357 				      1 << spec->pll_coef_bit, 0);
358 }
359 
alc_fix_pll_init(struct hda_codec * codec,hda_nid_t nid,unsigned int coef_idx,unsigned int coef_bit)360 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
361 			     unsigned int coef_idx, unsigned int coef_bit)
362 {
363 	struct alc_spec *spec = codec->spec;
364 	spec->pll_nid = nid;
365 	spec->pll_coef_idx = coef_idx;
366 	spec->pll_coef_bit = coef_bit;
367 	alc_fix_pll(codec);
368 }
369 
370 /* update the master volume per volume-knob's unsol event */
alc_update_knob_master(struct hda_codec * codec,struct hda_jack_callback * jack)371 static void alc_update_knob_master(struct hda_codec *codec,
372 				   struct hda_jack_callback *jack)
373 {
374 	unsigned int val;
375 	struct snd_kcontrol *kctl;
376 	struct snd_ctl_elem_value *uctl;
377 
378 	kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
379 	if (!kctl)
380 		return;
381 	uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
382 	if (!uctl)
383 		return;
384 	val = snd_hda_codec_read(codec, jack->nid, 0,
385 				 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
386 	val &= HDA_AMP_VOLMASK;
387 	uctl->value.integer.value[0] = val;
388 	uctl->value.integer.value[1] = val;
389 	kctl->put(kctl, uctl);
390 	kfree(uctl);
391 }
392 
alc880_unsol_event(struct hda_codec * codec,unsigned int res)393 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
394 {
395 	/* For some reason, the res given from ALC880 is broken.
396 	   Here we adjust it properly. */
397 	snd_hda_jack_unsol_event(codec, res >> 2);
398 }
399 
400 /* Change EAPD to verb control */
alc_fill_eapd_coef(struct hda_codec * codec)401 static void alc_fill_eapd_coef(struct hda_codec *codec)
402 {
403 	int coef;
404 
405 	coef = alc_get_coef0(codec);
406 
407 	switch (codec->core.vendor_id) {
408 	case 0x10ec0262:
409 		alc_update_coef_idx(codec, 0x7, 0, 1<<5);
410 		break;
411 	case 0x10ec0267:
412 	case 0x10ec0268:
413 		alc_update_coef_idx(codec, 0x7, 0, 1<<13);
414 		break;
415 	case 0x10ec0269:
416 		if ((coef & 0x00f0) == 0x0010)
417 			alc_update_coef_idx(codec, 0xd, 0, 1<<14);
418 		if ((coef & 0x00f0) == 0x0020)
419 			alc_update_coef_idx(codec, 0x4, 1<<15, 0);
420 		if ((coef & 0x00f0) == 0x0030)
421 			alc_update_coef_idx(codec, 0x10, 1<<9, 0);
422 		break;
423 	case 0x10ec0280:
424 	case 0x10ec0284:
425 	case 0x10ec0290:
426 	case 0x10ec0292:
427 		alc_update_coef_idx(codec, 0x4, 1<<15, 0);
428 		break;
429 	case 0x10ec0225:
430 	case 0x10ec0295:
431 	case 0x10ec0299:
432 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
433 		fallthrough;
434 	case 0x10ec0215:
435 	case 0x10ec0230:
436 	case 0x10ec0233:
437 	case 0x10ec0235:
438 	case 0x10ec0236:
439 	case 0x10ec0245:
440 	case 0x10ec0255:
441 	case 0x10ec0256:
442 	case 0x19e58326:
443 	case 0x10ec0257:
444 	case 0x10ec0282:
445 	case 0x10ec0283:
446 	case 0x10ec0286:
447 	case 0x10ec0288:
448 	case 0x10ec0285:
449 	case 0x10ec0298:
450 	case 0x10ec0289:
451 	case 0x10ec0300:
452 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
453 		break;
454 	case 0x10ec0275:
455 		alc_update_coef_idx(codec, 0xe, 0, 1<<0);
456 		break;
457 	case 0x10ec0287:
458 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
459 		alc_write_coef_idx(codec, 0x8, 0x4ab7);
460 		break;
461 	case 0x10ec0293:
462 		alc_update_coef_idx(codec, 0xa, 1<<13, 0);
463 		break;
464 	case 0x10ec0234:
465 	case 0x10ec0274:
466 	case 0x10ec0294:
467 	case 0x10ec0700:
468 	case 0x10ec0701:
469 	case 0x10ec0703:
470 	case 0x10ec0711:
471 		alc_update_coef_idx(codec, 0x10, 1<<15, 0);
472 		break;
473 	case 0x10ec0662:
474 		if ((coef & 0x00f0) == 0x0030)
475 			alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
476 		break;
477 	case 0x10ec0272:
478 	case 0x10ec0273:
479 	case 0x10ec0663:
480 	case 0x10ec0665:
481 	case 0x10ec0670:
482 	case 0x10ec0671:
483 	case 0x10ec0672:
484 		alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
485 		break;
486 	case 0x10ec0222:
487 	case 0x10ec0623:
488 		alc_update_coef_idx(codec, 0x19, 1<<13, 0);
489 		break;
490 	case 0x10ec0668:
491 		alc_update_coef_idx(codec, 0x7, 3<<13, 0);
492 		break;
493 	case 0x10ec0867:
494 		alc_update_coef_idx(codec, 0x4, 1<<10, 0);
495 		break;
496 	case 0x10ec0888:
497 		if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
498 			alc_update_coef_idx(codec, 0x7, 1<<5, 0);
499 		break;
500 	case 0x10ec0892:
501 	case 0x10ec0897:
502 		alc_update_coef_idx(codec, 0x7, 1<<5, 0);
503 		break;
504 	case 0x10ec0899:
505 	case 0x10ec0900:
506 	case 0x10ec0b00:
507 	case 0x10ec1168:
508 	case 0x10ec1220:
509 		alc_update_coef_idx(codec, 0x7, 1<<1, 0);
510 		break;
511 	}
512 }
513 
514 /* additional initialization for ALC888 variants */
alc888_coef_init(struct hda_codec * codec)515 static void alc888_coef_init(struct hda_codec *codec)
516 {
517 	switch (alc_get_coef0(codec) & 0x00f0) {
518 	/* alc888-VA */
519 	case 0x00:
520 	/* alc888-VB */
521 	case 0x10:
522 		alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
523 		break;
524 	}
525 }
526 
527 /* turn on/off EAPD control (only if available) */
set_eapd(struct hda_codec * codec,hda_nid_t nid,int on)528 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
529 {
530 	if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
531 		return;
532 	if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
533 		snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
534 				    on ? 2 : 0);
535 }
536 
537 /* turn on/off EAPD controls of the codec */
alc_auto_setup_eapd(struct hda_codec * codec,bool on)538 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
539 {
540 	/* We currently only handle front, HP */
541 	static const hda_nid_t pins[] = {
542 		0x0f, 0x10, 0x14, 0x15, 0x17, 0
543 	};
544 	const hda_nid_t *p;
545 	for (p = pins; *p; p++)
546 		set_eapd(codec, *p, on);
547 }
548 
549 static int find_ext_mic_pin(struct hda_codec *codec);
550 
alc_headset_mic_no_shutup(struct hda_codec * codec)551 static void alc_headset_mic_no_shutup(struct hda_codec *codec)
552 {
553 	const struct hda_pincfg *pin;
554 	int mic_pin = find_ext_mic_pin(codec);
555 	int i;
556 
557 	/* don't shut up pins when unloading the driver; otherwise it breaks
558 	 * the default pin setup at the next load of the driver
559 	 */
560 	if (codec->bus->shutdown)
561 		return;
562 
563 	snd_array_for_each(&codec->init_pins, i, pin) {
564 		/* use read here for syncing after issuing each verb */
565 		if (pin->nid != mic_pin)
566 			snd_hda_codec_read(codec, pin->nid, 0,
567 					AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
568 	}
569 
570 	codec->pins_shutup = 1;
571 }
572 
alc_shutup_pins(struct hda_codec * codec)573 static void alc_shutup_pins(struct hda_codec *codec)
574 {
575 	struct alc_spec *spec = codec->spec;
576 
577 	switch (codec->core.vendor_id) {
578 	case 0x10ec0236:
579 	case 0x10ec0256:
580 	case 0x19e58326:
581 	case 0x10ec0283:
582 	case 0x10ec0286:
583 	case 0x10ec0288:
584 	case 0x10ec0298:
585 		alc_headset_mic_no_shutup(codec);
586 		break;
587 	default:
588 		if (!spec->no_shutup_pins)
589 			snd_hda_shutup_pins(codec);
590 		break;
591 	}
592 }
593 
594 /* generic shutup callback;
595  * just turning off EAPD and a little pause for avoiding pop-noise
596  */
alc_eapd_shutup(struct hda_codec * codec)597 static void alc_eapd_shutup(struct hda_codec *codec)
598 {
599 	struct alc_spec *spec = codec->spec;
600 
601 	alc_auto_setup_eapd(codec, false);
602 	if (!spec->no_depop_delay)
603 		msleep(200);
604 	alc_shutup_pins(codec);
605 }
606 
607 /* generic EAPD initialization */
alc_auto_init_amp(struct hda_codec * codec,int type)608 static void alc_auto_init_amp(struct hda_codec *codec, int type)
609 {
610 	alc_auto_setup_eapd(codec, true);
611 	alc_write_gpio(codec);
612 	switch (type) {
613 	case ALC_INIT_DEFAULT:
614 		switch (codec->core.vendor_id) {
615 		case 0x10ec0260:
616 			alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
617 			break;
618 		case 0x10ec0880:
619 		case 0x10ec0882:
620 		case 0x10ec0883:
621 		case 0x10ec0885:
622 			alc_update_coef_idx(codec, 7, 0, 0x2030);
623 			break;
624 		case 0x10ec0888:
625 			alc888_coef_init(codec);
626 			break;
627 		}
628 		break;
629 	}
630 }
631 
632 /* get a primary headphone pin if available */
alc_get_hp_pin(struct alc_spec * spec)633 static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
634 {
635 	if (spec->gen.autocfg.hp_pins[0])
636 		return spec->gen.autocfg.hp_pins[0];
637 	if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
638 		return spec->gen.autocfg.line_out_pins[0];
639 	return 0;
640 }
641 
642 /*
643  * Realtek SSID verification
644  */
645 
646 /* Could be any non-zero and even value. When used as fixup, tells
647  * the driver to ignore any present sku defines.
648  */
649 #define ALC_FIXUP_SKU_IGNORE (2)
650 
alc_fixup_sku_ignore(struct hda_codec * codec,const struct hda_fixup * fix,int action)651 static void alc_fixup_sku_ignore(struct hda_codec *codec,
652 				 const struct hda_fixup *fix, int action)
653 {
654 	struct alc_spec *spec = codec->spec;
655 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
656 		spec->cdefine.fixup = 1;
657 		spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
658 	}
659 }
660 
alc_fixup_no_depop_delay(struct hda_codec * codec,const struct hda_fixup * fix,int action)661 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
662 				    const struct hda_fixup *fix, int action)
663 {
664 	struct alc_spec *spec = codec->spec;
665 
666 	if (action == HDA_FIXUP_ACT_PROBE) {
667 		spec->no_depop_delay = 1;
668 		codec->depop_delay = 0;
669 	}
670 }
671 
alc_auto_parse_customize_define(struct hda_codec * codec)672 static int alc_auto_parse_customize_define(struct hda_codec *codec)
673 {
674 	unsigned int ass, tmp, i;
675 	unsigned nid = 0;
676 	struct alc_spec *spec = codec->spec;
677 
678 	spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
679 
680 	if (spec->cdefine.fixup) {
681 		ass = spec->cdefine.sku_cfg;
682 		if (ass == ALC_FIXUP_SKU_IGNORE)
683 			return -1;
684 		goto do_sku;
685 	}
686 
687 	if (!codec->bus->pci)
688 		return -1;
689 	ass = codec->core.subsystem_id & 0xffff;
690 	if (ass != codec->bus->pci->subsystem_device && (ass & 1))
691 		goto do_sku;
692 
693 	nid = 0x1d;
694 	if (codec->core.vendor_id == 0x10ec0260)
695 		nid = 0x17;
696 	ass = snd_hda_codec_get_pincfg(codec, nid);
697 
698 	if (!(ass & 1)) {
699 		codec_info(codec, "%s: SKU not ready 0x%08x\n",
700 			   codec->core.chip_name, ass);
701 		return -1;
702 	}
703 
704 	/* check sum */
705 	tmp = 0;
706 	for (i = 1; i < 16; i++) {
707 		if ((ass >> i) & 1)
708 			tmp++;
709 	}
710 	if (((ass >> 16) & 0xf) != tmp)
711 		return -1;
712 
713 	spec->cdefine.port_connectivity = ass >> 30;
714 	spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
715 	spec->cdefine.check_sum = (ass >> 16) & 0xf;
716 	spec->cdefine.customization = ass >> 8;
717 do_sku:
718 	spec->cdefine.sku_cfg = ass;
719 	spec->cdefine.external_amp = (ass & 0x38) >> 3;
720 	spec->cdefine.platform_type = (ass & 0x4) >> 2;
721 	spec->cdefine.swap = (ass & 0x2) >> 1;
722 	spec->cdefine.override = ass & 0x1;
723 
724 	codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
725 		   nid, spec->cdefine.sku_cfg);
726 	codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
727 		   spec->cdefine.port_connectivity);
728 	codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
729 	codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
730 	codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
731 	codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
732 	codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
733 	codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
734 	codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
735 
736 	return 0;
737 }
738 
739 /* 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)740 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
741 {
742 	int i;
743 	for (i = 0; i < nums; i++)
744 		if (list[i] == nid)
745 			return i;
746 	return -1;
747 }
748 /* 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)749 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
750 {
751 	return find_idx_in_nid_list(nid, list, nums) >= 0;
752 }
753 
754 /* check subsystem ID and set up device-specific initialization;
755  * return 1 if initialized, 0 if invalid SSID
756  */
757 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
758  *	31 ~ 16 :	Manufacture ID
759  *	15 ~ 8	:	SKU ID
760  *	7  ~ 0	:	Assembly ID
761  *	port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
762  */
alc_subsystem_id(struct hda_codec * codec,const hda_nid_t * ports)763 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
764 {
765 	unsigned int ass, tmp, i;
766 	unsigned nid;
767 	struct alc_spec *spec = codec->spec;
768 
769 	if (spec->cdefine.fixup) {
770 		ass = spec->cdefine.sku_cfg;
771 		if (ass == ALC_FIXUP_SKU_IGNORE)
772 			return 0;
773 		goto do_sku;
774 	}
775 
776 	ass = codec->core.subsystem_id & 0xffff;
777 	if (codec->bus->pci &&
778 	    ass != codec->bus->pci->subsystem_device && (ass & 1))
779 		goto do_sku;
780 
781 	/* invalid SSID, check the special NID pin defcfg instead */
782 	/*
783 	 * 31~30	: port connectivity
784 	 * 29~21	: reserve
785 	 * 20		: PCBEEP input
786 	 * 19~16	: Check sum (15:1)
787 	 * 15~1		: Custom
788 	 * 0		: override
789 	*/
790 	nid = 0x1d;
791 	if (codec->core.vendor_id == 0x10ec0260)
792 		nid = 0x17;
793 	ass = snd_hda_codec_get_pincfg(codec, nid);
794 	codec_dbg(codec,
795 		  "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
796 		   ass, nid);
797 	if (!(ass & 1))
798 		return 0;
799 	if ((ass >> 30) != 1)	/* no physical connection */
800 		return 0;
801 
802 	/* check sum */
803 	tmp = 0;
804 	for (i = 1; i < 16; i++) {
805 		if ((ass >> i) & 1)
806 			tmp++;
807 	}
808 	if (((ass >> 16) & 0xf) != tmp)
809 		return 0;
810 do_sku:
811 	codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
812 		   ass & 0xffff, codec->core.vendor_id);
813 	/*
814 	 * 0 : override
815 	 * 1 :	Swap Jack
816 	 * 2 : 0 --> Desktop, 1 --> Laptop
817 	 * 3~5 : External Amplifier control
818 	 * 7~6 : Reserved
819 	*/
820 	tmp = (ass & 0x38) >> 3;	/* external Amp control */
821 	if (spec->init_amp == ALC_INIT_UNDEFINED) {
822 		switch (tmp) {
823 		case 1:
824 			alc_setup_gpio(codec, 0x01);
825 			break;
826 		case 3:
827 			alc_setup_gpio(codec, 0x02);
828 			break;
829 		case 7:
830 			alc_setup_gpio(codec, 0x04);
831 			break;
832 		case 5:
833 		default:
834 			spec->init_amp = ALC_INIT_DEFAULT;
835 			break;
836 		}
837 	}
838 
839 	/* is laptop or Desktop and enable the function "Mute internal speaker
840 	 * when the external headphone out jack is plugged"
841 	 */
842 	if (!(ass & 0x8000))
843 		return 1;
844 	/*
845 	 * 10~8 : Jack location
846 	 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
847 	 * 14~13: Resvered
848 	 * 15   : 1 --> enable the function "Mute internal speaker
849 	 *	        when the external headphone out jack is plugged"
850 	 */
851 	if (!alc_get_hp_pin(spec)) {
852 		hda_nid_t nid;
853 		tmp = (ass >> 11) & 0x3;	/* HP to chassis */
854 		nid = ports[tmp];
855 		if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
856 				      spec->gen.autocfg.line_outs))
857 			return 1;
858 		spec->gen.autocfg.hp_pins[0] = nid;
859 	}
860 	return 1;
861 }
862 
863 /* Check the validity of ALC subsystem-id
864  * 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)865 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
866 {
867 	if (!alc_subsystem_id(codec, ports)) {
868 		struct alc_spec *spec = codec->spec;
869 		if (spec->init_amp == ALC_INIT_UNDEFINED) {
870 			codec_dbg(codec,
871 				  "realtek: Enable default setup for auto mode as fallback\n");
872 			spec->init_amp = ALC_INIT_DEFAULT;
873 		}
874 	}
875 }
876 
877 /*
878  */
879 
alc_fixup_inv_dmic(struct hda_codec * codec,const struct hda_fixup * fix,int action)880 static void alc_fixup_inv_dmic(struct hda_codec *codec,
881 			       const struct hda_fixup *fix, int action)
882 {
883 	struct alc_spec *spec = codec->spec;
884 
885 	spec->gen.inv_dmic_split = 1;
886 }
887 
888 
alc_build_controls(struct hda_codec * codec)889 static int alc_build_controls(struct hda_codec *codec)
890 {
891 	int err;
892 
893 	err = snd_hda_gen_build_controls(codec);
894 	if (err < 0)
895 		return err;
896 
897 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
898 	return 0;
899 }
900 
901 
902 /*
903  * Common callbacks
904  */
905 
alc_pre_init(struct hda_codec * codec)906 static void alc_pre_init(struct hda_codec *codec)
907 {
908 	alc_fill_eapd_coef(codec);
909 }
910 
911 #define is_s3_resume(codec) \
912 	((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
913 #define is_s4_resume(codec) \
914 	((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
915 
alc_init(struct hda_codec * codec)916 static int alc_init(struct hda_codec *codec)
917 {
918 	struct alc_spec *spec = codec->spec;
919 
920 	/* hibernation resume needs the full chip initialization */
921 	if (is_s4_resume(codec))
922 		alc_pre_init(codec);
923 
924 	if (spec->init_hook)
925 		spec->init_hook(codec);
926 
927 	spec->gen.skip_verbs = 1; /* applied in below */
928 	snd_hda_gen_init(codec);
929 	alc_fix_pll(codec);
930 	alc_auto_init_amp(codec, spec->init_amp);
931 	snd_hda_apply_verbs(codec); /* apply verbs here after own init */
932 
933 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
934 
935 	return 0;
936 }
937 
938 #define alc_free	snd_hda_gen_free
939 
940 #ifdef CONFIG_PM
alc_shutup(struct hda_codec * codec)941 static inline void alc_shutup(struct hda_codec *codec)
942 {
943 	struct alc_spec *spec = codec->spec;
944 
945 	if (!snd_hda_get_bool_hint(codec, "shutup"))
946 		return; /* disabled explicitly by hints */
947 
948 	if (spec && spec->shutup)
949 		spec->shutup(codec);
950 	else
951 		alc_shutup_pins(codec);
952 }
953 
alc_power_eapd(struct hda_codec * codec)954 static void alc_power_eapd(struct hda_codec *codec)
955 {
956 	alc_auto_setup_eapd(codec, false);
957 }
958 
alc_suspend(struct hda_codec * codec)959 static int alc_suspend(struct hda_codec *codec)
960 {
961 	struct alc_spec *spec = codec->spec;
962 	alc_shutup(codec);
963 	if (spec && spec->power_hook)
964 		spec->power_hook(codec);
965 	return 0;
966 }
967 
alc_resume(struct hda_codec * codec)968 static int alc_resume(struct hda_codec *codec)
969 {
970 	struct alc_spec *spec = codec->spec;
971 
972 	if (!spec->no_depop_delay)
973 		msleep(150); /* to avoid pop noise */
974 	codec->patch_ops.init(codec);
975 	snd_hda_regmap_sync(codec);
976 	hda_call_check_power_status(codec, 0x01);
977 	return 0;
978 }
979 #endif
980 
981 /*
982  */
983 static const struct hda_codec_ops alc_patch_ops = {
984 	.build_controls = alc_build_controls,
985 	.build_pcms = snd_hda_gen_build_pcms,
986 	.init = alc_init,
987 	.free = alc_free,
988 	.unsol_event = snd_hda_jack_unsol_event,
989 #ifdef CONFIG_PM
990 	.resume = alc_resume,
991 	.suspend = alc_suspend,
992 	.check_power_status = snd_hda_gen_check_power_status,
993 #endif
994 };
995 
996 
997 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
998 
999 /*
1000  * Rename codecs appropriately from COEF value or subvendor id
1001  */
1002 struct alc_codec_rename_table {
1003 	unsigned int vendor_id;
1004 	unsigned short coef_mask;
1005 	unsigned short coef_bits;
1006 	const char *name;
1007 };
1008 
1009 struct alc_codec_rename_pci_table {
1010 	unsigned int codec_vendor_id;
1011 	unsigned short pci_subvendor;
1012 	unsigned short pci_subdevice;
1013 	const char *name;
1014 };
1015 
1016 static const struct alc_codec_rename_table rename_tbl[] = {
1017 	{ 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
1018 	{ 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
1019 	{ 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
1020 	{ 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
1021 	{ 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
1022 	{ 0x10ec0269, 0xffff, 0xa023, "ALC259" },
1023 	{ 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
1024 	{ 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
1025 	{ 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
1026 	{ 0x10ec0662, 0xffff, 0x4020, "ALC656" },
1027 	{ 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
1028 	{ 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
1029 	{ 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
1030 	{ 0x10ec0899, 0x2000, 0x2000, "ALC899" },
1031 	{ 0x10ec0892, 0xffff, 0x8020, "ALC661" },
1032 	{ 0x10ec0892, 0xffff, 0x8011, "ALC661" },
1033 	{ 0x10ec0892, 0xffff, 0x4011, "ALC656" },
1034 	{ } /* terminator */
1035 };
1036 
1037 static const struct alc_codec_rename_pci_table rename_pci_tbl[] = {
1038 	{ 0x10ec0280, 0x1028, 0, "ALC3220" },
1039 	{ 0x10ec0282, 0x1028, 0, "ALC3221" },
1040 	{ 0x10ec0283, 0x1028, 0, "ALC3223" },
1041 	{ 0x10ec0288, 0x1028, 0, "ALC3263" },
1042 	{ 0x10ec0292, 0x1028, 0, "ALC3226" },
1043 	{ 0x10ec0293, 0x1028, 0, "ALC3235" },
1044 	{ 0x10ec0255, 0x1028, 0, "ALC3234" },
1045 	{ 0x10ec0668, 0x1028, 0, "ALC3661" },
1046 	{ 0x10ec0275, 0x1028, 0, "ALC3260" },
1047 	{ 0x10ec0899, 0x1028, 0, "ALC3861" },
1048 	{ 0x10ec0298, 0x1028, 0, "ALC3266" },
1049 	{ 0x10ec0236, 0x1028, 0, "ALC3204" },
1050 	{ 0x10ec0256, 0x1028, 0, "ALC3246" },
1051 	{ 0x10ec0225, 0x1028, 0, "ALC3253" },
1052 	{ 0x10ec0295, 0x1028, 0, "ALC3254" },
1053 	{ 0x10ec0299, 0x1028, 0, "ALC3271" },
1054 	{ 0x10ec0670, 0x1025, 0, "ALC669X" },
1055 	{ 0x10ec0676, 0x1025, 0, "ALC679X" },
1056 	{ 0x10ec0282, 0x1043, 0, "ALC3229" },
1057 	{ 0x10ec0233, 0x1043, 0, "ALC3236" },
1058 	{ 0x10ec0280, 0x103c, 0, "ALC3228" },
1059 	{ 0x10ec0282, 0x103c, 0, "ALC3227" },
1060 	{ 0x10ec0286, 0x103c, 0, "ALC3242" },
1061 	{ 0x10ec0290, 0x103c, 0, "ALC3241" },
1062 	{ 0x10ec0668, 0x103c, 0, "ALC3662" },
1063 	{ 0x10ec0283, 0x17aa, 0, "ALC3239" },
1064 	{ 0x10ec0292, 0x17aa, 0, "ALC3232" },
1065 	{ } /* terminator */
1066 };
1067 
alc_codec_rename_from_preset(struct hda_codec * codec)1068 static int alc_codec_rename_from_preset(struct hda_codec *codec)
1069 {
1070 	const struct alc_codec_rename_table *p;
1071 	const struct alc_codec_rename_pci_table *q;
1072 
1073 	for (p = rename_tbl; p->vendor_id; p++) {
1074 		if (p->vendor_id != codec->core.vendor_id)
1075 			continue;
1076 		if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1077 			return alc_codec_rename(codec, p->name);
1078 	}
1079 
1080 	if (!codec->bus->pci)
1081 		return 0;
1082 	for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
1083 		if (q->codec_vendor_id != codec->core.vendor_id)
1084 			continue;
1085 		if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1086 			continue;
1087 		if (!q->pci_subdevice ||
1088 		    q->pci_subdevice == codec->bus->pci->subsystem_device)
1089 			return alc_codec_rename(codec, q->name);
1090 	}
1091 
1092 	return 0;
1093 }
1094 
1095 
1096 /*
1097  * Digital-beep handlers
1098  */
1099 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1100 
1101 /* additional beep mixers; private_value will be overwritten */
1102 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1103 	HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1104 	HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1105 };
1106 
1107 /* set up and create beep controls */
set_beep_amp(struct alc_spec * spec,hda_nid_t nid,int idx,int dir)1108 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
1109 			int idx, int dir)
1110 {
1111 	struct snd_kcontrol_new *knew;
1112 	unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
1113 	int i;
1114 
1115 	for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
1116 		knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1117 					    &alc_beep_mixer[i]);
1118 		if (!knew)
1119 			return -ENOMEM;
1120 		knew->private_value = beep_amp;
1121 	}
1122 	return 0;
1123 }
1124 
1125 static const struct snd_pci_quirk beep_allow_list[] = {
1126 	SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1127 	SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1128 	SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1129 	SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1130 	SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1131 	SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1132 	SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1133 	SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1134 	SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1135 	/* denylist -- no beep available */
1136 	SND_PCI_QUIRK(0x17aa, 0x309e, "Lenovo ThinkCentre M73", 0),
1137 	SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0),
1138 	{}
1139 };
1140 
has_cdefine_beep(struct hda_codec * codec)1141 static inline int has_cdefine_beep(struct hda_codec *codec)
1142 {
1143 	struct alc_spec *spec = codec->spec;
1144 	const struct snd_pci_quirk *q;
1145 	q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list);
1146 	if (q)
1147 		return q->value;
1148 	return spec->cdefine.enable_pcbeep;
1149 }
1150 #else
1151 #define set_beep_amp(spec, nid, idx, dir)	0
1152 #define has_cdefine_beep(codec)		0
1153 #endif
1154 
1155 /* parse the BIOS configuration and set up the alc_spec */
1156 /* return 1 if successful, 0 if the proper config is not found,
1157  * or a negative error code
1158  */
alc_parse_auto_config(struct hda_codec * codec,const hda_nid_t * ignore_nids,const hda_nid_t * ssid_nids)1159 static int alc_parse_auto_config(struct hda_codec *codec,
1160 				 const hda_nid_t *ignore_nids,
1161 				 const hda_nid_t *ssid_nids)
1162 {
1163 	struct alc_spec *spec = codec->spec;
1164 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1165 	int err;
1166 
1167 	err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1168 				       spec->parse_flags);
1169 	if (err < 0)
1170 		return err;
1171 
1172 	if (ssid_nids)
1173 		alc_ssid_check(codec, ssid_nids);
1174 
1175 	err = snd_hda_gen_parse_auto_config(codec, cfg);
1176 	if (err < 0)
1177 		return err;
1178 
1179 	return 1;
1180 }
1181 
1182 /* common preparation job for alc_spec */
alc_alloc_spec(struct hda_codec * codec,hda_nid_t mixer_nid)1183 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1184 {
1185 	struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1186 	int err;
1187 
1188 	if (!spec)
1189 		return -ENOMEM;
1190 	codec->spec = spec;
1191 	snd_hda_gen_spec_init(&spec->gen);
1192 	spec->gen.mixer_nid = mixer_nid;
1193 	spec->gen.own_eapd_ctl = 1;
1194 	codec->single_adc_amp = 1;
1195 	/* FIXME: do we need this for all Realtek codec models? */
1196 	codec->spdif_status_reset = 1;
1197 	codec->forced_resume = 1;
1198 	codec->patch_ops = alc_patch_ops;
1199 	mutex_init(&spec->coef_mutex);
1200 
1201 	err = alc_codec_rename_from_preset(codec);
1202 	if (err < 0) {
1203 		kfree(spec);
1204 		return err;
1205 	}
1206 	return 0;
1207 }
1208 
alc880_parse_auto_config(struct hda_codec * codec)1209 static int alc880_parse_auto_config(struct hda_codec *codec)
1210 {
1211 	static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1212 	static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1213 	return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1214 }
1215 
1216 /*
1217  * ALC880 fix-ups
1218  */
1219 enum {
1220 	ALC880_FIXUP_GPIO1,
1221 	ALC880_FIXUP_GPIO2,
1222 	ALC880_FIXUP_MEDION_RIM,
1223 	ALC880_FIXUP_LG,
1224 	ALC880_FIXUP_LG_LW25,
1225 	ALC880_FIXUP_W810,
1226 	ALC880_FIXUP_EAPD_COEF,
1227 	ALC880_FIXUP_TCL_S700,
1228 	ALC880_FIXUP_VOL_KNOB,
1229 	ALC880_FIXUP_FUJITSU,
1230 	ALC880_FIXUP_F1734,
1231 	ALC880_FIXUP_UNIWILL,
1232 	ALC880_FIXUP_UNIWILL_DIG,
1233 	ALC880_FIXUP_Z71V,
1234 	ALC880_FIXUP_ASUS_W5A,
1235 	ALC880_FIXUP_3ST_BASE,
1236 	ALC880_FIXUP_3ST,
1237 	ALC880_FIXUP_3ST_DIG,
1238 	ALC880_FIXUP_5ST_BASE,
1239 	ALC880_FIXUP_5ST,
1240 	ALC880_FIXUP_5ST_DIG,
1241 	ALC880_FIXUP_6ST_BASE,
1242 	ALC880_FIXUP_6ST,
1243 	ALC880_FIXUP_6ST_DIG,
1244 	ALC880_FIXUP_6ST_AUTOMUTE,
1245 };
1246 
1247 /* enable the volume-knob widget support on NID 0x21 */
alc880_fixup_vol_knob(struct hda_codec * codec,const struct hda_fixup * fix,int action)1248 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1249 				  const struct hda_fixup *fix, int action)
1250 {
1251 	if (action == HDA_FIXUP_ACT_PROBE)
1252 		snd_hda_jack_detect_enable_callback(codec, 0x21,
1253 						    alc_update_knob_master);
1254 }
1255 
1256 static const struct hda_fixup alc880_fixups[] = {
1257 	[ALC880_FIXUP_GPIO1] = {
1258 		.type = HDA_FIXUP_FUNC,
1259 		.v.func = alc_fixup_gpio1,
1260 	},
1261 	[ALC880_FIXUP_GPIO2] = {
1262 		.type = HDA_FIXUP_FUNC,
1263 		.v.func = alc_fixup_gpio2,
1264 	},
1265 	[ALC880_FIXUP_MEDION_RIM] = {
1266 		.type = HDA_FIXUP_VERBS,
1267 		.v.verbs = (const struct hda_verb[]) {
1268 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1269 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1270 			{ }
1271 		},
1272 		.chained = true,
1273 		.chain_id = ALC880_FIXUP_GPIO2,
1274 	},
1275 	[ALC880_FIXUP_LG] = {
1276 		.type = HDA_FIXUP_PINS,
1277 		.v.pins = (const struct hda_pintbl[]) {
1278 			/* disable bogus unused pins */
1279 			{ 0x16, 0x411111f0 },
1280 			{ 0x18, 0x411111f0 },
1281 			{ 0x1a, 0x411111f0 },
1282 			{ }
1283 		}
1284 	},
1285 	[ALC880_FIXUP_LG_LW25] = {
1286 		.type = HDA_FIXUP_PINS,
1287 		.v.pins = (const struct hda_pintbl[]) {
1288 			{ 0x1a, 0x0181344f }, /* line-in */
1289 			{ 0x1b, 0x0321403f }, /* headphone */
1290 			{ }
1291 		}
1292 	},
1293 	[ALC880_FIXUP_W810] = {
1294 		.type = HDA_FIXUP_PINS,
1295 		.v.pins = (const struct hda_pintbl[]) {
1296 			/* disable bogus unused pins */
1297 			{ 0x17, 0x411111f0 },
1298 			{ }
1299 		},
1300 		.chained = true,
1301 		.chain_id = ALC880_FIXUP_GPIO2,
1302 	},
1303 	[ALC880_FIXUP_EAPD_COEF] = {
1304 		.type = HDA_FIXUP_VERBS,
1305 		.v.verbs = (const struct hda_verb[]) {
1306 			/* change to EAPD mode */
1307 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1308 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1309 			{}
1310 		},
1311 	},
1312 	[ALC880_FIXUP_TCL_S700] = {
1313 		.type = HDA_FIXUP_VERBS,
1314 		.v.verbs = (const struct hda_verb[]) {
1315 			/* change to EAPD mode */
1316 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1317 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3070 },
1318 			{}
1319 		},
1320 		.chained = true,
1321 		.chain_id = ALC880_FIXUP_GPIO2,
1322 	},
1323 	[ALC880_FIXUP_VOL_KNOB] = {
1324 		.type = HDA_FIXUP_FUNC,
1325 		.v.func = alc880_fixup_vol_knob,
1326 	},
1327 	[ALC880_FIXUP_FUJITSU] = {
1328 		/* override all pins as BIOS on old Amilo is broken */
1329 		.type = HDA_FIXUP_PINS,
1330 		.v.pins = (const struct hda_pintbl[]) {
1331 			{ 0x14, 0x0121401f }, /* HP */
1332 			{ 0x15, 0x99030120 }, /* speaker */
1333 			{ 0x16, 0x99030130 }, /* bass speaker */
1334 			{ 0x17, 0x411111f0 }, /* N/A */
1335 			{ 0x18, 0x411111f0 }, /* N/A */
1336 			{ 0x19, 0x01a19950 }, /* mic-in */
1337 			{ 0x1a, 0x411111f0 }, /* N/A */
1338 			{ 0x1b, 0x411111f0 }, /* N/A */
1339 			{ 0x1c, 0x411111f0 }, /* N/A */
1340 			{ 0x1d, 0x411111f0 }, /* N/A */
1341 			{ 0x1e, 0x01454140 }, /* SPDIF out */
1342 			{ }
1343 		},
1344 		.chained = true,
1345 		.chain_id = ALC880_FIXUP_VOL_KNOB,
1346 	},
1347 	[ALC880_FIXUP_F1734] = {
1348 		/* almost compatible with FUJITSU, but no bass and SPDIF */
1349 		.type = HDA_FIXUP_PINS,
1350 		.v.pins = (const struct hda_pintbl[]) {
1351 			{ 0x14, 0x0121401f }, /* HP */
1352 			{ 0x15, 0x99030120 }, /* speaker */
1353 			{ 0x16, 0x411111f0 }, /* N/A */
1354 			{ 0x17, 0x411111f0 }, /* N/A */
1355 			{ 0x18, 0x411111f0 }, /* N/A */
1356 			{ 0x19, 0x01a19950 }, /* mic-in */
1357 			{ 0x1a, 0x411111f0 }, /* N/A */
1358 			{ 0x1b, 0x411111f0 }, /* N/A */
1359 			{ 0x1c, 0x411111f0 }, /* N/A */
1360 			{ 0x1d, 0x411111f0 }, /* N/A */
1361 			{ 0x1e, 0x411111f0 }, /* N/A */
1362 			{ }
1363 		},
1364 		.chained = true,
1365 		.chain_id = ALC880_FIXUP_VOL_KNOB,
1366 	},
1367 	[ALC880_FIXUP_UNIWILL] = {
1368 		/* need to fix HP and speaker pins to be parsed correctly */
1369 		.type = HDA_FIXUP_PINS,
1370 		.v.pins = (const struct hda_pintbl[]) {
1371 			{ 0x14, 0x0121411f }, /* HP */
1372 			{ 0x15, 0x99030120 }, /* speaker */
1373 			{ 0x16, 0x99030130 }, /* bass speaker */
1374 			{ }
1375 		},
1376 	},
1377 	[ALC880_FIXUP_UNIWILL_DIG] = {
1378 		.type = HDA_FIXUP_PINS,
1379 		.v.pins = (const struct hda_pintbl[]) {
1380 			/* disable bogus unused pins */
1381 			{ 0x17, 0x411111f0 },
1382 			{ 0x19, 0x411111f0 },
1383 			{ 0x1b, 0x411111f0 },
1384 			{ 0x1f, 0x411111f0 },
1385 			{ }
1386 		}
1387 	},
1388 	[ALC880_FIXUP_Z71V] = {
1389 		.type = HDA_FIXUP_PINS,
1390 		.v.pins = (const struct hda_pintbl[]) {
1391 			/* set up the whole pins as BIOS is utterly broken */
1392 			{ 0x14, 0x99030120 }, /* speaker */
1393 			{ 0x15, 0x0121411f }, /* HP */
1394 			{ 0x16, 0x411111f0 }, /* N/A */
1395 			{ 0x17, 0x411111f0 }, /* N/A */
1396 			{ 0x18, 0x01a19950 }, /* mic-in */
1397 			{ 0x19, 0x411111f0 }, /* N/A */
1398 			{ 0x1a, 0x01813031 }, /* line-in */
1399 			{ 0x1b, 0x411111f0 }, /* N/A */
1400 			{ 0x1c, 0x411111f0 }, /* N/A */
1401 			{ 0x1d, 0x411111f0 }, /* N/A */
1402 			{ 0x1e, 0x0144111e }, /* SPDIF */
1403 			{ }
1404 		}
1405 	},
1406 	[ALC880_FIXUP_ASUS_W5A] = {
1407 		.type = HDA_FIXUP_PINS,
1408 		.v.pins = (const struct hda_pintbl[]) {
1409 			/* set up the whole pins as BIOS is utterly broken */
1410 			{ 0x14, 0x0121411f }, /* HP */
1411 			{ 0x15, 0x411111f0 }, /* N/A */
1412 			{ 0x16, 0x411111f0 }, /* N/A */
1413 			{ 0x17, 0x411111f0 }, /* N/A */
1414 			{ 0x18, 0x90a60160 }, /* mic */
1415 			{ 0x19, 0x411111f0 }, /* N/A */
1416 			{ 0x1a, 0x411111f0 }, /* N/A */
1417 			{ 0x1b, 0x411111f0 }, /* N/A */
1418 			{ 0x1c, 0x411111f0 }, /* N/A */
1419 			{ 0x1d, 0x411111f0 }, /* N/A */
1420 			{ 0x1e, 0xb743111e }, /* SPDIF out */
1421 			{ }
1422 		},
1423 		.chained = true,
1424 		.chain_id = ALC880_FIXUP_GPIO1,
1425 	},
1426 	[ALC880_FIXUP_3ST_BASE] = {
1427 		.type = HDA_FIXUP_PINS,
1428 		.v.pins = (const struct hda_pintbl[]) {
1429 			{ 0x14, 0x01014010 }, /* line-out */
1430 			{ 0x15, 0x411111f0 }, /* N/A */
1431 			{ 0x16, 0x411111f0 }, /* N/A */
1432 			{ 0x17, 0x411111f0 }, /* N/A */
1433 			{ 0x18, 0x01a19c30 }, /* mic-in */
1434 			{ 0x19, 0x0121411f }, /* HP */
1435 			{ 0x1a, 0x01813031 }, /* line-in */
1436 			{ 0x1b, 0x02a19c40 }, /* front-mic */
1437 			{ 0x1c, 0x411111f0 }, /* N/A */
1438 			{ 0x1d, 0x411111f0 }, /* N/A */
1439 			/* 0x1e is filled in below */
1440 			{ 0x1f, 0x411111f0 }, /* N/A */
1441 			{ }
1442 		}
1443 	},
1444 	[ALC880_FIXUP_3ST] = {
1445 		.type = HDA_FIXUP_PINS,
1446 		.v.pins = (const struct hda_pintbl[]) {
1447 			{ 0x1e, 0x411111f0 }, /* N/A */
1448 			{ }
1449 		},
1450 		.chained = true,
1451 		.chain_id = ALC880_FIXUP_3ST_BASE,
1452 	},
1453 	[ALC880_FIXUP_3ST_DIG] = {
1454 		.type = HDA_FIXUP_PINS,
1455 		.v.pins = (const struct hda_pintbl[]) {
1456 			{ 0x1e, 0x0144111e }, /* SPDIF */
1457 			{ }
1458 		},
1459 		.chained = true,
1460 		.chain_id = ALC880_FIXUP_3ST_BASE,
1461 	},
1462 	[ALC880_FIXUP_5ST_BASE] = {
1463 		.type = HDA_FIXUP_PINS,
1464 		.v.pins = (const struct hda_pintbl[]) {
1465 			{ 0x14, 0x01014010 }, /* front */
1466 			{ 0x15, 0x411111f0 }, /* N/A */
1467 			{ 0x16, 0x01011411 }, /* CLFE */
1468 			{ 0x17, 0x01016412 }, /* surr */
1469 			{ 0x18, 0x01a19c30 }, /* mic-in */
1470 			{ 0x19, 0x0121411f }, /* HP */
1471 			{ 0x1a, 0x01813031 }, /* line-in */
1472 			{ 0x1b, 0x02a19c40 }, /* front-mic */
1473 			{ 0x1c, 0x411111f0 }, /* N/A */
1474 			{ 0x1d, 0x411111f0 }, /* N/A */
1475 			/* 0x1e is filled in below */
1476 			{ 0x1f, 0x411111f0 }, /* N/A */
1477 			{ }
1478 		}
1479 	},
1480 	[ALC880_FIXUP_5ST] = {
1481 		.type = HDA_FIXUP_PINS,
1482 		.v.pins = (const struct hda_pintbl[]) {
1483 			{ 0x1e, 0x411111f0 }, /* N/A */
1484 			{ }
1485 		},
1486 		.chained = true,
1487 		.chain_id = ALC880_FIXUP_5ST_BASE,
1488 	},
1489 	[ALC880_FIXUP_5ST_DIG] = {
1490 		.type = HDA_FIXUP_PINS,
1491 		.v.pins = (const struct hda_pintbl[]) {
1492 			{ 0x1e, 0x0144111e }, /* SPDIF */
1493 			{ }
1494 		},
1495 		.chained = true,
1496 		.chain_id = ALC880_FIXUP_5ST_BASE,
1497 	},
1498 	[ALC880_FIXUP_6ST_BASE] = {
1499 		.type = HDA_FIXUP_PINS,
1500 		.v.pins = (const struct hda_pintbl[]) {
1501 			{ 0x14, 0x01014010 }, /* front */
1502 			{ 0x15, 0x01016412 }, /* surr */
1503 			{ 0x16, 0x01011411 }, /* CLFE */
1504 			{ 0x17, 0x01012414 }, /* side */
1505 			{ 0x18, 0x01a19c30 }, /* mic-in */
1506 			{ 0x19, 0x02a19c40 }, /* front-mic */
1507 			{ 0x1a, 0x01813031 }, /* line-in */
1508 			{ 0x1b, 0x0121411f }, /* HP */
1509 			{ 0x1c, 0x411111f0 }, /* N/A */
1510 			{ 0x1d, 0x411111f0 }, /* N/A */
1511 			/* 0x1e is filled in below */
1512 			{ 0x1f, 0x411111f0 }, /* N/A */
1513 			{ }
1514 		}
1515 	},
1516 	[ALC880_FIXUP_6ST] = {
1517 		.type = HDA_FIXUP_PINS,
1518 		.v.pins = (const struct hda_pintbl[]) {
1519 			{ 0x1e, 0x411111f0 }, /* N/A */
1520 			{ }
1521 		},
1522 		.chained = true,
1523 		.chain_id = ALC880_FIXUP_6ST_BASE,
1524 	},
1525 	[ALC880_FIXUP_6ST_DIG] = {
1526 		.type = HDA_FIXUP_PINS,
1527 		.v.pins = (const struct hda_pintbl[]) {
1528 			{ 0x1e, 0x0144111e }, /* SPDIF */
1529 			{ }
1530 		},
1531 		.chained = true,
1532 		.chain_id = ALC880_FIXUP_6ST_BASE,
1533 	},
1534 	[ALC880_FIXUP_6ST_AUTOMUTE] = {
1535 		.type = HDA_FIXUP_PINS,
1536 		.v.pins = (const struct hda_pintbl[]) {
1537 			{ 0x1b, 0x0121401f }, /* HP with jack detect */
1538 			{ }
1539 		},
1540 		.chained_before = true,
1541 		.chain_id = ALC880_FIXUP_6ST_BASE,
1542 	},
1543 };
1544 
1545 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1546 	SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1547 	SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1548 	SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1549 	SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1550 	SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1551 	SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1552 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1553 	SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1554 	SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1555 	SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1556 	SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1557 	SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1558 	SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1559 	SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1560 	SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1561 	SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1562 	SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1563 	SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1564 	SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1565 	SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1566 	SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1567 	SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1568 	SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1569 
1570 	/* Below is the copied entries from alc880_quirks.c.
1571 	 * It's not quite sure whether BIOS sets the correct pin-config table
1572 	 * on these machines, thus they are kept to be compatible with
1573 	 * the old static quirks.  Once when it's confirmed to work without
1574 	 * these overrides, it'd be better to remove.
1575 	 */
1576 	SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1577 	SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1578 	SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1579 	SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1580 	SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1581 	SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1582 	SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1583 	SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1584 	SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1585 	SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1586 	SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1587 	SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1588 	SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1589 	SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1590 	SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1591 	SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1592 	SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1593 	SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1594 	SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1595 	SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1596 	SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1597 	SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1598 	SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1599 	SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1600 	SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1601 	SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1602 	SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1603 	SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1604 	SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1605 	SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1606 	SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1607 	SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1608 	SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1609 	/* default Intel */
1610 	SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1611 	SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1612 	SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1613 	{}
1614 };
1615 
1616 static const struct hda_model_fixup alc880_fixup_models[] = {
1617 	{.id = ALC880_FIXUP_3ST, .name = "3stack"},
1618 	{.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1619 	{.id = ALC880_FIXUP_5ST, .name = "5stack"},
1620 	{.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1621 	{.id = ALC880_FIXUP_6ST, .name = "6stack"},
1622 	{.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1623 	{.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1624 	{}
1625 };
1626 
1627 
1628 /*
1629  * OK, here we have finally the patch for ALC880
1630  */
patch_alc880(struct hda_codec * codec)1631 static int patch_alc880(struct hda_codec *codec)
1632 {
1633 	struct alc_spec *spec;
1634 	int err;
1635 
1636 	err = alc_alloc_spec(codec, 0x0b);
1637 	if (err < 0)
1638 		return err;
1639 
1640 	spec = codec->spec;
1641 	spec->gen.need_dac_fix = 1;
1642 	spec->gen.beep_nid = 0x01;
1643 
1644 	codec->patch_ops.unsol_event = alc880_unsol_event;
1645 
1646 	alc_pre_init(codec);
1647 
1648 	snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1649 		       alc880_fixups);
1650 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1651 
1652 	/* automatic parse from the BIOS config */
1653 	err = alc880_parse_auto_config(codec);
1654 	if (err < 0)
1655 		goto error;
1656 
1657 	if (!spec->gen.no_analog) {
1658 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1659 		if (err < 0)
1660 			goto error;
1661 	}
1662 
1663 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1664 
1665 	return 0;
1666 
1667  error:
1668 	alc_free(codec);
1669 	return err;
1670 }
1671 
1672 
1673 /*
1674  * ALC260 support
1675  */
alc260_parse_auto_config(struct hda_codec * codec)1676 static int alc260_parse_auto_config(struct hda_codec *codec)
1677 {
1678 	static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1679 	static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1680 	return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1681 }
1682 
1683 /*
1684  * Pin config fixes
1685  */
1686 enum {
1687 	ALC260_FIXUP_HP_DC5750,
1688 	ALC260_FIXUP_HP_PIN_0F,
1689 	ALC260_FIXUP_COEF,
1690 	ALC260_FIXUP_GPIO1,
1691 	ALC260_FIXUP_GPIO1_TOGGLE,
1692 	ALC260_FIXUP_REPLACER,
1693 	ALC260_FIXUP_HP_B1900,
1694 	ALC260_FIXUP_KN1,
1695 	ALC260_FIXUP_FSC_S7020,
1696 	ALC260_FIXUP_FSC_S7020_JWSE,
1697 	ALC260_FIXUP_VAIO_PINS,
1698 };
1699 
alc260_gpio1_automute(struct hda_codec * codec)1700 static void alc260_gpio1_automute(struct hda_codec *codec)
1701 {
1702 	struct alc_spec *spec = codec->spec;
1703 
1704 	alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1705 }
1706 
alc260_fixup_gpio1_toggle(struct hda_codec * codec,const struct hda_fixup * fix,int action)1707 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1708 				      const struct hda_fixup *fix, int action)
1709 {
1710 	struct alc_spec *spec = codec->spec;
1711 	if (action == HDA_FIXUP_ACT_PROBE) {
1712 		/* although the machine has only one output pin, we need to
1713 		 * toggle GPIO1 according to the jack state
1714 		 */
1715 		spec->gen.automute_hook = alc260_gpio1_automute;
1716 		spec->gen.detect_hp = 1;
1717 		spec->gen.automute_speaker = 1;
1718 		spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1719 		snd_hda_jack_detect_enable_callback(codec, 0x0f,
1720 						    snd_hda_gen_hp_automute);
1721 		alc_setup_gpio(codec, 0x01);
1722 	}
1723 }
1724 
alc260_fixup_kn1(struct hda_codec * codec,const struct hda_fixup * fix,int action)1725 static void alc260_fixup_kn1(struct hda_codec *codec,
1726 			     const struct hda_fixup *fix, int action)
1727 {
1728 	struct alc_spec *spec = codec->spec;
1729 	static const struct hda_pintbl pincfgs[] = {
1730 		{ 0x0f, 0x02214000 }, /* HP/speaker */
1731 		{ 0x12, 0x90a60160 }, /* int mic */
1732 		{ 0x13, 0x02a19000 }, /* ext mic */
1733 		{ 0x18, 0x01446000 }, /* SPDIF out */
1734 		/* disable bogus I/O pins */
1735 		{ 0x10, 0x411111f0 },
1736 		{ 0x11, 0x411111f0 },
1737 		{ 0x14, 0x411111f0 },
1738 		{ 0x15, 0x411111f0 },
1739 		{ 0x16, 0x411111f0 },
1740 		{ 0x17, 0x411111f0 },
1741 		{ 0x19, 0x411111f0 },
1742 		{ }
1743 	};
1744 
1745 	switch (action) {
1746 	case HDA_FIXUP_ACT_PRE_PROBE:
1747 		snd_hda_apply_pincfgs(codec, pincfgs);
1748 		spec->init_amp = ALC_INIT_NONE;
1749 		break;
1750 	}
1751 }
1752 
alc260_fixup_fsc_s7020(struct hda_codec * codec,const struct hda_fixup * fix,int action)1753 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1754 				   const struct hda_fixup *fix, int action)
1755 {
1756 	struct alc_spec *spec = codec->spec;
1757 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
1758 		spec->init_amp = ALC_INIT_NONE;
1759 }
1760 
alc260_fixup_fsc_s7020_jwse(struct hda_codec * codec,const struct hda_fixup * fix,int action)1761 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1762 				   const struct hda_fixup *fix, int action)
1763 {
1764 	struct alc_spec *spec = codec->spec;
1765 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1766 		spec->gen.add_jack_modes = 1;
1767 		spec->gen.hp_mic = 1;
1768 	}
1769 }
1770 
1771 static const struct hda_fixup alc260_fixups[] = {
1772 	[ALC260_FIXUP_HP_DC5750] = {
1773 		.type = HDA_FIXUP_PINS,
1774 		.v.pins = (const struct hda_pintbl[]) {
1775 			{ 0x11, 0x90130110 }, /* speaker */
1776 			{ }
1777 		}
1778 	},
1779 	[ALC260_FIXUP_HP_PIN_0F] = {
1780 		.type = HDA_FIXUP_PINS,
1781 		.v.pins = (const struct hda_pintbl[]) {
1782 			{ 0x0f, 0x01214000 }, /* HP */
1783 			{ }
1784 		}
1785 	},
1786 	[ALC260_FIXUP_COEF] = {
1787 		.type = HDA_FIXUP_VERBS,
1788 		.v.verbs = (const struct hda_verb[]) {
1789 			{ 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1790 			{ 0x1a, AC_VERB_SET_PROC_COEF,  0x3040 },
1791 			{ }
1792 		},
1793 	},
1794 	[ALC260_FIXUP_GPIO1] = {
1795 		.type = HDA_FIXUP_FUNC,
1796 		.v.func = alc_fixup_gpio1,
1797 	},
1798 	[ALC260_FIXUP_GPIO1_TOGGLE] = {
1799 		.type = HDA_FIXUP_FUNC,
1800 		.v.func = alc260_fixup_gpio1_toggle,
1801 		.chained = true,
1802 		.chain_id = ALC260_FIXUP_HP_PIN_0F,
1803 	},
1804 	[ALC260_FIXUP_REPLACER] = {
1805 		.type = HDA_FIXUP_VERBS,
1806 		.v.verbs = (const struct hda_verb[]) {
1807 			{ 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1808 			{ 0x1a, AC_VERB_SET_PROC_COEF,  0x3050 },
1809 			{ }
1810 		},
1811 		.chained = true,
1812 		.chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1813 	},
1814 	[ALC260_FIXUP_HP_B1900] = {
1815 		.type = HDA_FIXUP_FUNC,
1816 		.v.func = alc260_fixup_gpio1_toggle,
1817 		.chained = true,
1818 		.chain_id = ALC260_FIXUP_COEF,
1819 	},
1820 	[ALC260_FIXUP_KN1] = {
1821 		.type = HDA_FIXUP_FUNC,
1822 		.v.func = alc260_fixup_kn1,
1823 	},
1824 	[ALC260_FIXUP_FSC_S7020] = {
1825 		.type = HDA_FIXUP_FUNC,
1826 		.v.func = alc260_fixup_fsc_s7020,
1827 	},
1828 	[ALC260_FIXUP_FSC_S7020_JWSE] = {
1829 		.type = HDA_FIXUP_FUNC,
1830 		.v.func = alc260_fixup_fsc_s7020_jwse,
1831 		.chained = true,
1832 		.chain_id = ALC260_FIXUP_FSC_S7020,
1833 	},
1834 	[ALC260_FIXUP_VAIO_PINS] = {
1835 		.type = HDA_FIXUP_PINS,
1836 		.v.pins = (const struct hda_pintbl[]) {
1837 			/* Pin configs are missing completely on some VAIOs */
1838 			{ 0x0f, 0x01211020 },
1839 			{ 0x10, 0x0001003f },
1840 			{ 0x11, 0x411111f0 },
1841 			{ 0x12, 0x01a15930 },
1842 			{ 0x13, 0x411111f0 },
1843 			{ 0x14, 0x411111f0 },
1844 			{ 0x15, 0x411111f0 },
1845 			{ 0x16, 0x411111f0 },
1846 			{ 0x17, 0x411111f0 },
1847 			{ 0x18, 0x411111f0 },
1848 			{ 0x19, 0x411111f0 },
1849 			{ }
1850 		}
1851 	},
1852 };
1853 
1854 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1855 	SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1856 	SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1857 	SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1858 	SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1859 	SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1860 	SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1861 	SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1862 	SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1863 	SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1864 	SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1865 	SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1866 	SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1867 	{}
1868 };
1869 
1870 static const struct hda_model_fixup alc260_fixup_models[] = {
1871 	{.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1872 	{.id = ALC260_FIXUP_COEF, .name = "coef"},
1873 	{.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1874 	{.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1875 	{}
1876 };
1877 
1878 /*
1879  */
patch_alc260(struct hda_codec * codec)1880 static int patch_alc260(struct hda_codec *codec)
1881 {
1882 	struct alc_spec *spec;
1883 	int err;
1884 
1885 	err = alc_alloc_spec(codec, 0x07);
1886 	if (err < 0)
1887 		return err;
1888 
1889 	spec = codec->spec;
1890 	/* as quite a few machines require HP amp for speaker outputs,
1891 	 * it's easier to enable it unconditionally; even if it's unneeded,
1892 	 * it's almost harmless.
1893 	 */
1894 	spec->gen.prefer_hp_amp = 1;
1895 	spec->gen.beep_nid = 0x01;
1896 
1897 	spec->shutup = alc_eapd_shutup;
1898 
1899 	alc_pre_init(codec);
1900 
1901 	snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1902 			   alc260_fixups);
1903 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1904 
1905 	/* automatic parse from the BIOS config */
1906 	err = alc260_parse_auto_config(codec);
1907 	if (err < 0)
1908 		goto error;
1909 
1910 	if (!spec->gen.no_analog) {
1911 		err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1912 		if (err < 0)
1913 			goto error;
1914 	}
1915 
1916 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1917 
1918 	return 0;
1919 
1920  error:
1921 	alc_free(codec);
1922 	return err;
1923 }
1924 
1925 
1926 /*
1927  * ALC882/883/885/888/889 support
1928  *
1929  * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1930  * configuration.  Each pin widget can choose any input DACs and a mixer.
1931  * Each ADC is connected from a mixer of all inputs.  This makes possible
1932  * 6-channel independent captures.
1933  *
1934  * In addition, an independent DAC for the multi-playback (not used in this
1935  * driver yet).
1936  */
1937 
1938 /*
1939  * Pin config fixes
1940  */
1941 enum {
1942 	ALC882_FIXUP_ABIT_AW9D_MAX,
1943 	ALC882_FIXUP_LENOVO_Y530,
1944 	ALC882_FIXUP_PB_M5210,
1945 	ALC882_FIXUP_ACER_ASPIRE_7736,
1946 	ALC882_FIXUP_ASUS_W90V,
1947 	ALC889_FIXUP_CD,
1948 	ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1949 	ALC889_FIXUP_VAIO_TT,
1950 	ALC888_FIXUP_EEE1601,
1951 	ALC886_FIXUP_EAPD,
1952 	ALC882_FIXUP_EAPD,
1953 	ALC883_FIXUP_EAPD,
1954 	ALC883_FIXUP_ACER_EAPD,
1955 	ALC882_FIXUP_GPIO1,
1956 	ALC882_FIXUP_GPIO2,
1957 	ALC882_FIXUP_GPIO3,
1958 	ALC889_FIXUP_COEF,
1959 	ALC882_FIXUP_ASUS_W2JC,
1960 	ALC882_FIXUP_ACER_ASPIRE_4930G,
1961 	ALC882_FIXUP_ACER_ASPIRE_8930G,
1962 	ALC882_FIXUP_ASPIRE_8930G_VERBS,
1963 	ALC885_FIXUP_MACPRO_GPIO,
1964 	ALC889_FIXUP_DAC_ROUTE,
1965 	ALC889_FIXUP_MBP_VREF,
1966 	ALC889_FIXUP_IMAC91_VREF,
1967 	ALC889_FIXUP_MBA11_VREF,
1968 	ALC889_FIXUP_MBA21_VREF,
1969 	ALC889_FIXUP_MP11_VREF,
1970 	ALC889_FIXUP_MP41_VREF,
1971 	ALC882_FIXUP_INV_DMIC,
1972 	ALC882_FIXUP_NO_PRIMARY_HP,
1973 	ALC887_FIXUP_ASUS_BASS,
1974 	ALC887_FIXUP_BASS_CHMAP,
1975 	ALC1220_FIXUP_GB_DUAL_CODECS,
1976 	ALC1220_FIXUP_GB_X570,
1977 	ALC1220_FIXUP_CLEVO_P950,
1978 	ALC1220_FIXUP_CLEVO_PB51ED,
1979 	ALC1220_FIXUP_CLEVO_PB51ED_PINS,
1980 	ALC887_FIXUP_ASUS_AUDIO,
1981 	ALC887_FIXUP_ASUS_HMIC,
1982 	ALCS1200A_FIXUP_MIC_VREF,
1983 	ALC888VD_FIXUP_MIC_100VREF,
1984 };
1985 
alc889_fixup_coef(struct hda_codec * codec,const struct hda_fixup * fix,int action)1986 static void alc889_fixup_coef(struct hda_codec *codec,
1987 			      const struct hda_fixup *fix, int action)
1988 {
1989 	if (action != HDA_FIXUP_ACT_INIT)
1990 		return;
1991 	alc_update_coef_idx(codec, 7, 0, 0x2030);
1992 }
1993 
1994 /* set up GPIO at initialization */
alc885_fixup_macpro_gpio(struct hda_codec * codec,const struct hda_fixup * fix,int action)1995 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1996 				     const struct hda_fixup *fix, int action)
1997 {
1998 	struct alc_spec *spec = codec->spec;
1999 
2000 	spec->gpio_write_delay = true;
2001 	alc_fixup_gpio3(codec, fix, action);
2002 }
2003 
2004 /* Fix the connection of some pins for ALC889:
2005  * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
2006  * work correctly (bko#42740)
2007  */
alc889_fixup_dac_route(struct hda_codec * codec,const struct hda_fixup * fix,int action)2008 static void alc889_fixup_dac_route(struct hda_codec *codec,
2009 				   const struct hda_fixup *fix, int action)
2010 {
2011 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2012 		/* fake the connections during parsing the tree */
2013 		static const hda_nid_t conn1[] = { 0x0c, 0x0d };
2014 		static const hda_nid_t conn2[] = { 0x0e, 0x0f };
2015 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2016 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
2017 		snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
2018 		snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
2019 	} else if (action == HDA_FIXUP_ACT_PROBE) {
2020 		/* restore the connections */
2021 		static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
2022 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
2023 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
2024 		snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
2025 		snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
2026 	}
2027 }
2028 
2029 /* Set VREF on HP pin */
alc889_fixup_mbp_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2030 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
2031 				  const struct hda_fixup *fix, int action)
2032 {
2033 	static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
2034 	struct alc_spec *spec = codec->spec;
2035 	int i;
2036 
2037 	if (action != HDA_FIXUP_ACT_INIT)
2038 		return;
2039 	for (i = 0; i < ARRAY_SIZE(nids); i++) {
2040 		unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
2041 		if (get_defcfg_device(val) != AC_JACK_HP_OUT)
2042 			continue;
2043 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
2044 		val |= AC_PINCTL_VREF_80;
2045 		snd_hda_set_pin_ctl(codec, nids[i], val);
2046 		spec->gen.keep_vref_in_automute = 1;
2047 		break;
2048 	}
2049 }
2050 
alc889_fixup_mac_pins(struct hda_codec * codec,const hda_nid_t * nids,int num_nids)2051 static void alc889_fixup_mac_pins(struct hda_codec *codec,
2052 				  const hda_nid_t *nids, int num_nids)
2053 {
2054 	struct alc_spec *spec = codec->spec;
2055 	int i;
2056 
2057 	for (i = 0; i < num_nids; i++) {
2058 		unsigned int val;
2059 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
2060 		val |= AC_PINCTL_VREF_50;
2061 		snd_hda_set_pin_ctl(codec, nids[i], val);
2062 	}
2063 	spec->gen.keep_vref_in_automute = 1;
2064 }
2065 
2066 /* Set VREF on speaker pins on imac91 */
alc889_fixup_imac91_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2067 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2068 				     const struct hda_fixup *fix, int action)
2069 {
2070 	static const hda_nid_t nids[] = { 0x18, 0x1a };
2071 
2072 	if (action == HDA_FIXUP_ACT_INIT)
2073 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2074 }
2075 
2076 /* Set VREF on speaker pins on mba11 */
alc889_fixup_mba11_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2077 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2078 				    const struct hda_fixup *fix, int action)
2079 {
2080 	static const hda_nid_t nids[] = { 0x18 };
2081 
2082 	if (action == HDA_FIXUP_ACT_INIT)
2083 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2084 }
2085 
2086 /* Set VREF on speaker pins on mba21 */
alc889_fixup_mba21_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)2087 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2088 				    const struct hda_fixup *fix, int action)
2089 {
2090 	static const hda_nid_t nids[] = { 0x18, 0x19 };
2091 
2092 	if (action == HDA_FIXUP_ACT_INIT)
2093 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2094 }
2095 
2096 /* Don't take HP output as primary
2097  * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
2098  * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2099  */
alc882_fixup_no_primary_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)2100 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2101 				       const struct hda_fixup *fix, int action)
2102 {
2103 	struct alc_spec *spec = codec->spec;
2104 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2105 		spec->gen.no_primary_hp = 1;
2106 		spec->gen.no_multi_io = 1;
2107 	}
2108 }
2109 
2110 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2111 				 const struct hda_fixup *fix, int action);
2112 
2113 /* For dual-codec configuration, we need to disable some features to avoid
2114  * conflicts of kctls and PCM streams
2115  */
alc_fixup_dual_codecs(struct hda_codec * codec,const struct hda_fixup * fix,int action)2116 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2117 				  const struct hda_fixup *fix, int action)
2118 {
2119 	struct alc_spec *spec = codec->spec;
2120 
2121 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
2122 		return;
2123 	/* disable vmaster */
2124 	spec->gen.suppress_vmaster = 1;
2125 	/* auto-mute and auto-mic switch don't work with multiple codecs */
2126 	spec->gen.suppress_auto_mute = 1;
2127 	spec->gen.suppress_auto_mic = 1;
2128 	/* disable aamix as well */
2129 	spec->gen.mixer_nid = 0;
2130 	/* add location prefix to avoid conflicts */
2131 	codec->force_pin_prefix = 1;
2132 }
2133 
rename_ctl(struct hda_codec * codec,const char * oldname,const char * newname)2134 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2135 		       const char *newname)
2136 {
2137 	struct snd_kcontrol *kctl;
2138 
2139 	kctl = snd_hda_find_mixer_ctl(codec, oldname);
2140 	if (kctl)
2141 		strcpy(kctl->id.name, newname);
2142 }
2143 
alc1220_fixup_gb_dual_codecs(struct hda_codec * codec,const struct hda_fixup * fix,int action)2144 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2145 					 const struct hda_fixup *fix,
2146 					 int action)
2147 {
2148 	alc_fixup_dual_codecs(codec, fix, action);
2149 	switch (action) {
2150 	case HDA_FIXUP_ACT_PRE_PROBE:
2151 		/* override card longname to provide a unique UCM profile */
2152 		strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2153 		break;
2154 	case HDA_FIXUP_ACT_BUILD:
2155 		/* rename Capture controls depending on the codec */
2156 		rename_ctl(codec, "Capture Volume",
2157 			   codec->addr == 0 ?
2158 			   "Rear-Panel Capture Volume" :
2159 			   "Front-Panel Capture Volume");
2160 		rename_ctl(codec, "Capture Switch",
2161 			   codec->addr == 0 ?
2162 			   "Rear-Panel Capture Switch" :
2163 			   "Front-Panel Capture Switch");
2164 		break;
2165 	}
2166 }
2167 
alc1220_fixup_gb_x570(struct hda_codec * codec,const struct hda_fixup * fix,int action)2168 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
2169 				     const struct hda_fixup *fix,
2170 				     int action)
2171 {
2172 	static const hda_nid_t conn1[] = { 0x0c };
2173 	static const struct coef_fw gb_x570_coefs[] = {
2174 		WRITE_COEF(0x07, 0x03c0),
2175 		WRITE_COEF(0x1a, 0x01c1),
2176 		WRITE_COEF(0x1b, 0x0202),
2177 		WRITE_COEF(0x43, 0x3005),
2178 		{}
2179 	};
2180 
2181 	switch (action) {
2182 	case HDA_FIXUP_ACT_PRE_PROBE:
2183 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2184 		snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2185 		break;
2186 	case HDA_FIXUP_ACT_INIT:
2187 		alc_process_coef_fw(codec, gb_x570_coefs);
2188 		break;
2189 	}
2190 }
2191 
alc1220_fixup_clevo_p950(struct hda_codec * codec,const struct hda_fixup * fix,int action)2192 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2193 				     const struct hda_fixup *fix,
2194 				     int action)
2195 {
2196 	static const hda_nid_t conn1[] = { 0x0c };
2197 
2198 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
2199 		return;
2200 
2201 	alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2202 	/* We therefore want to make sure 0x14 (front headphone) and
2203 	 * 0x1b (speakers) use the stereo DAC 0x02
2204 	 */
2205 	snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2206 	snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2207 }
2208 
2209 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2210 				const struct hda_fixup *fix, int action);
2211 
alc1220_fixup_clevo_pb51ed(struct hda_codec * codec,const struct hda_fixup * fix,int action)2212 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2213 				     const struct hda_fixup *fix,
2214 				     int action)
2215 {
2216 	alc1220_fixup_clevo_p950(codec, fix, action);
2217 	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2218 }
2219 
alc887_asus_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)2220 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2221 					 struct hda_jack_callback *jack)
2222 {
2223 	struct alc_spec *spec = codec->spec;
2224 	unsigned int vref;
2225 
2226 	snd_hda_gen_hp_automute(codec, jack);
2227 
2228 	if (spec->gen.hp_jack_present)
2229 		vref = AC_PINCTL_VREF_80;
2230 	else
2231 		vref = AC_PINCTL_VREF_HIZ;
2232 	snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2233 }
2234 
alc887_fixup_asus_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)2235 static void alc887_fixup_asus_jack(struct hda_codec *codec,
2236 				     const struct hda_fixup *fix, int action)
2237 {
2238 	struct alc_spec *spec = codec->spec;
2239 	if (action != HDA_FIXUP_ACT_PROBE)
2240 		return;
2241 	snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2242 	spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
2243 }
2244 
2245 static const struct hda_fixup alc882_fixups[] = {
2246 	[ALC882_FIXUP_ABIT_AW9D_MAX] = {
2247 		.type = HDA_FIXUP_PINS,
2248 		.v.pins = (const struct hda_pintbl[]) {
2249 			{ 0x15, 0x01080104 }, /* side */
2250 			{ 0x16, 0x01011012 }, /* rear */
2251 			{ 0x17, 0x01016011 }, /* clfe */
2252 			{ }
2253 		}
2254 	},
2255 	[ALC882_FIXUP_LENOVO_Y530] = {
2256 		.type = HDA_FIXUP_PINS,
2257 		.v.pins = (const struct hda_pintbl[]) {
2258 			{ 0x15, 0x99130112 }, /* rear int speakers */
2259 			{ 0x16, 0x99130111 }, /* subwoofer */
2260 			{ }
2261 		}
2262 	},
2263 	[ALC882_FIXUP_PB_M5210] = {
2264 		.type = HDA_FIXUP_PINCTLS,
2265 		.v.pins = (const struct hda_pintbl[]) {
2266 			{ 0x19, PIN_VREF50 },
2267 			{}
2268 		}
2269 	},
2270 	[ALC882_FIXUP_ACER_ASPIRE_7736] = {
2271 		.type = HDA_FIXUP_FUNC,
2272 		.v.func = alc_fixup_sku_ignore,
2273 	},
2274 	[ALC882_FIXUP_ASUS_W90V] = {
2275 		.type = HDA_FIXUP_PINS,
2276 		.v.pins = (const struct hda_pintbl[]) {
2277 			{ 0x16, 0x99130110 }, /* fix sequence for CLFE */
2278 			{ }
2279 		}
2280 	},
2281 	[ALC889_FIXUP_CD] = {
2282 		.type = HDA_FIXUP_PINS,
2283 		.v.pins = (const struct hda_pintbl[]) {
2284 			{ 0x1c, 0x993301f0 }, /* CD */
2285 			{ }
2286 		}
2287 	},
2288 	[ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2289 		.type = HDA_FIXUP_PINS,
2290 		.v.pins = (const struct hda_pintbl[]) {
2291 			{ 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2292 			{ }
2293 		},
2294 		.chained = true,
2295 		.chain_id = ALC889_FIXUP_CD,
2296 	},
2297 	[ALC889_FIXUP_VAIO_TT] = {
2298 		.type = HDA_FIXUP_PINS,
2299 		.v.pins = (const struct hda_pintbl[]) {
2300 			{ 0x17, 0x90170111 }, /* hidden surround speaker */
2301 			{ }
2302 		}
2303 	},
2304 	[ALC888_FIXUP_EEE1601] = {
2305 		.type = HDA_FIXUP_VERBS,
2306 		.v.verbs = (const struct hda_verb[]) {
2307 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2308 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
2309 			{ }
2310 		}
2311 	},
2312 	[ALC886_FIXUP_EAPD] = {
2313 		.type = HDA_FIXUP_VERBS,
2314 		.v.verbs = (const struct hda_verb[]) {
2315 			/* change to EAPD mode */
2316 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2317 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0068 },
2318 			{ }
2319 		}
2320 	},
2321 	[ALC882_FIXUP_EAPD] = {
2322 		.type = HDA_FIXUP_VERBS,
2323 		.v.verbs = (const struct hda_verb[]) {
2324 			/* change to EAPD mode */
2325 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2326 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2327 			{ }
2328 		}
2329 	},
2330 	[ALC883_FIXUP_EAPD] = {
2331 		.type = HDA_FIXUP_VERBS,
2332 		.v.verbs = (const struct hda_verb[]) {
2333 			/* change to EAPD mode */
2334 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2335 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2336 			{ }
2337 		}
2338 	},
2339 	[ALC883_FIXUP_ACER_EAPD] = {
2340 		.type = HDA_FIXUP_VERBS,
2341 		.v.verbs = (const struct hda_verb[]) {
2342 			/* eanable EAPD on Acer laptops */
2343 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2344 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2345 			{ }
2346 		}
2347 	},
2348 	[ALC882_FIXUP_GPIO1] = {
2349 		.type = HDA_FIXUP_FUNC,
2350 		.v.func = alc_fixup_gpio1,
2351 	},
2352 	[ALC882_FIXUP_GPIO2] = {
2353 		.type = HDA_FIXUP_FUNC,
2354 		.v.func = alc_fixup_gpio2,
2355 	},
2356 	[ALC882_FIXUP_GPIO3] = {
2357 		.type = HDA_FIXUP_FUNC,
2358 		.v.func = alc_fixup_gpio3,
2359 	},
2360 	[ALC882_FIXUP_ASUS_W2JC] = {
2361 		.type = HDA_FIXUP_FUNC,
2362 		.v.func = alc_fixup_gpio1,
2363 		.chained = true,
2364 		.chain_id = ALC882_FIXUP_EAPD,
2365 	},
2366 	[ALC889_FIXUP_COEF] = {
2367 		.type = HDA_FIXUP_FUNC,
2368 		.v.func = alc889_fixup_coef,
2369 	},
2370 	[ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2371 		.type = HDA_FIXUP_PINS,
2372 		.v.pins = (const struct hda_pintbl[]) {
2373 			{ 0x16, 0x99130111 }, /* CLFE speaker */
2374 			{ 0x17, 0x99130112 }, /* surround speaker */
2375 			{ }
2376 		},
2377 		.chained = true,
2378 		.chain_id = ALC882_FIXUP_GPIO1,
2379 	},
2380 	[ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2381 		.type = HDA_FIXUP_PINS,
2382 		.v.pins = (const struct hda_pintbl[]) {
2383 			{ 0x16, 0x99130111 }, /* CLFE speaker */
2384 			{ 0x1b, 0x99130112 }, /* surround speaker */
2385 			{ }
2386 		},
2387 		.chained = true,
2388 		.chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2389 	},
2390 	[ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2391 		/* additional init verbs for Acer Aspire 8930G */
2392 		.type = HDA_FIXUP_VERBS,
2393 		.v.verbs = (const struct hda_verb[]) {
2394 			/* Enable all DACs */
2395 			/* DAC DISABLE/MUTE 1? */
2396 			/*  setting bits 1-5 disables DAC nids 0x02-0x06
2397 			 *  apparently. Init=0x38 */
2398 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2399 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2400 			/* DAC DISABLE/MUTE 2? */
2401 			/*  some bit here disables the other DACs.
2402 			 *  Init=0x4900 */
2403 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2404 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2405 			/* DMIC fix
2406 			 * This laptop has a stereo digital microphone.
2407 			 * The mics are only 1cm apart which makes the stereo
2408 			 * useless. However, either the mic or the ALC889
2409 			 * makes the signal become a difference/sum signal
2410 			 * instead of standard stereo, which is annoying.
2411 			 * So instead we flip this bit which makes the
2412 			 * codec replicate the sum signal to both channels,
2413 			 * turning it into a normal mono mic.
2414 			 */
2415 			/* DMIC_CONTROL? Init value = 0x0001 */
2416 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2417 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2418 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2419 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2420 			{ }
2421 		},
2422 		.chained = true,
2423 		.chain_id = ALC882_FIXUP_GPIO1,
2424 	},
2425 	[ALC885_FIXUP_MACPRO_GPIO] = {
2426 		.type = HDA_FIXUP_FUNC,
2427 		.v.func = alc885_fixup_macpro_gpio,
2428 	},
2429 	[ALC889_FIXUP_DAC_ROUTE] = {
2430 		.type = HDA_FIXUP_FUNC,
2431 		.v.func = alc889_fixup_dac_route,
2432 	},
2433 	[ALC889_FIXUP_MBP_VREF] = {
2434 		.type = HDA_FIXUP_FUNC,
2435 		.v.func = alc889_fixup_mbp_vref,
2436 		.chained = true,
2437 		.chain_id = ALC882_FIXUP_GPIO1,
2438 	},
2439 	[ALC889_FIXUP_IMAC91_VREF] = {
2440 		.type = HDA_FIXUP_FUNC,
2441 		.v.func = alc889_fixup_imac91_vref,
2442 		.chained = true,
2443 		.chain_id = ALC882_FIXUP_GPIO1,
2444 	},
2445 	[ALC889_FIXUP_MBA11_VREF] = {
2446 		.type = HDA_FIXUP_FUNC,
2447 		.v.func = alc889_fixup_mba11_vref,
2448 		.chained = true,
2449 		.chain_id = ALC889_FIXUP_MBP_VREF,
2450 	},
2451 	[ALC889_FIXUP_MBA21_VREF] = {
2452 		.type = HDA_FIXUP_FUNC,
2453 		.v.func = alc889_fixup_mba21_vref,
2454 		.chained = true,
2455 		.chain_id = ALC889_FIXUP_MBP_VREF,
2456 	},
2457 	[ALC889_FIXUP_MP11_VREF] = {
2458 		.type = HDA_FIXUP_FUNC,
2459 		.v.func = alc889_fixup_mba11_vref,
2460 		.chained = true,
2461 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
2462 	},
2463 	[ALC889_FIXUP_MP41_VREF] = {
2464 		.type = HDA_FIXUP_FUNC,
2465 		.v.func = alc889_fixup_mbp_vref,
2466 		.chained = true,
2467 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
2468 	},
2469 	[ALC882_FIXUP_INV_DMIC] = {
2470 		.type = HDA_FIXUP_FUNC,
2471 		.v.func = alc_fixup_inv_dmic,
2472 	},
2473 	[ALC882_FIXUP_NO_PRIMARY_HP] = {
2474 		.type = HDA_FIXUP_FUNC,
2475 		.v.func = alc882_fixup_no_primary_hp,
2476 	},
2477 	[ALC887_FIXUP_ASUS_BASS] = {
2478 		.type = HDA_FIXUP_PINS,
2479 		.v.pins = (const struct hda_pintbl[]) {
2480 			{0x16, 0x99130130}, /* bass speaker */
2481 			{}
2482 		},
2483 		.chained = true,
2484 		.chain_id = ALC887_FIXUP_BASS_CHMAP,
2485 	},
2486 	[ALC887_FIXUP_BASS_CHMAP] = {
2487 		.type = HDA_FIXUP_FUNC,
2488 		.v.func = alc_fixup_bass_chmap,
2489 	},
2490 	[ALC1220_FIXUP_GB_DUAL_CODECS] = {
2491 		.type = HDA_FIXUP_FUNC,
2492 		.v.func = alc1220_fixup_gb_dual_codecs,
2493 	},
2494 	[ALC1220_FIXUP_GB_X570] = {
2495 		.type = HDA_FIXUP_FUNC,
2496 		.v.func = alc1220_fixup_gb_x570,
2497 	},
2498 	[ALC1220_FIXUP_CLEVO_P950] = {
2499 		.type = HDA_FIXUP_FUNC,
2500 		.v.func = alc1220_fixup_clevo_p950,
2501 	},
2502 	[ALC1220_FIXUP_CLEVO_PB51ED] = {
2503 		.type = HDA_FIXUP_FUNC,
2504 		.v.func = alc1220_fixup_clevo_pb51ed,
2505 	},
2506 	[ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
2507 		.type = HDA_FIXUP_PINS,
2508 		.v.pins = (const struct hda_pintbl[]) {
2509 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2510 			{}
2511 		},
2512 		.chained = true,
2513 		.chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
2514 	},
2515 	[ALC887_FIXUP_ASUS_AUDIO] = {
2516 		.type = HDA_FIXUP_PINS,
2517 		.v.pins = (const struct hda_pintbl[]) {
2518 			{ 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
2519 			{ 0x19, 0x22219420 },
2520 			{}
2521 		},
2522 	},
2523 	[ALC887_FIXUP_ASUS_HMIC] = {
2524 		.type = HDA_FIXUP_FUNC,
2525 		.v.func = alc887_fixup_asus_jack,
2526 		.chained = true,
2527 		.chain_id = ALC887_FIXUP_ASUS_AUDIO,
2528 	},
2529 	[ALCS1200A_FIXUP_MIC_VREF] = {
2530 		.type = HDA_FIXUP_PINCTLS,
2531 		.v.pins = (const struct hda_pintbl[]) {
2532 			{ 0x18, PIN_VREF50 }, /* rear mic */
2533 			{ 0x19, PIN_VREF50 }, /* front mic */
2534 			{}
2535 		}
2536 	},
2537 	[ALC888VD_FIXUP_MIC_100VREF] = {
2538 		.type = HDA_FIXUP_PINCTLS,
2539 		.v.pins = (const struct hda_pintbl[]) {
2540 			{ 0x18, PIN_VREF100 }, /* headset mic */
2541 			{}
2542 		}
2543 	},
2544 };
2545 
2546 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2547 	SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2548 	SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2549 	SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2550 	SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2551 	SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2552 	SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2553 	SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2554 	SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2555 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2556 	SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2557 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2558 	SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2559 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
2560 	SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2561 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
2562 	SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2563 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2564 	SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2565 	SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2566 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2567 	SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2568 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2569 	SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2570 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2571 	SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2572 	SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2573 	SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2574 	SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2575 	SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2576 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2577 	SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
2578 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2579 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2580 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2581 	SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF),
2582 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2583 	SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2584 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2585 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2586 	SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2587 
2588 	/* All Apple entries are in codec SSIDs */
2589 	SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2590 	SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2591 	SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2592 	SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2593 	SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2594 	SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2595 	SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2596 	SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2597 	SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2598 	SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2599 	SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2600 	SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2601 	SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2602 	SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2603 	SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2604 	SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2605 	SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2606 	SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2607 	SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2608 	SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2609 	SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2610 	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2611 
2612 	SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2613 	SND_PCI_QUIRK(0x10ec, 0x12d8, "iBase Elo Touch", ALC888VD_FIXUP_MIC_100VREF),
2614 	SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
2615 	SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2616 	SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2617 	SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570),
2618 	SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570),
2619 	SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570),
2620 	SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
2621 	SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
2622 	SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
2623 	SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
2624 	SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
2625 	SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
2626 	SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2627 	SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS),
2628 	SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2629 	SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2630 	SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2631 	SND_PCI_QUIRK(0x1558, 0x3702, "Clevo X370SN[VW]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2632 	SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2633 	SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2634 	SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2635 	SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2636 	SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2637 	SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2638 	SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2639 	SND_PCI_QUIRK(0x1558, 0x66a2, "Clevo PE60RNE", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2640 	SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2641 	SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2642 	SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2643 	SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2644 	SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2645 	SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2646 	SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2647 	SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
2648 	SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2649 	SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
2650 	SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
2651 	SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2652 	SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2653 	SND_PCI_QUIRK(0x1558, 0x95e3, "Clevo P955[ER]T", ALC1220_FIXUP_CLEVO_P950),
2654 	SND_PCI_QUIRK(0x1558, 0x95e4, "Clevo P955ER", ALC1220_FIXUP_CLEVO_P950),
2655 	SND_PCI_QUIRK(0x1558, 0x95e5, "Clevo P955EE6", ALC1220_FIXUP_CLEVO_P950),
2656 	SND_PCI_QUIRK(0x1558, 0x95e6, "Clevo P950R[CDF]", ALC1220_FIXUP_CLEVO_P950),
2657 	SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2658 	SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2659 	SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
2660 	SND_PCI_QUIRK(0x1558, 0xd502, "Clevo PD50SNE", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2661 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2662 	SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2663 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2664 	SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2665 	{}
2666 };
2667 
2668 static const struct hda_model_fixup alc882_fixup_models[] = {
2669 	{.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2670 	{.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2671 	{.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2672 	{.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2673 	{.id = ALC889_FIXUP_CD, .name = "cd"},
2674 	{.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2675 	{.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2676 	{.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2677 	{.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2678 	{.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2679 	{.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2680 	{.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2681 	{.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2682 	{.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2683 	{.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2684 	{.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2685 	{.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2686 	{.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2687 	{.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2688 	{.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2689 	{.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2690 	{.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2691 	{.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2692 	{.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2693 	{.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2694 	{.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2695 	{.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2696 	{.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2697 	{.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2698 	{.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2699 	{.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
2700 	{.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2701 	{}
2702 };
2703 
2704 static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = {
2705 	SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950,
2706 		{0x14, 0x01014010},
2707 		{0x15, 0x01011012},
2708 		{0x16, 0x01016011},
2709 		{0x18, 0x01a19040},
2710 		{0x19, 0x02a19050},
2711 		{0x1a, 0x0181304f},
2712 		{0x1b, 0x0221401f},
2713 		{0x1e, 0x01456130}),
2714 	SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
2715 		{0x14, 0x01015010},
2716 		{0x15, 0x01011012},
2717 		{0x16, 0x01011011},
2718 		{0x18, 0x01a11040},
2719 		{0x19, 0x02a19050},
2720 		{0x1a, 0x0181104f},
2721 		{0x1b, 0x0221401f},
2722 		{0x1e, 0x01451130}),
2723 	{}
2724 };
2725 
2726 /*
2727  * BIOS auto configuration
2728  */
2729 /* almost identical with ALC880 parser... */
alc882_parse_auto_config(struct hda_codec * codec)2730 static int alc882_parse_auto_config(struct hda_codec *codec)
2731 {
2732 	static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2733 	static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2734 	return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2735 }
2736 
2737 /*
2738  */
patch_alc882(struct hda_codec * codec)2739 static int patch_alc882(struct hda_codec *codec)
2740 {
2741 	struct alc_spec *spec;
2742 	int err;
2743 
2744 	err = alc_alloc_spec(codec, 0x0b);
2745 	if (err < 0)
2746 		return err;
2747 
2748 	spec = codec->spec;
2749 
2750 	switch (codec->core.vendor_id) {
2751 	case 0x10ec0882:
2752 	case 0x10ec0885:
2753 	case 0x10ec0900:
2754 	case 0x10ec0b00:
2755 	case 0x10ec1220:
2756 		break;
2757 	default:
2758 		/* ALC883 and variants */
2759 		alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2760 		break;
2761 	}
2762 
2763 	alc_pre_init(codec);
2764 
2765 	snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2766 		       alc882_fixups);
2767 	snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
2768 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2769 
2770 	alc_auto_parse_customize_define(codec);
2771 
2772 	if (has_cdefine_beep(codec))
2773 		spec->gen.beep_nid = 0x01;
2774 
2775 	/* automatic parse from the BIOS config */
2776 	err = alc882_parse_auto_config(codec);
2777 	if (err < 0)
2778 		goto error;
2779 
2780 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
2781 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2782 		if (err < 0)
2783 			goto error;
2784 	}
2785 
2786 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2787 
2788 	return 0;
2789 
2790  error:
2791 	alc_free(codec);
2792 	return err;
2793 }
2794 
2795 
2796 /*
2797  * ALC262 support
2798  */
alc262_parse_auto_config(struct hda_codec * codec)2799 static int alc262_parse_auto_config(struct hda_codec *codec)
2800 {
2801 	static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2802 	static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2803 	return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2804 }
2805 
2806 /*
2807  * Pin config fixes
2808  */
2809 enum {
2810 	ALC262_FIXUP_FSC_H270,
2811 	ALC262_FIXUP_FSC_S7110,
2812 	ALC262_FIXUP_HP_Z200,
2813 	ALC262_FIXUP_TYAN,
2814 	ALC262_FIXUP_LENOVO_3000,
2815 	ALC262_FIXUP_BENQ,
2816 	ALC262_FIXUP_BENQ_T31,
2817 	ALC262_FIXUP_INV_DMIC,
2818 	ALC262_FIXUP_INTEL_BAYLEYBAY,
2819 };
2820 
2821 static const struct hda_fixup alc262_fixups[] = {
2822 	[ALC262_FIXUP_FSC_H270] = {
2823 		.type = HDA_FIXUP_PINS,
2824 		.v.pins = (const struct hda_pintbl[]) {
2825 			{ 0x14, 0x99130110 }, /* speaker */
2826 			{ 0x15, 0x0221142f }, /* front HP */
2827 			{ 0x1b, 0x0121141f }, /* rear HP */
2828 			{ }
2829 		}
2830 	},
2831 	[ALC262_FIXUP_FSC_S7110] = {
2832 		.type = HDA_FIXUP_PINS,
2833 		.v.pins = (const struct hda_pintbl[]) {
2834 			{ 0x15, 0x90170110 }, /* speaker */
2835 			{ }
2836 		},
2837 		.chained = true,
2838 		.chain_id = ALC262_FIXUP_BENQ,
2839 	},
2840 	[ALC262_FIXUP_HP_Z200] = {
2841 		.type = HDA_FIXUP_PINS,
2842 		.v.pins = (const struct hda_pintbl[]) {
2843 			{ 0x16, 0x99130120 }, /* internal speaker */
2844 			{ }
2845 		}
2846 	},
2847 	[ALC262_FIXUP_TYAN] = {
2848 		.type = HDA_FIXUP_PINS,
2849 		.v.pins = (const struct hda_pintbl[]) {
2850 			{ 0x14, 0x1993e1f0 }, /* int AUX */
2851 			{ }
2852 		}
2853 	},
2854 	[ALC262_FIXUP_LENOVO_3000] = {
2855 		.type = HDA_FIXUP_PINCTLS,
2856 		.v.pins = (const struct hda_pintbl[]) {
2857 			{ 0x19, PIN_VREF50 },
2858 			{}
2859 		},
2860 		.chained = true,
2861 		.chain_id = ALC262_FIXUP_BENQ,
2862 	},
2863 	[ALC262_FIXUP_BENQ] = {
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, 0x3070 },
2868 			{}
2869 		}
2870 	},
2871 	[ALC262_FIXUP_BENQ_T31] = {
2872 		.type = HDA_FIXUP_VERBS,
2873 		.v.verbs = (const struct hda_verb[]) {
2874 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2875 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2876 			{}
2877 		}
2878 	},
2879 	[ALC262_FIXUP_INV_DMIC] = {
2880 		.type = HDA_FIXUP_FUNC,
2881 		.v.func = alc_fixup_inv_dmic,
2882 	},
2883 	[ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2884 		.type = HDA_FIXUP_FUNC,
2885 		.v.func = alc_fixup_no_depop_delay,
2886 	},
2887 };
2888 
2889 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2890 	SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2891 	SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2892 	SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2893 	SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2894 	SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2895 	SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2896 	SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2897 	SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2898 	SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2899 	SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2900 	{}
2901 };
2902 
2903 static const struct hda_model_fixup alc262_fixup_models[] = {
2904 	{.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2905 	{.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2906 	{.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2907 	{.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2908 	{.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2909 	{.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2910 	{.id = ALC262_FIXUP_BENQ, .name = "benq"},
2911 	{.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2912 	{.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2913 	{}
2914 };
2915 
2916 /*
2917  */
patch_alc262(struct hda_codec * codec)2918 static int patch_alc262(struct hda_codec *codec)
2919 {
2920 	struct alc_spec *spec;
2921 	int err;
2922 
2923 	err = alc_alloc_spec(codec, 0x0b);
2924 	if (err < 0)
2925 		return err;
2926 
2927 	spec = codec->spec;
2928 	spec->gen.shared_mic_vref_pin = 0x18;
2929 
2930 	spec->shutup = alc_eapd_shutup;
2931 
2932 #if 0
2933 	/* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is
2934 	 * under-run
2935 	 */
2936 	alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2937 #endif
2938 	alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2939 
2940 	alc_pre_init(codec);
2941 
2942 	snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2943 		       alc262_fixups);
2944 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2945 
2946 	alc_auto_parse_customize_define(codec);
2947 
2948 	if (has_cdefine_beep(codec))
2949 		spec->gen.beep_nid = 0x01;
2950 
2951 	/* automatic parse from the BIOS config */
2952 	err = alc262_parse_auto_config(codec);
2953 	if (err < 0)
2954 		goto error;
2955 
2956 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
2957 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2958 		if (err < 0)
2959 			goto error;
2960 	}
2961 
2962 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2963 
2964 	return 0;
2965 
2966  error:
2967 	alc_free(codec);
2968 	return err;
2969 }
2970 
2971 /*
2972  *  ALC268
2973  */
2974 /* bind Beep switches of both NID 0x0f and 0x10 */
alc268_beep_switch_put(struct snd_kcontrol * kcontrol,struct snd_ctl_elem_value * ucontrol)2975 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2976 				  struct snd_ctl_elem_value *ucontrol)
2977 {
2978 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2979 	unsigned long pval;
2980 	int err;
2981 
2982 	mutex_lock(&codec->control_mutex);
2983 	pval = kcontrol->private_value;
2984 	kcontrol->private_value = (pval & ~0xff) | 0x0f;
2985 	err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2986 	if (err >= 0) {
2987 		kcontrol->private_value = (pval & ~0xff) | 0x10;
2988 		err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2989 	}
2990 	kcontrol->private_value = pval;
2991 	mutex_unlock(&codec->control_mutex);
2992 	return err;
2993 }
2994 
2995 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2996 	HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2997 	{
2998 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2999 		.name = "Beep Playback Switch",
3000 		.subdevice = HDA_SUBDEV_AMP_FLAG,
3001 		.info = snd_hda_mixer_amp_switch_info,
3002 		.get = snd_hda_mixer_amp_switch_get,
3003 		.put = alc268_beep_switch_put,
3004 		.private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
3005 	},
3006 };
3007 
3008 /* set PCBEEP vol = 0, mute connections */
3009 static const struct hda_verb alc268_beep_init_verbs[] = {
3010 	{0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3011 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3012 	{0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3013 	{ }
3014 };
3015 
3016 enum {
3017 	ALC268_FIXUP_INV_DMIC,
3018 	ALC268_FIXUP_HP_EAPD,
3019 	ALC268_FIXUP_SPDIF,
3020 };
3021 
3022 static const struct hda_fixup alc268_fixups[] = {
3023 	[ALC268_FIXUP_INV_DMIC] = {
3024 		.type = HDA_FIXUP_FUNC,
3025 		.v.func = alc_fixup_inv_dmic,
3026 	},
3027 	[ALC268_FIXUP_HP_EAPD] = {
3028 		.type = HDA_FIXUP_VERBS,
3029 		.v.verbs = (const struct hda_verb[]) {
3030 			{0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
3031 			{}
3032 		}
3033 	},
3034 	[ALC268_FIXUP_SPDIF] = {
3035 		.type = HDA_FIXUP_PINS,
3036 		.v.pins = (const struct hda_pintbl[]) {
3037 			{ 0x1e, 0x014b1180 }, /* enable SPDIF out */
3038 			{}
3039 		}
3040 	},
3041 };
3042 
3043 static const struct hda_model_fixup alc268_fixup_models[] = {
3044 	{.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
3045 	{.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
3046 	{.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
3047 	{}
3048 };
3049 
3050 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
3051 	SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
3052 	SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
3053 	/* below is codec SSID since multiple Toshiba laptops have the
3054 	 * same PCI SSID 1179:ff00
3055 	 */
3056 	SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
3057 	{}
3058 };
3059 
3060 /*
3061  * BIOS auto configuration
3062  */
alc268_parse_auto_config(struct hda_codec * codec)3063 static int alc268_parse_auto_config(struct hda_codec *codec)
3064 {
3065 	static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3066 	return alc_parse_auto_config(codec, NULL, alc268_ssids);
3067 }
3068 
3069 /*
3070  */
patch_alc268(struct hda_codec * codec)3071 static int patch_alc268(struct hda_codec *codec)
3072 {
3073 	struct alc_spec *spec;
3074 	int i, err;
3075 
3076 	/* ALC268 has no aa-loopback mixer */
3077 	err = alc_alloc_spec(codec, 0);
3078 	if (err < 0)
3079 		return err;
3080 
3081 	spec = codec->spec;
3082 	if (has_cdefine_beep(codec))
3083 		spec->gen.beep_nid = 0x01;
3084 
3085 	spec->shutup = alc_eapd_shutup;
3086 
3087 	alc_pre_init(codec);
3088 
3089 	snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
3090 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3091 
3092 	/* automatic parse from the BIOS config */
3093 	err = alc268_parse_auto_config(codec);
3094 	if (err < 0)
3095 		goto error;
3096 
3097 	if (err > 0 && !spec->gen.no_analog &&
3098 	    spec->gen.autocfg.speaker_pins[0] != 0x1d) {
3099 		for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
3100 			if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
3101 						  &alc268_beep_mixer[i])) {
3102 				err = -ENOMEM;
3103 				goto error;
3104 			}
3105 		}
3106 		snd_hda_add_verbs(codec, alc268_beep_init_verbs);
3107 		if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
3108 			/* override the amp caps for beep generator */
3109 			snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
3110 					  (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
3111 					  (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
3112 					  (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3113 					  (0 << AC_AMPCAP_MUTE_SHIFT));
3114 	}
3115 
3116 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3117 
3118 	return 0;
3119 
3120  error:
3121 	alc_free(codec);
3122 	return err;
3123 }
3124 
3125 /*
3126  * ALC269
3127  */
3128 
3129 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
3130 	.rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3131 };
3132 
3133 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
3134 	.rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3135 };
3136 
3137 /* different alc269-variants */
3138 enum {
3139 	ALC269_TYPE_ALC269VA,
3140 	ALC269_TYPE_ALC269VB,
3141 	ALC269_TYPE_ALC269VC,
3142 	ALC269_TYPE_ALC269VD,
3143 	ALC269_TYPE_ALC280,
3144 	ALC269_TYPE_ALC282,
3145 	ALC269_TYPE_ALC283,
3146 	ALC269_TYPE_ALC284,
3147 	ALC269_TYPE_ALC293,
3148 	ALC269_TYPE_ALC286,
3149 	ALC269_TYPE_ALC298,
3150 	ALC269_TYPE_ALC255,
3151 	ALC269_TYPE_ALC256,
3152 	ALC269_TYPE_ALC257,
3153 	ALC269_TYPE_ALC215,
3154 	ALC269_TYPE_ALC225,
3155 	ALC269_TYPE_ALC245,
3156 	ALC269_TYPE_ALC287,
3157 	ALC269_TYPE_ALC294,
3158 	ALC269_TYPE_ALC300,
3159 	ALC269_TYPE_ALC623,
3160 	ALC269_TYPE_ALC700,
3161 };
3162 
3163 /*
3164  * BIOS auto configuration
3165  */
alc269_parse_auto_config(struct hda_codec * codec)3166 static int alc269_parse_auto_config(struct hda_codec *codec)
3167 {
3168 	static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3169 	static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
3170 	static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3171 	struct alc_spec *spec = codec->spec;
3172 	const hda_nid_t *ssids;
3173 
3174 	switch (spec->codec_variant) {
3175 	case ALC269_TYPE_ALC269VA:
3176 	case ALC269_TYPE_ALC269VC:
3177 	case ALC269_TYPE_ALC280:
3178 	case ALC269_TYPE_ALC284:
3179 	case ALC269_TYPE_ALC293:
3180 		ssids = alc269va_ssids;
3181 		break;
3182 	case ALC269_TYPE_ALC269VB:
3183 	case ALC269_TYPE_ALC269VD:
3184 	case ALC269_TYPE_ALC282:
3185 	case ALC269_TYPE_ALC283:
3186 	case ALC269_TYPE_ALC286:
3187 	case ALC269_TYPE_ALC298:
3188 	case ALC269_TYPE_ALC255:
3189 	case ALC269_TYPE_ALC256:
3190 	case ALC269_TYPE_ALC257:
3191 	case ALC269_TYPE_ALC215:
3192 	case ALC269_TYPE_ALC225:
3193 	case ALC269_TYPE_ALC245:
3194 	case ALC269_TYPE_ALC287:
3195 	case ALC269_TYPE_ALC294:
3196 	case ALC269_TYPE_ALC300:
3197 	case ALC269_TYPE_ALC623:
3198 	case ALC269_TYPE_ALC700:
3199 		ssids = alc269_ssids;
3200 		break;
3201 	default:
3202 		ssids = alc269_ssids;
3203 		break;
3204 	}
3205 
3206 	return alc_parse_auto_config(codec, alc269_ignore, ssids);
3207 }
3208 
3209 static const struct hda_jack_keymap alc_headset_btn_keymap[] = {
3210 	{ SND_JACK_BTN_0, KEY_PLAYPAUSE },
3211 	{ SND_JACK_BTN_1, KEY_VOICECOMMAND },
3212 	{ SND_JACK_BTN_2, KEY_VOLUMEUP },
3213 	{ SND_JACK_BTN_3, KEY_VOLUMEDOWN },
3214 	{}
3215 };
3216 
alc_headset_btn_callback(struct hda_codec * codec,struct hda_jack_callback * jack)3217 static void alc_headset_btn_callback(struct hda_codec *codec,
3218 				     struct hda_jack_callback *jack)
3219 {
3220 	int report = 0;
3221 
3222 	if (jack->unsol_res & (7 << 13))
3223 		report |= SND_JACK_BTN_0;
3224 
3225 	if (jack->unsol_res  & (1 << 16 | 3 << 8))
3226 		report |= SND_JACK_BTN_1;
3227 
3228 	/* Volume up key */
3229 	if (jack->unsol_res & (7 << 23))
3230 		report |= SND_JACK_BTN_2;
3231 
3232 	/* Volume down key */
3233 	if (jack->unsol_res & (7 << 10))
3234 		report |= SND_JACK_BTN_3;
3235 
3236 	snd_hda_jack_set_button_state(codec, jack->nid, report);
3237 }
3238 
alc_disable_headset_jack_key(struct hda_codec * codec)3239 static void alc_disable_headset_jack_key(struct hda_codec *codec)
3240 {
3241 	struct alc_spec *spec = codec->spec;
3242 
3243 	if (!spec->has_hs_key)
3244 		return;
3245 
3246 	switch (codec->core.vendor_id) {
3247 	case 0x10ec0215:
3248 	case 0x10ec0225:
3249 	case 0x10ec0285:
3250 	case 0x10ec0287:
3251 	case 0x10ec0295:
3252 	case 0x10ec0289:
3253 	case 0x10ec0299:
3254 		alc_write_coef_idx(codec, 0x48, 0x0);
3255 		alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3256 		alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
3257 		break;
3258 	case 0x10ec0230:
3259 	case 0x10ec0236:
3260 	case 0x10ec0256:
3261 	case 0x10ec0257:
3262 	case 0x19e58326:
3263 		alc_write_coef_idx(codec, 0x48, 0x0);
3264 		alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3265 		break;
3266 	}
3267 }
3268 
alc_enable_headset_jack_key(struct hda_codec * codec)3269 static void alc_enable_headset_jack_key(struct hda_codec *codec)
3270 {
3271 	struct alc_spec *spec = codec->spec;
3272 
3273 	if (!spec->has_hs_key)
3274 		return;
3275 
3276 	switch (codec->core.vendor_id) {
3277 	case 0x10ec0215:
3278 	case 0x10ec0225:
3279 	case 0x10ec0285:
3280 	case 0x10ec0287:
3281 	case 0x10ec0295:
3282 	case 0x10ec0289:
3283 	case 0x10ec0299:
3284 		alc_write_coef_idx(codec, 0x48, 0xd011);
3285 		alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3286 		alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
3287 		break;
3288 	case 0x10ec0230:
3289 	case 0x10ec0236:
3290 	case 0x10ec0256:
3291 	case 0x10ec0257:
3292 	case 0x19e58326:
3293 		alc_write_coef_idx(codec, 0x48, 0xd011);
3294 		alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3295 		break;
3296 	}
3297 }
3298 
alc_fixup_headset_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)3299 static void alc_fixup_headset_jack(struct hda_codec *codec,
3300 				    const struct hda_fixup *fix, int action)
3301 {
3302 	struct alc_spec *spec = codec->spec;
3303 	hda_nid_t hp_pin;
3304 
3305 	switch (action) {
3306 	case HDA_FIXUP_ACT_PRE_PROBE:
3307 		spec->has_hs_key = 1;
3308 		snd_hda_jack_detect_enable_callback(codec, 0x55,
3309 						    alc_headset_btn_callback);
3310 		break;
3311 	case HDA_FIXUP_ACT_BUILD:
3312 		hp_pin = alc_get_hp_pin(spec);
3313 		if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55,
3314 							alc_headset_btn_keymap,
3315 							hp_pin))
3316 			snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack",
3317 					      false, SND_JACK_HEADSET,
3318 					      alc_headset_btn_keymap);
3319 
3320 		alc_enable_headset_jack_key(codec);
3321 		break;
3322 	}
3323 }
3324 
alc269vb_toggle_power_output(struct hda_codec * codec,int power_up)3325 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3326 {
3327 	alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3328 }
3329 
alc269_shutup(struct hda_codec * codec)3330 static void alc269_shutup(struct hda_codec *codec)
3331 {
3332 	struct alc_spec *spec = codec->spec;
3333 
3334 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3335 		alc269vb_toggle_power_output(codec, 0);
3336 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3337 			(alc_get_coef0(codec) & 0x00ff) == 0x018) {
3338 		msleep(150);
3339 	}
3340 	alc_shutup_pins(codec);
3341 }
3342 
3343 static const struct coef_fw alc282_coefs[] = {
3344 	WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3345 	UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3346 	WRITE_COEF(0x07, 0x0200), /* DMIC control */
3347 	UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3348 	UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3349 	WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3350 	WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3351 	WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
3352 	UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3353 	UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3354 	WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
3355 	UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
3356 	WRITE_COEF(0x34, 0xa0c0), /* ANC */
3357 	UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
3358 	UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3359 	UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3360 	WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3361 	WRITE_COEF(0x63, 0x2902), /* PLL */
3362 	WRITE_COEF(0x68, 0xa080), /* capless control 2 */
3363 	WRITE_COEF(0x69, 0x3400), /* capless control 3 */
3364 	WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
3365 	WRITE_COEF(0x6b, 0x0), /* capless control 5 */
3366 	UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
3367 	WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
3368 	UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
3369 	WRITE_COEF(0x71, 0x0014), /* class D test 6 */
3370 	WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
3371 	UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
3372 	WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
3373 	{}
3374 };
3375 
alc282_restore_default_value(struct hda_codec * codec)3376 static void alc282_restore_default_value(struct hda_codec *codec)
3377 {
3378 	alc_process_coef_fw(codec, alc282_coefs);
3379 }
3380 
alc282_init(struct hda_codec * codec)3381 static void alc282_init(struct hda_codec *codec)
3382 {
3383 	struct alc_spec *spec = codec->spec;
3384 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3385 	bool hp_pin_sense;
3386 	int coef78;
3387 
3388 	alc282_restore_default_value(codec);
3389 
3390 	if (!hp_pin)
3391 		return;
3392 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3393 	coef78 = alc_read_coef_idx(codec, 0x78);
3394 
3395 	/* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3396 	/* Headphone capless set to high power mode */
3397 	alc_write_coef_idx(codec, 0x78, 0x9004);
3398 
3399 	if (hp_pin_sense)
3400 		msleep(2);
3401 
3402 	snd_hda_codec_write(codec, hp_pin, 0,
3403 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3404 
3405 	if (hp_pin_sense)
3406 		msleep(85);
3407 
3408 	snd_hda_codec_write(codec, hp_pin, 0,
3409 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3410 
3411 	if (hp_pin_sense)
3412 		msleep(100);
3413 
3414 	/* Headphone capless set to normal mode */
3415 	alc_write_coef_idx(codec, 0x78, coef78);
3416 }
3417 
alc282_shutup(struct hda_codec * codec)3418 static void alc282_shutup(struct hda_codec *codec)
3419 {
3420 	struct alc_spec *spec = codec->spec;
3421 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3422 	bool hp_pin_sense;
3423 	int coef78;
3424 
3425 	if (!hp_pin) {
3426 		alc269_shutup(codec);
3427 		return;
3428 	}
3429 
3430 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3431 	coef78 = alc_read_coef_idx(codec, 0x78);
3432 	alc_write_coef_idx(codec, 0x78, 0x9004);
3433 
3434 	if (hp_pin_sense)
3435 		msleep(2);
3436 
3437 	snd_hda_codec_write(codec, hp_pin, 0,
3438 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3439 
3440 	if (hp_pin_sense)
3441 		msleep(85);
3442 
3443 	if (!spec->no_shutup_pins)
3444 		snd_hda_codec_write(codec, hp_pin, 0,
3445 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3446 
3447 	if (hp_pin_sense)
3448 		msleep(100);
3449 
3450 	alc_auto_setup_eapd(codec, false);
3451 	alc_shutup_pins(codec);
3452 	alc_write_coef_idx(codec, 0x78, coef78);
3453 }
3454 
3455 static const struct coef_fw alc283_coefs[] = {
3456 	WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3457 	UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3458 	WRITE_COEF(0x07, 0x0200), /* DMIC control */
3459 	UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3460 	UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3461 	WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3462 	WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3463 	WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3464 	UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3465 	UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3466 	WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3467 	UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3468 	WRITE_COEF(0x22, 0xa0c0), /* ANC */
3469 	UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3470 	UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3471 	UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3472 	WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3473 	WRITE_COEF(0x2e, 0x2902), /* PLL */
3474 	WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3475 	WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3476 	WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3477 	WRITE_COEF(0x36, 0x0), /* capless control 5 */
3478 	UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3479 	WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3480 	UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3481 	WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3482 	WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3483 	UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3484 	WRITE_COEF(0x49, 0x0), /* test mode */
3485 	UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3486 	UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3487 	WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3488 	UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3489 	{}
3490 };
3491 
alc283_restore_default_value(struct hda_codec * codec)3492 static void alc283_restore_default_value(struct hda_codec *codec)
3493 {
3494 	alc_process_coef_fw(codec, alc283_coefs);
3495 }
3496 
alc283_init(struct hda_codec * codec)3497 static void alc283_init(struct hda_codec *codec)
3498 {
3499 	struct alc_spec *spec = codec->spec;
3500 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3501 	bool hp_pin_sense;
3502 
3503 	alc283_restore_default_value(codec);
3504 
3505 	if (!hp_pin)
3506 		return;
3507 
3508 	msleep(30);
3509 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3510 
3511 	/* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3512 	/* Headphone capless set to high power mode */
3513 	alc_write_coef_idx(codec, 0x43, 0x9004);
3514 
3515 	snd_hda_codec_write(codec, hp_pin, 0,
3516 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3517 
3518 	if (hp_pin_sense)
3519 		msleep(85);
3520 
3521 	snd_hda_codec_write(codec, hp_pin, 0,
3522 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3523 
3524 	if (hp_pin_sense)
3525 		msleep(85);
3526 	/* Index 0x46 Combo jack auto switch control 2 */
3527 	/* 3k pull low control for Headset jack. */
3528 	alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3529 	/* Headphone capless set to normal mode */
3530 	alc_write_coef_idx(codec, 0x43, 0x9614);
3531 }
3532 
alc283_shutup(struct hda_codec * codec)3533 static void alc283_shutup(struct hda_codec *codec)
3534 {
3535 	struct alc_spec *spec = codec->spec;
3536 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3537 	bool hp_pin_sense;
3538 
3539 	if (!hp_pin) {
3540 		alc269_shutup(codec);
3541 		return;
3542 	}
3543 
3544 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3545 
3546 	alc_write_coef_idx(codec, 0x43, 0x9004);
3547 
3548 	/*depop hp during suspend*/
3549 	alc_write_coef_idx(codec, 0x06, 0x2100);
3550 
3551 	snd_hda_codec_write(codec, hp_pin, 0,
3552 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3553 
3554 	if (hp_pin_sense)
3555 		msleep(100);
3556 
3557 	if (!spec->no_shutup_pins)
3558 		snd_hda_codec_write(codec, hp_pin, 0,
3559 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3560 
3561 	alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3562 
3563 	if (hp_pin_sense)
3564 		msleep(100);
3565 	alc_auto_setup_eapd(codec, false);
3566 	alc_shutup_pins(codec);
3567 	alc_write_coef_idx(codec, 0x43, 0x9614);
3568 }
3569 
alc256_init(struct hda_codec * codec)3570 static void alc256_init(struct hda_codec *codec)
3571 {
3572 	struct alc_spec *spec = codec->spec;
3573 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3574 	bool hp_pin_sense;
3575 
3576 	if (spec->ultra_low_power) {
3577 		alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3578 		alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3579 		alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3580 		alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3581 		alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3582 		msleep(30);
3583 	}
3584 
3585 	if (!hp_pin)
3586 		hp_pin = 0x21;
3587 
3588 	msleep(30);
3589 
3590 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3591 
3592 	if (hp_pin_sense)
3593 		msleep(2);
3594 
3595 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3596 
3597 	snd_hda_codec_write(codec, hp_pin, 0,
3598 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3599 
3600 	if (hp_pin_sense || spec->ultra_low_power)
3601 		msleep(85);
3602 
3603 	snd_hda_codec_write(codec, hp_pin, 0,
3604 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3605 
3606 	if (hp_pin_sense || spec->ultra_low_power)
3607 		msleep(100);
3608 
3609 	alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3610 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3611 	alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3612 	alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3613 	/*
3614 	 * Expose headphone mic (or possibly Line In on some machines) instead
3615 	 * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3616 	 * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3617 	 * this register.
3618 	 */
3619 	alc_write_coef_idx(codec, 0x36, 0x5757);
3620 }
3621 
alc256_shutup(struct hda_codec * codec)3622 static void alc256_shutup(struct hda_codec *codec)
3623 {
3624 	struct alc_spec *spec = codec->spec;
3625 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3626 	bool hp_pin_sense;
3627 
3628 	if (!hp_pin)
3629 		hp_pin = 0x21;
3630 
3631 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3632 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3633 
3634 	if (hp_pin_sense)
3635 		msleep(2);
3636 
3637 	snd_hda_codec_write(codec, hp_pin, 0,
3638 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3639 
3640 	if (hp_pin_sense || spec->ultra_low_power)
3641 		msleep(85);
3642 
3643 	/* 3k pull low control for Headset jack. */
3644 	/* NOTE: call this before clearing the pin, otherwise codec stalls */
3645 	/* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
3646 	 * when booting with headset plugged. So skip setting it for the codec alc257
3647 	 */
3648 	if (spec->en_3kpull_low)
3649 		alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3650 
3651 	if (!spec->no_shutup_pins)
3652 		snd_hda_codec_write(codec, hp_pin, 0,
3653 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3654 
3655 	if (hp_pin_sense || spec->ultra_low_power)
3656 		msleep(100);
3657 
3658 	alc_auto_setup_eapd(codec, false);
3659 	alc_shutup_pins(codec);
3660 	if (spec->ultra_low_power) {
3661 		msleep(50);
3662 		alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3663 		alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3664 		alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3665 		alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3666 		alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3667 		msleep(30);
3668 	}
3669 }
3670 
alc285_hp_init(struct hda_codec * codec)3671 static void alc285_hp_init(struct hda_codec *codec)
3672 {
3673 	struct alc_spec *spec = codec->spec;
3674 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3675 	int i, val;
3676 	int coef38, coef0d, coef36;
3677 
3678 	alc_update_coef_idx(codec, 0x4a, 1<<15, 1<<15); /* Reset HP JD */
3679 	coef38 = alc_read_coef_idx(codec, 0x38); /* Amp control */
3680 	coef0d = alc_read_coef_idx(codec, 0x0d); /* Digital Misc control */
3681 	coef36 = alc_read_coef_idx(codec, 0x36); /* Passthrough Control */
3682 	alc_update_coef_idx(codec, 0x38, 1<<4, 0x0);
3683 	alc_update_coef_idx(codec, 0x0d, 0x110, 0x0);
3684 
3685 	alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
3686 
3687 	if (hp_pin)
3688 		snd_hda_codec_write(codec, hp_pin, 0,
3689 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3690 
3691 	msleep(130);
3692 	alc_update_coef_idx(codec, 0x36, 1<<14, 1<<14);
3693 	alc_update_coef_idx(codec, 0x36, 1<<13, 0x0);
3694 
3695 	if (hp_pin)
3696 		snd_hda_codec_write(codec, hp_pin, 0,
3697 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3698 	msleep(10);
3699 	alc_write_coef_idx(codec, 0x67, 0x0); /* Set HP depop to manual mode */
3700 	alc_write_coefex_idx(codec, 0x58, 0x00, 0x7880);
3701 	alc_write_coefex_idx(codec, 0x58, 0x0f, 0xf049);
3702 	alc_update_coefex_idx(codec, 0x58, 0x03, 0x00f0, 0x00c0);
3703 
3704 	alc_write_coefex_idx(codec, 0x58, 0x00, 0xf888); /* HP depop procedure start */
3705 	val = alc_read_coefex_idx(codec, 0x58, 0x00);
3706 	for (i = 0; i < 20 && val & 0x8000; i++) {
3707 		msleep(50);
3708 		val = alc_read_coefex_idx(codec, 0x58, 0x00);
3709 	} /* Wait for depop procedure finish  */
3710 
3711 	alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the result */
3712 	alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
3713 	alc_update_coef_idx(codec, 0x0d, 0x110, coef0d);
3714 	alc_update_coef_idx(codec, 0x36, 3<<13, coef36);
3715 
3716 	msleep(50);
3717 	alc_update_coef_idx(codec, 0x4a, 1<<15, 0);
3718 }
3719 
alc225_init(struct hda_codec * codec)3720 static void alc225_init(struct hda_codec *codec)
3721 {
3722 	struct alc_spec *spec = codec->spec;
3723 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3724 	bool hp1_pin_sense, hp2_pin_sense;
3725 
3726 	if (spec->ultra_low_power) {
3727 		alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3728 		alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3729 		alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3730 		msleep(30);
3731 	}
3732 
3733 	if (spec->codec_variant != ALC269_TYPE_ALC287 &&
3734 		spec->codec_variant != ALC269_TYPE_ALC245)
3735 		/* required only at boot or S3 and S4 resume time */
3736 		if (!spec->done_hp_init ||
3737 			is_s3_resume(codec) ||
3738 			is_s4_resume(codec)) {
3739 			alc285_hp_init(codec);
3740 			spec->done_hp_init = true;
3741 		}
3742 
3743 	if (!hp_pin)
3744 		hp_pin = 0x21;
3745 	msleep(30);
3746 
3747 	hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3748 	hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3749 
3750 	if (hp1_pin_sense || hp2_pin_sense)
3751 		msleep(2);
3752 
3753 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3754 
3755 	if (hp1_pin_sense || spec->ultra_low_power)
3756 		snd_hda_codec_write(codec, hp_pin, 0,
3757 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3758 	if (hp2_pin_sense)
3759 		snd_hda_codec_write(codec, 0x16, 0,
3760 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3761 
3762 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3763 		msleep(85);
3764 
3765 	if (hp1_pin_sense || spec->ultra_low_power)
3766 		snd_hda_codec_write(codec, hp_pin, 0,
3767 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3768 	if (hp2_pin_sense)
3769 		snd_hda_codec_write(codec, 0x16, 0,
3770 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3771 
3772 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3773 		msleep(100);
3774 
3775 	alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3776 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3777 }
3778 
alc225_shutup(struct hda_codec * codec)3779 static void alc225_shutup(struct hda_codec *codec)
3780 {
3781 	struct alc_spec *spec = codec->spec;
3782 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3783 	bool hp1_pin_sense, hp2_pin_sense;
3784 
3785 	if (!hp_pin)
3786 		hp_pin = 0x21;
3787 
3788 	alc_disable_headset_jack_key(codec);
3789 	/* 3k pull low control for Headset jack. */
3790 	alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3791 
3792 	hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3793 	hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3794 
3795 	if (hp1_pin_sense || hp2_pin_sense)
3796 		msleep(2);
3797 
3798 	if (hp1_pin_sense || spec->ultra_low_power)
3799 		snd_hda_codec_write(codec, hp_pin, 0,
3800 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3801 	if (hp2_pin_sense)
3802 		snd_hda_codec_write(codec, 0x16, 0,
3803 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3804 
3805 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3806 		msleep(85);
3807 
3808 	if (hp1_pin_sense || spec->ultra_low_power)
3809 		snd_hda_codec_write(codec, hp_pin, 0,
3810 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3811 	if (hp2_pin_sense)
3812 		snd_hda_codec_write(codec, 0x16, 0,
3813 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3814 
3815 	if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3816 		msleep(100);
3817 
3818 	alc_auto_setup_eapd(codec, false);
3819 	alc_shutup_pins(codec);
3820 	if (spec->ultra_low_power) {
3821 		msleep(50);
3822 		alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3823 		alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3824 		alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3825 		alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3826 		msleep(30);
3827 	}
3828 
3829 	alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3830 	alc_enable_headset_jack_key(codec);
3831 }
3832 
alc_default_init(struct hda_codec * codec)3833 static void alc_default_init(struct hda_codec *codec)
3834 {
3835 	struct alc_spec *spec = codec->spec;
3836 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3837 	bool hp_pin_sense;
3838 
3839 	if (!hp_pin)
3840 		return;
3841 
3842 	msleep(30);
3843 
3844 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3845 
3846 	if (hp_pin_sense)
3847 		msleep(2);
3848 
3849 	snd_hda_codec_write(codec, hp_pin, 0,
3850 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3851 
3852 	if (hp_pin_sense)
3853 		msleep(85);
3854 
3855 	snd_hda_codec_write(codec, hp_pin, 0,
3856 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3857 
3858 	if (hp_pin_sense)
3859 		msleep(100);
3860 }
3861 
alc_default_shutup(struct hda_codec * codec)3862 static void alc_default_shutup(struct hda_codec *codec)
3863 {
3864 	struct alc_spec *spec = codec->spec;
3865 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3866 	bool hp_pin_sense;
3867 
3868 	if (!hp_pin) {
3869 		alc269_shutup(codec);
3870 		return;
3871 	}
3872 
3873 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3874 
3875 	if (hp_pin_sense)
3876 		msleep(2);
3877 
3878 	snd_hda_codec_write(codec, hp_pin, 0,
3879 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3880 
3881 	if (hp_pin_sense)
3882 		msleep(85);
3883 
3884 	if (!spec->no_shutup_pins)
3885 		snd_hda_codec_write(codec, hp_pin, 0,
3886 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3887 
3888 	if (hp_pin_sense)
3889 		msleep(100);
3890 
3891 	alc_auto_setup_eapd(codec, false);
3892 	alc_shutup_pins(codec);
3893 }
3894 
alc294_hp_init(struct hda_codec * codec)3895 static void alc294_hp_init(struct hda_codec *codec)
3896 {
3897 	struct alc_spec *spec = codec->spec;
3898 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
3899 	int i, val;
3900 
3901 	if (!hp_pin)
3902 		return;
3903 
3904 	snd_hda_codec_write(codec, hp_pin, 0,
3905 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3906 
3907 	msleep(100);
3908 
3909 	if (!spec->no_shutup_pins)
3910 		snd_hda_codec_write(codec, hp_pin, 0,
3911 				    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3912 
3913 	alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3914 	alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3915 
3916 	/* Wait for depop procedure finish  */
3917 	val = alc_read_coefex_idx(codec, 0x58, 0x01);
3918 	for (i = 0; i < 20 && val & 0x0080; i++) {
3919 		msleep(50);
3920 		val = alc_read_coefex_idx(codec, 0x58, 0x01);
3921 	}
3922 	/* Set HP depop to auto mode */
3923 	alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3924 	msleep(50);
3925 }
3926 
alc294_init(struct hda_codec * codec)3927 static void alc294_init(struct hda_codec *codec)
3928 {
3929 	struct alc_spec *spec = codec->spec;
3930 
3931 	/* required only at boot or S4 resume time */
3932 	if (!spec->done_hp_init ||
3933 	    codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3934 		alc294_hp_init(codec);
3935 		spec->done_hp_init = true;
3936 	}
3937 	alc_default_init(codec);
3938 }
3939 
alc5505_coef_set(struct hda_codec * codec,unsigned int index_reg,unsigned int val)3940 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3941 			     unsigned int val)
3942 {
3943 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3944 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3945 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3946 }
3947 
alc5505_coef_get(struct hda_codec * codec,unsigned int index_reg)3948 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3949 {
3950 	unsigned int val;
3951 
3952 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3953 	val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3954 		& 0xffff;
3955 	val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3956 		<< 16;
3957 	return val;
3958 }
3959 
alc5505_dsp_halt(struct hda_codec * codec)3960 static void alc5505_dsp_halt(struct hda_codec *codec)
3961 {
3962 	unsigned int val;
3963 
3964 	alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3965 	alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3966 	alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3967 	alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3968 	alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3969 	alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3970 	alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3971 	val = alc5505_coef_get(codec, 0x6220);
3972 	alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3973 }
3974 
alc5505_dsp_back_from_halt(struct hda_codec * codec)3975 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3976 {
3977 	alc5505_coef_set(codec, 0x61b8, 0x04133302);
3978 	alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3979 	alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3980 	alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3981 	alc5505_coef_set(codec, 0x6220, 0x2002010f);
3982 	alc5505_coef_set(codec, 0x880c, 0x00000004);
3983 }
3984 
alc5505_dsp_init(struct hda_codec * codec)3985 static void alc5505_dsp_init(struct hda_codec *codec)
3986 {
3987 	unsigned int val;
3988 
3989 	alc5505_dsp_halt(codec);
3990 	alc5505_dsp_back_from_halt(codec);
3991 	alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3992 	alc5505_coef_set(codec, 0x61b0, 0x5b16);
3993 	alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3994 	alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3995 	alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3996 	alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3997 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3998 	alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3999 	alc5505_coef_set(codec, 0x61b8, 0x04173302);
4000 	alc5505_coef_set(codec, 0x61b8, 0x04163302);
4001 	alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
4002 	alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
4003 	alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
4004 
4005 	val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
4006 	if (val <= 3)
4007 		alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
4008 	else
4009 		alc5505_coef_set(codec, 0x6220, 0x6002018f);
4010 
4011 	alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
4012 	alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
4013 	alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
4014 	alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
4015 	alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
4016 	alc5505_coef_set(codec, 0x880c, 0x00000003);
4017 	alc5505_coef_set(codec, 0x880c, 0x00000010);
4018 
4019 #ifdef HALT_REALTEK_ALC5505
4020 	alc5505_dsp_halt(codec);
4021 #endif
4022 }
4023 
4024 #ifdef HALT_REALTEK_ALC5505
4025 #define alc5505_dsp_suspend(codec)	do { } while (0) /* NOP */
4026 #define alc5505_dsp_resume(codec)	do { } while (0) /* NOP */
4027 #else
4028 #define alc5505_dsp_suspend(codec)	alc5505_dsp_halt(codec)
4029 #define alc5505_dsp_resume(codec)	alc5505_dsp_back_from_halt(codec)
4030 #endif
4031 
4032 #ifdef CONFIG_PM
alc269_suspend(struct hda_codec * codec)4033 static int alc269_suspend(struct hda_codec *codec)
4034 {
4035 	struct alc_spec *spec = codec->spec;
4036 
4037 	if (spec->has_alc5505_dsp)
4038 		alc5505_dsp_suspend(codec);
4039 	return alc_suspend(codec);
4040 }
4041 
alc269_resume(struct hda_codec * codec)4042 static int alc269_resume(struct hda_codec *codec)
4043 {
4044 	struct alc_spec *spec = codec->spec;
4045 
4046 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4047 		alc269vb_toggle_power_output(codec, 0);
4048 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4049 			(alc_get_coef0(codec) & 0x00ff) == 0x018) {
4050 		msleep(150);
4051 	}
4052 
4053 	codec->patch_ops.init(codec);
4054 
4055 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4056 		alc269vb_toggle_power_output(codec, 1);
4057 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4058 			(alc_get_coef0(codec) & 0x00ff) == 0x017) {
4059 		msleep(200);
4060 	}
4061 
4062 	snd_hda_regmap_sync(codec);
4063 	hda_call_check_power_status(codec, 0x01);
4064 
4065 	/* on some machine, the BIOS will clear the codec gpio data when enter
4066 	 * suspend, and won't restore the data after resume, so we restore it
4067 	 * in the driver.
4068 	 */
4069 	if (spec->gpio_data)
4070 		alc_write_gpio_data(codec);
4071 
4072 	if (spec->has_alc5505_dsp)
4073 		alc5505_dsp_resume(codec);
4074 
4075 	return 0;
4076 }
4077 #endif /* CONFIG_PM */
4078 
alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec * codec,const struct hda_fixup * fix,int action)4079 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
4080 						 const struct hda_fixup *fix, int action)
4081 {
4082 	struct alc_spec *spec = codec->spec;
4083 
4084 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4085 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4086 }
4087 
alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4088 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
4089 						 const struct hda_fixup *fix,
4090 						 int action)
4091 {
4092 	unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
4093 	unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
4094 
4095 	if (cfg_headphone && cfg_headset_mic == 0x411111f0)
4096 		snd_hda_codec_set_pincfg(codec, 0x19,
4097 			(cfg_headphone & ~AC_DEFCFG_DEVICE) |
4098 			(AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
4099 }
4100 
alc269_fixup_hweq(struct hda_codec * codec,const struct hda_fixup * fix,int action)4101 static void alc269_fixup_hweq(struct hda_codec *codec,
4102 			       const struct hda_fixup *fix, int action)
4103 {
4104 	if (action == HDA_FIXUP_ACT_INIT)
4105 		alc_update_coef_idx(codec, 0x1e, 0, 0x80);
4106 }
4107 
alc269_fixup_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4108 static void alc269_fixup_headset_mic(struct hda_codec *codec,
4109 				       const struct hda_fixup *fix, int action)
4110 {
4111 	struct alc_spec *spec = codec->spec;
4112 
4113 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4114 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4115 }
4116 
alc271_fixup_dmic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4117 static void alc271_fixup_dmic(struct hda_codec *codec,
4118 			      const struct hda_fixup *fix, int action)
4119 {
4120 	static const struct hda_verb verbs[] = {
4121 		{0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
4122 		{0x20, AC_VERB_SET_PROC_COEF, 0x4000},
4123 		{}
4124 	};
4125 	unsigned int cfg;
4126 
4127 	if (strcmp(codec->core.chip_name, "ALC271X") &&
4128 	    strcmp(codec->core.chip_name, "ALC269VB"))
4129 		return;
4130 	cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4131 	if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
4132 		snd_hda_sequence_write(codec, verbs);
4133 }
4134 
4135 /* Fix the speaker amp after resume, etc */
alc269vb_fixup_aspire_e1_coef(struct hda_codec * codec,const struct hda_fixup * fix,int action)4136 static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4137 					  const struct hda_fixup *fix,
4138 					  int action)
4139 {
4140 	if (action == HDA_FIXUP_ACT_INIT)
4141 		alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4142 }
4143 
alc269_fixup_pcm_44k(struct hda_codec * codec,const struct hda_fixup * fix,int action)4144 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4145 				 const struct hda_fixup *fix, int action)
4146 {
4147 	struct alc_spec *spec = codec->spec;
4148 
4149 	if (action != HDA_FIXUP_ACT_PROBE)
4150 		return;
4151 
4152 	/* Due to a hardware problem on Lenovo Ideadpad, we need to
4153 	 * fix the sample rate of analog I/O to 44.1kHz
4154 	 */
4155 	spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
4156 	spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
4157 }
4158 
alc269_fixup_stereo_dmic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4159 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4160 				     const struct hda_fixup *fix, int action)
4161 {
4162 	/* The digital-mic unit sends PDM (differential signal) instead of
4163 	 * the standard PCM, thus you can't record a valid mono stream as is.
4164 	 * Below is a workaround specific to ALC269 to control the dmic
4165 	 * signal source as mono.
4166 	 */
4167 	if (action == HDA_FIXUP_ACT_INIT)
4168 		alc_update_coef_idx(codec, 0x07, 0, 0x80);
4169 }
4170 
alc269_quanta_automute(struct hda_codec * codec)4171 static void alc269_quanta_automute(struct hda_codec *codec)
4172 {
4173 	snd_hda_gen_update_outputs(codec);
4174 
4175 	alc_write_coef_idx(codec, 0x0c, 0x680);
4176 	alc_write_coef_idx(codec, 0x0c, 0x480);
4177 }
4178 
alc269_fixup_quanta_mute(struct hda_codec * codec,const struct hda_fixup * fix,int action)4179 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4180 				     const struct hda_fixup *fix, int action)
4181 {
4182 	struct alc_spec *spec = codec->spec;
4183 	if (action != HDA_FIXUP_ACT_PROBE)
4184 		return;
4185 	spec->gen.automute_hook = alc269_quanta_automute;
4186 }
4187 
alc269_x101_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)4188 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4189 					 struct hda_jack_callback *jack)
4190 {
4191 	struct alc_spec *spec = codec->spec;
4192 	int vref;
4193 	msleep(200);
4194 	snd_hda_gen_hp_automute(codec, jack);
4195 
4196 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4197 	msleep(100);
4198 	snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4199 			    vref);
4200 	msleep(500);
4201 	snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4202 			    vref);
4203 }
4204 
4205 /*
4206  * Magic sequence to make Huawei Matebook X right speaker working (bko#197801)
4207  */
4208 struct hda_alc298_mbxinit {
4209 	unsigned char value_0x23;
4210 	unsigned char value_0x25;
4211 };
4212 
alc298_huawei_mbx_stereo_seq(struct hda_codec * codec,const struct hda_alc298_mbxinit * initval,bool first)4213 static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4214 					 const struct hda_alc298_mbxinit *initval,
4215 					 bool first)
4216 {
4217 	snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4218 	alc_write_coef_idx(codec, 0x26, 0xb000);
4219 
4220 	if (first)
4221 		snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4222 
4223 	snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4224 	alc_write_coef_idx(codec, 0x26, 0xf000);
4225 	alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4226 
4227 	if (initval->value_0x23 != 0x1e)
4228 		alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4229 
4230 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4231 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4232 }
4233 
alc298_fixup_huawei_mbx_stereo(struct hda_codec * codec,const struct hda_fixup * fix,int action)4234 static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4235 					   const struct hda_fixup *fix,
4236 					   int action)
4237 {
4238 	/* Initialization magic */
4239 	static const struct hda_alc298_mbxinit dac_init[] = {
4240 		{0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00},
4241 		{0x10, 0x00}, {0x1a, 0x40}, {0x1b, 0x82}, {0x1c, 0x00},
4242 		{0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00},
4243 		{0x20, 0xc2}, {0x21, 0xc8}, {0x22, 0x26}, {0x23, 0x24},
4244 		{0x27, 0xff}, {0x28, 0xff}, {0x29, 0xff}, {0x2a, 0x8f},
4245 		{0x2b, 0x02}, {0x2c, 0x48}, {0x2d, 0x34}, {0x2e, 0x00},
4246 		{0x2f, 0x00},
4247 		{0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00},
4248 		{0x34, 0x00}, {0x35, 0x01}, {0x36, 0x93}, {0x37, 0x0c},
4249 		{0x38, 0x00}, {0x39, 0x00}, {0x3a, 0xf8}, {0x38, 0x80},
4250 		{}
4251 	};
4252 	const struct hda_alc298_mbxinit *seq;
4253 
4254 	if (action != HDA_FIXUP_ACT_INIT)
4255 		return;
4256 
4257 	/* Start */
4258 	snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4259 	snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4260 	alc_write_coef_idx(codec, 0x26, 0xf000);
4261 	alc_write_coef_idx(codec, 0x22, 0x31);
4262 	alc_write_coef_idx(codec, 0x23, 0x0b);
4263 	alc_write_coef_idx(codec, 0x25, 0x00);
4264 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4265 	snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4266 
4267 	for (seq = dac_init; seq->value_0x23; seq++)
4268 		alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4269 }
4270 
alc269_fixup_x101_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)4271 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4272 				     const struct hda_fixup *fix, int action)
4273 {
4274 	struct alc_spec *spec = codec->spec;
4275 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4276 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4277 		spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
4278 	}
4279 }
4280 
alc_update_vref_led(struct hda_codec * codec,hda_nid_t pin,bool polarity,bool on)4281 static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin,
4282 				bool polarity, bool on)
4283 {
4284 	unsigned int pinval;
4285 
4286 	if (!pin)
4287 		return;
4288 	if (polarity)
4289 		on = !on;
4290 	pinval = snd_hda_codec_get_pin_target(codec, pin);
4291 	pinval &= ~AC_PINCTL_VREFEN;
4292 	pinval |= on ? AC_PINCTL_VREF_80 : AC_PINCTL_VREF_HIZ;
4293 	/* temporarily power up/down for setting VREF */
4294 	snd_hda_power_up_pm(codec);
4295 	snd_hda_set_pin_ctl_cache(codec, pin, pinval);
4296 	snd_hda_power_down_pm(codec);
4297 }
4298 
4299 /* 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)4300 static int vref_mute_led_set(struct led_classdev *led_cdev,
4301 			     enum led_brightness brightness)
4302 {
4303 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4304 	struct alc_spec *spec = codec->spec;
4305 
4306 	alc_update_vref_led(codec, spec->mute_led_nid,
4307 			    spec->mute_led_polarity, brightness);
4308 	return 0;
4309 }
4310 
4311 /* Make sure the led works even in runtime suspend */
led_power_filter(struct hda_codec * codec,hda_nid_t nid,unsigned int power_state)4312 static unsigned int led_power_filter(struct hda_codec *codec,
4313 						  hda_nid_t nid,
4314 						  unsigned int power_state)
4315 {
4316 	struct alc_spec *spec = codec->spec;
4317 
4318 	if (power_state != AC_PWRST_D3 || nid == 0 ||
4319 	    (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
4320 		return power_state;
4321 
4322 	/* Set pin ctl again, it might have just been set to 0 */
4323 	snd_hda_set_pin_ctl(codec, nid,
4324 			    snd_hda_codec_get_pin_target(codec, nid));
4325 
4326 	return snd_hda_gen_path_power_filter(codec, nid, power_state);
4327 }
4328 
alc269_fixup_hp_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4329 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4330 				     const struct hda_fixup *fix, int action)
4331 {
4332 	struct alc_spec *spec = codec->spec;
4333 	const struct dmi_device *dev = NULL;
4334 
4335 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
4336 		return;
4337 
4338 	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
4339 		int pol, pin;
4340 		if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
4341 			continue;
4342 		if (pin < 0x0a || pin >= 0x10)
4343 			break;
4344 		spec->mute_led_polarity = pol;
4345 		spec->mute_led_nid = pin - 0x0a + 0x18;
4346 		snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4347 		codec->power_filter = led_power_filter;
4348 		codec_dbg(codec,
4349 			  "Detected mute LED for %x:%d\n", spec->mute_led_nid,
4350 			   spec->mute_led_polarity);
4351 		break;
4352 	}
4353 }
4354 
alc269_fixup_hp_mute_led_micx(struct hda_codec * codec,const struct hda_fixup * fix,int action,hda_nid_t pin)4355 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4356 					  const struct hda_fixup *fix,
4357 					  int action, hda_nid_t pin)
4358 {
4359 	struct alc_spec *spec = codec->spec;
4360 
4361 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4362 		spec->mute_led_polarity = 0;
4363 		spec->mute_led_nid = pin;
4364 		snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4365 		codec->power_filter = led_power_filter;
4366 	}
4367 }
4368 
alc269_fixup_hp_mute_led_mic1(struct hda_codec * codec,const struct hda_fixup * fix,int action)4369 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4370 				const struct hda_fixup *fix, int action)
4371 {
4372 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4373 }
4374 
alc269_fixup_hp_mute_led_mic2(struct hda_codec * codec,const struct hda_fixup * fix,int action)4375 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4376 				const struct hda_fixup *fix, int action)
4377 {
4378 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4379 }
4380 
alc269_fixup_hp_mute_led_mic3(struct hda_codec * codec,const struct hda_fixup * fix,int action)4381 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4382 				const struct hda_fixup *fix, int action)
4383 {
4384 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4385 }
4386 
4387 /* update LED status via GPIO */
alc_update_gpio_led(struct hda_codec * codec,unsigned int mask,int polarity,bool enabled)4388 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4389 				int polarity, bool enabled)
4390 {
4391 	if (polarity)
4392 		enabled = !enabled;
4393 	alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4394 }
4395 
4396 /* turn on/off mute LED via GPIO per vmaster hook */
gpio_mute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4397 static int gpio_mute_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_mute_led_mask,
4404 			    spec->mute_led_polarity, !brightness);
4405 	return 0;
4406 }
4407 
4408 /* turn on/off mic-mute LED via GPIO per capture hook */
micmute_led_set(struct led_classdev * led_cdev,enum led_brightness brightness)4409 static int micmute_led_set(struct led_classdev *led_cdev,
4410 			   enum led_brightness brightness)
4411 {
4412 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4413 	struct alc_spec *spec = codec->spec;
4414 
4415 	alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4416 			    spec->micmute_led_polarity, !brightness);
4417 	return 0;
4418 }
4419 
4420 /* 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)4421 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4422 				  int action,
4423 				  unsigned int mute_mask,
4424 				  unsigned int micmute_mask)
4425 {
4426 	struct alc_spec *spec = codec->spec;
4427 
4428 	alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4429 
4430 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
4431 		return;
4432 	if (mute_mask) {
4433 		spec->gpio_mute_led_mask = mute_mask;
4434 		snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set);
4435 	}
4436 	if (micmute_mask) {
4437 		spec->gpio_mic_led_mask = micmute_mask;
4438 		snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set);
4439 	}
4440 }
4441 
alc236_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4442 static void alc236_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, 0x02, 0x01);
4446 }
4447 
alc269_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4448 static void alc269_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, 0x08, 0x10);
4452 }
4453 
alc285_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4454 static void alc285_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, 0x04, 0x01);
4458 }
4459 
alc286_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4460 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4461 				const struct hda_fixup *fix, int action)
4462 {
4463 	alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4464 }
4465 
alc287_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4466 static void alc287_fixup_hp_gpio_led(struct hda_codec *codec,
4467 				const struct hda_fixup *fix, int action)
4468 {
4469 	alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
4470 }
4471 
alc245_fixup_hp_gpio_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4472 static void alc245_fixup_hp_gpio_led(struct hda_codec *codec,
4473 				const struct hda_fixup *fix, int action)
4474 {
4475 	struct alc_spec *spec = codec->spec;
4476 
4477 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4478 		spec->micmute_led_polarity = 1;
4479 	alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4480 }
4481 
4482 /* 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)4483 static int vref_micmute_led_set(struct led_classdev *led_cdev,
4484 				enum led_brightness brightness)
4485 {
4486 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4487 	struct alc_spec *spec = codec->spec;
4488 
4489 	alc_update_vref_led(codec, spec->cap_mute_led_nid,
4490 			    spec->micmute_led_polarity, brightness);
4491 	return 0;
4492 }
4493 
alc269_fixup_hp_gpio_mic1_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4494 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4495 				const struct hda_fixup *fix, int action)
4496 {
4497 	struct alc_spec *spec = codec->spec;
4498 
4499 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4500 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4501 		/* Like hp_gpio_mic1_led, but also needs GPIO4 low to
4502 		 * enable headphone amp
4503 		 */
4504 		spec->gpio_mask |= 0x10;
4505 		spec->gpio_dir |= 0x10;
4506 		spec->cap_mute_led_nid = 0x18;
4507 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4508 		codec->power_filter = led_power_filter;
4509 	}
4510 }
4511 
alc280_fixup_hp_gpio4(struct hda_codec * codec,const struct hda_fixup * fix,int action)4512 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4513 				   const struct hda_fixup *fix, int action)
4514 {
4515 	struct alc_spec *spec = codec->spec;
4516 
4517 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4518 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4519 		spec->cap_mute_led_nid = 0x18;
4520 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4521 		codec->power_filter = led_power_filter;
4522 	}
4523 }
4524 
4525 /* HP Spectre x360 14 model needs a unique workaround for enabling the amp;
4526  * it needs to toggle the GPIO0 once on and off at each time (bko#210633)
4527  */
alc245_fixup_hp_x360_amp(struct hda_codec * codec,const struct hda_fixup * fix,int action)4528 static void alc245_fixup_hp_x360_amp(struct hda_codec *codec,
4529 				     const struct hda_fixup *fix, int action)
4530 {
4531 	struct alc_spec *spec = codec->spec;
4532 
4533 	switch (action) {
4534 	case HDA_FIXUP_ACT_PRE_PROBE:
4535 		spec->gpio_mask |= 0x01;
4536 		spec->gpio_dir |= 0x01;
4537 		break;
4538 	case HDA_FIXUP_ACT_INIT:
4539 		/* need to toggle GPIO to enable the amp */
4540 		alc_update_gpio_data(codec, 0x01, true);
4541 		msleep(100);
4542 		alc_update_gpio_data(codec, 0x01, false);
4543 		break;
4544 	}
4545 }
4546 
4547 /* 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)4548 static void alc274_hp_envy_pcm_hook(struct hda_pcm_stream *hinfo,
4549 				    struct hda_codec *codec,
4550 				    struct snd_pcm_substream *substream,
4551 				    int action)
4552 {
4553 	switch (action) {
4554 	case HDA_GEN_PCM_ACT_PREPARE:
4555 		alc_update_gpio_data(codec, 0x04, true);
4556 		break;
4557 	case HDA_GEN_PCM_ACT_CLEANUP:
4558 		alc_update_gpio_data(codec, 0x04, false);
4559 		break;
4560 	}
4561 }
4562 
alc274_fixup_hp_envy_gpio(struct hda_codec * codec,const struct hda_fixup * fix,int action)4563 static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec,
4564 				      const struct hda_fixup *fix,
4565 				      int action)
4566 {
4567 	struct alc_spec *spec = codec->spec;
4568 
4569 	if (action == HDA_FIXUP_ACT_PROBE) {
4570 		spec->gpio_mask |= 0x04;
4571 		spec->gpio_dir |= 0x04;
4572 		spec->gen.pcm_playback_hook = alc274_hp_envy_pcm_hook;
4573 	}
4574 }
4575 
alc_update_coef_led(struct hda_codec * codec,struct alc_coef_led * led,bool polarity,bool on)4576 static void alc_update_coef_led(struct hda_codec *codec,
4577 				struct alc_coef_led *led,
4578 				bool polarity, bool on)
4579 {
4580 	if (polarity)
4581 		on = !on;
4582 	/* temporarily power up/down for setting COEF bit */
4583 	alc_update_coef_idx(codec, led->idx, led->mask,
4584 			    on ? led->on : led->off);
4585 }
4586 
4587 /* 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)4588 static int coef_mute_led_set(struct led_classdev *led_cdev,
4589 			     enum led_brightness brightness)
4590 {
4591 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4592 	struct alc_spec *spec = codec->spec;
4593 
4594 	alc_update_coef_led(codec, &spec->mute_led_coef,
4595 			    spec->mute_led_polarity, brightness);
4596 	return 0;
4597 }
4598 
alc285_fixup_hp_mute_led_coefbit(struct hda_codec * codec,const struct hda_fixup * fix,int action)4599 static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4600 					  const struct hda_fixup *fix,
4601 					  int action)
4602 {
4603 	struct alc_spec *spec = codec->spec;
4604 
4605 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4606 		spec->mute_led_polarity = 0;
4607 		spec->mute_led_coef.idx = 0x0b;
4608 		spec->mute_led_coef.mask = 1 << 3;
4609 		spec->mute_led_coef.on = 1 << 3;
4610 		spec->mute_led_coef.off = 0;
4611 		snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4612 	}
4613 }
4614 
alc236_fixup_hp_mute_led_coefbit(struct hda_codec * codec,const struct hda_fixup * fix,int action)4615 static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4616 					  const struct hda_fixup *fix,
4617 					  int action)
4618 {
4619 	struct alc_spec *spec = codec->spec;
4620 
4621 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4622 		spec->mute_led_polarity = 0;
4623 		spec->mute_led_coef.idx = 0x34;
4624 		spec->mute_led_coef.mask = 1 << 5;
4625 		spec->mute_led_coef.on = 0;
4626 		spec->mute_led_coef.off = 1 << 5;
4627 		snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4628 	}
4629 }
4630 
alc236_fixup_hp_mute_led_coefbit2(struct hda_codec * codec,const struct hda_fixup * fix,int action)4631 static void alc236_fixup_hp_mute_led_coefbit2(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->mute_led_polarity = 0;
4638 		spec->mute_led_coef.idx = 0x07;
4639 		spec->mute_led_coef.mask = 1;
4640 		spec->mute_led_coef.on = 1;
4641 		spec->mute_led_coef.off = 0;
4642 		snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4643 	}
4644 }
4645 
4646 /* 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)4647 static int coef_micmute_led_set(struct led_classdev *led_cdev,
4648 				enum led_brightness brightness)
4649 {
4650 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4651 	struct alc_spec *spec = codec->spec;
4652 
4653 	alc_update_coef_led(codec, &spec->mic_led_coef,
4654 			    spec->micmute_led_polarity, brightness);
4655 	return 0;
4656 }
4657 
alc285_fixup_hp_coef_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4658 static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4659 				const struct hda_fixup *fix, int action)
4660 {
4661 	struct alc_spec *spec = codec->spec;
4662 
4663 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4664 		spec->mic_led_coef.idx = 0x19;
4665 		spec->mic_led_coef.mask = 1 << 13;
4666 		spec->mic_led_coef.on = 1 << 13;
4667 		spec->mic_led_coef.off = 0;
4668 		snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4669 	}
4670 }
4671 
alc285_fixup_hp_gpio_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4672 static void alc285_fixup_hp_gpio_micmute_led(struct hda_codec *codec,
4673 				const struct hda_fixup *fix, int action)
4674 {
4675 	struct alc_spec *spec = codec->spec;
4676 
4677 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
4678 		spec->micmute_led_polarity = 1;
4679 	alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4680 }
4681 
alc236_fixup_hp_coef_micmute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4682 static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4683 				const struct hda_fixup *fix, int action)
4684 {
4685 	struct alc_spec *spec = codec->spec;
4686 
4687 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4688 		spec->mic_led_coef.idx = 0x35;
4689 		spec->mic_led_coef.mask = 3 << 2;
4690 		spec->mic_led_coef.on = 2 << 2;
4691 		spec->mic_led_coef.off = 1 << 2;
4692 		snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4693 	}
4694 }
4695 
alc285_fixup_hp_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4696 static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4697 				const struct hda_fixup *fix, int action)
4698 {
4699 	alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4700 	alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4701 }
4702 
alc285_fixup_hp_spectre_x360_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4703 static void alc285_fixup_hp_spectre_x360_mute_led(struct hda_codec *codec,
4704 				const struct hda_fixup *fix, int action)
4705 {
4706 	alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4707 	alc285_fixup_hp_gpio_micmute_led(codec, fix, action);
4708 }
4709 
alc236_fixup_hp_mute_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4710 static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4711 				const struct hda_fixup *fix, int action)
4712 {
4713 	alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4714 	alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4715 }
4716 
alc236_fixup_hp_micmute_led_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)4717 static void alc236_fixup_hp_micmute_led_vref(struct hda_codec *codec,
4718 				const struct hda_fixup *fix, int action)
4719 {
4720 	struct alc_spec *spec = codec->spec;
4721 
4722 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4723 		spec->cap_mute_led_nid = 0x1a;
4724 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4725 		codec->power_filter = led_power_filter;
4726 	}
4727 }
4728 
alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)4729 static void alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec *codec,
4730 				const struct hda_fixup *fix, int action)
4731 {
4732 	alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4733 	alc236_fixup_hp_micmute_led_vref(codec, fix, action);
4734 }
4735 
alc298_samsung_write_coef_pack(struct hda_codec * codec,const unsigned short coefs[2])4736 static inline void alc298_samsung_write_coef_pack(struct hda_codec *codec,
4737 						  const unsigned short coefs[2])
4738 {
4739 	alc_write_coef_idx(codec, 0x23, coefs[0]);
4740 	alc_write_coef_idx(codec, 0x25, coefs[1]);
4741 	alc_write_coef_idx(codec, 0x26, 0xb011);
4742 }
4743 
4744 struct alc298_samsung_amp_desc {
4745 	unsigned char nid;
4746 	unsigned short init_seq[2][2];
4747 };
4748 
alc298_fixup_samsung_amp(struct hda_codec * codec,const struct hda_fixup * fix,int action)4749 static void alc298_fixup_samsung_amp(struct hda_codec *codec,
4750 				     const struct hda_fixup *fix, int action)
4751 {
4752 	int i, j;
4753 	static const unsigned short init_seq[][2] = {
4754 		{ 0x19, 0x00 }, { 0x20, 0xc0 }, { 0x22, 0x44 }, { 0x23, 0x08 },
4755 		{ 0x24, 0x85 }, { 0x25, 0x41 }, { 0x35, 0x40 }, { 0x36, 0x01 },
4756 		{ 0x38, 0x81 }, { 0x3a, 0x03 }, { 0x3b, 0x81 }, { 0x40, 0x3e },
4757 		{ 0x41, 0x07 }, { 0x400, 0x1 }
4758 	};
4759 	static const struct alc298_samsung_amp_desc amps[] = {
4760 		{ 0x3a, { { 0x18, 0x1 }, { 0x26, 0x0 } } },
4761 		{ 0x39, { { 0x18, 0x2 }, { 0x26, 0x1 } } }
4762 	};
4763 
4764 	if (action != HDA_FIXUP_ACT_INIT)
4765 		return;
4766 
4767 	for (i = 0; i < ARRAY_SIZE(amps); i++) {
4768 		alc_write_coef_idx(codec, 0x22, amps[i].nid);
4769 
4770 		for (j = 0; j < ARRAY_SIZE(amps[i].init_seq); j++)
4771 			alc298_samsung_write_coef_pack(codec, amps[i].init_seq[j]);
4772 
4773 		for (j = 0; j < ARRAY_SIZE(init_seq); j++)
4774 			alc298_samsung_write_coef_pack(codec, init_seq[j]);
4775 	}
4776 }
4777 
4778 #if IS_REACHABLE(CONFIG_INPUT)
gpio2_mic_hotkey_event(struct hda_codec * codec,struct hda_jack_callback * event)4779 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4780 				   struct hda_jack_callback *event)
4781 {
4782 	struct alc_spec *spec = codec->spec;
4783 
4784 	/* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4785 	   send both key on and key off event for every interrupt. */
4786 	input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4787 	input_sync(spec->kb_dev);
4788 	input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4789 	input_sync(spec->kb_dev);
4790 }
4791 
alc_register_micmute_input_device(struct hda_codec * codec)4792 static int alc_register_micmute_input_device(struct hda_codec *codec)
4793 {
4794 	struct alc_spec *spec = codec->spec;
4795 	int i;
4796 
4797 	spec->kb_dev = input_allocate_device();
4798 	if (!spec->kb_dev) {
4799 		codec_err(codec, "Out of memory (input_allocate_device)\n");
4800 		return -ENOMEM;
4801 	}
4802 
4803 	spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4804 
4805 	spec->kb_dev->name = "Microphone Mute Button";
4806 	spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4807 	spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4808 	spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4809 	spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4810 	for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4811 		set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4812 
4813 	if (input_register_device(spec->kb_dev)) {
4814 		codec_err(codec, "input_register_device failed\n");
4815 		input_free_device(spec->kb_dev);
4816 		spec->kb_dev = NULL;
4817 		return -ENOMEM;
4818 	}
4819 
4820 	return 0;
4821 }
4822 
4823 /* GPIO1 = set according to SKU external amp
4824  * GPIO2 = mic mute hotkey
4825  * GPIO3 = mute LED
4826  * GPIO4 = mic mute LED
4827  */
alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec * codec,const struct hda_fixup * fix,int action)4828 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4829 					     const struct hda_fixup *fix, int action)
4830 {
4831 	struct alc_spec *spec = codec->spec;
4832 
4833 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4834 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4835 		spec->init_amp = ALC_INIT_DEFAULT;
4836 		if (alc_register_micmute_input_device(codec) != 0)
4837 			return;
4838 
4839 		spec->gpio_mask |= 0x06;
4840 		spec->gpio_dir |= 0x02;
4841 		spec->gpio_data |= 0x02;
4842 		snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4843 					  AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
4844 		snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4845 						    gpio2_mic_hotkey_event);
4846 		return;
4847 	}
4848 
4849 	if (!spec->kb_dev)
4850 		return;
4851 
4852 	switch (action) {
4853 	case HDA_FIXUP_ACT_FREE:
4854 		input_unregister_device(spec->kb_dev);
4855 		spec->kb_dev = NULL;
4856 	}
4857 }
4858 
4859 /* Line2 = mic mute hotkey
4860  * GPIO2 = mic mute LED
4861  */
alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec * codec,const struct hda_fixup * fix,int action)4862 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4863 					     const struct hda_fixup *fix, int action)
4864 {
4865 	struct alc_spec *spec = codec->spec;
4866 
4867 	alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4868 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4869 		spec->init_amp = ALC_INIT_DEFAULT;
4870 		if (alc_register_micmute_input_device(codec) != 0)
4871 			return;
4872 
4873 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
4874 						    gpio2_mic_hotkey_event);
4875 		return;
4876 	}
4877 
4878 	if (!spec->kb_dev)
4879 		return;
4880 
4881 	switch (action) {
4882 	case HDA_FIXUP_ACT_FREE:
4883 		input_unregister_device(spec->kb_dev);
4884 		spec->kb_dev = NULL;
4885 	}
4886 }
4887 #else /* INPUT */
4888 #define alc280_fixup_hp_gpio2_mic_hotkey	NULL
4889 #define alc233_fixup_lenovo_line2_mic_hotkey	NULL
4890 #endif /* INPUT */
4891 
alc269_fixup_hp_line1_mic1_led(struct hda_codec * codec,const struct hda_fixup * fix,int action)4892 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4893 				const struct hda_fixup *fix, int action)
4894 {
4895 	struct alc_spec *spec = codec->spec;
4896 
4897 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4898 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4899 		spec->cap_mute_led_nid = 0x18;
4900 		snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4901 	}
4902 }
4903 
4904 static const struct coef_fw alc225_pre_hsmode[] = {
4905 	UPDATE_COEF(0x4a, 1<<8, 0),
4906 	UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4907 	UPDATE_COEF(0x63, 3<<14, 3<<14),
4908 	UPDATE_COEF(0x4a, 3<<4, 2<<4),
4909 	UPDATE_COEF(0x4a, 3<<10, 3<<10),
4910 	UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4911 	UPDATE_COEF(0x4a, 3<<10, 0),
4912 	{}
4913 };
4914 
alc_headset_mode_unplugged(struct hda_codec * codec)4915 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4916 {
4917 	struct alc_spec *spec = codec->spec;
4918 	static const struct coef_fw coef0255[] = {
4919 		WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4920 		WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4921 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4922 		WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4923 		WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4924 		{}
4925 	};
4926 	static const struct coef_fw coef0256[] = {
4927 		WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4928 		WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4929 		WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4930 		WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4931 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4932 		{}
4933 	};
4934 	static const struct coef_fw coef0233[] = {
4935 		WRITE_COEF(0x1b, 0x0c0b),
4936 		WRITE_COEF(0x45, 0xc429),
4937 		UPDATE_COEF(0x35, 0x4000, 0),
4938 		WRITE_COEF(0x06, 0x2104),
4939 		WRITE_COEF(0x1a, 0x0001),
4940 		WRITE_COEF(0x26, 0x0004),
4941 		WRITE_COEF(0x32, 0x42a3),
4942 		{}
4943 	};
4944 	static const struct coef_fw coef0288[] = {
4945 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4946 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4947 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4948 		UPDATE_COEF(0x66, 0x0008, 0),
4949 		UPDATE_COEF(0x67, 0x2000, 0),
4950 		{}
4951 	};
4952 	static const struct coef_fw coef0298[] = {
4953 		UPDATE_COEF(0x19, 0x1300, 0x0300),
4954 		{}
4955 	};
4956 	static const struct coef_fw coef0292[] = {
4957 		WRITE_COEF(0x76, 0x000e),
4958 		WRITE_COEF(0x6c, 0x2400),
4959 		WRITE_COEF(0x18, 0x7308),
4960 		WRITE_COEF(0x6b, 0xc429),
4961 		{}
4962 	};
4963 	static const struct coef_fw coef0293[] = {
4964 		UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4965 		UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4966 		UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4967 		UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4968 		WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4969 		UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4970 		{}
4971 	};
4972 	static const struct coef_fw coef0668[] = {
4973 		WRITE_COEF(0x15, 0x0d40),
4974 		WRITE_COEF(0xb7, 0x802b),
4975 		{}
4976 	};
4977 	static const struct coef_fw coef0225[] = {
4978 		UPDATE_COEF(0x63, 3<<14, 0),
4979 		{}
4980 	};
4981 	static const struct coef_fw coef0274[] = {
4982 		UPDATE_COEF(0x4a, 0x0100, 0),
4983 		UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4984 		UPDATE_COEF(0x6b, 0xf000, 0x5000),
4985 		UPDATE_COEF(0x4a, 0x0010, 0),
4986 		UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4987 		WRITE_COEF(0x45, 0x5289),
4988 		UPDATE_COEF(0x4a, 0x0c00, 0),
4989 		{}
4990 	};
4991 
4992 	if (spec->no_internal_mic_pin) {
4993 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
4994 		return;
4995 	}
4996 
4997 	switch (codec->core.vendor_id) {
4998 	case 0x10ec0255:
4999 		alc_process_coef_fw(codec, coef0255);
5000 		break;
5001 	case 0x10ec0230:
5002 	case 0x10ec0236:
5003 	case 0x10ec0256:
5004 	case 0x19e58326:
5005 		alc_process_coef_fw(codec, coef0256);
5006 		break;
5007 	case 0x10ec0234:
5008 	case 0x10ec0274:
5009 	case 0x10ec0294:
5010 		alc_process_coef_fw(codec, coef0274);
5011 		break;
5012 	case 0x10ec0233:
5013 	case 0x10ec0283:
5014 		alc_process_coef_fw(codec, coef0233);
5015 		break;
5016 	case 0x10ec0286:
5017 	case 0x10ec0288:
5018 		alc_process_coef_fw(codec, coef0288);
5019 		break;
5020 	case 0x10ec0298:
5021 		alc_process_coef_fw(codec, coef0298);
5022 		alc_process_coef_fw(codec, coef0288);
5023 		break;
5024 	case 0x10ec0292:
5025 		alc_process_coef_fw(codec, coef0292);
5026 		break;
5027 	case 0x10ec0293:
5028 		alc_process_coef_fw(codec, coef0293);
5029 		break;
5030 	case 0x10ec0668:
5031 		alc_process_coef_fw(codec, coef0668);
5032 		break;
5033 	case 0x10ec0215:
5034 	case 0x10ec0225:
5035 	case 0x10ec0285:
5036 	case 0x10ec0295:
5037 	case 0x10ec0289:
5038 	case 0x10ec0299:
5039 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5040 		alc_process_coef_fw(codec, coef0225);
5041 		break;
5042 	case 0x10ec0867:
5043 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5044 		break;
5045 	}
5046 	codec_dbg(codec, "Headset jack set to unplugged mode.\n");
5047 }
5048 
5049 
alc_headset_mode_mic_in(struct hda_codec * codec,hda_nid_t hp_pin,hda_nid_t mic_pin)5050 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5051 				    hda_nid_t mic_pin)
5052 {
5053 	static const struct coef_fw coef0255[] = {
5054 		WRITE_COEFEX(0x57, 0x03, 0x8aa6),
5055 		WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
5056 		{}
5057 	};
5058 	static const struct coef_fw coef0256[] = {
5059 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
5060 		WRITE_COEFEX(0x57, 0x03, 0x09a3),
5061 		WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
5062 		{}
5063 	};
5064 	static const struct coef_fw coef0233[] = {
5065 		UPDATE_COEF(0x35, 0, 1<<14),
5066 		WRITE_COEF(0x06, 0x2100),
5067 		WRITE_COEF(0x1a, 0x0021),
5068 		WRITE_COEF(0x26, 0x008c),
5069 		{}
5070 	};
5071 	static const struct coef_fw coef0288[] = {
5072 		UPDATE_COEF(0x4f, 0x00c0, 0),
5073 		UPDATE_COEF(0x50, 0x2000, 0),
5074 		UPDATE_COEF(0x56, 0x0006, 0),
5075 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
5076 		UPDATE_COEF(0x66, 0x0008, 0x0008),
5077 		UPDATE_COEF(0x67, 0x2000, 0x2000),
5078 		{}
5079 	};
5080 	static const struct coef_fw coef0292[] = {
5081 		WRITE_COEF(0x19, 0xa208),
5082 		WRITE_COEF(0x2e, 0xacf0),
5083 		{}
5084 	};
5085 	static const struct coef_fw coef0293[] = {
5086 		UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
5087 		UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
5088 		UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5089 		{}
5090 	};
5091 	static const struct coef_fw coef0688[] = {
5092 		WRITE_COEF(0xb7, 0x802b),
5093 		WRITE_COEF(0xb5, 0x1040),
5094 		UPDATE_COEF(0xc3, 0, 1<<12),
5095 		{}
5096 	};
5097 	static const struct coef_fw coef0225[] = {
5098 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
5099 		UPDATE_COEF(0x4a, 3<<4, 2<<4),
5100 		UPDATE_COEF(0x63, 3<<14, 0),
5101 		{}
5102 	};
5103 	static const struct coef_fw coef0274[] = {
5104 		UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
5105 		UPDATE_COEF(0x4a, 0x0010, 0),
5106 		UPDATE_COEF(0x6b, 0xf000, 0),
5107 		{}
5108 	};
5109 
5110 	switch (codec->core.vendor_id) {
5111 	case 0x10ec0255:
5112 		alc_write_coef_idx(codec, 0x45, 0xc489);
5113 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5114 		alc_process_coef_fw(codec, coef0255);
5115 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5116 		break;
5117 	case 0x10ec0230:
5118 	case 0x10ec0236:
5119 	case 0x10ec0256:
5120 	case 0x19e58326:
5121 		alc_write_coef_idx(codec, 0x45, 0xc489);
5122 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5123 		alc_process_coef_fw(codec, coef0256);
5124 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5125 		break;
5126 	case 0x10ec0234:
5127 	case 0x10ec0274:
5128 	case 0x10ec0294:
5129 		alc_write_coef_idx(codec, 0x45, 0x4689);
5130 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5131 		alc_process_coef_fw(codec, coef0274);
5132 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5133 		break;
5134 	case 0x10ec0233:
5135 	case 0x10ec0283:
5136 		alc_write_coef_idx(codec, 0x45, 0xc429);
5137 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5138 		alc_process_coef_fw(codec, coef0233);
5139 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5140 		break;
5141 	case 0x10ec0286:
5142 	case 0x10ec0288:
5143 	case 0x10ec0298:
5144 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5145 		alc_process_coef_fw(codec, coef0288);
5146 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5147 		break;
5148 	case 0x10ec0292:
5149 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5150 		alc_process_coef_fw(codec, coef0292);
5151 		break;
5152 	case 0x10ec0293:
5153 		/* Set to TRS mode */
5154 		alc_write_coef_idx(codec, 0x45, 0xc429);
5155 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5156 		alc_process_coef_fw(codec, coef0293);
5157 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5158 		break;
5159 	case 0x10ec0867:
5160 		alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
5161 		fallthrough;
5162 	case 0x10ec0221:
5163 	case 0x10ec0662:
5164 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5165 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5166 		break;
5167 	case 0x10ec0668:
5168 		alc_write_coef_idx(codec, 0x11, 0x0001);
5169 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5170 		alc_process_coef_fw(codec, coef0688);
5171 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5172 		break;
5173 	case 0x10ec0215:
5174 	case 0x10ec0225:
5175 	case 0x10ec0285:
5176 	case 0x10ec0295:
5177 	case 0x10ec0289:
5178 	case 0x10ec0299:
5179 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5180 		alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
5181 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5182 		alc_process_coef_fw(codec, coef0225);
5183 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5184 		break;
5185 	}
5186 	codec_dbg(codec, "Headset jack set to mic-in mode.\n");
5187 }
5188 
alc_headset_mode_default(struct hda_codec * codec)5189 static void alc_headset_mode_default(struct hda_codec *codec)
5190 {
5191 	static const struct coef_fw coef0225[] = {
5192 		UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
5193 		UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
5194 		UPDATE_COEF(0x49, 3<<8, 0<<8),
5195 		UPDATE_COEF(0x4a, 3<<4, 3<<4),
5196 		UPDATE_COEF(0x63, 3<<14, 0),
5197 		UPDATE_COEF(0x67, 0xf000, 0x3000),
5198 		{}
5199 	};
5200 	static const struct coef_fw coef0255[] = {
5201 		WRITE_COEF(0x45, 0xc089),
5202 		WRITE_COEF(0x45, 0xc489),
5203 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5204 		WRITE_COEF(0x49, 0x0049),
5205 		{}
5206 	};
5207 	static const struct coef_fw coef0256[] = {
5208 		WRITE_COEF(0x45, 0xc489),
5209 		WRITE_COEFEX(0x57, 0x03, 0x0da3),
5210 		WRITE_COEF(0x49, 0x0049),
5211 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
5212 		WRITE_COEF(0x06, 0x6100),
5213 		{}
5214 	};
5215 	static const struct coef_fw coef0233[] = {
5216 		WRITE_COEF(0x06, 0x2100),
5217 		WRITE_COEF(0x32, 0x4ea3),
5218 		{}
5219 	};
5220 	static const struct coef_fw coef0288[] = {
5221 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
5222 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5223 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5224 		UPDATE_COEF(0x66, 0x0008, 0),
5225 		UPDATE_COEF(0x67, 0x2000, 0),
5226 		{}
5227 	};
5228 	static const struct coef_fw coef0292[] = {
5229 		WRITE_COEF(0x76, 0x000e),
5230 		WRITE_COEF(0x6c, 0x2400),
5231 		WRITE_COEF(0x6b, 0xc429),
5232 		WRITE_COEF(0x18, 0x7308),
5233 		{}
5234 	};
5235 	static const struct coef_fw coef0293[] = {
5236 		UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
5237 		WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
5238 		UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5239 		{}
5240 	};
5241 	static const struct coef_fw coef0688[] = {
5242 		WRITE_COEF(0x11, 0x0041),
5243 		WRITE_COEF(0x15, 0x0d40),
5244 		WRITE_COEF(0xb7, 0x802b),
5245 		{}
5246 	};
5247 	static const struct coef_fw coef0274[] = {
5248 		WRITE_COEF(0x45, 0x4289),
5249 		UPDATE_COEF(0x4a, 0x0010, 0x0010),
5250 		UPDATE_COEF(0x6b, 0x0f00, 0),
5251 		UPDATE_COEF(0x49, 0x0300, 0x0300),
5252 		{}
5253 	};
5254 
5255 	switch (codec->core.vendor_id) {
5256 	case 0x10ec0215:
5257 	case 0x10ec0225:
5258 	case 0x10ec0285:
5259 	case 0x10ec0295:
5260 	case 0x10ec0289:
5261 	case 0x10ec0299:
5262 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5263 		alc_process_coef_fw(codec, coef0225);
5264 		break;
5265 	case 0x10ec0255:
5266 		alc_process_coef_fw(codec, coef0255);
5267 		break;
5268 	case 0x10ec0230:
5269 	case 0x10ec0236:
5270 	case 0x10ec0256:
5271 	case 0x19e58326:
5272 		alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5273 		alc_write_coef_idx(codec, 0x45, 0xc089);
5274 		msleep(50);
5275 		alc_process_coef_fw(codec, coef0256);
5276 		break;
5277 	case 0x10ec0234:
5278 	case 0x10ec0274:
5279 	case 0x10ec0294:
5280 		alc_process_coef_fw(codec, coef0274);
5281 		break;
5282 	case 0x10ec0233:
5283 	case 0x10ec0283:
5284 		alc_process_coef_fw(codec, coef0233);
5285 		break;
5286 	case 0x10ec0286:
5287 	case 0x10ec0288:
5288 	case 0x10ec0298:
5289 		alc_process_coef_fw(codec, coef0288);
5290 		break;
5291 	case 0x10ec0292:
5292 		alc_process_coef_fw(codec, coef0292);
5293 		break;
5294 	case 0x10ec0293:
5295 		alc_process_coef_fw(codec, coef0293);
5296 		break;
5297 	case 0x10ec0668:
5298 		alc_process_coef_fw(codec, coef0688);
5299 		break;
5300 	case 0x10ec0867:
5301 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5302 		break;
5303 	}
5304 	codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5305 }
5306 
5307 /* Iphone type */
alc_headset_mode_ctia(struct hda_codec * codec)5308 static void alc_headset_mode_ctia(struct hda_codec *codec)
5309 {
5310 	int val;
5311 
5312 	static const struct coef_fw coef0255[] = {
5313 		WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5314 		WRITE_COEF(0x1b, 0x0c2b),
5315 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5316 		{}
5317 	};
5318 	static const struct coef_fw coef0256[] = {
5319 		WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5320 		WRITE_COEF(0x1b, 0x0e6b),
5321 		{}
5322 	};
5323 	static const struct coef_fw coef0233[] = {
5324 		WRITE_COEF(0x45, 0xd429),
5325 		WRITE_COEF(0x1b, 0x0c2b),
5326 		WRITE_COEF(0x32, 0x4ea3),
5327 		{}
5328 	};
5329 	static const struct coef_fw coef0288[] = {
5330 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5331 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5332 		UPDATE_COEF(0x66, 0x0008, 0),
5333 		UPDATE_COEF(0x67, 0x2000, 0),
5334 		{}
5335 	};
5336 	static const struct coef_fw coef0292[] = {
5337 		WRITE_COEF(0x6b, 0xd429),
5338 		WRITE_COEF(0x76, 0x0008),
5339 		WRITE_COEF(0x18, 0x7388),
5340 		{}
5341 	};
5342 	static const struct coef_fw coef0293[] = {
5343 		WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
5344 		UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5345 		{}
5346 	};
5347 	static const struct coef_fw coef0688[] = {
5348 		WRITE_COEF(0x11, 0x0001),
5349 		WRITE_COEF(0x15, 0x0d60),
5350 		WRITE_COEF(0xc3, 0x0000),
5351 		{}
5352 	};
5353 	static const struct coef_fw coef0225_1[] = {
5354 		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5355 		UPDATE_COEF(0x63, 3<<14, 2<<14),
5356 		{}
5357 	};
5358 	static const struct coef_fw coef0225_2[] = {
5359 		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5360 		UPDATE_COEF(0x63, 3<<14, 1<<14),
5361 		{}
5362 	};
5363 
5364 	switch (codec->core.vendor_id) {
5365 	case 0x10ec0255:
5366 		alc_process_coef_fw(codec, coef0255);
5367 		break;
5368 	case 0x10ec0230:
5369 	case 0x10ec0236:
5370 	case 0x10ec0256:
5371 	case 0x19e58326:
5372 		alc_process_coef_fw(codec, coef0256);
5373 		break;
5374 	case 0x10ec0234:
5375 	case 0x10ec0274:
5376 	case 0x10ec0294:
5377 		alc_write_coef_idx(codec, 0x45, 0xd689);
5378 		break;
5379 	case 0x10ec0233:
5380 	case 0x10ec0283:
5381 		alc_process_coef_fw(codec, coef0233);
5382 		break;
5383 	case 0x10ec0298:
5384 		val = alc_read_coef_idx(codec, 0x50);
5385 		if (val & (1 << 12)) {
5386 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5387 			alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5388 			msleep(300);
5389 		} else {
5390 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5391 			alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5392 			msleep(300);
5393 		}
5394 		break;
5395 	case 0x10ec0286:
5396 	case 0x10ec0288:
5397 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5398 		msleep(300);
5399 		alc_process_coef_fw(codec, coef0288);
5400 		break;
5401 	case 0x10ec0292:
5402 		alc_process_coef_fw(codec, coef0292);
5403 		break;
5404 	case 0x10ec0293:
5405 		alc_process_coef_fw(codec, coef0293);
5406 		break;
5407 	case 0x10ec0668:
5408 		alc_process_coef_fw(codec, coef0688);
5409 		break;
5410 	case 0x10ec0215:
5411 	case 0x10ec0225:
5412 	case 0x10ec0285:
5413 	case 0x10ec0295:
5414 	case 0x10ec0289:
5415 	case 0x10ec0299:
5416 		val = alc_read_coef_idx(codec, 0x45);
5417 		if (val & (1 << 9))
5418 			alc_process_coef_fw(codec, coef0225_2);
5419 		else
5420 			alc_process_coef_fw(codec, coef0225_1);
5421 		break;
5422 	case 0x10ec0867:
5423 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5424 		break;
5425 	}
5426 	codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5427 }
5428 
5429 /* Nokia type */
alc_headset_mode_omtp(struct hda_codec * codec)5430 static void alc_headset_mode_omtp(struct hda_codec *codec)
5431 {
5432 	static const struct coef_fw coef0255[] = {
5433 		WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5434 		WRITE_COEF(0x1b, 0x0c2b),
5435 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5436 		{}
5437 	};
5438 	static const struct coef_fw coef0256[] = {
5439 		WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5440 		WRITE_COEF(0x1b, 0x0e6b),
5441 		{}
5442 	};
5443 	static const struct coef_fw coef0233[] = {
5444 		WRITE_COEF(0x45, 0xe429),
5445 		WRITE_COEF(0x1b, 0x0c2b),
5446 		WRITE_COEF(0x32, 0x4ea3),
5447 		{}
5448 	};
5449 	static const struct coef_fw coef0288[] = {
5450 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5451 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5452 		UPDATE_COEF(0x66, 0x0008, 0),
5453 		UPDATE_COEF(0x67, 0x2000, 0),
5454 		{}
5455 	};
5456 	static const struct coef_fw coef0292[] = {
5457 		WRITE_COEF(0x6b, 0xe429),
5458 		WRITE_COEF(0x76, 0x0008),
5459 		WRITE_COEF(0x18, 0x7388),
5460 		{}
5461 	};
5462 	static const struct coef_fw coef0293[] = {
5463 		WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
5464 		UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5465 		{}
5466 	};
5467 	static const struct coef_fw coef0688[] = {
5468 		WRITE_COEF(0x11, 0x0001),
5469 		WRITE_COEF(0x15, 0x0d50),
5470 		WRITE_COEF(0xc3, 0x0000),
5471 		{}
5472 	};
5473 	static const struct coef_fw coef0225[] = {
5474 		UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5475 		UPDATE_COEF(0x63, 3<<14, 2<<14),
5476 		{}
5477 	};
5478 
5479 	switch (codec->core.vendor_id) {
5480 	case 0x10ec0255:
5481 		alc_process_coef_fw(codec, coef0255);
5482 		break;
5483 	case 0x10ec0230:
5484 	case 0x10ec0236:
5485 	case 0x10ec0256:
5486 	case 0x19e58326:
5487 		alc_process_coef_fw(codec, coef0256);
5488 		break;
5489 	case 0x10ec0234:
5490 	case 0x10ec0274:
5491 	case 0x10ec0294:
5492 		alc_write_coef_idx(codec, 0x45, 0xe689);
5493 		break;
5494 	case 0x10ec0233:
5495 	case 0x10ec0283:
5496 		alc_process_coef_fw(codec, coef0233);
5497 		break;
5498 	case 0x10ec0298:
5499 		alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5500 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5501 		msleep(300);
5502 		break;
5503 	case 0x10ec0286:
5504 	case 0x10ec0288:
5505 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5506 		msleep(300);
5507 		alc_process_coef_fw(codec, coef0288);
5508 		break;
5509 	case 0x10ec0292:
5510 		alc_process_coef_fw(codec, coef0292);
5511 		break;
5512 	case 0x10ec0293:
5513 		alc_process_coef_fw(codec, coef0293);
5514 		break;
5515 	case 0x10ec0668:
5516 		alc_process_coef_fw(codec, coef0688);
5517 		break;
5518 	case 0x10ec0215:
5519 	case 0x10ec0225:
5520 	case 0x10ec0285:
5521 	case 0x10ec0295:
5522 	case 0x10ec0289:
5523 	case 0x10ec0299:
5524 		alc_process_coef_fw(codec, coef0225);
5525 		break;
5526 	}
5527 	codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5528 }
5529 
alc_determine_headset_type(struct hda_codec * codec)5530 static void alc_determine_headset_type(struct hda_codec *codec)
5531 {
5532 	int val;
5533 	bool is_ctia = false;
5534 	struct alc_spec *spec = codec->spec;
5535 	static const struct coef_fw coef0255[] = {
5536 		WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
5537 		WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
5538  conteol) */
5539 		{}
5540 	};
5541 	static const struct coef_fw coef0288[] = {
5542 		UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
5543 		{}
5544 	};
5545 	static const struct coef_fw coef0298[] = {
5546 		UPDATE_COEF(0x50, 0x2000, 0x2000),
5547 		UPDATE_COEF(0x56, 0x0006, 0x0006),
5548 		UPDATE_COEF(0x66, 0x0008, 0),
5549 		UPDATE_COEF(0x67, 0x2000, 0),
5550 		UPDATE_COEF(0x19, 0x1300, 0x1300),
5551 		{}
5552 	};
5553 	static const struct coef_fw coef0293[] = {
5554 		UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
5555 		WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
5556 		{}
5557 	};
5558 	static const struct coef_fw coef0688[] = {
5559 		WRITE_COEF(0x11, 0x0001),
5560 		WRITE_COEF(0xb7, 0x802b),
5561 		WRITE_COEF(0x15, 0x0d60),
5562 		WRITE_COEF(0xc3, 0x0c00),
5563 		{}
5564 	};
5565 	static const struct coef_fw coef0274[] = {
5566 		UPDATE_COEF(0x4a, 0x0010, 0),
5567 		UPDATE_COEF(0x4a, 0x8000, 0),
5568 		WRITE_COEF(0x45, 0xd289),
5569 		UPDATE_COEF(0x49, 0x0300, 0x0300),
5570 		{}
5571 	};
5572 
5573 	if (spec->no_internal_mic_pin) {
5574 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5575 		return;
5576 	}
5577 
5578 	switch (codec->core.vendor_id) {
5579 	case 0x10ec0255:
5580 		alc_process_coef_fw(codec, coef0255);
5581 		msleep(300);
5582 		val = alc_read_coef_idx(codec, 0x46);
5583 		is_ctia = (val & 0x0070) == 0x0070;
5584 		break;
5585 	case 0x10ec0230:
5586 	case 0x10ec0236:
5587 	case 0x10ec0256:
5588 	case 0x19e58326:
5589 		alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5590 		alc_write_coef_idx(codec, 0x06, 0x6104);
5591 		alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5592 
5593 		snd_hda_codec_write(codec, 0x21, 0,
5594 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5595 		msleep(80);
5596 		snd_hda_codec_write(codec, 0x21, 0,
5597 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5598 
5599 		alc_process_coef_fw(codec, coef0255);
5600 		msleep(300);
5601 		val = alc_read_coef_idx(codec, 0x46);
5602 		is_ctia = (val & 0x0070) == 0x0070;
5603 
5604 		alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5605 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5606 
5607 		snd_hda_codec_write(codec, 0x21, 0,
5608 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5609 		msleep(80);
5610 		snd_hda_codec_write(codec, 0x21, 0,
5611 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5612 		break;
5613 	case 0x10ec0234:
5614 	case 0x10ec0274:
5615 	case 0x10ec0294:
5616 		alc_process_coef_fw(codec, coef0274);
5617 		msleep(850);
5618 		val = alc_read_coef_idx(codec, 0x46);
5619 		is_ctia = (val & 0x00f0) == 0x00f0;
5620 		break;
5621 	case 0x10ec0233:
5622 	case 0x10ec0283:
5623 		alc_write_coef_idx(codec, 0x45, 0xd029);
5624 		msleep(300);
5625 		val = alc_read_coef_idx(codec, 0x46);
5626 		is_ctia = (val & 0x0070) == 0x0070;
5627 		break;
5628 	case 0x10ec0298:
5629 		snd_hda_codec_write(codec, 0x21, 0,
5630 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5631 		msleep(100);
5632 		snd_hda_codec_write(codec, 0x21, 0,
5633 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5634 		msleep(200);
5635 
5636 		val = alc_read_coef_idx(codec, 0x50);
5637 		if (val & (1 << 12)) {
5638 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5639 			alc_process_coef_fw(codec, coef0288);
5640 			msleep(350);
5641 			val = alc_read_coef_idx(codec, 0x50);
5642 			is_ctia = (val & 0x0070) == 0x0070;
5643 		} else {
5644 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5645 			alc_process_coef_fw(codec, coef0288);
5646 			msleep(350);
5647 			val = alc_read_coef_idx(codec, 0x50);
5648 			is_ctia = (val & 0x0070) == 0x0070;
5649 		}
5650 		alc_process_coef_fw(codec, coef0298);
5651 		snd_hda_codec_write(codec, 0x21, 0,
5652 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
5653 		msleep(75);
5654 		snd_hda_codec_write(codec, 0x21, 0,
5655 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5656 		break;
5657 	case 0x10ec0286:
5658 	case 0x10ec0288:
5659 		alc_process_coef_fw(codec, coef0288);
5660 		msleep(350);
5661 		val = alc_read_coef_idx(codec, 0x50);
5662 		is_ctia = (val & 0x0070) == 0x0070;
5663 		break;
5664 	case 0x10ec0292:
5665 		alc_write_coef_idx(codec, 0x6b, 0xd429);
5666 		msleep(300);
5667 		val = alc_read_coef_idx(codec, 0x6c);
5668 		is_ctia = (val & 0x001c) == 0x001c;
5669 		break;
5670 	case 0x10ec0293:
5671 		alc_process_coef_fw(codec, coef0293);
5672 		msleep(300);
5673 		val = alc_read_coef_idx(codec, 0x46);
5674 		is_ctia = (val & 0x0070) == 0x0070;
5675 		break;
5676 	case 0x10ec0668:
5677 		alc_process_coef_fw(codec, coef0688);
5678 		msleep(300);
5679 		val = alc_read_coef_idx(codec, 0xbe);
5680 		is_ctia = (val & 0x1c02) == 0x1c02;
5681 		break;
5682 	case 0x10ec0215:
5683 	case 0x10ec0225:
5684 	case 0x10ec0285:
5685 	case 0x10ec0295:
5686 	case 0x10ec0289:
5687 	case 0x10ec0299:
5688 		snd_hda_codec_write(codec, 0x21, 0,
5689 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5690 		msleep(80);
5691 		snd_hda_codec_write(codec, 0x21, 0,
5692 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5693 
5694 		alc_process_coef_fw(codec, alc225_pre_hsmode);
5695 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5696 		val = alc_read_coef_idx(codec, 0x45);
5697 		if (val & (1 << 9)) {
5698 			alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5699 			alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5700 			msleep(800);
5701 			val = alc_read_coef_idx(codec, 0x46);
5702 			is_ctia = (val & 0x00f0) == 0x00f0;
5703 		} else {
5704 			alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5705 			alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5706 			msleep(800);
5707 			val = alc_read_coef_idx(codec, 0x46);
5708 			is_ctia = (val & 0x00f0) == 0x00f0;
5709 		}
5710 		alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5711 		alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5712 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5713 
5714 		snd_hda_codec_write(codec, 0x21, 0,
5715 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5716 		msleep(80);
5717 		snd_hda_codec_write(codec, 0x21, 0,
5718 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5719 		break;
5720 	case 0x10ec0867:
5721 		is_ctia = true;
5722 		break;
5723 	}
5724 
5725 	codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5726 		    is_ctia ? "yes" : "no");
5727 	spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5728 }
5729 
alc_update_headset_mode(struct hda_codec * codec)5730 static void alc_update_headset_mode(struct hda_codec *codec)
5731 {
5732 	struct alc_spec *spec = codec->spec;
5733 
5734 	hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5735 	hda_nid_t hp_pin = alc_get_hp_pin(spec);
5736 
5737 	int new_headset_mode;
5738 
5739 	if (!snd_hda_jack_detect(codec, hp_pin))
5740 		new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
5741 	else if (mux_pin == spec->headset_mic_pin)
5742 		new_headset_mode = ALC_HEADSET_MODE_HEADSET;
5743 	else if (mux_pin == spec->headphone_mic_pin)
5744 		new_headset_mode = ALC_HEADSET_MODE_MIC;
5745 	else
5746 		new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
5747 
5748 	if (new_headset_mode == spec->current_headset_mode) {
5749 		snd_hda_gen_update_outputs(codec);
5750 		return;
5751 	}
5752 
5753 	switch (new_headset_mode) {
5754 	case ALC_HEADSET_MODE_UNPLUGGED:
5755 		alc_headset_mode_unplugged(codec);
5756 		spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5757 		spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5758 		spec->gen.hp_jack_present = false;
5759 		break;
5760 	case ALC_HEADSET_MODE_HEADSET:
5761 		if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5762 			alc_determine_headset_type(codec);
5763 		if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5764 			alc_headset_mode_ctia(codec);
5765 		else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5766 			alc_headset_mode_omtp(codec);
5767 		spec->gen.hp_jack_present = true;
5768 		break;
5769 	case ALC_HEADSET_MODE_MIC:
5770 		alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5771 		spec->gen.hp_jack_present = false;
5772 		break;
5773 	case ALC_HEADSET_MODE_HEADPHONE:
5774 		alc_headset_mode_default(codec);
5775 		spec->gen.hp_jack_present = true;
5776 		break;
5777 	}
5778 	if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5779 		snd_hda_set_pin_ctl_cache(codec, hp_pin,
5780 					  AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5781 		if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5782 			snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5783 						  PIN_VREFHIZ);
5784 	}
5785 	spec->current_headset_mode = new_headset_mode;
5786 
5787 	snd_hda_gen_update_outputs(codec);
5788 }
5789 
alc_update_headset_mode_hook(struct hda_codec * codec,struct snd_kcontrol * kcontrol,struct snd_ctl_elem_value * ucontrol)5790 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5791 					 struct snd_kcontrol *kcontrol,
5792 					 struct snd_ctl_elem_value *ucontrol)
5793 {
5794 	alc_update_headset_mode(codec);
5795 }
5796 
alc_update_headset_jack_cb(struct hda_codec * codec,struct hda_jack_callback * jack)5797 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5798 				       struct hda_jack_callback *jack)
5799 {
5800 	snd_hda_gen_hp_automute(codec, jack);
5801 	alc_update_headset_mode(codec);
5802 }
5803 
alc_probe_headset_mode(struct hda_codec * codec)5804 static void alc_probe_headset_mode(struct hda_codec *codec)
5805 {
5806 	int i;
5807 	struct alc_spec *spec = codec->spec;
5808 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5809 
5810 	/* Find mic pins */
5811 	for (i = 0; i < cfg->num_inputs; i++) {
5812 		if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5813 			spec->headset_mic_pin = cfg->inputs[i].pin;
5814 		if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5815 			spec->headphone_mic_pin = cfg->inputs[i].pin;
5816 	}
5817 
5818 	WARN_ON(spec->gen.cap_sync_hook);
5819 	spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5820 	spec->gen.automute_hook = alc_update_headset_mode;
5821 	spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5822 }
5823 
alc_fixup_headset_mode(struct hda_codec * codec,const struct hda_fixup * fix,int action)5824 static void alc_fixup_headset_mode(struct hda_codec *codec,
5825 				const struct hda_fixup *fix, int action)
5826 {
5827 	struct alc_spec *spec = codec->spec;
5828 
5829 	switch (action) {
5830 	case HDA_FIXUP_ACT_PRE_PROBE:
5831 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5832 		break;
5833 	case HDA_FIXUP_ACT_PROBE:
5834 		alc_probe_headset_mode(codec);
5835 		break;
5836 	case HDA_FIXUP_ACT_INIT:
5837 		if (is_s3_resume(codec) || is_s4_resume(codec)) {
5838 			spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5839 			spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5840 		}
5841 		alc_update_headset_mode(codec);
5842 		break;
5843 	}
5844 }
5845 
alc_fixup_headset_mode_no_hp_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)5846 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5847 				const struct hda_fixup *fix, int action)
5848 {
5849 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5850 		struct alc_spec *spec = codec->spec;
5851 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5852 	}
5853 	else
5854 		alc_fixup_headset_mode(codec, fix, action);
5855 }
5856 
alc255_set_default_jack_type(struct hda_codec * codec)5857 static void alc255_set_default_jack_type(struct hda_codec *codec)
5858 {
5859 	/* Set to iphone type */
5860 	static const struct coef_fw alc255fw[] = {
5861 		WRITE_COEF(0x1b, 0x880b),
5862 		WRITE_COEF(0x45, 0xd089),
5863 		WRITE_COEF(0x1b, 0x080b),
5864 		WRITE_COEF(0x46, 0x0004),
5865 		WRITE_COEF(0x1b, 0x0c0b),
5866 		{}
5867 	};
5868 	static const struct coef_fw alc256fw[] = {
5869 		WRITE_COEF(0x1b, 0x884b),
5870 		WRITE_COEF(0x45, 0xd089),
5871 		WRITE_COEF(0x1b, 0x084b),
5872 		WRITE_COEF(0x46, 0x0004),
5873 		WRITE_COEF(0x1b, 0x0c4b),
5874 		{}
5875 	};
5876 	switch (codec->core.vendor_id) {
5877 	case 0x10ec0255:
5878 		alc_process_coef_fw(codec, alc255fw);
5879 		break;
5880 	case 0x10ec0230:
5881 	case 0x10ec0236:
5882 	case 0x10ec0256:
5883 	case 0x19e58326:
5884 		alc_process_coef_fw(codec, alc256fw);
5885 		break;
5886 	}
5887 	msleep(30);
5888 }
5889 
alc_fixup_headset_mode_alc255(struct hda_codec * codec,const struct hda_fixup * fix,int action)5890 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5891 				const struct hda_fixup *fix, int action)
5892 {
5893 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5894 		alc255_set_default_jack_type(codec);
5895 	}
5896 	alc_fixup_headset_mode(codec, fix, action);
5897 }
5898 
alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)5899 static void alc_fixup_headset_mode_alc255_no_hp_mic(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->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5905 		alc255_set_default_jack_type(codec);
5906 	}
5907 	else
5908 		alc_fixup_headset_mode(codec, fix, action);
5909 }
5910 
alc288_update_headset_jack_cb(struct hda_codec * codec,struct hda_jack_callback * jack)5911 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5912 				       struct hda_jack_callback *jack)
5913 {
5914 	struct alc_spec *spec = codec->spec;
5915 
5916 	alc_update_headset_jack_cb(codec, jack);
5917 	/* Headset Mic enable or disable, only for Dell Dino */
5918 	alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5919 }
5920 
alc_fixup_headset_mode_dell_alc288(struct hda_codec * codec,const struct hda_fixup * fix,int action)5921 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5922 				const struct hda_fixup *fix, int action)
5923 {
5924 	alc_fixup_headset_mode(codec, fix, action);
5925 	if (action == HDA_FIXUP_ACT_PROBE) {
5926 		struct alc_spec *spec = codec->spec;
5927 		/* toggled via hp_automute_hook */
5928 		spec->gpio_mask |= 0x40;
5929 		spec->gpio_dir |= 0x40;
5930 		spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5931 	}
5932 }
5933 
alc_fixup_auto_mute_via_amp(struct hda_codec * codec,const struct hda_fixup * fix,int action)5934 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5935 					const struct hda_fixup *fix, int action)
5936 {
5937 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5938 		struct alc_spec *spec = codec->spec;
5939 		spec->gen.auto_mute_via_amp = 1;
5940 	}
5941 }
5942 
alc_fixup_no_shutup(struct hda_codec * codec,const struct hda_fixup * fix,int action)5943 static void alc_fixup_no_shutup(struct hda_codec *codec,
5944 				const struct hda_fixup *fix, int action)
5945 {
5946 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5947 		struct alc_spec *spec = codec->spec;
5948 		spec->no_shutup_pins = 1;
5949 	}
5950 }
5951 
alc_fixup_disable_aamix(struct hda_codec * codec,const struct hda_fixup * fix,int action)5952 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5953 				    const struct hda_fixup *fix, int action)
5954 {
5955 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5956 		struct alc_spec *spec = codec->spec;
5957 		/* Disable AA-loopback as it causes white noise */
5958 		spec->gen.mixer_nid = 0;
5959 	}
5960 }
5961 
5962 /* 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)5963 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5964 				  const struct hda_fixup *fix, int action)
5965 {
5966 	static const struct hda_pintbl pincfgs[] = {
5967 		{ 0x16, 0x21211010 }, /* dock headphone */
5968 		{ 0x19, 0x21a11010 }, /* dock mic */
5969 		{ }
5970 	};
5971 	struct alc_spec *spec = codec->spec;
5972 
5973 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5974 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5975 		codec->power_save_node = 0; /* avoid click noises */
5976 		snd_hda_apply_pincfgs(codec, pincfgs);
5977 	}
5978 }
5979 
alc_fixup_tpt470_dock(struct hda_codec * codec,const struct hda_fixup * fix,int action)5980 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5981 				  const struct hda_fixup *fix, int action)
5982 {
5983 	static const struct hda_pintbl pincfgs[] = {
5984 		{ 0x17, 0x21211010 }, /* dock headphone */
5985 		{ 0x19, 0x21a11010 }, /* dock mic */
5986 		{ }
5987 	};
5988 	struct alc_spec *spec = codec->spec;
5989 
5990 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5991 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5992 		snd_hda_apply_pincfgs(codec, pincfgs);
5993 	} else if (action == HDA_FIXUP_ACT_INIT) {
5994 		/* Enable DOCK device */
5995 		snd_hda_codec_write(codec, 0x17, 0,
5996 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5997 		/* Enable DOCK device */
5998 		snd_hda_codec_write(codec, 0x19, 0,
5999 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
6000 	}
6001 }
6002 
alc_fixup_tpt470_dacs(struct hda_codec * codec,const struct hda_fixup * fix,int action)6003 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
6004 				  const struct hda_fixup *fix, int action)
6005 {
6006 	/* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
6007 	 * the speaker output becomes too low by some reason on Thinkpads with
6008 	 * ALC298 codec
6009 	 */
6010 	static const hda_nid_t preferred_pairs[] = {
6011 		0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
6012 		0
6013 	};
6014 	struct alc_spec *spec = codec->spec;
6015 
6016 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
6017 		spec->gen.preferred_dacs = preferred_pairs;
6018 }
6019 
alc295_fixup_asus_dacs(struct hda_codec * codec,const struct hda_fixup * fix,int action)6020 static void alc295_fixup_asus_dacs(struct hda_codec *codec,
6021 				   const struct hda_fixup *fix, int action)
6022 {
6023 	static const hda_nid_t preferred_pairs[] = {
6024 		0x17, 0x02, 0x21, 0x03, 0
6025 	};
6026 	struct alc_spec *spec = codec->spec;
6027 
6028 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
6029 		spec->gen.preferred_dacs = preferred_pairs;
6030 }
6031 
alc_shutup_dell_xps13(struct hda_codec * codec)6032 static void alc_shutup_dell_xps13(struct hda_codec *codec)
6033 {
6034 	struct alc_spec *spec = codec->spec;
6035 	int hp_pin = alc_get_hp_pin(spec);
6036 
6037 	/* Prevent pop noises when headphones are plugged in */
6038 	snd_hda_codec_write(codec, hp_pin, 0,
6039 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
6040 	msleep(20);
6041 }
6042 
alc_fixup_dell_xps13(struct hda_codec * codec,const struct hda_fixup * fix,int action)6043 static void alc_fixup_dell_xps13(struct hda_codec *codec,
6044 				const struct hda_fixup *fix, int action)
6045 {
6046 	struct alc_spec *spec = codec->spec;
6047 	struct hda_input_mux *imux = &spec->gen.input_mux;
6048 	int i;
6049 
6050 	switch (action) {
6051 	case HDA_FIXUP_ACT_PRE_PROBE:
6052 		/* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
6053 		 * it causes a click noise at start up
6054 		 */
6055 		snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6056 		spec->shutup = alc_shutup_dell_xps13;
6057 		break;
6058 	case HDA_FIXUP_ACT_PROBE:
6059 		/* Make the internal mic the default input source. */
6060 		for (i = 0; i < imux->num_items; i++) {
6061 			if (spec->gen.imux_pins[i] == 0x12) {
6062 				spec->gen.cur_mux[0] = i;
6063 				break;
6064 			}
6065 		}
6066 		break;
6067 	}
6068 }
6069 
alc_fixup_headset_mode_alc662(struct hda_codec * codec,const struct hda_fixup * fix,int action)6070 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
6071 				const struct hda_fixup *fix, int action)
6072 {
6073 	struct alc_spec *spec = codec->spec;
6074 
6075 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6076 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
6077 		spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
6078 
6079 		/* Disable boost for mic-in permanently. (This code is only called
6080 		   from quirks that guarantee that the headphone is at NID 0x1b.) */
6081 		snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
6082 		snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
6083 	} else
6084 		alc_fixup_headset_mode(codec, fix, action);
6085 }
6086 
alc_fixup_headset_mode_alc668(struct hda_codec * codec,const struct hda_fixup * fix,int action)6087 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
6088 				const struct hda_fixup *fix, int action)
6089 {
6090 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6091 		alc_write_coef_idx(codec, 0xc4, 0x8000);
6092 		alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
6093 		snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
6094 	}
6095 	alc_fixup_headset_mode(codec, fix, action);
6096 }
6097 
6098 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
find_ext_mic_pin(struct hda_codec * codec)6099 static int find_ext_mic_pin(struct hda_codec *codec)
6100 {
6101 	struct alc_spec *spec = codec->spec;
6102 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6103 	hda_nid_t nid;
6104 	unsigned int defcfg;
6105 	int i;
6106 
6107 	for (i = 0; i < cfg->num_inputs; i++) {
6108 		if (cfg->inputs[i].type != AUTO_PIN_MIC)
6109 			continue;
6110 		nid = cfg->inputs[i].pin;
6111 		defcfg = snd_hda_codec_get_pincfg(codec, nid);
6112 		if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
6113 			continue;
6114 		return nid;
6115 	}
6116 
6117 	return 0;
6118 }
6119 
alc271_hp_gate_mic_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)6120 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
6121 				    const struct hda_fixup *fix,
6122 				    int action)
6123 {
6124 	struct alc_spec *spec = codec->spec;
6125 
6126 	if (action == HDA_FIXUP_ACT_PROBE) {
6127 		int mic_pin = find_ext_mic_pin(codec);
6128 		int hp_pin = alc_get_hp_pin(spec);
6129 
6130 		if (snd_BUG_ON(!mic_pin || !hp_pin))
6131 			return;
6132 		snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
6133 	}
6134 }
6135 
alc269_fixup_limit_int_mic_boost(struct hda_codec * codec,const struct hda_fixup * fix,int action)6136 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
6137 					     const struct hda_fixup *fix,
6138 					     int action)
6139 {
6140 	struct alc_spec *spec = codec->spec;
6141 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6142 	int i;
6143 
6144 	/* The mic boosts on level 2 and 3 are too noisy
6145 	   on the internal mic input.
6146 	   Therefore limit the boost to 0 or 1. */
6147 
6148 	if (action != HDA_FIXUP_ACT_PROBE)
6149 		return;
6150 
6151 	for (i = 0; i < cfg->num_inputs; i++) {
6152 		hda_nid_t nid = cfg->inputs[i].pin;
6153 		unsigned int defcfg;
6154 		if (cfg->inputs[i].type != AUTO_PIN_MIC)
6155 			continue;
6156 		defcfg = snd_hda_codec_get_pincfg(codec, nid);
6157 		if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
6158 			continue;
6159 
6160 		snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
6161 					  (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
6162 					  (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6163 					  (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
6164 					  (0 << AC_AMPCAP_MUTE_SHIFT));
6165 	}
6166 }
6167 
alc283_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)6168 static void alc283_hp_automute_hook(struct hda_codec *codec,
6169 				    struct hda_jack_callback *jack)
6170 {
6171 	struct alc_spec *spec = codec->spec;
6172 	int vref;
6173 
6174 	msleep(200);
6175 	snd_hda_gen_hp_automute(codec, jack);
6176 
6177 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
6178 
6179 	msleep(600);
6180 	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6181 			    vref);
6182 }
6183 
alc283_fixup_chromebook(struct hda_codec * codec,const struct hda_fixup * fix,int action)6184 static void alc283_fixup_chromebook(struct hda_codec *codec,
6185 				    const struct hda_fixup *fix, int action)
6186 {
6187 	struct alc_spec *spec = codec->spec;
6188 
6189 	switch (action) {
6190 	case HDA_FIXUP_ACT_PRE_PROBE:
6191 		snd_hda_override_wcaps(codec, 0x03, 0);
6192 		/* Disable AA-loopback as it causes white noise */
6193 		spec->gen.mixer_nid = 0;
6194 		break;
6195 	case HDA_FIXUP_ACT_INIT:
6196 		/* MIC2-VREF control */
6197 		/* Set to manual mode */
6198 		alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6199 		/* Enable Line1 input control by verb */
6200 		alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
6201 		break;
6202 	}
6203 }
6204 
alc283_fixup_sense_combo_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)6205 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
6206 				    const struct hda_fixup *fix, int action)
6207 {
6208 	struct alc_spec *spec = codec->spec;
6209 
6210 	switch (action) {
6211 	case HDA_FIXUP_ACT_PRE_PROBE:
6212 		spec->gen.hp_automute_hook = alc283_hp_automute_hook;
6213 		break;
6214 	case HDA_FIXUP_ACT_INIT:
6215 		/* MIC2-VREF control */
6216 		/* Set to manual mode */
6217 		alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6218 		break;
6219 	}
6220 }
6221 
6222 /* mute tablet speaker pin (0x14) via dock plugging in addition */
asus_tx300_automute(struct hda_codec * codec)6223 static void asus_tx300_automute(struct hda_codec *codec)
6224 {
6225 	struct alc_spec *spec = codec->spec;
6226 	snd_hda_gen_update_outputs(codec);
6227 	if (snd_hda_jack_detect(codec, 0x1b))
6228 		spec->gen.mute_bits |= (1ULL << 0x14);
6229 }
6230 
alc282_fixup_asus_tx300(struct hda_codec * codec,const struct hda_fixup * fix,int action)6231 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
6232 				    const struct hda_fixup *fix, int action)
6233 {
6234 	struct alc_spec *spec = codec->spec;
6235 	static const struct hda_pintbl dock_pins[] = {
6236 		{ 0x1b, 0x21114000 }, /* dock speaker pin */
6237 		{}
6238 	};
6239 
6240 	switch (action) {
6241 	case HDA_FIXUP_ACT_PRE_PROBE:
6242 		spec->init_amp = ALC_INIT_DEFAULT;
6243 		/* TX300 needs to set up GPIO2 for the speaker amp */
6244 		alc_setup_gpio(codec, 0x04);
6245 		snd_hda_apply_pincfgs(codec, dock_pins);
6246 		spec->gen.auto_mute_via_amp = 1;
6247 		spec->gen.automute_hook = asus_tx300_automute;
6248 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
6249 						    snd_hda_gen_hp_automute);
6250 		break;
6251 	case HDA_FIXUP_ACT_PROBE:
6252 		spec->init_amp = ALC_INIT_DEFAULT;
6253 		break;
6254 	case HDA_FIXUP_ACT_BUILD:
6255 		/* this is a bit tricky; give more sane names for the main
6256 		 * (tablet) speaker and the dock speaker, respectively
6257 		 */
6258 		rename_ctl(codec, "Speaker Playback Switch",
6259 			   "Dock Speaker Playback Switch");
6260 		rename_ctl(codec, "Bass Speaker Playback Switch",
6261 			   "Speaker Playback Switch");
6262 		break;
6263 	}
6264 }
6265 
alc290_fixup_mono_speakers(struct hda_codec * codec,const struct hda_fixup * fix,int action)6266 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
6267 				       const struct hda_fixup *fix, int action)
6268 {
6269 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6270 		/* DAC node 0x03 is giving mono output. We therefore want to
6271 		   make sure 0x14 (front speaker) and 0x15 (headphones) use the
6272 		   stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
6273 		static const hda_nid_t conn1[] = { 0x0c };
6274 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
6275 		snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
6276 	}
6277 }
6278 
alc298_fixup_speaker_volume(struct hda_codec * codec,const struct hda_fixup * fix,int action)6279 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
6280 					const struct hda_fixup *fix, int action)
6281 {
6282 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6283 		/* The speaker is routed to the Node 0x06 by a mistake, as a result
6284 		   we can't adjust the speaker's volume since this node does not has
6285 		   Amp-out capability. we change the speaker's route to:
6286 		   Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
6287 		   Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
6288 		   speaker's volume now. */
6289 
6290 		static const hda_nid_t conn1[] = { 0x0c };
6291 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
6292 	}
6293 }
6294 
6295 /* 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)6296 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
6297 				      const struct hda_fixup *fix, int action)
6298 {
6299 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6300 		static const hda_nid_t conn[] = { 0x02, 0x03 };
6301 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6302 	}
6303 }
6304 
6305 /* 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)6306 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6307 					  const struct hda_fixup *fix, int action)
6308 {
6309 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6310 		static const hda_nid_t conn[] = { 0x02 };
6311 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6312 	}
6313 }
6314 
6315 /* Hook to update amp GPIO4 for automute */
alc280_hp_gpio4_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)6316 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6317 					  struct hda_jack_callback *jack)
6318 {
6319 	struct alc_spec *spec = codec->spec;
6320 
6321 	snd_hda_gen_hp_automute(codec, jack);
6322 	/* mute_led_polarity is set to 0, so we pass inverted value here */
6323 	alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6324 			    !spec->gen.hp_jack_present);
6325 }
6326 
6327 /* Manage GPIOs for HP EliteBook Folio 9480m.
6328  *
6329  * GPIO4 is the headphone amplifier power control
6330  * GPIO3 is the audio output mute indicator LED
6331  */
6332 
alc280_fixup_hp_9480m(struct hda_codec * codec,const struct hda_fixup * fix,int action)6333 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6334 				  const struct hda_fixup *fix,
6335 				  int action)
6336 {
6337 	struct alc_spec *spec = codec->spec;
6338 
6339 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6340 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6341 		/* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
6342 		spec->gpio_mask |= 0x10;
6343 		spec->gpio_dir |= 0x10;
6344 		spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
6345 	}
6346 }
6347 
alc275_fixup_gpio4_off(struct hda_codec * codec,const struct hda_fixup * fix,int action)6348 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6349 				   const struct hda_fixup *fix,
6350 				   int action)
6351 {
6352 	struct alc_spec *spec = codec->spec;
6353 
6354 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6355 		spec->gpio_mask |= 0x04;
6356 		spec->gpio_dir |= 0x04;
6357 		/* set data bit low */
6358 	}
6359 }
6360 
6361 /* Quirk for Thinkpad X1 7th and 8th Gen
6362  * The following fixed routing needed
6363  * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
6364  * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
6365  * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
6366  */
alc285_fixup_thinkpad_x1_gen7(struct hda_codec * codec,const struct hda_fixup * fix,int action)6367 static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6368 					  const struct hda_fixup *fix, int action)
6369 {
6370 	static const hda_nid_t conn[] = { 0x02, 0x03 }; /* exclude 0x06 */
6371 	static const hda_nid_t preferred_pairs[] = {
6372 		0x14, 0x02, 0x17, 0x03, 0x21, 0x03, 0
6373 	};
6374 	struct alc_spec *spec = codec->spec;
6375 
6376 	switch (action) {
6377 	case HDA_FIXUP_ACT_PRE_PROBE:
6378 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6379 		spec->gen.preferred_dacs = preferred_pairs;
6380 		break;
6381 	case HDA_FIXUP_ACT_BUILD:
6382 		/* The generic parser creates somewhat unintuitive volume ctls
6383 		 * with the fixed routing above, and the shared DAC2 may be
6384 		 * confusing for PA.
6385 		 * Rename those to unique names so that PA doesn't touch them
6386 		 * and use only Master volume.
6387 		 */
6388 		rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6389 		rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6390 		break;
6391 	}
6392 }
6393 
alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec * codec,const struct hda_fixup * fix,int action)6394 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6395 					 const struct hda_fixup *fix,
6396 					 int action)
6397 {
6398 	alc_fixup_dual_codecs(codec, fix, action);
6399 	switch (action) {
6400 	case HDA_FIXUP_ACT_PRE_PROBE:
6401 		/* override card longname to provide a unique UCM profile */
6402 		strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6403 		break;
6404 	case HDA_FIXUP_ACT_BUILD:
6405 		/* rename Capture controls depending on the codec */
6406 		rename_ctl(codec, "Capture Volume",
6407 			   codec->addr == 0 ?
6408 			   "Rear-Panel Capture Volume" :
6409 			   "Front-Panel Capture Volume");
6410 		rename_ctl(codec, "Capture Switch",
6411 			   codec->addr == 0 ?
6412 			   "Rear-Panel Capture Switch" :
6413 			   "Front-Panel Capture Switch");
6414 		break;
6415 	}
6416 }
6417 
alc225_fixup_s3_pop_noise(struct hda_codec * codec,const struct hda_fixup * fix,int action)6418 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6419 				      const struct hda_fixup *fix, int action)
6420 {
6421 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
6422 		return;
6423 
6424 	codec->power_save_node = 1;
6425 }
6426 
6427 /* 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)6428 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6429 				    const struct hda_fixup *fix, int action)
6430 {
6431 	struct alc_spec *spec = codec->spec;
6432 	static const hda_nid_t preferred_pairs[] = {
6433 		0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
6434 		0
6435 	};
6436 
6437 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
6438 		return;
6439 
6440 	spec->gen.preferred_dacs = preferred_pairs;
6441 	spec->gen.auto_mute_via_amp = 1;
6442 	codec->power_save_node = 0;
6443 }
6444 
6445 /* 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)6446 static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6447 				    const struct hda_fixup *fix, int action)
6448 {
6449 	static const hda_nid_t preferred_pairs[] = {
6450 		0x14, 0x02, 0x17, 0x02, 0x21, 0x03, 0
6451 	};
6452 	struct alc_spec *spec = codec->spec;
6453 
6454 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6455 		spec->gen.preferred_dacs = preferred_pairs;
6456 		spec->gen.obey_preferred_dacs = 1;
6457 	}
6458 }
6459 
6460 /* 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)6461 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6462 			      const struct hda_fixup *fix, int action)
6463 {
6464 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
6465 		return;
6466 
6467 	snd_hda_override_wcaps(codec, 0x03, 0);
6468 }
6469 
alc_combo_jack_hp_jd_restart(struct hda_codec * codec)6470 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6471 {
6472 	switch (codec->core.vendor_id) {
6473 	case 0x10ec0274:
6474 	case 0x10ec0294:
6475 	case 0x10ec0225:
6476 	case 0x10ec0295:
6477 	case 0x10ec0299:
6478 		alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6479 		alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6480 		break;
6481 	case 0x10ec0230:
6482 	case 0x10ec0235:
6483 	case 0x10ec0236:
6484 	case 0x10ec0255:
6485 	case 0x10ec0256:
6486 	case 0x10ec0257:
6487 	case 0x19e58326:
6488 		alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6489 		alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6490 		break;
6491 	}
6492 }
6493 
alc295_fixup_chromebook(struct hda_codec * codec,const struct hda_fixup * fix,int action)6494 static void alc295_fixup_chromebook(struct hda_codec *codec,
6495 				    const struct hda_fixup *fix, int action)
6496 {
6497 	struct alc_spec *spec = codec->spec;
6498 
6499 	switch (action) {
6500 	case HDA_FIXUP_ACT_PRE_PROBE:
6501 		spec->ultra_low_power = true;
6502 		break;
6503 	case HDA_FIXUP_ACT_INIT:
6504 		alc_combo_jack_hp_jd_restart(codec);
6505 		break;
6506 	}
6507 }
6508 
alc_fixup_disable_mic_vref(struct hda_codec * codec,const struct hda_fixup * fix,int action)6509 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6510 				  const struct hda_fixup *fix, int action)
6511 {
6512 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
6513 		snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6514 }
6515 
6516 
alc294_gx502_toggle_output(struct hda_codec * codec,struct hda_jack_callback * cb)6517 static void alc294_gx502_toggle_output(struct hda_codec *codec,
6518 					struct hda_jack_callback *cb)
6519 {
6520 	/* The Windows driver sets the codec up in a very different way where
6521 	 * it appears to leave 0x10 = 0x8a20 set. For Linux we need to toggle it
6522 	 */
6523 	if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6524 		alc_write_coef_idx(codec, 0x10, 0x8a20);
6525 	else
6526 		alc_write_coef_idx(codec, 0x10, 0x0a20);
6527 }
6528 
alc294_fixup_gx502_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)6529 static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6530 					const struct hda_fixup *fix, int action)
6531 {
6532 	/* Pin 0x21: headphones/headset mic */
6533 	if (!is_jack_detectable(codec, 0x21))
6534 		return;
6535 
6536 	switch (action) {
6537 	case HDA_FIXUP_ACT_PRE_PROBE:
6538 		snd_hda_jack_detect_enable_callback(codec, 0x21,
6539 				alc294_gx502_toggle_output);
6540 		break;
6541 	case HDA_FIXUP_ACT_INIT:
6542 		/* Make sure to start in a correct state, i.e. if
6543 		 * headphones have been plugged in before powering up the system
6544 		 */
6545 		alc294_gx502_toggle_output(codec, NULL);
6546 		break;
6547 	}
6548 }
6549 
alc294_gu502_toggle_output(struct hda_codec * codec,struct hda_jack_callback * cb)6550 static void alc294_gu502_toggle_output(struct hda_codec *codec,
6551 				       struct hda_jack_callback *cb)
6552 {
6553 	/* Windows sets 0x10 to 0x8420 for Node 0x20 which is
6554 	 * responsible from changes between speakers and headphones
6555 	 */
6556 	if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6557 		alc_write_coef_idx(codec, 0x10, 0x8420);
6558 	else
6559 		alc_write_coef_idx(codec, 0x10, 0x0a20);
6560 }
6561 
alc294_fixup_gu502_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)6562 static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6563 				  const struct hda_fixup *fix, int action)
6564 {
6565 	if (!is_jack_detectable(codec, 0x21))
6566 		return;
6567 
6568 	switch (action) {
6569 	case HDA_FIXUP_ACT_PRE_PROBE:
6570 		snd_hda_jack_detect_enable_callback(codec, 0x21,
6571 				alc294_gu502_toggle_output);
6572 		break;
6573 	case HDA_FIXUP_ACT_INIT:
6574 		alc294_gu502_toggle_output(codec, NULL);
6575 		break;
6576 	}
6577 }
6578 
alc285_fixup_hp_gpio_amp_init(struct hda_codec * codec,const struct hda_fixup * fix,int action)6579 static void  alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6580 			      const struct hda_fixup *fix, int action)
6581 {
6582 	if (action != HDA_FIXUP_ACT_INIT)
6583 		return;
6584 
6585 	msleep(100);
6586 	alc_write_coef_idx(codec, 0x65, 0x0);
6587 }
6588 
alc274_fixup_hp_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)6589 static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6590 				    const struct hda_fixup *fix, int action)
6591 {
6592 	switch (action) {
6593 	case HDA_FIXUP_ACT_INIT:
6594 		alc_combo_jack_hp_jd_restart(codec);
6595 		break;
6596 	}
6597 }
6598 
alc_fixup_no_int_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)6599 static void alc_fixup_no_int_mic(struct hda_codec *codec,
6600 				    const struct hda_fixup *fix, int action)
6601 {
6602 	struct alc_spec *spec = codec->spec;
6603 
6604 	switch (action) {
6605 	case HDA_FIXUP_ACT_PRE_PROBE:
6606 		/* Mic RING SLEEVE swap for combo jack */
6607 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
6608 		spec->no_internal_mic_pin = true;
6609 		break;
6610 	case HDA_FIXUP_ACT_INIT:
6611 		alc_combo_jack_hp_jd_restart(codec);
6612 		break;
6613 	}
6614 }
6615 
6616 /* GPIO1 = amplifier on/off
6617  * GPIO3 = mic mute LED
6618  */
alc285_fixup_hp_spectre_x360_eb1(struct hda_codec * codec,const struct hda_fixup * fix,int action)6619 static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
6620 					  const struct hda_fixup *fix, int action)
6621 {
6622 	static const hda_nid_t conn[] = { 0x02 };
6623 
6624 	struct alc_spec *spec = codec->spec;
6625 	static const struct hda_pintbl pincfgs[] = {
6626 		{ 0x14, 0x90170110 },  /* front/high speakers */
6627 		{ 0x17, 0x90170130 },  /* back/bass speakers */
6628 		{ }
6629 	};
6630 
6631 	//enable micmute led
6632 	alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
6633 
6634 	switch (action) {
6635 	case HDA_FIXUP_ACT_PRE_PROBE:
6636 		spec->micmute_led_polarity = 1;
6637 		/* needed for amp of back speakers */
6638 		spec->gpio_mask |= 0x01;
6639 		spec->gpio_dir |= 0x01;
6640 		snd_hda_apply_pincfgs(codec, pincfgs);
6641 		/* share DAC to have unified volume control */
6642 		snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
6643 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6644 		break;
6645 	case HDA_FIXUP_ACT_INIT:
6646 		/* need to toggle GPIO to enable the amp of back speakers */
6647 		alc_update_gpio_data(codec, 0x01, true);
6648 		msleep(100);
6649 		alc_update_gpio_data(codec, 0x01, false);
6650 		break;
6651 	}
6652 }
6653 
alc285_fixup_hp_spectre_x360(struct hda_codec * codec,const struct hda_fixup * fix,int action)6654 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6655 					  const struct hda_fixup *fix, int action)
6656 {
6657 	static const hda_nid_t conn[] = { 0x02 };
6658 	static const struct hda_pintbl pincfgs[] = {
6659 		{ 0x14, 0x90170110 },  /* rear speaker */
6660 		{ }
6661 	};
6662 
6663 	switch (action) {
6664 	case HDA_FIXUP_ACT_PRE_PROBE:
6665 		snd_hda_apply_pincfgs(codec, pincfgs);
6666 		/* force front speaker to DAC1 */
6667 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6668 		break;
6669 	}
6670 }
6671 
6672 /* for hda_fixup_thinkpad_acpi() */
6673 #include "thinkpad_helper.c"
6674 
alc_fixup_thinkpad_acpi(struct hda_codec * codec,const struct hda_fixup * fix,int action)6675 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6676 				    const struct hda_fixup *fix, int action)
6677 {
6678 	alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6679 	hda_fixup_thinkpad_acpi(codec, fix, action);
6680 }
6681 
6682 /* 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)6683 static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6684 						  const struct hda_fixup *fix,
6685 						  int action)
6686 {
6687 	struct alc_spec *spec = codec->spec;
6688 
6689 	switch (action) {
6690 	case HDA_FIXUP_ACT_PRE_PROBE:
6691 		spec->gen.suppress_auto_mute = 1;
6692 		break;
6693 	}
6694 }
6695 
6696 /* for alc295_fixup_hp_top_speakers */
6697 #include "hp_x360_helper.c"
6698 
6699 /* for alc285_fixup_ideapad_s740_coef() */
6700 #include "ideapad_s740_helper.c"
6701 
6702 static const struct coef_fw alc256_fixup_set_coef_defaults_coefs[] = {
6703 	WRITE_COEF(0x10, 0x0020), WRITE_COEF(0x24, 0x0000),
6704 	WRITE_COEF(0x26, 0x0000), WRITE_COEF(0x29, 0x3000),
6705 	WRITE_COEF(0x37, 0xfe05), WRITE_COEF(0x45, 0x5089),
6706 	{}
6707 };
6708 
alc256_fixup_set_coef_defaults(struct hda_codec * codec,const struct hda_fixup * fix,int action)6709 static void alc256_fixup_set_coef_defaults(struct hda_codec *codec,
6710 					   const struct hda_fixup *fix,
6711 					   int action)
6712 {
6713 	/*
6714 	 * A certain other OS sets these coeffs to different values. On at least
6715 	 * one TongFang barebone these settings might survive even a cold
6716 	 * reboot. So to restore a clean slate the values are explicitly reset
6717 	 * to default here. Without this, the external microphone is always in a
6718 	 * plugged-in state, while the internal microphone is always in an
6719 	 * unplugged state, breaking the ability to use the internal microphone.
6720 	 */
6721 	alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs);
6722 }
6723 
6724 static const struct coef_fw alc233_fixup_no_audio_jack_coefs[] = {
6725 	WRITE_COEF(0x1a, 0x9003), WRITE_COEF(0x1b, 0x0e2b), WRITE_COEF(0x37, 0xfe06),
6726 	WRITE_COEF(0x38, 0x4981), WRITE_COEF(0x45, 0xd489), WRITE_COEF(0x46, 0x0074),
6727 	WRITE_COEF(0x49, 0x0149),
6728 	{}
6729 };
6730 
alc233_fixup_no_audio_jack(struct hda_codec * codec,const struct hda_fixup * fix,int action)6731 static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
6732 				       const struct hda_fixup *fix,
6733 				       int action)
6734 {
6735 	/*
6736 	 * The audio jack input and output is not detected on the ASRock NUC Box
6737 	 * 1100 series when cold booting without this fix. Warm rebooting from a
6738 	 * certain other OS makes the audio functional, as COEF settings are
6739 	 * preserved in this case. This fix sets these altered COEF values as
6740 	 * the default.
6741 	 */
6742 	alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
6743 }
6744 
alc256_fixup_mic_no_presence_and_resume(struct hda_codec * codec,const struct hda_fixup * fix,int action)6745 static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
6746 						    const struct hda_fixup *fix,
6747 						    int action)
6748 {
6749 	/*
6750 	 * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
6751 	 * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
6752 	 * needs an additional quirk for sound working after suspend and resume.
6753 	 */
6754 	if (codec->core.vendor_id == 0x10ec0256) {
6755 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
6756 		snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
6757 	} else {
6758 		snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
6759 	}
6760 }
6761 
alc295_fixup_dell_inspiron_top_speakers(struct hda_codec * codec,const struct hda_fixup * fix,int action)6762 static void alc295_fixup_dell_inspiron_top_speakers(struct hda_codec *codec,
6763 					  const struct hda_fixup *fix, int action)
6764 {
6765 	static const struct hda_pintbl pincfgs[] = {
6766 		{ 0x14, 0x90170151 },
6767 		{ 0x17, 0x90170150 },
6768 		{ }
6769 	};
6770 	static const hda_nid_t conn[] = { 0x02, 0x03 };
6771 	static const hda_nid_t preferred_pairs[] = {
6772 		0x14, 0x02,
6773 		0x17, 0x03,
6774 		0x21, 0x02,
6775 		0
6776 	};
6777 	struct alc_spec *spec = codec->spec;
6778 
6779 	alc_fixup_no_shutup(codec, fix, action);
6780 
6781 	switch (action) {
6782 	case HDA_FIXUP_ACT_PRE_PROBE:
6783 		snd_hda_apply_pincfgs(codec, pincfgs);
6784 		snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6785 		spec->gen.preferred_dacs = preferred_pairs;
6786 		break;
6787 	}
6788 }
6789 
6790 enum {
6791 	ALC269_FIXUP_GPIO2,
6792 	ALC269_FIXUP_SONY_VAIO,
6793 	ALC275_FIXUP_SONY_VAIO_GPIO2,
6794 	ALC269_FIXUP_DELL_M101Z,
6795 	ALC269_FIXUP_SKU_IGNORE,
6796 	ALC269_FIXUP_ASUS_G73JW,
6797 	ALC269_FIXUP_LENOVO_EAPD,
6798 	ALC275_FIXUP_SONY_HWEQ,
6799 	ALC275_FIXUP_SONY_DISABLE_AAMIX,
6800 	ALC271_FIXUP_DMIC,
6801 	ALC269_FIXUP_PCM_44K,
6802 	ALC269_FIXUP_STEREO_DMIC,
6803 	ALC269_FIXUP_HEADSET_MIC,
6804 	ALC269_FIXUP_QUANTA_MUTE,
6805 	ALC269_FIXUP_LIFEBOOK,
6806 	ALC269_FIXUP_LIFEBOOK_EXTMIC,
6807 	ALC269_FIXUP_LIFEBOOK_HP_PIN,
6808 	ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
6809 	ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
6810 	ALC269_FIXUP_AMIC,
6811 	ALC269_FIXUP_DMIC,
6812 	ALC269VB_FIXUP_AMIC,
6813 	ALC269VB_FIXUP_DMIC,
6814 	ALC269_FIXUP_HP_MUTE_LED,
6815 	ALC269_FIXUP_HP_MUTE_LED_MIC1,
6816 	ALC269_FIXUP_HP_MUTE_LED_MIC2,
6817 	ALC269_FIXUP_HP_MUTE_LED_MIC3,
6818 	ALC269_FIXUP_HP_GPIO_LED,
6819 	ALC269_FIXUP_HP_GPIO_MIC1_LED,
6820 	ALC269_FIXUP_HP_LINE1_MIC1_LED,
6821 	ALC269_FIXUP_INV_DMIC,
6822 	ALC269_FIXUP_LENOVO_DOCK,
6823 	ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
6824 	ALC269_FIXUP_NO_SHUTUP,
6825 	ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
6826 	ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
6827 	ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6828 	ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
6829 	ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6830 	ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6831 	ALC269_FIXUP_HEADSET_MODE,
6832 	ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
6833 	ALC269_FIXUP_ASPIRE_HEADSET_MIC,
6834 	ALC269_FIXUP_ASUS_X101_FUNC,
6835 	ALC269_FIXUP_ASUS_X101_VERB,
6836 	ALC269_FIXUP_ASUS_X101,
6837 	ALC271_FIXUP_AMIC_MIC2,
6838 	ALC271_FIXUP_HP_GATE_MIC_JACK,
6839 	ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
6840 	ALC269_FIXUP_ACER_AC700,
6841 	ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
6842 	ALC269VB_FIXUP_ASUS_ZENBOOK,
6843 	ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
6844 	ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE,
6845 	ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
6846 	ALC269VB_FIXUP_ORDISSIMO_EVE2,
6847 	ALC283_FIXUP_CHROME_BOOK,
6848 	ALC283_FIXUP_SENSE_COMBO_JACK,
6849 	ALC282_FIXUP_ASUS_TX300,
6850 	ALC283_FIXUP_INT_MIC,
6851 	ALC290_FIXUP_MONO_SPEAKERS,
6852 	ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6853 	ALC290_FIXUP_SUBWOOFER,
6854 	ALC290_FIXUP_SUBWOOFER_HSJACK,
6855 	ALC269_FIXUP_THINKPAD_ACPI,
6856 	ALC269_FIXUP_DMIC_THINKPAD_ACPI,
6857 	ALC269VB_FIXUP_CHUWI_COREBOOK_XPRO,
6858 	ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6859 	ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6860 	ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6861 	ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
6862 	ALC255_FIXUP_HEADSET_MODE,
6863 	ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
6864 	ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
6865 	ALC292_FIXUP_TPT440_DOCK,
6866 	ALC292_FIXUP_TPT440,
6867 	ALC283_FIXUP_HEADSET_MIC,
6868 	ALC255_FIXUP_MIC_MUTE_LED,
6869 	ALC282_FIXUP_ASPIRE_V5_PINS,
6870 	ALC269VB_FIXUP_ASPIRE_E1_COEF,
6871 	ALC280_FIXUP_HP_GPIO4,
6872 	ALC286_FIXUP_HP_GPIO_LED,
6873 	ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
6874 	ALC280_FIXUP_HP_DOCK_PINS,
6875 	ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
6876 	ALC280_FIXUP_HP_9480M,
6877 	ALC245_FIXUP_HP_X360_AMP,
6878 	ALC285_FIXUP_HP_SPECTRE_X360_EB1,
6879 	ALC288_FIXUP_DELL_HEADSET_MODE,
6880 	ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
6881 	ALC288_FIXUP_DELL_XPS_13,
6882 	ALC288_FIXUP_DISABLE_AAMIX,
6883 	ALC292_FIXUP_DELL_E7X_AAMIX,
6884 	ALC292_FIXUP_DELL_E7X,
6885 	ALC292_FIXUP_DISABLE_AAMIX,
6886 	ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
6887 	ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
6888 	ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6889 	ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6890 	ALC275_FIXUP_DELL_XPS,
6891 	ALC293_FIXUP_LENOVO_SPK_NOISE,
6892 	ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
6893 	ALC255_FIXUP_DELL_SPK_NOISE,
6894 	ALC225_FIXUP_DISABLE_MIC_VREF,
6895 	ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6896 	ALC295_FIXUP_DISABLE_DAC3,
6897 	ALC285_FIXUP_SPEAKER2_TO_DAC1,
6898 	ALC280_FIXUP_HP_HEADSET_MIC,
6899 	ALC221_FIXUP_HP_FRONT_MIC,
6900 	ALC292_FIXUP_TPT460,
6901 	ALC298_FIXUP_SPK_VOLUME,
6902 	ALC298_FIXUP_LENOVO_SPK_VOLUME,
6903 	ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
6904 	ALC269_FIXUP_ATIV_BOOK_8,
6905 	ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE,
6906 	ALC221_FIXUP_HP_MIC_NO_PRESENCE,
6907 	ALC256_FIXUP_ASUS_HEADSET_MODE,
6908 	ALC256_FIXUP_ASUS_MIC,
6909 	ALC256_FIXUP_ASUS_AIO_GPIO2,
6910 	ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
6911 	ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
6912 	ALC233_FIXUP_LENOVO_MULTI_CODECS,
6913 	ALC233_FIXUP_ACER_HEADSET_MIC,
6914 	ALC294_FIXUP_LENOVO_MIC_LOCATION,
6915 	ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
6916 	ALC225_FIXUP_S3_POP_NOISE,
6917 	ALC700_FIXUP_INTEL_REFERENCE,
6918 	ALC274_FIXUP_DELL_BIND_DACS,
6919 	ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6920 	ALC298_FIXUP_TPT470_DOCK_FIX,
6921 	ALC298_FIXUP_TPT470_DOCK,
6922 	ALC255_FIXUP_DUMMY_LINEOUT_VERB,
6923 	ALC255_FIXUP_DELL_HEADSET_MIC,
6924 	ALC256_FIXUP_HUAWEI_MACH_WX9_PINS,
6925 	ALC298_FIXUP_HUAWEI_MBX_STEREO,
6926 	ALC295_FIXUP_HP_X360,
6927 	ALC221_FIXUP_HP_HEADSET_MIC,
6928 	ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
6929 	ALC295_FIXUP_HP_AUTO_MUTE,
6930 	ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
6931 	ALC294_FIXUP_ASUS_MIC,
6932 	ALC294_FIXUP_ASUS_HEADSET_MIC,
6933 	ALC294_FIXUP_ASUS_SPK,
6934 	ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
6935 	ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
6936 	ALC255_FIXUP_ACER_HEADSET_MIC,
6937 	ALC295_FIXUP_CHROME_BOOK,
6938 	ALC225_FIXUP_HEADSET_JACK,
6939 	ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
6940 	ALC225_FIXUP_WYSE_AUTO_MUTE,
6941 	ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
6942 	ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
6943 	ALC256_FIXUP_ASUS_HEADSET_MIC,
6944 	ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
6945 	ALC299_FIXUP_PREDATOR_SPK,
6946 	ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
6947 	ALC289_FIXUP_DELL_SPK2,
6948 	ALC289_FIXUP_DUAL_SPK,
6949 	ALC294_FIXUP_SPK2_TO_DAC1,
6950 	ALC294_FIXUP_ASUS_DUAL_SPK,
6951 	ALC285_FIXUP_THINKPAD_X1_GEN7,
6952 	ALC285_FIXUP_THINKPAD_HEADSET_JACK,
6953 	ALC294_FIXUP_ASUS_HPE,
6954 	ALC294_FIXUP_ASUS_COEF_1B,
6955 	ALC294_FIXUP_ASUS_GX502_HP,
6956 	ALC294_FIXUP_ASUS_GX502_PINS,
6957 	ALC294_FIXUP_ASUS_GX502_VERBS,
6958 	ALC294_FIXUP_ASUS_GU502_HP,
6959 	ALC294_FIXUP_ASUS_GU502_PINS,
6960 	ALC294_FIXUP_ASUS_GU502_VERBS,
6961 	ALC294_FIXUP_ASUS_G513_PINS,
6962 	ALC285_FIXUP_ASUS_G533Z_PINS,
6963 	ALC285_FIXUP_HP_GPIO_LED,
6964 	ALC285_FIXUP_HP_MUTE_LED,
6965 	ALC285_FIXUP_HP_SPECTRE_X360_MUTE_LED,
6966 	ALC236_FIXUP_HP_MUTE_LED_COEFBIT2,
6967 	ALC236_FIXUP_HP_GPIO_LED,
6968 	ALC236_FIXUP_HP_MUTE_LED,
6969 	ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
6970 	ALC298_FIXUP_SAMSUNG_AMP,
6971 	ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6972 	ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6973 	ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
6974 	ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
6975 	ALC269VC_FIXUP_ACER_HEADSET_MIC,
6976 	ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE,
6977 	ALC289_FIXUP_ASUS_GA401,
6978 	ALC289_FIXUP_ASUS_GA502,
6979 	ALC256_FIXUP_ACER_MIC_NO_PRESENCE,
6980 	ALC285_FIXUP_HP_GPIO_AMP_INIT,
6981 	ALC269_FIXUP_CZC_B20,
6982 	ALC269_FIXUP_CZC_TMI,
6983 	ALC269_FIXUP_CZC_L101,
6984 	ALC269_FIXUP_LEMOTE_A1802,
6985 	ALC269_FIXUP_LEMOTE_A190X,
6986 	ALC256_FIXUP_INTEL_NUC8_RUGGED,
6987 	ALC233_FIXUP_INTEL_NUC8_DMIC,
6988 	ALC233_FIXUP_INTEL_NUC8_BOOST,
6989 	ALC256_FIXUP_INTEL_NUC10,
6990 	ALC255_FIXUP_XIAOMI_HEADSET_MIC,
6991 	ALC274_FIXUP_HP_MIC,
6992 	ALC274_FIXUP_HP_HEADSET_MIC,
6993 	ALC274_FIXUP_HP_ENVY_GPIO,
6994 	ALC256_FIXUP_ASUS_HPE,
6995 	ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
6996 	ALC287_FIXUP_HP_GPIO_LED,
6997 	ALC256_FIXUP_HP_HEADSET_MIC,
6998 	ALC245_FIXUP_HP_GPIO_LED,
6999 	ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
7000 	ALC282_FIXUP_ACER_DISABLE_LINEOUT,
7001 	ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST,
7002 	ALC256_FIXUP_ACER_HEADSET_MIC,
7003 	ALC285_FIXUP_IDEAPAD_S740_COEF,
7004 	ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST,
7005 	ALC295_FIXUP_ASUS_DACS,
7006 	ALC295_FIXUP_HP_OMEN,
7007 	ALC285_FIXUP_HP_SPECTRE_X360,
7008 	ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP,
7009 	ALC623_FIXUP_LENOVO_THINKSTATION_P340,
7010 	ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
7011 	ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
7012 	ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
7013 	ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
7014 	ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
7015 	ALC298_FIXUP_LENOVO_C940_DUET7,
7016 	ALC287_FIXUP_13S_GEN2_SPEAKERS,
7017 	ALC256_FIXUP_SET_COEF_DEFAULTS,
7018 	ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
7019 	ALC233_FIXUP_NO_AUDIO_JACK,
7020 	ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME,
7021 	ALC285_FIXUP_LEGION_Y9000X_SPEAKERS,
7022 	ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
7023 	ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED,
7024 	ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS,
7025 	ALC236_FIXUP_DELL_DUAL_CODECS,
7026 };
7027 
7028 /* A special fixup for Lenovo C940 and Yoga Duet 7;
7029  * both have the very same PCI SSID, and we need to apply different fixups
7030  * depending on the codec ID
7031  */
alc298_fixup_lenovo_c940_duet7(struct hda_codec * codec,const struct hda_fixup * fix,int action)7032 static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
7033 					   const struct hda_fixup *fix,
7034 					   int action)
7035 {
7036 	int id;
7037 
7038 	if (codec->core.vendor_id == 0x10ec0298)
7039 		id = ALC298_FIXUP_LENOVO_SPK_VOLUME; /* C940 */
7040 	else
7041 		id = ALC287_FIXUP_YOGA7_14ITL_SPEAKERS; /* Duet 7 */
7042 	__snd_hda_apply_fixup(codec, id, action, 0);
7043 }
7044 
7045 static const struct hda_fixup alc269_fixups[] = {
7046 	[ALC269_FIXUP_GPIO2] = {
7047 		.type = HDA_FIXUP_FUNC,
7048 		.v.func = alc_fixup_gpio2,
7049 	},
7050 	[ALC269_FIXUP_SONY_VAIO] = {
7051 		.type = HDA_FIXUP_PINCTLS,
7052 		.v.pins = (const struct hda_pintbl[]) {
7053 			{0x19, PIN_VREFGRD},
7054 			{}
7055 		}
7056 	},
7057 	[ALC275_FIXUP_SONY_VAIO_GPIO2] = {
7058 		.type = HDA_FIXUP_FUNC,
7059 		.v.func = alc275_fixup_gpio4_off,
7060 		.chained = true,
7061 		.chain_id = ALC269_FIXUP_SONY_VAIO
7062 	},
7063 	[ALC269_FIXUP_DELL_M101Z] = {
7064 		.type = HDA_FIXUP_VERBS,
7065 		.v.verbs = (const struct hda_verb[]) {
7066 			/* Enables internal speaker */
7067 			{0x20, AC_VERB_SET_COEF_INDEX, 13},
7068 			{0x20, AC_VERB_SET_PROC_COEF, 0x4040},
7069 			{}
7070 		}
7071 	},
7072 	[ALC269_FIXUP_SKU_IGNORE] = {
7073 		.type = HDA_FIXUP_FUNC,
7074 		.v.func = alc_fixup_sku_ignore,
7075 	},
7076 	[ALC269_FIXUP_ASUS_G73JW] = {
7077 		.type = HDA_FIXUP_PINS,
7078 		.v.pins = (const struct hda_pintbl[]) {
7079 			{ 0x17, 0x99130111 }, /* subwoofer */
7080 			{ }
7081 		}
7082 	},
7083 	[ALC269_FIXUP_LENOVO_EAPD] = {
7084 		.type = HDA_FIXUP_VERBS,
7085 		.v.verbs = (const struct hda_verb[]) {
7086 			{0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
7087 			{}
7088 		}
7089 	},
7090 	[ALC275_FIXUP_SONY_HWEQ] = {
7091 		.type = HDA_FIXUP_FUNC,
7092 		.v.func = alc269_fixup_hweq,
7093 		.chained = true,
7094 		.chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
7095 	},
7096 	[ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
7097 		.type = HDA_FIXUP_FUNC,
7098 		.v.func = alc_fixup_disable_aamix,
7099 		.chained = true,
7100 		.chain_id = ALC269_FIXUP_SONY_VAIO
7101 	},
7102 	[ALC271_FIXUP_DMIC] = {
7103 		.type = HDA_FIXUP_FUNC,
7104 		.v.func = alc271_fixup_dmic,
7105 	},
7106 	[ALC269_FIXUP_PCM_44K] = {
7107 		.type = HDA_FIXUP_FUNC,
7108 		.v.func = alc269_fixup_pcm_44k,
7109 		.chained = true,
7110 		.chain_id = ALC269_FIXUP_QUANTA_MUTE
7111 	},
7112 	[ALC269_FIXUP_STEREO_DMIC] = {
7113 		.type = HDA_FIXUP_FUNC,
7114 		.v.func = alc269_fixup_stereo_dmic,
7115 	},
7116 	[ALC269_FIXUP_HEADSET_MIC] = {
7117 		.type = HDA_FIXUP_FUNC,
7118 		.v.func = alc269_fixup_headset_mic,
7119 	},
7120 	[ALC269_FIXUP_QUANTA_MUTE] = {
7121 		.type = HDA_FIXUP_FUNC,
7122 		.v.func = alc269_fixup_quanta_mute,
7123 	},
7124 	[ALC269_FIXUP_LIFEBOOK] = {
7125 		.type = HDA_FIXUP_PINS,
7126 		.v.pins = (const struct hda_pintbl[]) {
7127 			{ 0x1a, 0x2101103f }, /* dock line-out */
7128 			{ 0x1b, 0x23a11040 }, /* dock mic-in */
7129 			{ }
7130 		},
7131 		.chained = true,
7132 		.chain_id = ALC269_FIXUP_QUANTA_MUTE
7133 	},
7134 	[ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
7135 		.type = HDA_FIXUP_PINS,
7136 		.v.pins = (const struct hda_pintbl[]) {
7137 			{ 0x19, 0x01a1903c }, /* headset mic, with jack detect */
7138 			{ }
7139 		},
7140 	},
7141 	[ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
7142 		.type = HDA_FIXUP_PINS,
7143 		.v.pins = (const struct hda_pintbl[]) {
7144 			{ 0x21, 0x0221102f }, /* HP out */
7145 			{ }
7146 		},
7147 	},
7148 	[ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
7149 		.type = HDA_FIXUP_FUNC,
7150 		.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
7151 	},
7152 	[ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
7153 		.type = HDA_FIXUP_FUNC,
7154 		.v.func = alc269_fixup_pincfg_U7x7_headset_mic,
7155 	},
7156 	[ALC269VB_FIXUP_CHUWI_COREBOOK_XPRO] = {
7157 		.type = HDA_FIXUP_PINS,
7158 		.v.pins = (const struct hda_pintbl[]) {
7159 			{ 0x18, 0x03a19020 }, /* headset mic */
7160 			{ 0x1b, 0x90170150 }, /* speaker */
7161 			{ }
7162 		},
7163 	},
7164 	[ALC269_FIXUP_AMIC] = {
7165 		.type = HDA_FIXUP_PINS,
7166 		.v.pins = (const struct hda_pintbl[]) {
7167 			{ 0x14, 0x99130110 }, /* speaker */
7168 			{ 0x15, 0x0121401f }, /* HP out */
7169 			{ 0x18, 0x01a19c20 }, /* mic */
7170 			{ 0x19, 0x99a3092f }, /* int-mic */
7171 			{ }
7172 		},
7173 	},
7174 	[ALC269_FIXUP_DMIC] = {
7175 		.type = HDA_FIXUP_PINS,
7176 		.v.pins = (const struct hda_pintbl[]) {
7177 			{ 0x12, 0x99a3092f }, /* int-mic */
7178 			{ 0x14, 0x99130110 }, /* speaker */
7179 			{ 0x15, 0x0121401f }, /* HP out */
7180 			{ 0x18, 0x01a19c20 }, /* mic */
7181 			{ }
7182 		},
7183 	},
7184 	[ALC269VB_FIXUP_AMIC] = {
7185 		.type = HDA_FIXUP_PINS,
7186 		.v.pins = (const struct hda_pintbl[]) {
7187 			{ 0x14, 0x99130110 }, /* speaker */
7188 			{ 0x18, 0x01a19c20 }, /* mic */
7189 			{ 0x19, 0x99a3092f }, /* int-mic */
7190 			{ 0x21, 0x0121401f }, /* HP out */
7191 			{ }
7192 		},
7193 	},
7194 	[ALC269VB_FIXUP_DMIC] = {
7195 		.type = HDA_FIXUP_PINS,
7196 		.v.pins = (const struct hda_pintbl[]) {
7197 			{ 0x12, 0x99a3092f }, /* int-mic */
7198 			{ 0x14, 0x99130110 }, /* speaker */
7199 			{ 0x18, 0x01a19c20 }, /* mic */
7200 			{ 0x21, 0x0121401f }, /* HP out */
7201 			{ }
7202 		},
7203 	},
7204 	[ALC269_FIXUP_HP_MUTE_LED] = {
7205 		.type = HDA_FIXUP_FUNC,
7206 		.v.func = alc269_fixup_hp_mute_led,
7207 	},
7208 	[ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
7209 		.type = HDA_FIXUP_FUNC,
7210 		.v.func = alc269_fixup_hp_mute_led_mic1,
7211 	},
7212 	[ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
7213 		.type = HDA_FIXUP_FUNC,
7214 		.v.func = alc269_fixup_hp_mute_led_mic2,
7215 	},
7216 	[ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
7217 		.type = HDA_FIXUP_FUNC,
7218 		.v.func = alc269_fixup_hp_mute_led_mic3,
7219 		.chained = true,
7220 		.chain_id = ALC295_FIXUP_HP_AUTO_MUTE
7221 	},
7222 	[ALC269_FIXUP_HP_GPIO_LED] = {
7223 		.type = HDA_FIXUP_FUNC,
7224 		.v.func = alc269_fixup_hp_gpio_led,
7225 	},
7226 	[ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
7227 		.type = HDA_FIXUP_FUNC,
7228 		.v.func = alc269_fixup_hp_gpio_mic1_led,
7229 	},
7230 	[ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
7231 		.type = HDA_FIXUP_FUNC,
7232 		.v.func = alc269_fixup_hp_line1_mic1_led,
7233 	},
7234 	[ALC269_FIXUP_INV_DMIC] = {
7235 		.type = HDA_FIXUP_FUNC,
7236 		.v.func = alc_fixup_inv_dmic,
7237 	},
7238 	[ALC269_FIXUP_NO_SHUTUP] = {
7239 		.type = HDA_FIXUP_FUNC,
7240 		.v.func = alc_fixup_no_shutup,
7241 	},
7242 	[ALC269_FIXUP_LENOVO_DOCK] = {
7243 		.type = HDA_FIXUP_PINS,
7244 		.v.pins = (const struct hda_pintbl[]) {
7245 			{ 0x19, 0x23a11040 }, /* dock mic */
7246 			{ 0x1b, 0x2121103f }, /* dock headphone */
7247 			{ }
7248 		},
7249 		.chained = true,
7250 		.chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
7251 	},
7252 	[ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
7253 		.type = HDA_FIXUP_FUNC,
7254 		.v.func = alc269_fixup_limit_int_mic_boost,
7255 		.chained = true,
7256 		.chain_id = ALC269_FIXUP_LENOVO_DOCK,
7257 	},
7258 	[ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
7259 		.type = HDA_FIXUP_FUNC,
7260 		.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
7261 		.chained = true,
7262 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7263 	},
7264 	[ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7265 		.type = HDA_FIXUP_PINS,
7266 		.v.pins = (const struct hda_pintbl[]) {
7267 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7268 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7269 			{ }
7270 		},
7271 		.chained = true,
7272 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7273 	},
7274 	[ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7275 		.type = HDA_FIXUP_PINS,
7276 		.v.pins = (const struct hda_pintbl[]) {
7277 			{ 0x16, 0x21014020 }, /* dock line out */
7278 			{ 0x19, 0x21a19030 }, /* dock mic */
7279 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7280 			{ }
7281 		},
7282 		.chained = true,
7283 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7284 	},
7285 	[ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
7286 		.type = HDA_FIXUP_PINS,
7287 		.v.pins = (const struct hda_pintbl[]) {
7288 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7289 			{ }
7290 		},
7291 		.chained = true,
7292 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7293 	},
7294 	[ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
7295 		.type = HDA_FIXUP_PINS,
7296 		.v.pins = (const struct hda_pintbl[]) {
7297 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7298 			{ 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7299 			{ }
7300 		},
7301 		.chained = true,
7302 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7303 	},
7304 	[ALC269_FIXUP_HEADSET_MODE] = {
7305 		.type = HDA_FIXUP_FUNC,
7306 		.v.func = alc_fixup_headset_mode,
7307 		.chained = true,
7308 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7309 	},
7310 	[ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7311 		.type = HDA_FIXUP_FUNC,
7312 		.v.func = alc_fixup_headset_mode_no_hp_mic,
7313 	},
7314 	[ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
7315 		.type = HDA_FIXUP_PINS,
7316 		.v.pins = (const struct hda_pintbl[]) {
7317 			{ 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
7318 			{ }
7319 		},
7320 		.chained = true,
7321 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
7322 	},
7323 	[ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
7324 		.type = HDA_FIXUP_PINS,
7325 		.v.pins = (const struct hda_pintbl[]) {
7326 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7327 			{ }
7328 		},
7329 		.chained = true,
7330 		.chain_id = ALC269_FIXUP_HEADSET_MIC
7331 	},
7332 	[ALC256_FIXUP_HUAWEI_MACH_WX9_PINS] = {
7333 		.type = HDA_FIXUP_PINS,
7334 		.v.pins = (const struct hda_pintbl[]) {
7335 			{0x12, 0x90a60130},
7336 			{0x13, 0x40000000},
7337 			{0x14, 0x90170110},
7338 			{0x18, 0x411111f0},
7339 			{0x19, 0x04a11040},
7340 			{0x1a, 0x411111f0},
7341 			{0x1b, 0x90170112},
7342 			{0x1d, 0x40759a05},
7343 			{0x1e, 0x411111f0},
7344 			{0x21, 0x04211020},
7345 			{ }
7346 		},
7347 		.chained = true,
7348 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7349 	},
7350 	[ALC298_FIXUP_HUAWEI_MBX_STEREO] = {
7351 		.type = HDA_FIXUP_FUNC,
7352 		.v.func = alc298_fixup_huawei_mbx_stereo,
7353 		.chained = true,
7354 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7355 	},
7356 	[ALC269_FIXUP_ASUS_X101_FUNC] = {
7357 		.type = HDA_FIXUP_FUNC,
7358 		.v.func = alc269_fixup_x101_headset_mic,
7359 	},
7360 	[ALC269_FIXUP_ASUS_X101_VERB] = {
7361 		.type = HDA_FIXUP_VERBS,
7362 		.v.verbs = (const struct hda_verb[]) {
7363 			{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
7364 			{0x20, AC_VERB_SET_COEF_INDEX, 0x08},
7365 			{0x20, AC_VERB_SET_PROC_COEF,  0x0310},
7366 			{ }
7367 		},
7368 		.chained = true,
7369 		.chain_id = ALC269_FIXUP_ASUS_X101_FUNC
7370 	},
7371 	[ALC269_FIXUP_ASUS_X101] = {
7372 		.type = HDA_FIXUP_PINS,
7373 		.v.pins = (const struct hda_pintbl[]) {
7374 			{ 0x18, 0x04a1182c }, /* Headset mic */
7375 			{ }
7376 		},
7377 		.chained = true,
7378 		.chain_id = ALC269_FIXUP_ASUS_X101_VERB
7379 	},
7380 	[ALC271_FIXUP_AMIC_MIC2] = {
7381 		.type = HDA_FIXUP_PINS,
7382 		.v.pins = (const struct hda_pintbl[]) {
7383 			{ 0x14, 0x99130110 }, /* speaker */
7384 			{ 0x19, 0x01a19c20 }, /* mic */
7385 			{ 0x1b, 0x99a7012f }, /* int-mic */
7386 			{ 0x21, 0x0121401f }, /* HP out */
7387 			{ }
7388 		},
7389 	},
7390 	[ALC271_FIXUP_HP_GATE_MIC_JACK] = {
7391 		.type = HDA_FIXUP_FUNC,
7392 		.v.func = alc271_hp_gate_mic_jack,
7393 		.chained = true,
7394 		.chain_id = ALC271_FIXUP_AMIC_MIC2,
7395 	},
7396 	[ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
7397 		.type = HDA_FIXUP_FUNC,
7398 		.v.func = alc269_fixup_limit_int_mic_boost,
7399 		.chained = true,
7400 		.chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
7401 	},
7402 	[ALC269_FIXUP_ACER_AC700] = {
7403 		.type = HDA_FIXUP_PINS,
7404 		.v.pins = (const struct hda_pintbl[]) {
7405 			{ 0x12, 0x99a3092f }, /* int-mic */
7406 			{ 0x14, 0x99130110 }, /* speaker */
7407 			{ 0x18, 0x03a11c20 }, /* mic */
7408 			{ 0x1e, 0x0346101e }, /* SPDIF1 */
7409 			{ 0x21, 0x0321101f }, /* HP out */
7410 			{ }
7411 		},
7412 		.chained = true,
7413 		.chain_id = ALC271_FIXUP_DMIC,
7414 	},
7415 	[ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
7416 		.type = HDA_FIXUP_FUNC,
7417 		.v.func = alc269_fixup_limit_int_mic_boost,
7418 		.chained = true,
7419 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7420 	},
7421 	[ALC269VB_FIXUP_ASUS_ZENBOOK] = {
7422 		.type = HDA_FIXUP_FUNC,
7423 		.v.func = alc269_fixup_limit_int_mic_boost,
7424 		.chained = true,
7425 		.chain_id = ALC269VB_FIXUP_DMIC,
7426 	},
7427 	[ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
7428 		.type = HDA_FIXUP_VERBS,
7429 		.v.verbs = (const struct hda_verb[]) {
7430 			/* class-D output amp +5dB */
7431 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
7432 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
7433 			{}
7434 		},
7435 		.chained = true,
7436 		.chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
7437 	},
7438 	[ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7439 		.type = HDA_FIXUP_PINS,
7440 		.v.pins = (const struct hda_pintbl[]) {
7441 			{ 0x18, 0x01a110f0 },  /* use as headset mic */
7442 			{ }
7443 		},
7444 		.chained = true,
7445 		.chain_id = ALC269_FIXUP_HEADSET_MIC
7446 	},
7447 	[ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
7448 		.type = HDA_FIXUP_FUNC,
7449 		.v.func = alc269_fixup_limit_int_mic_boost,
7450 		.chained = true,
7451 		.chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
7452 	},
7453 	[ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
7454 		.type = HDA_FIXUP_PINS,
7455 		.v.pins = (const struct hda_pintbl[]) {
7456 			{ 0x12, 0x99a3092f }, /* int-mic */
7457 			{ 0x18, 0x03a11d20 }, /* mic */
7458 			{ 0x19, 0x411111f0 }, /* Unused bogus pin */
7459 			{ }
7460 		},
7461 	},
7462 	[ALC283_FIXUP_CHROME_BOOK] = {
7463 		.type = HDA_FIXUP_FUNC,
7464 		.v.func = alc283_fixup_chromebook,
7465 	},
7466 	[ALC283_FIXUP_SENSE_COMBO_JACK] = {
7467 		.type = HDA_FIXUP_FUNC,
7468 		.v.func = alc283_fixup_sense_combo_jack,
7469 		.chained = true,
7470 		.chain_id = ALC283_FIXUP_CHROME_BOOK,
7471 	},
7472 	[ALC282_FIXUP_ASUS_TX300] = {
7473 		.type = HDA_FIXUP_FUNC,
7474 		.v.func = alc282_fixup_asus_tx300,
7475 	},
7476 	[ALC283_FIXUP_INT_MIC] = {
7477 		.type = HDA_FIXUP_VERBS,
7478 		.v.verbs = (const struct hda_verb[]) {
7479 			{0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
7480 			{0x20, AC_VERB_SET_PROC_COEF, 0x0011},
7481 			{ }
7482 		},
7483 		.chained = true,
7484 		.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7485 	},
7486 	[ALC290_FIXUP_SUBWOOFER_HSJACK] = {
7487 		.type = HDA_FIXUP_PINS,
7488 		.v.pins = (const struct hda_pintbl[]) {
7489 			{ 0x17, 0x90170112 }, /* subwoofer */
7490 			{ }
7491 		},
7492 		.chained = true,
7493 		.chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
7494 	},
7495 	[ALC290_FIXUP_SUBWOOFER] = {
7496 		.type = HDA_FIXUP_PINS,
7497 		.v.pins = (const struct hda_pintbl[]) {
7498 			{ 0x17, 0x90170112 }, /* subwoofer */
7499 			{ }
7500 		},
7501 		.chained = true,
7502 		.chain_id = ALC290_FIXUP_MONO_SPEAKERS,
7503 	},
7504 	[ALC290_FIXUP_MONO_SPEAKERS] = {
7505 		.type = HDA_FIXUP_FUNC,
7506 		.v.func = alc290_fixup_mono_speakers,
7507 	},
7508 	[ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
7509 		.type = HDA_FIXUP_FUNC,
7510 		.v.func = alc290_fixup_mono_speakers,
7511 		.chained = true,
7512 		.chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
7513 	},
7514 	[ALC269_FIXUP_THINKPAD_ACPI] = {
7515 		.type = HDA_FIXUP_FUNC,
7516 		.v.func = alc_fixup_thinkpad_acpi,
7517 		.chained = true,
7518 		.chain_id = ALC269_FIXUP_SKU_IGNORE,
7519 	},
7520 	[ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
7521 		.type = HDA_FIXUP_FUNC,
7522 		.v.func = alc_fixup_inv_dmic,
7523 		.chained = true,
7524 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7525 	},
7526 	[ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
7527 		.type = HDA_FIXUP_PINS,
7528 		.v.pins = (const struct hda_pintbl[]) {
7529 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7530 			{ }
7531 		},
7532 		.chained = true,
7533 		.chain_id = ALC255_FIXUP_HEADSET_MODE
7534 	},
7535 	[ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7536 		.type = HDA_FIXUP_PINS,
7537 		.v.pins = (const struct hda_pintbl[]) {
7538 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7539 			{ }
7540 		},
7541 		.chained = true,
7542 		.chain_id = ALC255_FIXUP_HEADSET_MODE
7543 	},
7544 	[ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7545 		.type = HDA_FIXUP_PINS,
7546 		.v.pins = (const struct hda_pintbl[]) {
7547 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7548 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7549 			{ }
7550 		},
7551 		.chained = true,
7552 		.chain_id = ALC255_FIXUP_HEADSET_MODE
7553 	},
7554 	[ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7555 		.type = HDA_FIXUP_PINS,
7556 		.v.pins = (const struct hda_pintbl[]) {
7557 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7558 			{ }
7559 		},
7560 		.chained = true,
7561 		.chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7562 	},
7563 	[ALC255_FIXUP_HEADSET_MODE] = {
7564 		.type = HDA_FIXUP_FUNC,
7565 		.v.func = alc_fixup_headset_mode_alc255,
7566 		.chained = true,
7567 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7568 	},
7569 	[ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7570 		.type = HDA_FIXUP_FUNC,
7571 		.v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
7572 	},
7573 	[ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7574 		.type = HDA_FIXUP_PINS,
7575 		.v.pins = (const struct hda_pintbl[]) {
7576 			{ 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7577 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7578 			{ }
7579 		},
7580 		.chained = true,
7581 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7582 	},
7583 	[ALC292_FIXUP_TPT440_DOCK] = {
7584 		.type = HDA_FIXUP_FUNC,
7585 		.v.func = alc_fixup_tpt440_dock,
7586 		.chained = true,
7587 		.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7588 	},
7589 	[ALC292_FIXUP_TPT440] = {
7590 		.type = HDA_FIXUP_FUNC,
7591 		.v.func = alc_fixup_disable_aamix,
7592 		.chained = true,
7593 		.chain_id = ALC292_FIXUP_TPT440_DOCK,
7594 	},
7595 	[ALC283_FIXUP_HEADSET_MIC] = {
7596 		.type = HDA_FIXUP_PINS,
7597 		.v.pins = (const struct hda_pintbl[]) {
7598 			{ 0x19, 0x04a110f0 },
7599 			{ },
7600 		},
7601 	},
7602 	[ALC255_FIXUP_MIC_MUTE_LED] = {
7603 		.type = HDA_FIXUP_FUNC,
7604 		.v.func = alc_fixup_micmute_led,
7605 	},
7606 	[ALC282_FIXUP_ASPIRE_V5_PINS] = {
7607 		.type = HDA_FIXUP_PINS,
7608 		.v.pins = (const struct hda_pintbl[]) {
7609 			{ 0x12, 0x90a60130 },
7610 			{ 0x14, 0x90170110 },
7611 			{ 0x17, 0x40000008 },
7612 			{ 0x18, 0x411111f0 },
7613 			{ 0x19, 0x01a1913c },
7614 			{ 0x1a, 0x411111f0 },
7615 			{ 0x1b, 0x411111f0 },
7616 			{ 0x1d, 0x40f89b2d },
7617 			{ 0x1e, 0x411111f0 },
7618 			{ 0x21, 0x0321101f },
7619 			{ },
7620 		},
7621 	},
7622 	[ALC269VB_FIXUP_ASPIRE_E1_COEF] = {
7623 		.type = HDA_FIXUP_FUNC,
7624 		.v.func = alc269vb_fixup_aspire_e1_coef,
7625 	},
7626 	[ALC280_FIXUP_HP_GPIO4] = {
7627 		.type = HDA_FIXUP_FUNC,
7628 		.v.func = alc280_fixup_hp_gpio4,
7629 	},
7630 	[ALC286_FIXUP_HP_GPIO_LED] = {
7631 		.type = HDA_FIXUP_FUNC,
7632 		.v.func = alc286_fixup_hp_gpio_led,
7633 	},
7634 	[ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
7635 		.type = HDA_FIXUP_FUNC,
7636 		.v.func = alc280_fixup_hp_gpio2_mic_hotkey,
7637 	},
7638 	[ALC280_FIXUP_HP_DOCK_PINS] = {
7639 		.type = HDA_FIXUP_PINS,
7640 		.v.pins = (const struct hda_pintbl[]) {
7641 			{ 0x1b, 0x21011020 }, /* line-out */
7642 			{ 0x1a, 0x01a1903c }, /* headset mic */
7643 			{ 0x18, 0x2181103f }, /* line-in */
7644 			{ },
7645 		},
7646 		.chained = true,
7647 		.chain_id = ALC280_FIXUP_HP_GPIO4
7648 	},
7649 	[ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
7650 		.type = HDA_FIXUP_PINS,
7651 		.v.pins = (const struct hda_pintbl[]) {
7652 			{ 0x1b, 0x21011020 }, /* line-out */
7653 			{ 0x18, 0x2181103f }, /* line-in */
7654 			{ },
7655 		},
7656 		.chained = true,
7657 		.chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
7658 	},
7659 	[ALC280_FIXUP_HP_9480M] = {
7660 		.type = HDA_FIXUP_FUNC,
7661 		.v.func = alc280_fixup_hp_9480m,
7662 	},
7663 	[ALC245_FIXUP_HP_X360_AMP] = {
7664 		.type = HDA_FIXUP_FUNC,
7665 		.v.func = alc245_fixup_hp_x360_amp,
7666 		.chained = true,
7667 		.chain_id = ALC245_FIXUP_HP_GPIO_LED
7668 	},
7669 	[ALC288_FIXUP_DELL_HEADSET_MODE] = {
7670 		.type = HDA_FIXUP_FUNC,
7671 		.v.func = alc_fixup_headset_mode_dell_alc288,
7672 		.chained = true,
7673 		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
7674 	},
7675 	[ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7676 		.type = HDA_FIXUP_PINS,
7677 		.v.pins = (const struct hda_pintbl[]) {
7678 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7679 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7680 			{ }
7681 		},
7682 		.chained = true,
7683 		.chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
7684 	},
7685 	[ALC288_FIXUP_DISABLE_AAMIX] = {
7686 		.type = HDA_FIXUP_FUNC,
7687 		.v.func = alc_fixup_disable_aamix,
7688 		.chained = true,
7689 		.chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
7690 	},
7691 	[ALC288_FIXUP_DELL_XPS_13] = {
7692 		.type = HDA_FIXUP_FUNC,
7693 		.v.func = alc_fixup_dell_xps13,
7694 		.chained = true,
7695 		.chain_id = ALC288_FIXUP_DISABLE_AAMIX
7696 	},
7697 	[ALC292_FIXUP_DISABLE_AAMIX] = {
7698 		.type = HDA_FIXUP_FUNC,
7699 		.v.func = alc_fixup_disable_aamix,
7700 		.chained = true,
7701 		.chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
7702 	},
7703 	[ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
7704 		.type = HDA_FIXUP_FUNC,
7705 		.v.func = alc_fixup_disable_aamix,
7706 		.chained = true,
7707 		.chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
7708 	},
7709 	[ALC292_FIXUP_DELL_E7X_AAMIX] = {
7710 		.type = HDA_FIXUP_FUNC,
7711 		.v.func = alc_fixup_dell_xps13,
7712 		.chained = true,
7713 		.chain_id = ALC292_FIXUP_DISABLE_AAMIX
7714 	},
7715 	[ALC292_FIXUP_DELL_E7X] = {
7716 		.type = HDA_FIXUP_FUNC,
7717 		.v.func = alc_fixup_micmute_led,
7718 		/* micmute fixup must be applied at last */
7719 		.chained_before = true,
7720 		.chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
7721 	},
7722 	[ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = {
7723 		.type = HDA_FIXUP_PINS,
7724 		.v.pins = (const struct hda_pintbl[]) {
7725 			{ 0x18, 0x01a1913c }, /* headset mic w/o jack detect */
7726 			{ }
7727 		},
7728 		.chained_before = true,
7729 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
7730 	},
7731 	[ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7732 		.type = HDA_FIXUP_PINS,
7733 		.v.pins = (const struct hda_pintbl[]) {
7734 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7735 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7736 			{ }
7737 		},
7738 		.chained = true,
7739 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7740 	},
7741 	[ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
7742 		.type = HDA_FIXUP_PINS,
7743 		.v.pins = (const struct hda_pintbl[]) {
7744 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7745 			{ }
7746 		},
7747 		.chained = true,
7748 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7749 	},
7750 	[ALC275_FIXUP_DELL_XPS] = {
7751 		.type = HDA_FIXUP_VERBS,
7752 		.v.verbs = (const struct hda_verb[]) {
7753 			/* Enables internal speaker */
7754 			{0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
7755 			{0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
7756 			{0x20, AC_VERB_SET_COEF_INDEX, 0x30},
7757 			{0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
7758 			{}
7759 		}
7760 	},
7761 	[ALC293_FIXUP_LENOVO_SPK_NOISE] = {
7762 		.type = HDA_FIXUP_FUNC,
7763 		.v.func = alc_fixup_disable_aamix,
7764 		.chained = true,
7765 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
7766 	},
7767 	[ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
7768 		.type = HDA_FIXUP_FUNC,
7769 		.v.func = alc233_fixup_lenovo_line2_mic_hotkey,
7770 	},
7771 	[ALC233_FIXUP_INTEL_NUC8_DMIC] = {
7772 		.type = HDA_FIXUP_FUNC,
7773 		.v.func = alc_fixup_inv_dmic,
7774 		.chained = true,
7775 		.chain_id = ALC233_FIXUP_INTEL_NUC8_BOOST,
7776 	},
7777 	[ALC233_FIXUP_INTEL_NUC8_BOOST] = {
7778 		.type = HDA_FIXUP_FUNC,
7779 		.v.func = alc269_fixup_limit_int_mic_boost
7780 	},
7781 	[ALC255_FIXUP_DELL_SPK_NOISE] = {
7782 		.type = HDA_FIXUP_FUNC,
7783 		.v.func = alc_fixup_disable_aamix,
7784 		.chained = true,
7785 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7786 	},
7787 	[ALC225_FIXUP_DISABLE_MIC_VREF] = {
7788 		.type = HDA_FIXUP_FUNC,
7789 		.v.func = alc_fixup_disable_mic_vref,
7790 		.chained = true,
7791 		.chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7792 	},
7793 	[ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7794 		.type = HDA_FIXUP_VERBS,
7795 		.v.verbs = (const struct hda_verb[]) {
7796 			/* Disable pass-through path for FRONT 14h */
7797 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7798 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7799 			{}
7800 		},
7801 		.chained = true,
7802 		.chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
7803 	},
7804 	[ALC280_FIXUP_HP_HEADSET_MIC] = {
7805 		.type = HDA_FIXUP_FUNC,
7806 		.v.func = alc_fixup_disable_aamix,
7807 		.chained = true,
7808 		.chain_id = ALC269_FIXUP_HEADSET_MIC,
7809 	},
7810 	[ALC221_FIXUP_HP_FRONT_MIC] = {
7811 		.type = HDA_FIXUP_PINS,
7812 		.v.pins = (const struct hda_pintbl[]) {
7813 			{ 0x19, 0x02a19020 }, /* Front Mic */
7814 			{ }
7815 		},
7816 	},
7817 	[ALC292_FIXUP_TPT460] = {
7818 		.type = HDA_FIXUP_FUNC,
7819 		.v.func = alc_fixup_tpt440_dock,
7820 		.chained = true,
7821 		.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
7822 	},
7823 	[ALC298_FIXUP_SPK_VOLUME] = {
7824 		.type = HDA_FIXUP_FUNC,
7825 		.v.func = alc298_fixup_speaker_volume,
7826 		.chained = true,
7827 		.chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
7828 	},
7829 	[ALC298_FIXUP_LENOVO_SPK_VOLUME] = {
7830 		.type = HDA_FIXUP_FUNC,
7831 		.v.func = alc298_fixup_speaker_volume,
7832 	},
7833 	[ALC295_FIXUP_DISABLE_DAC3] = {
7834 		.type = HDA_FIXUP_FUNC,
7835 		.v.func = alc295_fixup_disable_dac3,
7836 	},
7837 	[ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
7838 		.type = HDA_FIXUP_FUNC,
7839 		.v.func = alc285_fixup_speaker2_to_dac1,
7840 		.chained = true,
7841 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
7842 	},
7843 	[ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
7844 		.type = HDA_FIXUP_PINS,
7845 		.v.pins = (const struct hda_pintbl[]) {
7846 			{ 0x1b, 0x90170151 },
7847 			{ }
7848 		},
7849 		.chained = true,
7850 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7851 	},
7852 	[ALC269_FIXUP_ATIV_BOOK_8] = {
7853 		.type = HDA_FIXUP_FUNC,
7854 		.v.func = alc_fixup_auto_mute_via_amp,
7855 		.chained = true,
7856 		.chain_id = ALC269_FIXUP_NO_SHUTUP
7857 	},
7858 	[ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE] = {
7859 		.type = HDA_FIXUP_PINS,
7860 		.v.pins = (const struct hda_pintbl[]) {
7861 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7862 			{ 0x1a, 0x01813030 }, /* use as headphone mic, without its own jack detect */
7863 			{ }
7864 		},
7865 		.chained = true,
7866 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7867 	},
7868 	[ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
7869 		.type = HDA_FIXUP_PINS,
7870 		.v.pins = (const struct hda_pintbl[]) {
7871 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7872 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7873 			{ }
7874 		},
7875 		.chained = true,
7876 		.chain_id = ALC269_FIXUP_HEADSET_MODE
7877 	},
7878 	[ALC256_FIXUP_ASUS_HEADSET_MODE] = {
7879 		.type = HDA_FIXUP_FUNC,
7880 		.v.func = alc_fixup_headset_mode,
7881 	},
7882 	[ALC256_FIXUP_ASUS_MIC] = {
7883 		.type = HDA_FIXUP_PINS,
7884 		.v.pins = (const struct hda_pintbl[]) {
7885 			{ 0x13, 0x90a60160 }, /* use as internal mic */
7886 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7887 			{ }
7888 		},
7889 		.chained = true,
7890 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7891 	},
7892 	[ALC256_FIXUP_ASUS_AIO_GPIO2] = {
7893 		.type = HDA_FIXUP_FUNC,
7894 		/* Set up GPIO2 for the speaker amp */
7895 		.v.func = alc_fixup_gpio4,
7896 	},
7897 	[ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7898 		.type = HDA_FIXUP_PINS,
7899 		.v.pins = (const struct hda_pintbl[]) {
7900 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7901 			{ }
7902 		},
7903 		.chained = true,
7904 		.chain_id = ALC269_FIXUP_HEADSET_MIC
7905 	},
7906 	[ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
7907 		.type = HDA_FIXUP_VERBS,
7908 		.v.verbs = (const struct hda_verb[]) {
7909 			/* Enables internal speaker */
7910 			{0x20, AC_VERB_SET_COEF_INDEX, 0x40},
7911 			{0x20, AC_VERB_SET_PROC_COEF, 0x8800},
7912 			{}
7913 		},
7914 		.chained = true,
7915 		.chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7916 	},
7917 	[ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
7918 		.type = HDA_FIXUP_FUNC,
7919 		.v.func = alc233_alc662_fixup_lenovo_dual_codecs,
7920 		.chained = true,
7921 		.chain_id = ALC269_FIXUP_GPIO2
7922 	},
7923 	[ALC233_FIXUP_ACER_HEADSET_MIC] = {
7924 		.type = HDA_FIXUP_VERBS,
7925 		.v.verbs = (const struct hda_verb[]) {
7926 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
7927 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
7928 			{ }
7929 		},
7930 		.chained = true,
7931 		.chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7932 	},
7933 	[ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
7934 		.type = HDA_FIXUP_PINS,
7935 		.v.pins = (const struct hda_pintbl[]) {
7936 			/* Change the mic location from front to right, otherwise there are
7937 			   two front mics with the same name, pulseaudio can't handle them.
7938 			   This is just a temporary workaround, after applying this fixup,
7939 			   there will be one "Front Mic" and one "Mic" in this machine.
7940 			 */
7941 			{ 0x1a, 0x04a19040 },
7942 			{ }
7943 		},
7944 	},
7945 	[ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
7946 		.type = HDA_FIXUP_PINS,
7947 		.v.pins = (const struct hda_pintbl[]) {
7948 			{ 0x16, 0x0101102f }, /* Rear Headset HP */
7949 			{ 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
7950 			{ 0x1a, 0x01a19030 }, /* Rear Headset MIC */
7951 			{ 0x1b, 0x02011020 },
7952 			{ }
7953 		},
7954 		.chained = true,
7955 		.chain_id = ALC225_FIXUP_S3_POP_NOISE
7956 	},
7957 	[ALC225_FIXUP_S3_POP_NOISE] = {
7958 		.type = HDA_FIXUP_FUNC,
7959 		.v.func = alc225_fixup_s3_pop_noise,
7960 		.chained = true,
7961 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7962 	},
7963 	[ALC700_FIXUP_INTEL_REFERENCE] = {
7964 		.type = HDA_FIXUP_VERBS,
7965 		.v.verbs = (const struct hda_verb[]) {
7966 			/* Enables internal speaker */
7967 			{0x20, AC_VERB_SET_COEF_INDEX, 0x45},
7968 			{0x20, AC_VERB_SET_PROC_COEF, 0x5289},
7969 			{0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
7970 			{0x20, AC_VERB_SET_PROC_COEF, 0x001b},
7971 			{0x58, AC_VERB_SET_COEF_INDEX, 0x00},
7972 			{0x58, AC_VERB_SET_PROC_COEF, 0x3888},
7973 			{0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
7974 			{0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
7975 			{}
7976 		}
7977 	},
7978 	[ALC274_FIXUP_DELL_BIND_DACS] = {
7979 		.type = HDA_FIXUP_FUNC,
7980 		.v.func = alc274_fixup_bind_dacs,
7981 		.chained = true,
7982 		.chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7983 	},
7984 	[ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
7985 		.type = HDA_FIXUP_PINS,
7986 		.v.pins = (const struct hda_pintbl[]) {
7987 			{ 0x1b, 0x0401102f },
7988 			{ }
7989 		},
7990 		.chained = true,
7991 		.chain_id = ALC274_FIXUP_DELL_BIND_DACS
7992 	},
7993 	[ALC298_FIXUP_TPT470_DOCK_FIX] = {
7994 		.type = HDA_FIXUP_FUNC,
7995 		.v.func = alc_fixup_tpt470_dock,
7996 		.chained = true,
7997 		.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
7998 	},
7999 	[ALC298_FIXUP_TPT470_DOCK] = {
8000 		.type = HDA_FIXUP_FUNC,
8001 		.v.func = alc_fixup_tpt470_dacs,
8002 		.chained = true,
8003 		.chain_id = ALC298_FIXUP_TPT470_DOCK_FIX
8004 	},
8005 	[ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
8006 		.type = HDA_FIXUP_PINS,
8007 		.v.pins = (const struct hda_pintbl[]) {
8008 			{ 0x14, 0x0201101f },
8009 			{ }
8010 		},
8011 		.chained = true,
8012 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
8013 	},
8014 	[ALC255_FIXUP_DELL_HEADSET_MIC] = {
8015 		.type = HDA_FIXUP_PINS,
8016 		.v.pins = (const struct hda_pintbl[]) {
8017 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8018 			{ }
8019 		},
8020 		.chained = true,
8021 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8022 	},
8023 	[ALC295_FIXUP_HP_X360] = {
8024 		.type = HDA_FIXUP_FUNC,
8025 		.v.func = alc295_fixup_hp_top_speakers,
8026 		.chained = true,
8027 		.chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
8028 	},
8029 	[ALC221_FIXUP_HP_HEADSET_MIC] = {
8030 		.type = HDA_FIXUP_PINS,
8031 		.v.pins = (const struct hda_pintbl[]) {
8032 			{ 0x19, 0x0181313f},
8033 			{ }
8034 		},
8035 		.chained = true,
8036 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8037 	},
8038 	[ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
8039 		.type = HDA_FIXUP_FUNC,
8040 		.v.func = alc285_fixup_invalidate_dacs,
8041 		.chained = true,
8042 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
8043 	},
8044 	[ALC295_FIXUP_HP_AUTO_MUTE] = {
8045 		.type = HDA_FIXUP_FUNC,
8046 		.v.func = alc_fixup_auto_mute_via_amp,
8047 	},
8048 	[ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
8049 		.type = HDA_FIXUP_PINS,
8050 		.v.pins = (const struct hda_pintbl[]) {
8051 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8052 			{ }
8053 		},
8054 		.chained = true,
8055 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8056 	},
8057 	[ALC294_FIXUP_ASUS_MIC] = {
8058 		.type = HDA_FIXUP_PINS,
8059 		.v.pins = (const struct hda_pintbl[]) {
8060 			{ 0x13, 0x90a60160 }, /* use as internal mic */
8061 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
8062 			{ }
8063 		},
8064 		.chained = true,
8065 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8066 	},
8067 	[ALC294_FIXUP_ASUS_HEADSET_MIC] = {
8068 		.type = HDA_FIXUP_PINS,
8069 		.v.pins = (const struct hda_pintbl[]) {
8070 			{ 0x19, 0x01a1103c }, /* use as headset mic */
8071 			{ }
8072 		},
8073 		.chained = true,
8074 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8075 	},
8076 	[ALC294_FIXUP_ASUS_SPK] = {
8077 		.type = HDA_FIXUP_VERBS,
8078 		.v.verbs = (const struct hda_verb[]) {
8079 			/* Set EAPD high */
8080 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
8081 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
8082 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8083 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
8084 			{ }
8085 		},
8086 		.chained = true,
8087 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8088 	},
8089 	[ALC295_FIXUP_CHROME_BOOK] = {
8090 		.type = HDA_FIXUP_FUNC,
8091 		.v.func = alc295_fixup_chromebook,
8092 		.chained = true,
8093 		.chain_id = ALC225_FIXUP_HEADSET_JACK
8094 	},
8095 	[ALC225_FIXUP_HEADSET_JACK] = {
8096 		.type = HDA_FIXUP_FUNC,
8097 		.v.func = alc_fixup_headset_jack,
8098 	},
8099 	[ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
8100 		.type = HDA_FIXUP_PINS,
8101 		.v.pins = (const struct hda_pintbl[]) {
8102 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8103 			{ }
8104 		},
8105 		.chained = true,
8106 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8107 	},
8108 	[ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
8109 		.type = HDA_FIXUP_VERBS,
8110 		.v.verbs = (const struct hda_verb[]) {
8111 			/* Disable PCBEEP-IN passthrough */
8112 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
8113 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
8114 			{ }
8115 		},
8116 		.chained = true,
8117 		.chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
8118 	},
8119 	[ALC255_FIXUP_ACER_HEADSET_MIC] = {
8120 		.type = HDA_FIXUP_PINS,
8121 		.v.pins = (const struct hda_pintbl[]) {
8122 			{ 0x19, 0x03a11130 },
8123 			{ 0x1a, 0x90a60140 }, /* use as internal mic */
8124 			{ }
8125 		},
8126 		.chained = true,
8127 		.chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
8128 	},
8129 	[ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
8130 		.type = HDA_FIXUP_PINS,
8131 		.v.pins = (const struct hda_pintbl[]) {
8132 			{ 0x16, 0x01011020 }, /* Rear Line out */
8133 			{ 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
8134 			{ }
8135 		},
8136 		.chained = true,
8137 		.chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
8138 	},
8139 	[ALC225_FIXUP_WYSE_AUTO_MUTE] = {
8140 		.type = HDA_FIXUP_FUNC,
8141 		.v.func = alc_fixup_auto_mute_via_amp,
8142 		.chained = true,
8143 		.chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
8144 	},
8145 	[ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
8146 		.type = HDA_FIXUP_FUNC,
8147 		.v.func = alc_fixup_disable_mic_vref,
8148 		.chained = true,
8149 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8150 	},
8151 	[ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
8152 		.type = HDA_FIXUP_VERBS,
8153 		.v.verbs = (const struct hda_verb[]) {
8154 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
8155 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
8156 			{ }
8157 		},
8158 		.chained = true,
8159 		.chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
8160 	},
8161 	[ALC256_FIXUP_ASUS_HEADSET_MIC] = {
8162 		.type = HDA_FIXUP_PINS,
8163 		.v.pins = (const struct hda_pintbl[]) {
8164 			{ 0x19, 0x03a11020 }, /* headset mic with jack detect */
8165 			{ }
8166 		},
8167 		.chained = true,
8168 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8169 	},
8170 	[ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8171 		.type = HDA_FIXUP_PINS,
8172 		.v.pins = (const struct hda_pintbl[]) {
8173 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
8174 			{ }
8175 		},
8176 		.chained = true,
8177 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8178 	},
8179 	[ALC299_FIXUP_PREDATOR_SPK] = {
8180 		.type = HDA_FIXUP_PINS,
8181 		.v.pins = (const struct hda_pintbl[]) {
8182 			{ 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
8183 			{ }
8184 		}
8185 	},
8186 	[ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
8187 		.type = HDA_FIXUP_PINS,
8188 		.v.pins = (const struct hda_pintbl[]) {
8189 			{ 0x19, 0x04a11040 },
8190 			{ 0x21, 0x04211020 },
8191 			{ }
8192 		},
8193 		.chained = true,
8194 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8195 	},
8196 	[ALC289_FIXUP_DELL_SPK2] = {
8197 		.type = HDA_FIXUP_PINS,
8198 		.v.pins = (const struct hda_pintbl[]) {
8199 			{ 0x17, 0x90170130 }, /* bass spk */
8200 			{ }
8201 		},
8202 		.chained = true,
8203 		.chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
8204 	},
8205 	[ALC289_FIXUP_DUAL_SPK] = {
8206 		.type = HDA_FIXUP_FUNC,
8207 		.v.func = alc285_fixup_speaker2_to_dac1,
8208 		.chained = true,
8209 		.chain_id = ALC289_FIXUP_DELL_SPK2
8210 	},
8211 	[ALC294_FIXUP_SPK2_TO_DAC1] = {
8212 		.type = HDA_FIXUP_FUNC,
8213 		.v.func = alc285_fixup_speaker2_to_dac1,
8214 		.chained = true,
8215 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8216 	},
8217 	[ALC294_FIXUP_ASUS_DUAL_SPK] = {
8218 		.type = HDA_FIXUP_FUNC,
8219 		/* The GPIO must be pulled to initialize the AMP */
8220 		.v.func = alc_fixup_gpio4,
8221 		.chained = true,
8222 		.chain_id = ALC294_FIXUP_SPK2_TO_DAC1
8223 	},
8224 	[ALC285_FIXUP_THINKPAD_X1_GEN7] = {
8225 		.type = HDA_FIXUP_FUNC,
8226 		.v.func = alc285_fixup_thinkpad_x1_gen7,
8227 		.chained = true,
8228 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
8229 	},
8230 	[ALC285_FIXUP_THINKPAD_HEADSET_JACK] = {
8231 		.type = HDA_FIXUP_FUNC,
8232 		.v.func = alc_fixup_headset_jack,
8233 		.chained = true,
8234 		.chain_id = ALC285_FIXUP_THINKPAD_X1_GEN7
8235 	},
8236 	[ALC294_FIXUP_ASUS_HPE] = {
8237 		.type = HDA_FIXUP_VERBS,
8238 		.v.verbs = (const struct hda_verb[]) {
8239 			/* Set EAPD high */
8240 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8241 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
8242 			{ }
8243 		},
8244 		.chained = true,
8245 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8246 	},
8247 	[ALC294_FIXUP_ASUS_GX502_PINS] = {
8248 		.type = HDA_FIXUP_PINS,
8249 		.v.pins = (const struct hda_pintbl[]) {
8250 			{ 0x19, 0x03a11050 }, /* front HP mic */
8251 			{ 0x1a, 0x01a11830 }, /* rear external mic */
8252 			{ 0x21, 0x03211020 }, /* front HP out */
8253 			{ }
8254 		},
8255 		.chained = true,
8256 		.chain_id = ALC294_FIXUP_ASUS_GX502_VERBS
8257 	},
8258 	[ALC294_FIXUP_ASUS_GX502_VERBS] = {
8259 		.type = HDA_FIXUP_VERBS,
8260 		.v.verbs = (const struct hda_verb[]) {
8261 			/* set 0x15 to HP-OUT ctrl */
8262 			{ 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8263 			/* unmute the 0x15 amp */
8264 			{ 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
8265 			{ }
8266 		},
8267 		.chained = true,
8268 		.chain_id = ALC294_FIXUP_ASUS_GX502_HP
8269 	},
8270 	[ALC294_FIXUP_ASUS_GX502_HP] = {
8271 		.type = HDA_FIXUP_FUNC,
8272 		.v.func = alc294_fixup_gx502_hp,
8273 	},
8274 	[ALC294_FIXUP_ASUS_GU502_PINS] = {
8275 		.type = HDA_FIXUP_PINS,
8276 		.v.pins = (const struct hda_pintbl[]) {
8277 			{ 0x19, 0x01a11050 }, /* rear HP mic */
8278 			{ 0x1a, 0x01a11830 }, /* rear external mic */
8279 			{ 0x21, 0x012110f0 }, /* rear HP out */
8280 			{ }
8281 		},
8282 		.chained = true,
8283 		.chain_id = ALC294_FIXUP_ASUS_GU502_VERBS
8284 	},
8285 	[ALC294_FIXUP_ASUS_GU502_VERBS] = {
8286 		.type = HDA_FIXUP_VERBS,
8287 		.v.verbs = (const struct hda_verb[]) {
8288 			/* set 0x15 to HP-OUT ctrl */
8289 			{ 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8290 			/* unmute the 0x15 amp */
8291 			{ 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
8292 			/* set 0x1b to HP-OUT */
8293 			{ 0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8294 			{ }
8295 		},
8296 		.chained = true,
8297 		.chain_id = ALC294_FIXUP_ASUS_GU502_HP
8298 	},
8299 	[ALC294_FIXUP_ASUS_GU502_HP] = {
8300 		.type = HDA_FIXUP_FUNC,
8301 		.v.func = alc294_fixup_gu502_hp,
8302 	},
8303 	 [ALC294_FIXUP_ASUS_G513_PINS] = {
8304 		.type = HDA_FIXUP_PINS,
8305 		.v.pins = (const struct hda_pintbl[]) {
8306 				{ 0x19, 0x03a11050 }, /* front HP mic */
8307 				{ 0x1a, 0x03a11c30 }, /* rear external mic */
8308 				{ 0x21, 0x03211420 }, /* front HP out */
8309 				{ }
8310 		},
8311 	},
8312 	[ALC285_FIXUP_ASUS_G533Z_PINS] = {
8313 		.type = HDA_FIXUP_PINS,
8314 		.v.pins = (const struct hda_pintbl[]) {
8315 			{ 0x14, 0x90170152 }, /* Speaker Surround Playback Switch */
8316 			{ 0x19, 0x03a19020 }, /* Mic Boost Volume */
8317 			{ 0x1a, 0x03a11c30 }, /* Mic Boost Volume */
8318 			{ 0x1e, 0x90170151 }, /* Rear jack, IN OUT EAPD Detect */
8319 			{ 0x21, 0x03211420 },
8320 			{ }
8321 		},
8322 	},
8323 	[ALC294_FIXUP_ASUS_COEF_1B] = {
8324 		.type = HDA_FIXUP_VERBS,
8325 		.v.verbs = (const struct hda_verb[]) {
8326 			/* Set bit 10 to correct noisy output after reboot from
8327 			 * Windows 10 (due to pop noise reduction?)
8328 			 */
8329 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
8330 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
8331 			{ }
8332 		},
8333 		.chained = true,
8334 		.chain_id = ALC289_FIXUP_ASUS_GA401,
8335 	},
8336 	[ALC285_FIXUP_HP_GPIO_LED] = {
8337 		.type = HDA_FIXUP_FUNC,
8338 		.v.func = alc285_fixup_hp_gpio_led,
8339 	},
8340 	[ALC285_FIXUP_HP_MUTE_LED] = {
8341 		.type = HDA_FIXUP_FUNC,
8342 		.v.func = alc285_fixup_hp_mute_led,
8343 	},
8344 	[ALC285_FIXUP_HP_SPECTRE_X360_MUTE_LED] = {
8345 		.type = HDA_FIXUP_FUNC,
8346 		.v.func = alc285_fixup_hp_spectre_x360_mute_led,
8347 	},
8348 	[ALC236_FIXUP_HP_MUTE_LED_COEFBIT2] = {
8349 	    .type = HDA_FIXUP_FUNC,
8350 	    .v.func = alc236_fixup_hp_mute_led_coefbit2,
8351 	},
8352 	[ALC236_FIXUP_HP_GPIO_LED] = {
8353 		.type = HDA_FIXUP_FUNC,
8354 		.v.func = alc236_fixup_hp_gpio_led,
8355 	},
8356 	[ALC236_FIXUP_HP_MUTE_LED] = {
8357 		.type = HDA_FIXUP_FUNC,
8358 		.v.func = alc236_fixup_hp_mute_led,
8359 	},
8360 	[ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF] = {
8361 		.type = HDA_FIXUP_FUNC,
8362 		.v.func = alc236_fixup_hp_mute_led_micmute_vref,
8363 	},
8364 	[ALC298_FIXUP_SAMSUNG_AMP] = {
8365 		.type = HDA_FIXUP_FUNC,
8366 		.v.func = alc298_fixup_samsung_amp,
8367 		.chained = true,
8368 		.chain_id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET
8369 	},
8370 	[ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
8371 		.type = HDA_FIXUP_VERBS,
8372 		.v.verbs = (const struct hda_verb[]) {
8373 			{ 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
8374 			{ }
8375 		},
8376 	},
8377 	[ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
8378 		.type = HDA_FIXUP_VERBS,
8379 		.v.verbs = (const struct hda_verb[]) {
8380 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x08},
8381 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf},
8382 			{ }
8383 		},
8384 	},
8385 	[ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8386 		.type = HDA_FIXUP_PINS,
8387 		.v.pins = (const struct hda_pintbl[]) {
8388 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8389 			{ }
8390 		},
8391 		.chained = true,
8392 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8393 	},
8394 	[ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS] = {
8395 		.type = HDA_FIXUP_PINS,
8396 		.v.pins = (const struct hda_pintbl[]) {
8397 			{ 0x14, 0x90100120 }, /* use as internal speaker */
8398 			{ 0x18, 0x02a111f0 }, /* use as headset mic, without its own jack detect */
8399 			{ 0x1a, 0x01011020 }, /* use as line out */
8400 			{ },
8401 		},
8402 		.chained = true,
8403 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8404 	},
8405 	[ALC269VC_FIXUP_ACER_HEADSET_MIC] = {
8406 		.type = HDA_FIXUP_PINS,
8407 		.v.pins = (const struct hda_pintbl[]) {
8408 			{ 0x18, 0x02a11030 }, /* use as headset mic */
8409 			{ }
8410 		},
8411 		.chained = true,
8412 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8413 	},
8414 	[ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE] = {
8415 		.type = HDA_FIXUP_PINS,
8416 		.v.pins = (const struct hda_pintbl[]) {
8417 			{ 0x18, 0x01a11130 }, /* use as headset mic, without its own jack detect */
8418 			{ }
8419 		},
8420 		.chained = true,
8421 		.chain_id = ALC269_FIXUP_HEADSET_MIC
8422 	},
8423 	[ALC289_FIXUP_ASUS_GA401] = {
8424 		.type = HDA_FIXUP_FUNC,
8425 		.v.func = alc289_fixup_asus_ga401,
8426 		.chained = true,
8427 		.chain_id = ALC289_FIXUP_ASUS_GA502,
8428 	},
8429 	[ALC289_FIXUP_ASUS_GA502] = {
8430 		.type = HDA_FIXUP_PINS,
8431 		.v.pins = (const struct hda_pintbl[]) {
8432 			{ 0x19, 0x03a11020 }, /* headset mic with jack detect */
8433 			{ }
8434 		},
8435 	},
8436 	[ALC256_FIXUP_ACER_MIC_NO_PRESENCE] = {
8437 		.type = HDA_FIXUP_PINS,
8438 		.v.pins = (const struct hda_pintbl[]) {
8439 			{ 0x19, 0x02a11120 }, /* use as headset mic, without its own jack detect */
8440 			{ }
8441 		},
8442 		.chained = true,
8443 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8444 	},
8445 	[ALC285_FIXUP_HP_GPIO_AMP_INIT] = {
8446 		.type = HDA_FIXUP_FUNC,
8447 		.v.func = alc285_fixup_hp_gpio_amp_init,
8448 		.chained = true,
8449 		.chain_id = ALC285_FIXUP_HP_GPIO_LED
8450 	},
8451 	[ALC269_FIXUP_CZC_B20] = {
8452 		.type = HDA_FIXUP_PINS,
8453 		.v.pins = (const struct hda_pintbl[]) {
8454 			{ 0x12, 0x411111f0 },
8455 			{ 0x14, 0x90170110 }, /* speaker */
8456 			{ 0x15, 0x032f1020 }, /* HP out */
8457 			{ 0x17, 0x411111f0 },
8458 			{ 0x18, 0x03ab1040 }, /* mic */
8459 			{ 0x19, 0xb7a7013f },
8460 			{ 0x1a, 0x0181305f },
8461 			{ 0x1b, 0x411111f0 },
8462 			{ 0x1d, 0x411111f0 },
8463 			{ 0x1e, 0x411111f0 },
8464 			{ }
8465 		},
8466 		.chain_id = ALC269_FIXUP_DMIC,
8467 	},
8468 	[ALC269_FIXUP_CZC_TMI] = {
8469 		.type = HDA_FIXUP_PINS,
8470 		.v.pins = (const struct hda_pintbl[]) {
8471 			{ 0x12, 0x4000c000 },
8472 			{ 0x14, 0x90170110 }, /* speaker */
8473 			{ 0x15, 0x0421401f }, /* HP out */
8474 			{ 0x17, 0x411111f0 },
8475 			{ 0x18, 0x04a19020 }, /* mic */
8476 			{ 0x19, 0x411111f0 },
8477 			{ 0x1a, 0x411111f0 },
8478 			{ 0x1b, 0x411111f0 },
8479 			{ 0x1d, 0x40448505 },
8480 			{ 0x1e, 0x411111f0 },
8481 			{ 0x20, 0x8000ffff },
8482 			{ }
8483 		},
8484 		.chain_id = ALC269_FIXUP_DMIC,
8485 	},
8486 	[ALC269_FIXUP_CZC_L101] = {
8487 		.type = HDA_FIXUP_PINS,
8488 		.v.pins = (const struct hda_pintbl[]) {
8489 			{ 0x12, 0x40000000 },
8490 			{ 0x14, 0x01014010 }, /* speaker */
8491 			{ 0x15, 0x411111f0 }, /* HP out */
8492 			{ 0x16, 0x411111f0 },
8493 			{ 0x18, 0x01a19020 }, /* mic */
8494 			{ 0x19, 0x02a19021 },
8495 			{ 0x1a, 0x0181302f },
8496 			{ 0x1b, 0x0221401f },
8497 			{ 0x1c, 0x411111f0 },
8498 			{ 0x1d, 0x4044c601 },
8499 			{ 0x1e, 0x411111f0 },
8500 			{ }
8501 		},
8502 		.chain_id = ALC269_FIXUP_DMIC,
8503 	},
8504 	[ALC269_FIXUP_LEMOTE_A1802] = {
8505 		.type = HDA_FIXUP_PINS,
8506 		.v.pins = (const struct hda_pintbl[]) {
8507 			{ 0x12, 0x40000000 },
8508 			{ 0x14, 0x90170110 }, /* speaker */
8509 			{ 0x17, 0x411111f0 },
8510 			{ 0x18, 0x03a19040 }, /* mic1 */
8511 			{ 0x19, 0x90a70130 }, /* mic2 */
8512 			{ 0x1a, 0x411111f0 },
8513 			{ 0x1b, 0x411111f0 },
8514 			{ 0x1d, 0x40489d2d },
8515 			{ 0x1e, 0x411111f0 },
8516 			{ 0x20, 0x0003ffff },
8517 			{ 0x21, 0x03214020 },
8518 			{ }
8519 		},
8520 		.chain_id = ALC269_FIXUP_DMIC,
8521 	},
8522 	[ALC269_FIXUP_LEMOTE_A190X] = {
8523 		.type = HDA_FIXUP_PINS,
8524 		.v.pins = (const struct hda_pintbl[]) {
8525 			{ 0x14, 0x99130110 }, /* speaker */
8526 			{ 0x15, 0x0121401f }, /* HP out */
8527 			{ 0x18, 0x01a19c20 }, /* rear  mic */
8528 			{ 0x19, 0x99a3092f }, /* front mic */
8529 			{ 0x1b, 0x0201401f }, /* front lineout */
8530 			{ }
8531 		},
8532 		.chain_id = ALC269_FIXUP_DMIC,
8533 	},
8534 	[ALC256_FIXUP_INTEL_NUC8_RUGGED] = {
8535 		.type = HDA_FIXUP_PINS,
8536 		.v.pins = (const struct hda_pintbl[]) {
8537 			{ 0x1b, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8538 			{ }
8539 		},
8540 		.chained = true,
8541 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8542 	},
8543 	[ALC256_FIXUP_INTEL_NUC10] = {
8544 		.type = HDA_FIXUP_PINS,
8545 		.v.pins = (const struct hda_pintbl[]) {
8546 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8547 			{ }
8548 		},
8549 		.chained = true,
8550 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8551 	},
8552 	[ALC255_FIXUP_XIAOMI_HEADSET_MIC] = {
8553 		.type = HDA_FIXUP_VERBS,
8554 		.v.verbs = (const struct hda_verb[]) {
8555 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8556 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8557 			{ }
8558 		},
8559 		.chained = true,
8560 		.chain_id = ALC289_FIXUP_ASUS_GA502
8561 	},
8562 	[ALC274_FIXUP_HP_MIC] = {
8563 		.type = HDA_FIXUP_VERBS,
8564 		.v.verbs = (const struct hda_verb[]) {
8565 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8566 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8567 			{ }
8568 		},
8569 	},
8570 	[ALC274_FIXUP_HP_HEADSET_MIC] = {
8571 		.type = HDA_FIXUP_FUNC,
8572 		.v.func = alc274_fixup_hp_headset_mic,
8573 		.chained = true,
8574 		.chain_id = ALC274_FIXUP_HP_MIC
8575 	},
8576 	[ALC274_FIXUP_HP_ENVY_GPIO] = {
8577 		.type = HDA_FIXUP_FUNC,
8578 		.v.func = alc274_fixup_hp_envy_gpio,
8579 	},
8580 	[ALC256_FIXUP_ASUS_HPE] = {
8581 		.type = HDA_FIXUP_VERBS,
8582 		.v.verbs = (const struct hda_verb[]) {
8583 			/* Set EAPD high */
8584 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8585 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x7778 },
8586 			{ }
8587 		},
8588 		.chained = true,
8589 		.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8590 	},
8591 	[ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK] = {
8592 		.type = HDA_FIXUP_FUNC,
8593 		.v.func = alc_fixup_headset_jack,
8594 		.chained = true,
8595 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
8596 	},
8597 	[ALC287_FIXUP_HP_GPIO_LED] = {
8598 		.type = HDA_FIXUP_FUNC,
8599 		.v.func = alc287_fixup_hp_gpio_led,
8600 	},
8601 	[ALC256_FIXUP_HP_HEADSET_MIC] = {
8602 		.type = HDA_FIXUP_FUNC,
8603 		.v.func = alc274_fixup_hp_headset_mic,
8604 	},
8605 	[ALC236_FIXUP_DELL_AIO_HEADSET_MIC] = {
8606 		.type = HDA_FIXUP_FUNC,
8607 		.v.func = alc_fixup_no_int_mic,
8608 		.chained = true,
8609 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
8610 	},
8611 	[ALC282_FIXUP_ACER_DISABLE_LINEOUT] = {
8612 		.type = HDA_FIXUP_PINS,
8613 		.v.pins = (const struct hda_pintbl[]) {
8614 			{ 0x1b, 0x411111f0 },
8615 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8616 			{ },
8617 		},
8618 		.chained = true,
8619 		.chain_id = ALC269_FIXUP_HEADSET_MODE
8620 	},
8621 	[ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST] = {
8622 		.type = HDA_FIXUP_FUNC,
8623 		.v.func = alc269_fixup_limit_int_mic_boost,
8624 		.chained = true,
8625 		.chain_id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
8626 	},
8627 	[ALC256_FIXUP_ACER_HEADSET_MIC] = {
8628 		.type = HDA_FIXUP_PINS,
8629 		.v.pins = (const struct hda_pintbl[]) {
8630 			{ 0x19, 0x02a1113c }, /* use as headset mic, without its own jack detect */
8631 			{ 0x1a, 0x90a1092f }, /* use as internal mic */
8632 			{ }
8633 		},
8634 		.chained = true,
8635 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8636 	},
8637 	[ALC285_FIXUP_IDEAPAD_S740_COEF] = {
8638 		.type = HDA_FIXUP_FUNC,
8639 		.v.func = alc285_fixup_ideapad_s740_coef,
8640 		.chained = true,
8641 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8642 	},
8643 	[ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8644 		.type = HDA_FIXUP_FUNC,
8645 		.v.func = alc269_fixup_limit_int_mic_boost,
8646 		.chained = true,
8647 		.chain_id = ALC285_FIXUP_HP_MUTE_LED,
8648 	},
8649 	[ALC295_FIXUP_ASUS_DACS] = {
8650 		.type = HDA_FIXUP_FUNC,
8651 		.v.func = alc295_fixup_asus_dacs,
8652 	},
8653 	[ALC295_FIXUP_HP_OMEN] = {
8654 		.type = HDA_FIXUP_PINS,
8655 		.v.pins = (const struct hda_pintbl[]) {
8656 			{ 0x12, 0xb7a60130 },
8657 			{ 0x13, 0x40000000 },
8658 			{ 0x14, 0x411111f0 },
8659 			{ 0x16, 0x411111f0 },
8660 			{ 0x17, 0x90170110 },
8661 			{ 0x18, 0x411111f0 },
8662 			{ 0x19, 0x02a11030 },
8663 			{ 0x1a, 0x411111f0 },
8664 			{ 0x1b, 0x04a19030 },
8665 			{ 0x1d, 0x40600001 },
8666 			{ 0x1e, 0x411111f0 },
8667 			{ 0x21, 0x03211020 },
8668 			{}
8669 		},
8670 		.chained = true,
8671 		.chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
8672 	},
8673 	[ALC285_FIXUP_HP_SPECTRE_X360] = {
8674 		.type = HDA_FIXUP_FUNC,
8675 		.v.func = alc285_fixup_hp_spectre_x360,
8676 	},
8677 	[ALC285_FIXUP_HP_SPECTRE_X360_EB1] = {
8678 		.type = HDA_FIXUP_FUNC,
8679 		.v.func = alc285_fixup_hp_spectre_x360_eb1
8680 	},
8681 	[ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = {
8682 		.type = HDA_FIXUP_FUNC,
8683 		.v.func = alc285_fixup_ideapad_s740_coef,
8684 		.chained = true,
8685 		.chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK,
8686 	},
8687 	[ALC623_FIXUP_LENOVO_THINKSTATION_P340] = {
8688 		.type = HDA_FIXUP_FUNC,
8689 		.v.func = alc_fixup_no_shutup,
8690 		.chained = true,
8691 		.chain_id = ALC283_FIXUP_HEADSET_MIC,
8692 	},
8693 	[ALC255_FIXUP_ACER_HEADPHONE_AND_MIC] = {
8694 		.type = HDA_FIXUP_PINS,
8695 		.v.pins = (const struct hda_pintbl[]) {
8696 			{ 0x21, 0x03211030 }, /* Change the Headphone location to Left */
8697 			{ }
8698 		},
8699 		.chained = true,
8700 		.chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC
8701 	},
8702 	[ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8703 		.type = HDA_FIXUP_FUNC,
8704 		.v.func = alc269_fixup_limit_int_mic_boost,
8705 		.chained = true,
8706 		.chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
8707 	},
8708 	[ALC285_FIXUP_LEGION_Y9000X_SPEAKERS] = {
8709 		.type = HDA_FIXUP_FUNC,
8710 		.v.func = alc285_fixup_ideapad_s740_coef,
8711 		.chained = true,
8712 		.chain_id = ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
8713 	},
8714 	[ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE] = {
8715 		.type = HDA_FIXUP_FUNC,
8716 		.v.func = alc287_fixup_legion_15imhg05_speakers,
8717 		.chained = true,
8718 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8719 	},
8720 	[ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
8721 		.type = HDA_FIXUP_VERBS,
8722 		//.v.verbs = legion_15imhg05_coefs,
8723 		.v.verbs = (const struct hda_verb[]) {
8724 			 // set left speaker Legion 7i.
8725 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8726 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8727 
8728 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8729 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8730 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8731 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8732 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8733 
8734 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8735 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8736 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8737 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8738 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8739 
8740 			 // set right speaker Legion 7i.
8741 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8742 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8743 
8744 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8745 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8746 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8747 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8748 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8749 
8750 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8751 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8752 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8753 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8754 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8755 			 {}
8756 		},
8757 		.chained = true,
8758 		.chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
8759 	},
8760 	[ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
8761 		.type = HDA_FIXUP_FUNC,
8762 		.v.func = alc287_fixup_legion_15imhg05_speakers,
8763 		.chained = true,
8764 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
8765 	},
8766 	[ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
8767 		.type = HDA_FIXUP_VERBS,
8768 		.v.verbs = (const struct hda_verb[]) {
8769 			 // set left speaker Yoga 7i.
8770 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8771 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8772 
8773 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8774 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8775 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8776 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8777 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8778 
8779 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8780 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8781 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8782 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8783 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8784 
8785 			 // set right speaker Yoga 7i.
8786 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8787 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
8788 
8789 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8790 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8791 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8792 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8793 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8794 
8795 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8796 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8797 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8798 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8799 			 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8800 			 {}
8801 		},
8802 		.chained = true,
8803 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
8804 	},
8805 	[ALC298_FIXUP_LENOVO_C940_DUET7] = {
8806 		.type = HDA_FIXUP_FUNC,
8807 		.v.func = alc298_fixup_lenovo_c940_duet7,
8808 	},
8809 	[ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
8810 		.type = HDA_FIXUP_VERBS,
8811 		.v.verbs = (const struct hda_verb[]) {
8812 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8813 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8814 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8815 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8816 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8817 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8818 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8819 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8820 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8821 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8822 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8823 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8824 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8825 			{ 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8826 			{}
8827 		},
8828 		.chained = true,
8829 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
8830 	},
8831 	[ALC256_FIXUP_SET_COEF_DEFAULTS] = {
8832 		.type = HDA_FIXUP_FUNC,
8833 		.v.func = alc256_fixup_set_coef_defaults,
8834 	},
8835 	[ALC245_FIXUP_HP_GPIO_LED] = {
8836 		.type = HDA_FIXUP_FUNC,
8837 		.v.func = alc245_fixup_hp_gpio_led,
8838 	},
8839 	[ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
8840 		.type = HDA_FIXUP_PINS,
8841 		.v.pins = (const struct hda_pintbl[]) {
8842 			{ 0x19, 0x03a11120 }, /* use as headset mic, without its own jack detect */
8843 			{ }
8844 		},
8845 		.chained = true,
8846 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
8847 	},
8848 	[ALC233_FIXUP_NO_AUDIO_JACK] = {
8849 		.type = HDA_FIXUP_FUNC,
8850 		.v.func = alc233_fixup_no_audio_jack,
8851 	},
8852 	[ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME] = {
8853 		.type = HDA_FIXUP_FUNC,
8854 		.v.func = alc256_fixup_mic_no_presence_and_resume,
8855 		.chained = true,
8856 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8857 	},
8858 	[ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED] = {
8859 		.type = HDA_FIXUP_VERBS,
8860 		.v.verbs = (const struct hda_verb[]) {
8861 			 { 0x20, AC_VERB_SET_COEF_INDEX, 0x19 },
8862 			 { 0x20, AC_VERB_SET_PROC_COEF, 0x8e11 },
8863 			 { }
8864 		},
8865 		.chained = true,
8866 		.chain_id = ALC285_FIXUP_HP_MUTE_LED,
8867 	},
8868 	[ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS] = {
8869 		.type = HDA_FIXUP_FUNC,
8870 		.v.func = alc295_fixup_dell_inspiron_top_speakers,
8871 		.chained = true,
8872 		.chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
8873 	},
8874 	[ALC236_FIXUP_DELL_DUAL_CODECS] = {
8875 		.type = HDA_FIXUP_PINS,
8876 		.v.func = alc1220_fixup_gb_dual_codecs,
8877 		.chained = true,
8878 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8879 	},
8880 };
8881 
8882 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
8883 	SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
8884 	SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
8885 	SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
8886 	SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
8887 	SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8888 	SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
8889 	SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
8890 	SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8891 	SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8892 	SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
8893 	SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8894 	SND_PCI_QUIRK(0x1025, 0x0840, "Acer Aspire E1", ALC269VB_FIXUP_ASPIRE_E1_COEF),
8895 	SND_PCI_QUIRK(0x1025, 0x101c, "Acer Veriton N2510G", ALC269_FIXUP_LIFEBOOK),
8896 	SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
8897 	SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
8898 	SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
8899 	SND_PCI_QUIRK(0x1025, 0x1094, "Acer Aspire E5-575T", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST),
8900 	SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8901 	SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8902 	SND_PCI_QUIRK(0x1025, 0x1166, "Acer Veriton N4640G", ALC269_FIXUP_LIFEBOOK),
8903 	SND_PCI_QUIRK(0x1025, 0x1167, "Acer Veriton N6640G", ALC269_FIXUP_LIFEBOOK),
8904 	SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
8905 	SND_PCI_QUIRK(0x1025, 0x1247, "Acer vCopperbox", ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS),
8906 	SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
8907 	SND_PCI_QUIRK(0x1025, 0x1269, "Acer SWIFT SF314-54", ALC256_FIXUP_ACER_HEADSET_MIC),
8908 	SND_PCI_QUIRK(0x1025, 0x126a, "Acer Swift SF114-32", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8909 	SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8910 	SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8911 	SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8912 	SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
8913 	SND_PCI_QUIRK(0x1025, 0x129d, "Acer SWIFT SF313-51", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8914 	SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8915 	SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8916 	SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
8917 	SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
8918 	SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8919 	SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8920 	SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8921 	SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
8922 	SND_PCI_QUIRK(0x1025, 0x1534, "Acer Predator PH315-54", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8923 	SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
8924 	SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
8925 	SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
8926 	SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
8927 	SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8928 	SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
8929 	SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
8930 	SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
8931 	SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8932 	SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8933 	SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8934 	SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8935 	SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8936 	SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
8937 	SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
8938 	SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
8939 	SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8940 	SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8941 	SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
8942 	SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8943 	SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8944 	SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8945 	SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8946 	SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8947 	SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8948 	SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8949 	SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8950 	SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8951 	SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8952 	SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8953 	SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
8954 	SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
8955 	SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
8956 	SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
8957 	SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8958 	SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
8959 	SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
8960 	SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8961 	SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8962 	SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8963 	SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8964 	SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
8965 	SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
8966 	SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
8967 	SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8968 	SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8969 	SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8970 	SND_PCI_QUIRK(0x1028, 0x098d, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8971 	SND_PCI_QUIRK(0x1028, 0x09bf, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8972 	SND_PCI_QUIRK(0x1028, 0x0a2e, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
8973 	SND_PCI_QUIRK(0x1028, 0x0a30, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
8974 	SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC),
8975 	SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK),
8976 	SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK),
8977 	SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8978 	SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8979 	SND_PCI_QUIRK(0x1028, 0x0b19, "Dell XPS 15 9520", ALC289_FIXUP_DUAL_SPK),
8980 	SND_PCI_QUIRK(0x1028, 0x0b1a, "Dell Precision 5570", ALC289_FIXUP_DUAL_SPK),
8981 	SND_PCI_QUIRK(0x1028, 0x0b37, "Dell Inspiron 16 Plus 7620 2-in-1", ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS),
8982 	SND_PCI_QUIRK(0x1028, 0x0b71, "Dell Inspiron 16 Plus 7620", ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS),
8983 	SND_PCI_QUIRK(0x1028, 0x0c03, "Dell Precision 5340", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8984 	SND_PCI_QUIRK(0x1028, 0x0c19, "Dell Precision 3340", ALC236_FIXUP_DELL_DUAL_CODECS),
8985 	SND_PCI_QUIRK(0x1028, 0x0c1a, "Dell Precision 3340", ALC236_FIXUP_DELL_DUAL_CODECS),
8986 	SND_PCI_QUIRK(0x1028, 0x0c1b, "Dell Precision 3440", ALC236_FIXUP_DELL_DUAL_CODECS),
8987 	SND_PCI_QUIRK(0x1028, 0x0c1c, "Dell Precision 3540", ALC236_FIXUP_DELL_DUAL_CODECS),
8988 	SND_PCI_QUIRK(0x1028, 0x0c1d, "Dell Precision 3440", ALC236_FIXUP_DELL_DUAL_CODECS),
8989 	SND_PCI_QUIRK(0x1028, 0x0c1e, "Dell Precision 3540", ALC236_FIXUP_DELL_DUAL_CODECS),
8990 	SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8991 	SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8992 	SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
8993 	SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8994 	SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
8995 	SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8996 	SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8997 	SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8998 	SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8999 	SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
9000 	SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9001 	SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9002 	SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9003 	SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9004 	SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9005 	SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9006 	SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9007 	SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9008 	SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9009 	SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9010 	SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9011 	SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9012 	SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9013 	SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
9014 	SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
9015 	SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9016 	SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9017 	SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9018 	SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9019 	SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9020 	SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9021 	SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9022 	SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9023 	SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
9024 	SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9025 	SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
9026 	SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9027 	SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
9028 	SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9029 	SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9030 	SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9031 	SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9032 	SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9033 	SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9034 	SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9035 	SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9036 	SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9037 	SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9038 	SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9039 	SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9040 	SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9041 	SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9042 	SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
9043 	SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9044 	SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9045 	SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9046 	SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9047 	SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9048 	SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9049 	SND_PCI_QUIRK(0x103c, 0x2b5e, "HP 288 Pro G2 MT", ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE),
9050 	SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9051 	SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9052 	SND_PCI_QUIRK(0x103c, 0x8077, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
9053 	SND_PCI_QUIRK(0x103c, 0x8158, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
9054 	SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC295_FIXUP_HP_X360),
9055 	SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
9056 	SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
9057 	SND_PCI_QUIRK(0x103c, 0x827f, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9058 	SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9059 	SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
9060 	SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9061 	SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9062 	SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9063 	SND_PCI_QUIRK(0x103c, 0x84ae, "HP 15-db0403ng", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9064 	SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
9065 	SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9066 	SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
9067 	SND_PCI_QUIRK(0x103c, 0x8537, "HP ProBook 440 G6", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9068 	SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9069 	SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9070 	SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
9071 	SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO),
9072 	SND_PCI_QUIRK(0x103c, 0x86e7, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9073 	SND_PCI_QUIRK(0x103c, 0x86e8, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9074 	SND_PCI_QUIRK(0x103c, 0x86f9, "HP Spectre x360 13-aw0xxx", ALC285_FIXUP_HP_SPECTRE_X360_MUTE_LED),
9075 	SND_PCI_QUIRK(0x103c, 0x8716, "HP Elite Dragonfly G2 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9076 	SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9077 	SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
9078 	SND_PCI_QUIRK(0x103c, 0x8728, "HP EliteBook 840 G7", ALC285_FIXUP_HP_GPIO_LED),
9079 	SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
9080 	SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9081 	SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9082 	SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9083 	SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
9084 	SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
9085 	SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
9086 	SND_PCI_QUIRK(0x103c, 0x8780, "HP ZBook Fury 17 G7 Mobile Workstation",
9087 		      ALC285_FIXUP_HP_GPIO_AMP_INIT),
9088 	SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation",
9089 		      ALC285_FIXUP_HP_GPIO_AMP_INIT),
9090 	SND_PCI_QUIRK(0x103c, 0x8786, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
9091 	SND_PCI_QUIRK(0x103c, 0x8787, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
9092 	SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
9093 	SND_PCI_QUIRK(0x103c, 0x87b7, "HP Laptop 14-fq0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9094 	SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
9095 	SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9096 	SND_PCI_QUIRK(0x103c, 0x87e7, "HP ProBook 450 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9097 	SND_PCI_QUIRK(0x103c, 0x87f1, "HP ProBook 630 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9098 	SND_PCI_QUIRK(0x103c, 0x87f2, "HP ProBook 640 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9099 	SND_PCI_QUIRK(0x103c, 0x87f4, "HP", ALC287_FIXUP_HP_GPIO_LED),
9100 	SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED),
9101 	SND_PCI_QUIRK(0x103c, 0x87f6, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
9102 	SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
9103 	SND_PCI_QUIRK(0x103c, 0x87fe, "HP Laptop 15s-fq2xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9104 	SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
9105 	SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9106 	SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9107 	SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9108 	SND_PCI_QUIRK(0x103c, 0x881d, "HP 250 G8 Notebook PC", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9109 	SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9110 	SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9111 	SND_PCI_QUIRK(0x103c, 0x884b, "HP EliteBook 840 Aero G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9112 	SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
9113 	SND_PCI_QUIRK(0x103c, 0x8862, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9114 	SND_PCI_QUIRK(0x103c, 0x8863, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9115 	SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9116 	SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9117 	SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
9118 	SND_PCI_QUIRK(0x103c, 0x887a, "HP Laptop 15s-eq2xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9119 	SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED),
9120 	SND_PCI_QUIRK(0x103c, 0x8895, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED),
9121 	SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
9122 	SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9123 	SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
9124 	SND_PCI_QUIRK(0x103c, 0x89aa, "HP EliteBook 630 G9", ALC236_FIXUP_HP_GPIO_LED),
9125 	SND_PCI_QUIRK(0x103c, 0x89c3, "HP", ALC285_FIXUP_HP_GPIO_LED),
9126 	SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9127 	SND_PCI_QUIRK(0x103c, 0x89d3, "HP EliteBook 645 G9 (MB 89D2)", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9128 	SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
9129 	SND_PCI_QUIRK(0x103c, 0x8aa0, "HP ProBook 440 G9 (MB 8A9E)", ALC236_FIXUP_HP_GPIO_LED),
9130 	SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED),
9131 	SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED),
9132 	SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED),
9133 	SND_PCI_QUIRK(0x103c, 0x8b5d, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9134 	SND_PCI_QUIRK(0x103c, 0x8b5e, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
9135 	SND_PCI_QUIRK(0x103c, 0x8bf0, "HP", ALC236_FIXUP_HP_GPIO_LED),
9136 	SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
9137 	SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
9138 	SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9139 	SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
9140 	SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
9141 	SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9142 	SND_PCI_QUIRK(0x1043, 0x10d3, "ASUS K6500ZC", ALC294_FIXUP_ASUS_SPK),
9143 	SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9144 	SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9145 	SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9146 	SND_PCI_QUIRK(0x1043, 0x1271, "ASUS X430UN", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
9147 	SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9148 	SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9149 	SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
9150 	SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
9151 	SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE),
9152 	SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
9153 	SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
9154 	SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
9155 	SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK),
9156 	SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
9157 	SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
9158 	SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS),
9159 	SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
9160 	SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
9161 	SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
9162 	SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
9163 	SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE),
9164 	SND_PCI_QUIRK(0x1043, 0x1970, "ASUS UX550VE", ALC289_FIXUP_ASUS_GA401),
9165 	SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE),
9166 	SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
9167 	SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
9168 	SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
9169 	SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
9170 	SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
9171 	SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
9172 	SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9173 	SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9174 	SND_PCI_QUIRK(0x1043, 0x1c62, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
9175 	SND_PCI_QUIRK(0x1043, 0x1c92, "ASUS ROG Strix G15", ALC285_FIXUP_ASUS_G533Z_PINS),
9176 	SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
9177 	SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401),
9178 	SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
9179 	SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
9180 	SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS),
9181 	SND_PCI_QUIRK(0x1043, 0x1e5e, "ASUS ROG Strix G513", ALC294_FIXUP_ASUS_G513_PINS),
9182 	SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
9183 	SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401),
9184 	SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
9185 	SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401),
9186 	SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
9187 	SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
9188 	SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
9189 	SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
9190 	SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
9191 	SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
9192 	SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
9193 	SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
9194 	SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
9195 	SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
9196 	SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9197 	SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9198 	SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
9199 	SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
9200 	SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
9201 	SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
9202 	SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
9203 	SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
9204 	SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
9205 	SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
9206 	SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9207 	SND_PCI_QUIRK(0x10ec, 0x124c, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9208 	SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9209 	SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9210 	SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
9211 	SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
9212 	SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9213 	SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_AMP),
9214 	SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_AMP),
9215 	SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9216 	SND_PCI_QUIRK(0x144d, 0xc1a3, "Samsung Galaxy Book Pro (NP935XDB-KC1SE)", ALC298_FIXUP_SAMSUNG_AMP),
9217 	SND_PCI_QUIRK(0x144d, 0xc1a6, "Samsung Galaxy Book Pro 360 (NP930QBD)", ALC298_FIXUP_SAMSUNG_AMP),
9218 	SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
9219 	SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_AMP),
9220 	SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
9221 	SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9222 	SND_PCI_QUIRK(0x144d, 0xca03, "Samsung Galaxy Book2 Pro 360 (NP930QED)", ALC298_FIXUP_SAMSUNG_AMP),
9223 	SND_PCI_QUIRK(0x144d, 0xc868, "Samsung Galaxy Book2 Pro (NP930XED)", ALC298_FIXUP_SAMSUNG_AMP),
9224 	SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
9225 	SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
9226 	SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
9227 	SND_PCI_QUIRK(0x152d, 0x1082, "Quanta NL3", ALC269_FIXUP_LIFEBOOK),
9228 	SND_PCI_QUIRK(0x1558, 0x1323, "Clevo N130ZU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9229 	SND_PCI_QUIRK(0x1558, 0x1325, "Clevo N15[01][CW]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9230 	SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9231 	SND_PCI_QUIRK(0x1558, 0x1403, "Clevo N140CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9232 	SND_PCI_QUIRK(0x1558, 0x1404, "Clevo N150CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9233 	SND_PCI_QUIRK(0x1558, 0x14a1, "Clevo L141MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9234 	SND_PCI_QUIRK(0x1558, 0x4018, "Clevo NV40M[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9235 	SND_PCI_QUIRK(0x1558, 0x4019, "Clevo NV40MZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9236 	SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9237 	SND_PCI_QUIRK(0x1558, 0x4041, "Clevo NV4[15]PZ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9238 	SND_PCI_QUIRK(0x1558, 0x40a1, "Clevo NL40GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9239 	SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9240 	SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9241 	SND_PCI_QUIRK(0x1558, 0x5015, "Clevo NH5[58]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9242 	SND_PCI_QUIRK(0x1558, 0x5017, "Clevo NH7[79]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9243 	SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9244 	SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9245 	SND_PCI_QUIRK(0x1558, 0x50b6, "Clevo NK50S5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9246 	SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9247 	SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9248 	SND_PCI_QUIRK(0x1558, 0x50e1, "Clevo NH5[58]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9249 	SND_PCI_QUIRK(0x1558, 0x50e2, "Clevo NH7[79]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9250 	SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9251 	SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9252 	SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9253 	SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9254 	SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9255 	SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9256 	SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9257 	SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9258 	SND_PCI_QUIRK(0x1558, 0x51b1, "Clevo NS50AU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9259 	SND_PCI_QUIRK(0x1558, 0x51b3, "Clevo NS70AU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9260 	SND_PCI_QUIRK(0x1558, 0x5630, "Clevo NP50RNJS", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9261 	SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9262 	SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9263 	SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9264 	SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9265 	SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9266 	SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9267 	SND_PCI_QUIRK(0x1558, 0x7716, "Clevo NS50PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9268 	SND_PCI_QUIRK(0x1558, 0x7717, "Clevo NS70PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9269 	SND_PCI_QUIRK(0x1558, 0x7718, "Clevo L140PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9270 	SND_PCI_QUIRK(0x1558, 0x7724, "Clevo L140AU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9271 	SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9272 	SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9273 	SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9274 	SND_PCI_QUIRK(0x1558, 0x8535, "Clevo NH50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9275 	SND_PCI_QUIRK(0x1558, 0x8536, "Clevo NH79D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9276 	SND_PCI_QUIRK(0x1558, 0x8550, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9277 	SND_PCI_QUIRK(0x1558, 0x8551, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9278 	SND_PCI_QUIRK(0x1558, 0x8560, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
9279 	SND_PCI_QUIRK(0x1558, 0x8561, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
9280 	SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
9281 	SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9282 	SND_PCI_QUIRK(0x1558, 0x866d, "Clevo NP5[05]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9283 	SND_PCI_QUIRK(0x1558, 0x867c, "Clevo NP7[01]PNP", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9284 	SND_PCI_QUIRK(0x1558, 0x867d, "Clevo NP7[01]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9285 	SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9286 	SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME),
9287 	SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9288 	SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9289 	SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9290 	SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9291 	SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9292 	SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9293 	SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9294 	SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL5[03]RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9295 	SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL50NU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9296 	SND_PCI_QUIRK(0x1558, 0xa650, "Clevo NP[567]0SN[CD]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9297 	SND_PCI_QUIRK(0x1558, 0xa671, "Clevo NP70SN[CDE]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9298 	SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9299 	SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9300 	SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9301 	SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9302 	SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9303 	SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9304 	SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
9305 	SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
9306 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
9307 	SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
9308 	SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
9309 	SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
9310 	SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
9311 	SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
9312 	SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
9313 	SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
9314 	SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
9315 	SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
9316 	SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
9317 	SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
9318 	SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
9319 	SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
9320 	SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
9321 	SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
9322 	SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
9323 	SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9324 	SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
9325 	SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
9326 	SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
9327 	SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9328 	SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9329 	SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
9330 	SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
9331 	SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
9332 	SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9333 	SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9334 	SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
9335 	SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9336 	SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9337 	SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9338 	SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9339 	SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
9340 	SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
9341 	SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
9342 	SND_PCI_QUIRK(0x17aa, 0x22c2, "Thinkpad X1 Extreme Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
9343 	SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
9344 	SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
9345 	SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9346 	SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9347 	SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9348 	SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9349 	SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9350 	SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9351 	SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9352 	SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9353 	SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
9354 	SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo Yoga DuetITL 2021", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9355 	SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9356 	SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940 / Yoga Duet 7", ALC298_FIXUP_LENOVO_C940_DUET7),
9357 	SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
9358 	SND_PCI_QUIRK(0x17aa, 0x3820, "Yoga Duet 7 13ITL6", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9359 	SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
9360 	SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
9361 	SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9362 	SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
9363 	SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
9364 	SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9365 	SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9366 	SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9367 	SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
9368 	SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
9369 	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
9370 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
9371 	SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9372 	SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
9373 	SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
9374 	SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9375 	SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
9376 	SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
9377 	SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
9378 	SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
9379 	SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
9380 	SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
9381 	SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
9382 	SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
9383 	SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9384 	SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9385 	SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9386 	SND_PCI_QUIRK(0x17aa, 0x508b, "Thinkpad X12 Gen 1", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9387 	SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9388 	SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9389 	SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9390 	SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
9391 	SND_PCI_QUIRK(0x17aa, 0x9e56, "Lenovo ZhaoYang CF4620Z", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9392 	SND_PCI_QUIRK(0x1849, 0x1233, "ASRock NUC Box 1100", ALC233_FIXUP_NO_AUDIO_JACK),
9393 	SND_PCI_QUIRK(0x1849, 0xa233, "Positivo Master C6300", ALC269_FIXUP_HEADSET_MIC),
9394 	SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
9395 	SND_PCI_QUIRK(0x19e5, 0x320f, "Huawei WRT-WX9 ", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
9396 	SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20),
9397 	SND_PCI_QUIRK(0x1b35, 0x1236, "CZC TMI", ALC269_FIXUP_CZC_TMI),
9398 	SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
9399 	SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
9400 	SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
9401 	SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
9402 	SND_PCI_QUIRK(0x1c6c, 0x1251, "Positivo N14KP6-TG", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE),
9403 	SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_SET_COEF_DEFAULTS),
9404 	SND_PCI_QUIRK(0x1d05, 0x1096, "TongFang GMxMRxx", ALC269_FIXUP_NO_SHUTUP),
9405 	SND_PCI_QUIRK(0x1d05, 0x1100, "TongFang GKxNRxx", ALC269_FIXUP_NO_SHUTUP),
9406 	SND_PCI_QUIRK(0x1d05, 0x1111, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9407 	SND_PCI_QUIRK(0x1d05, 0x1119, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9408 	SND_PCI_QUIRK(0x1d05, 0x1129, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9409 	SND_PCI_QUIRK(0x1d05, 0x1147, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
9410 	SND_PCI_QUIRK(0x1d05, 0x115c, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
9411 	SND_PCI_QUIRK(0x1d05, 0x121b, "TongFang GMxAGxx", ALC269_FIXUP_NO_SHUTUP),
9412 	SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
9413 	SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
9414 	SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
9415 	SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC),
9416 	SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
9417 	SND_PCI_QUIRK(0x2782, 0x0232, "CHUWI CoreBook XPro", ALC269VB_FIXUP_CHUWI_COREBOOK_XPRO),
9418 	SND_PCI_QUIRK(0x2782, 0x1707, "Vaio VJFE-ADL", ALC298_FIXUP_SPK_VOLUME),
9419 	SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
9420 	SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
9421 	SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10),
9422 
9423 #if 0
9424 	/* Below is a quirk table taken from the old code.
9425 	 * Basically the device should work as is without the fixup table.
9426 	 * If BIOS doesn't give a proper info, enable the corresponding
9427 	 * fixup entry.
9428 	 */
9429 	SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
9430 		      ALC269_FIXUP_AMIC),
9431 	SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
9432 	SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
9433 	SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
9434 	SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
9435 	SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
9436 	SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
9437 	SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
9438 	SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
9439 	SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
9440 	SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
9441 	SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
9442 	SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
9443 	SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
9444 	SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
9445 	SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
9446 	SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
9447 	SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
9448 	SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
9449 	SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
9450 	SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
9451 	SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
9452 	SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
9453 	SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
9454 	SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
9455 	SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
9456 	SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
9457 	SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
9458 	SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
9459 	SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
9460 	SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
9461 	SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
9462 	SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
9463 	SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
9464 	SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
9465 	SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
9466 	SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
9467 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
9468 	SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
9469 	SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
9470 #endif
9471 	{}
9472 };
9473 
9474 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
9475 	SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
9476 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
9477 	SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
9478 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
9479 	SND_PCI_QUIRK_VENDOR(0x19e5, "Huawei Matebook", ALC255_FIXUP_MIC_MUTE_LED),
9480 	{}
9481 };
9482 
9483 static const struct hda_model_fixup alc269_fixup_models[] = {
9484 	{.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
9485 	{.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
9486 	{.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
9487 	{.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
9488 	{.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
9489 	{.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
9490 	{.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
9491 	{.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
9492 	{.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9493 	{.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
9494 	{.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9495 	{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
9496 	{.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
9497 	{.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
9498 	{.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
9499 	{.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
9500 	{.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
9501 	{.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
9502 	{.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
9503 	{.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
9504 	{.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
9505 	{.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
9506 	{.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
9507 	{.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
9508 	{.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
9509 	{.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
9510 	{.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
9511 	{.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
9512 	{.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
9513 	{.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
9514 	{.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
9515 	{.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
9516 	{.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
9517 	{.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
9518 	{.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
9519 	{.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
9520 	{.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
9521 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
9522 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
9523 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
9524 	{.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
9525 	{.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
9526 	{.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
9527 	{.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
9528 	{.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
9529 	{.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
9530 	{.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
9531 	{.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
9532 	{.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
9533 	{.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
9534 	{.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
9535 	{.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
9536 	{.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
9537 	{.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
9538 	{.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
9539 	{.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
9540 	{.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
9541 	{.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
9542 	{.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
9543 	{.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
9544 	{.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
9545 	{.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
9546 	{.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
9547 	{.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
9548 	{.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
9549 	{.id = ALC255_FIXUP_MIC_MUTE_LED, .name = "alc255-dell-mute"},
9550 	{.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
9551 	{.id = ALC269VB_FIXUP_ASPIRE_E1_COEF, .name = "aspire-e1-coef"},
9552 	{.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
9553 	{.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9554 	{.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
9555 	{.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
9556 	{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
9557 	{.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
9558 	{.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
9559 	{.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
9560 	{.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
9561 	{.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
9562 	{.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
9563 	{.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
9564 	{.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
9565 	{.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
9566 	{.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
9567 	{.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
9568 	{.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
9569 	{.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
9570 	{.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
9571 	{.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
9572 	{.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
9573 	{.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
9574 	{.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
9575 	{.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
9576 	{.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
9577 	{.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
9578 	{.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
9579 	{.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
9580 	{.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
9581 	{.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
9582 	{.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
9583 	{.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
9584 	{.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
9585 	{.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
9586 	{.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
9587 	{.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
9588 	{.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
9589 	{.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
9590 	{.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
9591 	{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
9592 	{.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
9593 	{.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
9594 	{.id = ALC298_FIXUP_SAMSUNG_AMP, .name = "alc298-samsung-amp"},
9595 	{.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
9596 	{.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
9597 	{.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
9598 	{.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
9599 	{.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
9600 	{.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
9601 	{.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"},
9602 	{.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
9603 	{.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
9604 	{.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
9605 	{.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"},
9606 	{}
9607 };
9608 #define ALC225_STANDARD_PINS \
9609 	{0x21, 0x04211020}
9610 
9611 #define ALC256_STANDARD_PINS \
9612 	{0x12, 0x90a60140}, \
9613 	{0x14, 0x90170110}, \
9614 	{0x21, 0x02211020}
9615 
9616 #define ALC282_STANDARD_PINS \
9617 	{0x14, 0x90170110}
9618 
9619 #define ALC290_STANDARD_PINS \
9620 	{0x12, 0x99a30130}
9621 
9622 #define ALC292_STANDARD_PINS \
9623 	{0x14, 0x90170110}, \
9624 	{0x15, 0x0221401f}
9625 
9626 #define ALC295_STANDARD_PINS \
9627 	{0x12, 0xb7a60130}, \
9628 	{0x14, 0x90170110}, \
9629 	{0x21, 0x04211020}
9630 
9631 #define ALC298_STANDARD_PINS \
9632 	{0x12, 0x90a60130}, \
9633 	{0x21, 0x03211020}
9634 
9635 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
9636 	SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
9637 		{0x14, 0x01014020},
9638 		{0x17, 0x90170110},
9639 		{0x18, 0x02a11030},
9640 		{0x19, 0x0181303F},
9641 		{0x21, 0x0221102f}),
9642 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
9643 		{0x12, 0x90a601c0},
9644 		{0x14, 0x90171120},
9645 		{0x21, 0x02211030}),
9646 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9647 		{0x14, 0x90170110},
9648 		{0x1b, 0x90a70130},
9649 		{0x21, 0x03211020}),
9650 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9651 		{0x1a, 0x90a70130},
9652 		{0x1b, 0x90170110},
9653 		{0x21, 0x03211020}),
9654 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9655 		ALC225_STANDARD_PINS,
9656 		{0x12, 0xb7a60130},
9657 		{0x14, 0x901701a0}),
9658 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9659 		ALC225_STANDARD_PINS,
9660 		{0x12, 0xb7a60130},
9661 		{0x14, 0x901701b0}),
9662 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9663 		ALC225_STANDARD_PINS,
9664 		{0x12, 0xb7a60150},
9665 		{0x14, 0x901701a0}),
9666 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9667 		ALC225_STANDARD_PINS,
9668 		{0x12, 0xb7a60150},
9669 		{0x14, 0x901701b0}),
9670 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9671 		ALC225_STANDARD_PINS,
9672 		{0x12, 0xb7a60130},
9673 		{0x1b, 0x90170110}),
9674 	SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9675 		{0x1b, 0x01111010},
9676 		{0x1e, 0x01451130},
9677 		{0x21, 0x02211020}),
9678 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
9679 		{0x12, 0x90a60140},
9680 		{0x14, 0x90170110},
9681 		{0x19, 0x02a11030},
9682 		{0x21, 0x02211020}),
9683 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9684 		{0x14, 0x90170110},
9685 		{0x19, 0x02a11030},
9686 		{0x1a, 0x02a11040},
9687 		{0x1b, 0x01014020},
9688 		{0x21, 0x0221101f}),
9689 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9690 		{0x14, 0x90170110},
9691 		{0x19, 0x02a11030},
9692 		{0x1a, 0x02a11040},
9693 		{0x1b, 0x01011020},
9694 		{0x21, 0x0221101f}),
9695 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9696 		{0x14, 0x90170110},
9697 		{0x19, 0x02a11020},
9698 		{0x1a, 0x02a11030},
9699 		{0x21, 0x0221101f}),
9700 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
9701 		{0x21, 0x02211010}),
9702 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9703 		{0x14, 0x90170110},
9704 		{0x19, 0x02a11020},
9705 		{0x21, 0x02211030}),
9706 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9707 		{0x14, 0x90170110},
9708 		{0x21, 0x02211020}),
9709 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9710 		{0x14, 0x90170130},
9711 		{0x21, 0x02211040}),
9712 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9713 		{0x12, 0x90a60140},
9714 		{0x14, 0x90170110},
9715 		{0x21, 0x02211020}),
9716 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9717 		{0x12, 0x90a60160},
9718 		{0x14, 0x90170120},
9719 		{0x21, 0x02211030}),
9720 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9721 		{0x14, 0x90170110},
9722 		{0x1b, 0x02011020},
9723 		{0x21, 0x0221101f}),
9724 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9725 		{0x14, 0x90170110},
9726 		{0x1b, 0x01011020},
9727 		{0x21, 0x0221101f}),
9728 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9729 		{0x14, 0x90170130},
9730 		{0x1b, 0x01014020},
9731 		{0x21, 0x0221103f}),
9732 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9733 		{0x14, 0x90170130},
9734 		{0x1b, 0x01011020},
9735 		{0x21, 0x0221103f}),
9736 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9737 		{0x14, 0x90170130},
9738 		{0x1b, 0x02011020},
9739 		{0x21, 0x0221103f}),
9740 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9741 		{0x14, 0x90170150},
9742 		{0x1b, 0x02011020},
9743 		{0x21, 0x0221105f}),
9744 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9745 		{0x14, 0x90170110},
9746 		{0x1b, 0x01014020},
9747 		{0x21, 0x0221101f}),
9748 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9749 		{0x12, 0x90a60160},
9750 		{0x14, 0x90170120},
9751 		{0x17, 0x90170140},
9752 		{0x21, 0x0321102f}),
9753 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9754 		{0x12, 0x90a60160},
9755 		{0x14, 0x90170130},
9756 		{0x21, 0x02211040}),
9757 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9758 		{0x12, 0x90a60160},
9759 		{0x14, 0x90170140},
9760 		{0x21, 0x02211050}),
9761 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9762 		{0x12, 0x90a60170},
9763 		{0x14, 0x90170120},
9764 		{0x21, 0x02211030}),
9765 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9766 		{0x12, 0x90a60170},
9767 		{0x14, 0x90170130},
9768 		{0x21, 0x02211040}),
9769 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9770 		{0x12, 0x90a60170},
9771 		{0x14, 0x90171130},
9772 		{0x21, 0x02211040}),
9773 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9774 		{0x12, 0x90a60170},
9775 		{0x14, 0x90170140},
9776 		{0x21, 0x02211050}),
9777 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9778 		{0x12, 0x90a60180},
9779 		{0x14, 0x90170130},
9780 		{0x21, 0x02211040}),
9781 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9782 		{0x12, 0x90a60180},
9783 		{0x14, 0x90170120},
9784 		{0x21, 0x02211030}),
9785 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9786 		{0x1b, 0x01011020},
9787 		{0x21, 0x02211010}),
9788 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9789 		{0x14, 0x90170110},
9790 		{0x1b, 0x90a70130},
9791 		{0x21, 0x04211020}),
9792 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9793 		{0x14, 0x90170110},
9794 		{0x1b, 0x90a70130},
9795 		{0x21, 0x03211020}),
9796 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9797 		{0x12, 0x90a60130},
9798 		{0x14, 0x90170110},
9799 		{0x21, 0x03211020}),
9800 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9801 		{0x12, 0x90a60130},
9802 		{0x14, 0x90170110},
9803 		{0x21, 0x04211020}),
9804 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9805 		{0x1a, 0x90a70130},
9806 		{0x1b, 0x90170110},
9807 		{0x21, 0x03211020}),
9808        SND_HDA_PIN_QUIRK(0x10ec0256, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9809 		{0x14, 0x90170110},
9810 		{0x19, 0x02a11020},
9811 		{0x21, 0x0221101f}),
9812        SND_HDA_PIN_QUIRK(0x10ec0274, 0x103c, "HP", ALC274_FIXUP_HP_HEADSET_MIC,
9813 		{0x17, 0x90170110},
9814 		{0x19, 0x03a11030},
9815 		{0x21, 0x03211020}),
9816 	SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
9817 		{0x12, 0x90a60130},
9818 		{0x14, 0x90170110},
9819 		{0x15, 0x0421101f},
9820 		{0x1a, 0x04a11020}),
9821 	SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
9822 		{0x12, 0x90a60140},
9823 		{0x14, 0x90170110},
9824 		{0x15, 0x0421101f},
9825 		{0x18, 0x02811030},
9826 		{0x1a, 0x04a1103f},
9827 		{0x1b, 0x02011020}),
9828 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9829 		ALC282_STANDARD_PINS,
9830 		{0x12, 0x99a30130},
9831 		{0x19, 0x03a11020},
9832 		{0x21, 0x0321101f}),
9833 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9834 		ALC282_STANDARD_PINS,
9835 		{0x12, 0x99a30130},
9836 		{0x19, 0x03a11020},
9837 		{0x21, 0x03211040}),
9838 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9839 		ALC282_STANDARD_PINS,
9840 		{0x12, 0x99a30130},
9841 		{0x19, 0x03a11030},
9842 		{0x21, 0x03211020}),
9843 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9844 		ALC282_STANDARD_PINS,
9845 		{0x12, 0x99a30130},
9846 		{0x19, 0x04a11020},
9847 		{0x21, 0x0421101f}),
9848 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
9849 		ALC282_STANDARD_PINS,
9850 		{0x12, 0x90a60140},
9851 		{0x19, 0x04a11030},
9852 		{0x21, 0x04211020}),
9853 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9854 		ALC282_STANDARD_PINS,
9855 		{0x12, 0x90a609c0},
9856 		{0x18, 0x03a11830},
9857 		{0x19, 0x04a19831},
9858 		{0x1a, 0x0481303f},
9859 		{0x1b, 0x04211020},
9860 		{0x21, 0x0321101f}),
9861 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9862 		ALC282_STANDARD_PINS,
9863 		{0x12, 0x90a60940},
9864 		{0x18, 0x03a11830},
9865 		{0x19, 0x04a19831},
9866 		{0x1a, 0x0481303f},
9867 		{0x1b, 0x04211020},
9868 		{0x21, 0x0321101f}),
9869 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9870 		ALC282_STANDARD_PINS,
9871 		{0x12, 0x90a60130},
9872 		{0x21, 0x0321101f}),
9873 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9874 		{0x12, 0x90a60160},
9875 		{0x14, 0x90170120},
9876 		{0x21, 0x02211030}),
9877 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9878 		ALC282_STANDARD_PINS,
9879 		{0x12, 0x90a60130},
9880 		{0x19, 0x03a11020},
9881 		{0x21, 0x0321101f}),
9882 	SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
9883 		{0x12, 0x90a60130},
9884 		{0x14, 0x90170110},
9885 		{0x19, 0x04a11040},
9886 		{0x21, 0x04211020}),
9887 	SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
9888 		{0x14, 0x90170110},
9889 		{0x19, 0x04a11040},
9890 		{0x1d, 0x40600001},
9891 		{0x21, 0x04211020}),
9892 	SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
9893 		{0x14, 0x90170110},
9894 		{0x19, 0x04a11040},
9895 		{0x21, 0x04211020}),
9896 	SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_HEADSET_JACK,
9897 		{0x14, 0x90170110},
9898 		{0x17, 0x90170111},
9899 		{0x19, 0x03a11030},
9900 		{0x21, 0x03211020}),
9901 	SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
9902 		{0x12, 0x90a60130},
9903 		{0x17, 0x90170110},
9904 		{0x21, 0x02211020}),
9905 	SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
9906 		{0x12, 0x90a60120},
9907 		{0x14, 0x90170110},
9908 		{0x21, 0x0321101f}),
9909 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9910 		ALC290_STANDARD_PINS,
9911 		{0x15, 0x04211040},
9912 		{0x18, 0x90170112},
9913 		{0x1a, 0x04a11020}),
9914 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9915 		ALC290_STANDARD_PINS,
9916 		{0x15, 0x04211040},
9917 		{0x18, 0x90170110},
9918 		{0x1a, 0x04a11020}),
9919 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9920 		ALC290_STANDARD_PINS,
9921 		{0x15, 0x0421101f},
9922 		{0x1a, 0x04a11020}),
9923 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9924 		ALC290_STANDARD_PINS,
9925 		{0x15, 0x04211020},
9926 		{0x1a, 0x04a11040}),
9927 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9928 		ALC290_STANDARD_PINS,
9929 		{0x14, 0x90170110},
9930 		{0x15, 0x04211020},
9931 		{0x1a, 0x04a11040}),
9932 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9933 		ALC290_STANDARD_PINS,
9934 		{0x14, 0x90170110},
9935 		{0x15, 0x04211020},
9936 		{0x1a, 0x04a11020}),
9937 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9938 		ALC290_STANDARD_PINS,
9939 		{0x14, 0x90170110},
9940 		{0x15, 0x0421101f},
9941 		{0x1a, 0x04a11020}),
9942 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9943 		ALC292_STANDARD_PINS,
9944 		{0x12, 0x90a60140},
9945 		{0x16, 0x01014020},
9946 		{0x19, 0x01a19030}),
9947 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9948 		ALC292_STANDARD_PINS,
9949 		{0x12, 0x90a60140},
9950 		{0x16, 0x01014020},
9951 		{0x18, 0x02a19031},
9952 		{0x19, 0x01a1903e}),
9953 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
9954 		ALC292_STANDARD_PINS,
9955 		{0x12, 0x90a60140}),
9956 	SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9957 		ALC292_STANDARD_PINS,
9958 		{0x13, 0x90a60140},
9959 		{0x16, 0x21014020},
9960 		{0x19, 0x21a19030}),
9961 	SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9962 		ALC292_STANDARD_PINS,
9963 		{0x13, 0x90a60140}),
9964 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_HPE,
9965 		{0x17, 0x90170110},
9966 		{0x21, 0x04211020}),
9967 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
9968 		{0x14, 0x90170110},
9969 		{0x1b, 0x90a70130},
9970 		{0x21, 0x04211020}),
9971 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9972 		{0x12, 0x90a60130},
9973 		{0x17, 0x90170110},
9974 		{0x21, 0x03211020}),
9975 	SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9976 		{0x12, 0x90a60130},
9977 		{0x17, 0x90170110},
9978 		{0x21, 0x04211020}),
9979 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9980 		{0x12, 0x90a60130},
9981 		{0x17, 0x90170110},
9982 		{0x21, 0x03211020}),
9983 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9984 		{0x12, 0x90a60120},
9985 		{0x17, 0x90170110},
9986 		{0x21, 0x04211030}),
9987 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9988 		{0x12, 0x90a60130},
9989 		{0x17, 0x90170110},
9990 		{0x21, 0x03211020}),
9991 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9992 		{0x12, 0x90a60130},
9993 		{0x17, 0x90170110},
9994 		{0x21, 0x03211020}),
9995 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9996 		ALC298_STANDARD_PINS,
9997 		{0x17, 0x90170110}),
9998 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9999 		ALC298_STANDARD_PINS,
10000 		{0x17, 0x90170140}),
10001 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
10002 		ALC298_STANDARD_PINS,
10003 		{0x17, 0x90170150}),
10004 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
10005 		{0x12, 0xb7a60140},
10006 		{0x13, 0xb7a60150},
10007 		{0x17, 0x90170110},
10008 		{0x1a, 0x03011020},
10009 		{0x21, 0x03211030}),
10010 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
10011 		{0x12, 0xb7a60140},
10012 		{0x17, 0x90170110},
10013 		{0x1a, 0x03a11030},
10014 		{0x21, 0x03211020}),
10015 	SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10016 		ALC225_STANDARD_PINS,
10017 		{0x12, 0xb7a60130},
10018 		{0x17, 0x90170110}),
10019 	SND_HDA_PIN_QUIRK(0x10ec0623, 0x17aa, "Lenovo", ALC283_FIXUP_HEADSET_MIC,
10020 		{0x14, 0x01014010},
10021 		{0x17, 0x90170120},
10022 		{0x18, 0x02a11030},
10023 		{0x19, 0x02a1103f},
10024 		{0x21, 0x0221101f}),
10025 	{}
10026 };
10027 
10028 /* This is the fallback pin_fixup_tbl for alc269 family, to make the tbl match
10029  * more machines, don't need to match all valid pins, just need to match
10030  * all the pins defined in the tbl. Just because of this reason, it is possible
10031  * that a single machine matches multiple tbls, so there is one limitation:
10032  *   at most one tbl is allowed to define for the same vendor and same codec
10033  */
10034 static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
10035 	SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10036 		{0x19, 0x40000000},
10037 		{0x1b, 0x40000000}),
10038 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
10039 		{0x19, 0x40000000},
10040 		{0x1b, 0x40000000}),
10041 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
10042 		{0x19, 0x40000000},
10043 		{0x1a, 0x40000000}),
10044 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
10045 		{0x19, 0x40000000},
10046 		{0x1a, 0x40000000}),
10047 	SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
10048 		{0x19, 0x40000000},
10049 		{0x1a, 0x40000000}),
10050 	{}
10051 };
10052 
alc269_fill_coef(struct hda_codec * codec)10053 static void alc269_fill_coef(struct hda_codec *codec)
10054 {
10055 	struct alc_spec *spec = codec->spec;
10056 	int val;
10057 
10058 	if (spec->codec_variant != ALC269_TYPE_ALC269VB)
10059 		return;
10060 
10061 	if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
10062 		alc_write_coef_idx(codec, 0xf, 0x960b);
10063 		alc_write_coef_idx(codec, 0xe, 0x8817);
10064 	}
10065 
10066 	if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
10067 		alc_write_coef_idx(codec, 0xf, 0x960b);
10068 		alc_write_coef_idx(codec, 0xe, 0x8814);
10069 	}
10070 
10071 	if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
10072 		/* Power up output pin */
10073 		alc_update_coef_idx(codec, 0x04, 0, 1<<11);
10074 	}
10075 
10076 	if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
10077 		val = alc_read_coef_idx(codec, 0xd);
10078 		if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
10079 			/* Capless ramp up clock control */
10080 			alc_write_coef_idx(codec, 0xd, val | (1<<10));
10081 		}
10082 		val = alc_read_coef_idx(codec, 0x17);
10083 		if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
10084 			/* Class D power on reset */
10085 			alc_write_coef_idx(codec, 0x17, val | (1<<7));
10086 		}
10087 	}
10088 
10089 	/* HP */
10090 	alc_update_coef_idx(codec, 0x4, 0, 1<<11);
10091 }
10092 
10093 /*
10094  */
patch_alc269(struct hda_codec * codec)10095 static int patch_alc269(struct hda_codec *codec)
10096 {
10097 	struct alc_spec *spec;
10098 	int err;
10099 
10100 	err = alc_alloc_spec(codec, 0x0b);
10101 	if (err < 0)
10102 		return err;
10103 
10104 	spec = codec->spec;
10105 	spec->gen.shared_mic_vref_pin = 0x18;
10106 	codec->power_save_node = 0;
10107 	spec->en_3kpull_low = true;
10108 
10109 #ifdef CONFIG_PM
10110 	codec->patch_ops.suspend = alc269_suspend;
10111 	codec->patch_ops.resume = alc269_resume;
10112 #endif
10113 	spec->shutup = alc_default_shutup;
10114 	spec->init_hook = alc_default_init;
10115 
10116 	switch (codec->core.vendor_id) {
10117 	case 0x10ec0269:
10118 		spec->codec_variant = ALC269_TYPE_ALC269VA;
10119 		switch (alc_get_coef0(codec) & 0x00f0) {
10120 		case 0x0010:
10121 			if (codec->bus->pci &&
10122 			    codec->bus->pci->subsystem_vendor == 0x1025 &&
10123 			    spec->cdefine.platform_type == 1)
10124 				err = alc_codec_rename(codec, "ALC271X");
10125 			spec->codec_variant = ALC269_TYPE_ALC269VB;
10126 			break;
10127 		case 0x0020:
10128 			if (codec->bus->pci &&
10129 			    codec->bus->pci->subsystem_vendor == 0x17aa &&
10130 			    codec->bus->pci->subsystem_device == 0x21f3)
10131 				err = alc_codec_rename(codec, "ALC3202");
10132 			spec->codec_variant = ALC269_TYPE_ALC269VC;
10133 			break;
10134 		case 0x0030:
10135 			spec->codec_variant = ALC269_TYPE_ALC269VD;
10136 			break;
10137 		default:
10138 			alc_fix_pll_init(codec, 0x20, 0x04, 15);
10139 		}
10140 		if (err < 0)
10141 			goto error;
10142 		spec->shutup = alc269_shutup;
10143 		spec->init_hook = alc269_fill_coef;
10144 		alc269_fill_coef(codec);
10145 		break;
10146 
10147 	case 0x10ec0280:
10148 	case 0x10ec0290:
10149 		spec->codec_variant = ALC269_TYPE_ALC280;
10150 		break;
10151 	case 0x10ec0282:
10152 		spec->codec_variant = ALC269_TYPE_ALC282;
10153 		spec->shutup = alc282_shutup;
10154 		spec->init_hook = alc282_init;
10155 		break;
10156 	case 0x10ec0233:
10157 	case 0x10ec0283:
10158 		spec->codec_variant = ALC269_TYPE_ALC283;
10159 		spec->shutup = alc283_shutup;
10160 		spec->init_hook = alc283_init;
10161 		break;
10162 	case 0x10ec0284:
10163 	case 0x10ec0292:
10164 		spec->codec_variant = ALC269_TYPE_ALC284;
10165 		break;
10166 	case 0x10ec0293:
10167 		spec->codec_variant = ALC269_TYPE_ALC293;
10168 		break;
10169 	case 0x10ec0286:
10170 	case 0x10ec0288:
10171 		spec->codec_variant = ALC269_TYPE_ALC286;
10172 		break;
10173 	case 0x10ec0298:
10174 		spec->codec_variant = ALC269_TYPE_ALC298;
10175 		break;
10176 	case 0x10ec0235:
10177 	case 0x10ec0255:
10178 		spec->codec_variant = ALC269_TYPE_ALC255;
10179 		spec->shutup = alc256_shutup;
10180 		spec->init_hook = alc256_init;
10181 		break;
10182 	case 0x10ec0230:
10183 	case 0x10ec0236:
10184 	case 0x10ec0256:
10185 	case 0x19e58326:
10186 		spec->codec_variant = ALC269_TYPE_ALC256;
10187 		spec->shutup = alc256_shutup;
10188 		spec->init_hook = alc256_init;
10189 		spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
10190 		if (codec->core.vendor_id == 0x10ec0236 &&
10191 		    codec->bus->pci->vendor != PCI_VENDOR_ID_AMD)
10192 			spec->en_3kpull_low = false;
10193 		break;
10194 	case 0x10ec0257:
10195 		spec->codec_variant = ALC269_TYPE_ALC257;
10196 		spec->shutup = alc256_shutup;
10197 		spec->init_hook = alc256_init;
10198 		spec->gen.mixer_nid = 0;
10199 		spec->en_3kpull_low = false;
10200 		break;
10201 	case 0x10ec0215:
10202 	case 0x10ec0245:
10203 	case 0x10ec0285:
10204 	case 0x10ec0289:
10205 		if (alc_get_coef0(codec) & 0x0010)
10206 			spec->codec_variant = ALC269_TYPE_ALC245;
10207 		else
10208 			spec->codec_variant = ALC269_TYPE_ALC215;
10209 		spec->shutup = alc225_shutup;
10210 		spec->init_hook = alc225_init;
10211 		spec->gen.mixer_nid = 0;
10212 		break;
10213 	case 0x10ec0225:
10214 	case 0x10ec0295:
10215 	case 0x10ec0299:
10216 		spec->codec_variant = ALC269_TYPE_ALC225;
10217 		spec->shutup = alc225_shutup;
10218 		spec->init_hook = alc225_init;
10219 		spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
10220 		break;
10221 	case 0x10ec0287:
10222 		spec->codec_variant = ALC269_TYPE_ALC287;
10223 		spec->shutup = alc225_shutup;
10224 		spec->init_hook = alc225_init;
10225 		spec->gen.mixer_nid = 0; /* no loopback on ALC287 */
10226 		break;
10227 	case 0x10ec0234:
10228 	case 0x10ec0274:
10229 	case 0x10ec0294:
10230 		spec->codec_variant = ALC269_TYPE_ALC294;
10231 		spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
10232 		alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
10233 		spec->init_hook = alc294_init;
10234 		break;
10235 	case 0x10ec0300:
10236 		spec->codec_variant = ALC269_TYPE_ALC300;
10237 		spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
10238 		break;
10239 	case 0x10ec0623:
10240 		spec->codec_variant = ALC269_TYPE_ALC623;
10241 		break;
10242 	case 0x10ec0700:
10243 	case 0x10ec0701:
10244 	case 0x10ec0703:
10245 	case 0x10ec0711:
10246 		spec->codec_variant = ALC269_TYPE_ALC700;
10247 		spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
10248 		alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
10249 		spec->init_hook = alc294_init;
10250 		break;
10251 
10252 	}
10253 
10254 	if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
10255 		spec->has_alc5505_dsp = 1;
10256 		spec->init_hook = alc5505_dsp_init;
10257 	}
10258 
10259 	alc_pre_init(codec);
10260 
10261 	snd_hda_pick_fixup(codec, alc269_fixup_models,
10262 		       alc269_fixup_tbl, alc269_fixups);
10263 	/* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
10264 	 * the quirk breaks the latter (bko#214101).
10265 	 * Clear the wrong entry.
10266 	 */
10267 	if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
10268 	    codec->core.vendor_id == 0x10ec0294) {
10269 		codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
10270 		codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
10271 	}
10272 
10273 	snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
10274 	snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
10275 	snd_hda_pick_fixup(codec, NULL,	alc269_fixup_vendor_tbl,
10276 			   alc269_fixups);
10277 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10278 
10279 	alc_auto_parse_customize_define(codec);
10280 
10281 	if (has_cdefine_beep(codec))
10282 		spec->gen.beep_nid = 0x01;
10283 
10284 	/* automatic parse from the BIOS config */
10285 	err = alc269_parse_auto_config(codec);
10286 	if (err < 0)
10287 		goto error;
10288 
10289 	if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
10290 		err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
10291 		if (err < 0)
10292 			goto error;
10293 	}
10294 
10295 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10296 
10297 	return 0;
10298 
10299  error:
10300 	alc_free(codec);
10301 	return err;
10302 }
10303 
10304 /*
10305  * ALC861
10306  */
10307 
alc861_parse_auto_config(struct hda_codec * codec)10308 static int alc861_parse_auto_config(struct hda_codec *codec)
10309 {
10310 	static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10311 	static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
10312 	return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
10313 }
10314 
10315 /* Pin config fixes */
10316 enum {
10317 	ALC861_FIXUP_FSC_AMILO_PI1505,
10318 	ALC861_FIXUP_AMP_VREF_0F,
10319 	ALC861_FIXUP_NO_JACK_DETECT,
10320 	ALC861_FIXUP_ASUS_A6RP,
10321 	ALC660_FIXUP_ASUS_W7J,
10322 };
10323 
10324 /* 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)10325 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
10326 			const struct hda_fixup *fix, int action)
10327 {
10328 	struct alc_spec *spec = codec->spec;
10329 	unsigned int val;
10330 
10331 	if (action != HDA_FIXUP_ACT_INIT)
10332 		return;
10333 	val = snd_hda_codec_get_pin_target(codec, 0x0f);
10334 	if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
10335 		val |= AC_PINCTL_IN_EN;
10336 	val |= AC_PINCTL_VREF_50;
10337 	snd_hda_set_pin_ctl(codec, 0x0f, val);
10338 	spec->gen.keep_vref_in_automute = 1;
10339 }
10340 
10341 /* suppress the jack-detection */
alc_fixup_no_jack_detect(struct hda_codec * codec,const struct hda_fixup * fix,int action)10342 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
10343 				     const struct hda_fixup *fix, int action)
10344 {
10345 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
10346 		codec->no_jack_detect = 1;
10347 }
10348 
10349 static const struct hda_fixup alc861_fixups[] = {
10350 	[ALC861_FIXUP_FSC_AMILO_PI1505] = {
10351 		.type = HDA_FIXUP_PINS,
10352 		.v.pins = (const struct hda_pintbl[]) {
10353 			{ 0x0b, 0x0221101f }, /* HP */
10354 			{ 0x0f, 0x90170310 }, /* speaker */
10355 			{ }
10356 		}
10357 	},
10358 	[ALC861_FIXUP_AMP_VREF_0F] = {
10359 		.type = HDA_FIXUP_FUNC,
10360 		.v.func = alc861_fixup_asus_amp_vref_0f,
10361 	},
10362 	[ALC861_FIXUP_NO_JACK_DETECT] = {
10363 		.type = HDA_FIXUP_FUNC,
10364 		.v.func = alc_fixup_no_jack_detect,
10365 	},
10366 	[ALC861_FIXUP_ASUS_A6RP] = {
10367 		.type = HDA_FIXUP_FUNC,
10368 		.v.func = alc861_fixup_asus_amp_vref_0f,
10369 		.chained = true,
10370 		.chain_id = ALC861_FIXUP_NO_JACK_DETECT,
10371 	},
10372 	[ALC660_FIXUP_ASUS_W7J] = {
10373 		.type = HDA_FIXUP_VERBS,
10374 		.v.verbs = (const struct hda_verb[]) {
10375 			/* ASUS W7J needs a magic pin setup on unused NID 0x10
10376 			 * for enabling outputs
10377 			 */
10378 			{0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10379 			{ }
10380 		},
10381 	}
10382 };
10383 
10384 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
10385 	SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
10386 	SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
10387 	SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
10388 	SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
10389 	SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
10390 	SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
10391 	SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
10392 	{}
10393 };
10394 
10395 /*
10396  */
patch_alc861(struct hda_codec * codec)10397 static int patch_alc861(struct hda_codec *codec)
10398 {
10399 	struct alc_spec *spec;
10400 	int err;
10401 
10402 	err = alc_alloc_spec(codec, 0x15);
10403 	if (err < 0)
10404 		return err;
10405 
10406 	spec = codec->spec;
10407 	if (has_cdefine_beep(codec))
10408 		spec->gen.beep_nid = 0x23;
10409 
10410 #ifdef CONFIG_PM
10411 	spec->power_hook = alc_power_eapd;
10412 #endif
10413 
10414 	alc_pre_init(codec);
10415 
10416 	snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
10417 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10418 
10419 	/* automatic parse from the BIOS config */
10420 	err = alc861_parse_auto_config(codec);
10421 	if (err < 0)
10422 		goto error;
10423 
10424 	if (!spec->gen.no_analog) {
10425 		err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
10426 		if (err < 0)
10427 			goto error;
10428 	}
10429 
10430 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10431 
10432 	return 0;
10433 
10434  error:
10435 	alc_free(codec);
10436 	return err;
10437 }
10438 
10439 /*
10440  * ALC861-VD support
10441  *
10442  * Based on ALC882
10443  *
10444  * In addition, an independent DAC
10445  */
alc861vd_parse_auto_config(struct hda_codec * codec)10446 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10447 {
10448 	static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10449 	static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10450 	return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
10451 }
10452 
10453 enum {
10454 	ALC660VD_FIX_ASUS_GPIO1,
10455 	ALC861VD_FIX_DALLAS,
10456 };
10457 
10458 /* exclude VREF80 */
alc861vd_fixup_dallas(struct hda_codec * codec,const struct hda_fixup * fix,int action)10459 static void alc861vd_fixup_dallas(struct hda_codec *codec,
10460 				  const struct hda_fixup *fix, int action)
10461 {
10462 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10463 		snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
10464 		snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
10465 	}
10466 }
10467 
10468 /* reset GPIO1 */
alc660vd_fixup_asus_gpio1(struct hda_codec * codec,const struct hda_fixup * fix,int action)10469 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
10470 				      const struct hda_fixup *fix, int action)
10471 {
10472 	struct alc_spec *spec = codec->spec;
10473 
10474 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
10475 		spec->gpio_mask |= 0x02;
10476 	alc_fixup_gpio(codec, action, 0x01);
10477 }
10478 
10479 static const struct hda_fixup alc861vd_fixups[] = {
10480 	[ALC660VD_FIX_ASUS_GPIO1] = {
10481 		.type = HDA_FIXUP_FUNC,
10482 		.v.func = alc660vd_fixup_asus_gpio1,
10483 	},
10484 	[ALC861VD_FIX_DALLAS] = {
10485 		.type = HDA_FIXUP_FUNC,
10486 		.v.func = alc861vd_fixup_dallas,
10487 	},
10488 };
10489 
10490 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
10491 	SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
10492 	SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
10493 	SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
10494 	{}
10495 };
10496 
10497 /*
10498  */
patch_alc861vd(struct hda_codec * codec)10499 static int patch_alc861vd(struct hda_codec *codec)
10500 {
10501 	struct alc_spec *spec;
10502 	int err;
10503 
10504 	err = alc_alloc_spec(codec, 0x0b);
10505 	if (err < 0)
10506 		return err;
10507 
10508 	spec = codec->spec;
10509 	if (has_cdefine_beep(codec))
10510 		spec->gen.beep_nid = 0x23;
10511 
10512 	spec->shutup = alc_eapd_shutup;
10513 
10514 	alc_pre_init(codec);
10515 
10516 	snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
10517 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10518 
10519 	/* automatic parse from the BIOS config */
10520 	err = alc861vd_parse_auto_config(codec);
10521 	if (err < 0)
10522 		goto error;
10523 
10524 	if (!spec->gen.no_analog) {
10525 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10526 		if (err < 0)
10527 			goto error;
10528 	}
10529 
10530 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10531 
10532 	return 0;
10533 
10534  error:
10535 	alc_free(codec);
10536 	return err;
10537 }
10538 
10539 /*
10540  * ALC662 support
10541  *
10542  * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10543  * configuration.  Each pin widget can choose any input DACs and a mixer.
10544  * Each ADC is connected from a mixer of all inputs.  This makes possible
10545  * 6-channel independent captures.
10546  *
10547  * In addition, an independent DAC for the multi-playback (not used in this
10548  * driver yet).
10549  */
10550 
10551 /*
10552  * BIOS auto configuration
10553  */
10554 
alc662_parse_auto_config(struct hda_codec * codec)10555 static int alc662_parse_auto_config(struct hda_codec *codec)
10556 {
10557 	static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10558 	static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
10559 	static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10560 	const hda_nid_t *ssids;
10561 
10562 	if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
10563 	    codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
10564 	    codec->core.vendor_id == 0x10ec0671)
10565 		ssids = alc663_ssids;
10566 	else
10567 		ssids = alc662_ssids;
10568 	return alc_parse_auto_config(codec, alc662_ignore, ssids);
10569 }
10570 
alc272_fixup_mario(struct hda_codec * codec,const struct hda_fixup * fix,int action)10571 static void alc272_fixup_mario(struct hda_codec *codec,
10572 			       const struct hda_fixup *fix, int action)
10573 {
10574 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
10575 		return;
10576 	if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
10577 				      (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
10578 				      (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
10579 				      (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10580 				      (0 << AC_AMPCAP_MUTE_SHIFT)))
10581 		codec_warn(codec, "failed to override amp caps for NID 0x2\n");
10582 }
10583 
10584 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
10585 	{ .channels = 2,
10586 	  .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
10587 	{ .channels = 4,
10588 	  .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
10589 		   SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
10590 	{ }
10591 };
10592 
10593 /* override the 2.1 chmap */
alc_fixup_bass_chmap(struct hda_codec * codec,const struct hda_fixup * fix,int action)10594 static void alc_fixup_bass_chmap(struct hda_codec *codec,
10595 				    const struct hda_fixup *fix, int action)
10596 {
10597 	if (action == HDA_FIXUP_ACT_BUILD) {
10598 		struct alc_spec *spec = codec->spec;
10599 		spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
10600 	}
10601 }
10602 
10603 /* avoid D3 for keeping GPIO up */
gpio_led_power_filter(struct hda_codec * codec,hda_nid_t nid,unsigned int power_state)10604 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
10605 					  hda_nid_t nid,
10606 					  unsigned int power_state)
10607 {
10608 	struct alc_spec *spec = codec->spec;
10609 	if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
10610 		return AC_PWRST_D0;
10611 	return power_state;
10612 }
10613 
alc662_fixup_led_gpio1(struct hda_codec * codec,const struct hda_fixup * fix,int action)10614 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
10615 				   const struct hda_fixup *fix, int action)
10616 {
10617 	struct alc_spec *spec = codec->spec;
10618 
10619 	alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
10620 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10621 		spec->mute_led_polarity = 1;
10622 		codec->power_filter = gpio_led_power_filter;
10623 	}
10624 }
10625 
alc662_usi_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)10626 static void alc662_usi_automute_hook(struct hda_codec *codec,
10627 					 struct hda_jack_callback *jack)
10628 {
10629 	struct alc_spec *spec = codec->spec;
10630 	int vref;
10631 	msleep(200);
10632 	snd_hda_gen_hp_automute(codec, jack);
10633 
10634 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
10635 	msleep(100);
10636 	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10637 			    vref);
10638 }
10639 
alc662_fixup_usi_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)10640 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
10641 				     const struct hda_fixup *fix, int action)
10642 {
10643 	struct alc_spec *spec = codec->spec;
10644 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10645 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10646 		spec->gen.hp_automute_hook = alc662_usi_automute_hook;
10647 	}
10648 }
10649 
alc662_aspire_ethos_mute_speakers(struct hda_codec * codec,struct hda_jack_callback * cb)10650 static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
10651 					struct hda_jack_callback *cb)
10652 {
10653 	/* surround speakers at 0x1b already get muted automatically when
10654 	 * headphones are plugged in, but we have to mute/unmute the remaining
10655 	 * channels manually:
10656 	 * 0x15 - front left/front right
10657 	 * 0x18 - front center/ LFE
10658 	 */
10659 	if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
10660 		snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
10661 		snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
10662 	} else {
10663 		snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
10664 		snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
10665 	}
10666 }
10667 
alc662_fixup_aspire_ethos_hp(struct hda_codec * codec,const struct hda_fixup * fix,int action)10668 static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
10669 					const struct hda_fixup *fix, int action)
10670 {
10671     /* Pin 0x1b: shared headphones jack and surround speakers */
10672 	if (!is_jack_detectable(codec, 0x1b))
10673 		return;
10674 
10675 	switch (action) {
10676 	case HDA_FIXUP_ACT_PRE_PROBE:
10677 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
10678 				alc662_aspire_ethos_mute_speakers);
10679 		/* subwoofer needs an extra GPIO setting to become audible */
10680 		alc_setup_gpio(codec, 0x02);
10681 		break;
10682 	case HDA_FIXUP_ACT_INIT:
10683 		/* Make sure to start in a correct state, i.e. if
10684 		 * headphones have been plugged in before powering up the system
10685 		 */
10686 		alc662_aspire_ethos_mute_speakers(codec, NULL);
10687 		break;
10688 	}
10689 }
10690 
alc671_fixup_hp_headset_mic2(struct hda_codec * codec,const struct hda_fixup * fix,int action)10691 static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
10692 					     const struct hda_fixup *fix, int action)
10693 {
10694 	struct alc_spec *spec = codec->spec;
10695 
10696 	static const struct hda_pintbl pincfgs[] = {
10697 		{ 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */
10698 		{ 0x1b, 0x0181304f },
10699 		{ }
10700 	};
10701 
10702 	switch (action) {
10703 	case HDA_FIXUP_ACT_PRE_PROBE:
10704 		spec->gen.mixer_nid = 0;
10705 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10706 		snd_hda_apply_pincfgs(codec, pincfgs);
10707 		break;
10708 	case HDA_FIXUP_ACT_INIT:
10709 		alc_write_coef_idx(codec, 0x19, 0xa054);
10710 		break;
10711 	}
10712 }
10713 
alc897_hp_automute_hook(struct hda_codec * codec,struct hda_jack_callback * jack)10714 static void alc897_hp_automute_hook(struct hda_codec *codec,
10715 					 struct hda_jack_callback *jack)
10716 {
10717 	struct alc_spec *spec = codec->spec;
10718 	int vref;
10719 
10720 	snd_hda_gen_hp_automute(codec, jack);
10721 	vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP;
10722 	snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10723 			    vref);
10724 }
10725 
alc897_fixup_lenovo_headset_mic(struct hda_codec * codec,const struct hda_fixup * fix,int action)10726 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
10727 				     const struct hda_fixup *fix, int action)
10728 {
10729 	struct alc_spec *spec = codec->spec;
10730 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10731 		spec->gen.hp_automute_hook = alc897_hp_automute_hook;
10732 	}
10733 }
10734 
alc897_fixup_lenovo_headset_mode(struct hda_codec * codec,const struct hda_fixup * fix,int action)10735 static void alc897_fixup_lenovo_headset_mode(struct hda_codec *codec,
10736 				     const struct hda_fixup *fix, int action)
10737 {
10738 	struct alc_spec *spec = codec->spec;
10739 
10740 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10741 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10742 		spec->gen.hp_automute_hook = alc897_hp_automute_hook;
10743 	}
10744 }
10745 
10746 static const struct coef_fw alc668_coefs[] = {
10747 	WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
10748 	WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
10749 	WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
10750 	WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
10751 	WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
10752 	WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
10753 	WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
10754 	WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
10755 	WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
10756 	WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
10757 	WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
10758 	WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
10759 	WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
10760 	WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
10761 	WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
10762 	WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
10763 	WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
10764 	WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
10765 	WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
10766 	WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
10767 	{}
10768 };
10769 
alc668_restore_default_value(struct hda_codec * codec)10770 static void alc668_restore_default_value(struct hda_codec *codec)
10771 {
10772 	alc_process_coef_fw(codec, alc668_coefs);
10773 }
10774 
10775 enum {
10776 	ALC662_FIXUP_ASPIRE,
10777 	ALC662_FIXUP_LED_GPIO1,
10778 	ALC662_FIXUP_IDEAPAD,
10779 	ALC272_FIXUP_MARIO,
10780 	ALC662_FIXUP_CZC_ET26,
10781 	ALC662_FIXUP_CZC_P10T,
10782 	ALC662_FIXUP_SKU_IGNORE,
10783 	ALC662_FIXUP_HP_RP5800,
10784 	ALC662_FIXUP_ASUS_MODE1,
10785 	ALC662_FIXUP_ASUS_MODE2,
10786 	ALC662_FIXUP_ASUS_MODE3,
10787 	ALC662_FIXUP_ASUS_MODE4,
10788 	ALC662_FIXUP_ASUS_MODE5,
10789 	ALC662_FIXUP_ASUS_MODE6,
10790 	ALC662_FIXUP_ASUS_MODE7,
10791 	ALC662_FIXUP_ASUS_MODE8,
10792 	ALC662_FIXUP_NO_JACK_DETECT,
10793 	ALC662_FIXUP_ZOTAC_Z68,
10794 	ALC662_FIXUP_INV_DMIC,
10795 	ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
10796 	ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
10797 	ALC662_FIXUP_HEADSET_MODE,
10798 	ALC668_FIXUP_HEADSET_MODE,
10799 	ALC662_FIXUP_BASS_MODE4_CHMAP,
10800 	ALC662_FIXUP_BASS_16,
10801 	ALC662_FIXUP_BASS_1A,
10802 	ALC662_FIXUP_BASS_CHMAP,
10803 	ALC668_FIXUP_AUTO_MUTE,
10804 	ALC668_FIXUP_DELL_DISABLE_AAMIX,
10805 	ALC668_FIXUP_DELL_XPS13,
10806 	ALC662_FIXUP_ASUS_Nx50,
10807 	ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10808 	ALC668_FIXUP_ASUS_Nx51,
10809 	ALC668_FIXUP_MIC_COEF,
10810 	ALC668_FIXUP_ASUS_G751,
10811 	ALC891_FIXUP_HEADSET_MODE,
10812 	ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10813 	ALC662_FIXUP_ACER_VERITON,
10814 	ALC892_FIXUP_ASROCK_MOBO,
10815 	ALC662_FIXUP_USI_FUNC,
10816 	ALC662_FIXUP_USI_HEADSET_MODE,
10817 	ALC662_FIXUP_LENOVO_MULTI_CODECS,
10818 	ALC669_FIXUP_ACER_ASPIRE_ETHOS,
10819 	ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET,
10820 	ALC671_FIXUP_HP_HEADSET_MIC2,
10821 	ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
10822 	ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
10823 	ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
10824 	ALC668_FIXUP_HEADSET_MIC,
10825 	ALC668_FIXUP_MIC_DET_COEF,
10826 	ALC897_FIXUP_LENOVO_HEADSET_MIC,
10827 	ALC897_FIXUP_HEADSET_MIC_PIN,
10828 	ALC897_FIXUP_HP_HSMIC_VERB,
10829 	ALC897_FIXUP_LENOVO_HEADSET_MODE,
10830 	ALC897_FIXUP_HEADSET_MIC_PIN2,
10831 	ALC897_FIXUP_UNIS_H3C_X500S,
10832 };
10833 
10834 static const struct hda_fixup alc662_fixups[] = {
10835 	[ALC662_FIXUP_ASPIRE] = {
10836 		.type = HDA_FIXUP_PINS,
10837 		.v.pins = (const struct hda_pintbl[]) {
10838 			{ 0x15, 0x99130112 }, /* subwoofer */
10839 			{ }
10840 		}
10841 	},
10842 	[ALC662_FIXUP_LED_GPIO1] = {
10843 		.type = HDA_FIXUP_FUNC,
10844 		.v.func = alc662_fixup_led_gpio1,
10845 	},
10846 	[ALC662_FIXUP_IDEAPAD] = {
10847 		.type = HDA_FIXUP_PINS,
10848 		.v.pins = (const struct hda_pintbl[]) {
10849 			{ 0x17, 0x99130112 }, /* subwoofer */
10850 			{ }
10851 		},
10852 		.chained = true,
10853 		.chain_id = ALC662_FIXUP_LED_GPIO1,
10854 	},
10855 	[ALC272_FIXUP_MARIO] = {
10856 		.type = HDA_FIXUP_FUNC,
10857 		.v.func = alc272_fixup_mario,
10858 	},
10859 	[ALC662_FIXUP_CZC_ET26] = {
10860 		.type = HDA_FIXUP_PINS,
10861 		.v.pins = (const struct hda_pintbl[]) {
10862 			{0x12, 0x403cc000},
10863 			{0x14, 0x90170110}, /* speaker */
10864 			{0x15, 0x411111f0},
10865 			{0x16, 0x411111f0},
10866 			{0x18, 0x01a19030}, /* mic */
10867 			{0x19, 0x90a7013f}, /* int-mic */
10868 			{0x1a, 0x01014020},
10869 			{0x1b, 0x0121401f},
10870 			{0x1c, 0x411111f0},
10871 			{0x1d, 0x411111f0},
10872 			{0x1e, 0x40478e35},
10873 			{}
10874 		},
10875 		.chained = true,
10876 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10877 	},
10878 	[ALC662_FIXUP_CZC_P10T] = {
10879 		.type = HDA_FIXUP_VERBS,
10880 		.v.verbs = (const struct hda_verb[]) {
10881 			{0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
10882 			{}
10883 		}
10884 	},
10885 	[ALC662_FIXUP_SKU_IGNORE] = {
10886 		.type = HDA_FIXUP_FUNC,
10887 		.v.func = alc_fixup_sku_ignore,
10888 	},
10889 	[ALC662_FIXUP_HP_RP5800] = {
10890 		.type = HDA_FIXUP_PINS,
10891 		.v.pins = (const struct hda_pintbl[]) {
10892 			{ 0x14, 0x0221201f }, /* HP out */
10893 			{ }
10894 		},
10895 		.chained = true,
10896 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10897 	},
10898 	[ALC662_FIXUP_ASUS_MODE1] = {
10899 		.type = HDA_FIXUP_PINS,
10900 		.v.pins = (const struct hda_pintbl[]) {
10901 			{ 0x14, 0x99130110 }, /* speaker */
10902 			{ 0x18, 0x01a19c20 }, /* mic */
10903 			{ 0x19, 0x99a3092f }, /* int-mic */
10904 			{ 0x21, 0x0121401f }, /* HP out */
10905 			{ }
10906 		},
10907 		.chained = true,
10908 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10909 	},
10910 	[ALC662_FIXUP_ASUS_MODE2] = {
10911 		.type = HDA_FIXUP_PINS,
10912 		.v.pins = (const struct hda_pintbl[]) {
10913 			{ 0x14, 0x99130110 }, /* speaker */
10914 			{ 0x18, 0x01a19820 }, /* mic */
10915 			{ 0x19, 0x99a3092f }, /* int-mic */
10916 			{ 0x1b, 0x0121401f }, /* HP out */
10917 			{ }
10918 		},
10919 		.chained = true,
10920 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10921 	},
10922 	[ALC662_FIXUP_ASUS_MODE3] = {
10923 		.type = HDA_FIXUP_PINS,
10924 		.v.pins = (const struct hda_pintbl[]) {
10925 			{ 0x14, 0x99130110 }, /* speaker */
10926 			{ 0x15, 0x0121441f }, /* HP */
10927 			{ 0x18, 0x01a19840 }, /* mic */
10928 			{ 0x19, 0x99a3094f }, /* int-mic */
10929 			{ 0x21, 0x01211420 }, /* HP2 */
10930 			{ }
10931 		},
10932 		.chained = true,
10933 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10934 	},
10935 	[ALC662_FIXUP_ASUS_MODE4] = {
10936 		.type = HDA_FIXUP_PINS,
10937 		.v.pins = (const struct hda_pintbl[]) {
10938 			{ 0x14, 0x99130110 }, /* speaker */
10939 			{ 0x16, 0x99130111 }, /* speaker */
10940 			{ 0x18, 0x01a19840 }, /* mic */
10941 			{ 0x19, 0x99a3094f }, /* int-mic */
10942 			{ 0x21, 0x0121441f }, /* HP */
10943 			{ }
10944 		},
10945 		.chained = true,
10946 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10947 	},
10948 	[ALC662_FIXUP_ASUS_MODE5] = {
10949 		.type = HDA_FIXUP_PINS,
10950 		.v.pins = (const struct hda_pintbl[]) {
10951 			{ 0x14, 0x99130110 }, /* speaker */
10952 			{ 0x15, 0x0121441f }, /* HP */
10953 			{ 0x16, 0x99130111 }, /* speaker */
10954 			{ 0x18, 0x01a19840 }, /* mic */
10955 			{ 0x19, 0x99a3094f }, /* int-mic */
10956 			{ }
10957 		},
10958 		.chained = true,
10959 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10960 	},
10961 	[ALC662_FIXUP_ASUS_MODE6] = {
10962 		.type = HDA_FIXUP_PINS,
10963 		.v.pins = (const struct hda_pintbl[]) {
10964 			{ 0x14, 0x99130110 }, /* speaker */
10965 			{ 0x15, 0x01211420 }, /* HP2 */
10966 			{ 0x18, 0x01a19840 }, /* mic */
10967 			{ 0x19, 0x99a3094f }, /* int-mic */
10968 			{ 0x1b, 0x0121441f }, /* HP */
10969 			{ }
10970 		},
10971 		.chained = true,
10972 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10973 	},
10974 	[ALC662_FIXUP_ASUS_MODE7] = {
10975 		.type = HDA_FIXUP_PINS,
10976 		.v.pins = (const struct hda_pintbl[]) {
10977 			{ 0x14, 0x99130110 }, /* speaker */
10978 			{ 0x17, 0x99130111 }, /* speaker */
10979 			{ 0x18, 0x01a19840 }, /* mic */
10980 			{ 0x19, 0x99a3094f }, /* int-mic */
10981 			{ 0x1b, 0x01214020 }, /* HP */
10982 			{ 0x21, 0x0121401f }, /* HP */
10983 			{ }
10984 		},
10985 		.chained = true,
10986 		.chain_id = ALC662_FIXUP_SKU_IGNORE
10987 	},
10988 	[ALC662_FIXUP_ASUS_MODE8] = {
10989 		.type = HDA_FIXUP_PINS,
10990 		.v.pins = (const struct hda_pintbl[]) {
10991 			{ 0x14, 0x99130110 }, /* speaker */
10992 			{ 0x12, 0x99a30970 }, /* int-mic */
10993 			{ 0x15, 0x01214020 }, /* HP */
10994 			{ 0x17, 0x99130111 }, /* speaker */
10995 			{ 0x18, 0x01a19840 }, /* mic */
10996 			{ 0x21, 0x0121401f }, /* HP */
10997 			{ }
10998 		},
10999 		.chained = true,
11000 		.chain_id = ALC662_FIXUP_SKU_IGNORE
11001 	},
11002 	[ALC662_FIXUP_NO_JACK_DETECT] = {
11003 		.type = HDA_FIXUP_FUNC,
11004 		.v.func = alc_fixup_no_jack_detect,
11005 	},
11006 	[ALC662_FIXUP_ZOTAC_Z68] = {
11007 		.type = HDA_FIXUP_PINS,
11008 		.v.pins = (const struct hda_pintbl[]) {
11009 			{ 0x1b, 0x02214020 }, /* Front HP */
11010 			{ }
11011 		}
11012 	},
11013 	[ALC662_FIXUP_INV_DMIC] = {
11014 		.type = HDA_FIXUP_FUNC,
11015 		.v.func = alc_fixup_inv_dmic,
11016 	},
11017 	[ALC668_FIXUP_DELL_XPS13] = {
11018 		.type = HDA_FIXUP_FUNC,
11019 		.v.func = alc_fixup_dell_xps13,
11020 		.chained = true,
11021 		.chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
11022 	},
11023 	[ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
11024 		.type = HDA_FIXUP_FUNC,
11025 		.v.func = alc_fixup_disable_aamix,
11026 		.chained = true,
11027 		.chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
11028 	},
11029 	[ALC668_FIXUP_AUTO_MUTE] = {
11030 		.type = HDA_FIXUP_FUNC,
11031 		.v.func = alc_fixup_auto_mute_via_amp,
11032 		.chained = true,
11033 		.chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
11034 	},
11035 	[ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
11036 		.type = HDA_FIXUP_PINS,
11037 		.v.pins = (const struct hda_pintbl[]) {
11038 			{ 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11039 			/* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
11040 			{ }
11041 		},
11042 		.chained = true,
11043 		.chain_id = ALC662_FIXUP_HEADSET_MODE
11044 	},
11045 	[ALC662_FIXUP_HEADSET_MODE] = {
11046 		.type = HDA_FIXUP_FUNC,
11047 		.v.func = alc_fixup_headset_mode_alc662,
11048 	},
11049 	[ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
11050 		.type = HDA_FIXUP_PINS,
11051 		.v.pins = (const struct hda_pintbl[]) {
11052 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
11053 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11054 			{ }
11055 		},
11056 		.chained = true,
11057 		.chain_id = ALC668_FIXUP_HEADSET_MODE
11058 	},
11059 	[ALC668_FIXUP_HEADSET_MODE] = {
11060 		.type = HDA_FIXUP_FUNC,
11061 		.v.func = alc_fixup_headset_mode_alc668,
11062 	},
11063 	[ALC662_FIXUP_BASS_MODE4_CHMAP] = {
11064 		.type = HDA_FIXUP_FUNC,
11065 		.v.func = alc_fixup_bass_chmap,
11066 		.chained = true,
11067 		.chain_id = ALC662_FIXUP_ASUS_MODE4
11068 	},
11069 	[ALC662_FIXUP_BASS_16] = {
11070 		.type = HDA_FIXUP_PINS,
11071 		.v.pins = (const struct hda_pintbl[]) {
11072 			{0x16, 0x80106111}, /* bass speaker */
11073 			{}
11074 		},
11075 		.chained = true,
11076 		.chain_id = ALC662_FIXUP_BASS_CHMAP,
11077 	},
11078 	[ALC662_FIXUP_BASS_1A] = {
11079 		.type = HDA_FIXUP_PINS,
11080 		.v.pins = (const struct hda_pintbl[]) {
11081 			{0x1a, 0x80106111}, /* bass speaker */
11082 			{}
11083 		},
11084 		.chained = true,
11085 		.chain_id = ALC662_FIXUP_BASS_CHMAP,
11086 	},
11087 	[ALC662_FIXUP_BASS_CHMAP] = {
11088 		.type = HDA_FIXUP_FUNC,
11089 		.v.func = alc_fixup_bass_chmap,
11090 	},
11091 	[ALC662_FIXUP_ASUS_Nx50] = {
11092 		.type = HDA_FIXUP_FUNC,
11093 		.v.func = alc_fixup_auto_mute_via_amp,
11094 		.chained = true,
11095 		.chain_id = ALC662_FIXUP_BASS_1A
11096 	},
11097 	[ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
11098 		.type = HDA_FIXUP_FUNC,
11099 		.v.func = alc_fixup_headset_mode_alc668,
11100 		.chain_id = ALC662_FIXUP_BASS_CHMAP
11101 	},
11102 	[ALC668_FIXUP_ASUS_Nx51] = {
11103 		.type = HDA_FIXUP_PINS,
11104 		.v.pins = (const struct hda_pintbl[]) {
11105 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
11106 			{ 0x1a, 0x90170151 }, /* bass speaker */
11107 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11108 			{}
11109 		},
11110 		.chained = true,
11111 		.chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
11112 	},
11113 	[ALC668_FIXUP_MIC_COEF] = {
11114 		.type = HDA_FIXUP_VERBS,
11115 		.v.verbs = (const struct hda_verb[]) {
11116 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
11117 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
11118 			{}
11119 		},
11120 	},
11121 	[ALC668_FIXUP_ASUS_G751] = {
11122 		.type = HDA_FIXUP_PINS,
11123 		.v.pins = (const struct hda_pintbl[]) {
11124 			{ 0x16, 0x0421101f }, /* HP */
11125 			{}
11126 		},
11127 		.chained = true,
11128 		.chain_id = ALC668_FIXUP_MIC_COEF
11129 	},
11130 	[ALC891_FIXUP_HEADSET_MODE] = {
11131 		.type = HDA_FIXUP_FUNC,
11132 		.v.func = alc_fixup_headset_mode,
11133 	},
11134 	[ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
11135 		.type = HDA_FIXUP_PINS,
11136 		.v.pins = (const struct hda_pintbl[]) {
11137 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
11138 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
11139 			{ }
11140 		},
11141 		.chained = true,
11142 		.chain_id = ALC891_FIXUP_HEADSET_MODE
11143 	},
11144 	[ALC662_FIXUP_ACER_VERITON] = {
11145 		.type = HDA_FIXUP_PINS,
11146 		.v.pins = (const struct hda_pintbl[]) {
11147 			{ 0x15, 0x50170120 }, /* no internal speaker */
11148 			{ }
11149 		}
11150 	},
11151 	[ALC892_FIXUP_ASROCK_MOBO] = {
11152 		.type = HDA_FIXUP_PINS,
11153 		.v.pins = (const struct hda_pintbl[]) {
11154 			{ 0x15, 0x40f000f0 }, /* disabled */
11155 			{ 0x16, 0x40f000f0 }, /* disabled */
11156 			{ }
11157 		}
11158 	},
11159 	[ALC662_FIXUP_USI_FUNC] = {
11160 		.type = HDA_FIXUP_FUNC,
11161 		.v.func = alc662_fixup_usi_headset_mic,
11162 	},
11163 	[ALC662_FIXUP_USI_HEADSET_MODE] = {
11164 		.type = HDA_FIXUP_PINS,
11165 		.v.pins = (const struct hda_pintbl[]) {
11166 			{ 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
11167 			{ 0x18, 0x01a1903d },
11168 			{ }
11169 		},
11170 		.chained = true,
11171 		.chain_id = ALC662_FIXUP_USI_FUNC
11172 	},
11173 	[ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
11174 		.type = HDA_FIXUP_FUNC,
11175 		.v.func = alc233_alc662_fixup_lenovo_dual_codecs,
11176 	},
11177 	[ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET] = {
11178 		.type = HDA_FIXUP_FUNC,
11179 		.v.func = alc662_fixup_aspire_ethos_hp,
11180 	},
11181 	[ALC669_FIXUP_ACER_ASPIRE_ETHOS] = {
11182 		.type = HDA_FIXUP_PINS,
11183 		.v.pins = (const struct hda_pintbl[]) {
11184 			{ 0x15, 0x92130110 }, /* front speakers */
11185 			{ 0x18, 0x99130111 }, /* center/subwoofer */
11186 			{ 0x1b, 0x11130012 }, /* surround plus jack for HP */
11187 			{ }
11188 		},
11189 		.chained = true,
11190 		.chain_id = ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET
11191 	},
11192 	[ALC671_FIXUP_HP_HEADSET_MIC2] = {
11193 		.type = HDA_FIXUP_FUNC,
11194 		.v.func = alc671_fixup_hp_headset_mic2,
11195 	},
11196 	[ALC662_FIXUP_ACER_X2660G_HEADSET_MODE] = {
11197 		.type = HDA_FIXUP_PINS,
11198 		.v.pins = (const struct hda_pintbl[]) {
11199 			{ 0x1a, 0x02a1113c }, /* use as headset mic, without its own jack detect */
11200 			{ }
11201 		},
11202 		.chained = true,
11203 		.chain_id = ALC662_FIXUP_USI_FUNC
11204 	},
11205 	[ALC662_FIXUP_ACER_NITRO_HEADSET_MODE] = {
11206 		.type = HDA_FIXUP_PINS,
11207 		.v.pins = (const struct hda_pintbl[]) {
11208 			{ 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
11209 			{ 0x1b, 0x0221144f },
11210 			{ }
11211 		},
11212 		.chained = true,
11213 		.chain_id = ALC662_FIXUP_USI_FUNC
11214 	},
11215 	[ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
11216 		.type = HDA_FIXUP_PINS,
11217 		.v.pins = (const struct hda_pintbl[]) {
11218 			{ 0x1b, 0x04a1112c },
11219 			{ }
11220 		},
11221 		.chained = true,
11222 		.chain_id = ALC668_FIXUP_HEADSET_MIC
11223 	},
11224 	[ALC668_FIXUP_HEADSET_MIC] = {
11225 		.type = HDA_FIXUP_FUNC,
11226 		.v.func = alc269_fixup_headset_mic,
11227 		.chained = true,
11228 		.chain_id = ALC668_FIXUP_MIC_DET_COEF
11229 	},
11230 	[ALC668_FIXUP_MIC_DET_COEF] = {
11231 		.type = HDA_FIXUP_VERBS,
11232 		.v.verbs = (const struct hda_verb[]) {
11233 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
11234 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
11235 			{}
11236 		},
11237 	},
11238 	[ALC897_FIXUP_LENOVO_HEADSET_MIC] = {
11239 		.type = HDA_FIXUP_FUNC,
11240 		.v.func = alc897_fixup_lenovo_headset_mic,
11241 	},
11242 	[ALC897_FIXUP_HEADSET_MIC_PIN] = {
11243 		.type = HDA_FIXUP_PINS,
11244 		.v.pins = (const struct hda_pintbl[]) {
11245 			{ 0x1a, 0x03a11050 },
11246 			{ }
11247 		},
11248 		.chained = true,
11249 		.chain_id = ALC897_FIXUP_LENOVO_HEADSET_MIC
11250 	},
11251 	[ALC897_FIXUP_HP_HSMIC_VERB] = {
11252 		.type = HDA_FIXUP_PINS,
11253 		.v.pins = (const struct hda_pintbl[]) {
11254 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
11255 			{ }
11256 		},
11257 	},
11258 	[ALC897_FIXUP_LENOVO_HEADSET_MODE] = {
11259 		.type = HDA_FIXUP_FUNC,
11260 		.v.func = alc897_fixup_lenovo_headset_mode,
11261 	},
11262 	[ALC897_FIXUP_HEADSET_MIC_PIN2] = {
11263 		.type = HDA_FIXUP_PINS,
11264 		.v.pins = (const struct hda_pintbl[]) {
11265 			{ 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
11266 			{ }
11267 		},
11268 		.chained = true,
11269 		.chain_id = ALC897_FIXUP_LENOVO_HEADSET_MODE
11270 	},
11271 	[ALC897_FIXUP_UNIS_H3C_X500S] = {
11272 		.type = HDA_FIXUP_VERBS,
11273 		.v.verbs = (const struct hda_verb[]) {
11274 			{ 0x14, AC_VERB_SET_EAPD_BTLENABLE, 0 },
11275 			{}
11276 		},
11277 	},
11278 };
11279 
11280 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
11281 	SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
11282 	SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
11283 	SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
11284 	SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
11285 	SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
11286 	SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
11287 	SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
11288 	SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
11289 	SND_PCI_QUIRK(0x1025, 0x0566, "Acer Aspire Ethos 8951G", ALC669_FIXUP_ACER_ASPIRE_ETHOS),
11290 	SND_PCI_QUIRK(0x1025, 0x123c, "Acer Nitro N50-600", ALC662_FIXUP_ACER_NITRO_HEADSET_MODE),
11291 	SND_PCI_QUIRK(0x1025, 0x124e, "Acer 2660G", ALC662_FIXUP_ACER_X2660G_HEADSET_MODE),
11292 	SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11293 	SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11294 	SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
11295 	SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
11296 	SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
11297 	SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11298 	SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11299 	SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11300 	SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11301 	SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11302 	SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
11303 	SND_PCI_QUIRK(0x103c, 0x870c, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
11304 	SND_PCI_QUIRK(0x103c, 0x8719, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
11305 	SND_PCI_QUIRK(0x103c, 0x872b, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
11306 	SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
11307 	SND_PCI_QUIRK(0x103c, 0x8768, "HP Slim Desktop S01", ALC671_FIXUP_HP_HEADSET_MIC2),
11308 	SND_PCI_QUIRK(0x103c, 0x877e, "HP 288 Pro G6", ALC671_FIXUP_HP_HEADSET_MIC2),
11309 	SND_PCI_QUIRK(0x103c, 0x885f, "HP 288 Pro G8", ALC671_FIXUP_HP_HEADSET_MIC2),
11310 	SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
11311 	SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
11312 	SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
11313 	SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
11314 	SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
11315 	SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
11316 	SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
11317 	SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
11318 	SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
11319 	SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
11320 	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
11321 	SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
11322 	SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
11323 	SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
11324 	SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
11325 	SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
11326 	SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
11327 	SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
11328 	SND_PCI_QUIRK(0x17aa, 0x1057, "Lenovo P360", ALC897_FIXUP_HEADSET_MIC_PIN),
11329 	SND_PCI_QUIRK(0x17aa, 0x1064, "Lenovo P3 Tower", ALC897_FIXUP_HEADSET_MIC_PIN),
11330 	SND_PCI_QUIRK(0x17aa, 0x32ca, "Lenovo ThinkCentre M80", ALC897_FIXUP_HEADSET_MIC_PIN),
11331 	SND_PCI_QUIRK(0x17aa, 0x32cb, "Lenovo ThinkCentre M70", ALC897_FIXUP_HEADSET_MIC_PIN),
11332 	SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN),
11333 	SND_PCI_QUIRK(0x17aa, 0x32f7, "Lenovo ThinkCentre M90", ALC897_FIXUP_HEADSET_MIC_PIN),
11334 	SND_PCI_QUIRK(0x17aa, 0x3321, "Lenovo ThinkCentre M70 Gen4", ALC897_FIXUP_HEADSET_MIC_PIN),
11335 	SND_PCI_QUIRK(0x17aa, 0x331b, "Lenovo ThinkCentre M90 Gen4", ALC897_FIXUP_HEADSET_MIC_PIN),
11336 	SND_PCI_QUIRK(0x17aa, 0x3364, "Lenovo ThinkCentre M90 Gen5", ALC897_FIXUP_HEADSET_MIC_PIN),
11337 	SND_PCI_QUIRK(0x17aa, 0x3742, "Lenovo TianYi510Pro-14IOB", ALC897_FIXUP_HEADSET_MIC_PIN2),
11338 	SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
11339 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
11340 	SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
11341 	SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
11342 	SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
11343 	SND_PCI_QUIRK(0x1b35, 0x1234, "CZC ET26", ALC662_FIXUP_CZC_ET26),
11344 	SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
11345 	SND_PCI_QUIRK(0x1c6c, 0x1239, "Compaq N14JP6-V2", ALC897_FIXUP_HP_HSMIC_VERB),
11346 
11347 #if 0
11348 	/* Below is a quirk table taken from the old code.
11349 	 * Basically the device should work as is without the fixup table.
11350 	 * If BIOS doesn't give a proper info, enable the corresponding
11351 	 * fixup entry.
11352 	 */
11353 	SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
11354 	SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
11355 	SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
11356 	SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
11357 	SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11358 	SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11359 	SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11360 	SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
11361 	SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
11362 	SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11363 	SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
11364 	SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
11365 	SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
11366 	SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
11367 	SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
11368 	SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11369 	SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
11370 	SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
11371 	SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11372 	SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11373 	SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11374 	SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11375 	SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
11376 	SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
11377 	SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
11378 	SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11379 	SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
11380 	SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11381 	SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11382 	SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
11383 	SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11384 	SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11385 	SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
11386 	SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
11387 	SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
11388 	SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
11389 	SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
11390 	SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
11391 	SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
11392 	SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11393 	SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
11394 	SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
11395 	SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11396 	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
11397 	SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
11398 	SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
11399 	SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
11400 	SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
11401 	SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11402 	SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
11403 #endif
11404 	{}
11405 };
11406 
11407 static const struct hda_model_fixup alc662_fixup_models[] = {
11408 	{.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
11409 	{.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
11410 	{.id = ALC272_FIXUP_MARIO, .name = "mario"},
11411 	{.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
11412 	{.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
11413 	{.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
11414 	{.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
11415 	{.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
11416 	{.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
11417 	{.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
11418 	{.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
11419 	{.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
11420 	{.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
11421 	{.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
11422 	{.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
11423 	{.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
11424 	{.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
11425 	{.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
11426 	{.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
11427 	{.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
11428 	{.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
11429 	{.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
11430 	{.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
11431 	{.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
11432 	{.id = ALC668_FIXUP_ASUS_G751, .name = "asus-g751"},
11433 	{.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
11434 	{.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
11435 	{.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
11436 	{.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
11437 	{.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
11438 	{.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
11439 	{.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
11440 	{.id = ALC897_FIXUP_UNIS_H3C_X500S, .name = "unis-h3c-x500s"},
11441 	{}
11442 };
11443 
11444 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
11445 	SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
11446 		{0x17, 0x02211010},
11447 		{0x18, 0x01a19030},
11448 		{0x1a, 0x01813040},
11449 		{0x21, 0x01014020}),
11450 	SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
11451 		{0x16, 0x01813030},
11452 		{0x17, 0x02211010},
11453 		{0x18, 0x01a19040},
11454 		{0x21, 0x01014020}),
11455 	SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
11456 		{0x14, 0x01014010},
11457 		{0x18, 0x01a19020},
11458 		{0x1a, 0x0181302f},
11459 		{0x1b, 0x0221401f}),
11460 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11461 		{0x12, 0x99a30130},
11462 		{0x14, 0x90170110},
11463 		{0x15, 0x0321101f},
11464 		{0x16, 0x03011020}),
11465 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11466 		{0x12, 0x99a30140},
11467 		{0x14, 0x90170110},
11468 		{0x15, 0x0321101f},
11469 		{0x16, 0x03011020}),
11470 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11471 		{0x12, 0x99a30150},
11472 		{0x14, 0x90170110},
11473 		{0x15, 0x0321101f},
11474 		{0x16, 0x03011020}),
11475 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11476 		{0x14, 0x90170110},
11477 		{0x15, 0x0321101f},
11478 		{0x16, 0x03011020}),
11479 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
11480 		{0x12, 0x90a60130},
11481 		{0x14, 0x90170110},
11482 		{0x15, 0x0321101f}),
11483 	SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11484 		{0x14, 0x01014010},
11485 		{0x17, 0x90170150},
11486 		{0x19, 0x02a11060},
11487 		{0x1b, 0x01813030},
11488 		{0x21, 0x02211020}),
11489 	SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11490 		{0x14, 0x01014010},
11491 		{0x18, 0x01a19040},
11492 		{0x1b, 0x01813030},
11493 		{0x21, 0x02211020}),
11494 	SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11495 		{0x14, 0x01014020},
11496 		{0x17, 0x90170110},
11497 		{0x18, 0x01a19050},
11498 		{0x1b, 0x01813040},
11499 		{0x21, 0x02211030}),
11500 	{}
11501 };
11502 
11503 /*
11504  */
patch_alc662(struct hda_codec * codec)11505 static int patch_alc662(struct hda_codec *codec)
11506 {
11507 	struct alc_spec *spec;
11508 	int err;
11509 
11510 	err = alc_alloc_spec(codec, 0x0b);
11511 	if (err < 0)
11512 		return err;
11513 
11514 	spec = codec->spec;
11515 
11516 	spec->shutup = alc_eapd_shutup;
11517 
11518 	/* handle multiple HPs as is */
11519 	spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
11520 
11521 	alc_fix_pll_init(codec, 0x20, 0x04, 15);
11522 
11523 	switch (codec->core.vendor_id) {
11524 	case 0x10ec0668:
11525 		spec->init_hook = alc668_restore_default_value;
11526 		break;
11527 	}
11528 
11529 	alc_pre_init(codec);
11530 
11531 	snd_hda_pick_fixup(codec, alc662_fixup_models,
11532 		       alc662_fixup_tbl, alc662_fixups);
11533 	snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
11534 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11535 
11536 	alc_auto_parse_customize_define(codec);
11537 
11538 	if (has_cdefine_beep(codec))
11539 		spec->gen.beep_nid = 0x01;
11540 
11541 	if ((alc_get_coef0(codec) & (1 << 14)) &&
11542 	    codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
11543 	    spec->cdefine.platform_type == 1) {
11544 		err = alc_codec_rename(codec, "ALC272X");
11545 		if (err < 0)
11546 			goto error;
11547 	}
11548 
11549 	/* automatic parse from the BIOS config */
11550 	err = alc662_parse_auto_config(codec);
11551 	if (err < 0)
11552 		goto error;
11553 
11554 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
11555 		switch (codec->core.vendor_id) {
11556 		case 0x10ec0662:
11557 			err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11558 			break;
11559 		case 0x10ec0272:
11560 		case 0x10ec0663:
11561 		case 0x10ec0665:
11562 		case 0x10ec0668:
11563 			err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
11564 			break;
11565 		case 0x10ec0273:
11566 			err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
11567 			break;
11568 		}
11569 		if (err < 0)
11570 			goto error;
11571 	}
11572 
11573 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11574 
11575 	return 0;
11576 
11577  error:
11578 	alc_free(codec);
11579 	return err;
11580 }
11581 
11582 /*
11583  * ALC680 support
11584  */
11585 
alc680_parse_auto_config(struct hda_codec * codec)11586 static int alc680_parse_auto_config(struct hda_codec *codec)
11587 {
11588 	return alc_parse_auto_config(codec, NULL, NULL);
11589 }
11590 
11591 /*
11592  */
patch_alc680(struct hda_codec * codec)11593 static int patch_alc680(struct hda_codec *codec)
11594 {
11595 	int err;
11596 
11597 	/* ALC680 has no aa-loopback mixer */
11598 	err = alc_alloc_spec(codec, 0);
11599 	if (err < 0)
11600 		return err;
11601 
11602 	/* automatic parse from the BIOS config */
11603 	err = alc680_parse_auto_config(codec);
11604 	if (err < 0) {
11605 		alc_free(codec);
11606 		return err;
11607 	}
11608 
11609 	return 0;
11610 }
11611 
11612 /*
11613  * patch entries
11614  */
11615 static const struct hda_device_id snd_hda_id_realtek[] = {
11616 	HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
11617 	HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
11618 	HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
11619 	HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
11620 	HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
11621 	HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
11622 	HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
11623 	HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
11624 	HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
11625 	HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
11626 	HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
11627 	HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
11628 	HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
11629 	HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
11630 	HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
11631 	HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
11632 	HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
11633 	HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
11634 	HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
11635 	HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
11636 	HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
11637 	HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
11638 	HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
11639 	HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
11640 	HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
11641 	HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
11642 	HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
11643 	HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
11644 	HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
11645 	HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
11646 	HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
11647 	HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
11648 	HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
11649 	HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
11650 	HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
11651 	HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
11652 	HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
11653 	HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
11654 	HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
11655 	HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
11656 	HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
11657 	HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
11658 	HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
11659 	HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
11660 	HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
11661 	HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
11662 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
11663 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
11664 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
11665 	HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
11666 	HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
11667 	HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
11668 	HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
11669 	HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
11670 	HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
11671 	HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
11672 	HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
11673 	HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
11674 	HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
11675 	HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
11676 	HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
11677 	HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
11678 	HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
11679 	HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
11680 	HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
11681 	HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
11682 	HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
11683 	HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
11684 	HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
11685 	HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
11686 	HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
11687 	HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
11688 	HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
11689 	HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
11690 	HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
11691 	HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
11692 	HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
11693 	HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
11694 	HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269),
11695 	{} /* terminator */
11696 };
11697 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
11698 
11699 MODULE_LICENSE("GPL");
11700 MODULE_DESCRIPTION("Realtek HD-audio codec");
11701 
11702 static struct hda_codec_driver realtek_driver = {
11703 	.id = snd_hda_id_realtek,
11704 };
11705 
11706 module_hda_codec_driver(realtek_driver);
11707