xref: /openbmc/linux/sound/pci/hda/patch_realtek.c (revision 3ac14b39)
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * HD audio interface patch for Realtek ALC codecs
5  *
6  * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7  *                    PeiSen Hou <pshou@realtek.com.tw>
8  *                    Takashi Iwai <tiwai@suse.de>
9  *                    Jonathan Woithe <jwoithe@just42.net>
10  *
11  *  This driver is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This driver is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24  */
25 
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/dmi.h>
31 #include <linux/module.h>
32 #include <linux/input.h>
33 #include <sound/core.h>
34 #include <sound/jack.h>
35 #include "hda_codec.h"
36 #include "hda_local.h"
37 #include "hda_auto_parser.h"
38 #include "hda_jack.h"
39 #include "hda_generic.h"
40 
41 /* keep halting ALC5505 DSP, for power saving */
42 #define HALT_REALTEK_ALC5505
43 
44 /* extra amp-initialization sequence types */
45 enum {
46 	ALC_INIT_UNDEFINED,
47 	ALC_INIT_NONE,
48 	ALC_INIT_DEFAULT,
49 };
50 
51 enum {
52 	ALC_HEADSET_MODE_UNKNOWN,
53 	ALC_HEADSET_MODE_UNPLUGGED,
54 	ALC_HEADSET_MODE_HEADSET,
55 	ALC_HEADSET_MODE_MIC,
56 	ALC_HEADSET_MODE_HEADPHONE,
57 };
58 
59 enum {
60 	ALC_HEADSET_TYPE_UNKNOWN,
61 	ALC_HEADSET_TYPE_CTIA,
62 	ALC_HEADSET_TYPE_OMTP,
63 };
64 
65 enum {
66 	ALC_KEY_MICMUTE_INDEX,
67 };
68 
69 struct alc_customize_define {
70 	unsigned int  sku_cfg;
71 	unsigned char port_connectivity;
72 	unsigned char check_sum;
73 	unsigned char customization;
74 	unsigned char external_amp;
75 	unsigned int  enable_pcbeep:1;
76 	unsigned int  platform_type:1;
77 	unsigned int  swap:1;
78 	unsigned int  override:1;
79 	unsigned int  fixup:1; /* Means that this sku is set by driver, not read from hw */
80 };
81 
82 struct alc_spec {
83 	struct hda_gen_spec gen; /* must be at head */
84 
85 	/* codec parameterization */
86 	struct alc_customize_define cdefine;
87 	unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
88 
89 	/* GPIO bits */
90 	unsigned int gpio_mask;
91 	unsigned int gpio_dir;
92 	unsigned int gpio_data;
93 	bool gpio_write_delay;	/* add a delay before writing gpio_data */
94 
95 	/* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
96 	int mute_led_polarity;
97 	hda_nid_t mute_led_nid;
98 	hda_nid_t cap_mute_led_nid;
99 
100 	unsigned int gpio_mute_led_mask;
101 	unsigned int gpio_mic_led_mask;
102 
103 	hda_nid_t headset_mic_pin;
104 	hda_nid_t headphone_mic_pin;
105 	int current_headset_mode;
106 	int current_headset_type;
107 
108 	/* hooks */
109 	void (*init_hook)(struct hda_codec *codec);
110 #ifdef CONFIG_PM
111 	void (*power_hook)(struct hda_codec *codec);
112 #endif
113 	void (*shutup)(struct hda_codec *codec);
114 	void (*reboot_notify)(struct hda_codec *codec);
115 
116 	int init_amp;
117 	int codec_variant;	/* flag for other variants */
118 	unsigned int has_alc5505_dsp:1;
119 	unsigned int no_depop_delay:1;
120 
121 	/* for PLL fix */
122 	hda_nid_t pll_nid;
123 	unsigned int pll_coef_idx, pll_coef_bit;
124 	unsigned int coef0;
125 	struct input_dev *kb_dev;
126 	u8 alc_mute_keycode_map[1];
127 };
128 
129 /*
130  * COEF access helper functions
131  */
132 
133 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
134 			       unsigned int coef_idx)
135 {
136 	unsigned int val;
137 
138 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
139 	val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
140 	return val;
141 }
142 
143 #define alc_read_coef_idx(codec, coef_idx) \
144 	alc_read_coefex_idx(codec, 0x20, coef_idx)
145 
146 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
147 				 unsigned int coef_idx, unsigned int coef_val)
148 {
149 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
150 	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
151 }
152 
153 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
154 	alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
155 
156 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
157 				  unsigned int coef_idx, unsigned int mask,
158 				  unsigned int bits_set)
159 {
160 	unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
161 
162 	if (val != -1)
163 		alc_write_coefex_idx(codec, nid, coef_idx,
164 				     (val & ~mask) | bits_set);
165 }
166 
167 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set)	\
168 	alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
169 
170 /* a special bypass for COEF 0; read the cached value at the second time */
171 static unsigned int alc_get_coef0(struct hda_codec *codec)
172 {
173 	struct alc_spec *spec = codec->spec;
174 
175 	if (!spec->coef0)
176 		spec->coef0 = alc_read_coef_idx(codec, 0);
177 	return spec->coef0;
178 }
179 
180 /* coef writes/updates batch */
181 struct coef_fw {
182 	unsigned char nid;
183 	unsigned char idx;
184 	unsigned short mask;
185 	unsigned short val;
186 };
187 
188 #define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
189 	{ .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
190 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
191 #define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
192 #define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
193 
194 static void alc_process_coef_fw(struct hda_codec *codec,
195 				const struct coef_fw *fw)
196 {
197 	for (; fw->nid; fw++) {
198 		if (fw->mask == (unsigned short)-1)
199 			alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
200 		else
201 			alc_update_coefex_idx(codec, fw->nid, fw->idx,
202 					      fw->mask, fw->val);
203 	}
204 }
205 
206 /*
207  * GPIO setup tables, used in initialization
208  */
209 
210 /* Enable GPIO mask and set output */
211 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
212 {
213 	struct alc_spec *spec = codec->spec;
214 
215 	spec->gpio_mask |= mask;
216 	spec->gpio_dir |= mask;
217 	spec->gpio_data |= mask;
218 }
219 
220 static void alc_write_gpio_data(struct hda_codec *codec)
221 {
222 	struct alc_spec *spec = codec->spec;
223 
224 	snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
225 			    spec->gpio_data);
226 }
227 
228 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
229 				 bool on)
230 {
231 	struct alc_spec *spec = codec->spec;
232 	unsigned int oldval = spec->gpio_data;
233 
234 	if (on)
235 		spec->gpio_data |= mask;
236 	else
237 		spec->gpio_data &= ~mask;
238 	if (oldval != spec->gpio_data)
239 		alc_write_gpio_data(codec);
240 }
241 
242 static void alc_write_gpio(struct hda_codec *codec)
243 {
244 	struct alc_spec *spec = codec->spec;
245 
246 	if (!spec->gpio_mask)
247 		return;
248 
249 	snd_hda_codec_write(codec, codec->core.afg, 0,
250 			    AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
251 	snd_hda_codec_write(codec, codec->core.afg, 0,
252 			    AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
253 	if (spec->gpio_write_delay)
254 		msleep(1);
255 	alc_write_gpio_data(codec);
256 }
257 
258 static void alc_fixup_gpio(struct hda_codec *codec, int action,
259 			   unsigned int mask)
260 {
261 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
262 		alc_setup_gpio(codec, mask);
263 }
264 
265 static void alc_fixup_gpio1(struct hda_codec *codec,
266 			    const struct hda_fixup *fix, int action)
267 {
268 	alc_fixup_gpio(codec, action, 0x01);
269 }
270 
271 static void alc_fixup_gpio2(struct hda_codec *codec,
272 			    const struct hda_fixup *fix, int action)
273 {
274 	alc_fixup_gpio(codec, action, 0x02);
275 }
276 
277 static void alc_fixup_gpio3(struct hda_codec *codec,
278 			    const struct hda_fixup *fix, int action)
279 {
280 	alc_fixup_gpio(codec, action, 0x03);
281 }
282 
283 static void alc_fixup_gpio4(struct hda_codec *codec,
284 			    const struct hda_fixup *fix, int action)
285 {
286 	alc_fixup_gpio(codec, action, 0x04);
287 }
288 
289 /*
290  * Fix hardware PLL issue
291  * On some codecs, the analog PLL gating control must be off while
292  * the default value is 1.
293  */
294 static void alc_fix_pll(struct hda_codec *codec)
295 {
296 	struct alc_spec *spec = codec->spec;
297 
298 	if (spec->pll_nid)
299 		alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
300 				      1 << spec->pll_coef_bit, 0);
301 }
302 
303 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
304 			     unsigned int coef_idx, unsigned int coef_bit)
305 {
306 	struct alc_spec *spec = codec->spec;
307 	spec->pll_nid = nid;
308 	spec->pll_coef_idx = coef_idx;
309 	spec->pll_coef_bit = coef_bit;
310 	alc_fix_pll(codec);
311 }
312 
313 /* update the master volume per volume-knob's unsol event */
314 static void alc_update_knob_master(struct hda_codec *codec,
315 				   struct hda_jack_callback *jack)
316 {
317 	unsigned int val;
318 	struct snd_kcontrol *kctl;
319 	struct snd_ctl_elem_value *uctl;
320 
321 	kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
322 	if (!kctl)
323 		return;
324 	uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
325 	if (!uctl)
326 		return;
327 	val = snd_hda_codec_read(codec, jack->nid, 0,
328 				 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
329 	val &= HDA_AMP_VOLMASK;
330 	uctl->value.integer.value[0] = val;
331 	uctl->value.integer.value[1] = val;
332 	kctl->put(kctl, uctl);
333 	kfree(uctl);
334 }
335 
336 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
337 {
338 	/* For some reason, the res given from ALC880 is broken.
339 	   Here we adjust it properly. */
340 	snd_hda_jack_unsol_event(codec, res >> 2);
341 }
342 
343 /* Change EAPD to verb control */
344 static void alc_fill_eapd_coef(struct hda_codec *codec)
345 {
346 	int coef;
347 
348 	coef = alc_get_coef0(codec);
349 
350 	switch (codec->core.vendor_id) {
351 	case 0x10ec0262:
352 		alc_update_coef_idx(codec, 0x7, 0, 1<<5);
353 		break;
354 	case 0x10ec0267:
355 	case 0x10ec0268:
356 		alc_update_coef_idx(codec, 0x7, 0, 1<<13);
357 		break;
358 	case 0x10ec0269:
359 		if ((coef & 0x00f0) == 0x0010)
360 			alc_update_coef_idx(codec, 0xd, 0, 1<<14);
361 		if ((coef & 0x00f0) == 0x0020)
362 			alc_update_coef_idx(codec, 0x4, 1<<15, 0);
363 		if ((coef & 0x00f0) == 0x0030)
364 			alc_update_coef_idx(codec, 0x10, 1<<9, 0);
365 		break;
366 	case 0x10ec0280:
367 	case 0x10ec0284:
368 	case 0x10ec0290:
369 	case 0x10ec0292:
370 		alc_update_coef_idx(codec, 0x4, 1<<15, 0);
371 		break;
372 	case 0x10ec0225:
373 	case 0x10ec0295:
374 	case 0x10ec0299:
375 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
376 		/* fallthrough */
377 	case 0x10ec0215:
378 	case 0x10ec0233:
379 	case 0x10ec0235:
380 	case 0x10ec0236:
381 	case 0x10ec0255:
382 	case 0x10ec0256:
383 	case 0x10ec0257:
384 	case 0x10ec0282:
385 	case 0x10ec0283:
386 	case 0x10ec0286:
387 	case 0x10ec0288:
388 	case 0x10ec0285:
389 	case 0x10ec0298:
390 	case 0x10ec0289:
391 		alc_update_coef_idx(codec, 0x10, 1<<9, 0);
392 		break;
393 	case 0x10ec0275:
394 		alc_update_coef_idx(codec, 0xe, 0, 1<<0);
395 		break;
396 	case 0x10ec0293:
397 		alc_update_coef_idx(codec, 0xa, 1<<13, 0);
398 		break;
399 	case 0x10ec0234:
400 	case 0x10ec0274:
401 	case 0x10ec0294:
402 	case 0x10ec0700:
403 	case 0x10ec0701:
404 	case 0x10ec0703:
405 		alc_update_coef_idx(codec, 0x10, 1<<15, 0);
406 		break;
407 	case 0x10ec0662:
408 		if ((coef & 0x00f0) == 0x0030)
409 			alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
410 		break;
411 	case 0x10ec0272:
412 	case 0x10ec0273:
413 	case 0x10ec0663:
414 	case 0x10ec0665:
415 	case 0x10ec0670:
416 	case 0x10ec0671:
417 	case 0x10ec0672:
418 		alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
419 		break;
420 	case 0x10ec0668:
421 		alc_update_coef_idx(codec, 0x7, 3<<13, 0);
422 		break;
423 	case 0x10ec0867:
424 		alc_update_coef_idx(codec, 0x4, 1<<10, 0);
425 		break;
426 	case 0x10ec0888:
427 		if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
428 			alc_update_coef_idx(codec, 0x7, 1<<5, 0);
429 		break;
430 	case 0x10ec0892:
431 		alc_update_coef_idx(codec, 0x7, 1<<5, 0);
432 		break;
433 	case 0x10ec0899:
434 	case 0x10ec0900:
435 	case 0x10ec1168:
436 	case 0x10ec1220:
437 		alc_update_coef_idx(codec, 0x7, 1<<1, 0);
438 		break;
439 	}
440 }
441 
442 /* additional initialization for ALC888 variants */
443 static void alc888_coef_init(struct hda_codec *codec)
444 {
445 	switch (alc_get_coef0(codec) & 0x00f0) {
446 	/* alc888-VA */
447 	case 0x00:
448 	/* alc888-VB */
449 	case 0x10:
450 		alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
451 		break;
452 	}
453 }
454 
455 /* turn on/off EAPD control (only if available) */
456 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
457 {
458 	if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
459 		return;
460 	if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
461 		snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
462 				    on ? 2 : 0);
463 }
464 
465 /* turn on/off EAPD controls of the codec */
466 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
467 {
468 	/* We currently only handle front, HP */
469 	static hda_nid_t pins[] = {
470 		0x0f, 0x10, 0x14, 0x15, 0x17, 0
471 	};
472 	hda_nid_t *p;
473 	for (p = pins; *p; p++)
474 		set_eapd(codec, *p, on);
475 }
476 
477 /* generic shutup callback;
478  * just turning off EAPD and a little pause for avoiding pop-noise
479  */
480 static void alc_eapd_shutup(struct hda_codec *codec)
481 {
482 	struct alc_spec *spec = codec->spec;
483 
484 	alc_auto_setup_eapd(codec, false);
485 	if (!spec->no_depop_delay)
486 		msleep(200);
487 	snd_hda_shutup_pins(codec);
488 }
489 
490 /* generic EAPD initialization */
491 static void alc_auto_init_amp(struct hda_codec *codec, int type)
492 {
493 	alc_fill_eapd_coef(codec);
494 	alc_auto_setup_eapd(codec, true);
495 	alc_write_gpio(codec);
496 	switch (type) {
497 	case ALC_INIT_DEFAULT:
498 		switch (codec->core.vendor_id) {
499 		case 0x10ec0260:
500 			alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
501 			break;
502 		case 0x10ec0880:
503 		case 0x10ec0882:
504 		case 0x10ec0883:
505 		case 0x10ec0885:
506 			alc_update_coef_idx(codec, 7, 0, 0x2030);
507 			break;
508 		case 0x10ec0888:
509 			alc888_coef_init(codec);
510 			break;
511 		}
512 		break;
513 	}
514 }
515 
516 
517 /*
518  * Realtek SSID verification
519  */
520 
521 /* Could be any non-zero and even value. When used as fixup, tells
522  * the driver to ignore any present sku defines.
523  */
524 #define ALC_FIXUP_SKU_IGNORE (2)
525 
526 static void alc_fixup_sku_ignore(struct hda_codec *codec,
527 				 const struct hda_fixup *fix, int action)
528 {
529 	struct alc_spec *spec = codec->spec;
530 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
531 		spec->cdefine.fixup = 1;
532 		spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
533 	}
534 }
535 
536 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
537 				    const struct hda_fixup *fix, int action)
538 {
539 	struct alc_spec *spec = codec->spec;
540 
541 	if (action == HDA_FIXUP_ACT_PROBE) {
542 		spec->no_depop_delay = 1;
543 		codec->depop_delay = 0;
544 	}
545 }
546 
547 static int alc_auto_parse_customize_define(struct hda_codec *codec)
548 {
549 	unsigned int ass, tmp, i;
550 	unsigned nid = 0;
551 	struct alc_spec *spec = codec->spec;
552 
553 	spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
554 
555 	if (spec->cdefine.fixup) {
556 		ass = spec->cdefine.sku_cfg;
557 		if (ass == ALC_FIXUP_SKU_IGNORE)
558 			return -1;
559 		goto do_sku;
560 	}
561 
562 	if (!codec->bus->pci)
563 		return -1;
564 	ass = codec->core.subsystem_id & 0xffff;
565 	if (ass != codec->bus->pci->subsystem_device && (ass & 1))
566 		goto do_sku;
567 
568 	nid = 0x1d;
569 	if (codec->core.vendor_id == 0x10ec0260)
570 		nid = 0x17;
571 	ass = snd_hda_codec_get_pincfg(codec, nid);
572 
573 	if (!(ass & 1)) {
574 		codec_info(codec, "%s: SKU not ready 0x%08x\n",
575 			   codec->core.chip_name, ass);
576 		return -1;
577 	}
578 
579 	/* check sum */
580 	tmp = 0;
581 	for (i = 1; i < 16; i++) {
582 		if ((ass >> i) & 1)
583 			tmp++;
584 	}
585 	if (((ass >> 16) & 0xf) != tmp)
586 		return -1;
587 
588 	spec->cdefine.port_connectivity = ass >> 30;
589 	spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
590 	spec->cdefine.check_sum = (ass >> 16) & 0xf;
591 	spec->cdefine.customization = ass >> 8;
592 do_sku:
593 	spec->cdefine.sku_cfg = ass;
594 	spec->cdefine.external_amp = (ass & 0x38) >> 3;
595 	spec->cdefine.platform_type = (ass & 0x4) >> 2;
596 	spec->cdefine.swap = (ass & 0x2) >> 1;
597 	spec->cdefine.override = ass & 0x1;
598 
599 	codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
600 		   nid, spec->cdefine.sku_cfg);
601 	codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
602 		   spec->cdefine.port_connectivity);
603 	codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
604 	codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
605 	codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
606 	codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
607 	codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
608 	codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
609 	codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
610 
611 	return 0;
612 }
613 
614 /* return the position of NID in the list, or -1 if not found */
615 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
616 {
617 	int i;
618 	for (i = 0; i < nums; i++)
619 		if (list[i] == nid)
620 			return i;
621 	return -1;
622 }
623 /* return true if the given NID is found in the list */
624 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
625 {
626 	return find_idx_in_nid_list(nid, list, nums) >= 0;
627 }
628 
629 /* check subsystem ID and set up device-specific initialization;
630  * return 1 if initialized, 0 if invalid SSID
631  */
632 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
633  *	31 ~ 16 :	Manufacture ID
634  *	15 ~ 8	:	SKU ID
635  *	7  ~ 0	:	Assembly ID
636  *	port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
637  */
638 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
639 {
640 	unsigned int ass, tmp, i;
641 	unsigned nid;
642 	struct alc_spec *spec = codec->spec;
643 
644 	if (spec->cdefine.fixup) {
645 		ass = spec->cdefine.sku_cfg;
646 		if (ass == ALC_FIXUP_SKU_IGNORE)
647 			return 0;
648 		goto do_sku;
649 	}
650 
651 	ass = codec->core.subsystem_id & 0xffff;
652 	if (codec->bus->pci &&
653 	    ass != codec->bus->pci->subsystem_device && (ass & 1))
654 		goto do_sku;
655 
656 	/* invalid SSID, check the special NID pin defcfg instead */
657 	/*
658 	 * 31~30	: port connectivity
659 	 * 29~21	: reserve
660 	 * 20		: PCBEEP input
661 	 * 19~16	: Check sum (15:1)
662 	 * 15~1		: Custom
663 	 * 0		: override
664 	*/
665 	nid = 0x1d;
666 	if (codec->core.vendor_id == 0x10ec0260)
667 		nid = 0x17;
668 	ass = snd_hda_codec_get_pincfg(codec, nid);
669 	codec_dbg(codec,
670 		  "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
671 		   ass, nid);
672 	if (!(ass & 1))
673 		return 0;
674 	if ((ass >> 30) != 1)	/* no physical connection */
675 		return 0;
676 
677 	/* check sum */
678 	tmp = 0;
679 	for (i = 1; i < 16; i++) {
680 		if ((ass >> i) & 1)
681 			tmp++;
682 	}
683 	if (((ass >> 16) & 0xf) != tmp)
684 		return 0;
685 do_sku:
686 	codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
687 		   ass & 0xffff, codec->core.vendor_id);
688 	/*
689 	 * 0 : override
690 	 * 1 :	Swap Jack
691 	 * 2 : 0 --> Desktop, 1 --> Laptop
692 	 * 3~5 : External Amplifier control
693 	 * 7~6 : Reserved
694 	*/
695 	tmp = (ass & 0x38) >> 3;	/* external Amp control */
696 	if (spec->init_amp == ALC_INIT_UNDEFINED) {
697 		switch (tmp) {
698 		case 1:
699 			alc_setup_gpio(codec, 0x01);
700 			break;
701 		case 3:
702 			alc_setup_gpio(codec, 0x02);
703 			break;
704 		case 7:
705 			alc_setup_gpio(codec, 0x03);
706 			break;
707 		case 5:
708 		default:
709 			spec->init_amp = ALC_INIT_DEFAULT;
710 			break;
711 		}
712 	}
713 
714 	/* is laptop or Desktop and enable the function "Mute internal speaker
715 	 * when the external headphone out jack is plugged"
716 	 */
717 	if (!(ass & 0x8000))
718 		return 1;
719 	/*
720 	 * 10~8 : Jack location
721 	 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
722 	 * 14~13: Resvered
723 	 * 15   : 1 --> enable the function "Mute internal speaker
724 	 *	        when the external headphone out jack is plugged"
725 	 */
726 	if (!spec->gen.autocfg.hp_pins[0] &&
727 	    !(spec->gen.autocfg.line_out_pins[0] &&
728 	      spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
729 		hda_nid_t nid;
730 		tmp = (ass >> 11) & 0x3;	/* HP to chassis */
731 		nid = ports[tmp];
732 		if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
733 				      spec->gen.autocfg.line_outs))
734 			return 1;
735 		spec->gen.autocfg.hp_pins[0] = nid;
736 	}
737 	return 1;
738 }
739 
740 /* Check the validity of ALC subsystem-id
741  * ports contains an array of 4 pin NIDs for port-A, E, D and I */
742 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
743 {
744 	if (!alc_subsystem_id(codec, ports)) {
745 		struct alc_spec *spec = codec->spec;
746 		codec_dbg(codec,
747 			  "realtek: Enable default setup for auto mode as fallback\n");
748 		spec->init_amp = ALC_INIT_DEFAULT;
749 	}
750 }
751 
752 /*
753  */
754 
755 static void alc_fixup_inv_dmic(struct hda_codec *codec,
756 			       const struct hda_fixup *fix, int action)
757 {
758 	struct alc_spec *spec = codec->spec;
759 
760 	spec->gen.inv_dmic_split = 1;
761 }
762 
763 
764 static int alc_build_controls(struct hda_codec *codec)
765 {
766 	int err;
767 
768 	err = snd_hda_gen_build_controls(codec);
769 	if (err < 0)
770 		return err;
771 
772 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
773 	return 0;
774 }
775 
776 
777 /*
778  * Common callbacks
779  */
780 
781 static int alc_init(struct hda_codec *codec)
782 {
783 	struct alc_spec *spec = codec->spec;
784 
785 	if (spec->init_hook)
786 		spec->init_hook(codec);
787 
788 	alc_fix_pll(codec);
789 	alc_auto_init_amp(codec, spec->init_amp);
790 
791 	snd_hda_gen_init(codec);
792 
793 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
794 
795 	return 0;
796 }
797 
798 static inline void alc_shutup(struct hda_codec *codec)
799 {
800 	struct alc_spec *spec = codec->spec;
801 
802 	if (!snd_hda_get_bool_hint(codec, "shutup"))
803 		return; /* disabled explicitly by hints */
804 
805 	if (spec && spec->shutup)
806 		spec->shutup(codec);
807 	else
808 		snd_hda_shutup_pins(codec);
809 }
810 
811 static void alc_reboot_notify(struct hda_codec *codec)
812 {
813 	struct alc_spec *spec = codec->spec;
814 
815 	if (spec && spec->reboot_notify)
816 		spec->reboot_notify(codec);
817 	else
818 		alc_shutup(codec);
819 }
820 
821 /* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */
822 static void alc_d3_at_reboot(struct hda_codec *codec)
823 {
824 	snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
825 	snd_hda_codec_write(codec, codec->core.afg, 0,
826 			    AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
827 	msleep(10);
828 }
829 
830 #define alc_free	snd_hda_gen_free
831 
832 #ifdef CONFIG_PM
833 static void alc_power_eapd(struct hda_codec *codec)
834 {
835 	alc_auto_setup_eapd(codec, false);
836 }
837 
838 static int alc_suspend(struct hda_codec *codec)
839 {
840 	struct alc_spec *spec = codec->spec;
841 	alc_shutup(codec);
842 	if (spec && spec->power_hook)
843 		spec->power_hook(codec);
844 	return 0;
845 }
846 #endif
847 
848 #ifdef CONFIG_PM
849 static int alc_resume(struct hda_codec *codec)
850 {
851 	struct alc_spec *spec = codec->spec;
852 
853 	if (!spec->no_depop_delay)
854 		msleep(150); /* to avoid pop noise */
855 	codec->patch_ops.init(codec);
856 	regcache_sync(codec->core.regmap);
857 	hda_call_check_power_status(codec, 0x01);
858 	return 0;
859 }
860 #endif
861 
862 /*
863  */
864 static const struct hda_codec_ops alc_patch_ops = {
865 	.build_controls = alc_build_controls,
866 	.build_pcms = snd_hda_gen_build_pcms,
867 	.init = alc_init,
868 	.free = alc_free,
869 	.unsol_event = snd_hda_jack_unsol_event,
870 #ifdef CONFIG_PM
871 	.resume = alc_resume,
872 	.suspend = alc_suspend,
873 	.check_power_status = snd_hda_gen_check_power_status,
874 #endif
875 	.reboot_notify = alc_reboot_notify,
876 };
877 
878 
879 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
880 
881 /*
882  * Rename codecs appropriately from COEF value or subvendor id
883  */
884 struct alc_codec_rename_table {
885 	unsigned int vendor_id;
886 	unsigned short coef_mask;
887 	unsigned short coef_bits;
888 	const char *name;
889 };
890 
891 struct alc_codec_rename_pci_table {
892 	unsigned int codec_vendor_id;
893 	unsigned short pci_subvendor;
894 	unsigned short pci_subdevice;
895 	const char *name;
896 };
897 
898 static struct alc_codec_rename_table rename_tbl[] = {
899 	{ 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
900 	{ 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
901 	{ 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
902 	{ 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
903 	{ 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
904 	{ 0x10ec0269, 0xffff, 0xa023, "ALC259" },
905 	{ 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
906 	{ 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
907 	{ 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
908 	{ 0x10ec0662, 0xffff, 0x4020, "ALC656" },
909 	{ 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
910 	{ 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
911 	{ 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
912 	{ 0x10ec0899, 0x2000, 0x2000, "ALC899" },
913 	{ 0x10ec0892, 0xffff, 0x8020, "ALC661" },
914 	{ 0x10ec0892, 0xffff, 0x8011, "ALC661" },
915 	{ 0x10ec0892, 0xffff, 0x4011, "ALC656" },
916 	{ } /* terminator */
917 };
918 
919 static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
920 	{ 0x10ec0280, 0x1028, 0, "ALC3220" },
921 	{ 0x10ec0282, 0x1028, 0, "ALC3221" },
922 	{ 0x10ec0283, 0x1028, 0, "ALC3223" },
923 	{ 0x10ec0288, 0x1028, 0, "ALC3263" },
924 	{ 0x10ec0292, 0x1028, 0, "ALC3226" },
925 	{ 0x10ec0293, 0x1028, 0, "ALC3235" },
926 	{ 0x10ec0255, 0x1028, 0, "ALC3234" },
927 	{ 0x10ec0668, 0x1028, 0, "ALC3661" },
928 	{ 0x10ec0275, 0x1028, 0, "ALC3260" },
929 	{ 0x10ec0899, 0x1028, 0, "ALC3861" },
930 	{ 0x10ec0298, 0x1028, 0, "ALC3266" },
931 	{ 0x10ec0236, 0x1028, 0, "ALC3204" },
932 	{ 0x10ec0256, 0x1028, 0, "ALC3246" },
933 	{ 0x10ec0225, 0x1028, 0, "ALC3253" },
934 	{ 0x10ec0295, 0x1028, 0, "ALC3254" },
935 	{ 0x10ec0299, 0x1028, 0, "ALC3271" },
936 	{ 0x10ec0670, 0x1025, 0, "ALC669X" },
937 	{ 0x10ec0676, 0x1025, 0, "ALC679X" },
938 	{ 0x10ec0282, 0x1043, 0, "ALC3229" },
939 	{ 0x10ec0233, 0x1043, 0, "ALC3236" },
940 	{ 0x10ec0280, 0x103c, 0, "ALC3228" },
941 	{ 0x10ec0282, 0x103c, 0, "ALC3227" },
942 	{ 0x10ec0286, 0x103c, 0, "ALC3242" },
943 	{ 0x10ec0290, 0x103c, 0, "ALC3241" },
944 	{ 0x10ec0668, 0x103c, 0, "ALC3662" },
945 	{ 0x10ec0283, 0x17aa, 0, "ALC3239" },
946 	{ 0x10ec0292, 0x17aa, 0, "ALC3232" },
947 	{ } /* terminator */
948 };
949 
950 static int alc_codec_rename_from_preset(struct hda_codec *codec)
951 {
952 	const struct alc_codec_rename_table *p;
953 	const struct alc_codec_rename_pci_table *q;
954 
955 	for (p = rename_tbl; p->vendor_id; p++) {
956 		if (p->vendor_id != codec->core.vendor_id)
957 			continue;
958 		if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
959 			return alc_codec_rename(codec, p->name);
960 	}
961 
962 	if (!codec->bus->pci)
963 		return 0;
964 	for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
965 		if (q->codec_vendor_id != codec->core.vendor_id)
966 			continue;
967 		if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
968 			continue;
969 		if (!q->pci_subdevice ||
970 		    q->pci_subdevice == codec->bus->pci->subsystem_device)
971 			return alc_codec_rename(codec, q->name);
972 	}
973 
974 	return 0;
975 }
976 
977 
978 /*
979  * Digital-beep handlers
980  */
981 #ifdef CONFIG_SND_HDA_INPUT_BEEP
982 
983 /* additional beep mixers; private_value will be overwritten */
984 static const struct snd_kcontrol_new alc_beep_mixer[] = {
985 	HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
986 	HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
987 };
988 
989 /* set up and create beep controls */
990 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
991 			int idx, int dir)
992 {
993 	struct snd_kcontrol_new *knew;
994 	unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
995 	int i;
996 
997 	for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
998 		knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
999 					    &alc_beep_mixer[i]);
1000 		if (!knew)
1001 			return -ENOMEM;
1002 		knew->private_value = beep_amp;
1003 	}
1004 	return 0;
1005 }
1006 
1007 static const struct snd_pci_quirk beep_white_list[] = {
1008 	SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1009 	SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1010 	SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1011 	SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1012 	SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1013 	SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1014 	SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1015 	SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1016 	SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1017 	{}
1018 };
1019 
1020 static inline int has_cdefine_beep(struct hda_codec *codec)
1021 {
1022 	struct alc_spec *spec = codec->spec;
1023 	const struct snd_pci_quirk *q;
1024 	q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1025 	if (q)
1026 		return q->value;
1027 	return spec->cdefine.enable_pcbeep;
1028 }
1029 #else
1030 #define set_beep_amp(spec, nid, idx, dir)	0
1031 #define has_cdefine_beep(codec)		0
1032 #endif
1033 
1034 /* parse the BIOS configuration and set up the alc_spec */
1035 /* return 1 if successful, 0 if the proper config is not found,
1036  * or a negative error code
1037  */
1038 static int alc_parse_auto_config(struct hda_codec *codec,
1039 				 const hda_nid_t *ignore_nids,
1040 				 const hda_nid_t *ssid_nids)
1041 {
1042 	struct alc_spec *spec = codec->spec;
1043 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1044 	int err;
1045 
1046 	err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1047 				       spec->parse_flags);
1048 	if (err < 0)
1049 		return err;
1050 
1051 	if (ssid_nids)
1052 		alc_ssid_check(codec, ssid_nids);
1053 
1054 	err = snd_hda_gen_parse_auto_config(codec, cfg);
1055 	if (err < 0)
1056 		return err;
1057 
1058 	return 1;
1059 }
1060 
1061 /* common preparation job for alc_spec */
1062 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1063 {
1064 	struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1065 	int err;
1066 
1067 	if (!spec)
1068 		return -ENOMEM;
1069 	codec->spec = spec;
1070 	snd_hda_gen_spec_init(&spec->gen);
1071 	spec->gen.mixer_nid = mixer_nid;
1072 	spec->gen.own_eapd_ctl = 1;
1073 	codec->single_adc_amp = 1;
1074 	/* FIXME: do we need this for all Realtek codec models? */
1075 	codec->spdif_status_reset = 1;
1076 	codec->patch_ops = alc_patch_ops;
1077 
1078 	err = alc_codec_rename_from_preset(codec);
1079 	if (err < 0) {
1080 		kfree(spec);
1081 		return err;
1082 	}
1083 	return 0;
1084 }
1085 
1086 static int alc880_parse_auto_config(struct hda_codec *codec)
1087 {
1088 	static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1089 	static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1090 	return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1091 }
1092 
1093 /*
1094  * ALC880 fix-ups
1095  */
1096 enum {
1097 	ALC880_FIXUP_GPIO1,
1098 	ALC880_FIXUP_GPIO2,
1099 	ALC880_FIXUP_MEDION_RIM,
1100 	ALC880_FIXUP_LG,
1101 	ALC880_FIXUP_LG_LW25,
1102 	ALC880_FIXUP_W810,
1103 	ALC880_FIXUP_EAPD_COEF,
1104 	ALC880_FIXUP_TCL_S700,
1105 	ALC880_FIXUP_VOL_KNOB,
1106 	ALC880_FIXUP_FUJITSU,
1107 	ALC880_FIXUP_F1734,
1108 	ALC880_FIXUP_UNIWILL,
1109 	ALC880_FIXUP_UNIWILL_DIG,
1110 	ALC880_FIXUP_Z71V,
1111 	ALC880_FIXUP_ASUS_W5A,
1112 	ALC880_FIXUP_3ST_BASE,
1113 	ALC880_FIXUP_3ST,
1114 	ALC880_FIXUP_3ST_DIG,
1115 	ALC880_FIXUP_5ST_BASE,
1116 	ALC880_FIXUP_5ST,
1117 	ALC880_FIXUP_5ST_DIG,
1118 	ALC880_FIXUP_6ST_BASE,
1119 	ALC880_FIXUP_6ST,
1120 	ALC880_FIXUP_6ST_DIG,
1121 	ALC880_FIXUP_6ST_AUTOMUTE,
1122 };
1123 
1124 /* enable the volume-knob widget support on NID 0x21 */
1125 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1126 				  const struct hda_fixup *fix, int action)
1127 {
1128 	if (action == HDA_FIXUP_ACT_PROBE)
1129 		snd_hda_jack_detect_enable_callback(codec, 0x21,
1130 						    alc_update_knob_master);
1131 }
1132 
1133 static const struct hda_fixup alc880_fixups[] = {
1134 	[ALC880_FIXUP_GPIO1] = {
1135 		.type = HDA_FIXUP_FUNC,
1136 		.v.func = alc_fixup_gpio1,
1137 	},
1138 	[ALC880_FIXUP_GPIO2] = {
1139 		.type = HDA_FIXUP_FUNC,
1140 		.v.func = alc_fixup_gpio2,
1141 	},
1142 	[ALC880_FIXUP_MEDION_RIM] = {
1143 		.type = HDA_FIXUP_VERBS,
1144 		.v.verbs = (const struct hda_verb[]) {
1145 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1146 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1147 			{ }
1148 		},
1149 		.chained = true,
1150 		.chain_id = ALC880_FIXUP_GPIO2,
1151 	},
1152 	[ALC880_FIXUP_LG] = {
1153 		.type = HDA_FIXUP_PINS,
1154 		.v.pins = (const struct hda_pintbl[]) {
1155 			/* disable bogus unused pins */
1156 			{ 0x16, 0x411111f0 },
1157 			{ 0x18, 0x411111f0 },
1158 			{ 0x1a, 0x411111f0 },
1159 			{ }
1160 		}
1161 	},
1162 	[ALC880_FIXUP_LG_LW25] = {
1163 		.type = HDA_FIXUP_PINS,
1164 		.v.pins = (const struct hda_pintbl[]) {
1165 			{ 0x1a, 0x0181344f }, /* line-in */
1166 			{ 0x1b, 0x0321403f }, /* headphone */
1167 			{ }
1168 		}
1169 	},
1170 	[ALC880_FIXUP_W810] = {
1171 		.type = HDA_FIXUP_PINS,
1172 		.v.pins = (const struct hda_pintbl[]) {
1173 			/* disable bogus unused pins */
1174 			{ 0x17, 0x411111f0 },
1175 			{ }
1176 		},
1177 		.chained = true,
1178 		.chain_id = ALC880_FIXUP_GPIO2,
1179 	},
1180 	[ALC880_FIXUP_EAPD_COEF] = {
1181 		.type = HDA_FIXUP_VERBS,
1182 		.v.verbs = (const struct hda_verb[]) {
1183 			/* change to EAPD mode */
1184 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1185 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1186 			{}
1187 		},
1188 	},
1189 	[ALC880_FIXUP_TCL_S700] = {
1190 		.type = HDA_FIXUP_VERBS,
1191 		.v.verbs = (const struct hda_verb[]) {
1192 			/* change to EAPD mode */
1193 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1194 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x3070 },
1195 			{}
1196 		},
1197 		.chained = true,
1198 		.chain_id = ALC880_FIXUP_GPIO2,
1199 	},
1200 	[ALC880_FIXUP_VOL_KNOB] = {
1201 		.type = HDA_FIXUP_FUNC,
1202 		.v.func = alc880_fixup_vol_knob,
1203 	},
1204 	[ALC880_FIXUP_FUJITSU] = {
1205 		/* override all pins as BIOS on old Amilo is broken */
1206 		.type = HDA_FIXUP_PINS,
1207 		.v.pins = (const struct hda_pintbl[]) {
1208 			{ 0x14, 0x0121401f }, /* HP */
1209 			{ 0x15, 0x99030120 }, /* speaker */
1210 			{ 0x16, 0x99030130 }, /* bass speaker */
1211 			{ 0x17, 0x411111f0 }, /* N/A */
1212 			{ 0x18, 0x411111f0 }, /* N/A */
1213 			{ 0x19, 0x01a19950 }, /* mic-in */
1214 			{ 0x1a, 0x411111f0 }, /* N/A */
1215 			{ 0x1b, 0x411111f0 }, /* N/A */
1216 			{ 0x1c, 0x411111f0 }, /* N/A */
1217 			{ 0x1d, 0x411111f0 }, /* N/A */
1218 			{ 0x1e, 0x01454140 }, /* SPDIF out */
1219 			{ }
1220 		},
1221 		.chained = true,
1222 		.chain_id = ALC880_FIXUP_VOL_KNOB,
1223 	},
1224 	[ALC880_FIXUP_F1734] = {
1225 		/* almost compatible with FUJITSU, but no bass and SPDIF */
1226 		.type = HDA_FIXUP_PINS,
1227 		.v.pins = (const struct hda_pintbl[]) {
1228 			{ 0x14, 0x0121401f }, /* HP */
1229 			{ 0x15, 0x99030120 }, /* speaker */
1230 			{ 0x16, 0x411111f0 }, /* N/A */
1231 			{ 0x17, 0x411111f0 }, /* N/A */
1232 			{ 0x18, 0x411111f0 }, /* N/A */
1233 			{ 0x19, 0x01a19950 }, /* mic-in */
1234 			{ 0x1a, 0x411111f0 }, /* N/A */
1235 			{ 0x1b, 0x411111f0 }, /* N/A */
1236 			{ 0x1c, 0x411111f0 }, /* N/A */
1237 			{ 0x1d, 0x411111f0 }, /* N/A */
1238 			{ 0x1e, 0x411111f0 }, /* N/A */
1239 			{ }
1240 		},
1241 		.chained = true,
1242 		.chain_id = ALC880_FIXUP_VOL_KNOB,
1243 	},
1244 	[ALC880_FIXUP_UNIWILL] = {
1245 		/* need to fix HP and speaker pins to be parsed correctly */
1246 		.type = HDA_FIXUP_PINS,
1247 		.v.pins = (const struct hda_pintbl[]) {
1248 			{ 0x14, 0x0121411f }, /* HP */
1249 			{ 0x15, 0x99030120 }, /* speaker */
1250 			{ 0x16, 0x99030130 }, /* bass speaker */
1251 			{ }
1252 		},
1253 	},
1254 	[ALC880_FIXUP_UNIWILL_DIG] = {
1255 		.type = HDA_FIXUP_PINS,
1256 		.v.pins = (const struct hda_pintbl[]) {
1257 			/* disable bogus unused pins */
1258 			{ 0x17, 0x411111f0 },
1259 			{ 0x19, 0x411111f0 },
1260 			{ 0x1b, 0x411111f0 },
1261 			{ 0x1f, 0x411111f0 },
1262 			{ }
1263 		}
1264 	},
1265 	[ALC880_FIXUP_Z71V] = {
1266 		.type = HDA_FIXUP_PINS,
1267 		.v.pins = (const struct hda_pintbl[]) {
1268 			/* set up the whole pins as BIOS is utterly broken */
1269 			{ 0x14, 0x99030120 }, /* speaker */
1270 			{ 0x15, 0x0121411f }, /* HP */
1271 			{ 0x16, 0x411111f0 }, /* N/A */
1272 			{ 0x17, 0x411111f0 }, /* N/A */
1273 			{ 0x18, 0x01a19950 }, /* mic-in */
1274 			{ 0x19, 0x411111f0 }, /* N/A */
1275 			{ 0x1a, 0x01813031 }, /* line-in */
1276 			{ 0x1b, 0x411111f0 }, /* N/A */
1277 			{ 0x1c, 0x411111f0 }, /* N/A */
1278 			{ 0x1d, 0x411111f0 }, /* N/A */
1279 			{ 0x1e, 0x0144111e }, /* SPDIF */
1280 			{ }
1281 		}
1282 	},
1283 	[ALC880_FIXUP_ASUS_W5A] = {
1284 		.type = HDA_FIXUP_PINS,
1285 		.v.pins = (const struct hda_pintbl[]) {
1286 			/* set up the whole pins as BIOS is utterly broken */
1287 			{ 0x14, 0x0121411f }, /* HP */
1288 			{ 0x15, 0x411111f0 }, /* N/A */
1289 			{ 0x16, 0x411111f0 }, /* N/A */
1290 			{ 0x17, 0x411111f0 }, /* N/A */
1291 			{ 0x18, 0x90a60160 }, /* mic */
1292 			{ 0x19, 0x411111f0 }, /* N/A */
1293 			{ 0x1a, 0x411111f0 }, /* N/A */
1294 			{ 0x1b, 0x411111f0 }, /* N/A */
1295 			{ 0x1c, 0x411111f0 }, /* N/A */
1296 			{ 0x1d, 0x411111f0 }, /* N/A */
1297 			{ 0x1e, 0xb743111e }, /* SPDIF out */
1298 			{ }
1299 		},
1300 		.chained = true,
1301 		.chain_id = ALC880_FIXUP_GPIO1,
1302 	},
1303 	[ALC880_FIXUP_3ST_BASE] = {
1304 		.type = HDA_FIXUP_PINS,
1305 		.v.pins = (const struct hda_pintbl[]) {
1306 			{ 0x14, 0x01014010 }, /* line-out */
1307 			{ 0x15, 0x411111f0 }, /* N/A */
1308 			{ 0x16, 0x411111f0 }, /* N/A */
1309 			{ 0x17, 0x411111f0 }, /* N/A */
1310 			{ 0x18, 0x01a19c30 }, /* mic-in */
1311 			{ 0x19, 0x0121411f }, /* HP */
1312 			{ 0x1a, 0x01813031 }, /* line-in */
1313 			{ 0x1b, 0x02a19c40 }, /* front-mic */
1314 			{ 0x1c, 0x411111f0 }, /* N/A */
1315 			{ 0x1d, 0x411111f0 }, /* N/A */
1316 			/* 0x1e is filled in below */
1317 			{ 0x1f, 0x411111f0 }, /* N/A */
1318 			{ }
1319 		}
1320 	},
1321 	[ALC880_FIXUP_3ST] = {
1322 		.type = HDA_FIXUP_PINS,
1323 		.v.pins = (const struct hda_pintbl[]) {
1324 			{ 0x1e, 0x411111f0 }, /* N/A */
1325 			{ }
1326 		},
1327 		.chained = true,
1328 		.chain_id = ALC880_FIXUP_3ST_BASE,
1329 	},
1330 	[ALC880_FIXUP_3ST_DIG] = {
1331 		.type = HDA_FIXUP_PINS,
1332 		.v.pins = (const struct hda_pintbl[]) {
1333 			{ 0x1e, 0x0144111e }, /* SPDIF */
1334 			{ }
1335 		},
1336 		.chained = true,
1337 		.chain_id = ALC880_FIXUP_3ST_BASE,
1338 	},
1339 	[ALC880_FIXUP_5ST_BASE] = {
1340 		.type = HDA_FIXUP_PINS,
1341 		.v.pins = (const struct hda_pintbl[]) {
1342 			{ 0x14, 0x01014010 }, /* front */
1343 			{ 0x15, 0x411111f0 }, /* N/A */
1344 			{ 0x16, 0x01011411 }, /* CLFE */
1345 			{ 0x17, 0x01016412 }, /* surr */
1346 			{ 0x18, 0x01a19c30 }, /* mic-in */
1347 			{ 0x19, 0x0121411f }, /* HP */
1348 			{ 0x1a, 0x01813031 }, /* line-in */
1349 			{ 0x1b, 0x02a19c40 }, /* front-mic */
1350 			{ 0x1c, 0x411111f0 }, /* N/A */
1351 			{ 0x1d, 0x411111f0 }, /* N/A */
1352 			/* 0x1e is filled in below */
1353 			{ 0x1f, 0x411111f0 }, /* N/A */
1354 			{ }
1355 		}
1356 	},
1357 	[ALC880_FIXUP_5ST] = {
1358 		.type = HDA_FIXUP_PINS,
1359 		.v.pins = (const struct hda_pintbl[]) {
1360 			{ 0x1e, 0x411111f0 }, /* N/A */
1361 			{ }
1362 		},
1363 		.chained = true,
1364 		.chain_id = ALC880_FIXUP_5ST_BASE,
1365 	},
1366 	[ALC880_FIXUP_5ST_DIG] = {
1367 		.type = HDA_FIXUP_PINS,
1368 		.v.pins = (const struct hda_pintbl[]) {
1369 			{ 0x1e, 0x0144111e }, /* SPDIF */
1370 			{ }
1371 		},
1372 		.chained = true,
1373 		.chain_id = ALC880_FIXUP_5ST_BASE,
1374 	},
1375 	[ALC880_FIXUP_6ST_BASE] = {
1376 		.type = HDA_FIXUP_PINS,
1377 		.v.pins = (const struct hda_pintbl[]) {
1378 			{ 0x14, 0x01014010 }, /* front */
1379 			{ 0x15, 0x01016412 }, /* surr */
1380 			{ 0x16, 0x01011411 }, /* CLFE */
1381 			{ 0x17, 0x01012414 }, /* side */
1382 			{ 0x18, 0x01a19c30 }, /* mic-in */
1383 			{ 0x19, 0x02a19c40 }, /* front-mic */
1384 			{ 0x1a, 0x01813031 }, /* line-in */
1385 			{ 0x1b, 0x0121411f }, /* HP */
1386 			{ 0x1c, 0x411111f0 }, /* N/A */
1387 			{ 0x1d, 0x411111f0 }, /* N/A */
1388 			/* 0x1e is filled in below */
1389 			{ 0x1f, 0x411111f0 }, /* N/A */
1390 			{ }
1391 		}
1392 	},
1393 	[ALC880_FIXUP_6ST] = {
1394 		.type = HDA_FIXUP_PINS,
1395 		.v.pins = (const struct hda_pintbl[]) {
1396 			{ 0x1e, 0x411111f0 }, /* N/A */
1397 			{ }
1398 		},
1399 		.chained = true,
1400 		.chain_id = ALC880_FIXUP_6ST_BASE,
1401 	},
1402 	[ALC880_FIXUP_6ST_DIG] = {
1403 		.type = HDA_FIXUP_PINS,
1404 		.v.pins = (const struct hda_pintbl[]) {
1405 			{ 0x1e, 0x0144111e }, /* SPDIF */
1406 			{ }
1407 		},
1408 		.chained = true,
1409 		.chain_id = ALC880_FIXUP_6ST_BASE,
1410 	},
1411 	[ALC880_FIXUP_6ST_AUTOMUTE] = {
1412 		.type = HDA_FIXUP_PINS,
1413 		.v.pins = (const struct hda_pintbl[]) {
1414 			{ 0x1b, 0x0121401f }, /* HP with jack detect */
1415 			{ }
1416 		},
1417 		.chained_before = true,
1418 		.chain_id = ALC880_FIXUP_6ST_BASE,
1419 	},
1420 };
1421 
1422 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1423 	SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1424 	SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1425 	SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1426 	SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1427 	SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1428 	SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1429 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1430 	SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1431 	SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1432 	SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1433 	SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1434 	SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1435 	SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1436 	SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1437 	SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1438 	SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1439 	SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1440 	SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1441 	SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1442 	SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1443 	SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1444 	SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1445 	SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1446 
1447 	/* Below is the copied entries from alc880_quirks.c.
1448 	 * It's not quite sure whether BIOS sets the correct pin-config table
1449 	 * on these machines, thus they are kept to be compatible with
1450 	 * the old static quirks.  Once when it's confirmed to work without
1451 	 * these overrides, it'd be better to remove.
1452 	 */
1453 	SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1454 	SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1455 	SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1456 	SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1457 	SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1458 	SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1459 	SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1460 	SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1461 	SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1462 	SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1463 	SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1464 	SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1465 	SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1466 	SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1467 	SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1468 	SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1469 	SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1470 	SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1471 	SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1472 	SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1473 	SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1474 	SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1475 	SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1476 	SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1477 	SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1478 	SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1479 	SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1480 	SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1481 	SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1482 	SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1483 	SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1484 	SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1485 	SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1486 	/* default Intel */
1487 	SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1488 	SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1489 	SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1490 	{}
1491 };
1492 
1493 static const struct hda_model_fixup alc880_fixup_models[] = {
1494 	{.id = ALC880_FIXUP_3ST, .name = "3stack"},
1495 	{.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1496 	{.id = ALC880_FIXUP_5ST, .name = "5stack"},
1497 	{.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1498 	{.id = ALC880_FIXUP_6ST, .name = "6stack"},
1499 	{.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1500 	{.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1501 	{}
1502 };
1503 
1504 
1505 /*
1506  * OK, here we have finally the patch for ALC880
1507  */
1508 static int patch_alc880(struct hda_codec *codec)
1509 {
1510 	struct alc_spec *spec;
1511 	int err;
1512 
1513 	err = alc_alloc_spec(codec, 0x0b);
1514 	if (err < 0)
1515 		return err;
1516 
1517 	spec = codec->spec;
1518 	spec->gen.need_dac_fix = 1;
1519 	spec->gen.beep_nid = 0x01;
1520 
1521 	codec->patch_ops.unsol_event = alc880_unsol_event;
1522 
1523 	snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1524 		       alc880_fixups);
1525 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1526 
1527 	/* automatic parse from the BIOS config */
1528 	err = alc880_parse_auto_config(codec);
1529 	if (err < 0)
1530 		goto error;
1531 
1532 	if (!spec->gen.no_analog) {
1533 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1534 		if (err < 0)
1535 			goto error;
1536 	}
1537 
1538 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1539 
1540 	return 0;
1541 
1542  error:
1543 	alc_free(codec);
1544 	return err;
1545 }
1546 
1547 
1548 /*
1549  * ALC260 support
1550  */
1551 static int alc260_parse_auto_config(struct hda_codec *codec)
1552 {
1553 	static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1554 	static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1555 	return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1556 }
1557 
1558 /*
1559  * Pin config fixes
1560  */
1561 enum {
1562 	ALC260_FIXUP_HP_DC5750,
1563 	ALC260_FIXUP_HP_PIN_0F,
1564 	ALC260_FIXUP_COEF,
1565 	ALC260_FIXUP_GPIO1,
1566 	ALC260_FIXUP_GPIO1_TOGGLE,
1567 	ALC260_FIXUP_REPLACER,
1568 	ALC260_FIXUP_HP_B1900,
1569 	ALC260_FIXUP_KN1,
1570 	ALC260_FIXUP_FSC_S7020,
1571 	ALC260_FIXUP_FSC_S7020_JWSE,
1572 	ALC260_FIXUP_VAIO_PINS,
1573 };
1574 
1575 static void alc260_gpio1_automute(struct hda_codec *codec)
1576 {
1577 	struct alc_spec *spec = codec->spec;
1578 
1579 	alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1580 }
1581 
1582 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1583 				      const struct hda_fixup *fix, int action)
1584 {
1585 	struct alc_spec *spec = codec->spec;
1586 	if (action == HDA_FIXUP_ACT_PROBE) {
1587 		/* although the machine has only one output pin, we need to
1588 		 * toggle GPIO1 according to the jack state
1589 		 */
1590 		spec->gen.automute_hook = alc260_gpio1_automute;
1591 		spec->gen.detect_hp = 1;
1592 		spec->gen.automute_speaker = 1;
1593 		spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1594 		snd_hda_jack_detect_enable_callback(codec, 0x0f,
1595 						    snd_hda_gen_hp_automute);
1596 		alc_setup_gpio(codec, 0x01);
1597 	}
1598 }
1599 
1600 static void alc260_fixup_kn1(struct hda_codec *codec,
1601 			     const struct hda_fixup *fix, int action)
1602 {
1603 	struct alc_spec *spec = codec->spec;
1604 	static const struct hda_pintbl pincfgs[] = {
1605 		{ 0x0f, 0x02214000 }, /* HP/speaker */
1606 		{ 0x12, 0x90a60160 }, /* int mic */
1607 		{ 0x13, 0x02a19000 }, /* ext mic */
1608 		{ 0x18, 0x01446000 }, /* SPDIF out */
1609 		/* disable bogus I/O pins */
1610 		{ 0x10, 0x411111f0 },
1611 		{ 0x11, 0x411111f0 },
1612 		{ 0x14, 0x411111f0 },
1613 		{ 0x15, 0x411111f0 },
1614 		{ 0x16, 0x411111f0 },
1615 		{ 0x17, 0x411111f0 },
1616 		{ 0x19, 0x411111f0 },
1617 		{ }
1618 	};
1619 
1620 	switch (action) {
1621 	case HDA_FIXUP_ACT_PRE_PROBE:
1622 		snd_hda_apply_pincfgs(codec, pincfgs);
1623 		spec->init_amp = ALC_INIT_NONE;
1624 		break;
1625 	}
1626 }
1627 
1628 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1629 				   const struct hda_fixup *fix, int action)
1630 {
1631 	struct alc_spec *spec = codec->spec;
1632 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
1633 		spec->init_amp = ALC_INIT_NONE;
1634 }
1635 
1636 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1637 				   const struct hda_fixup *fix, int action)
1638 {
1639 	struct alc_spec *spec = codec->spec;
1640 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1641 		spec->gen.add_jack_modes = 1;
1642 		spec->gen.hp_mic = 1;
1643 	}
1644 }
1645 
1646 static const struct hda_fixup alc260_fixups[] = {
1647 	[ALC260_FIXUP_HP_DC5750] = {
1648 		.type = HDA_FIXUP_PINS,
1649 		.v.pins = (const struct hda_pintbl[]) {
1650 			{ 0x11, 0x90130110 }, /* speaker */
1651 			{ }
1652 		}
1653 	},
1654 	[ALC260_FIXUP_HP_PIN_0F] = {
1655 		.type = HDA_FIXUP_PINS,
1656 		.v.pins = (const struct hda_pintbl[]) {
1657 			{ 0x0f, 0x01214000 }, /* HP */
1658 			{ }
1659 		}
1660 	},
1661 	[ALC260_FIXUP_COEF] = {
1662 		.type = HDA_FIXUP_VERBS,
1663 		.v.verbs = (const struct hda_verb[]) {
1664 			{ 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1665 			{ 0x1a, AC_VERB_SET_PROC_COEF,  0x3040 },
1666 			{ }
1667 		},
1668 	},
1669 	[ALC260_FIXUP_GPIO1] = {
1670 		.type = HDA_FIXUP_FUNC,
1671 		.v.func = alc_fixup_gpio1,
1672 	},
1673 	[ALC260_FIXUP_GPIO1_TOGGLE] = {
1674 		.type = HDA_FIXUP_FUNC,
1675 		.v.func = alc260_fixup_gpio1_toggle,
1676 		.chained = true,
1677 		.chain_id = ALC260_FIXUP_HP_PIN_0F,
1678 	},
1679 	[ALC260_FIXUP_REPLACER] = {
1680 		.type = HDA_FIXUP_VERBS,
1681 		.v.verbs = (const struct hda_verb[]) {
1682 			{ 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1683 			{ 0x1a, AC_VERB_SET_PROC_COEF,  0x3050 },
1684 			{ }
1685 		},
1686 		.chained = true,
1687 		.chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1688 	},
1689 	[ALC260_FIXUP_HP_B1900] = {
1690 		.type = HDA_FIXUP_FUNC,
1691 		.v.func = alc260_fixup_gpio1_toggle,
1692 		.chained = true,
1693 		.chain_id = ALC260_FIXUP_COEF,
1694 	},
1695 	[ALC260_FIXUP_KN1] = {
1696 		.type = HDA_FIXUP_FUNC,
1697 		.v.func = alc260_fixup_kn1,
1698 	},
1699 	[ALC260_FIXUP_FSC_S7020] = {
1700 		.type = HDA_FIXUP_FUNC,
1701 		.v.func = alc260_fixup_fsc_s7020,
1702 	},
1703 	[ALC260_FIXUP_FSC_S7020_JWSE] = {
1704 		.type = HDA_FIXUP_FUNC,
1705 		.v.func = alc260_fixup_fsc_s7020_jwse,
1706 		.chained = true,
1707 		.chain_id = ALC260_FIXUP_FSC_S7020,
1708 	},
1709 	[ALC260_FIXUP_VAIO_PINS] = {
1710 		.type = HDA_FIXUP_PINS,
1711 		.v.pins = (const struct hda_pintbl[]) {
1712 			/* Pin configs are missing completely on some VAIOs */
1713 			{ 0x0f, 0x01211020 },
1714 			{ 0x10, 0x0001003f },
1715 			{ 0x11, 0x411111f0 },
1716 			{ 0x12, 0x01a15930 },
1717 			{ 0x13, 0x411111f0 },
1718 			{ 0x14, 0x411111f0 },
1719 			{ 0x15, 0x411111f0 },
1720 			{ 0x16, 0x411111f0 },
1721 			{ 0x17, 0x411111f0 },
1722 			{ 0x18, 0x411111f0 },
1723 			{ 0x19, 0x411111f0 },
1724 			{ }
1725 		}
1726 	},
1727 };
1728 
1729 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1730 	SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1731 	SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1732 	SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1733 	SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1734 	SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1735 	SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1736 	SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1737 	SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1738 	SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1739 	SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1740 	SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1741 	SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1742 	{}
1743 };
1744 
1745 static const struct hda_model_fixup alc260_fixup_models[] = {
1746 	{.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1747 	{.id = ALC260_FIXUP_COEF, .name = "coef"},
1748 	{.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1749 	{.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1750 	{}
1751 };
1752 
1753 /*
1754  */
1755 static int patch_alc260(struct hda_codec *codec)
1756 {
1757 	struct alc_spec *spec;
1758 	int err;
1759 
1760 	err = alc_alloc_spec(codec, 0x07);
1761 	if (err < 0)
1762 		return err;
1763 
1764 	spec = codec->spec;
1765 	/* as quite a few machines require HP amp for speaker outputs,
1766 	 * it's easier to enable it unconditionally; even if it's unneeded,
1767 	 * it's almost harmless.
1768 	 */
1769 	spec->gen.prefer_hp_amp = 1;
1770 	spec->gen.beep_nid = 0x01;
1771 
1772 	spec->shutup = alc_eapd_shutup;
1773 
1774 	snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1775 			   alc260_fixups);
1776 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1777 
1778 	/* automatic parse from the BIOS config */
1779 	err = alc260_parse_auto_config(codec);
1780 	if (err < 0)
1781 		goto error;
1782 
1783 	if (!spec->gen.no_analog) {
1784 		err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1785 		if (err < 0)
1786 			goto error;
1787 	}
1788 
1789 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1790 
1791 	return 0;
1792 
1793  error:
1794 	alc_free(codec);
1795 	return err;
1796 }
1797 
1798 
1799 /*
1800  * ALC882/883/885/888/889 support
1801  *
1802  * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1803  * configuration.  Each pin widget can choose any input DACs and a mixer.
1804  * Each ADC is connected from a mixer of all inputs.  This makes possible
1805  * 6-channel independent captures.
1806  *
1807  * In addition, an independent DAC for the multi-playback (not used in this
1808  * driver yet).
1809  */
1810 
1811 /*
1812  * Pin config fixes
1813  */
1814 enum {
1815 	ALC882_FIXUP_ABIT_AW9D_MAX,
1816 	ALC882_FIXUP_LENOVO_Y530,
1817 	ALC882_FIXUP_PB_M5210,
1818 	ALC882_FIXUP_ACER_ASPIRE_7736,
1819 	ALC882_FIXUP_ASUS_W90V,
1820 	ALC889_FIXUP_CD,
1821 	ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1822 	ALC889_FIXUP_VAIO_TT,
1823 	ALC888_FIXUP_EEE1601,
1824 	ALC882_FIXUP_EAPD,
1825 	ALC883_FIXUP_EAPD,
1826 	ALC883_FIXUP_ACER_EAPD,
1827 	ALC882_FIXUP_GPIO1,
1828 	ALC882_FIXUP_GPIO2,
1829 	ALC882_FIXUP_GPIO3,
1830 	ALC889_FIXUP_COEF,
1831 	ALC882_FIXUP_ASUS_W2JC,
1832 	ALC882_FIXUP_ACER_ASPIRE_4930G,
1833 	ALC882_FIXUP_ACER_ASPIRE_8930G,
1834 	ALC882_FIXUP_ASPIRE_8930G_VERBS,
1835 	ALC885_FIXUP_MACPRO_GPIO,
1836 	ALC889_FIXUP_DAC_ROUTE,
1837 	ALC889_FIXUP_MBP_VREF,
1838 	ALC889_FIXUP_IMAC91_VREF,
1839 	ALC889_FIXUP_MBA11_VREF,
1840 	ALC889_FIXUP_MBA21_VREF,
1841 	ALC889_FIXUP_MP11_VREF,
1842 	ALC889_FIXUP_MP41_VREF,
1843 	ALC882_FIXUP_INV_DMIC,
1844 	ALC882_FIXUP_NO_PRIMARY_HP,
1845 	ALC887_FIXUP_ASUS_BASS,
1846 	ALC887_FIXUP_BASS_CHMAP,
1847 	ALC1220_FIXUP_GB_DUAL_CODECS,
1848 	ALC1220_FIXUP_CLEVO_P950,
1849 };
1850 
1851 static void alc889_fixup_coef(struct hda_codec *codec,
1852 			      const struct hda_fixup *fix, int action)
1853 {
1854 	if (action != HDA_FIXUP_ACT_INIT)
1855 		return;
1856 	alc_update_coef_idx(codec, 7, 0, 0x2030);
1857 }
1858 
1859 /* set up GPIO at initialization */
1860 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1861 				     const struct hda_fixup *fix, int action)
1862 {
1863 	struct alc_spec *spec = codec->spec;
1864 
1865 	spec->gpio_write_delay = true;
1866 	alc_fixup_gpio3(codec, fix, action);
1867 }
1868 
1869 /* Fix the connection of some pins for ALC889:
1870  * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1871  * work correctly (bko#42740)
1872  */
1873 static void alc889_fixup_dac_route(struct hda_codec *codec,
1874 				   const struct hda_fixup *fix, int action)
1875 {
1876 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1877 		/* fake the connections during parsing the tree */
1878 		hda_nid_t conn1[2] = { 0x0c, 0x0d };
1879 		hda_nid_t conn2[2] = { 0x0e, 0x0f };
1880 		snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1881 		snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1882 		snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1883 		snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1884 	} else if (action == HDA_FIXUP_ACT_PROBE) {
1885 		/* restore the connections */
1886 		hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1887 		snd_hda_override_conn_list(codec, 0x14, 5, conn);
1888 		snd_hda_override_conn_list(codec, 0x15, 5, conn);
1889 		snd_hda_override_conn_list(codec, 0x18, 5, conn);
1890 		snd_hda_override_conn_list(codec, 0x1a, 5, conn);
1891 	}
1892 }
1893 
1894 /* Set VREF on HP pin */
1895 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1896 				  const struct hda_fixup *fix, int action)
1897 {
1898 	struct alc_spec *spec = codec->spec;
1899 	static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 };
1900 	int i;
1901 
1902 	if (action != HDA_FIXUP_ACT_INIT)
1903 		return;
1904 	for (i = 0; i < ARRAY_SIZE(nids); i++) {
1905 		unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1906 		if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1907 			continue;
1908 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
1909 		val |= AC_PINCTL_VREF_80;
1910 		snd_hda_set_pin_ctl(codec, nids[i], val);
1911 		spec->gen.keep_vref_in_automute = 1;
1912 		break;
1913 	}
1914 }
1915 
1916 static void alc889_fixup_mac_pins(struct hda_codec *codec,
1917 				  const hda_nid_t *nids, int num_nids)
1918 {
1919 	struct alc_spec *spec = codec->spec;
1920 	int i;
1921 
1922 	for (i = 0; i < num_nids; i++) {
1923 		unsigned int val;
1924 		val = snd_hda_codec_get_pin_target(codec, nids[i]);
1925 		val |= AC_PINCTL_VREF_50;
1926 		snd_hda_set_pin_ctl(codec, nids[i], val);
1927 	}
1928 	spec->gen.keep_vref_in_automute = 1;
1929 }
1930 
1931 /* Set VREF on speaker pins on imac91 */
1932 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1933 				     const struct hda_fixup *fix, int action)
1934 {
1935 	static hda_nid_t nids[2] = { 0x18, 0x1a };
1936 
1937 	if (action == HDA_FIXUP_ACT_INIT)
1938 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1939 }
1940 
1941 /* Set VREF on speaker pins on mba11 */
1942 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1943 				    const struct hda_fixup *fix, int action)
1944 {
1945 	static hda_nid_t nids[1] = { 0x18 };
1946 
1947 	if (action == HDA_FIXUP_ACT_INIT)
1948 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1949 }
1950 
1951 /* Set VREF on speaker pins on mba21 */
1952 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1953 				    const struct hda_fixup *fix, int action)
1954 {
1955 	static hda_nid_t nids[2] = { 0x18, 0x19 };
1956 
1957 	if (action == HDA_FIXUP_ACT_INIT)
1958 		alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1959 }
1960 
1961 /* Don't take HP output as primary
1962  * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1963  * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
1964  */
1965 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1966 				       const struct hda_fixup *fix, int action)
1967 {
1968 	struct alc_spec *spec = codec->spec;
1969 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1970 		spec->gen.no_primary_hp = 1;
1971 		spec->gen.no_multi_io = 1;
1972 	}
1973 }
1974 
1975 static void alc_fixup_bass_chmap(struct hda_codec *codec,
1976 				 const struct hda_fixup *fix, int action);
1977 
1978 /* For dual-codec configuration, we need to disable some features to avoid
1979  * conflicts of kctls and PCM streams
1980  */
1981 static void alc_fixup_dual_codecs(struct hda_codec *codec,
1982 				  const struct hda_fixup *fix, int action)
1983 {
1984 	struct alc_spec *spec = codec->spec;
1985 
1986 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
1987 		return;
1988 	/* disable vmaster */
1989 	spec->gen.suppress_vmaster = 1;
1990 	/* auto-mute and auto-mic switch don't work with multiple codecs */
1991 	spec->gen.suppress_auto_mute = 1;
1992 	spec->gen.suppress_auto_mic = 1;
1993 	/* disable aamix as well */
1994 	spec->gen.mixer_nid = 0;
1995 	/* add location prefix to avoid conflicts */
1996 	codec->force_pin_prefix = 1;
1997 }
1998 
1999 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2000 		       const char *newname)
2001 {
2002 	struct snd_kcontrol *kctl;
2003 
2004 	kctl = snd_hda_find_mixer_ctl(codec, oldname);
2005 	if (kctl)
2006 		strcpy(kctl->id.name, newname);
2007 }
2008 
2009 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2010 					 const struct hda_fixup *fix,
2011 					 int action)
2012 {
2013 	alc_fixup_dual_codecs(codec, fix, action);
2014 	switch (action) {
2015 	case HDA_FIXUP_ACT_PRE_PROBE:
2016 		/* override card longname to provide a unique UCM profile */
2017 		strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2018 		break;
2019 	case HDA_FIXUP_ACT_BUILD:
2020 		/* rename Capture controls depending on the codec */
2021 		rename_ctl(codec, "Capture Volume",
2022 			   codec->addr == 0 ?
2023 			   "Rear-Panel Capture Volume" :
2024 			   "Front-Panel Capture Volume");
2025 		rename_ctl(codec, "Capture Switch",
2026 			   codec->addr == 0 ?
2027 			   "Rear-Panel Capture Switch" :
2028 			   "Front-Panel Capture Switch");
2029 		break;
2030 	}
2031 }
2032 
2033 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2034 				     const struct hda_fixup *fix,
2035 				     int action)
2036 {
2037 	hda_nid_t conn1[1] = { 0x0c };
2038 
2039 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
2040 		return;
2041 
2042 	alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2043 	/* We therefore want to make sure 0x14 (front headphone) and
2044 	 * 0x1b (speakers) use the stereo DAC 0x02
2045 	 */
2046 	snd_hda_override_conn_list(codec, 0x14, 1, conn1);
2047 	snd_hda_override_conn_list(codec, 0x1b, 1, conn1);
2048 }
2049 
2050 static const struct hda_fixup alc882_fixups[] = {
2051 	[ALC882_FIXUP_ABIT_AW9D_MAX] = {
2052 		.type = HDA_FIXUP_PINS,
2053 		.v.pins = (const struct hda_pintbl[]) {
2054 			{ 0x15, 0x01080104 }, /* side */
2055 			{ 0x16, 0x01011012 }, /* rear */
2056 			{ 0x17, 0x01016011 }, /* clfe */
2057 			{ }
2058 		}
2059 	},
2060 	[ALC882_FIXUP_LENOVO_Y530] = {
2061 		.type = HDA_FIXUP_PINS,
2062 		.v.pins = (const struct hda_pintbl[]) {
2063 			{ 0x15, 0x99130112 }, /* rear int speakers */
2064 			{ 0x16, 0x99130111 }, /* subwoofer */
2065 			{ }
2066 		}
2067 	},
2068 	[ALC882_FIXUP_PB_M5210] = {
2069 		.type = HDA_FIXUP_PINCTLS,
2070 		.v.pins = (const struct hda_pintbl[]) {
2071 			{ 0x19, PIN_VREF50 },
2072 			{}
2073 		}
2074 	},
2075 	[ALC882_FIXUP_ACER_ASPIRE_7736] = {
2076 		.type = HDA_FIXUP_FUNC,
2077 		.v.func = alc_fixup_sku_ignore,
2078 	},
2079 	[ALC882_FIXUP_ASUS_W90V] = {
2080 		.type = HDA_FIXUP_PINS,
2081 		.v.pins = (const struct hda_pintbl[]) {
2082 			{ 0x16, 0x99130110 }, /* fix sequence for CLFE */
2083 			{ }
2084 		}
2085 	},
2086 	[ALC889_FIXUP_CD] = {
2087 		.type = HDA_FIXUP_PINS,
2088 		.v.pins = (const struct hda_pintbl[]) {
2089 			{ 0x1c, 0x993301f0 }, /* CD */
2090 			{ }
2091 		}
2092 	},
2093 	[ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2094 		.type = HDA_FIXUP_PINS,
2095 		.v.pins = (const struct hda_pintbl[]) {
2096 			{ 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2097 			{ }
2098 		},
2099 		.chained = true,
2100 		.chain_id = ALC889_FIXUP_CD,
2101 	},
2102 	[ALC889_FIXUP_VAIO_TT] = {
2103 		.type = HDA_FIXUP_PINS,
2104 		.v.pins = (const struct hda_pintbl[]) {
2105 			{ 0x17, 0x90170111 }, /* hidden surround speaker */
2106 			{ }
2107 		}
2108 	},
2109 	[ALC888_FIXUP_EEE1601] = {
2110 		.type = HDA_FIXUP_VERBS,
2111 		.v.verbs = (const struct hda_verb[]) {
2112 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2113 			{ 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
2114 			{ }
2115 		}
2116 	},
2117 	[ALC882_FIXUP_EAPD] = {
2118 		.type = HDA_FIXUP_VERBS,
2119 		.v.verbs = (const struct hda_verb[]) {
2120 			/* change to EAPD mode */
2121 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2122 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2123 			{ }
2124 		}
2125 	},
2126 	[ALC883_FIXUP_EAPD] = {
2127 		.type = HDA_FIXUP_VERBS,
2128 		.v.verbs = (const struct hda_verb[]) {
2129 			/* change to EAPD mode */
2130 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2131 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2132 			{ }
2133 		}
2134 	},
2135 	[ALC883_FIXUP_ACER_EAPD] = {
2136 		.type = HDA_FIXUP_VERBS,
2137 		.v.verbs = (const struct hda_verb[]) {
2138 			/* eanable EAPD on Acer laptops */
2139 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2140 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2141 			{ }
2142 		}
2143 	},
2144 	[ALC882_FIXUP_GPIO1] = {
2145 		.type = HDA_FIXUP_FUNC,
2146 		.v.func = alc_fixup_gpio1,
2147 	},
2148 	[ALC882_FIXUP_GPIO2] = {
2149 		.type = HDA_FIXUP_FUNC,
2150 		.v.func = alc_fixup_gpio2,
2151 	},
2152 	[ALC882_FIXUP_GPIO3] = {
2153 		.type = HDA_FIXUP_FUNC,
2154 		.v.func = alc_fixup_gpio3,
2155 	},
2156 	[ALC882_FIXUP_ASUS_W2JC] = {
2157 		.type = HDA_FIXUP_FUNC,
2158 		.v.func = alc_fixup_gpio1,
2159 		.chained = true,
2160 		.chain_id = ALC882_FIXUP_EAPD,
2161 	},
2162 	[ALC889_FIXUP_COEF] = {
2163 		.type = HDA_FIXUP_FUNC,
2164 		.v.func = alc889_fixup_coef,
2165 	},
2166 	[ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2167 		.type = HDA_FIXUP_PINS,
2168 		.v.pins = (const struct hda_pintbl[]) {
2169 			{ 0x16, 0x99130111 }, /* CLFE speaker */
2170 			{ 0x17, 0x99130112 }, /* surround speaker */
2171 			{ }
2172 		},
2173 		.chained = true,
2174 		.chain_id = ALC882_FIXUP_GPIO1,
2175 	},
2176 	[ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2177 		.type = HDA_FIXUP_PINS,
2178 		.v.pins = (const struct hda_pintbl[]) {
2179 			{ 0x16, 0x99130111 }, /* CLFE speaker */
2180 			{ 0x1b, 0x99130112 }, /* surround speaker */
2181 			{ }
2182 		},
2183 		.chained = true,
2184 		.chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2185 	},
2186 	[ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2187 		/* additional init verbs for Acer Aspire 8930G */
2188 		.type = HDA_FIXUP_VERBS,
2189 		.v.verbs = (const struct hda_verb[]) {
2190 			/* Enable all DACs */
2191 			/* DAC DISABLE/MUTE 1? */
2192 			/*  setting bits 1-5 disables DAC nids 0x02-0x06
2193 			 *  apparently. Init=0x38 */
2194 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2195 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2196 			/* DAC DISABLE/MUTE 2? */
2197 			/*  some bit here disables the other DACs.
2198 			 *  Init=0x4900 */
2199 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2200 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2201 			/* DMIC fix
2202 			 * This laptop has a stereo digital microphone.
2203 			 * The mics are only 1cm apart which makes the stereo
2204 			 * useless. However, either the mic or the ALC889
2205 			 * makes the signal become a difference/sum signal
2206 			 * instead of standard stereo, which is annoying.
2207 			 * So instead we flip this bit which makes the
2208 			 * codec replicate the sum signal to both channels,
2209 			 * turning it into a normal mono mic.
2210 			 */
2211 			/* DMIC_CONTROL? Init value = 0x0001 */
2212 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2213 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2214 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2215 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2216 			{ }
2217 		},
2218 		.chained = true,
2219 		.chain_id = ALC882_FIXUP_GPIO1,
2220 	},
2221 	[ALC885_FIXUP_MACPRO_GPIO] = {
2222 		.type = HDA_FIXUP_FUNC,
2223 		.v.func = alc885_fixup_macpro_gpio,
2224 	},
2225 	[ALC889_FIXUP_DAC_ROUTE] = {
2226 		.type = HDA_FIXUP_FUNC,
2227 		.v.func = alc889_fixup_dac_route,
2228 	},
2229 	[ALC889_FIXUP_MBP_VREF] = {
2230 		.type = HDA_FIXUP_FUNC,
2231 		.v.func = alc889_fixup_mbp_vref,
2232 		.chained = true,
2233 		.chain_id = ALC882_FIXUP_GPIO1,
2234 	},
2235 	[ALC889_FIXUP_IMAC91_VREF] = {
2236 		.type = HDA_FIXUP_FUNC,
2237 		.v.func = alc889_fixup_imac91_vref,
2238 		.chained = true,
2239 		.chain_id = ALC882_FIXUP_GPIO1,
2240 	},
2241 	[ALC889_FIXUP_MBA11_VREF] = {
2242 		.type = HDA_FIXUP_FUNC,
2243 		.v.func = alc889_fixup_mba11_vref,
2244 		.chained = true,
2245 		.chain_id = ALC889_FIXUP_MBP_VREF,
2246 	},
2247 	[ALC889_FIXUP_MBA21_VREF] = {
2248 		.type = HDA_FIXUP_FUNC,
2249 		.v.func = alc889_fixup_mba21_vref,
2250 		.chained = true,
2251 		.chain_id = ALC889_FIXUP_MBP_VREF,
2252 	},
2253 	[ALC889_FIXUP_MP11_VREF] = {
2254 		.type = HDA_FIXUP_FUNC,
2255 		.v.func = alc889_fixup_mba11_vref,
2256 		.chained = true,
2257 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
2258 	},
2259 	[ALC889_FIXUP_MP41_VREF] = {
2260 		.type = HDA_FIXUP_FUNC,
2261 		.v.func = alc889_fixup_mbp_vref,
2262 		.chained = true,
2263 		.chain_id = ALC885_FIXUP_MACPRO_GPIO,
2264 	},
2265 	[ALC882_FIXUP_INV_DMIC] = {
2266 		.type = HDA_FIXUP_FUNC,
2267 		.v.func = alc_fixup_inv_dmic,
2268 	},
2269 	[ALC882_FIXUP_NO_PRIMARY_HP] = {
2270 		.type = HDA_FIXUP_FUNC,
2271 		.v.func = alc882_fixup_no_primary_hp,
2272 	},
2273 	[ALC887_FIXUP_ASUS_BASS] = {
2274 		.type = HDA_FIXUP_PINS,
2275 		.v.pins = (const struct hda_pintbl[]) {
2276 			{0x16, 0x99130130}, /* bass speaker */
2277 			{}
2278 		},
2279 		.chained = true,
2280 		.chain_id = ALC887_FIXUP_BASS_CHMAP,
2281 	},
2282 	[ALC887_FIXUP_BASS_CHMAP] = {
2283 		.type = HDA_FIXUP_FUNC,
2284 		.v.func = alc_fixup_bass_chmap,
2285 	},
2286 	[ALC1220_FIXUP_GB_DUAL_CODECS] = {
2287 		.type = HDA_FIXUP_FUNC,
2288 		.v.func = alc1220_fixup_gb_dual_codecs,
2289 	},
2290 	[ALC1220_FIXUP_CLEVO_P950] = {
2291 		.type = HDA_FIXUP_FUNC,
2292 		.v.func = alc1220_fixup_clevo_p950,
2293 	},
2294 };
2295 
2296 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2297 	SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2298 	SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2299 	SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2300 	SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2301 	SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2302 	SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2303 	SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2304 	SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2305 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2306 	SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2307 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2308 	SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2309 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
2310 	SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2311 		      ALC882_FIXUP_ACER_ASPIRE_8930G),
2312 	SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2313 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2314 	SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2315 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2316 	SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2317 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2318 	SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2319 	SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2320 		      ALC882_FIXUP_ACER_ASPIRE_4930G),
2321 	SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2322 	SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2323 	SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2324 	SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2325 	SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2326 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2327 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2328 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2329 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2330 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2331 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2332 	SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2333 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2334 	SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2335 
2336 	/* All Apple entries are in codec SSIDs */
2337 	SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2338 	SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2339 	SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2340 	SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2341 	SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2342 	SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2343 	SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2344 	SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2345 	SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2346 	SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2347 	SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2348 	SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2349 	SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2350 	SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2351 	SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2352 	SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2353 	SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2354 	SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2355 	SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2356 	SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2357 	SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2358 	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2359 
2360 	SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2361 	SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2362 	SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2363 	SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2364 	SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2365 	SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2366 	SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2367 	SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2368 	SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2369 	SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2370 	SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2371 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2372 	SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2373 	{}
2374 };
2375 
2376 static const struct hda_model_fixup alc882_fixup_models[] = {
2377 	{.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2378 	{.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2379 	{.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2380 	{.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2381 	{.id = ALC889_FIXUP_CD, .name = "cd"},
2382 	{.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2383 	{.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2384 	{.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2385 	{.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2386 	{.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2387 	{.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2388 	{.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2389 	{.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2390 	{.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2391 	{.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2392 	{.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2393 	{.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2394 	{.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2395 	{.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2396 	{.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2397 	{.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2398 	{.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2399 	{.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2400 	{.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2401 	{.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2402 	{.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2403 	{.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2404 	{.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2405 	{.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2406 	{.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2407 	{.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2408 	{}
2409 };
2410 
2411 /*
2412  * BIOS auto configuration
2413  */
2414 /* almost identical with ALC880 parser... */
2415 static int alc882_parse_auto_config(struct hda_codec *codec)
2416 {
2417 	static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2418 	static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2419 	return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2420 }
2421 
2422 /*
2423  */
2424 static int patch_alc882(struct hda_codec *codec)
2425 {
2426 	struct alc_spec *spec;
2427 	int err;
2428 
2429 	err = alc_alloc_spec(codec, 0x0b);
2430 	if (err < 0)
2431 		return err;
2432 
2433 	spec = codec->spec;
2434 
2435 	switch (codec->core.vendor_id) {
2436 	case 0x10ec0882:
2437 	case 0x10ec0885:
2438 	case 0x10ec0900:
2439 	case 0x10ec1220:
2440 		break;
2441 	default:
2442 		/* ALC883 and variants */
2443 		alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2444 		break;
2445 	}
2446 
2447 	snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2448 		       alc882_fixups);
2449 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2450 
2451 	alc_auto_parse_customize_define(codec);
2452 
2453 	if (has_cdefine_beep(codec))
2454 		spec->gen.beep_nid = 0x01;
2455 
2456 	/* automatic parse from the BIOS config */
2457 	err = alc882_parse_auto_config(codec);
2458 	if (err < 0)
2459 		goto error;
2460 
2461 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
2462 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2463 		if (err < 0)
2464 			goto error;
2465 	}
2466 
2467 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2468 
2469 	return 0;
2470 
2471  error:
2472 	alc_free(codec);
2473 	return err;
2474 }
2475 
2476 
2477 /*
2478  * ALC262 support
2479  */
2480 static int alc262_parse_auto_config(struct hda_codec *codec)
2481 {
2482 	static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2483 	static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2484 	return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2485 }
2486 
2487 /*
2488  * Pin config fixes
2489  */
2490 enum {
2491 	ALC262_FIXUP_FSC_H270,
2492 	ALC262_FIXUP_FSC_S7110,
2493 	ALC262_FIXUP_HP_Z200,
2494 	ALC262_FIXUP_TYAN,
2495 	ALC262_FIXUP_LENOVO_3000,
2496 	ALC262_FIXUP_BENQ,
2497 	ALC262_FIXUP_BENQ_T31,
2498 	ALC262_FIXUP_INV_DMIC,
2499 	ALC262_FIXUP_INTEL_BAYLEYBAY,
2500 };
2501 
2502 static const struct hda_fixup alc262_fixups[] = {
2503 	[ALC262_FIXUP_FSC_H270] = {
2504 		.type = HDA_FIXUP_PINS,
2505 		.v.pins = (const struct hda_pintbl[]) {
2506 			{ 0x14, 0x99130110 }, /* speaker */
2507 			{ 0x15, 0x0221142f }, /* front HP */
2508 			{ 0x1b, 0x0121141f }, /* rear HP */
2509 			{ }
2510 		}
2511 	},
2512 	[ALC262_FIXUP_FSC_S7110] = {
2513 		.type = HDA_FIXUP_PINS,
2514 		.v.pins = (const struct hda_pintbl[]) {
2515 			{ 0x15, 0x90170110 }, /* speaker */
2516 			{ }
2517 		},
2518 		.chained = true,
2519 		.chain_id = ALC262_FIXUP_BENQ,
2520 	},
2521 	[ALC262_FIXUP_HP_Z200] = {
2522 		.type = HDA_FIXUP_PINS,
2523 		.v.pins = (const struct hda_pintbl[]) {
2524 			{ 0x16, 0x99130120 }, /* internal speaker */
2525 			{ }
2526 		}
2527 	},
2528 	[ALC262_FIXUP_TYAN] = {
2529 		.type = HDA_FIXUP_PINS,
2530 		.v.pins = (const struct hda_pintbl[]) {
2531 			{ 0x14, 0x1993e1f0 }, /* int AUX */
2532 			{ }
2533 		}
2534 	},
2535 	[ALC262_FIXUP_LENOVO_3000] = {
2536 		.type = HDA_FIXUP_PINCTLS,
2537 		.v.pins = (const struct hda_pintbl[]) {
2538 			{ 0x19, PIN_VREF50 },
2539 			{}
2540 		},
2541 		.chained = true,
2542 		.chain_id = ALC262_FIXUP_BENQ,
2543 	},
2544 	[ALC262_FIXUP_BENQ] = {
2545 		.type = HDA_FIXUP_VERBS,
2546 		.v.verbs = (const struct hda_verb[]) {
2547 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2548 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2549 			{}
2550 		}
2551 	},
2552 	[ALC262_FIXUP_BENQ_T31] = {
2553 		.type = HDA_FIXUP_VERBS,
2554 		.v.verbs = (const struct hda_verb[]) {
2555 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2556 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2557 			{}
2558 		}
2559 	},
2560 	[ALC262_FIXUP_INV_DMIC] = {
2561 		.type = HDA_FIXUP_FUNC,
2562 		.v.func = alc_fixup_inv_dmic,
2563 	},
2564 	[ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2565 		.type = HDA_FIXUP_FUNC,
2566 		.v.func = alc_fixup_no_depop_delay,
2567 	},
2568 };
2569 
2570 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2571 	SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2572 	SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2573 	SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2574 	SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2575 	SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2576 	SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2577 	SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2578 	SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2579 	SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2580 	SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2581 	{}
2582 };
2583 
2584 static const struct hda_model_fixup alc262_fixup_models[] = {
2585 	{.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2586 	{.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2587 	{.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2588 	{.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2589 	{.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2590 	{.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2591 	{.id = ALC262_FIXUP_BENQ, .name = "benq"},
2592 	{.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2593 	{.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2594 	{}
2595 };
2596 
2597 /*
2598  */
2599 static int patch_alc262(struct hda_codec *codec)
2600 {
2601 	struct alc_spec *spec;
2602 	int err;
2603 
2604 	err = alc_alloc_spec(codec, 0x0b);
2605 	if (err < 0)
2606 		return err;
2607 
2608 	spec = codec->spec;
2609 	spec->gen.shared_mic_vref_pin = 0x18;
2610 
2611 	spec->shutup = alc_eapd_shutup;
2612 
2613 #if 0
2614 	/* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is
2615 	 * under-run
2616 	 */
2617 	alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2618 #endif
2619 	alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2620 
2621 	snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2622 		       alc262_fixups);
2623 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2624 
2625 	alc_auto_parse_customize_define(codec);
2626 
2627 	if (has_cdefine_beep(codec))
2628 		spec->gen.beep_nid = 0x01;
2629 
2630 	/* automatic parse from the BIOS config */
2631 	err = alc262_parse_auto_config(codec);
2632 	if (err < 0)
2633 		goto error;
2634 
2635 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
2636 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2637 		if (err < 0)
2638 			goto error;
2639 	}
2640 
2641 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2642 
2643 	return 0;
2644 
2645  error:
2646 	alc_free(codec);
2647 	return err;
2648 }
2649 
2650 /*
2651  *  ALC268
2652  */
2653 /* bind Beep switches of both NID 0x0f and 0x10 */
2654 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2655 				  struct snd_ctl_elem_value *ucontrol)
2656 {
2657 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2658 	unsigned long pval;
2659 	int err;
2660 
2661 	mutex_lock(&codec->control_mutex);
2662 	pval = kcontrol->private_value;
2663 	kcontrol->private_value = (pval & ~0xff) | 0x0f;
2664 	err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2665 	if (err >= 0) {
2666 		kcontrol->private_value = (pval & ~0xff) | 0x10;
2667 		err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2668 	}
2669 	kcontrol->private_value = pval;
2670 	mutex_unlock(&codec->control_mutex);
2671 	return err;
2672 }
2673 
2674 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2675 	HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2676 	{
2677 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2678 		.name = "Beep Playback Switch",
2679 		.subdevice = HDA_SUBDEV_AMP_FLAG,
2680 		.info = snd_hda_mixer_amp_switch_info,
2681 		.get = snd_hda_mixer_amp_switch_get,
2682 		.put = alc268_beep_switch_put,
2683 		.private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2684 	},
2685 };
2686 
2687 /* set PCBEEP vol = 0, mute connections */
2688 static const struct hda_verb alc268_beep_init_verbs[] = {
2689 	{0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2690 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2691 	{0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2692 	{ }
2693 };
2694 
2695 enum {
2696 	ALC268_FIXUP_INV_DMIC,
2697 	ALC268_FIXUP_HP_EAPD,
2698 	ALC268_FIXUP_SPDIF,
2699 };
2700 
2701 static const struct hda_fixup alc268_fixups[] = {
2702 	[ALC268_FIXUP_INV_DMIC] = {
2703 		.type = HDA_FIXUP_FUNC,
2704 		.v.func = alc_fixup_inv_dmic,
2705 	},
2706 	[ALC268_FIXUP_HP_EAPD] = {
2707 		.type = HDA_FIXUP_VERBS,
2708 		.v.verbs = (const struct hda_verb[]) {
2709 			{0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2710 			{}
2711 		}
2712 	},
2713 	[ALC268_FIXUP_SPDIF] = {
2714 		.type = HDA_FIXUP_PINS,
2715 		.v.pins = (const struct hda_pintbl[]) {
2716 			{ 0x1e, 0x014b1180 }, /* enable SPDIF out */
2717 			{}
2718 		}
2719 	},
2720 };
2721 
2722 static const struct hda_model_fixup alc268_fixup_models[] = {
2723 	{.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2724 	{.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2725 	{.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2726 	{}
2727 };
2728 
2729 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2730 	SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2731 	SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2732 	/* below is codec SSID since multiple Toshiba laptops have the
2733 	 * same PCI SSID 1179:ff00
2734 	 */
2735 	SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2736 	{}
2737 };
2738 
2739 /*
2740  * BIOS auto configuration
2741  */
2742 static int alc268_parse_auto_config(struct hda_codec *codec)
2743 {
2744 	static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2745 	return alc_parse_auto_config(codec, NULL, alc268_ssids);
2746 }
2747 
2748 /*
2749  */
2750 static int patch_alc268(struct hda_codec *codec)
2751 {
2752 	struct alc_spec *spec;
2753 	int i, err;
2754 
2755 	/* ALC268 has no aa-loopback mixer */
2756 	err = alc_alloc_spec(codec, 0);
2757 	if (err < 0)
2758 		return err;
2759 
2760 	spec = codec->spec;
2761 	spec->gen.beep_nid = 0x01;
2762 
2763 	spec->shutup = alc_eapd_shutup;
2764 
2765 	snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2766 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2767 
2768 	/* automatic parse from the BIOS config */
2769 	err = alc268_parse_auto_config(codec);
2770 	if (err < 0)
2771 		goto error;
2772 
2773 	if (err > 0 && !spec->gen.no_analog &&
2774 	    spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2775 		for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
2776 			if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
2777 						  &alc268_beep_mixer[i])) {
2778 				err = -ENOMEM;
2779 				goto error;
2780 			}
2781 		}
2782 		snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2783 		if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2784 			/* override the amp caps for beep generator */
2785 			snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2786 					  (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2787 					  (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2788 					  (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2789 					  (0 << AC_AMPCAP_MUTE_SHIFT));
2790 	}
2791 
2792 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2793 
2794 	return 0;
2795 
2796  error:
2797 	alc_free(codec);
2798 	return err;
2799 }
2800 
2801 /*
2802  * ALC269
2803  */
2804 
2805 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2806 	.rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2807 };
2808 
2809 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2810 	.rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2811 };
2812 
2813 /* different alc269-variants */
2814 enum {
2815 	ALC269_TYPE_ALC269VA,
2816 	ALC269_TYPE_ALC269VB,
2817 	ALC269_TYPE_ALC269VC,
2818 	ALC269_TYPE_ALC269VD,
2819 	ALC269_TYPE_ALC280,
2820 	ALC269_TYPE_ALC282,
2821 	ALC269_TYPE_ALC283,
2822 	ALC269_TYPE_ALC284,
2823 	ALC269_TYPE_ALC293,
2824 	ALC269_TYPE_ALC286,
2825 	ALC269_TYPE_ALC298,
2826 	ALC269_TYPE_ALC255,
2827 	ALC269_TYPE_ALC256,
2828 	ALC269_TYPE_ALC257,
2829 	ALC269_TYPE_ALC215,
2830 	ALC269_TYPE_ALC225,
2831 	ALC269_TYPE_ALC294,
2832 	ALC269_TYPE_ALC700,
2833 };
2834 
2835 /*
2836  * BIOS auto configuration
2837  */
2838 static int alc269_parse_auto_config(struct hda_codec *codec)
2839 {
2840 	static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
2841 	static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2842 	static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2843 	struct alc_spec *spec = codec->spec;
2844 	const hda_nid_t *ssids;
2845 
2846 	switch (spec->codec_variant) {
2847 	case ALC269_TYPE_ALC269VA:
2848 	case ALC269_TYPE_ALC269VC:
2849 	case ALC269_TYPE_ALC280:
2850 	case ALC269_TYPE_ALC284:
2851 	case ALC269_TYPE_ALC293:
2852 		ssids = alc269va_ssids;
2853 		break;
2854 	case ALC269_TYPE_ALC269VB:
2855 	case ALC269_TYPE_ALC269VD:
2856 	case ALC269_TYPE_ALC282:
2857 	case ALC269_TYPE_ALC283:
2858 	case ALC269_TYPE_ALC286:
2859 	case ALC269_TYPE_ALC298:
2860 	case ALC269_TYPE_ALC255:
2861 	case ALC269_TYPE_ALC256:
2862 	case ALC269_TYPE_ALC257:
2863 	case ALC269_TYPE_ALC215:
2864 	case ALC269_TYPE_ALC225:
2865 	case ALC269_TYPE_ALC294:
2866 	case ALC269_TYPE_ALC700:
2867 		ssids = alc269_ssids;
2868 		break;
2869 	default:
2870 		ssids = alc269_ssids;
2871 		break;
2872 	}
2873 
2874 	return alc_parse_auto_config(codec, alc269_ignore, ssids);
2875 }
2876 
2877 static int find_ext_mic_pin(struct hda_codec *codec);
2878 
2879 static void alc286_shutup(struct hda_codec *codec)
2880 {
2881 	const struct hda_pincfg *pin;
2882 	int i;
2883 	int mic_pin = find_ext_mic_pin(codec);
2884 	/* don't shut up pins when unloading the driver; otherwise it breaks
2885 	 * the default pin setup at the next load of the driver
2886 	 */
2887 	if (codec->bus->shutdown)
2888 		return;
2889 	snd_array_for_each(&codec->init_pins, i, pin) {
2890 		/* use read here for syncing after issuing each verb */
2891 		if (pin->nid != mic_pin)
2892 			snd_hda_codec_read(codec, pin->nid, 0,
2893 					AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2894 	}
2895 	codec->pins_shutup = 1;
2896 }
2897 
2898 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
2899 {
2900 	alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
2901 }
2902 
2903 static void alc269_shutup(struct hda_codec *codec)
2904 {
2905 	struct alc_spec *spec = codec->spec;
2906 
2907 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2908 		alc269vb_toggle_power_output(codec, 0);
2909 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2910 			(alc_get_coef0(codec) & 0x00ff) == 0x018) {
2911 		msleep(150);
2912 	}
2913 	snd_hda_shutup_pins(codec);
2914 }
2915 
2916 static struct coef_fw alc282_coefs[] = {
2917 	WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2918 	UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2919 	WRITE_COEF(0x07, 0x0200), /* DMIC control */
2920 	UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2921 	UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2922 	WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2923 	WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2924 	WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2925 	UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2926 	UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2927 	WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2928 	UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2929 	WRITE_COEF(0x34, 0xa0c0), /* ANC */
2930 	UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2931 	UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2932 	UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2933 	WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2934 	WRITE_COEF(0x63, 0x2902), /* PLL */
2935 	WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2936 	WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2937 	WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2938 	WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2939 	UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2940 	WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2941 	UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2942 	WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2943 	WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2944 	UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2945 	WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2946 	{}
2947 };
2948 
2949 static void alc282_restore_default_value(struct hda_codec *codec)
2950 {
2951 	alc_process_coef_fw(codec, alc282_coefs);
2952 }
2953 
2954 static void alc282_init(struct hda_codec *codec)
2955 {
2956 	struct alc_spec *spec = codec->spec;
2957 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2958 	bool hp_pin_sense;
2959 	int coef78;
2960 
2961 	alc282_restore_default_value(codec);
2962 
2963 	if (!hp_pin)
2964 		return;
2965 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2966 	coef78 = alc_read_coef_idx(codec, 0x78);
2967 
2968 	/* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2969 	/* Headphone capless set to high power mode */
2970 	alc_write_coef_idx(codec, 0x78, 0x9004);
2971 
2972 	if (hp_pin_sense)
2973 		msleep(2);
2974 
2975 	snd_hda_codec_write(codec, hp_pin, 0,
2976 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2977 
2978 	if (hp_pin_sense)
2979 		msleep(85);
2980 
2981 	snd_hda_codec_write(codec, hp_pin, 0,
2982 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2983 
2984 	if (hp_pin_sense)
2985 		msleep(100);
2986 
2987 	/* Headphone capless set to normal mode */
2988 	alc_write_coef_idx(codec, 0x78, coef78);
2989 }
2990 
2991 static void alc282_shutup(struct hda_codec *codec)
2992 {
2993 	struct alc_spec *spec = codec->spec;
2994 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2995 	bool hp_pin_sense;
2996 	int coef78;
2997 
2998 	if (!hp_pin) {
2999 		alc269_shutup(codec);
3000 		return;
3001 	}
3002 
3003 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3004 	coef78 = alc_read_coef_idx(codec, 0x78);
3005 	alc_write_coef_idx(codec, 0x78, 0x9004);
3006 
3007 	if (hp_pin_sense)
3008 		msleep(2);
3009 
3010 	snd_hda_codec_write(codec, hp_pin, 0,
3011 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3012 
3013 	if (hp_pin_sense)
3014 		msleep(85);
3015 
3016 	snd_hda_codec_write(codec, hp_pin, 0,
3017 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3018 
3019 	if (hp_pin_sense)
3020 		msleep(100);
3021 
3022 	alc_auto_setup_eapd(codec, false);
3023 	snd_hda_shutup_pins(codec);
3024 	alc_write_coef_idx(codec, 0x78, coef78);
3025 }
3026 
3027 static struct coef_fw alc283_coefs[] = {
3028 	WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3029 	UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3030 	WRITE_COEF(0x07, 0x0200), /* DMIC control */
3031 	UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3032 	UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3033 	WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3034 	WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3035 	WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3036 	UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3037 	UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3038 	WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3039 	UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3040 	WRITE_COEF(0x22, 0xa0c0), /* ANC */
3041 	UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3042 	UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3043 	UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3044 	WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3045 	WRITE_COEF(0x2e, 0x2902), /* PLL */
3046 	WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3047 	WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3048 	WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3049 	WRITE_COEF(0x36, 0x0), /* capless control 5 */
3050 	UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3051 	WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3052 	UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3053 	WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3054 	WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3055 	UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3056 	WRITE_COEF(0x49, 0x0), /* test mode */
3057 	UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3058 	UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3059 	WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3060 	UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3061 	{}
3062 };
3063 
3064 static void alc283_restore_default_value(struct hda_codec *codec)
3065 {
3066 	alc_process_coef_fw(codec, alc283_coefs);
3067 }
3068 
3069 static void alc283_init(struct hda_codec *codec)
3070 {
3071 	struct alc_spec *spec = codec->spec;
3072 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3073 	bool hp_pin_sense;
3074 
3075 	if (!spec->gen.autocfg.hp_outs) {
3076 		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3077 			hp_pin = spec->gen.autocfg.line_out_pins[0];
3078 	}
3079 
3080 	alc283_restore_default_value(codec);
3081 
3082 	if (!hp_pin)
3083 		return;
3084 
3085 	msleep(30);
3086 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3087 
3088 	/* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3089 	/* Headphone capless set to high power mode */
3090 	alc_write_coef_idx(codec, 0x43, 0x9004);
3091 
3092 	snd_hda_codec_write(codec, hp_pin, 0,
3093 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3094 
3095 	if (hp_pin_sense)
3096 		msleep(85);
3097 
3098 	snd_hda_codec_write(codec, hp_pin, 0,
3099 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3100 
3101 	if (hp_pin_sense)
3102 		msleep(85);
3103 	/* Index 0x46 Combo jack auto switch control 2 */
3104 	/* 3k pull low control for Headset jack. */
3105 	alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3106 	/* Headphone capless set to normal mode */
3107 	alc_write_coef_idx(codec, 0x43, 0x9614);
3108 }
3109 
3110 static void alc283_shutup(struct hda_codec *codec)
3111 {
3112 	struct alc_spec *spec = codec->spec;
3113 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3114 	bool hp_pin_sense;
3115 
3116 	if (!spec->gen.autocfg.hp_outs) {
3117 		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3118 			hp_pin = spec->gen.autocfg.line_out_pins[0];
3119 	}
3120 
3121 	if (!hp_pin) {
3122 		alc269_shutup(codec);
3123 		return;
3124 	}
3125 
3126 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3127 
3128 	alc_write_coef_idx(codec, 0x43, 0x9004);
3129 
3130 	/*depop hp during suspend*/
3131 	alc_write_coef_idx(codec, 0x06, 0x2100);
3132 
3133 	snd_hda_codec_write(codec, hp_pin, 0,
3134 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3135 
3136 	if (hp_pin_sense)
3137 		msleep(100);
3138 
3139 	snd_hda_codec_write(codec, hp_pin, 0,
3140 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3141 
3142 	alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3143 
3144 	if (hp_pin_sense)
3145 		msleep(100);
3146 	alc_auto_setup_eapd(codec, false);
3147 	snd_hda_shutup_pins(codec);
3148 	alc_write_coef_idx(codec, 0x43, 0x9614);
3149 }
3150 
3151 static void alc256_init(struct hda_codec *codec)
3152 {
3153 	struct alc_spec *spec = codec->spec;
3154 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3155 	bool hp_pin_sense;
3156 
3157 	if (!hp_pin)
3158 		return;
3159 
3160 	msleep(30);
3161 
3162 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3163 
3164 	if (hp_pin_sense)
3165 		msleep(2);
3166 
3167 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3168 
3169 	snd_hda_codec_write(codec, hp_pin, 0,
3170 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3171 
3172 	if (hp_pin_sense)
3173 		msleep(85);
3174 
3175 	snd_hda_codec_write(codec, hp_pin, 0,
3176 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3177 
3178 	if (hp_pin_sense)
3179 		msleep(100);
3180 
3181 	alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3182 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3183 	alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3184 	alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3185 }
3186 
3187 static void alc256_shutup(struct hda_codec *codec)
3188 {
3189 	struct alc_spec *spec = codec->spec;
3190 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3191 	bool hp_pin_sense;
3192 
3193 	if (!hp_pin) {
3194 		alc269_shutup(codec);
3195 		return;
3196 	}
3197 
3198 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3199 
3200 	if (hp_pin_sense)
3201 		msleep(2);
3202 
3203 	snd_hda_codec_write(codec, hp_pin, 0,
3204 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3205 
3206 	if (hp_pin_sense)
3207 		msleep(85);
3208 
3209 	/* 3k pull low control for Headset jack. */
3210 	/* NOTE: call this before clearing the pin, otherwise codec stalls */
3211 	alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3212 
3213 	snd_hda_codec_write(codec, hp_pin, 0,
3214 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3215 
3216 	if (hp_pin_sense)
3217 		msleep(100);
3218 
3219 	alc_auto_setup_eapd(codec, false);
3220 	snd_hda_shutup_pins(codec);
3221 }
3222 
3223 static void alc225_init(struct hda_codec *codec)
3224 {
3225 	struct alc_spec *spec = codec->spec;
3226 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3227 	bool hp1_pin_sense, hp2_pin_sense;
3228 
3229 	if (!hp_pin)
3230 		return;
3231 
3232 	msleep(30);
3233 
3234 	hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3235 	hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3236 
3237 	if (hp1_pin_sense || hp2_pin_sense)
3238 		msleep(2);
3239 
3240 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3241 
3242 	if (hp1_pin_sense)
3243 		snd_hda_codec_write(codec, hp_pin, 0,
3244 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3245 	if (hp2_pin_sense)
3246 		snd_hda_codec_write(codec, 0x16, 0,
3247 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3248 
3249 	if (hp1_pin_sense || hp2_pin_sense)
3250 		msleep(85);
3251 
3252 	if (hp1_pin_sense)
3253 		snd_hda_codec_write(codec, hp_pin, 0,
3254 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3255 	if (hp2_pin_sense)
3256 		snd_hda_codec_write(codec, 0x16, 0,
3257 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3258 
3259 	if (hp1_pin_sense || hp2_pin_sense)
3260 		msleep(100);
3261 
3262 	alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3263 	alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3264 }
3265 
3266 static void alc225_shutup(struct hda_codec *codec)
3267 {
3268 	struct alc_spec *spec = codec->spec;
3269 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3270 	bool hp1_pin_sense, hp2_pin_sense;
3271 
3272 	if (!hp_pin) {
3273 		alc269_shutup(codec);
3274 		return;
3275 	}
3276 
3277 	/* 3k pull low control for Headset jack. */
3278 	alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3279 
3280 	hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3281 	hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3282 
3283 	if (hp1_pin_sense || hp2_pin_sense)
3284 		msleep(2);
3285 
3286 	if (hp1_pin_sense)
3287 		snd_hda_codec_write(codec, hp_pin, 0,
3288 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3289 	if (hp2_pin_sense)
3290 		snd_hda_codec_write(codec, 0x16, 0,
3291 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3292 
3293 	if (hp1_pin_sense || hp2_pin_sense)
3294 		msleep(85);
3295 
3296 	if (hp1_pin_sense)
3297 		snd_hda_codec_write(codec, hp_pin, 0,
3298 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3299 	if (hp2_pin_sense)
3300 		snd_hda_codec_write(codec, 0x16, 0,
3301 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3302 
3303 	if (hp1_pin_sense || hp2_pin_sense)
3304 		msleep(100);
3305 
3306 	alc_auto_setup_eapd(codec, false);
3307 	snd_hda_shutup_pins(codec);
3308 }
3309 
3310 static void alc_default_init(struct hda_codec *codec)
3311 {
3312 	struct alc_spec *spec = codec->spec;
3313 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3314 	bool hp_pin_sense;
3315 
3316 	if (!hp_pin)
3317 		return;
3318 
3319 	msleep(30);
3320 
3321 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3322 
3323 	if (hp_pin_sense)
3324 		msleep(2);
3325 
3326 	snd_hda_codec_write(codec, hp_pin, 0,
3327 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3328 
3329 	if (hp_pin_sense)
3330 		msleep(85);
3331 
3332 	snd_hda_codec_write(codec, hp_pin, 0,
3333 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3334 
3335 	if (hp_pin_sense)
3336 		msleep(100);
3337 }
3338 
3339 static void alc_default_shutup(struct hda_codec *codec)
3340 {
3341 	struct alc_spec *spec = codec->spec;
3342 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3343 	bool hp_pin_sense;
3344 
3345 	if (!hp_pin) {
3346 		alc269_shutup(codec);
3347 		return;
3348 	}
3349 
3350 	hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3351 
3352 	if (hp_pin_sense)
3353 		msleep(2);
3354 
3355 	snd_hda_codec_write(codec, hp_pin, 0,
3356 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3357 
3358 	if (hp_pin_sense)
3359 		msleep(85);
3360 
3361 	snd_hda_codec_write(codec, hp_pin, 0,
3362 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3363 
3364 	if (hp_pin_sense)
3365 		msleep(100);
3366 
3367 	alc_auto_setup_eapd(codec, false);
3368 	snd_hda_shutup_pins(codec);
3369 }
3370 
3371 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3372 			     unsigned int val)
3373 {
3374 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3375 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3376 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3377 }
3378 
3379 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3380 {
3381 	unsigned int val;
3382 
3383 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3384 	val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3385 		& 0xffff;
3386 	val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3387 		<< 16;
3388 	return val;
3389 }
3390 
3391 static void alc5505_dsp_halt(struct hda_codec *codec)
3392 {
3393 	unsigned int val;
3394 
3395 	alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3396 	alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3397 	alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3398 	alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3399 	alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3400 	alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3401 	alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3402 	val = alc5505_coef_get(codec, 0x6220);
3403 	alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3404 }
3405 
3406 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3407 {
3408 	alc5505_coef_set(codec, 0x61b8, 0x04133302);
3409 	alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3410 	alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3411 	alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3412 	alc5505_coef_set(codec, 0x6220, 0x2002010f);
3413 	alc5505_coef_set(codec, 0x880c, 0x00000004);
3414 }
3415 
3416 static void alc5505_dsp_init(struct hda_codec *codec)
3417 {
3418 	unsigned int val;
3419 
3420 	alc5505_dsp_halt(codec);
3421 	alc5505_dsp_back_from_halt(codec);
3422 	alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3423 	alc5505_coef_set(codec, 0x61b0, 0x5b16);
3424 	alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3425 	alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3426 	alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3427 	alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3428 	snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3429 	alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3430 	alc5505_coef_set(codec, 0x61b8, 0x04173302);
3431 	alc5505_coef_set(codec, 0x61b8, 0x04163302);
3432 	alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3433 	alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3434 	alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3435 
3436 	val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3437 	if (val <= 3)
3438 		alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3439 	else
3440 		alc5505_coef_set(codec, 0x6220, 0x6002018f);
3441 
3442 	alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3443 	alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3444 	alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3445 	alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3446 	alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3447 	alc5505_coef_set(codec, 0x880c, 0x00000003);
3448 	alc5505_coef_set(codec, 0x880c, 0x00000010);
3449 
3450 #ifdef HALT_REALTEK_ALC5505
3451 	alc5505_dsp_halt(codec);
3452 #endif
3453 }
3454 
3455 #ifdef HALT_REALTEK_ALC5505
3456 #define alc5505_dsp_suspend(codec)	/* NOP */
3457 #define alc5505_dsp_resume(codec)	/* NOP */
3458 #else
3459 #define alc5505_dsp_suspend(codec)	alc5505_dsp_halt(codec)
3460 #define alc5505_dsp_resume(codec)	alc5505_dsp_back_from_halt(codec)
3461 #endif
3462 
3463 #ifdef CONFIG_PM
3464 static int alc269_suspend(struct hda_codec *codec)
3465 {
3466 	struct alc_spec *spec = codec->spec;
3467 
3468 	if (spec->has_alc5505_dsp)
3469 		alc5505_dsp_suspend(codec);
3470 	return alc_suspend(codec);
3471 }
3472 
3473 static int alc269_resume(struct hda_codec *codec)
3474 {
3475 	struct alc_spec *spec = codec->spec;
3476 
3477 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3478 		alc269vb_toggle_power_output(codec, 0);
3479 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3480 			(alc_get_coef0(codec) & 0x00ff) == 0x018) {
3481 		msleep(150);
3482 	}
3483 
3484 	codec->patch_ops.init(codec);
3485 
3486 	if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3487 		alc269vb_toggle_power_output(codec, 1);
3488 	if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3489 			(alc_get_coef0(codec) & 0x00ff) == 0x017) {
3490 		msleep(200);
3491 	}
3492 
3493 	regcache_sync(codec->core.regmap);
3494 	hda_call_check_power_status(codec, 0x01);
3495 
3496 	/* on some machine, the BIOS will clear the codec gpio data when enter
3497 	 * suspend, and won't restore the data after resume, so we restore it
3498 	 * in the driver.
3499 	 */
3500 	if (spec->gpio_data)
3501 		alc_write_gpio_data(codec);
3502 
3503 	if (spec->has_alc5505_dsp)
3504 		alc5505_dsp_resume(codec);
3505 
3506 	return 0;
3507 }
3508 #endif /* CONFIG_PM */
3509 
3510 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
3511 						 const struct hda_fixup *fix, int action)
3512 {
3513 	struct alc_spec *spec = codec->spec;
3514 
3515 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
3516 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3517 }
3518 
3519 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3520 						 const struct hda_fixup *fix,
3521 						 int action)
3522 {
3523 	unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3524 	unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3525 
3526 	if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3527 		snd_hda_codec_set_pincfg(codec, 0x19,
3528 			(cfg_headphone & ~AC_DEFCFG_DEVICE) |
3529 			(AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3530 }
3531 
3532 static void alc269_fixup_hweq(struct hda_codec *codec,
3533 			       const struct hda_fixup *fix, int action)
3534 {
3535 	if (action == HDA_FIXUP_ACT_INIT)
3536 		alc_update_coef_idx(codec, 0x1e, 0, 0x80);
3537 }
3538 
3539 static void alc269_fixup_headset_mic(struct hda_codec *codec,
3540 				       const struct hda_fixup *fix, int action)
3541 {
3542 	struct alc_spec *spec = codec->spec;
3543 
3544 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
3545 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3546 }
3547 
3548 static void alc271_fixup_dmic(struct hda_codec *codec,
3549 			      const struct hda_fixup *fix, int action)
3550 {
3551 	static const struct hda_verb verbs[] = {
3552 		{0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3553 		{0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3554 		{}
3555 	};
3556 	unsigned int cfg;
3557 
3558 	if (strcmp(codec->core.chip_name, "ALC271X") &&
3559 	    strcmp(codec->core.chip_name, "ALC269VB"))
3560 		return;
3561 	cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3562 	if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3563 		snd_hda_sequence_write(codec, verbs);
3564 }
3565 
3566 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
3567 				 const struct hda_fixup *fix, int action)
3568 {
3569 	struct alc_spec *spec = codec->spec;
3570 
3571 	if (action != HDA_FIXUP_ACT_PROBE)
3572 		return;
3573 
3574 	/* Due to a hardware problem on Lenovo Ideadpad, we need to
3575 	 * fix the sample rate of analog I/O to 44.1kHz
3576 	 */
3577 	spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3578 	spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
3579 }
3580 
3581 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
3582 				     const struct hda_fixup *fix, int action)
3583 {
3584 	/* The digital-mic unit sends PDM (differential signal) instead of
3585 	 * the standard PCM, thus you can't record a valid mono stream as is.
3586 	 * Below is a workaround specific to ALC269 to control the dmic
3587 	 * signal source as mono.
3588 	 */
3589 	if (action == HDA_FIXUP_ACT_INIT)
3590 		alc_update_coef_idx(codec, 0x07, 0, 0x80);
3591 }
3592 
3593 static void alc269_quanta_automute(struct hda_codec *codec)
3594 {
3595 	snd_hda_gen_update_outputs(codec);
3596 
3597 	alc_write_coef_idx(codec, 0x0c, 0x680);
3598 	alc_write_coef_idx(codec, 0x0c, 0x480);
3599 }
3600 
3601 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
3602 				     const struct hda_fixup *fix, int action)
3603 {
3604 	struct alc_spec *spec = codec->spec;
3605 	if (action != HDA_FIXUP_ACT_PROBE)
3606 		return;
3607 	spec->gen.automute_hook = alc269_quanta_automute;
3608 }
3609 
3610 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3611 					 struct hda_jack_callback *jack)
3612 {
3613 	struct alc_spec *spec = codec->spec;
3614 	int vref;
3615 	msleep(200);
3616 	snd_hda_gen_hp_automute(codec, jack);
3617 
3618 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3619 	msleep(100);
3620 	snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3621 			    vref);
3622 	msleep(500);
3623 	snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3624 			    vref);
3625 }
3626 
3627 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3628 				     const struct hda_fixup *fix, int action)
3629 {
3630 	struct alc_spec *spec = codec->spec;
3631 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3632 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3633 		spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3634 	}
3635 }
3636 
3637 
3638 /* update mute-LED according to the speaker mute state via mic VREF pin */
3639 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
3640 {
3641 	struct hda_codec *codec = private_data;
3642 	struct alc_spec *spec = codec->spec;
3643 	unsigned int pinval;
3644 
3645 	if (spec->mute_led_polarity)
3646 		enabled = !enabled;
3647 	pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3648 	pinval &= ~AC_PINCTL_VREFEN;
3649 	pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
3650 	if (spec->mute_led_nid) {
3651 		/* temporarily power up/down for setting VREF */
3652 		snd_hda_power_up_pm(codec);
3653 		snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
3654 		snd_hda_power_down_pm(codec);
3655 	}
3656 }
3657 
3658 /* Make sure the led works even in runtime suspend */
3659 static unsigned int led_power_filter(struct hda_codec *codec,
3660 						  hda_nid_t nid,
3661 						  unsigned int power_state)
3662 {
3663 	struct alc_spec *spec = codec->spec;
3664 
3665 	if (power_state != AC_PWRST_D3 || nid == 0 ||
3666 	    (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
3667 		return power_state;
3668 
3669 	/* Set pin ctl again, it might have just been set to 0 */
3670 	snd_hda_set_pin_ctl(codec, nid,
3671 			    snd_hda_codec_get_pin_target(codec, nid));
3672 
3673 	return snd_hda_gen_path_power_filter(codec, nid, power_state);
3674 }
3675 
3676 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3677 				     const struct hda_fixup *fix, int action)
3678 {
3679 	struct alc_spec *spec = codec->spec;
3680 	const struct dmi_device *dev = NULL;
3681 
3682 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
3683 		return;
3684 
3685 	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3686 		int pol, pin;
3687 		if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3688 			continue;
3689 		if (pin < 0x0a || pin >= 0x10)
3690 			break;
3691 		spec->mute_led_polarity = pol;
3692 		spec->mute_led_nid = pin - 0x0a + 0x18;
3693 		spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3694 		spec->gen.vmaster_mute_enum = 1;
3695 		codec->power_filter = led_power_filter;
3696 		codec_dbg(codec,
3697 			  "Detected mute LED for %x:%d\n", spec->mute_led_nid,
3698 			   spec->mute_led_polarity);
3699 		break;
3700 	}
3701 }
3702 
3703 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
3704 					  const struct hda_fixup *fix,
3705 					  int action, hda_nid_t pin)
3706 {
3707 	struct alc_spec *spec = codec->spec;
3708 
3709 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3710 		spec->mute_led_polarity = 0;
3711 		spec->mute_led_nid = pin;
3712 		spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3713 		spec->gen.vmaster_mute_enum = 1;
3714 		codec->power_filter = led_power_filter;
3715 	}
3716 }
3717 
3718 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3719 				const struct hda_fixup *fix, int action)
3720 {
3721 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
3722 }
3723 
3724 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3725 				const struct hda_fixup *fix, int action)
3726 {
3727 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
3728 }
3729 
3730 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
3731 				const struct hda_fixup *fix, int action)
3732 {
3733 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
3734 }
3735 
3736 /* update LED status via GPIO */
3737 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
3738 				bool enabled)
3739 {
3740 	struct alc_spec *spec = codec->spec;
3741 
3742 	if (spec->mute_led_polarity)
3743 		enabled = !enabled;
3744 	alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
3745 }
3746 
3747 /* turn on/off mute LED via GPIO per vmaster hook */
3748 static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
3749 {
3750 	struct hda_codec *codec = private_data;
3751 	struct alc_spec *spec = codec->spec;
3752 
3753 	alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
3754 }
3755 
3756 /* turn on/off mic-mute LED via GPIO per capture hook */
3757 static void alc_gpio_micmute_update(struct hda_codec *codec)
3758 {
3759 	struct alc_spec *spec = codec->spec;
3760 
3761 	alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
3762 			    spec->gen.micmute_led.led_value);
3763 }
3764 
3765 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
3766 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
3767 				  int action,
3768 				  unsigned int mute_mask,
3769 				  unsigned int micmute_mask)
3770 {
3771 	struct alc_spec *spec = codec->spec;
3772 
3773 	alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
3774 
3775 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
3776 		return;
3777 	if (mute_mask) {
3778 		spec->gpio_mute_led_mask = mute_mask;
3779 		spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3780 	}
3781 	if (micmute_mask) {
3782 		spec->gpio_mic_led_mask = micmute_mask;
3783 		snd_hda_gen_add_micmute_led(codec, alc_gpio_micmute_update);
3784 	}
3785 }
3786 
3787 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3788 				const struct hda_fixup *fix, int action)
3789 {
3790 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
3791 }
3792 
3793 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
3794 				const struct hda_fixup *fix, int action)
3795 {
3796 	alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
3797 }
3798 
3799 /* turn on/off mic-mute LED per capture hook */
3800 static void alc_cap_micmute_update(struct hda_codec *codec)
3801 {
3802 	struct alc_spec *spec = codec->spec;
3803 	unsigned int pinval;
3804 
3805 	if (!spec->cap_mute_led_nid)
3806 		return;
3807 	pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
3808 	pinval &= ~AC_PINCTL_VREFEN;
3809 	if (spec->gen.micmute_led.led_value)
3810 		pinval |= AC_PINCTL_VREF_80;
3811 	else
3812 		pinval |= AC_PINCTL_VREF_HIZ;
3813 	snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3814 }
3815 
3816 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3817 				const struct hda_fixup *fix, int action)
3818 {
3819 	struct alc_spec *spec = codec->spec;
3820 
3821 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
3822 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3823 		/* Like hp_gpio_mic1_led, but also needs GPIO4 low to
3824 		 * enable headphone amp
3825 		 */
3826 		spec->gpio_mask |= 0x10;
3827 		spec->gpio_dir |= 0x10;
3828 		spec->cap_mute_led_nid = 0x18;
3829 		snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
3830 		codec->power_filter = led_power_filter;
3831 	}
3832 }
3833 
3834 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3835 				   const struct hda_fixup *fix, int action)
3836 {
3837 	struct alc_spec *spec = codec->spec;
3838 
3839 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
3840 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3841 		spec->cap_mute_led_nid = 0x18;
3842 		snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
3843 		codec->power_filter = led_power_filter;
3844 	}
3845 }
3846 
3847 #if IS_REACHABLE(CONFIG_INPUT)
3848 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
3849 				   struct hda_jack_callback *event)
3850 {
3851 	struct alc_spec *spec = codec->spec;
3852 
3853 	/* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
3854 	   send both key on and key off event for every interrupt. */
3855 	input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
3856 	input_sync(spec->kb_dev);
3857 	input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
3858 	input_sync(spec->kb_dev);
3859 }
3860 
3861 static int alc_register_micmute_input_device(struct hda_codec *codec)
3862 {
3863 	struct alc_spec *spec = codec->spec;
3864 	int i;
3865 
3866 	spec->kb_dev = input_allocate_device();
3867 	if (!spec->kb_dev) {
3868 		codec_err(codec, "Out of memory (input_allocate_device)\n");
3869 		return -ENOMEM;
3870 	}
3871 
3872 	spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
3873 
3874 	spec->kb_dev->name = "Microphone Mute Button";
3875 	spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
3876 	spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
3877 	spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
3878 	spec->kb_dev->keycode = spec->alc_mute_keycode_map;
3879 	for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
3880 		set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
3881 
3882 	if (input_register_device(spec->kb_dev)) {
3883 		codec_err(codec, "input_register_device failed\n");
3884 		input_free_device(spec->kb_dev);
3885 		spec->kb_dev = NULL;
3886 		return -ENOMEM;
3887 	}
3888 
3889 	return 0;
3890 }
3891 
3892 /* GPIO1 = set according to SKU external amp
3893  * GPIO2 = mic mute hotkey
3894  * GPIO3 = mute LED
3895  * GPIO4 = mic mute LED
3896  */
3897 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
3898 					     const struct hda_fixup *fix, int action)
3899 {
3900 	struct alc_spec *spec = codec->spec;
3901 
3902 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
3903 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3904 		spec->init_amp = ALC_INIT_DEFAULT;
3905 		if (alc_register_micmute_input_device(codec) != 0)
3906 			return;
3907 
3908 		spec->gpio_mask |= 0x06;
3909 		spec->gpio_dir |= 0x02;
3910 		spec->gpio_data |= 0x02;
3911 		snd_hda_codec_write_cache(codec, codec->core.afg, 0,
3912 					  AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
3913 		snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
3914 						    gpio2_mic_hotkey_event);
3915 		return;
3916 	}
3917 
3918 	if (!spec->kb_dev)
3919 		return;
3920 
3921 	switch (action) {
3922 	case HDA_FIXUP_ACT_FREE:
3923 		input_unregister_device(spec->kb_dev);
3924 		spec->kb_dev = NULL;
3925 	}
3926 }
3927 
3928 /* Line2 = mic mute hotkey
3929  * GPIO2 = mic mute LED
3930  */
3931 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
3932 					     const struct hda_fixup *fix, int action)
3933 {
3934 	struct alc_spec *spec = codec->spec;
3935 
3936 	alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
3937 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3938 		spec->init_amp = ALC_INIT_DEFAULT;
3939 		if (alc_register_micmute_input_device(codec) != 0)
3940 			return;
3941 
3942 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
3943 						    gpio2_mic_hotkey_event);
3944 		return;
3945 	}
3946 
3947 	if (!spec->kb_dev)
3948 		return;
3949 
3950 	switch (action) {
3951 	case HDA_FIXUP_ACT_FREE:
3952 		input_unregister_device(spec->kb_dev);
3953 		spec->kb_dev = NULL;
3954 	}
3955 }
3956 #else /* INPUT */
3957 #define alc280_fixup_hp_gpio2_mic_hotkey	NULL
3958 #define alc233_fixup_lenovo_line2_mic_hotkey	NULL
3959 #endif /* INPUT */
3960 
3961 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3962 				const struct hda_fixup *fix, int action)
3963 {
3964 	struct alc_spec *spec = codec->spec;
3965 
3966 	alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
3967 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3968 		spec->cap_mute_led_nid = 0x18;
3969 		snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
3970 	}
3971 }
3972 
3973 static struct coef_fw alc225_pre_hsmode[] = {
3974 	UPDATE_COEF(0x4a, 1<<8, 0),
3975 	UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
3976 	UPDATE_COEF(0x63, 3<<14, 3<<14),
3977 	UPDATE_COEF(0x4a, 3<<4, 2<<4),
3978 	UPDATE_COEF(0x4a, 3<<10, 3<<10),
3979 	UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
3980 	UPDATE_COEF(0x4a, 3<<10, 0),
3981 	{}
3982 };
3983 
3984 static void alc_headset_mode_unplugged(struct hda_codec *codec)
3985 {
3986 	static struct coef_fw coef0255[] = {
3987 		WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
3988 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
3989 		WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
3990 		WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
3991 		{}
3992 	};
3993 	static struct coef_fw coef0255_1[] = {
3994 		WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
3995 		{}
3996 	};
3997 	static struct coef_fw coef0256[] = {
3998 		WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
3999 		{}
4000 	};
4001 	static struct coef_fw coef0233[] = {
4002 		WRITE_COEF(0x1b, 0x0c0b),
4003 		WRITE_COEF(0x45, 0xc429),
4004 		UPDATE_COEF(0x35, 0x4000, 0),
4005 		WRITE_COEF(0x06, 0x2104),
4006 		WRITE_COEF(0x1a, 0x0001),
4007 		WRITE_COEF(0x26, 0x0004),
4008 		WRITE_COEF(0x32, 0x42a3),
4009 		{}
4010 	};
4011 	static struct coef_fw coef0288[] = {
4012 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4013 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4014 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4015 		UPDATE_COEF(0x66, 0x0008, 0),
4016 		UPDATE_COEF(0x67, 0x2000, 0),
4017 		{}
4018 	};
4019 	static struct coef_fw coef0298[] = {
4020 		UPDATE_COEF(0x19, 0x1300, 0x0300),
4021 		{}
4022 	};
4023 	static struct coef_fw coef0292[] = {
4024 		WRITE_COEF(0x76, 0x000e),
4025 		WRITE_COEF(0x6c, 0x2400),
4026 		WRITE_COEF(0x18, 0x7308),
4027 		WRITE_COEF(0x6b, 0xc429),
4028 		{}
4029 	};
4030 	static struct coef_fw coef0293[] = {
4031 		UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4032 		UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4033 		UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4034 		UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4035 		WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4036 		UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4037 		{}
4038 	};
4039 	static struct coef_fw coef0668[] = {
4040 		WRITE_COEF(0x15, 0x0d40),
4041 		WRITE_COEF(0xb7, 0x802b),
4042 		{}
4043 	};
4044 	static struct coef_fw coef0225[] = {
4045 		UPDATE_COEF(0x63, 3<<14, 0),
4046 		{}
4047 	};
4048 	static struct coef_fw coef0274[] = {
4049 		UPDATE_COEF(0x4a, 0x0100, 0),
4050 		UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4051 		UPDATE_COEF(0x6b, 0xf000, 0x5000),
4052 		UPDATE_COEF(0x4a, 0x0010, 0),
4053 		UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4054 		WRITE_COEF(0x45, 0x5289),
4055 		UPDATE_COEF(0x4a, 0x0c00, 0),
4056 		{}
4057 	};
4058 
4059 	switch (codec->core.vendor_id) {
4060 	case 0x10ec0255:
4061 		alc_process_coef_fw(codec, coef0255_1);
4062 		alc_process_coef_fw(codec, coef0255);
4063 		break;
4064 	case 0x10ec0236:
4065 	case 0x10ec0256:
4066 		alc_process_coef_fw(codec, coef0256);
4067 		alc_process_coef_fw(codec, coef0255);
4068 		break;
4069 	case 0x10ec0234:
4070 	case 0x10ec0274:
4071 	case 0x10ec0294:
4072 		alc_process_coef_fw(codec, coef0274);
4073 		break;
4074 	case 0x10ec0233:
4075 	case 0x10ec0283:
4076 		alc_process_coef_fw(codec, coef0233);
4077 		break;
4078 	case 0x10ec0286:
4079 	case 0x10ec0288:
4080 		alc_process_coef_fw(codec, coef0288);
4081 		break;
4082 	case 0x10ec0298:
4083 		alc_process_coef_fw(codec, coef0298);
4084 		alc_process_coef_fw(codec, coef0288);
4085 		break;
4086 	case 0x10ec0292:
4087 		alc_process_coef_fw(codec, coef0292);
4088 		break;
4089 	case 0x10ec0293:
4090 		alc_process_coef_fw(codec, coef0293);
4091 		break;
4092 	case 0x10ec0668:
4093 		alc_process_coef_fw(codec, coef0668);
4094 		break;
4095 	case 0x10ec0215:
4096 	case 0x10ec0225:
4097 	case 0x10ec0285:
4098 	case 0x10ec0295:
4099 	case 0x10ec0289:
4100 	case 0x10ec0299:
4101 		alc_process_coef_fw(codec, coef0225);
4102 		break;
4103 	case 0x10ec0867:
4104 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4105 		break;
4106 	}
4107 	codec_dbg(codec, "Headset jack set to unplugged mode.\n");
4108 }
4109 
4110 
4111 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4112 				    hda_nid_t mic_pin)
4113 {
4114 	static struct coef_fw coef0255[] = {
4115 		WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4116 		WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4117 		{}
4118 	};
4119 	static struct coef_fw coef0233[] = {
4120 		UPDATE_COEF(0x35, 0, 1<<14),
4121 		WRITE_COEF(0x06, 0x2100),
4122 		WRITE_COEF(0x1a, 0x0021),
4123 		WRITE_COEF(0x26, 0x008c),
4124 		{}
4125 	};
4126 	static struct coef_fw coef0288[] = {
4127 		UPDATE_COEF(0x4f, 0x00c0, 0),
4128 		UPDATE_COEF(0x50, 0x2000, 0),
4129 		UPDATE_COEF(0x56, 0x0006, 0),
4130 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4131 		UPDATE_COEF(0x66, 0x0008, 0x0008),
4132 		UPDATE_COEF(0x67, 0x2000, 0x2000),
4133 		{}
4134 	};
4135 	static struct coef_fw coef0292[] = {
4136 		WRITE_COEF(0x19, 0xa208),
4137 		WRITE_COEF(0x2e, 0xacf0),
4138 		{}
4139 	};
4140 	static struct coef_fw coef0293[] = {
4141 		UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4142 		UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4143 		UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4144 		{}
4145 	};
4146 	static struct coef_fw coef0688[] = {
4147 		WRITE_COEF(0xb7, 0x802b),
4148 		WRITE_COEF(0xb5, 0x1040),
4149 		UPDATE_COEF(0xc3, 0, 1<<12),
4150 		{}
4151 	};
4152 	static struct coef_fw coef0225[] = {
4153 		UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4154 		UPDATE_COEF(0x4a, 3<<4, 2<<4),
4155 		UPDATE_COEF(0x63, 3<<14, 0),
4156 		{}
4157 	};
4158 	static struct coef_fw coef0274[] = {
4159 		UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4160 		UPDATE_COEF(0x4a, 0x0010, 0),
4161 		UPDATE_COEF(0x6b, 0xf000, 0),
4162 		{}
4163 	};
4164 
4165 	switch (codec->core.vendor_id) {
4166 	case 0x10ec0236:
4167 	case 0x10ec0255:
4168 	case 0x10ec0256:
4169 		alc_write_coef_idx(codec, 0x45, 0xc489);
4170 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4171 		alc_process_coef_fw(codec, coef0255);
4172 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4173 		break;
4174 	case 0x10ec0234:
4175 	case 0x10ec0274:
4176 	case 0x10ec0294:
4177 		alc_write_coef_idx(codec, 0x45, 0x4689);
4178 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4179 		alc_process_coef_fw(codec, coef0274);
4180 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4181 		break;
4182 	case 0x10ec0233:
4183 	case 0x10ec0283:
4184 		alc_write_coef_idx(codec, 0x45, 0xc429);
4185 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4186 		alc_process_coef_fw(codec, coef0233);
4187 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4188 		break;
4189 	case 0x10ec0286:
4190 	case 0x10ec0288:
4191 	case 0x10ec0298:
4192 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4193 		alc_process_coef_fw(codec, coef0288);
4194 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4195 		break;
4196 	case 0x10ec0292:
4197 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4198 		alc_process_coef_fw(codec, coef0292);
4199 		break;
4200 	case 0x10ec0293:
4201 		/* Set to TRS mode */
4202 		alc_write_coef_idx(codec, 0x45, 0xc429);
4203 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4204 		alc_process_coef_fw(codec, coef0293);
4205 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4206 		break;
4207 	case 0x10ec0867:
4208 		alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4209 		/* fallthru */
4210 	case 0x10ec0221:
4211 	case 0x10ec0662:
4212 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4213 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4214 		break;
4215 	case 0x10ec0668:
4216 		alc_write_coef_idx(codec, 0x11, 0x0001);
4217 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4218 		alc_process_coef_fw(codec, coef0688);
4219 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4220 		break;
4221 	case 0x10ec0215:
4222 	case 0x10ec0225:
4223 	case 0x10ec0285:
4224 	case 0x10ec0295:
4225 	case 0x10ec0289:
4226 	case 0x10ec0299:
4227 		alc_process_coef_fw(codec, alc225_pre_hsmode);
4228 		alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4229 		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4230 		alc_process_coef_fw(codec, coef0225);
4231 		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4232 		break;
4233 	}
4234 	codec_dbg(codec, "Headset jack set to mic-in mode.\n");
4235 }
4236 
4237 static void alc_headset_mode_default(struct hda_codec *codec)
4238 {
4239 	static struct coef_fw coef0225[] = {
4240 		UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4241 		UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4242 		UPDATE_COEF(0x49, 3<<8, 0<<8),
4243 		UPDATE_COEF(0x4a, 3<<4, 3<<4),
4244 		UPDATE_COEF(0x63, 3<<14, 0),
4245 		UPDATE_COEF(0x67, 0xf000, 0x3000),
4246 		{}
4247 	};
4248 	static struct coef_fw coef0255[] = {
4249 		WRITE_COEF(0x45, 0xc089),
4250 		WRITE_COEF(0x45, 0xc489),
4251 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4252 		WRITE_COEF(0x49, 0x0049),
4253 		{}
4254 	};
4255 	static struct coef_fw coef0233[] = {
4256 		WRITE_COEF(0x06, 0x2100),
4257 		WRITE_COEF(0x32, 0x4ea3),
4258 		{}
4259 	};
4260 	static struct coef_fw coef0288[] = {
4261 		UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
4262 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4263 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4264 		UPDATE_COEF(0x66, 0x0008, 0),
4265 		UPDATE_COEF(0x67, 0x2000, 0),
4266 		{}
4267 	};
4268 	static struct coef_fw coef0292[] = {
4269 		WRITE_COEF(0x76, 0x000e),
4270 		WRITE_COEF(0x6c, 0x2400),
4271 		WRITE_COEF(0x6b, 0xc429),
4272 		WRITE_COEF(0x18, 0x7308),
4273 		{}
4274 	};
4275 	static struct coef_fw coef0293[] = {
4276 		UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4277 		WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
4278 		UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4279 		{}
4280 	};
4281 	static struct coef_fw coef0688[] = {
4282 		WRITE_COEF(0x11, 0x0041),
4283 		WRITE_COEF(0x15, 0x0d40),
4284 		WRITE_COEF(0xb7, 0x802b),
4285 		{}
4286 	};
4287 	static struct coef_fw coef0274[] = {
4288 		WRITE_COEF(0x45, 0x4289),
4289 		UPDATE_COEF(0x4a, 0x0010, 0x0010),
4290 		UPDATE_COEF(0x6b, 0x0f00, 0),
4291 		UPDATE_COEF(0x49, 0x0300, 0x0300),
4292 		{}
4293 	};
4294 
4295 	switch (codec->core.vendor_id) {
4296 	case 0x10ec0215:
4297 	case 0x10ec0225:
4298 	case 0x10ec0285:
4299 	case 0x10ec0295:
4300 	case 0x10ec0289:
4301 	case 0x10ec0299:
4302 		alc_process_coef_fw(codec, alc225_pre_hsmode);
4303 		alc_process_coef_fw(codec, coef0225);
4304 		break;
4305 	case 0x10ec0236:
4306 	case 0x10ec0255:
4307 	case 0x10ec0256:
4308 		alc_process_coef_fw(codec, coef0255);
4309 		break;
4310 	case 0x10ec0234:
4311 	case 0x10ec0274:
4312 	case 0x10ec0294:
4313 		alc_process_coef_fw(codec, coef0274);
4314 		break;
4315 	case 0x10ec0233:
4316 	case 0x10ec0283:
4317 		alc_process_coef_fw(codec, coef0233);
4318 		break;
4319 	case 0x10ec0286:
4320 	case 0x10ec0288:
4321 	case 0x10ec0298:
4322 		alc_process_coef_fw(codec, coef0288);
4323 		break;
4324 	case 0x10ec0292:
4325 		alc_process_coef_fw(codec, coef0292);
4326 		break;
4327 	case 0x10ec0293:
4328 		alc_process_coef_fw(codec, coef0293);
4329 		break;
4330 	case 0x10ec0668:
4331 		alc_process_coef_fw(codec, coef0688);
4332 		break;
4333 	case 0x10ec0867:
4334 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4335 		break;
4336 	}
4337 	codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
4338 }
4339 
4340 /* Iphone type */
4341 static void alc_headset_mode_ctia(struct hda_codec *codec)
4342 {
4343 	int val;
4344 
4345 	static struct coef_fw coef0255[] = {
4346 		WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4347 		WRITE_COEF(0x1b, 0x0c2b),
4348 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4349 		{}
4350 	};
4351 	static struct coef_fw coef0256[] = {
4352 		WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4353 		WRITE_COEF(0x1b, 0x0c6b),
4354 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4355 		{}
4356 	};
4357 	static struct coef_fw coef0233[] = {
4358 		WRITE_COEF(0x45, 0xd429),
4359 		WRITE_COEF(0x1b, 0x0c2b),
4360 		WRITE_COEF(0x32, 0x4ea3),
4361 		{}
4362 	};
4363 	static struct coef_fw coef0288[] = {
4364 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4365 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4366 		UPDATE_COEF(0x66, 0x0008, 0),
4367 		UPDATE_COEF(0x67, 0x2000, 0),
4368 		{}
4369 	};
4370 	static struct coef_fw coef0292[] = {
4371 		WRITE_COEF(0x6b, 0xd429),
4372 		WRITE_COEF(0x76, 0x0008),
4373 		WRITE_COEF(0x18, 0x7388),
4374 		{}
4375 	};
4376 	static struct coef_fw coef0293[] = {
4377 		WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
4378 		UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4379 		{}
4380 	};
4381 	static struct coef_fw coef0688[] = {
4382 		WRITE_COEF(0x11, 0x0001),
4383 		WRITE_COEF(0x15, 0x0d60),
4384 		WRITE_COEF(0xc3, 0x0000),
4385 		{}
4386 	};
4387 	static struct coef_fw coef0225_1[] = {
4388 		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4389 		UPDATE_COEF(0x63, 3<<14, 2<<14),
4390 		{}
4391 	};
4392 	static struct coef_fw coef0225_2[] = {
4393 		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4394 		UPDATE_COEF(0x63, 3<<14, 1<<14),
4395 		{}
4396 	};
4397 
4398 	switch (codec->core.vendor_id) {
4399 	case 0x10ec0255:
4400 		alc_process_coef_fw(codec, coef0255);
4401 		break;
4402 	case 0x10ec0236:
4403 	case 0x10ec0256:
4404 		alc_process_coef_fw(codec, coef0256);
4405 		break;
4406 	case 0x10ec0234:
4407 	case 0x10ec0274:
4408 	case 0x10ec0294:
4409 		alc_write_coef_idx(codec, 0x45, 0xd689);
4410 		break;
4411 	case 0x10ec0233:
4412 	case 0x10ec0283:
4413 		alc_process_coef_fw(codec, coef0233);
4414 		break;
4415 	case 0x10ec0298:
4416 		val = alc_read_coef_idx(codec, 0x50);
4417 		if (val & (1 << 12)) {
4418 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4419 			alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4420 			msleep(300);
4421 		} else {
4422 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4423 			alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4424 			msleep(300);
4425 		}
4426 		break;
4427 	case 0x10ec0286:
4428 	case 0x10ec0288:
4429 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4430 		msleep(300);
4431 		alc_process_coef_fw(codec, coef0288);
4432 		break;
4433 	case 0x10ec0292:
4434 		alc_process_coef_fw(codec, coef0292);
4435 		break;
4436 	case 0x10ec0293:
4437 		alc_process_coef_fw(codec, coef0293);
4438 		break;
4439 	case 0x10ec0668:
4440 		alc_process_coef_fw(codec, coef0688);
4441 		break;
4442 	case 0x10ec0215:
4443 	case 0x10ec0225:
4444 	case 0x10ec0285:
4445 	case 0x10ec0295:
4446 	case 0x10ec0289:
4447 	case 0x10ec0299:
4448 		val = alc_read_coef_idx(codec, 0x45);
4449 		if (val & (1 << 9))
4450 			alc_process_coef_fw(codec, coef0225_2);
4451 		else
4452 			alc_process_coef_fw(codec, coef0225_1);
4453 		break;
4454 	case 0x10ec0867:
4455 		alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4456 		break;
4457 	}
4458 	codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
4459 }
4460 
4461 /* Nokia type */
4462 static void alc_headset_mode_omtp(struct hda_codec *codec)
4463 {
4464 	static struct coef_fw coef0255[] = {
4465 		WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4466 		WRITE_COEF(0x1b, 0x0c2b),
4467 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4468 		{}
4469 	};
4470 	static struct coef_fw coef0256[] = {
4471 		WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4472 		WRITE_COEF(0x1b, 0x0c6b),
4473 		WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4474 		{}
4475 	};
4476 	static struct coef_fw coef0233[] = {
4477 		WRITE_COEF(0x45, 0xe429),
4478 		WRITE_COEF(0x1b, 0x0c2b),
4479 		WRITE_COEF(0x32, 0x4ea3),
4480 		{}
4481 	};
4482 	static struct coef_fw coef0288[] = {
4483 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4484 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4485 		UPDATE_COEF(0x66, 0x0008, 0),
4486 		UPDATE_COEF(0x67, 0x2000, 0),
4487 		{}
4488 	};
4489 	static struct coef_fw coef0292[] = {
4490 		WRITE_COEF(0x6b, 0xe429),
4491 		WRITE_COEF(0x76, 0x0008),
4492 		WRITE_COEF(0x18, 0x7388),
4493 		{}
4494 	};
4495 	static struct coef_fw coef0293[] = {
4496 		WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
4497 		UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4498 		{}
4499 	};
4500 	static struct coef_fw coef0688[] = {
4501 		WRITE_COEF(0x11, 0x0001),
4502 		WRITE_COEF(0x15, 0x0d50),
4503 		WRITE_COEF(0xc3, 0x0000),
4504 		{}
4505 	};
4506 	static struct coef_fw coef0225[] = {
4507 		UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
4508 		UPDATE_COEF(0x63, 3<<14, 2<<14),
4509 		{}
4510 	};
4511 
4512 	switch (codec->core.vendor_id) {
4513 	case 0x10ec0255:
4514 		alc_process_coef_fw(codec, coef0255);
4515 		break;
4516 	case 0x10ec0236:
4517 	case 0x10ec0256:
4518 		alc_process_coef_fw(codec, coef0256);
4519 		break;
4520 	case 0x10ec0234:
4521 	case 0x10ec0274:
4522 	case 0x10ec0294:
4523 		alc_write_coef_idx(codec, 0x45, 0xe689);
4524 		break;
4525 	case 0x10ec0233:
4526 	case 0x10ec0283:
4527 		alc_process_coef_fw(codec, coef0233);
4528 		break;
4529 	case 0x10ec0298:
4530 		alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
4531 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4532 		msleep(300);
4533 		break;
4534 	case 0x10ec0286:
4535 	case 0x10ec0288:
4536 		alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4537 		msleep(300);
4538 		alc_process_coef_fw(codec, coef0288);
4539 		break;
4540 	case 0x10ec0292:
4541 		alc_process_coef_fw(codec, coef0292);
4542 		break;
4543 	case 0x10ec0293:
4544 		alc_process_coef_fw(codec, coef0293);
4545 		break;
4546 	case 0x10ec0668:
4547 		alc_process_coef_fw(codec, coef0688);
4548 		break;
4549 	case 0x10ec0215:
4550 	case 0x10ec0225:
4551 	case 0x10ec0285:
4552 	case 0x10ec0295:
4553 	case 0x10ec0289:
4554 	case 0x10ec0299:
4555 		alc_process_coef_fw(codec, coef0225);
4556 		break;
4557 	}
4558 	codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
4559 }
4560 
4561 static void alc_determine_headset_type(struct hda_codec *codec)
4562 {
4563 	int val;
4564 	bool is_ctia = false;
4565 	struct alc_spec *spec = codec->spec;
4566 	static struct coef_fw coef0255[] = {
4567 		WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
4568 		WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
4569  conteol) */
4570 		{}
4571 	};
4572 	static struct coef_fw coef0288[] = {
4573 		UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
4574 		{}
4575 	};
4576 	static struct coef_fw coef0298[] = {
4577 		UPDATE_COEF(0x50, 0x2000, 0x2000),
4578 		UPDATE_COEF(0x56, 0x0006, 0x0006),
4579 		UPDATE_COEF(0x66, 0x0008, 0),
4580 		UPDATE_COEF(0x67, 0x2000, 0),
4581 		UPDATE_COEF(0x19, 0x1300, 0x1300),
4582 		{}
4583 	};
4584 	static struct coef_fw coef0293[] = {
4585 		UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
4586 		WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
4587 		{}
4588 	};
4589 	static struct coef_fw coef0688[] = {
4590 		WRITE_COEF(0x11, 0x0001),
4591 		WRITE_COEF(0xb7, 0x802b),
4592 		WRITE_COEF(0x15, 0x0d60),
4593 		WRITE_COEF(0xc3, 0x0c00),
4594 		{}
4595 	};
4596 	static struct coef_fw coef0274[] = {
4597 		UPDATE_COEF(0x4a, 0x0010, 0),
4598 		UPDATE_COEF(0x4a, 0x8000, 0),
4599 		WRITE_COEF(0x45, 0xd289),
4600 		UPDATE_COEF(0x49, 0x0300, 0x0300),
4601 		{}
4602 	};
4603 
4604 	switch (codec->core.vendor_id) {
4605 	case 0x10ec0236:
4606 	case 0x10ec0255:
4607 	case 0x10ec0256:
4608 		alc_process_coef_fw(codec, coef0255);
4609 		msleep(300);
4610 		val = alc_read_coef_idx(codec, 0x46);
4611 		is_ctia = (val & 0x0070) == 0x0070;
4612 		break;
4613 	case 0x10ec0234:
4614 	case 0x10ec0274:
4615 	case 0x10ec0294:
4616 		alc_process_coef_fw(codec, coef0274);
4617 		msleep(80);
4618 		val = alc_read_coef_idx(codec, 0x46);
4619 		is_ctia = (val & 0x00f0) == 0x00f0;
4620 		break;
4621 	case 0x10ec0233:
4622 	case 0x10ec0283:
4623 		alc_write_coef_idx(codec, 0x45, 0xd029);
4624 		msleep(300);
4625 		val = alc_read_coef_idx(codec, 0x46);
4626 		is_ctia = (val & 0x0070) == 0x0070;
4627 		break;
4628 	case 0x10ec0298:
4629 		snd_hda_codec_write(codec, 0x21, 0,
4630 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4631 		msleep(100);
4632 		snd_hda_codec_write(codec, 0x21, 0,
4633 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4634 		msleep(200);
4635 
4636 		val = alc_read_coef_idx(codec, 0x50);
4637 		if (val & (1 << 12)) {
4638 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4639 			alc_process_coef_fw(codec, coef0288);
4640 			msleep(350);
4641 			val = alc_read_coef_idx(codec, 0x50);
4642 			is_ctia = (val & 0x0070) == 0x0070;
4643 		} else {
4644 			alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4645 			alc_process_coef_fw(codec, coef0288);
4646 			msleep(350);
4647 			val = alc_read_coef_idx(codec, 0x50);
4648 			is_ctia = (val & 0x0070) == 0x0070;
4649 		}
4650 		alc_process_coef_fw(codec, coef0298);
4651 		snd_hda_codec_write(codec, 0x21, 0,
4652 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4653 		msleep(75);
4654 		snd_hda_codec_write(codec, 0x21, 0,
4655 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4656 		break;
4657 	case 0x10ec0286:
4658 	case 0x10ec0288:
4659 		alc_process_coef_fw(codec, coef0288);
4660 		msleep(350);
4661 		val = alc_read_coef_idx(codec, 0x50);
4662 		is_ctia = (val & 0x0070) == 0x0070;
4663 		break;
4664 	case 0x10ec0292:
4665 		alc_write_coef_idx(codec, 0x6b, 0xd429);
4666 		msleep(300);
4667 		val = alc_read_coef_idx(codec, 0x6c);
4668 		is_ctia = (val & 0x001c) == 0x001c;
4669 		break;
4670 	case 0x10ec0293:
4671 		alc_process_coef_fw(codec, coef0293);
4672 		msleep(300);
4673 		val = alc_read_coef_idx(codec, 0x46);
4674 		is_ctia = (val & 0x0070) == 0x0070;
4675 		break;
4676 	case 0x10ec0668:
4677 		alc_process_coef_fw(codec, coef0688);
4678 		msleep(300);
4679 		val = alc_read_coef_idx(codec, 0xbe);
4680 		is_ctia = (val & 0x1c02) == 0x1c02;
4681 		break;
4682 	case 0x10ec0215:
4683 	case 0x10ec0225:
4684 	case 0x10ec0285:
4685 	case 0x10ec0295:
4686 	case 0x10ec0289:
4687 	case 0x10ec0299:
4688 		snd_hda_codec_write(codec, 0x21, 0,
4689 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4690 		msleep(80);
4691 		snd_hda_codec_write(codec, 0x21, 0,
4692 			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4693 
4694 		alc_process_coef_fw(codec, alc225_pre_hsmode);
4695 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
4696 		val = alc_read_coef_idx(codec, 0x45);
4697 		if (val & (1 << 9)) {
4698 			alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4699 			alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
4700 			msleep(800);
4701 			val = alc_read_coef_idx(codec, 0x46);
4702 			is_ctia = (val & 0x00f0) == 0x00f0;
4703 		} else {
4704 			alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4705 			alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
4706 			msleep(800);
4707 			val = alc_read_coef_idx(codec, 0x46);
4708 			is_ctia = (val & 0x00f0) == 0x00f0;
4709 		}
4710 		alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
4711 		alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
4712 		alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
4713 
4714 		snd_hda_codec_write(codec, 0x21, 0,
4715 			    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4716 		msleep(80);
4717 		snd_hda_codec_write(codec, 0x21, 0,
4718 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4719 		break;
4720 	case 0x10ec0867:
4721 		is_ctia = true;
4722 		break;
4723 	}
4724 
4725 	codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
4726 		    is_ctia ? "yes" : "no");
4727 	spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
4728 }
4729 
4730 static void alc_update_headset_mode(struct hda_codec *codec)
4731 {
4732 	struct alc_spec *spec = codec->spec;
4733 
4734 	hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
4735 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
4736 
4737 	int new_headset_mode;
4738 
4739 	if (!snd_hda_jack_detect(codec, hp_pin))
4740 		new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
4741 	else if (mux_pin == spec->headset_mic_pin)
4742 		new_headset_mode = ALC_HEADSET_MODE_HEADSET;
4743 	else if (mux_pin == spec->headphone_mic_pin)
4744 		new_headset_mode = ALC_HEADSET_MODE_MIC;
4745 	else
4746 		new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
4747 
4748 	if (new_headset_mode == spec->current_headset_mode) {
4749 		snd_hda_gen_update_outputs(codec);
4750 		return;
4751 	}
4752 
4753 	switch (new_headset_mode) {
4754 	case ALC_HEADSET_MODE_UNPLUGGED:
4755 		alc_headset_mode_unplugged(codec);
4756 		spec->gen.hp_jack_present = false;
4757 		break;
4758 	case ALC_HEADSET_MODE_HEADSET:
4759 		if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
4760 			alc_determine_headset_type(codec);
4761 		if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
4762 			alc_headset_mode_ctia(codec);
4763 		else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
4764 			alc_headset_mode_omtp(codec);
4765 		spec->gen.hp_jack_present = true;
4766 		break;
4767 	case ALC_HEADSET_MODE_MIC:
4768 		alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
4769 		spec->gen.hp_jack_present = false;
4770 		break;
4771 	case ALC_HEADSET_MODE_HEADPHONE:
4772 		alc_headset_mode_default(codec);
4773 		spec->gen.hp_jack_present = true;
4774 		break;
4775 	}
4776 	if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
4777 		snd_hda_set_pin_ctl_cache(codec, hp_pin,
4778 					  AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
4779 		if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
4780 			snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
4781 						  PIN_VREFHIZ);
4782 	}
4783 	spec->current_headset_mode = new_headset_mode;
4784 
4785 	snd_hda_gen_update_outputs(codec);
4786 }
4787 
4788 static void alc_update_headset_mode_hook(struct hda_codec *codec,
4789 					 struct snd_kcontrol *kcontrol,
4790 					 struct snd_ctl_elem_value *ucontrol)
4791 {
4792 	alc_update_headset_mode(codec);
4793 }
4794 
4795 static void alc_update_headset_jack_cb(struct hda_codec *codec,
4796 				       struct hda_jack_callback *jack)
4797 {
4798 	struct alc_spec *spec = codec->spec;
4799 	spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
4800 	snd_hda_gen_hp_automute(codec, jack);
4801 }
4802 
4803 static void alc_probe_headset_mode(struct hda_codec *codec)
4804 {
4805 	int i;
4806 	struct alc_spec *spec = codec->spec;
4807 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4808 
4809 	/* Find mic pins */
4810 	for (i = 0; i < cfg->num_inputs; i++) {
4811 		if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
4812 			spec->headset_mic_pin = cfg->inputs[i].pin;
4813 		if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
4814 			spec->headphone_mic_pin = cfg->inputs[i].pin;
4815 	}
4816 
4817 	WARN_ON(spec->gen.cap_sync_hook);
4818 	spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
4819 	spec->gen.automute_hook = alc_update_headset_mode;
4820 	spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
4821 }
4822 
4823 static void alc_fixup_headset_mode(struct hda_codec *codec,
4824 				const struct hda_fixup *fix, int action)
4825 {
4826 	struct alc_spec *spec = codec->spec;
4827 
4828 	switch (action) {
4829 	case HDA_FIXUP_ACT_PRE_PROBE:
4830 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
4831 		break;
4832 	case HDA_FIXUP_ACT_PROBE:
4833 		alc_probe_headset_mode(codec);
4834 		break;
4835 	case HDA_FIXUP_ACT_INIT:
4836 		spec->current_headset_mode = 0;
4837 		alc_update_headset_mode(codec);
4838 		break;
4839 	}
4840 }
4841 
4842 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
4843 				const struct hda_fixup *fix, int action)
4844 {
4845 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4846 		struct alc_spec *spec = codec->spec;
4847 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4848 	}
4849 	else
4850 		alc_fixup_headset_mode(codec, fix, action);
4851 }
4852 
4853 static void alc255_set_default_jack_type(struct hda_codec *codec)
4854 {
4855 	/* Set to iphone type */
4856 	static struct coef_fw alc255fw[] = {
4857 		WRITE_COEF(0x1b, 0x880b),
4858 		WRITE_COEF(0x45, 0xd089),
4859 		WRITE_COEF(0x1b, 0x080b),
4860 		WRITE_COEF(0x46, 0x0004),
4861 		WRITE_COEF(0x1b, 0x0c0b),
4862 		{}
4863 	};
4864 	static struct coef_fw alc256fw[] = {
4865 		WRITE_COEF(0x1b, 0x884b),
4866 		WRITE_COEF(0x45, 0xd089),
4867 		WRITE_COEF(0x1b, 0x084b),
4868 		WRITE_COEF(0x46, 0x0004),
4869 		WRITE_COEF(0x1b, 0x0c4b),
4870 		{}
4871 	};
4872 	switch (codec->core.vendor_id) {
4873 	case 0x10ec0255:
4874 		alc_process_coef_fw(codec, alc255fw);
4875 		break;
4876 	case 0x10ec0236:
4877 	case 0x10ec0256:
4878 		alc_process_coef_fw(codec, alc256fw);
4879 		break;
4880 	}
4881 	msleep(30);
4882 }
4883 
4884 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
4885 				const struct hda_fixup *fix, int action)
4886 {
4887 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4888 		alc255_set_default_jack_type(codec);
4889 	}
4890 	alc_fixup_headset_mode(codec, fix, action);
4891 }
4892 
4893 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
4894 				const struct hda_fixup *fix, int action)
4895 {
4896 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4897 		struct alc_spec *spec = codec->spec;
4898 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4899 		alc255_set_default_jack_type(codec);
4900 	}
4901 	else
4902 		alc_fixup_headset_mode(codec, fix, action);
4903 }
4904 
4905 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
4906 				       struct hda_jack_callback *jack)
4907 {
4908 	struct alc_spec *spec = codec->spec;
4909 
4910 	alc_update_headset_jack_cb(codec, jack);
4911 	/* Headset Mic enable or disable, only for Dell Dino */
4912 	alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
4913 }
4914 
4915 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
4916 				const struct hda_fixup *fix, int action)
4917 {
4918 	alc_fixup_headset_mode(codec, fix, action);
4919 	if (action == HDA_FIXUP_ACT_PROBE) {
4920 		struct alc_spec *spec = codec->spec;
4921 		/* toggled via hp_automute_hook */
4922 		spec->gpio_mask |= 0x40;
4923 		spec->gpio_dir |= 0x40;
4924 		spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
4925 	}
4926 }
4927 
4928 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
4929 					const struct hda_fixup *fix, int action)
4930 {
4931 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4932 		struct alc_spec *spec = codec->spec;
4933 		spec->gen.auto_mute_via_amp = 1;
4934 	}
4935 }
4936 
4937 static void alc_no_shutup(struct hda_codec *codec)
4938 {
4939 }
4940 
4941 static void alc_fixup_no_shutup(struct hda_codec *codec,
4942 				const struct hda_fixup *fix, int action)
4943 {
4944 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4945 		struct alc_spec *spec = codec->spec;
4946 		spec->shutup = alc_no_shutup;
4947 	}
4948 }
4949 
4950 static void alc_fixup_disable_aamix(struct hda_codec *codec,
4951 				    const struct hda_fixup *fix, int action)
4952 {
4953 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4954 		struct alc_spec *spec = codec->spec;
4955 		/* Disable AA-loopback as it causes white noise */
4956 		spec->gen.mixer_nid = 0;
4957 	}
4958 }
4959 
4960 /* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
4961 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
4962 				  const struct hda_fixup *fix, int action)
4963 {
4964 	static const struct hda_pintbl pincfgs[] = {
4965 		{ 0x16, 0x21211010 }, /* dock headphone */
4966 		{ 0x19, 0x21a11010 }, /* dock mic */
4967 		{ }
4968 	};
4969 	struct alc_spec *spec = codec->spec;
4970 
4971 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4972 		spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
4973 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4974 		codec->power_save_node = 0; /* avoid click noises */
4975 		snd_hda_apply_pincfgs(codec, pincfgs);
4976 	}
4977 }
4978 
4979 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
4980 				  const struct hda_fixup *fix, int action)
4981 {
4982 	static const struct hda_pintbl pincfgs[] = {
4983 		{ 0x17, 0x21211010 }, /* dock headphone */
4984 		{ 0x19, 0x21a11010 }, /* dock mic */
4985 		{ }
4986 	};
4987 	struct alc_spec *spec = codec->spec;
4988 
4989 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4990 		spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4991 		snd_hda_apply_pincfgs(codec, pincfgs);
4992 	} else if (action == HDA_FIXUP_ACT_INIT) {
4993 		/* Enable DOCK device */
4994 		snd_hda_codec_write(codec, 0x17, 0,
4995 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
4996 		/* Enable DOCK device */
4997 		snd_hda_codec_write(codec, 0x19, 0,
4998 			    AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
4999 	}
5000 }
5001 
5002 static void alc_shutup_dell_xps13(struct hda_codec *codec)
5003 {
5004 	struct alc_spec *spec = codec->spec;
5005 	int hp_pin = spec->gen.autocfg.hp_pins[0];
5006 
5007 	/* Prevent pop noises when headphones are plugged in */
5008 	snd_hda_codec_write(codec, hp_pin, 0,
5009 			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5010 	msleep(20);
5011 }
5012 
5013 static void alc_fixup_dell_xps13(struct hda_codec *codec,
5014 				const struct hda_fixup *fix, int action)
5015 {
5016 	struct alc_spec *spec = codec->spec;
5017 	struct hda_input_mux *imux = &spec->gen.input_mux;
5018 	int i;
5019 
5020 	switch (action) {
5021 	case HDA_FIXUP_ACT_PRE_PROBE:
5022 		/* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
5023 		 * it causes a click noise at start up
5024 		 */
5025 		snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5026 		spec->shutup = alc_shutup_dell_xps13;
5027 		break;
5028 	case HDA_FIXUP_ACT_PROBE:
5029 		/* Make the internal mic the default input source. */
5030 		for (i = 0; i < imux->num_items; i++) {
5031 			if (spec->gen.imux_pins[i] == 0x12) {
5032 				spec->gen.cur_mux[0] = i;
5033 				break;
5034 			}
5035 		}
5036 		break;
5037 	}
5038 }
5039 
5040 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5041 				const struct hda_fixup *fix, int action)
5042 {
5043 	struct alc_spec *spec = codec->spec;
5044 
5045 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5046 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5047 		spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
5048 
5049 		/* Disable boost for mic-in permanently. (This code is only called
5050 		   from quirks that guarantee that the headphone is at NID 0x1b.) */
5051 		snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5052 		snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
5053 	} else
5054 		alc_fixup_headset_mode(codec, fix, action);
5055 }
5056 
5057 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5058 				const struct hda_fixup *fix, int action)
5059 {
5060 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5061 		alc_write_coef_idx(codec, 0xc4, 0x8000);
5062 		alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
5063 		snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
5064 	}
5065 	alc_fixup_headset_mode(codec, fix, action);
5066 }
5067 
5068 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
5069 static int find_ext_mic_pin(struct hda_codec *codec)
5070 {
5071 	struct alc_spec *spec = codec->spec;
5072 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5073 	hda_nid_t nid;
5074 	unsigned int defcfg;
5075 	int i;
5076 
5077 	for (i = 0; i < cfg->num_inputs; i++) {
5078 		if (cfg->inputs[i].type != AUTO_PIN_MIC)
5079 			continue;
5080 		nid = cfg->inputs[i].pin;
5081 		defcfg = snd_hda_codec_get_pincfg(codec, nid);
5082 		if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
5083 			continue;
5084 		return nid;
5085 	}
5086 
5087 	return 0;
5088 }
5089 
5090 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
5091 				    const struct hda_fixup *fix,
5092 				    int action)
5093 {
5094 	struct alc_spec *spec = codec->spec;
5095 
5096 	if (action == HDA_FIXUP_ACT_PROBE) {
5097 		int mic_pin = find_ext_mic_pin(codec);
5098 		int hp_pin = spec->gen.autocfg.hp_pins[0];
5099 
5100 		if (snd_BUG_ON(!mic_pin || !hp_pin))
5101 			return;
5102 		snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
5103 	}
5104 }
5105 
5106 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
5107 					     const struct hda_fixup *fix,
5108 					     int action)
5109 {
5110 	struct alc_spec *spec = codec->spec;
5111 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5112 	int i;
5113 
5114 	/* The mic boosts on level 2 and 3 are too noisy
5115 	   on the internal mic input.
5116 	   Therefore limit the boost to 0 or 1. */
5117 
5118 	if (action != HDA_FIXUP_ACT_PROBE)
5119 		return;
5120 
5121 	for (i = 0; i < cfg->num_inputs; i++) {
5122 		hda_nid_t nid = cfg->inputs[i].pin;
5123 		unsigned int defcfg;
5124 		if (cfg->inputs[i].type != AUTO_PIN_MIC)
5125 			continue;
5126 		defcfg = snd_hda_codec_get_pincfg(codec, nid);
5127 		if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
5128 			continue;
5129 
5130 		snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
5131 					  (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
5132 					  (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5133 					  (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
5134 					  (0 << AC_AMPCAP_MUTE_SHIFT));
5135 	}
5136 }
5137 
5138 static void alc283_hp_automute_hook(struct hda_codec *codec,
5139 				    struct hda_jack_callback *jack)
5140 {
5141 	struct alc_spec *spec = codec->spec;
5142 	int vref;
5143 
5144 	msleep(200);
5145 	snd_hda_gen_hp_automute(codec, jack);
5146 
5147 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
5148 
5149 	msleep(600);
5150 	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5151 			    vref);
5152 }
5153 
5154 static void alc283_fixup_chromebook(struct hda_codec *codec,
5155 				    const struct hda_fixup *fix, int action)
5156 {
5157 	struct alc_spec *spec = codec->spec;
5158 
5159 	switch (action) {
5160 	case HDA_FIXUP_ACT_PRE_PROBE:
5161 		snd_hda_override_wcaps(codec, 0x03, 0);
5162 		/* Disable AA-loopback as it causes white noise */
5163 		spec->gen.mixer_nid = 0;
5164 		break;
5165 	case HDA_FIXUP_ACT_INIT:
5166 		/* MIC2-VREF control */
5167 		/* Set to manual mode */
5168 		alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5169 		/* Enable Line1 input control by verb */
5170 		alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
5171 		break;
5172 	}
5173 }
5174 
5175 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
5176 				    const struct hda_fixup *fix, int action)
5177 {
5178 	struct alc_spec *spec = codec->spec;
5179 
5180 	switch (action) {
5181 	case HDA_FIXUP_ACT_PRE_PROBE:
5182 		spec->gen.hp_automute_hook = alc283_hp_automute_hook;
5183 		break;
5184 	case HDA_FIXUP_ACT_INIT:
5185 		/* MIC2-VREF control */
5186 		/* Set to manual mode */
5187 		alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5188 		break;
5189 	}
5190 }
5191 
5192 /* mute tablet speaker pin (0x14) via dock plugging in addition */
5193 static void asus_tx300_automute(struct hda_codec *codec)
5194 {
5195 	struct alc_spec *spec = codec->spec;
5196 	snd_hda_gen_update_outputs(codec);
5197 	if (snd_hda_jack_detect(codec, 0x1b))
5198 		spec->gen.mute_bits |= (1ULL << 0x14);
5199 }
5200 
5201 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
5202 				    const struct hda_fixup *fix, int action)
5203 {
5204 	struct alc_spec *spec = codec->spec;
5205 	static const struct hda_pintbl dock_pins[] = {
5206 		{ 0x1b, 0x21114000 }, /* dock speaker pin */
5207 		{}
5208 	};
5209 
5210 	switch (action) {
5211 	case HDA_FIXUP_ACT_PRE_PROBE:
5212 		spec->init_amp = ALC_INIT_DEFAULT;
5213 		/* TX300 needs to set up GPIO2 for the speaker amp */
5214 		alc_setup_gpio(codec, 0x04);
5215 		snd_hda_apply_pincfgs(codec, dock_pins);
5216 		spec->gen.auto_mute_via_amp = 1;
5217 		spec->gen.automute_hook = asus_tx300_automute;
5218 		snd_hda_jack_detect_enable_callback(codec, 0x1b,
5219 						    snd_hda_gen_hp_automute);
5220 		break;
5221 	case HDA_FIXUP_ACT_PROBE:
5222 		spec->init_amp = ALC_INIT_DEFAULT;
5223 		break;
5224 	case HDA_FIXUP_ACT_BUILD:
5225 		/* this is a bit tricky; give more sane names for the main
5226 		 * (tablet) speaker and the dock speaker, respectively
5227 		 */
5228 		rename_ctl(codec, "Speaker Playback Switch",
5229 			   "Dock Speaker Playback Switch");
5230 		rename_ctl(codec, "Bass Speaker Playback Switch",
5231 			   "Speaker Playback Switch");
5232 		break;
5233 	}
5234 }
5235 
5236 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
5237 				       const struct hda_fixup *fix, int action)
5238 {
5239 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5240 		/* DAC node 0x03 is giving mono output. We therefore want to
5241 		   make sure 0x14 (front speaker) and 0x15 (headphones) use the
5242 		   stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
5243 		hda_nid_t conn1[2] = { 0x0c };
5244 		snd_hda_override_conn_list(codec, 0x14, 1, conn1);
5245 		snd_hda_override_conn_list(codec, 0x15, 1, conn1);
5246 	}
5247 }
5248 
5249 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
5250 					const struct hda_fixup *fix, int action)
5251 {
5252 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5253 		/* The speaker is routed to the Node 0x06 by a mistake, as a result
5254 		   we can't adjust the speaker's volume since this node does not has
5255 		   Amp-out capability. we change the speaker's route to:
5256 		   Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
5257 		   Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
5258 		   speaker's volume now. */
5259 
5260 		hda_nid_t conn1[1] = { 0x0c };
5261 		snd_hda_override_conn_list(codec, 0x17, 1, conn1);
5262 	}
5263 }
5264 
5265 /* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
5266 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
5267 				      const struct hda_fixup *fix, int action)
5268 {
5269 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5270 		hda_nid_t conn[2] = { 0x02, 0x03 };
5271 		snd_hda_override_conn_list(codec, 0x17, 2, conn);
5272 	}
5273 }
5274 
5275 /* Hook to update amp GPIO4 for automute */
5276 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
5277 					  struct hda_jack_callback *jack)
5278 {
5279 	struct alc_spec *spec = codec->spec;
5280 
5281 	snd_hda_gen_hp_automute(codec, jack);
5282 	/* mute_led_polarity is set to 0, so we pass inverted value here */
5283 	alc_update_gpio_led(codec, 0x10, !spec->gen.hp_jack_present);
5284 }
5285 
5286 /* Manage GPIOs for HP EliteBook Folio 9480m.
5287  *
5288  * GPIO4 is the headphone amplifier power control
5289  * GPIO3 is the audio output mute indicator LED
5290  */
5291 
5292 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
5293 				  const struct hda_fixup *fix,
5294 				  int action)
5295 {
5296 	struct alc_spec *spec = codec->spec;
5297 
5298 	alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
5299 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5300 		/* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
5301 		spec->gpio_mask |= 0x10;
5302 		spec->gpio_dir |= 0x10;
5303 		spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
5304 	}
5305 }
5306 
5307 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
5308 				   const struct hda_fixup *fix,
5309 				   int action)
5310 {
5311 	struct alc_spec *spec = codec->spec;
5312 
5313 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5314 		spec->gpio_mask |= 0x04;
5315 		spec->gpio_dir |= 0x04;
5316 		/* set data bit low */
5317 	}
5318 }
5319 
5320 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
5321 					 const struct hda_fixup *fix,
5322 					 int action)
5323 {
5324 	alc_fixup_dual_codecs(codec, fix, action);
5325 	switch (action) {
5326 	case HDA_FIXUP_ACT_PRE_PROBE:
5327 		/* override card longname to provide a unique UCM profile */
5328 		strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
5329 		break;
5330 	case HDA_FIXUP_ACT_BUILD:
5331 		/* rename Capture controls depending on the codec */
5332 		rename_ctl(codec, "Capture Volume",
5333 			   codec->addr == 0 ?
5334 			   "Rear-Panel Capture Volume" :
5335 			   "Front-Panel Capture Volume");
5336 		rename_ctl(codec, "Capture Switch",
5337 			   codec->addr == 0 ?
5338 			   "Rear-Panel Capture Switch" :
5339 			   "Front-Panel Capture Switch");
5340 		break;
5341 	}
5342 }
5343 
5344 /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
5345 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
5346 				    const struct hda_fixup *fix, int action)
5347 {
5348 	struct alc_spec *spec = codec->spec;
5349 	static hda_nid_t preferred_pairs[] = {
5350 		0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
5351 		0
5352 	};
5353 
5354 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
5355 		return;
5356 
5357 	spec->gen.preferred_dacs = preferred_pairs;
5358 }
5359 
5360 /* for hda_fixup_thinkpad_acpi() */
5361 #include "thinkpad_helper.c"
5362 
5363 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
5364 				    const struct hda_fixup *fix, int action)
5365 {
5366 	alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
5367 	hda_fixup_thinkpad_acpi(codec, fix, action);
5368 }
5369 
5370 /* for dell wmi mic mute led */
5371 #include "dell_wmi_helper.c"
5372 
5373 /* for alc295_fixup_hp_top_speakers */
5374 #include "hp_x360_helper.c"
5375 
5376 enum {
5377 	ALC269_FIXUP_SONY_VAIO,
5378 	ALC275_FIXUP_SONY_VAIO_GPIO2,
5379 	ALC269_FIXUP_DELL_M101Z,
5380 	ALC269_FIXUP_SKU_IGNORE,
5381 	ALC269_FIXUP_ASUS_G73JW,
5382 	ALC269_FIXUP_LENOVO_EAPD,
5383 	ALC275_FIXUP_SONY_HWEQ,
5384 	ALC275_FIXUP_SONY_DISABLE_AAMIX,
5385 	ALC271_FIXUP_DMIC,
5386 	ALC269_FIXUP_PCM_44K,
5387 	ALC269_FIXUP_STEREO_DMIC,
5388 	ALC269_FIXUP_HEADSET_MIC,
5389 	ALC269_FIXUP_QUANTA_MUTE,
5390 	ALC269_FIXUP_LIFEBOOK,
5391 	ALC269_FIXUP_LIFEBOOK_EXTMIC,
5392 	ALC269_FIXUP_LIFEBOOK_HP_PIN,
5393 	ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
5394 	ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
5395 	ALC269_FIXUP_AMIC,
5396 	ALC269_FIXUP_DMIC,
5397 	ALC269VB_FIXUP_AMIC,
5398 	ALC269VB_FIXUP_DMIC,
5399 	ALC269_FIXUP_HP_MUTE_LED,
5400 	ALC269_FIXUP_HP_MUTE_LED_MIC1,
5401 	ALC269_FIXUP_HP_MUTE_LED_MIC2,
5402 	ALC269_FIXUP_HP_MUTE_LED_MIC3,
5403 	ALC269_FIXUP_HP_GPIO_LED,
5404 	ALC269_FIXUP_HP_GPIO_MIC1_LED,
5405 	ALC269_FIXUP_HP_LINE1_MIC1_LED,
5406 	ALC269_FIXUP_INV_DMIC,
5407 	ALC269_FIXUP_LENOVO_DOCK,
5408 	ALC269_FIXUP_NO_SHUTUP,
5409 	ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
5410 	ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
5411 	ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5412 	ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
5413 	ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5414 	ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
5415 	ALC269_FIXUP_HEADSET_MODE,
5416 	ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
5417 	ALC269_FIXUP_ASPIRE_HEADSET_MIC,
5418 	ALC269_FIXUP_ASUS_X101_FUNC,
5419 	ALC269_FIXUP_ASUS_X101_VERB,
5420 	ALC269_FIXUP_ASUS_X101,
5421 	ALC271_FIXUP_AMIC_MIC2,
5422 	ALC271_FIXUP_HP_GATE_MIC_JACK,
5423 	ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
5424 	ALC269_FIXUP_ACER_AC700,
5425 	ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
5426 	ALC269VB_FIXUP_ASUS_ZENBOOK,
5427 	ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
5428 	ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
5429 	ALC269VB_FIXUP_ORDISSIMO_EVE2,
5430 	ALC283_FIXUP_CHROME_BOOK,
5431 	ALC283_FIXUP_SENSE_COMBO_JACK,
5432 	ALC282_FIXUP_ASUS_TX300,
5433 	ALC283_FIXUP_INT_MIC,
5434 	ALC290_FIXUP_MONO_SPEAKERS,
5435 	ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5436 	ALC290_FIXUP_SUBWOOFER,
5437 	ALC290_FIXUP_SUBWOOFER_HSJACK,
5438 	ALC269_FIXUP_THINKPAD_ACPI,
5439 	ALC269_FIXUP_DMIC_THINKPAD_ACPI,
5440 	ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
5441 	ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
5442 	ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5443 	ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
5444 	ALC255_FIXUP_HEADSET_MODE,
5445 	ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
5446 	ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5447 	ALC292_FIXUP_TPT440_DOCK,
5448 	ALC292_FIXUP_TPT440,
5449 	ALC283_FIXUP_HEADSET_MIC,
5450 	ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
5451 	ALC282_FIXUP_ASPIRE_V5_PINS,
5452 	ALC280_FIXUP_HP_GPIO4,
5453 	ALC286_FIXUP_HP_GPIO_LED,
5454 	ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
5455 	ALC280_FIXUP_HP_DOCK_PINS,
5456 	ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
5457 	ALC280_FIXUP_HP_9480M,
5458 	ALC288_FIXUP_DELL_HEADSET_MODE,
5459 	ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
5460 	ALC288_FIXUP_DELL_XPS_13,
5461 	ALC288_FIXUP_DISABLE_AAMIX,
5462 	ALC292_FIXUP_DELL_E7X,
5463 	ALC292_FIXUP_DISABLE_AAMIX,
5464 	ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
5465 	ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
5466 	ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
5467 	ALC275_FIXUP_DELL_XPS,
5468 	ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE,
5469 	ALC293_FIXUP_LENOVO_SPK_NOISE,
5470 	ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
5471 	ALC255_FIXUP_DELL_SPK_NOISE,
5472 	ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
5473 	ALC295_FIXUP_DISABLE_DAC3,
5474 	ALC280_FIXUP_HP_HEADSET_MIC,
5475 	ALC221_FIXUP_HP_FRONT_MIC,
5476 	ALC292_FIXUP_TPT460,
5477 	ALC298_FIXUP_SPK_VOLUME,
5478 	ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
5479 	ALC269_FIXUP_ATIV_BOOK_8,
5480 	ALC221_FIXUP_HP_MIC_NO_PRESENCE,
5481 	ALC256_FIXUP_ASUS_HEADSET_MODE,
5482 	ALC256_FIXUP_ASUS_MIC,
5483 	ALC256_FIXUP_ASUS_AIO_GPIO2,
5484 	ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
5485 	ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
5486 	ALC233_FIXUP_LENOVO_MULTI_CODECS,
5487 	ALC294_FIXUP_LENOVO_MIC_LOCATION,
5488 	ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
5489 	ALC700_FIXUP_INTEL_REFERENCE,
5490 	ALC274_FIXUP_DELL_BIND_DACS,
5491 	ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
5492 	ALC298_FIXUP_TPT470_DOCK,
5493 	ALC255_FIXUP_DUMMY_LINEOUT_VERB,
5494 	ALC255_FIXUP_DELL_HEADSET_MIC,
5495 	ALC295_FIXUP_HP_X360,
5496 };
5497 
5498 static const struct hda_fixup alc269_fixups[] = {
5499 	[ALC269_FIXUP_SONY_VAIO] = {
5500 		.type = HDA_FIXUP_PINCTLS,
5501 		.v.pins = (const struct hda_pintbl[]) {
5502 			{0x19, PIN_VREFGRD},
5503 			{}
5504 		}
5505 	},
5506 	[ALC275_FIXUP_SONY_VAIO_GPIO2] = {
5507 		.type = HDA_FIXUP_FUNC,
5508 		.v.func = alc275_fixup_gpio4_off,
5509 		.chained = true,
5510 		.chain_id = ALC269_FIXUP_SONY_VAIO
5511 	},
5512 	[ALC269_FIXUP_DELL_M101Z] = {
5513 		.type = HDA_FIXUP_VERBS,
5514 		.v.verbs = (const struct hda_verb[]) {
5515 			/* Enables internal speaker */
5516 			{0x20, AC_VERB_SET_COEF_INDEX, 13},
5517 			{0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5518 			{}
5519 		}
5520 	},
5521 	[ALC269_FIXUP_SKU_IGNORE] = {
5522 		.type = HDA_FIXUP_FUNC,
5523 		.v.func = alc_fixup_sku_ignore,
5524 	},
5525 	[ALC269_FIXUP_ASUS_G73JW] = {
5526 		.type = HDA_FIXUP_PINS,
5527 		.v.pins = (const struct hda_pintbl[]) {
5528 			{ 0x17, 0x99130111 }, /* subwoofer */
5529 			{ }
5530 		}
5531 	},
5532 	[ALC269_FIXUP_LENOVO_EAPD] = {
5533 		.type = HDA_FIXUP_VERBS,
5534 		.v.verbs = (const struct hda_verb[]) {
5535 			{0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5536 			{}
5537 		}
5538 	},
5539 	[ALC275_FIXUP_SONY_HWEQ] = {
5540 		.type = HDA_FIXUP_FUNC,
5541 		.v.func = alc269_fixup_hweq,
5542 		.chained = true,
5543 		.chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5544 	},
5545 	[ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
5546 		.type = HDA_FIXUP_FUNC,
5547 		.v.func = alc_fixup_disable_aamix,
5548 		.chained = true,
5549 		.chain_id = ALC269_FIXUP_SONY_VAIO
5550 	},
5551 	[ALC271_FIXUP_DMIC] = {
5552 		.type = HDA_FIXUP_FUNC,
5553 		.v.func = alc271_fixup_dmic,
5554 	},
5555 	[ALC269_FIXUP_PCM_44K] = {
5556 		.type = HDA_FIXUP_FUNC,
5557 		.v.func = alc269_fixup_pcm_44k,
5558 		.chained = true,
5559 		.chain_id = ALC269_FIXUP_QUANTA_MUTE
5560 	},
5561 	[ALC269_FIXUP_STEREO_DMIC] = {
5562 		.type = HDA_FIXUP_FUNC,
5563 		.v.func = alc269_fixup_stereo_dmic,
5564 	},
5565 	[ALC269_FIXUP_HEADSET_MIC] = {
5566 		.type = HDA_FIXUP_FUNC,
5567 		.v.func = alc269_fixup_headset_mic,
5568 	},
5569 	[ALC269_FIXUP_QUANTA_MUTE] = {
5570 		.type = HDA_FIXUP_FUNC,
5571 		.v.func = alc269_fixup_quanta_mute,
5572 	},
5573 	[ALC269_FIXUP_LIFEBOOK] = {
5574 		.type = HDA_FIXUP_PINS,
5575 		.v.pins = (const struct hda_pintbl[]) {
5576 			{ 0x1a, 0x2101103f }, /* dock line-out */
5577 			{ 0x1b, 0x23a11040 }, /* dock mic-in */
5578 			{ }
5579 		},
5580 		.chained = true,
5581 		.chain_id = ALC269_FIXUP_QUANTA_MUTE
5582 	},
5583 	[ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
5584 		.type = HDA_FIXUP_PINS,
5585 		.v.pins = (const struct hda_pintbl[]) {
5586 			{ 0x19, 0x01a1903c }, /* headset mic, with jack detect */
5587 			{ }
5588 		},
5589 	},
5590 	[ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
5591 		.type = HDA_FIXUP_PINS,
5592 		.v.pins = (const struct hda_pintbl[]) {
5593 			{ 0x21, 0x0221102f }, /* HP out */
5594 			{ }
5595 		},
5596 	},
5597 	[ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
5598 		.type = HDA_FIXUP_FUNC,
5599 		.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
5600 	},
5601 	[ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
5602 		.type = HDA_FIXUP_FUNC,
5603 		.v.func = alc269_fixup_pincfg_U7x7_headset_mic,
5604 	},
5605 	[ALC269_FIXUP_AMIC] = {
5606 		.type = HDA_FIXUP_PINS,
5607 		.v.pins = (const struct hda_pintbl[]) {
5608 			{ 0x14, 0x99130110 }, /* speaker */
5609 			{ 0x15, 0x0121401f }, /* HP out */
5610 			{ 0x18, 0x01a19c20 }, /* mic */
5611 			{ 0x19, 0x99a3092f }, /* int-mic */
5612 			{ }
5613 		},
5614 	},
5615 	[ALC269_FIXUP_DMIC] = {
5616 		.type = HDA_FIXUP_PINS,
5617 		.v.pins = (const struct hda_pintbl[]) {
5618 			{ 0x12, 0x99a3092f }, /* int-mic */
5619 			{ 0x14, 0x99130110 }, /* speaker */
5620 			{ 0x15, 0x0121401f }, /* HP out */
5621 			{ 0x18, 0x01a19c20 }, /* mic */
5622 			{ }
5623 		},
5624 	},
5625 	[ALC269VB_FIXUP_AMIC] = {
5626 		.type = HDA_FIXUP_PINS,
5627 		.v.pins = (const struct hda_pintbl[]) {
5628 			{ 0x14, 0x99130110 }, /* speaker */
5629 			{ 0x18, 0x01a19c20 }, /* mic */
5630 			{ 0x19, 0x99a3092f }, /* int-mic */
5631 			{ 0x21, 0x0121401f }, /* HP out */
5632 			{ }
5633 		},
5634 	},
5635 	[ALC269VB_FIXUP_DMIC] = {
5636 		.type = HDA_FIXUP_PINS,
5637 		.v.pins = (const struct hda_pintbl[]) {
5638 			{ 0x12, 0x99a3092f }, /* int-mic */
5639 			{ 0x14, 0x99130110 }, /* speaker */
5640 			{ 0x18, 0x01a19c20 }, /* mic */
5641 			{ 0x21, 0x0121401f }, /* HP out */
5642 			{ }
5643 		},
5644 	},
5645 	[ALC269_FIXUP_HP_MUTE_LED] = {
5646 		.type = HDA_FIXUP_FUNC,
5647 		.v.func = alc269_fixup_hp_mute_led,
5648 	},
5649 	[ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
5650 		.type = HDA_FIXUP_FUNC,
5651 		.v.func = alc269_fixup_hp_mute_led_mic1,
5652 	},
5653 	[ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
5654 		.type = HDA_FIXUP_FUNC,
5655 		.v.func = alc269_fixup_hp_mute_led_mic2,
5656 	},
5657 	[ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
5658 		.type = HDA_FIXUP_FUNC,
5659 		.v.func = alc269_fixup_hp_mute_led_mic3,
5660 	},
5661 	[ALC269_FIXUP_HP_GPIO_LED] = {
5662 		.type = HDA_FIXUP_FUNC,
5663 		.v.func = alc269_fixup_hp_gpio_led,
5664 	},
5665 	[ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
5666 		.type = HDA_FIXUP_FUNC,
5667 		.v.func = alc269_fixup_hp_gpio_mic1_led,
5668 	},
5669 	[ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
5670 		.type = HDA_FIXUP_FUNC,
5671 		.v.func = alc269_fixup_hp_line1_mic1_led,
5672 	},
5673 	[ALC269_FIXUP_INV_DMIC] = {
5674 		.type = HDA_FIXUP_FUNC,
5675 		.v.func = alc_fixup_inv_dmic,
5676 	},
5677 	[ALC269_FIXUP_NO_SHUTUP] = {
5678 		.type = HDA_FIXUP_FUNC,
5679 		.v.func = alc_fixup_no_shutup,
5680 	},
5681 	[ALC269_FIXUP_LENOVO_DOCK] = {
5682 		.type = HDA_FIXUP_PINS,
5683 		.v.pins = (const struct hda_pintbl[]) {
5684 			{ 0x19, 0x23a11040 }, /* dock mic */
5685 			{ 0x1b, 0x2121103f }, /* dock headphone */
5686 			{ }
5687 		},
5688 		.chained = true,
5689 		.chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
5690 	},
5691 	[ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
5692 		.type = HDA_FIXUP_FUNC,
5693 		.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
5694 		.chained = true,
5695 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
5696 	},
5697 	[ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5698 		.type = HDA_FIXUP_PINS,
5699 		.v.pins = (const struct hda_pintbl[]) {
5700 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5701 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5702 			{ }
5703 		},
5704 		.chained = true,
5705 		.chain_id = ALC269_FIXUP_HEADSET_MODE
5706 	},
5707 	[ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
5708 		.type = HDA_FIXUP_PINS,
5709 		.v.pins = (const struct hda_pintbl[]) {
5710 			{ 0x16, 0x21014020 }, /* dock line out */
5711 			{ 0x19, 0x21a19030 }, /* dock mic */
5712 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5713 			{ }
5714 		},
5715 		.chained = true,
5716 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
5717 	},
5718 	[ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
5719 		.type = HDA_FIXUP_PINS,
5720 		.v.pins = (const struct hda_pintbl[]) {
5721 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5722 			{ }
5723 		},
5724 		.chained = true,
5725 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
5726 	},
5727 	[ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
5728 		.type = HDA_FIXUP_PINS,
5729 		.v.pins = (const struct hda_pintbl[]) {
5730 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5731 			{ 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5732 			{ }
5733 		},
5734 		.chained = true,
5735 		.chain_id = ALC269_FIXUP_HEADSET_MODE
5736 	},
5737 	[ALC269_FIXUP_HEADSET_MODE] = {
5738 		.type = HDA_FIXUP_FUNC,
5739 		.v.func = alc_fixup_headset_mode,
5740 		.chained = true,
5741 		.chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
5742 	},
5743 	[ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
5744 		.type = HDA_FIXUP_FUNC,
5745 		.v.func = alc_fixup_headset_mode_no_hp_mic,
5746 	},
5747 	[ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
5748 		.type = HDA_FIXUP_PINS,
5749 		.v.pins = (const struct hda_pintbl[]) {
5750 			{ 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
5751 			{ }
5752 		},
5753 		.chained = true,
5754 		.chain_id = ALC269_FIXUP_HEADSET_MODE,
5755 	},
5756 	[ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
5757 		.type = HDA_FIXUP_PINS,
5758 		.v.pins = (const struct hda_pintbl[]) {
5759 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5760 			{ }
5761 		},
5762 		.chained = true,
5763 		.chain_id = ALC269_FIXUP_HEADSET_MIC
5764 	},
5765 	[ALC269_FIXUP_ASUS_X101_FUNC] = {
5766 		.type = HDA_FIXUP_FUNC,
5767 		.v.func = alc269_fixup_x101_headset_mic,
5768 	},
5769 	[ALC269_FIXUP_ASUS_X101_VERB] = {
5770 		.type = HDA_FIXUP_VERBS,
5771 		.v.verbs = (const struct hda_verb[]) {
5772 			{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5773 			{0x20, AC_VERB_SET_COEF_INDEX, 0x08},
5774 			{0x20, AC_VERB_SET_PROC_COEF,  0x0310},
5775 			{ }
5776 		},
5777 		.chained = true,
5778 		.chain_id = ALC269_FIXUP_ASUS_X101_FUNC
5779 	},
5780 	[ALC269_FIXUP_ASUS_X101] = {
5781 		.type = HDA_FIXUP_PINS,
5782 		.v.pins = (const struct hda_pintbl[]) {
5783 			{ 0x18, 0x04a1182c }, /* Headset mic */
5784 			{ }
5785 		},
5786 		.chained = true,
5787 		.chain_id = ALC269_FIXUP_ASUS_X101_VERB
5788 	},
5789 	[ALC271_FIXUP_AMIC_MIC2] = {
5790 		.type = HDA_FIXUP_PINS,
5791 		.v.pins = (const struct hda_pintbl[]) {
5792 			{ 0x14, 0x99130110 }, /* speaker */
5793 			{ 0x19, 0x01a19c20 }, /* mic */
5794 			{ 0x1b, 0x99a7012f }, /* int-mic */
5795 			{ 0x21, 0x0121401f }, /* HP out */
5796 			{ }
5797 		},
5798 	},
5799 	[ALC271_FIXUP_HP_GATE_MIC_JACK] = {
5800 		.type = HDA_FIXUP_FUNC,
5801 		.v.func = alc271_hp_gate_mic_jack,
5802 		.chained = true,
5803 		.chain_id = ALC271_FIXUP_AMIC_MIC2,
5804 	},
5805 	[ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
5806 		.type = HDA_FIXUP_FUNC,
5807 		.v.func = alc269_fixup_limit_int_mic_boost,
5808 		.chained = true,
5809 		.chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
5810 	},
5811 	[ALC269_FIXUP_ACER_AC700] = {
5812 		.type = HDA_FIXUP_PINS,
5813 		.v.pins = (const struct hda_pintbl[]) {
5814 			{ 0x12, 0x99a3092f }, /* int-mic */
5815 			{ 0x14, 0x99130110 }, /* speaker */
5816 			{ 0x18, 0x03a11c20 }, /* mic */
5817 			{ 0x1e, 0x0346101e }, /* SPDIF1 */
5818 			{ 0x21, 0x0321101f }, /* HP out */
5819 			{ }
5820 		},
5821 		.chained = true,
5822 		.chain_id = ALC271_FIXUP_DMIC,
5823 	},
5824 	[ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
5825 		.type = HDA_FIXUP_FUNC,
5826 		.v.func = alc269_fixup_limit_int_mic_boost,
5827 		.chained = true,
5828 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
5829 	},
5830 	[ALC269VB_FIXUP_ASUS_ZENBOOK] = {
5831 		.type = HDA_FIXUP_FUNC,
5832 		.v.func = alc269_fixup_limit_int_mic_boost,
5833 		.chained = true,
5834 		.chain_id = ALC269VB_FIXUP_DMIC,
5835 	},
5836 	[ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
5837 		.type = HDA_FIXUP_VERBS,
5838 		.v.verbs = (const struct hda_verb[]) {
5839 			/* class-D output amp +5dB */
5840 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
5841 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
5842 			{}
5843 		},
5844 		.chained = true,
5845 		.chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
5846 	},
5847 	[ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
5848 		.type = HDA_FIXUP_FUNC,
5849 		.v.func = alc269_fixup_limit_int_mic_boost,
5850 		.chained = true,
5851 		.chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
5852 	},
5853 	[ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
5854 		.type = HDA_FIXUP_PINS,
5855 		.v.pins = (const struct hda_pintbl[]) {
5856 			{ 0x12, 0x99a3092f }, /* int-mic */
5857 			{ 0x18, 0x03a11d20 }, /* mic */
5858 			{ 0x19, 0x411111f0 }, /* Unused bogus pin */
5859 			{ }
5860 		},
5861 	},
5862 	[ALC283_FIXUP_CHROME_BOOK] = {
5863 		.type = HDA_FIXUP_FUNC,
5864 		.v.func = alc283_fixup_chromebook,
5865 	},
5866 	[ALC283_FIXUP_SENSE_COMBO_JACK] = {
5867 		.type = HDA_FIXUP_FUNC,
5868 		.v.func = alc283_fixup_sense_combo_jack,
5869 		.chained = true,
5870 		.chain_id = ALC283_FIXUP_CHROME_BOOK,
5871 	},
5872 	[ALC282_FIXUP_ASUS_TX300] = {
5873 		.type = HDA_FIXUP_FUNC,
5874 		.v.func = alc282_fixup_asus_tx300,
5875 	},
5876 	[ALC283_FIXUP_INT_MIC] = {
5877 		.type = HDA_FIXUP_VERBS,
5878 		.v.verbs = (const struct hda_verb[]) {
5879 			{0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
5880 			{0x20, AC_VERB_SET_PROC_COEF, 0x0011},
5881 			{ }
5882 		},
5883 		.chained = true,
5884 		.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
5885 	},
5886 	[ALC290_FIXUP_SUBWOOFER_HSJACK] = {
5887 		.type = HDA_FIXUP_PINS,
5888 		.v.pins = (const struct hda_pintbl[]) {
5889 			{ 0x17, 0x90170112 }, /* subwoofer */
5890 			{ }
5891 		},
5892 		.chained = true,
5893 		.chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5894 	},
5895 	[ALC290_FIXUP_SUBWOOFER] = {
5896 		.type = HDA_FIXUP_PINS,
5897 		.v.pins = (const struct hda_pintbl[]) {
5898 			{ 0x17, 0x90170112 }, /* subwoofer */
5899 			{ }
5900 		},
5901 		.chained = true,
5902 		.chain_id = ALC290_FIXUP_MONO_SPEAKERS,
5903 	},
5904 	[ALC290_FIXUP_MONO_SPEAKERS] = {
5905 		.type = HDA_FIXUP_FUNC,
5906 		.v.func = alc290_fixup_mono_speakers,
5907 	},
5908 	[ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
5909 		.type = HDA_FIXUP_FUNC,
5910 		.v.func = alc290_fixup_mono_speakers,
5911 		.chained = true,
5912 		.chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5913 	},
5914 	[ALC269_FIXUP_THINKPAD_ACPI] = {
5915 		.type = HDA_FIXUP_FUNC,
5916 		.v.func = alc_fixup_thinkpad_acpi,
5917 		.chained = true,
5918 		.chain_id = ALC269_FIXUP_SKU_IGNORE,
5919 	},
5920 	[ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
5921 		.type = HDA_FIXUP_FUNC,
5922 		.v.func = alc_fixup_inv_dmic,
5923 		.chained = true,
5924 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI,
5925 	},
5926 	[ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
5927 		.type = HDA_FIXUP_PINS,
5928 		.v.pins = (const struct hda_pintbl[]) {
5929 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5930 			{ }
5931 		},
5932 		.chained = true,
5933 		.chain_id = ALC255_FIXUP_HEADSET_MODE
5934 	},
5935 	[ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
5936 		.type = HDA_FIXUP_PINS,
5937 		.v.pins = (const struct hda_pintbl[]) {
5938 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5939 			{ }
5940 		},
5941 		.chained = true,
5942 		.chain_id = ALC255_FIXUP_HEADSET_MODE
5943 	},
5944 	[ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5945 		.type = HDA_FIXUP_PINS,
5946 		.v.pins = (const struct hda_pintbl[]) {
5947 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5948 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5949 			{ }
5950 		},
5951 		.chained = true,
5952 		.chain_id = ALC255_FIXUP_HEADSET_MODE
5953 	},
5954 	[ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
5955 		.type = HDA_FIXUP_PINS,
5956 		.v.pins = (const struct hda_pintbl[]) {
5957 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5958 			{ }
5959 		},
5960 		.chained = true,
5961 		.chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
5962 	},
5963 	[ALC255_FIXUP_HEADSET_MODE] = {
5964 		.type = HDA_FIXUP_FUNC,
5965 		.v.func = alc_fixup_headset_mode_alc255,
5966 		.chained = true,
5967 		.chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
5968 	},
5969 	[ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
5970 		.type = HDA_FIXUP_FUNC,
5971 		.v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
5972 	},
5973 	[ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5974 		.type = HDA_FIXUP_PINS,
5975 		.v.pins = (const struct hda_pintbl[]) {
5976 			{ 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5977 			{ 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5978 			{ }
5979 		},
5980 		.chained = true,
5981 		.chain_id = ALC269_FIXUP_HEADSET_MODE
5982 	},
5983 	[ALC292_FIXUP_TPT440_DOCK] = {
5984 		.type = HDA_FIXUP_FUNC,
5985 		.v.func = alc_fixup_tpt440_dock,
5986 		.chained = true,
5987 		.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
5988 	},
5989 	[ALC292_FIXUP_TPT440] = {
5990 		.type = HDA_FIXUP_FUNC,
5991 		.v.func = alc_fixup_disable_aamix,
5992 		.chained = true,
5993 		.chain_id = ALC292_FIXUP_TPT440_DOCK,
5994 	},
5995 	[ALC283_FIXUP_HEADSET_MIC] = {
5996 		.type = HDA_FIXUP_PINS,
5997 		.v.pins = (const struct hda_pintbl[]) {
5998 			{ 0x19, 0x04a110f0 },
5999 			{ },
6000 		},
6001 	},
6002 	[ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
6003 		.type = HDA_FIXUP_FUNC,
6004 		.v.func = alc_fixup_dell_wmi,
6005 	},
6006 	[ALC282_FIXUP_ASPIRE_V5_PINS] = {
6007 		.type = HDA_FIXUP_PINS,
6008 		.v.pins = (const struct hda_pintbl[]) {
6009 			{ 0x12, 0x90a60130 },
6010 			{ 0x14, 0x90170110 },
6011 			{ 0x17, 0x40000008 },
6012 			{ 0x18, 0x411111f0 },
6013 			{ 0x19, 0x01a1913c },
6014 			{ 0x1a, 0x411111f0 },
6015 			{ 0x1b, 0x411111f0 },
6016 			{ 0x1d, 0x40f89b2d },
6017 			{ 0x1e, 0x411111f0 },
6018 			{ 0x21, 0x0321101f },
6019 			{ },
6020 		},
6021 	},
6022 	[ALC280_FIXUP_HP_GPIO4] = {
6023 		.type = HDA_FIXUP_FUNC,
6024 		.v.func = alc280_fixup_hp_gpio4,
6025 	},
6026 	[ALC286_FIXUP_HP_GPIO_LED] = {
6027 		.type = HDA_FIXUP_FUNC,
6028 		.v.func = alc286_fixup_hp_gpio_led,
6029 	},
6030 	[ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
6031 		.type = HDA_FIXUP_FUNC,
6032 		.v.func = alc280_fixup_hp_gpio2_mic_hotkey,
6033 	},
6034 	[ALC280_FIXUP_HP_DOCK_PINS] = {
6035 		.type = HDA_FIXUP_PINS,
6036 		.v.pins = (const struct hda_pintbl[]) {
6037 			{ 0x1b, 0x21011020 }, /* line-out */
6038 			{ 0x1a, 0x01a1903c }, /* headset mic */
6039 			{ 0x18, 0x2181103f }, /* line-in */
6040 			{ },
6041 		},
6042 		.chained = true,
6043 		.chain_id = ALC280_FIXUP_HP_GPIO4
6044 	},
6045 	[ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
6046 		.type = HDA_FIXUP_PINS,
6047 		.v.pins = (const struct hda_pintbl[]) {
6048 			{ 0x1b, 0x21011020 }, /* line-out */
6049 			{ 0x18, 0x2181103f }, /* line-in */
6050 			{ },
6051 		},
6052 		.chained = true,
6053 		.chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
6054 	},
6055 	[ALC280_FIXUP_HP_9480M] = {
6056 		.type = HDA_FIXUP_FUNC,
6057 		.v.func = alc280_fixup_hp_9480m,
6058 	},
6059 	[ALC288_FIXUP_DELL_HEADSET_MODE] = {
6060 		.type = HDA_FIXUP_FUNC,
6061 		.v.func = alc_fixup_headset_mode_dell_alc288,
6062 		.chained = true,
6063 		.chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
6064 	},
6065 	[ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6066 		.type = HDA_FIXUP_PINS,
6067 		.v.pins = (const struct hda_pintbl[]) {
6068 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6069 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6070 			{ }
6071 		},
6072 		.chained = true,
6073 		.chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
6074 	},
6075 	[ALC288_FIXUP_DISABLE_AAMIX] = {
6076 		.type = HDA_FIXUP_FUNC,
6077 		.v.func = alc_fixup_disable_aamix,
6078 		.chained = true,
6079 		.chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
6080 	},
6081 	[ALC288_FIXUP_DELL_XPS_13] = {
6082 		.type = HDA_FIXUP_FUNC,
6083 		.v.func = alc_fixup_dell_xps13,
6084 		.chained = true,
6085 		.chain_id = ALC288_FIXUP_DISABLE_AAMIX
6086 	},
6087 	[ALC292_FIXUP_DISABLE_AAMIX] = {
6088 		.type = HDA_FIXUP_FUNC,
6089 		.v.func = alc_fixup_disable_aamix,
6090 		.chained = true,
6091 		.chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
6092 	},
6093 	[ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
6094 		.type = HDA_FIXUP_FUNC,
6095 		.v.func = alc_fixup_disable_aamix,
6096 		.chained = true,
6097 		.chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
6098 	},
6099 	[ALC292_FIXUP_DELL_E7X] = {
6100 		.type = HDA_FIXUP_FUNC,
6101 		.v.func = alc_fixup_dell_xps13,
6102 		.chained = true,
6103 		.chain_id = ALC292_FIXUP_DISABLE_AAMIX
6104 	},
6105 	[ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6106 		.type = HDA_FIXUP_PINS,
6107 		.v.pins = (const struct hda_pintbl[]) {
6108 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6109 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6110 			{ }
6111 		},
6112 		.chained = true,
6113 		.chain_id = ALC269_FIXUP_HEADSET_MODE
6114 	},
6115 	[ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
6116 		.type = HDA_FIXUP_PINS,
6117 		.v.pins = (const struct hda_pintbl[]) {
6118 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6119 			{ }
6120 		},
6121 		.chained = true,
6122 		.chain_id = ALC269_FIXUP_HEADSET_MODE
6123 	},
6124 	[ALC275_FIXUP_DELL_XPS] = {
6125 		.type = HDA_FIXUP_VERBS,
6126 		.v.verbs = (const struct hda_verb[]) {
6127 			/* Enables internal speaker */
6128 			{0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
6129 			{0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
6130 			{0x20, AC_VERB_SET_COEF_INDEX, 0x30},
6131 			{0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
6132 			{}
6133 		}
6134 	},
6135 	[ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE] = {
6136 		.type = HDA_FIXUP_VERBS,
6137 		.v.verbs = (const struct hda_verb[]) {
6138 			/* Disable pass-through path for FRONT 14h */
6139 			{0x20, AC_VERB_SET_COEF_INDEX, 0x36},
6140 			{0x20, AC_VERB_SET_PROC_COEF, 0x1737},
6141 			{}
6142 		},
6143 		.chained = true,
6144 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6145 	},
6146 	[ALC293_FIXUP_LENOVO_SPK_NOISE] = {
6147 		.type = HDA_FIXUP_FUNC,
6148 		.v.func = alc_fixup_disable_aamix,
6149 		.chained = true,
6150 		.chain_id = ALC269_FIXUP_THINKPAD_ACPI
6151 	},
6152 	[ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
6153 		.type = HDA_FIXUP_FUNC,
6154 		.v.func = alc233_fixup_lenovo_line2_mic_hotkey,
6155 	},
6156 	[ALC255_FIXUP_DELL_SPK_NOISE] = {
6157 		.type = HDA_FIXUP_FUNC,
6158 		.v.func = alc_fixup_disable_aamix,
6159 		.chained = true,
6160 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6161 	},
6162 	[ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6163 		.type = HDA_FIXUP_VERBS,
6164 		.v.verbs = (const struct hda_verb[]) {
6165 			/* Disable pass-through path for FRONT 14h */
6166 			{ 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6167 			{ 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6168 			{}
6169 		},
6170 		.chained = true,
6171 		.chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6172 	},
6173 	[ALC280_FIXUP_HP_HEADSET_MIC] = {
6174 		.type = HDA_FIXUP_FUNC,
6175 		.v.func = alc_fixup_disable_aamix,
6176 		.chained = true,
6177 		.chain_id = ALC269_FIXUP_HEADSET_MIC,
6178 	},
6179 	[ALC221_FIXUP_HP_FRONT_MIC] = {
6180 		.type = HDA_FIXUP_PINS,
6181 		.v.pins = (const struct hda_pintbl[]) {
6182 			{ 0x19, 0x02a19020 }, /* Front Mic */
6183 			{ }
6184 		},
6185 	},
6186 	[ALC292_FIXUP_TPT460] = {
6187 		.type = HDA_FIXUP_FUNC,
6188 		.v.func = alc_fixup_tpt440_dock,
6189 		.chained = true,
6190 		.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
6191 	},
6192 	[ALC298_FIXUP_SPK_VOLUME] = {
6193 		.type = HDA_FIXUP_FUNC,
6194 		.v.func = alc298_fixup_speaker_volume,
6195 		.chained = true,
6196 		.chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6197 	},
6198 	[ALC295_FIXUP_DISABLE_DAC3] = {
6199 		.type = HDA_FIXUP_FUNC,
6200 		.v.func = alc295_fixup_disable_dac3,
6201 	},
6202 	[ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
6203 		.type = HDA_FIXUP_PINS,
6204 		.v.pins = (const struct hda_pintbl[]) {
6205 			{ 0x1b, 0x90170151 },
6206 			{ }
6207 		},
6208 		.chained = true,
6209 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6210 	},
6211 	[ALC269_FIXUP_ATIV_BOOK_8] = {
6212 		.type = HDA_FIXUP_FUNC,
6213 		.v.func = alc_fixup_auto_mute_via_amp,
6214 		.chained = true,
6215 		.chain_id = ALC269_FIXUP_NO_SHUTUP
6216 	},
6217 	[ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
6218 		.type = HDA_FIXUP_PINS,
6219 		.v.pins = (const struct hda_pintbl[]) {
6220 			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6221 			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6222 			{ }
6223 		},
6224 		.chained = true,
6225 		.chain_id = ALC269_FIXUP_HEADSET_MODE
6226 	},
6227 	[ALC256_FIXUP_ASUS_HEADSET_MODE] = {
6228 		.type = HDA_FIXUP_FUNC,
6229 		.v.func = alc_fixup_headset_mode,
6230 	},
6231 	[ALC256_FIXUP_ASUS_MIC] = {
6232 		.type = HDA_FIXUP_PINS,
6233 		.v.pins = (const struct hda_pintbl[]) {
6234 			{ 0x13, 0x90a60160 }, /* use as internal mic */
6235 			{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6236 			{ }
6237 		},
6238 		.chained = true,
6239 		.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6240 	},
6241 	[ALC256_FIXUP_ASUS_AIO_GPIO2] = {
6242 		.type = HDA_FIXUP_FUNC,
6243 		/* Set up GPIO2 for the speaker amp */
6244 		.v.func = alc_fixup_gpio4,
6245 	},
6246 	[ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6247 		.type = HDA_FIXUP_PINS,
6248 		.v.pins = (const struct hda_pintbl[]) {
6249 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6250 			{ }
6251 		},
6252 		.chained = true,
6253 		.chain_id = ALC269_FIXUP_HEADSET_MIC
6254 	},
6255 	[ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
6256 		.type = HDA_FIXUP_VERBS,
6257 		.v.verbs = (const struct hda_verb[]) {
6258 			/* Enables internal speaker */
6259 			{0x20, AC_VERB_SET_COEF_INDEX, 0x40},
6260 			{0x20, AC_VERB_SET_PROC_COEF, 0x8800},
6261 			{}
6262 		},
6263 		.chained = true,
6264 		.chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6265 	},
6266 	[ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
6267 		.type = HDA_FIXUP_FUNC,
6268 		.v.func = alc233_alc662_fixup_lenovo_dual_codecs,
6269 	},
6270 	[ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
6271 		.type = HDA_FIXUP_PINS,
6272 		.v.pins = (const struct hda_pintbl[]) {
6273 			/* Change the mic location from front to right, otherwise there are
6274 			   two front mics with the same name, pulseaudio can't handle them.
6275 			   This is just a temporary workaround, after applying this fixup,
6276 			   there will be one "Front Mic" and one "Mic" in this machine.
6277 			 */
6278 			{ 0x1a, 0x04a19040 },
6279 			{ }
6280 		},
6281 	},
6282 	[ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
6283 		.type = HDA_FIXUP_PINS,
6284 		.v.pins = (const struct hda_pintbl[]) {
6285 			{ 0x16, 0x0101102f }, /* Rear Headset HP */
6286 			{ 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
6287 			{ 0x1a, 0x01a19030 }, /* Rear Headset MIC */
6288 			{ 0x1b, 0x02011020 },
6289 			{ }
6290 		},
6291 		.chained = true,
6292 		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6293 	},
6294 	[ALC700_FIXUP_INTEL_REFERENCE] = {
6295 		.type = HDA_FIXUP_VERBS,
6296 		.v.verbs = (const struct hda_verb[]) {
6297 			/* Enables internal speaker */
6298 			{0x20, AC_VERB_SET_COEF_INDEX, 0x45},
6299 			{0x20, AC_VERB_SET_PROC_COEF, 0x5289},
6300 			{0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
6301 			{0x20, AC_VERB_SET_PROC_COEF, 0x001b},
6302 			{0x58, AC_VERB_SET_COEF_INDEX, 0x00},
6303 			{0x58, AC_VERB_SET_PROC_COEF, 0x3888},
6304 			{0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
6305 			{0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
6306 			{}
6307 		}
6308 	},
6309 	[ALC274_FIXUP_DELL_BIND_DACS] = {
6310 		.type = HDA_FIXUP_FUNC,
6311 		.v.func = alc274_fixup_bind_dacs,
6312 		.chained = true,
6313 		.chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6314 	},
6315 	[ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
6316 		.type = HDA_FIXUP_PINS,
6317 		.v.pins = (const struct hda_pintbl[]) {
6318 			{ 0x1b, 0x0401102f },
6319 			{ }
6320 		},
6321 		.chained = true,
6322 		.chain_id = ALC274_FIXUP_DELL_BIND_DACS
6323 	},
6324 	[ALC298_FIXUP_TPT470_DOCK] = {
6325 		.type = HDA_FIXUP_FUNC,
6326 		.v.func = alc_fixup_tpt470_dock,
6327 		.chained = true,
6328 		.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
6329 	},
6330 	[ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
6331 		.type = HDA_FIXUP_PINS,
6332 		.v.pins = (const struct hda_pintbl[]) {
6333 			{ 0x14, 0x0201101f },
6334 			{ }
6335 		},
6336 		.chained = true,
6337 		.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6338 	},
6339 	[ALC255_FIXUP_DELL_HEADSET_MIC] = {
6340 		.type = HDA_FIXUP_PINS,
6341 		.v.pins = (const struct hda_pintbl[]) {
6342 			{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6343 			{ }
6344 		},
6345 		.chained = true,
6346 		.chain_id = ALC269_FIXUP_HEADSET_MIC
6347 	},
6348 	[ALC295_FIXUP_HP_X360] = {
6349 		.type = HDA_FIXUP_FUNC,
6350 		.v.func = alc295_fixup_hp_top_speakers,
6351 		.chained = true,
6352 		.chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
6353 	}
6354 };
6355 
6356 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6357 	SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
6358 	SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
6359 	SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
6360 	SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
6361 	SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
6362 	SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
6363 	SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
6364 	SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
6365 	SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
6366 	SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
6367 	SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
6368 	SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
6369 	SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
6370 	SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
6371 	SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
6372 	SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
6373 	SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
6374 	SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
6375 	SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
6376 	SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6377 	SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6378 	SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6379 	SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
6380 	SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
6381 	SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
6382 	SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
6383 	SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
6384 	SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6385 	SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6386 	SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
6387 	SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
6388 	SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
6389 	SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
6390 	SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6391 	SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6392 	SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6393 	SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6394 	SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6395 	SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6396 	SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6397 	SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
6398 	SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
6399 	SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
6400 	SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
6401 	SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
6402 	SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
6403 	SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
6404 	SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
6405 	SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
6406 	SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
6407 	SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
6408 	SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
6409 	SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
6410 	SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
6411 	SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6412 	SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6413 	SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
6414 	SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
6415 	SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
6416 	SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
6417 	/* ALC282 */
6418 	SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6419 	SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6420 	SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6421 	SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6422 	SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6423 	SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6424 	SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6425 	SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6426 	SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6427 	SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6428 	SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6429 	SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6430 	SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
6431 	SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
6432 	SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
6433 	SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6434 	SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6435 	SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6436 	SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6437 	SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6438 	SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
6439 	SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6440 	SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6441 	/* ALC290 */
6442 	SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6443 	SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6444 	SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6445 	SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6446 	SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6447 	SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6448 	SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6449 	SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6450 	SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6451 	SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
6452 	SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6453 	SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6454 	SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6455 	SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6456 	SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6457 	SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6458 	SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6459 	SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6460 	SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6461 	SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6462 	SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6463 	SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6464 	SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6465 	SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6466 	SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6467 	SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6468 	SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6469 	SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6470 	SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6471 	SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
6472 	SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
6473 	SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
6474 	SND_PCI_QUIRK(0x103c, 0x82bf, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
6475 	SND_PCI_QUIRK(0x103c, 0x82c0, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
6476 	SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
6477 	SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
6478 	SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6479 	SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
6480 	SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
6481 	SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6482 	SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
6483 	SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
6484 	SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
6485 	SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
6486 	SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
6487 	SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
6488 	SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
6489 	SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
6490 	SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
6491 	SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
6492 	SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
6493 	SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
6494 	SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
6495 	SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6496 	SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
6497 	SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
6498 	SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
6499 	SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
6500 	SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
6501 	SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
6502 	SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
6503 	SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
6504 	SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
6505 	SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
6506 	SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
6507 	SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
6508 	SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
6509 	SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
6510 	SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
6511 	SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
6512 	SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
6513 	SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
6514 	SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
6515 	SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
6516 	SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
6517 	SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
6518 	SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
6519 	SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
6520 	SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
6521 	SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
6522 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
6523 	SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
6524 	SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
6525 	SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
6526 	SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
6527 	SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
6528 	SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
6529 	SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
6530 	SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
6531 	SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
6532 	SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
6533 	SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
6534 	SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
6535 	SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
6536 	SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
6537 	SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
6538 	SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
6539 	SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6540 	SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
6541 	SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
6542 	SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
6543 	SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6544 	SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6545 	SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
6546 	SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
6547 	SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
6548 	SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6549 	SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6550 	SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
6551 	SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6552 	SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6553 	SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6554 	SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6555 	SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6556 	SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6557 	SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6558 	SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6559 	SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6560 	SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6561 	SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
6562 	SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
6563 	SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
6564 	SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6565 	SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
6566 	SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
6567 	SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6568 	SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
6569 	SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
6570 	SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
6571 	SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
6572 	SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
6573 	SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
6574 	SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
6575 	SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
6576 	SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6577 	SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6578 	SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6579 	SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
6580 	SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6581 	SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6582 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
6583 	SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
6584 	SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
6585 
6586 #if 0
6587 	/* Below is a quirk table taken from the old code.
6588 	 * Basically the device should work as is without the fixup table.
6589 	 * If BIOS doesn't give a proper info, enable the corresponding
6590 	 * fixup entry.
6591 	 */
6592 	SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6593 		      ALC269_FIXUP_AMIC),
6594 	SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
6595 	SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
6596 	SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
6597 	SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
6598 	SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
6599 	SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
6600 	SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
6601 	SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
6602 	SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
6603 	SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
6604 	SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
6605 	SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
6606 	SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
6607 	SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
6608 	SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
6609 	SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
6610 	SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
6611 	SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
6612 	SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
6613 	SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
6614 	SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
6615 	SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
6616 	SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
6617 	SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
6618 	SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
6619 	SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
6620 	SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
6621 	SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
6622 	SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
6623 	SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
6624 	SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
6625 	SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
6626 	SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
6627 	SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
6628 	SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
6629 	SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
6630 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
6631 	SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
6632 	SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
6633 #endif
6634 	{}
6635 };
6636 
6637 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
6638 	SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
6639 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
6640 	SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
6641 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
6642 	{}
6643 };
6644 
6645 static const struct hda_model_fixup alc269_fixup_models[] = {
6646 	{.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
6647 	{.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6648 	{.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
6649 	{.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
6650 	{.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
6651 	{.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
6652 	{.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
6653 	{.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
6654 	{.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
6655 	{.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
6656 	{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
6657 	{.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
6658 	{.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
6659 	{.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
6660 	{.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
6661 	{.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
6662 	{.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
6663 	{.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
6664 	{.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
6665 	{.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
6666 	{.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
6667 	{.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
6668 	{.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
6669 	{.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
6670 	{.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
6671 	{.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
6672 	{.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
6673 	{.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
6674 	{.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
6675 	{.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
6676 	{.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
6677 	{.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
6678 	{.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
6679 	{.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
6680 	{.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
6681 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
6682 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
6683 	{.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
6684 	{.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
6685 	{.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
6686 	{.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
6687 	{.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
6688 	{.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
6689 	{.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
6690 	{.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
6691 	{.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
6692 	{.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
6693 	{.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
6694 	{.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
6695 	{.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
6696 	{.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
6697 	{.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
6698 	{.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
6699 	{.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
6700 	{.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
6701 	{.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
6702 	{.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
6703 	{.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
6704 	{.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
6705 	{.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
6706 	{.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
6707 	{.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
6708 	{.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
6709 	{.id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, .name = "alc255-dell-mute"},
6710 	{.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
6711 	{.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
6712 	{.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
6713 	{.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
6714 	{.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
6715 	{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
6716 	{.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
6717 	{.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
6718 	{.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
6719 	{.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
6720 	{.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
6721 	{.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
6722 	{.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
6723 	{.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
6724 	{.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
6725 	{.id = ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE, .name = "alc256-dell-xps13"},
6726 	{.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
6727 	{.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
6728 	{.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
6729 	{.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
6730 	{.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
6731 	{.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
6732 	{.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
6733 	{.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
6734 	{.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
6735 	{.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
6736 	{.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
6737 	{.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
6738 	{.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
6739 	{.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
6740 	{.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
6741 	{.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
6742 	{.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
6743 	{.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
6744 	{.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
6745 	{.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
6746 	{.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
6747 	{.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
6748 	{}
6749 };
6750 #define ALC225_STANDARD_PINS \
6751 	{0x21, 0x04211020}
6752 
6753 #define ALC256_STANDARD_PINS \
6754 	{0x12, 0x90a60140}, \
6755 	{0x14, 0x90170110}, \
6756 	{0x21, 0x02211020}
6757 
6758 #define ALC282_STANDARD_PINS \
6759 	{0x14, 0x90170110}
6760 
6761 #define ALC290_STANDARD_PINS \
6762 	{0x12, 0x99a30130}
6763 
6764 #define ALC292_STANDARD_PINS \
6765 	{0x14, 0x90170110}, \
6766 	{0x15, 0x0221401f}
6767 
6768 #define ALC295_STANDARD_PINS \
6769 	{0x12, 0xb7a60130}, \
6770 	{0x14, 0x90170110}, \
6771 	{0x21, 0x04211020}
6772 
6773 #define ALC298_STANDARD_PINS \
6774 	{0x12, 0x90a60130}, \
6775 	{0x21, 0x03211020}
6776 
6777 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
6778 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6779 		{0x12, 0x90a601c0},
6780 		{0x14, 0x90171120},
6781 		{0x21, 0x02211030}),
6782 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6783 		{0x14, 0x90170110},
6784 		{0x1b, 0x90a70130},
6785 		{0x21, 0x03211020}),
6786 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6787 		{0x1a, 0x90a70130},
6788 		{0x1b, 0x90170110},
6789 		{0x21, 0x03211020}),
6790 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6791 		ALC225_STANDARD_PINS,
6792 		{0x12, 0xb7a60130},
6793 		{0x14, 0x901701a0}),
6794 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6795 		ALC225_STANDARD_PINS,
6796 		{0x12, 0xb7a60130},
6797 		{0x14, 0x901701b0}),
6798 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6799 		ALC225_STANDARD_PINS,
6800 		{0x12, 0xb7a60150},
6801 		{0x14, 0x901701a0}),
6802 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6803 		ALC225_STANDARD_PINS,
6804 		{0x12, 0xb7a60150},
6805 		{0x14, 0x901701b0}),
6806 	SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6807 		ALC225_STANDARD_PINS,
6808 		{0x12, 0xb7a60130},
6809 		{0x1b, 0x90170110}),
6810 	SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6811 		{0x1b, 0x01111010},
6812 		{0x1e, 0x01451130},
6813 		{0x21, 0x02211020}),
6814 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
6815 		{0x12, 0x90a60140},
6816 		{0x14, 0x90170110},
6817 		{0x19, 0x02a11030},
6818 		{0x21, 0x02211020}),
6819 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
6820 		{0x14, 0x90170110},
6821 		{0x19, 0x02a11030},
6822 		{0x1a, 0x02a11040},
6823 		{0x1b, 0x01014020},
6824 		{0x21, 0x0221101f}),
6825 	SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
6826 		{0x14, 0x90170110},
6827 		{0x19, 0x02a11020},
6828 		{0x1a, 0x02a11030},
6829 		{0x21, 0x0221101f}),
6830 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6831 		{0x12, 0x90a60140},
6832 		{0x14, 0x90170110},
6833 		{0x21, 0x02211020}),
6834 	SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6835 		{0x12, 0x90a60140},
6836 		{0x14, 0x90170150},
6837 		{0x21, 0x02211020}),
6838 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
6839 		{0x14, 0x90170110},
6840 		{0x21, 0x02211020}),
6841 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6842 		{0x14, 0x90170130},
6843 		{0x21, 0x02211040}),
6844 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6845 		{0x12, 0x90a60140},
6846 		{0x14, 0x90170110},
6847 		{0x21, 0x02211020}),
6848 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6849 		{0x12, 0x90a60160},
6850 		{0x14, 0x90170120},
6851 		{0x21, 0x02211030}),
6852 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6853 		{0x14, 0x90170110},
6854 		{0x1b, 0x02011020},
6855 		{0x21, 0x0221101f}),
6856 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6857 		{0x14, 0x90170110},
6858 		{0x1b, 0x01011020},
6859 		{0x21, 0x0221101f}),
6860 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6861 		{0x14, 0x90170130},
6862 		{0x1b, 0x01014020},
6863 		{0x21, 0x0221103f}),
6864 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6865 		{0x14, 0x90170130},
6866 		{0x1b, 0x01011020},
6867 		{0x21, 0x0221103f}),
6868 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6869 		{0x14, 0x90170130},
6870 		{0x1b, 0x02011020},
6871 		{0x21, 0x0221103f}),
6872 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6873 		{0x14, 0x90170150},
6874 		{0x1b, 0x02011020},
6875 		{0x21, 0x0221105f}),
6876 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6877 		{0x14, 0x90170110},
6878 		{0x1b, 0x01014020},
6879 		{0x21, 0x0221101f}),
6880 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6881 		{0x12, 0x90a60160},
6882 		{0x14, 0x90170120},
6883 		{0x17, 0x90170140},
6884 		{0x21, 0x0321102f}),
6885 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6886 		{0x12, 0x90a60160},
6887 		{0x14, 0x90170130},
6888 		{0x21, 0x02211040}),
6889 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6890 		{0x12, 0x90a60160},
6891 		{0x14, 0x90170140},
6892 		{0x21, 0x02211050}),
6893 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6894 		{0x12, 0x90a60170},
6895 		{0x14, 0x90170120},
6896 		{0x21, 0x02211030}),
6897 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6898 		{0x12, 0x90a60170},
6899 		{0x14, 0x90170130},
6900 		{0x21, 0x02211040}),
6901 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6902 		{0x12, 0x90a60170},
6903 		{0x14, 0x90171130},
6904 		{0x21, 0x02211040}),
6905 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6906 		{0x12, 0x90a60170},
6907 		{0x14, 0x90170140},
6908 		{0x21, 0x02211050}),
6909 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6910 		{0x12, 0x90a60180},
6911 		{0x14, 0x90170130},
6912 		{0x21, 0x02211040}),
6913 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6914 		{0x12, 0x90a60180},
6915 		{0x14, 0x90170120},
6916 		{0x21, 0x02211030}),
6917 	SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6918 		{0x1b, 0x01011020},
6919 		{0x21, 0x02211010}),
6920 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6921 		{0x12, 0x90a60130},
6922 		{0x14, 0x90170110},
6923 		{0x1b, 0x01011020},
6924 		{0x21, 0x0221101f}),
6925 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6926 		{0x12, 0x90a60160},
6927 		{0x14, 0x90170120},
6928 		{0x21, 0x02211030}),
6929 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6930 		{0x12, 0x90a60170},
6931 		{0x14, 0x90170120},
6932 		{0x21, 0x02211030}),
6933 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6934 		{0x12, 0x90a60180},
6935 		{0x14, 0x90170120},
6936 		{0x21, 0x02211030}),
6937 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6938 		{0x12, 0xb7a60130},
6939 		{0x14, 0x90170110},
6940 		{0x21, 0x02211020}),
6941 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6942 		{0x12, 0x90a60130},
6943 		{0x14, 0x90170110},
6944 		{0x14, 0x01011020},
6945 		{0x21, 0x0221101f}),
6946 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6947 		ALC256_STANDARD_PINS),
6948 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
6949 		{0x14, 0x90170110},
6950 		{0x1b, 0x90a70130},
6951 		{0x21, 0x04211020}),
6952 	SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
6953 		{0x14, 0x90170110},
6954 		{0x1b, 0x90a70130},
6955 		{0x21, 0x03211020}),
6956 	SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6957 		{0x12, 0xb7a60130},
6958 		{0x13, 0xb8a61140},
6959 		{0x16, 0x90170110},
6960 		{0x21, 0x04211020}),
6961 	SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
6962 		{0x12, 0x90a60130},
6963 		{0x14, 0x90170110},
6964 		{0x15, 0x0421101f},
6965 		{0x1a, 0x04a11020}),
6966 	SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
6967 		{0x12, 0x90a60140},
6968 		{0x14, 0x90170110},
6969 		{0x15, 0x0421101f},
6970 		{0x18, 0x02811030},
6971 		{0x1a, 0x04a1103f},
6972 		{0x1b, 0x02011020}),
6973 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
6974 		ALC282_STANDARD_PINS,
6975 		{0x12, 0x99a30130},
6976 		{0x19, 0x03a11020},
6977 		{0x21, 0x0321101f}),
6978 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
6979 		ALC282_STANDARD_PINS,
6980 		{0x12, 0x99a30130},
6981 		{0x19, 0x03a11020},
6982 		{0x21, 0x03211040}),
6983 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
6984 		ALC282_STANDARD_PINS,
6985 		{0x12, 0x99a30130},
6986 		{0x19, 0x03a11030},
6987 		{0x21, 0x03211020}),
6988 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
6989 		ALC282_STANDARD_PINS,
6990 		{0x12, 0x99a30130},
6991 		{0x19, 0x04a11020},
6992 		{0x21, 0x0421101f}),
6993 	SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
6994 		ALC282_STANDARD_PINS,
6995 		{0x12, 0x90a60140},
6996 		{0x19, 0x04a11030},
6997 		{0x21, 0x04211020}),
6998 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6999 		ALC282_STANDARD_PINS,
7000 		{0x12, 0x90a60130},
7001 		{0x21, 0x0321101f}),
7002 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7003 		{0x12, 0x90a60160},
7004 		{0x14, 0x90170120},
7005 		{0x21, 0x02211030}),
7006 	SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7007 		ALC282_STANDARD_PINS,
7008 		{0x12, 0x90a60130},
7009 		{0x19, 0x03a11020},
7010 		{0x21, 0x0321101f}),
7011 	SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
7012 		{0x12, 0x90a60120},
7013 		{0x14, 0x90170110},
7014 		{0x21, 0x0321101f}),
7015 	SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7016 		{0x12, 0xb7a60130},
7017 		{0x14, 0x90170110},
7018 		{0x21, 0x04211020}),
7019 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7020 		ALC290_STANDARD_PINS,
7021 		{0x15, 0x04211040},
7022 		{0x18, 0x90170112},
7023 		{0x1a, 0x04a11020}),
7024 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7025 		ALC290_STANDARD_PINS,
7026 		{0x15, 0x04211040},
7027 		{0x18, 0x90170110},
7028 		{0x1a, 0x04a11020}),
7029 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7030 		ALC290_STANDARD_PINS,
7031 		{0x15, 0x0421101f},
7032 		{0x1a, 0x04a11020}),
7033 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7034 		ALC290_STANDARD_PINS,
7035 		{0x15, 0x04211020},
7036 		{0x1a, 0x04a11040}),
7037 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7038 		ALC290_STANDARD_PINS,
7039 		{0x14, 0x90170110},
7040 		{0x15, 0x04211020},
7041 		{0x1a, 0x04a11040}),
7042 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7043 		ALC290_STANDARD_PINS,
7044 		{0x14, 0x90170110},
7045 		{0x15, 0x04211020},
7046 		{0x1a, 0x04a11020}),
7047 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7048 		ALC290_STANDARD_PINS,
7049 		{0x14, 0x90170110},
7050 		{0x15, 0x0421101f},
7051 		{0x1a, 0x04a11020}),
7052 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
7053 		ALC292_STANDARD_PINS,
7054 		{0x12, 0x90a60140},
7055 		{0x16, 0x01014020},
7056 		{0x19, 0x01a19030}),
7057 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
7058 		ALC292_STANDARD_PINS,
7059 		{0x12, 0x90a60140},
7060 		{0x16, 0x01014020},
7061 		{0x18, 0x02a19031},
7062 		{0x19, 0x01a1903e}),
7063 	SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
7064 		ALC292_STANDARD_PINS,
7065 		{0x12, 0x90a60140}),
7066 	SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
7067 		ALC292_STANDARD_PINS,
7068 		{0x13, 0x90a60140},
7069 		{0x16, 0x21014020},
7070 		{0x19, 0x21a19030}),
7071 	SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
7072 		ALC292_STANDARD_PINS,
7073 		{0x13, 0x90a60140}),
7074 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7075 		ALC295_STANDARD_PINS,
7076 		{0x17, 0x21014020},
7077 		{0x18, 0x21a19030}),
7078 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7079 		ALC295_STANDARD_PINS,
7080 		{0x17, 0x21014040},
7081 		{0x18, 0x21a19050}),
7082 	SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7083 		ALC295_STANDARD_PINS),
7084 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7085 		ALC298_STANDARD_PINS,
7086 		{0x17, 0x90170110}),
7087 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7088 		ALC298_STANDARD_PINS,
7089 		{0x17, 0x90170140}),
7090 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7091 		ALC298_STANDARD_PINS,
7092 		{0x17, 0x90170150}),
7093 	SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
7094 		{0x12, 0xb7a60140},
7095 		{0x13, 0xb7a60150},
7096 		{0x17, 0x90170110},
7097 		{0x1a, 0x03011020},
7098 		{0x21, 0x03211030}),
7099 	SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7100 		ALC225_STANDARD_PINS,
7101 		{0x12, 0xb7a60130},
7102 		{0x17, 0x90170110}),
7103 	{}
7104 };
7105 
7106 static void alc269_fill_coef(struct hda_codec *codec)
7107 {
7108 	struct alc_spec *spec = codec->spec;
7109 	int val;
7110 
7111 	if (spec->codec_variant != ALC269_TYPE_ALC269VB)
7112 		return;
7113 
7114 	if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
7115 		alc_write_coef_idx(codec, 0xf, 0x960b);
7116 		alc_write_coef_idx(codec, 0xe, 0x8817);
7117 	}
7118 
7119 	if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
7120 		alc_write_coef_idx(codec, 0xf, 0x960b);
7121 		alc_write_coef_idx(codec, 0xe, 0x8814);
7122 	}
7123 
7124 	if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
7125 		/* Power up output pin */
7126 		alc_update_coef_idx(codec, 0x04, 0, 1<<11);
7127 	}
7128 
7129 	if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
7130 		val = alc_read_coef_idx(codec, 0xd);
7131 		if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
7132 			/* Capless ramp up clock control */
7133 			alc_write_coef_idx(codec, 0xd, val | (1<<10));
7134 		}
7135 		val = alc_read_coef_idx(codec, 0x17);
7136 		if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
7137 			/* Class D power on reset */
7138 			alc_write_coef_idx(codec, 0x17, val | (1<<7));
7139 		}
7140 	}
7141 
7142 	/* HP */
7143 	alc_update_coef_idx(codec, 0x4, 0, 1<<11);
7144 }
7145 
7146 /*
7147  */
7148 static int patch_alc269(struct hda_codec *codec)
7149 {
7150 	struct alc_spec *spec;
7151 	int err;
7152 
7153 	err = alc_alloc_spec(codec, 0x0b);
7154 	if (err < 0)
7155 		return err;
7156 
7157 	spec = codec->spec;
7158 	spec->gen.shared_mic_vref_pin = 0x18;
7159 	codec->power_save_node = 1;
7160 
7161 #ifdef CONFIG_PM
7162 	codec->patch_ops.suspend = alc269_suspend;
7163 	codec->patch_ops.resume = alc269_resume;
7164 #endif
7165 	spec->shutup = alc_default_shutup;
7166 	spec->init_hook = alc_default_init;
7167 
7168 	switch (codec->core.vendor_id) {
7169 	case 0x10ec0269:
7170 		spec->codec_variant = ALC269_TYPE_ALC269VA;
7171 		switch (alc_get_coef0(codec) & 0x00f0) {
7172 		case 0x0010:
7173 			if (codec->bus->pci &&
7174 			    codec->bus->pci->subsystem_vendor == 0x1025 &&
7175 			    spec->cdefine.platform_type == 1)
7176 				err = alc_codec_rename(codec, "ALC271X");
7177 			spec->codec_variant = ALC269_TYPE_ALC269VB;
7178 			break;
7179 		case 0x0020:
7180 			if (codec->bus->pci &&
7181 			    codec->bus->pci->subsystem_vendor == 0x17aa &&
7182 			    codec->bus->pci->subsystem_device == 0x21f3)
7183 				err = alc_codec_rename(codec, "ALC3202");
7184 			spec->codec_variant = ALC269_TYPE_ALC269VC;
7185 			break;
7186 		case 0x0030:
7187 			spec->codec_variant = ALC269_TYPE_ALC269VD;
7188 			break;
7189 		default:
7190 			alc_fix_pll_init(codec, 0x20, 0x04, 15);
7191 		}
7192 		if (err < 0)
7193 			goto error;
7194 		spec->shutup = alc269_shutup;
7195 		spec->init_hook = alc269_fill_coef;
7196 		alc269_fill_coef(codec);
7197 		break;
7198 
7199 	case 0x10ec0280:
7200 	case 0x10ec0290:
7201 		spec->codec_variant = ALC269_TYPE_ALC280;
7202 		break;
7203 	case 0x10ec0282:
7204 		spec->codec_variant = ALC269_TYPE_ALC282;
7205 		spec->shutup = alc282_shutup;
7206 		spec->init_hook = alc282_init;
7207 		break;
7208 	case 0x10ec0233:
7209 	case 0x10ec0283:
7210 		spec->codec_variant = ALC269_TYPE_ALC283;
7211 		spec->shutup = alc283_shutup;
7212 		spec->init_hook = alc283_init;
7213 		break;
7214 	case 0x10ec0284:
7215 	case 0x10ec0292:
7216 		spec->codec_variant = ALC269_TYPE_ALC284;
7217 		break;
7218 	case 0x10ec0293:
7219 		spec->codec_variant = ALC269_TYPE_ALC293;
7220 		break;
7221 	case 0x10ec0286:
7222 	case 0x10ec0288:
7223 		spec->codec_variant = ALC269_TYPE_ALC286;
7224 		spec->shutup = alc286_shutup;
7225 		break;
7226 	case 0x10ec0298:
7227 		spec->codec_variant = ALC269_TYPE_ALC298;
7228 		break;
7229 	case 0x10ec0235:
7230 	case 0x10ec0255:
7231 		spec->codec_variant = ALC269_TYPE_ALC255;
7232 		spec->shutup = alc256_shutup;
7233 		spec->init_hook = alc256_init;
7234 		break;
7235 	case 0x10ec0236:
7236 	case 0x10ec0256:
7237 		spec->codec_variant = ALC269_TYPE_ALC256;
7238 		spec->shutup = alc256_shutup;
7239 		spec->init_hook = alc256_init;
7240 		spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
7241 		alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
7242 		break;
7243 	case 0x10ec0257:
7244 		spec->codec_variant = ALC269_TYPE_ALC257;
7245 		spec->shutup = alc256_shutup;
7246 		spec->init_hook = alc256_init;
7247 		spec->gen.mixer_nid = 0;
7248 		break;
7249 	case 0x10ec0215:
7250 	case 0x10ec0285:
7251 	case 0x10ec0289:
7252 		spec->codec_variant = ALC269_TYPE_ALC215;
7253 		spec->shutup = alc225_shutup;
7254 		spec->init_hook = alc225_init;
7255 		spec->gen.mixer_nid = 0;
7256 		break;
7257 	case 0x10ec0225:
7258 	case 0x10ec0295:
7259 	case 0x10ec0299:
7260 		spec->codec_variant = ALC269_TYPE_ALC225;
7261 		spec->shutup = alc225_shutup;
7262 		spec->init_hook = alc225_init;
7263 		spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
7264 		break;
7265 	case 0x10ec0234:
7266 	case 0x10ec0274:
7267 	case 0x10ec0294:
7268 		spec->codec_variant = ALC269_TYPE_ALC294;
7269 		spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
7270 		alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
7271 		break;
7272 	case 0x10ec0700:
7273 	case 0x10ec0701:
7274 	case 0x10ec0703:
7275 		spec->codec_variant = ALC269_TYPE_ALC700;
7276 		spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
7277 		alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
7278 		break;
7279 
7280 	}
7281 
7282 	if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
7283 		spec->has_alc5505_dsp = 1;
7284 		spec->init_hook = alc5505_dsp_init;
7285 	}
7286 
7287 	snd_hda_pick_fixup(codec, alc269_fixup_models,
7288 		       alc269_fixup_tbl, alc269_fixups);
7289 	snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
7290 	snd_hda_pick_fixup(codec, NULL,	alc269_fixup_vendor_tbl,
7291 			   alc269_fixups);
7292 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7293 
7294 	alc_auto_parse_customize_define(codec);
7295 
7296 	if (has_cdefine_beep(codec))
7297 		spec->gen.beep_nid = 0x01;
7298 
7299 	/* automatic parse from the BIOS config */
7300 	err = alc269_parse_auto_config(codec);
7301 	if (err < 0)
7302 		goto error;
7303 
7304 	if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
7305 		err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
7306 		if (err < 0)
7307 			goto error;
7308 	}
7309 
7310 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7311 
7312 	return 0;
7313 
7314  error:
7315 	alc_free(codec);
7316 	return err;
7317 }
7318 
7319 /*
7320  * ALC861
7321  */
7322 
7323 static int alc861_parse_auto_config(struct hda_codec *codec)
7324 {
7325 	static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7326 	static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
7327 	return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
7328 }
7329 
7330 /* Pin config fixes */
7331 enum {
7332 	ALC861_FIXUP_FSC_AMILO_PI1505,
7333 	ALC861_FIXUP_AMP_VREF_0F,
7334 	ALC861_FIXUP_NO_JACK_DETECT,
7335 	ALC861_FIXUP_ASUS_A6RP,
7336 	ALC660_FIXUP_ASUS_W7J,
7337 };
7338 
7339 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
7340 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
7341 			const struct hda_fixup *fix, int action)
7342 {
7343 	struct alc_spec *spec = codec->spec;
7344 	unsigned int val;
7345 
7346 	if (action != HDA_FIXUP_ACT_INIT)
7347 		return;
7348 	val = snd_hda_codec_get_pin_target(codec, 0x0f);
7349 	if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
7350 		val |= AC_PINCTL_IN_EN;
7351 	val |= AC_PINCTL_VREF_50;
7352 	snd_hda_set_pin_ctl(codec, 0x0f, val);
7353 	spec->gen.keep_vref_in_automute = 1;
7354 }
7355 
7356 /* suppress the jack-detection */
7357 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
7358 				     const struct hda_fixup *fix, int action)
7359 {
7360 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
7361 		codec->no_jack_detect = 1;
7362 }
7363 
7364 static const struct hda_fixup alc861_fixups[] = {
7365 	[ALC861_FIXUP_FSC_AMILO_PI1505] = {
7366 		.type = HDA_FIXUP_PINS,
7367 		.v.pins = (const struct hda_pintbl[]) {
7368 			{ 0x0b, 0x0221101f }, /* HP */
7369 			{ 0x0f, 0x90170310 }, /* speaker */
7370 			{ }
7371 		}
7372 	},
7373 	[ALC861_FIXUP_AMP_VREF_0F] = {
7374 		.type = HDA_FIXUP_FUNC,
7375 		.v.func = alc861_fixup_asus_amp_vref_0f,
7376 	},
7377 	[ALC861_FIXUP_NO_JACK_DETECT] = {
7378 		.type = HDA_FIXUP_FUNC,
7379 		.v.func = alc_fixup_no_jack_detect,
7380 	},
7381 	[ALC861_FIXUP_ASUS_A6RP] = {
7382 		.type = HDA_FIXUP_FUNC,
7383 		.v.func = alc861_fixup_asus_amp_vref_0f,
7384 		.chained = true,
7385 		.chain_id = ALC861_FIXUP_NO_JACK_DETECT,
7386 	},
7387 	[ALC660_FIXUP_ASUS_W7J] = {
7388 		.type = HDA_FIXUP_VERBS,
7389 		.v.verbs = (const struct hda_verb[]) {
7390 			/* ASUS W7J needs a magic pin setup on unused NID 0x10
7391 			 * for enabling outputs
7392 			 */
7393 			{0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7394 			{ }
7395 		},
7396 	}
7397 };
7398 
7399 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
7400 	SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
7401 	SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
7402 	SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
7403 	SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
7404 	SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
7405 	SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
7406 	SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
7407 	SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
7408 	{}
7409 };
7410 
7411 /*
7412  */
7413 static int patch_alc861(struct hda_codec *codec)
7414 {
7415 	struct alc_spec *spec;
7416 	int err;
7417 
7418 	err = alc_alloc_spec(codec, 0x15);
7419 	if (err < 0)
7420 		return err;
7421 
7422 	spec = codec->spec;
7423 	spec->gen.beep_nid = 0x23;
7424 
7425 #ifdef CONFIG_PM
7426 	spec->power_hook = alc_power_eapd;
7427 #endif
7428 
7429 	snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
7430 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7431 
7432 	/* automatic parse from the BIOS config */
7433 	err = alc861_parse_auto_config(codec);
7434 	if (err < 0)
7435 		goto error;
7436 
7437 	if (!spec->gen.no_analog) {
7438 		err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7439 		if (err < 0)
7440 			goto error;
7441 	}
7442 
7443 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7444 
7445 	return 0;
7446 
7447  error:
7448 	alc_free(codec);
7449 	return err;
7450 }
7451 
7452 /*
7453  * ALC861-VD support
7454  *
7455  * Based on ALC882
7456  *
7457  * In addition, an independent DAC
7458  */
7459 static int alc861vd_parse_auto_config(struct hda_codec *codec)
7460 {
7461 	static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
7462 	static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7463 	return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
7464 }
7465 
7466 enum {
7467 	ALC660VD_FIX_ASUS_GPIO1,
7468 	ALC861VD_FIX_DALLAS,
7469 };
7470 
7471 /* exclude VREF80 */
7472 static void alc861vd_fixup_dallas(struct hda_codec *codec,
7473 				  const struct hda_fixup *fix, int action)
7474 {
7475 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7476 		snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
7477 		snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
7478 	}
7479 }
7480 
7481 /* reset GPIO1 */
7482 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
7483 				      const struct hda_fixup *fix, int action)
7484 {
7485 	struct alc_spec *spec = codec->spec;
7486 
7487 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
7488 		spec->gpio_mask |= 0x02;
7489 	alc_fixup_gpio(codec, action, 0x01);
7490 }
7491 
7492 static const struct hda_fixup alc861vd_fixups[] = {
7493 	[ALC660VD_FIX_ASUS_GPIO1] = {
7494 		.type = HDA_FIXUP_FUNC,
7495 		.v.func = alc660vd_fixup_asus_gpio1,
7496 	},
7497 	[ALC861VD_FIX_DALLAS] = {
7498 		.type = HDA_FIXUP_FUNC,
7499 		.v.func = alc861vd_fixup_dallas,
7500 	},
7501 };
7502 
7503 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
7504 	SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
7505 	SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
7506 	SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
7507 	{}
7508 };
7509 
7510 /*
7511  */
7512 static int patch_alc861vd(struct hda_codec *codec)
7513 {
7514 	struct alc_spec *spec;
7515 	int err;
7516 
7517 	err = alc_alloc_spec(codec, 0x0b);
7518 	if (err < 0)
7519 		return err;
7520 
7521 	spec = codec->spec;
7522 	spec->gen.beep_nid = 0x23;
7523 
7524 	spec->shutup = alc_eapd_shutup;
7525 
7526 	snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
7527 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7528 
7529 	/* automatic parse from the BIOS config */
7530 	err = alc861vd_parse_auto_config(codec);
7531 	if (err < 0)
7532 		goto error;
7533 
7534 	if (!spec->gen.no_analog) {
7535 		err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7536 		if (err < 0)
7537 			goto error;
7538 	}
7539 
7540 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7541 
7542 	return 0;
7543 
7544  error:
7545 	alc_free(codec);
7546 	return err;
7547 }
7548 
7549 /*
7550  * ALC662 support
7551  *
7552  * ALC662 is almost identical with ALC880 but has cleaner and more flexible
7553  * configuration.  Each pin widget can choose any input DACs and a mixer.
7554  * Each ADC is connected from a mixer of all inputs.  This makes possible
7555  * 6-channel independent captures.
7556  *
7557  * In addition, an independent DAC for the multi-playback (not used in this
7558  * driver yet).
7559  */
7560 
7561 /*
7562  * BIOS auto configuration
7563  */
7564 
7565 static int alc662_parse_auto_config(struct hda_codec *codec)
7566 {
7567 	static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
7568 	static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
7569 	static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7570 	const hda_nid_t *ssids;
7571 
7572 	if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
7573 	    codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
7574 	    codec->core.vendor_id == 0x10ec0671)
7575 		ssids = alc663_ssids;
7576 	else
7577 		ssids = alc662_ssids;
7578 	return alc_parse_auto_config(codec, alc662_ignore, ssids);
7579 }
7580 
7581 static void alc272_fixup_mario(struct hda_codec *codec,
7582 			       const struct hda_fixup *fix, int action)
7583 {
7584 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
7585 		return;
7586 	if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
7587 				      (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
7588 				      (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
7589 				      (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7590 				      (0 << AC_AMPCAP_MUTE_SHIFT)))
7591 		codec_warn(codec, "failed to override amp caps for NID 0x2\n");
7592 }
7593 
7594 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
7595 	{ .channels = 2,
7596 	  .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
7597 	{ .channels = 4,
7598 	  .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
7599 		   SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
7600 	{ }
7601 };
7602 
7603 /* override the 2.1 chmap */
7604 static void alc_fixup_bass_chmap(struct hda_codec *codec,
7605 				    const struct hda_fixup *fix, int action)
7606 {
7607 	if (action == HDA_FIXUP_ACT_BUILD) {
7608 		struct alc_spec *spec = codec->spec;
7609 		spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
7610 	}
7611 }
7612 
7613 /* avoid D3 for keeping GPIO up */
7614 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
7615 					  hda_nid_t nid,
7616 					  unsigned int power_state)
7617 {
7618 	struct alc_spec *spec = codec->spec;
7619 	if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
7620 		return AC_PWRST_D0;
7621 	return power_state;
7622 }
7623 
7624 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
7625 				   const struct hda_fixup *fix, int action)
7626 {
7627 	struct alc_spec *spec = codec->spec;
7628 
7629 	alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
7630 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7631 		spec->mute_led_polarity = 1;
7632 		codec->power_filter = gpio_led_power_filter;
7633 	}
7634 }
7635 
7636 static void alc662_usi_automute_hook(struct hda_codec *codec,
7637 					 struct hda_jack_callback *jack)
7638 {
7639 	struct alc_spec *spec = codec->spec;
7640 	int vref;
7641 	msleep(200);
7642 	snd_hda_gen_hp_automute(codec, jack);
7643 
7644 	vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
7645 	msleep(100);
7646 	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7647 			    vref);
7648 }
7649 
7650 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
7651 				     const struct hda_fixup *fix, int action)
7652 {
7653 	struct alc_spec *spec = codec->spec;
7654 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7655 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
7656 		spec->gen.hp_automute_hook = alc662_usi_automute_hook;
7657 	}
7658 }
7659 
7660 static struct coef_fw alc668_coefs[] = {
7661 	WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
7662 	WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
7663 	WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
7664 	WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
7665 	WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
7666 	WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
7667 	WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
7668 	WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
7669 	WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
7670 	WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
7671 	WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
7672 	WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
7673 	WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
7674 	WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
7675 	WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
7676 	WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
7677 	WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
7678 	WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
7679 	WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
7680 	WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
7681 	{}
7682 };
7683 
7684 static void alc668_restore_default_value(struct hda_codec *codec)
7685 {
7686 	alc_process_coef_fw(codec, alc668_coefs);
7687 }
7688 
7689 enum {
7690 	ALC662_FIXUP_ASPIRE,
7691 	ALC662_FIXUP_LED_GPIO1,
7692 	ALC662_FIXUP_IDEAPAD,
7693 	ALC272_FIXUP_MARIO,
7694 	ALC662_FIXUP_CZC_P10T,
7695 	ALC662_FIXUP_SKU_IGNORE,
7696 	ALC662_FIXUP_HP_RP5800,
7697 	ALC662_FIXUP_ASUS_MODE1,
7698 	ALC662_FIXUP_ASUS_MODE2,
7699 	ALC662_FIXUP_ASUS_MODE3,
7700 	ALC662_FIXUP_ASUS_MODE4,
7701 	ALC662_FIXUP_ASUS_MODE5,
7702 	ALC662_FIXUP_ASUS_MODE6,
7703 	ALC662_FIXUP_ASUS_MODE7,
7704 	ALC662_FIXUP_ASUS_MODE8,
7705 	ALC662_FIXUP_NO_JACK_DETECT,
7706 	ALC662_FIXUP_ZOTAC_Z68,
7707 	ALC662_FIXUP_INV_DMIC,
7708 	ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
7709 	ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
7710 	ALC662_FIXUP_HEADSET_MODE,
7711 	ALC668_FIXUP_HEADSET_MODE,
7712 	ALC662_FIXUP_BASS_MODE4_CHMAP,
7713 	ALC662_FIXUP_BASS_16,
7714 	ALC662_FIXUP_BASS_1A,
7715 	ALC662_FIXUP_BASS_CHMAP,
7716 	ALC668_FIXUP_AUTO_MUTE,
7717 	ALC668_FIXUP_DELL_DISABLE_AAMIX,
7718 	ALC668_FIXUP_DELL_XPS13,
7719 	ALC662_FIXUP_ASUS_Nx50,
7720 	ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
7721 	ALC668_FIXUP_ASUS_Nx51,
7722 	ALC891_FIXUP_HEADSET_MODE,
7723 	ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
7724 	ALC662_FIXUP_ACER_VERITON,
7725 	ALC892_FIXUP_ASROCK_MOBO,
7726 	ALC662_FIXUP_USI_FUNC,
7727 	ALC662_FIXUP_USI_HEADSET_MODE,
7728 	ALC662_FIXUP_LENOVO_MULTI_CODECS,
7729 };
7730 
7731 static const struct hda_fixup alc662_fixups[] = {
7732 	[ALC662_FIXUP_ASPIRE] = {
7733 		.type = HDA_FIXUP_PINS,
7734 		.v.pins = (const struct hda_pintbl[]) {
7735 			{ 0x15, 0x99130112 }, /* subwoofer */
7736 			{ }
7737 		}
7738 	},
7739 	[ALC662_FIXUP_LED_GPIO1] = {
7740 		.type = HDA_FIXUP_FUNC,
7741 		.v.func = alc662_fixup_led_gpio1,
7742 	},
7743 	[ALC662_FIXUP_IDEAPAD] = {
7744 		.type = HDA_FIXUP_PINS,
7745 		.v.pins = (const struct hda_pintbl[]) {
7746 			{ 0x17, 0x99130112 }, /* subwoofer */
7747 			{ }
7748 		},
7749 		.chained = true,
7750 		.chain_id = ALC662_FIXUP_LED_GPIO1,
7751 	},
7752 	[ALC272_FIXUP_MARIO] = {
7753 		.type = HDA_FIXUP_FUNC,
7754 		.v.func = alc272_fixup_mario,
7755 	},
7756 	[ALC662_FIXUP_CZC_P10T] = {
7757 		.type = HDA_FIXUP_VERBS,
7758 		.v.verbs = (const struct hda_verb[]) {
7759 			{0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
7760 			{}
7761 		}
7762 	},
7763 	[ALC662_FIXUP_SKU_IGNORE] = {
7764 		.type = HDA_FIXUP_FUNC,
7765 		.v.func = alc_fixup_sku_ignore,
7766 	},
7767 	[ALC662_FIXUP_HP_RP5800] = {
7768 		.type = HDA_FIXUP_PINS,
7769 		.v.pins = (const struct hda_pintbl[]) {
7770 			{ 0x14, 0x0221201f }, /* HP out */
7771 			{ }
7772 		},
7773 		.chained = true,
7774 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7775 	},
7776 	[ALC662_FIXUP_ASUS_MODE1] = {
7777 		.type = HDA_FIXUP_PINS,
7778 		.v.pins = (const struct hda_pintbl[]) {
7779 			{ 0x14, 0x99130110 }, /* speaker */
7780 			{ 0x18, 0x01a19c20 }, /* mic */
7781 			{ 0x19, 0x99a3092f }, /* int-mic */
7782 			{ 0x21, 0x0121401f }, /* HP out */
7783 			{ }
7784 		},
7785 		.chained = true,
7786 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7787 	},
7788 	[ALC662_FIXUP_ASUS_MODE2] = {
7789 		.type = HDA_FIXUP_PINS,
7790 		.v.pins = (const struct hda_pintbl[]) {
7791 			{ 0x14, 0x99130110 }, /* speaker */
7792 			{ 0x18, 0x01a19820 }, /* mic */
7793 			{ 0x19, 0x99a3092f }, /* int-mic */
7794 			{ 0x1b, 0x0121401f }, /* HP out */
7795 			{ }
7796 		},
7797 		.chained = true,
7798 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7799 	},
7800 	[ALC662_FIXUP_ASUS_MODE3] = {
7801 		.type = HDA_FIXUP_PINS,
7802 		.v.pins = (const struct hda_pintbl[]) {
7803 			{ 0x14, 0x99130110 }, /* speaker */
7804 			{ 0x15, 0x0121441f }, /* HP */
7805 			{ 0x18, 0x01a19840 }, /* mic */
7806 			{ 0x19, 0x99a3094f }, /* int-mic */
7807 			{ 0x21, 0x01211420 }, /* HP2 */
7808 			{ }
7809 		},
7810 		.chained = true,
7811 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7812 	},
7813 	[ALC662_FIXUP_ASUS_MODE4] = {
7814 		.type = HDA_FIXUP_PINS,
7815 		.v.pins = (const struct hda_pintbl[]) {
7816 			{ 0x14, 0x99130110 }, /* speaker */
7817 			{ 0x16, 0x99130111 }, /* speaker */
7818 			{ 0x18, 0x01a19840 }, /* mic */
7819 			{ 0x19, 0x99a3094f }, /* int-mic */
7820 			{ 0x21, 0x0121441f }, /* HP */
7821 			{ }
7822 		},
7823 		.chained = true,
7824 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7825 	},
7826 	[ALC662_FIXUP_ASUS_MODE5] = {
7827 		.type = HDA_FIXUP_PINS,
7828 		.v.pins = (const struct hda_pintbl[]) {
7829 			{ 0x14, 0x99130110 }, /* speaker */
7830 			{ 0x15, 0x0121441f }, /* HP */
7831 			{ 0x16, 0x99130111 }, /* speaker */
7832 			{ 0x18, 0x01a19840 }, /* mic */
7833 			{ 0x19, 0x99a3094f }, /* int-mic */
7834 			{ }
7835 		},
7836 		.chained = true,
7837 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7838 	},
7839 	[ALC662_FIXUP_ASUS_MODE6] = {
7840 		.type = HDA_FIXUP_PINS,
7841 		.v.pins = (const struct hda_pintbl[]) {
7842 			{ 0x14, 0x99130110 }, /* speaker */
7843 			{ 0x15, 0x01211420 }, /* HP2 */
7844 			{ 0x18, 0x01a19840 }, /* mic */
7845 			{ 0x19, 0x99a3094f }, /* int-mic */
7846 			{ 0x1b, 0x0121441f }, /* HP */
7847 			{ }
7848 		},
7849 		.chained = true,
7850 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7851 	},
7852 	[ALC662_FIXUP_ASUS_MODE7] = {
7853 		.type = HDA_FIXUP_PINS,
7854 		.v.pins = (const struct hda_pintbl[]) {
7855 			{ 0x14, 0x99130110 }, /* speaker */
7856 			{ 0x17, 0x99130111 }, /* speaker */
7857 			{ 0x18, 0x01a19840 }, /* mic */
7858 			{ 0x19, 0x99a3094f }, /* int-mic */
7859 			{ 0x1b, 0x01214020 }, /* HP */
7860 			{ 0x21, 0x0121401f }, /* HP */
7861 			{ }
7862 		},
7863 		.chained = true,
7864 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7865 	},
7866 	[ALC662_FIXUP_ASUS_MODE8] = {
7867 		.type = HDA_FIXUP_PINS,
7868 		.v.pins = (const struct hda_pintbl[]) {
7869 			{ 0x14, 0x99130110 }, /* speaker */
7870 			{ 0x12, 0x99a30970 }, /* int-mic */
7871 			{ 0x15, 0x01214020 }, /* HP */
7872 			{ 0x17, 0x99130111 }, /* speaker */
7873 			{ 0x18, 0x01a19840 }, /* mic */
7874 			{ 0x21, 0x0121401f }, /* HP */
7875 			{ }
7876 		},
7877 		.chained = true,
7878 		.chain_id = ALC662_FIXUP_SKU_IGNORE
7879 	},
7880 	[ALC662_FIXUP_NO_JACK_DETECT] = {
7881 		.type = HDA_FIXUP_FUNC,
7882 		.v.func = alc_fixup_no_jack_detect,
7883 	},
7884 	[ALC662_FIXUP_ZOTAC_Z68] = {
7885 		.type = HDA_FIXUP_PINS,
7886 		.v.pins = (const struct hda_pintbl[]) {
7887 			{ 0x1b, 0x02214020 }, /* Front HP */
7888 			{ }
7889 		}
7890 	},
7891 	[ALC662_FIXUP_INV_DMIC] = {
7892 		.type = HDA_FIXUP_FUNC,
7893 		.v.func = alc_fixup_inv_dmic,
7894 	},
7895 	[ALC668_FIXUP_DELL_XPS13] = {
7896 		.type = HDA_FIXUP_FUNC,
7897 		.v.func = alc_fixup_dell_xps13,
7898 		.chained = true,
7899 		.chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
7900 	},
7901 	[ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
7902 		.type = HDA_FIXUP_FUNC,
7903 		.v.func = alc_fixup_disable_aamix,
7904 		.chained = true,
7905 		.chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
7906 	},
7907 	[ALC668_FIXUP_AUTO_MUTE] = {
7908 		.type = HDA_FIXUP_FUNC,
7909 		.v.func = alc_fixup_auto_mute_via_amp,
7910 		.chained = true,
7911 		.chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
7912 	},
7913 	[ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
7914 		.type = HDA_FIXUP_PINS,
7915 		.v.pins = (const struct hda_pintbl[]) {
7916 			{ 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
7917 			/* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
7918 			{ }
7919 		},
7920 		.chained = true,
7921 		.chain_id = ALC662_FIXUP_HEADSET_MODE
7922 	},
7923 	[ALC662_FIXUP_HEADSET_MODE] = {
7924 		.type = HDA_FIXUP_FUNC,
7925 		.v.func = alc_fixup_headset_mode_alc662,
7926 	},
7927 	[ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
7928 		.type = HDA_FIXUP_PINS,
7929 		.v.pins = (const struct hda_pintbl[]) {
7930 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
7931 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
7932 			{ }
7933 		},
7934 		.chained = true,
7935 		.chain_id = ALC668_FIXUP_HEADSET_MODE
7936 	},
7937 	[ALC668_FIXUP_HEADSET_MODE] = {
7938 		.type = HDA_FIXUP_FUNC,
7939 		.v.func = alc_fixup_headset_mode_alc668,
7940 	},
7941 	[ALC662_FIXUP_BASS_MODE4_CHMAP] = {
7942 		.type = HDA_FIXUP_FUNC,
7943 		.v.func = alc_fixup_bass_chmap,
7944 		.chained = true,
7945 		.chain_id = ALC662_FIXUP_ASUS_MODE4
7946 	},
7947 	[ALC662_FIXUP_BASS_16] = {
7948 		.type = HDA_FIXUP_PINS,
7949 		.v.pins = (const struct hda_pintbl[]) {
7950 			{0x16, 0x80106111}, /* bass speaker */
7951 			{}
7952 		},
7953 		.chained = true,
7954 		.chain_id = ALC662_FIXUP_BASS_CHMAP,
7955 	},
7956 	[ALC662_FIXUP_BASS_1A] = {
7957 		.type = HDA_FIXUP_PINS,
7958 		.v.pins = (const struct hda_pintbl[]) {
7959 			{0x1a, 0x80106111}, /* bass speaker */
7960 			{}
7961 		},
7962 		.chained = true,
7963 		.chain_id = ALC662_FIXUP_BASS_CHMAP,
7964 	},
7965 	[ALC662_FIXUP_BASS_CHMAP] = {
7966 		.type = HDA_FIXUP_FUNC,
7967 		.v.func = alc_fixup_bass_chmap,
7968 	},
7969 	[ALC662_FIXUP_ASUS_Nx50] = {
7970 		.type = HDA_FIXUP_FUNC,
7971 		.v.func = alc_fixup_auto_mute_via_amp,
7972 		.chained = true,
7973 		.chain_id = ALC662_FIXUP_BASS_1A
7974 	},
7975 	[ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
7976 		.type = HDA_FIXUP_FUNC,
7977 		.v.func = alc_fixup_headset_mode_alc668,
7978 		.chain_id = ALC662_FIXUP_BASS_CHMAP
7979 	},
7980 	[ALC668_FIXUP_ASUS_Nx51] = {
7981 		.type = HDA_FIXUP_PINS,
7982 		.v.pins = (const struct hda_pintbl[]) {
7983 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
7984 			{ 0x1a, 0x90170151 }, /* bass speaker */
7985 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
7986 			{}
7987 		},
7988 		.chained = true,
7989 		.chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
7990 	},
7991 	[ALC891_FIXUP_HEADSET_MODE] = {
7992 		.type = HDA_FIXUP_FUNC,
7993 		.v.func = alc_fixup_headset_mode,
7994 	},
7995 	[ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
7996 		.type = HDA_FIXUP_PINS,
7997 		.v.pins = (const struct hda_pintbl[]) {
7998 			{ 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
7999 			{ 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8000 			{ }
8001 		},
8002 		.chained = true,
8003 		.chain_id = ALC891_FIXUP_HEADSET_MODE
8004 	},
8005 	[ALC662_FIXUP_ACER_VERITON] = {
8006 		.type = HDA_FIXUP_PINS,
8007 		.v.pins = (const struct hda_pintbl[]) {
8008 			{ 0x15, 0x50170120 }, /* no internal speaker */
8009 			{ }
8010 		}
8011 	},
8012 	[ALC892_FIXUP_ASROCK_MOBO] = {
8013 		.type = HDA_FIXUP_PINS,
8014 		.v.pins = (const struct hda_pintbl[]) {
8015 			{ 0x15, 0x40f000f0 }, /* disabled */
8016 			{ 0x16, 0x40f000f0 }, /* disabled */
8017 			{ }
8018 		}
8019 	},
8020 	[ALC662_FIXUP_USI_FUNC] = {
8021 		.type = HDA_FIXUP_FUNC,
8022 		.v.func = alc662_fixup_usi_headset_mic,
8023 	},
8024 	[ALC662_FIXUP_USI_HEADSET_MODE] = {
8025 		.type = HDA_FIXUP_PINS,
8026 		.v.pins = (const struct hda_pintbl[]) {
8027 			{ 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
8028 			{ 0x18, 0x01a1903d },
8029 			{ }
8030 		},
8031 		.chained = true,
8032 		.chain_id = ALC662_FIXUP_USI_FUNC
8033 	},
8034 	[ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
8035 		.type = HDA_FIXUP_FUNC,
8036 		.v.func = alc233_alc662_fixup_lenovo_dual_codecs,
8037 	},
8038 };
8039 
8040 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
8041 	SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
8042 	SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
8043 	SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
8044 	SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
8045 	SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
8046 	SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
8047 	SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
8048 	SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
8049 	SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8050 	SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8051 	SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
8052 	SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
8053 	SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
8054 	SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8055 	SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8056 	SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8057 	SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8058 	SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8059 	SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
8060 	SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
8061 	SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
8062 	SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
8063 	SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
8064 	SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
8065 	SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
8066 	SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
8067 	SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
8068 	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
8069 	SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8070 	SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
8071 	SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
8072 	SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
8073 	SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
8074 	SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
8075 	SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
8076 	SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
8077 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
8078 	SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
8079 	SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
8080 	SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
8081 	SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
8082 
8083 #if 0
8084 	/* Below is a quirk table taken from the old code.
8085 	 * Basically the device should work as is without the fixup table.
8086 	 * If BIOS doesn't give a proper info, enable the corresponding
8087 	 * fixup entry.
8088 	 */
8089 	SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
8090 	SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
8091 	SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
8092 	SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
8093 	SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8094 	SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8095 	SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8096 	SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
8097 	SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
8098 	SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8099 	SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
8100 	SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
8101 	SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
8102 	SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
8103 	SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
8104 	SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8105 	SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
8106 	SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
8107 	SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8108 	SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8109 	SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8110 	SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8111 	SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
8112 	SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
8113 	SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
8114 	SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8115 	SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
8116 	SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8117 	SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8118 	SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
8119 	SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8120 	SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8121 	SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
8122 	SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
8123 	SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
8124 	SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
8125 	SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
8126 	SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
8127 	SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
8128 	SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8129 	SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
8130 	SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
8131 	SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8132 	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
8133 	SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
8134 	SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
8135 	SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
8136 	SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
8137 	SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8138 	SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
8139 #endif
8140 	{}
8141 };
8142 
8143 static const struct hda_model_fixup alc662_fixup_models[] = {
8144 	{.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
8145 	{.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
8146 	{.id = ALC272_FIXUP_MARIO, .name = "mario"},
8147 	{.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
8148 	{.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
8149 	{.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
8150 	{.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
8151 	{.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
8152 	{.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
8153 	{.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
8154 	{.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
8155 	{.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
8156 	{.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
8157 	{.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
8158 	{.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
8159 	{.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
8160 	{.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
8161 	{.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
8162 	{.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
8163 	{.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
8164 	{.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
8165 	{.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
8166 	{.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
8167 	{.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
8168 	{.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
8169 	{.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
8170 	{.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
8171 	{.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
8172 	{.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
8173 	{.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
8174 	{}
8175 };
8176 
8177 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
8178 	SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
8179 		{0x17, 0x02211010},
8180 		{0x18, 0x01a19030},
8181 		{0x1a, 0x01813040},
8182 		{0x21, 0x01014020}),
8183 	SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
8184 		{0x14, 0x01014010},
8185 		{0x18, 0x01a19020},
8186 		{0x1a, 0x0181302f},
8187 		{0x1b, 0x0221401f}),
8188 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8189 		{0x12, 0x99a30130},
8190 		{0x14, 0x90170110},
8191 		{0x15, 0x0321101f},
8192 		{0x16, 0x03011020}),
8193 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8194 		{0x12, 0x99a30140},
8195 		{0x14, 0x90170110},
8196 		{0x15, 0x0321101f},
8197 		{0x16, 0x03011020}),
8198 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8199 		{0x12, 0x99a30150},
8200 		{0x14, 0x90170110},
8201 		{0x15, 0x0321101f},
8202 		{0x16, 0x03011020}),
8203 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8204 		{0x14, 0x90170110},
8205 		{0x15, 0x0321101f},
8206 		{0x16, 0x03011020}),
8207 	SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
8208 		{0x12, 0x90a60130},
8209 		{0x14, 0x90170110},
8210 		{0x15, 0x0321101f}),
8211 	{}
8212 };
8213 
8214 /*
8215  */
8216 static int patch_alc662(struct hda_codec *codec)
8217 {
8218 	struct alc_spec *spec;
8219 	int err;
8220 
8221 	err = alc_alloc_spec(codec, 0x0b);
8222 	if (err < 0)
8223 		return err;
8224 
8225 	spec = codec->spec;
8226 
8227 	spec->shutup = alc_eapd_shutup;
8228 
8229 	/* handle multiple HPs as is */
8230 	spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
8231 
8232 	alc_fix_pll_init(codec, 0x20, 0x04, 15);
8233 
8234 	switch (codec->core.vendor_id) {
8235 	case 0x10ec0668:
8236 		spec->init_hook = alc668_restore_default_value;
8237 		break;
8238 	}
8239 
8240 	snd_hda_pick_fixup(codec, alc662_fixup_models,
8241 		       alc662_fixup_tbl, alc662_fixups);
8242 	snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
8243 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8244 
8245 	alc_auto_parse_customize_define(codec);
8246 
8247 	if (has_cdefine_beep(codec))
8248 		spec->gen.beep_nid = 0x01;
8249 
8250 	if ((alc_get_coef0(codec) & (1 << 14)) &&
8251 	    codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
8252 	    spec->cdefine.platform_type == 1) {
8253 		err = alc_codec_rename(codec, "ALC272X");
8254 		if (err < 0)
8255 			goto error;
8256 	}
8257 
8258 	/* automatic parse from the BIOS config */
8259 	err = alc662_parse_auto_config(codec);
8260 	if (err < 0)
8261 		goto error;
8262 
8263 	if (!spec->gen.no_analog && spec->gen.beep_nid) {
8264 		switch (codec->core.vendor_id) {
8265 		case 0x10ec0662:
8266 			err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
8267 			break;
8268 		case 0x10ec0272:
8269 		case 0x10ec0663:
8270 		case 0x10ec0665:
8271 		case 0x10ec0668:
8272 			err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
8273 			break;
8274 		case 0x10ec0273:
8275 			err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
8276 			break;
8277 		}
8278 		if (err < 0)
8279 			goto error;
8280 	}
8281 
8282 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
8283 
8284 	return 0;
8285 
8286  error:
8287 	alc_free(codec);
8288 	return err;
8289 }
8290 
8291 /*
8292  * ALC680 support
8293  */
8294 
8295 static int alc680_parse_auto_config(struct hda_codec *codec)
8296 {
8297 	return alc_parse_auto_config(codec, NULL, NULL);
8298 }
8299 
8300 /*
8301  */
8302 static int patch_alc680(struct hda_codec *codec)
8303 {
8304 	int err;
8305 
8306 	/* ALC680 has no aa-loopback mixer */
8307 	err = alc_alloc_spec(codec, 0);
8308 	if (err < 0)
8309 		return err;
8310 
8311 	/* automatic parse from the BIOS config */
8312 	err = alc680_parse_auto_config(codec);
8313 	if (err < 0) {
8314 		alc_free(codec);
8315 		return err;
8316 	}
8317 
8318 	return 0;
8319 }
8320 
8321 /*
8322  * patch entries
8323  */
8324 static const struct hda_device_id snd_hda_id_realtek[] = {
8325 	HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
8326 	HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
8327 	HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
8328 	HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
8329 	HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
8330 	HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
8331 	HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
8332 	HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
8333 	HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
8334 	HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
8335 	HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
8336 	HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
8337 	HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
8338 	HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
8339 	HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
8340 	HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
8341 	HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
8342 	HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
8343 	HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
8344 	HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
8345 	HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
8346 	HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
8347 	HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
8348 	HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
8349 	HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
8350 	HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
8351 	HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
8352 	HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
8353 	HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
8354 	HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
8355 	HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
8356 	HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
8357 	HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
8358 	HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
8359 	HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
8360 	HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
8361 	HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
8362 	HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
8363 	HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
8364 	HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
8365 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
8366 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
8367 	HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
8368 	HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
8369 	HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
8370 	HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
8371 	HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
8372 	HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
8373 	HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
8374 	HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
8375 	HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
8376 	HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
8377 	HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
8378 	HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
8379 	HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
8380 	HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
8381 	HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
8382 	HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
8383 	HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
8384 	HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
8385 	HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
8386 	HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
8387 	HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
8388 	HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
8389 	HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
8390 	HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
8391 	HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
8392 	HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
8393 	HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
8394 	{} /* terminator */
8395 };
8396 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
8397 
8398 MODULE_LICENSE("GPL");
8399 MODULE_DESCRIPTION("Realtek HD-audio codec");
8400 
8401 static struct hda_codec_driver realtek_driver = {
8402 	.id = snd_hda_id_realtek,
8403 };
8404 
8405 module_hda_codec_driver(realtek_driver);
8406