GNU Linux-libre 5.4.257-gnu1
[releases.git] / sound / pci / hda / patch_realtek.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Universal Interface for Intel High Definition Audio Codec
4  *
5  * HD audio interface patch for Realtek ALC codecs
6  *
7  * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
8  *                    PeiSen Hou <pshou@realtek.com.tw>
9  *                    Takashi Iwai <tiwai@suse.de>
10  *                    Jonathan Woithe <jwoithe@just42.net>
11  */
12
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/slab.h>
16 #include <linux/pci.h>
17 #include <linux/dmi.h>
18 #include <linux/module.h>
19 #include <linux/input.h>
20 #include <sound/core.h>
21 #include <sound/jack.h>
22 #include <sound/hda_codec.h>
23 #include "hda_local.h"
24 #include "hda_auto_parser.h"
25 #include "hda_jack.h"
26 #include "hda_generic.h"
27
28 /* keep halting ALC5505 DSP, for power saving */
29 #define HALT_REALTEK_ALC5505
30
31 /* extra amp-initialization sequence types */
32 enum {
33         ALC_INIT_UNDEFINED,
34         ALC_INIT_NONE,
35         ALC_INIT_DEFAULT,
36 };
37
38 enum {
39         ALC_HEADSET_MODE_UNKNOWN,
40         ALC_HEADSET_MODE_UNPLUGGED,
41         ALC_HEADSET_MODE_HEADSET,
42         ALC_HEADSET_MODE_MIC,
43         ALC_HEADSET_MODE_HEADPHONE,
44 };
45
46 enum {
47         ALC_HEADSET_TYPE_UNKNOWN,
48         ALC_HEADSET_TYPE_CTIA,
49         ALC_HEADSET_TYPE_OMTP,
50 };
51
52 enum {
53         ALC_KEY_MICMUTE_INDEX,
54 };
55
56 struct alc_customize_define {
57         unsigned int  sku_cfg;
58         unsigned char port_connectivity;
59         unsigned char check_sum;
60         unsigned char customization;
61         unsigned char external_amp;
62         unsigned int  enable_pcbeep:1;
63         unsigned int  platform_type:1;
64         unsigned int  swap:1;
65         unsigned int  override:1;
66         unsigned int  fixup:1; /* Means that this sku is set by driver, not read from hw */
67 };
68
69 struct alc_spec {
70         struct hda_gen_spec gen; /* must be at head */
71
72         /* codec parameterization */
73         struct alc_customize_define cdefine;
74         unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
75
76         /* GPIO bits */
77         unsigned int gpio_mask;
78         unsigned int gpio_dir;
79         unsigned int gpio_data;
80         bool gpio_write_delay;  /* add a delay before writing gpio_data */
81
82         /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
83         int mute_led_polarity;
84         int micmute_led_polarity;
85         hda_nid_t mute_led_nid;
86         hda_nid_t cap_mute_led_nid;
87
88         unsigned int gpio_mute_led_mask;
89         unsigned int gpio_mic_led_mask;
90         unsigned int mute_led_coef_idx;
91         unsigned int mute_led_coefbit_mask;
92         unsigned int mute_led_coefbit_on;
93         unsigned int mute_led_coefbit_off;
94         unsigned int mic_led_coef_idx;
95         unsigned int mic_led_coefbit_mask;
96         unsigned int mic_led_coefbit_on;
97         unsigned int mic_led_coefbit_off;
98
99         hda_nid_t headset_mic_pin;
100         hda_nid_t headphone_mic_pin;
101         int current_headset_mode;
102         int current_headset_type;
103
104         /* hooks */
105         void (*init_hook)(struct hda_codec *codec);
106 #ifdef CONFIG_PM
107         void (*power_hook)(struct hda_codec *codec);
108 #endif
109         void (*shutup)(struct hda_codec *codec);
110         void (*reboot_notify)(struct hda_codec *codec);
111
112         int init_amp;
113         int codec_variant;      /* flag for other variants */
114         unsigned int has_alc5505_dsp:1;
115         unsigned int no_depop_delay:1;
116         unsigned int done_hp_init:1;
117         unsigned int no_shutup_pins:1;
118         unsigned int ultra_low_power:1;
119         unsigned int has_hs_key: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 0x10ec0230:
379         case 0x10ec0233:
380         case 0x10ec0235:
381         case 0x10ec0236:
382         case 0x10ec0245:
383         case 0x10ec0255:
384         case 0x10ec0256:
385         case 0x19e58326:
386         case 0x10ec0257:
387         case 0x10ec0282:
388         case 0x10ec0283:
389         case 0x10ec0286:
390         case 0x10ec0288:
391         case 0x10ec0285:
392         case 0x10ec0298:
393         case 0x10ec0289:
394         case 0x10ec0300:
395                 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
396                 break;
397         case 0x10ec0275:
398                 alc_update_coef_idx(codec, 0xe, 0, 1<<0);
399                 break;
400         case 0x10ec0287:
401                 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
402                 alc_write_coef_idx(codec, 0x8, 0x4ab7);
403                 break;
404         case 0x10ec0293:
405                 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
406                 break;
407         case 0x10ec0234:
408         case 0x10ec0274:
409         case 0x10ec0294:
410         case 0x10ec0700:
411         case 0x10ec0701:
412         case 0x10ec0703:
413         case 0x10ec0711:
414                 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
415                 break;
416         case 0x10ec0662:
417                 if ((coef & 0x00f0) == 0x0030)
418                         alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
419                 break;
420         case 0x10ec0272:
421         case 0x10ec0273:
422         case 0x10ec0663:
423         case 0x10ec0665:
424         case 0x10ec0670:
425         case 0x10ec0671:
426         case 0x10ec0672:
427                 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
428                 break;
429         case 0x10ec0222:
430         case 0x10ec0623:
431                 alc_update_coef_idx(codec, 0x19, 1<<13, 0);
432                 break;
433         case 0x10ec0668:
434                 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
435                 break;
436         case 0x10ec0867:
437                 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
438                 break;
439         case 0x10ec0888:
440                 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
441                         alc_update_coef_idx(codec, 0x7, 1<<5, 0);
442                 break;
443         case 0x10ec0892:
444         case 0x10ec0897:
445                 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
446                 break;
447         case 0x10ec0899:
448         case 0x10ec0900:
449         case 0x10ec0b00:
450         case 0x10ec1168:
451         case 0x10ec1220:
452                 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
453                 break;
454         }
455 }
456
457 /* additional initialization for ALC888 variants */
458 static void alc888_coef_init(struct hda_codec *codec)
459 {
460         switch (alc_get_coef0(codec) & 0x00f0) {
461         /* alc888-VA */
462         case 0x00:
463         /* alc888-VB */
464         case 0x10:
465                 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
466                 break;
467         }
468 }
469
470 /* turn on/off EAPD control (only if available) */
471 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
472 {
473         if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
474                 return;
475         if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
476                 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
477                                     on ? 2 : 0);
478 }
479
480 /* turn on/off EAPD controls of the codec */
481 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
482 {
483         /* We currently only handle front, HP */
484         static const hda_nid_t pins[] = {
485                 0x0f, 0x10, 0x14, 0x15, 0x17, 0
486         };
487         const hda_nid_t *p;
488         for (p = pins; *p; p++)
489                 set_eapd(codec, *p, on);
490 }
491
492 static int find_ext_mic_pin(struct hda_codec *codec);
493
494 static void alc_headset_mic_no_shutup(struct hda_codec *codec)
495 {
496         const struct hda_pincfg *pin;
497         int mic_pin = find_ext_mic_pin(codec);
498         int i;
499
500         /* don't shut up pins when unloading the driver; otherwise it breaks
501          * the default pin setup at the next load of the driver
502          */
503         if (codec->bus->shutdown)
504                 return;
505
506         snd_array_for_each(&codec->init_pins, i, pin) {
507                 /* use read here for syncing after issuing each verb */
508                 if (pin->nid != mic_pin)
509                         snd_hda_codec_read(codec, pin->nid, 0,
510                                         AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
511         }
512
513         codec->pins_shutup = 1;
514 }
515
516 static void alc_shutup_pins(struct hda_codec *codec)
517 {
518         struct alc_spec *spec = codec->spec;
519
520         switch (codec->core.vendor_id) {
521         case 0x10ec0236:
522         case 0x10ec0256:
523         case 0x19e58326:
524         case 0x10ec0283:
525         case 0x10ec0286:
526         case 0x10ec0288:
527         case 0x10ec0298:
528                 alc_headset_mic_no_shutup(codec);
529                 break;
530         default:
531                 if (!spec->no_shutup_pins)
532                         snd_hda_shutup_pins(codec);
533                 break;
534         }
535 }
536
537 /* generic shutup callback;
538  * just turning off EAPD and a little pause for avoiding pop-noise
539  */
540 static void alc_eapd_shutup(struct hda_codec *codec)
541 {
542         struct alc_spec *spec = codec->spec;
543
544         alc_auto_setup_eapd(codec, false);
545         if (!spec->no_depop_delay)
546                 msleep(200);
547         alc_shutup_pins(codec);
548 }
549
550 /* generic EAPD initialization */
551 static void alc_auto_init_amp(struct hda_codec *codec, int type)
552 {
553         alc_auto_setup_eapd(codec, true);
554         alc_write_gpio(codec);
555         switch (type) {
556         case ALC_INIT_DEFAULT:
557                 switch (codec->core.vendor_id) {
558                 case 0x10ec0260:
559                         alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
560                         break;
561                 case 0x10ec0880:
562                 case 0x10ec0882:
563                 case 0x10ec0883:
564                 case 0x10ec0885:
565                         alc_update_coef_idx(codec, 7, 0, 0x2030);
566                         break;
567                 case 0x10ec0888:
568                         alc888_coef_init(codec);
569                         break;
570                 }
571                 break;
572         }
573 }
574
575 /* get a primary headphone pin if available */
576 static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
577 {
578         if (spec->gen.autocfg.hp_pins[0])
579                 return spec->gen.autocfg.hp_pins[0];
580         if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
581                 return spec->gen.autocfg.line_out_pins[0];
582         return 0;
583 }
584
585 /*
586  * Realtek SSID verification
587  */
588
589 /* Could be any non-zero and even value. When used as fixup, tells
590  * the driver to ignore any present sku defines.
591  */
592 #define ALC_FIXUP_SKU_IGNORE (2)
593
594 static void alc_fixup_sku_ignore(struct hda_codec *codec,
595                                  const struct hda_fixup *fix, int action)
596 {
597         struct alc_spec *spec = codec->spec;
598         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
599                 spec->cdefine.fixup = 1;
600                 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
601         }
602 }
603
604 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
605                                     const struct hda_fixup *fix, int action)
606 {
607         struct alc_spec *spec = codec->spec;
608
609         if (action == HDA_FIXUP_ACT_PROBE) {
610                 spec->no_depop_delay = 1;
611                 codec->depop_delay = 0;
612         }
613 }
614
615 static int alc_auto_parse_customize_define(struct hda_codec *codec)
616 {
617         unsigned int ass, tmp, i;
618         unsigned nid = 0;
619         struct alc_spec *spec = codec->spec;
620
621         spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
622
623         if (spec->cdefine.fixup) {
624                 ass = spec->cdefine.sku_cfg;
625                 if (ass == ALC_FIXUP_SKU_IGNORE)
626                         return -1;
627                 goto do_sku;
628         }
629
630         if (!codec->bus->pci)
631                 return -1;
632         ass = codec->core.subsystem_id & 0xffff;
633         if (ass != codec->bus->pci->subsystem_device && (ass & 1))
634                 goto do_sku;
635
636         nid = 0x1d;
637         if (codec->core.vendor_id == 0x10ec0260)
638                 nid = 0x17;
639         ass = snd_hda_codec_get_pincfg(codec, nid);
640
641         if (!(ass & 1)) {
642                 codec_info(codec, "%s: SKU not ready 0x%08x\n",
643                            codec->core.chip_name, ass);
644                 return -1;
645         }
646
647         /* check sum */
648         tmp = 0;
649         for (i = 1; i < 16; i++) {
650                 if ((ass >> i) & 1)
651                         tmp++;
652         }
653         if (((ass >> 16) & 0xf) != tmp)
654                 return -1;
655
656         spec->cdefine.port_connectivity = ass >> 30;
657         spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
658         spec->cdefine.check_sum = (ass >> 16) & 0xf;
659         spec->cdefine.customization = ass >> 8;
660 do_sku:
661         spec->cdefine.sku_cfg = ass;
662         spec->cdefine.external_amp = (ass & 0x38) >> 3;
663         spec->cdefine.platform_type = (ass & 0x4) >> 2;
664         spec->cdefine.swap = (ass & 0x2) >> 1;
665         spec->cdefine.override = ass & 0x1;
666
667         codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
668                    nid, spec->cdefine.sku_cfg);
669         codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
670                    spec->cdefine.port_connectivity);
671         codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
672         codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
673         codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
674         codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
675         codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
676         codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
677         codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
678
679         return 0;
680 }
681
682 /* return the position of NID in the list, or -1 if not found */
683 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
684 {
685         int i;
686         for (i = 0; i < nums; i++)
687                 if (list[i] == nid)
688                         return i;
689         return -1;
690 }
691 /* return true if the given NID is found in the list */
692 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
693 {
694         return find_idx_in_nid_list(nid, list, nums) >= 0;
695 }
696
697 /* check subsystem ID and set up device-specific initialization;
698  * return 1 if initialized, 0 if invalid SSID
699  */
700 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
701  *      31 ~ 16 :       Manufacture ID
702  *      15 ~ 8  :       SKU ID
703  *      7  ~ 0  :       Assembly ID
704  *      port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
705  */
706 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
707 {
708         unsigned int ass, tmp, i;
709         unsigned nid;
710         struct alc_spec *spec = codec->spec;
711
712         if (spec->cdefine.fixup) {
713                 ass = spec->cdefine.sku_cfg;
714                 if (ass == ALC_FIXUP_SKU_IGNORE)
715                         return 0;
716                 goto do_sku;
717         }
718
719         ass = codec->core.subsystem_id & 0xffff;
720         if (codec->bus->pci &&
721             ass != codec->bus->pci->subsystem_device && (ass & 1))
722                 goto do_sku;
723
724         /* invalid SSID, check the special NID pin defcfg instead */
725         /*
726          * 31~30        : port connectivity
727          * 29~21        : reserve
728          * 20           : PCBEEP input
729          * 19~16        : Check sum (15:1)
730          * 15~1         : Custom
731          * 0            : override
732         */
733         nid = 0x1d;
734         if (codec->core.vendor_id == 0x10ec0260)
735                 nid = 0x17;
736         ass = snd_hda_codec_get_pincfg(codec, nid);
737         codec_dbg(codec,
738                   "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
739                    ass, nid);
740         if (!(ass & 1))
741                 return 0;
742         if ((ass >> 30) != 1)   /* no physical connection */
743                 return 0;
744
745         /* check sum */
746         tmp = 0;
747         for (i = 1; i < 16; i++) {
748                 if ((ass >> i) & 1)
749                         tmp++;
750         }
751         if (((ass >> 16) & 0xf) != tmp)
752                 return 0;
753 do_sku:
754         codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
755                    ass & 0xffff, codec->core.vendor_id);
756         /*
757          * 0 : override
758          * 1 :  Swap Jack
759          * 2 : 0 --> Desktop, 1 --> Laptop
760          * 3~5 : External Amplifier control
761          * 7~6 : Reserved
762         */
763         tmp = (ass & 0x38) >> 3;        /* external Amp control */
764         if (spec->init_amp == ALC_INIT_UNDEFINED) {
765                 switch (tmp) {
766                 case 1:
767                         alc_setup_gpio(codec, 0x01);
768                         break;
769                 case 3:
770                         alc_setup_gpio(codec, 0x02);
771                         break;
772                 case 7:
773                         alc_setup_gpio(codec, 0x04);
774                         break;
775                 case 5:
776                 default:
777                         spec->init_amp = ALC_INIT_DEFAULT;
778                         break;
779                 }
780         }
781
782         /* is laptop or Desktop and enable the function "Mute internal speaker
783          * when the external headphone out jack is plugged"
784          */
785         if (!(ass & 0x8000))
786                 return 1;
787         /*
788          * 10~8 : Jack location
789          * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
790          * 14~13: Resvered
791          * 15   : 1 --> enable the function "Mute internal speaker
792          *              when the external headphone out jack is plugged"
793          */
794         if (!alc_get_hp_pin(spec)) {
795                 hda_nid_t nid;
796                 tmp = (ass >> 11) & 0x3;        /* HP to chassis */
797                 nid = ports[tmp];
798                 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
799                                       spec->gen.autocfg.line_outs))
800                         return 1;
801                 spec->gen.autocfg.hp_pins[0] = nid;
802         }
803         return 1;
804 }
805
806 /* Check the validity of ALC subsystem-id
807  * ports contains an array of 4 pin NIDs for port-A, E, D and I */
808 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
809 {
810         if (!alc_subsystem_id(codec, ports)) {
811                 struct alc_spec *spec = codec->spec;
812                 if (spec->init_amp == ALC_INIT_UNDEFINED) {
813                         codec_dbg(codec,
814                                   "realtek: Enable default setup for auto mode as fallback\n");
815                         spec->init_amp = ALC_INIT_DEFAULT;
816                 }
817         }
818 }
819
820 /*
821  */
822
823 static void alc_fixup_inv_dmic(struct hda_codec *codec,
824                                const struct hda_fixup *fix, int action)
825 {
826         struct alc_spec *spec = codec->spec;
827
828         spec->gen.inv_dmic_split = 1;
829 }
830
831
832 static int alc_build_controls(struct hda_codec *codec)
833 {
834         int err;
835
836         err = snd_hda_gen_build_controls(codec);
837         if (err < 0)
838                 return err;
839
840         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
841         return 0;
842 }
843
844
845 /*
846  * Common callbacks
847  */
848
849 static void alc_pre_init(struct hda_codec *codec)
850 {
851         alc_fill_eapd_coef(codec);
852 }
853
854 #define is_s3_resume(codec) \
855         ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
856 #define is_s4_resume(codec) \
857         ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
858
859 static int alc_init(struct hda_codec *codec)
860 {
861         struct alc_spec *spec = codec->spec;
862
863         /* hibernation resume needs the full chip initialization */
864         if (is_s4_resume(codec))
865                 alc_pre_init(codec);
866
867         if (spec->init_hook)
868                 spec->init_hook(codec);
869
870         spec->gen.skip_verbs = 1; /* applied in below */
871         snd_hda_gen_init(codec);
872         alc_fix_pll(codec);
873         alc_auto_init_amp(codec, spec->init_amp);
874         snd_hda_apply_verbs(codec); /* apply verbs here after own init */
875
876         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
877
878         return 0;
879 }
880
881 static inline void alc_shutup(struct hda_codec *codec)
882 {
883         struct alc_spec *spec = codec->spec;
884
885         if (!snd_hda_get_bool_hint(codec, "shutup"))
886                 return; /* disabled explicitly by hints */
887
888         if (spec && spec->shutup)
889                 spec->shutup(codec);
890         else
891                 alc_shutup_pins(codec);
892 }
893
894 static void alc_reboot_notify(struct hda_codec *codec)
895 {
896         struct alc_spec *spec = codec->spec;
897
898         if (spec && spec->reboot_notify)
899                 spec->reboot_notify(codec);
900         else
901                 alc_shutup(codec);
902 }
903
904 #define alc_free        snd_hda_gen_free
905
906 #ifdef CONFIG_PM
907 static void alc_power_eapd(struct hda_codec *codec)
908 {
909         alc_auto_setup_eapd(codec, false);
910 }
911
912 static int alc_suspend(struct hda_codec *codec)
913 {
914         struct alc_spec *spec = codec->spec;
915         alc_shutup(codec);
916         if (spec && spec->power_hook)
917                 spec->power_hook(codec);
918         return 0;
919 }
920 #endif
921
922 #ifdef CONFIG_PM
923 static int alc_resume(struct hda_codec *codec)
924 {
925         struct alc_spec *spec = codec->spec;
926
927         if (!spec->no_depop_delay)
928                 msleep(150); /* to avoid pop noise */
929         codec->patch_ops.init(codec);
930         snd_hda_regmap_sync(codec);
931         hda_call_check_power_status(codec, 0x01);
932         return 0;
933 }
934 #endif
935
936 /*
937  */
938 static const struct hda_codec_ops alc_patch_ops = {
939         .build_controls = alc_build_controls,
940         .build_pcms = snd_hda_gen_build_pcms,
941         .init = alc_init,
942         .free = alc_free,
943         .unsol_event = snd_hda_jack_unsol_event,
944 #ifdef CONFIG_PM
945         .resume = alc_resume,
946         .suspend = alc_suspend,
947         .check_power_status = snd_hda_gen_check_power_status,
948 #endif
949         .reboot_notify = alc_reboot_notify,
950 };
951
952
953 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
954
955 /*
956  * Rename codecs appropriately from COEF value or subvendor id
957  */
958 struct alc_codec_rename_table {
959         unsigned int vendor_id;
960         unsigned short coef_mask;
961         unsigned short coef_bits;
962         const char *name;
963 };
964
965 struct alc_codec_rename_pci_table {
966         unsigned int codec_vendor_id;
967         unsigned short pci_subvendor;
968         unsigned short pci_subdevice;
969         const char *name;
970 };
971
972 static const struct alc_codec_rename_table rename_tbl[] = {
973         { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
974         { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
975         { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
976         { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
977         { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
978         { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
979         { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
980         { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
981         { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
982         { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
983         { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
984         { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
985         { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
986         { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
987         { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
988         { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
989         { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
990         { } /* terminator */
991 };
992
993 static const struct alc_codec_rename_pci_table rename_pci_tbl[] = {
994         { 0x10ec0280, 0x1028, 0, "ALC3220" },
995         { 0x10ec0282, 0x1028, 0, "ALC3221" },
996         { 0x10ec0283, 0x1028, 0, "ALC3223" },
997         { 0x10ec0288, 0x1028, 0, "ALC3263" },
998         { 0x10ec0292, 0x1028, 0, "ALC3226" },
999         { 0x10ec0293, 0x1028, 0, "ALC3235" },
1000         { 0x10ec0255, 0x1028, 0, "ALC3234" },
1001         { 0x10ec0668, 0x1028, 0, "ALC3661" },
1002         { 0x10ec0275, 0x1028, 0, "ALC3260" },
1003         { 0x10ec0899, 0x1028, 0, "ALC3861" },
1004         { 0x10ec0298, 0x1028, 0, "ALC3266" },
1005         { 0x10ec0236, 0x1028, 0, "ALC3204" },
1006         { 0x10ec0256, 0x1028, 0, "ALC3246" },
1007         { 0x10ec0225, 0x1028, 0, "ALC3253" },
1008         { 0x10ec0295, 0x1028, 0, "ALC3254" },
1009         { 0x10ec0299, 0x1028, 0, "ALC3271" },
1010         { 0x10ec0670, 0x1025, 0, "ALC669X" },
1011         { 0x10ec0676, 0x1025, 0, "ALC679X" },
1012         { 0x10ec0282, 0x1043, 0, "ALC3229" },
1013         { 0x10ec0233, 0x1043, 0, "ALC3236" },
1014         { 0x10ec0280, 0x103c, 0, "ALC3228" },
1015         { 0x10ec0282, 0x103c, 0, "ALC3227" },
1016         { 0x10ec0286, 0x103c, 0, "ALC3242" },
1017         { 0x10ec0290, 0x103c, 0, "ALC3241" },
1018         { 0x10ec0668, 0x103c, 0, "ALC3662" },
1019         { 0x10ec0283, 0x17aa, 0, "ALC3239" },
1020         { 0x10ec0292, 0x17aa, 0, "ALC3232" },
1021         { } /* terminator */
1022 };
1023
1024 static int alc_codec_rename_from_preset(struct hda_codec *codec)
1025 {
1026         const struct alc_codec_rename_table *p;
1027         const struct alc_codec_rename_pci_table *q;
1028
1029         for (p = rename_tbl; p->vendor_id; p++) {
1030                 if (p->vendor_id != codec->core.vendor_id)
1031                         continue;
1032                 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1033                         return alc_codec_rename(codec, p->name);
1034         }
1035
1036         if (!codec->bus->pci)
1037                 return 0;
1038         for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
1039                 if (q->codec_vendor_id != codec->core.vendor_id)
1040                         continue;
1041                 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1042                         continue;
1043                 if (!q->pci_subdevice ||
1044                     q->pci_subdevice == codec->bus->pci->subsystem_device)
1045                         return alc_codec_rename(codec, q->name);
1046         }
1047
1048         return 0;
1049 }
1050
1051
1052 /*
1053  * Digital-beep handlers
1054  */
1055 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1056
1057 /* additional beep mixers; private_value will be overwritten */
1058 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1059         HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1060         HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1061 };
1062
1063 /* set up and create beep controls */
1064 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
1065                         int idx, int dir)
1066 {
1067         struct snd_kcontrol_new *knew;
1068         unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
1069         int i;
1070
1071         for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
1072                 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1073                                             &alc_beep_mixer[i]);
1074                 if (!knew)
1075                         return -ENOMEM;
1076                 knew->private_value = beep_amp;
1077         }
1078         return 0;
1079 }
1080
1081 static const struct snd_pci_quirk beep_white_list[] = {
1082         SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1083         SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1084         SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1085         SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1086         SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1087         SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1088         SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1089         SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1090         SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1091         /* blacklist -- no beep available */
1092         SND_PCI_QUIRK(0x17aa, 0x309e, "Lenovo ThinkCentre M73", 0),
1093         SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0),
1094         {}
1095 };
1096
1097 static inline int has_cdefine_beep(struct hda_codec *codec)
1098 {
1099         struct alc_spec *spec = codec->spec;
1100         const struct snd_pci_quirk *q;
1101         q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1102         if (q)
1103                 return q->value;
1104         return spec->cdefine.enable_pcbeep;
1105 }
1106 #else
1107 #define set_beep_amp(spec, nid, idx, dir)       0
1108 #define has_cdefine_beep(codec)         0
1109 #endif
1110
1111 /* parse the BIOS configuration and set up the alc_spec */
1112 /* return 1 if successful, 0 if the proper config is not found,
1113  * or a negative error code
1114  */
1115 static int alc_parse_auto_config(struct hda_codec *codec,
1116                                  const hda_nid_t *ignore_nids,
1117                                  const hda_nid_t *ssid_nids)
1118 {
1119         struct alc_spec *spec = codec->spec;
1120         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1121         int err;
1122
1123         err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1124                                        spec->parse_flags);
1125         if (err < 0)
1126                 return err;
1127
1128         if (ssid_nids)
1129                 alc_ssid_check(codec, ssid_nids);
1130
1131         err = snd_hda_gen_parse_auto_config(codec, cfg);
1132         if (err < 0)
1133                 return err;
1134
1135         return 1;
1136 }
1137
1138 /* common preparation job for alc_spec */
1139 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1140 {
1141         struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1142         int err;
1143
1144         if (!spec)
1145                 return -ENOMEM;
1146         codec->spec = spec;
1147         snd_hda_gen_spec_init(&spec->gen);
1148         spec->gen.mixer_nid = mixer_nid;
1149         spec->gen.own_eapd_ctl = 1;
1150         codec->single_adc_amp = 1;
1151         /* FIXME: do we need this for all Realtek codec models? */
1152         codec->spdif_status_reset = 1;
1153         codec->forced_resume = 1;
1154         codec->patch_ops = alc_patch_ops;
1155
1156         err = alc_codec_rename_from_preset(codec);
1157         if (err < 0) {
1158                 kfree(spec);
1159                 return err;
1160         }
1161         return 0;
1162 }
1163
1164 static int alc880_parse_auto_config(struct hda_codec *codec)
1165 {
1166         static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1167         static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1168         return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1169 }
1170
1171 /*
1172  * ALC880 fix-ups
1173  */
1174 enum {
1175         ALC880_FIXUP_GPIO1,
1176         ALC880_FIXUP_GPIO2,
1177         ALC880_FIXUP_MEDION_RIM,
1178         ALC880_FIXUP_LG,
1179         ALC880_FIXUP_LG_LW25,
1180         ALC880_FIXUP_W810,
1181         ALC880_FIXUP_EAPD_COEF,
1182         ALC880_FIXUP_TCL_S700,
1183         ALC880_FIXUP_VOL_KNOB,
1184         ALC880_FIXUP_FUJITSU,
1185         ALC880_FIXUP_F1734,
1186         ALC880_FIXUP_UNIWILL,
1187         ALC880_FIXUP_UNIWILL_DIG,
1188         ALC880_FIXUP_Z71V,
1189         ALC880_FIXUP_ASUS_W5A,
1190         ALC880_FIXUP_3ST_BASE,
1191         ALC880_FIXUP_3ST,
1192         ALC880_FIXUP_3ST_DIG,
1193         ALC880_FIXUP_5ST_BASE,
1194         ALC880_FIXUP_5ST,
1195         ALC880_FIXUP_5ST_DIG,
1196         ALC880_FIXUP_6ST_BASE,
1197         ALC880_FIXUP_6ST,
1198         ALC880_FIXUP_6ST_DIG,
1199         ALC880_FIXUP_6ST_AUTOMUTE,
1200 };
1201
1202 /* enable the volume-knob widget support on NID 0x21 */
1203 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1204                                   const struct hda_fixup *fix, int action)
1205 {
1206         if (action == HDA_FIXUP_ACT_PROBE)
1207                 snd_hda_jack_detect_enable_callback(codec, 0x21,
1208                                                     alc_update_knob_master);
1209 }
1210
1211 static const struct hda_fixup alc880_fixups[] = {
1212         [ALC880_FIXUP_GPIO1] = {
1213                 .type = HDA_FIXUP_FUNC,
1214                 .v.func = alc_fixup_gpio1,
1215         },
1216         [ALC880_FIXUP_GPIO2] = {
1217                 .type = HDA_FIXUP_FUNC,
1218                 .v.func = alc_fixup_gpio2,
1219         },
1220         [ALC880_FIXUP_MEDION_RIM] = {
1221                 .type = HDA_FIXUP_VERBS,
1222                 .v.verbs = (const struct hda_verb[]) {
1223                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1224                         { 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1225                         { }
1226                 },
1227                 .chained = true,
1228                 .chain_id = ALC880_FIXUP_GPIO2,
1229         },
1230         [ALC880_FIXUP_LG] = {
1231                 .type = HDA_FIXUP_PINS,
1232                 .v.pins = (const struct hda_pintbl[]) {
1233                         /* disable bogus unused pins */
1234                         { 0x16, 0x411111f0 },
1235                         { 0x18, 0x411111f0 },
1236                         { 0x1a, 0x411111f0 },
1237                         { }
1238                 }
1239         },
1240         [ALC880_FIXUP_LG_LW25] = {
1241                 .type = HDA_FIXUP_PINS,
1242                 .v.pins = (const struct hda_pintbl[]) {
1243                         { 0x1a, 0x0181344f }, /* line-in */
1244                         { 0x1b, 0x0321403f }, /* headphone */
1245                         { }
1246                 }
1247         },
1248         [ALC880_FIXUP_W810] = {
1249                 .type = HDA_FIXUP_PINS,
1250                 .v.pins = (const struct hda_pintbl[]) {
1251                         /* disable bogus unused pins */
1252                         { 0x17, 0x411111f0 },
1253                         { }
1254                 },
1255                 .chained = true,
1256                 .chain_id = ALC880_FIXUP_GPIO2,
1257         },
1258         [ALC880_FIXUP_EAPD_COEF] = {
1259                 .type = HDA_FIXUP_VERBS,
1260                 .v.verbs = (const struct hda_verb[]) {
1261                         /* change to EAPD mode */
1262                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1263                         { 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1264                         {}
1265                 },
1266         },
1267         [ALC880_FIXUP_TCL_S700] = {
1268                 .type = HDA_FIXUP_VERBS,
1269                 .v.verbs = (const struct hda_verb[]) {
1270                         /* change to EAPD mode */
1271                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1272                         { 0x20, AC_VERB_SET_PROC_COEF,  0x3070 },
1273                         {}
1274                 },
1275                 .chained = true,
1276                 .chain_id = ALC880_FIXUP_GPIO2,
1277         },
1278         [ALC880_FIXUP_VOL_KNOB] = {
1279                 .type = HDA_FIXUP_FUNC,
1280                 .v.func = alc880_fixup_vol_knob,
1281         },
1282         [ALC880_FIXUP_FUJITSU] = {
1283                 /* override all pins as BIOS on old Amilo is broken */
1284                 .type = HDA_FIXUP_PINS,
1285                 .v.pins = (const struct hda_pintbl[]) {
1286                         { 0x14, 0x0121401f }, /* HP */
1287                         { 0x15, 0x99030120 }, /* speaker */
1288                         { 0x16, 0x99030130 }, /* bass speaker */
1289                         { 0x17, 0x411111f0 }, /* N/A */
1290                         { 0x18, 0x411111f0 }, /* N/A */
1291                         { 0x19, 0x01a19950 }, /* mic-in */
1292                         { 0x1a, 0x411111f0 }, /* N/A */
1293                         { 0x1b, 0x411111f0 }, /* N/A */
1294                         { 0x1c, 0x411111f0 }, /* N/A */
1295                         { 0x1d, 0x411111f0 }, /* N/A */
1296                         { 0x1e, 0x01454140 }, /* SPDIF out */
1297                         { }
1298                 },
1299                 .chained = true,
1300                 .chain_id = ALC880_FIXUP_VOL_KNOB,
1301         },
1302         [ALC880_FIXUP_F1734] = {
1303                 /* almost compatible with FUJITSU, but no bass and SPDIF */
1304                 .type = HDA_FIXUP_PINS,
1305                 .v.pins = (const struct hda_pintbl[]) {
1306                         { 0x14, 0x0121401f }, /* HP */
1307                         { 0x15, 0x99030120 }, /* speaker */
1308                         { 0x16, 0x411111f0 }, /* N/A */
1309                         { 0x17, 0x411111f0 }, /* N/A */
1310                         { 0x18, 0x411111f0 }, /* N/A */
1311                         { 0x19, 0x01a19950 }, /* mic-in */
1312                         { 0x1a, 0x411111f0 }, /* N/A */
1313                         { 0x1b, 0x411111f0 }, /* N/A */
1314                         { 0x1c, 0x411111f0 }, /* N/A */
1315                         { 0x1d, 0x411111f0 }, /* N/A */
1316                         { 0x1e, 0x411111f0 }, /* N/A */
1317                         { }
1318                 },
1319                 .chained = true,
1320                 .chain_id = ALC880_FIXUP_VOL_KNOB,
1321         },
1322         [ALC880_FIXUP_UNIWILL] = {
1323                 /* need to fix HP and speaker pins to be parsed correctly */
1324                 .type = HDA_FIXUP_PINS,
1325                 .v.pins = (const struct hda_pintbl[]) {
1326                         { 0x14, 0x0121411f }, /* HP */
1327                         { 0x15, 0x99030120 }, /* speaker */
1328                         { 0x16, 0x99030130 }, /* bass speaker */
1329                         { }
1330                 },
1331         },
1332         [ALC880_FIXUP_UNIWILL_DIG] = {
1333                 .type = HDA_FIXUP_PINS,
1334                 .v.pins = (const struct hda_pintbl[]) {
1335                         /* disable bogus unused pins */
1336                         { 0x17, 0x411111f0 },
1337                         { 0x19, 0x411111f0 },
1338                         { 0x1b, 0x411111f0 },
1339                         { 0x1f, 0x411111f0 },
1340                         { }
1341                 }
1342         },
1343         [ALC880_FIXUP_Z71V] = {
1344                 .type = HDA_FIXUP_PINS,
1345                 .v.pins = (const struct hda_pintbl[]) {
1346                         /* set up the whole pins as BIOS is utterly broken */
1347                         { 0x14, 0x99030120 }, /* speaker */
1348                         { 0x15, 0x0121411f }, /* HP */
1349                         { 0x16, 0x411111f0 }, /* N/A */
1350                         { 0x17, 0x411111f0 }, /* N/A */
1351                         { 0x18, 0x01a19950 }, /* mic-in */
1352                         { 0x19, 0x411111f0 }, /* N/A */
1353                         { 0x1a, 0x01813031 }, /* line-in */
1354                         { 0x1b, 0x411111f0 }, /* N/A */
1355                         { 0x1c, 0x411111f0 }, /* N/A */
1356                         { 0x1d, 0x411111f0 }, /* N/A */
1357                         { 0x1e, 0x0144111e }, /* SPDIF */
1358                         { }
1359                 }
1360         },
1361         [ALC880_FIXUP_ASUS_W5A] = {
1362                 .type = HDA_FIXUP_PINS,
1363                 .v.pins = (const struct hda_pintbl[]) {
1364                         /* set up the whole pins as BIOS is utterly broken */
1365                         { 0x14, 0x0121411f }, /* HP */
1366                         { 0x15, 0x411111f0 }, /* N/A */
1367                         { 0x16, 0x411111f0 }, /* N/A */
1368                         { 0x17, 0x411111f0 }, /* N/A */
1369                         { 0x18, 0x90a60160 }, /* mic */
1370                         { 0x19, 0x411111f0 }, /* N/A */
1371                         { 0x1a, 0x411111f0 }, /* N/A */
1372                         { 0x1b, 0x411111f0 }, /* N/A */
1373                         { 0x1c, 0x411111f0 }, /* N/A */
1374                         { 0x1d, 0x411111f0 }, /* N/A */
1375                         { 0x1e, 0xb743111e }, /* SPDIF out */
1376                         { }
1377                 },
1378                 .chained = true,
1379                 .chain_id = ALC880_FIXUP_GPIO1,
1380         },
1381         [ALC880_FIXUP_3ST_BASE] = {
1382                 .type = HDA_FIXUP_PINS,
1383                 .v.pins = (const struct hda_pintbl[]) {
1384                         { 0x14, 0x01014010 }, /* line-out */
1385                         { 0x15, 0x411111f0 }, /* N/A */
1386                         { 0x16, 0x411111f0 }, /* N/A */
1387                         { 0x17, 0x411111f0 }, /* N/A */
1388                         { 0x18, 0x01a19c30 }, /* mic-in */
1389                         { 0x19, 0x0121411f }, /* HP */
1390                         { 0x1a, 0x01813031 }, /* line-in */
1391                         { 0x1b, 0x02a19c40 }, /* front-mic */
1392                         { 0x1c, 0x411111f0 }, /* N/A */
1393                         { 0x1d, 0x411111f0 }, /* N/A */
1394                         /* 0x1e is filled in below */
1395                         { 0x1f, 0x411111f0 }, /* N/A */
1396                         { }
1397                 }
1398         },
1399         [ALC880_FIXUP_3ST] = {
1400                 .type = HDA_FIXUP_PINS,
1401                 .v.pins = (const struct hda_pintbl[]) {
1402                         { 0x1e, 0x411111f0 }, /* N/A */
1403                         { }
1404                 },
1405                 .chained = true,
1406                 .chain_id = ALC880_FIXUP_3ST_BASE,
1407         },
1408         [ALC880_FIXUP_3ST_DIG] = {
1409                 .type = HDA_FIXUP_PINS,
1410                 .v.pins = (const struct hda_pintbl[]) {
1411                         { 0x1e, 0x0144111e }, /* SPDIF */
1412                         { }
1413                 },
1414                 .chained = true,
1415                 .chain_id = ALC880_FIXUP_3ST_BASE,
1416         },
1417         [ALC880_FIXUP_5ST_BASE] = {
1418                 .type = HDA_FIXUP_PINS,
1419                 .v.pins = (const struct hda_pintbl[]) {
1420                         { 0x14, 0x01014010 }, /* front */
1421                         { 0x15, 0x411111f0 }, /* N/A */
1422                         { 0x16, 0x01011411 }, /* CLFE */
1423                         { 0x17, 0x01016412 }, /* surr */
1424                         { 0x18, 0x01a19c30 }, /* mic-in */
1425                         { 0x19, 0x0121411f }, /* HP */
1426                         { 0x1a, 0x01813031 }, /* line-in */
1427                         { 0x1b, 0x02a19c40 }, /* front-mic */
1428                         { 0x1c, 0x411111f0 }, /* N/A */
1429                         { 0x1d, 0x411111f0 }, /* N/A */
1430                         /* 0x1e is filled in below */
1431                         { 0x1f, 0x411111f0 }, /* N/A */
1432                         { }
1433                 }
1434         },
1435         [ALC880_FIXUP_5ST] = {
1436                 .type = HDA_FIXUP_PINS,
1437                 .v.pins = (const struct hda_pintbl[]) {
1438                         { 0x1e, 0x411111f0 }, /* N/A */
1439                         { }
1440                 },
1441                 .chained = true,
1442                 .chain_id = ALC880_FIXUP_5ST_BASE,
1443         },
1444         [ALC880_FIXUP_5ST_DIG] = {
1445                 .type = HDA_FIXUP_PINS,
1446                 .v.pins = (const struct hda_pintbl[]) {
1447                         { 0x1e, 0x0144111e }, /* SPDIF */
1448                         { }
1449                 },
1450                 .chained = true,
1451                 .chain_id = ALC880_FIXUP_5ST_BASE,
1452         },
1453         [ALC880_FIXUP_6ST_BASE] = {
1454                 .type = HDA_FIXUP_PINS,
1455                 .v.pins = (const struct hda_pintbl[]) {
1456                         { 0x14, 0x01014010 }, /* front */
1457                         { 0x15, 0x01016412 }, /* surr */
1458                         { 0x16, 0x01011411 }, /* CLFE */
1459                         { 0x17, 0x01012414 }, /* side */
1460                         { 0x18, 0x01a19c30 }, /* mic-in */
1461                         { 0x19, 0x02a19c40 }, /* front-mic */
1462                         { 0x1a, 0x01813031 }, /* line-in */
1463                         { 0x1b, 0x0121411f }, /* HP */
1464                         { 0x1c, 0x411111f0 }, /* N/A */
1465                         { 0x1d, 0x411111f0 }, /* N/A */
1466                         /* 0x1e is filled in below */
1467                         { 0x1f, 0x411111f0 }, /* N/A */
1468                         { }
1469                 }
1470         },
1471         [ALC880_FIXUP_6ST] = {
1472                 .type = HDA_FIXUP_PINS,
1473                 .v.pins = (const struct hda_pintbl[]) {
1474                         { 0x1e, 0x411111f0 }, /* N/A */
1475                         { }
1476                 },
1477                 .chained = true,
1478                 .chain_id = ALC880_FIXUP_6ST_BASE,
1479         },
1480         [ALC880_FIXUP_6ST_DIG] = {
1481                 .type = HDA_FIXUP_PINS,
1482                 .v.pins = (const struct hda_pintbl[]) {
1483                         { 0x1e, 0x0144111e }, /* SPDIF */
1484                         { }
1485                 },
1486                 .chained = true,
1487                 .chain_id = ALC880_FIXUP_6ST_BASE,
1488         },
1489         [ALC880_FIXUP_6ST_AUTOMUTE] = {
1490                 .type = HDA_FIXUP_PINS,
1491                 .v.pins = (const struct hda_pintbl[]) {
1492                         { 0x1b, 0x0121401f }, /* HP with jack detect */
1493                         { }
1494                 },
1495                 .chained_before = true,
1496                 .chain_id = ALC880_FIXUP_6ST_BASE,
1497         },
1498 };
1499
1500 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1501         SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1502         SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1503         SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1504         SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1505         SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1506         SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1507         SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1508         SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1509         SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1510         SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1511         SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1512         SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1513         SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1514         SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1515         SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1516         SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1517         SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1518         SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1519         SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1520         SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1521         SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1522         SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1523         SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1524
1525         /* Below is the copied entries from alc880_quirks.c.
1526          * It's not quite sure whether BIOS sets the correct pin-config table
1527          * on these machines, thus they are kept to be compatible with
1528          * the old static quirks.  Once when it's confirmed to work without
1529          * these overrides, it'd be better to remove.
1530          */
1531         SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1532         SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1533         SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1534         SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1535         SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1536         SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1537         SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1538         SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1539         SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1540         SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1541         SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1542         SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1543         SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1544         SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1545         SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1546         SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1547         SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1548         SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1549         SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1550         SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1551         SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1552         SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1553         SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1554         SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1555         SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1556         SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1557         SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1558         SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1559         SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1560         SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1561         SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1562         SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1563         SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1564         /* default Intel */
1565         SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1566         SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1567         SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1568         {}
1569 };
1570
1571 static const struct hda_model_fixup alc880_fixup_models[] = {
1572         {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1573         {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1574         {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1575         {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1576         {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1577         {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1578         {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1579         {}
1580 };
1581
1582
1583 /*
1584  * OK, here we have finally the patch for ALC880
1585  */
1586 static int patch_alc880(struct hda_codec *codec)
1587 {
1588         struct alc_spec *spec;
1589         int err;
1590
1591         err = alc_alloc_spec(codec, 0x0b);
1592         if (err < 0)
1593                 return err;
1594
1595         spec = codec->spec;
1596         spec->gen.need_dac_fix = 1;
1597         spec->gen.beep_nid = 0x01;
1598
1599         codec->patch_ops.unsol_event = alc880_unsol_event;
1600
1601         alc_pre_init(codec);
1602
1603         snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1604                        alc880_fixups);
1605         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1606
1607         /* automatic parse from the BIOS config */
1608         err = alc880_parse_auto_config(codec);
1609         if (err < 0)
1610                 goto error;
1611
1612         if (!spec->gen.no_analog) {
1613                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1614                 if (err < 0)
1615                         goto error;
1616         }
1617
1618         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1619
1620         return 0;
1621
1622  error:
1623         alc_free(codec);
1624         return err;
1625 }
1626
1627
1628 /*
1629  * ALC260 support
1630  */
1631 static int alc260_parse_auto_config(struct hda_codec *codec)
1632 {
1633         static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1634         static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1635         return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1636 }
1637
1638 /*
1639  * Pin config fixes
1640  */
1641 enum {
1642         ALC260_FIXUP_HP_DC5750,
1643         ALC260_FIXUP_HP_PIN_0F,
1644         ALC260_FIXUP_COEF,
1645         ALC260_FIXUP_GPIO1,
1646         ALC260_FIXUP_GPIO1_TOGGLE,
1647         ALC260_FIXUP_REPLACER,
1648         ALC260_FIXUP_HP_B1900,
1649         ALC260_FIXUP_KN1,
1650         ALC260_FIXUP_FSC_S7020,
1651         ALC260_FIXUP_FSC_S7020_JWSE,
1652         ALC260_FIXUP_VAIO_PINS,
1653 };
1654
1655 static void alc260_gpio1_automute(struct hda_codec *codec)
1656 {
1657         struct alc_spec *spec = codec->spec;
1658
1659         alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1660 }
1661
1662 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1663                                       const struct hda_fixup *fix, int action)
1664 {
1665         struct alc_spec *spec = codec->spec;
1666         if (action == HDA_FIXUP_ACT_PROBE) {
1667                 /* although the machine has only one output pin, we need to
1668                  * toggle GPIO1 according to the jack state
1669                  */
1670                 spec->gen.automute_hook = alc260_gpio1_automute;
1671                 spec->gen.detect_hp = 1;
1672                 spec->gen.automute_speaker = 1;
1673                 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1674                 snd_hda_jack_detect_enable_callback(codec, 0x0f,
1675                                                     snd_hda_gen_hp_automute);
1676                 alc_setup_gpio(codec, 0x01);
1677         }
1678 }
1679
1680 static void alc260_fixup_kn1(struct hda_codec *codec,
1681                              const struct hda_fixup *fix, int action)
1682 {
1683         struct alc_spec *spec = codec->spec;
1684         static const struct hda_pintbl pincfgs[] = {
1685                 { 0x0f, 0x02214000 }, /* HP/speaker */
1686                 { 0x12, 0x90a60160 }, /* int mic */
1687                 { 0x13, 0x02a19000 }, /* ext mic */
1688                 { 0x18, 0x01446000 }, /* SPDIF out */
1689                 /* disable bogus I/O pins */
1690                 { 0x10, 0x411111f0 },
1691                 { 0x11, 0x411111f0 },
1692                 { 0x14, 0x411111f0 },
1693                 { 0x15, 0x411111f0 },
1694                 { 0x16, 0x411111f0 },
1695                 { 0x17, 0x411111f0 },
1696                 { 0x19, 0x411111f0 },
1697                 { }
1698         };
1699
1700         switch (action) {
1701         case HDA_FIXUP_ACT_PRE_PROBE:
1702                 snd_hda_apply_pincfgs(codec, pincfgs);
1703                 spec->init_amp = ALC_INIT_NONE;
1704                 break;
1705         }
1706 }
1707
1708 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1709                                    const struct hda_fixup *fix, int action)
1710 {
1711         struct alc_spec *spec = codec->spec;
1712         if (action == HDA_FIXUP_ACT_PRE_PROBE)
1713                 spec->init_amp = ALC_INIT_NONE;
1714 }
1715
1716 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1717                                    const struct hda_fixup *fix, int action)
1718 {
1719         struct alc_spec *spec = codec->spec;
1720         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1721                 spec->gen.add_jack_modes = 1;
1722                 spec->gen.hp_mic = 1;
1723         }
1724 }
1725
1726 static const struct hda_fixup alc260_fixups[] = {
1727         [ALC260_FIXUP_HP_DC5750] = {
1728                 .type = HDA_FIXUP_PINS,
1729                 .v.pins = (const struct hda_pintbl[]) {
1730                         { 0x11, 0x90130110 }, /* speaker */
1731                         { }
1732                 }
1733         },
1734         [ALC260_FIXUP_HP_PIN_0F] = {
1735                 .type = HDA_FIXUP_PINS,
1736                 .v.pins = (const struct hda_pintbl[]) {
1737                         { 0x0f, 0x01214000 }, /* HP */
1738                         { }
1739                 }
1740         },
1741         [ALC260_FIXUP_COEF] = {
1742                 .type = HDA_FIXUP_VERBS,
1743                 .v.verbs = (const struct hda_verb[]) {
1744                         { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1745                         { 0x1a, AC_VERB_SET_PROC_COEF,  0x3040 },
1746                         { }
1747                 },
1748         },
1749         [ALC260_FIXUP_GPIO1] = {
1750                 .type = HDA_FIXUP_FUNC,
1751                 .v.func = alc_fixup_gpio1,
1752         },
1753         [ALC260_FIXUP_GPIO1_TOGGLE] = {
1754                 .type = HDA_FIXUP_FUNC,
1755                 .v.func = alc260_fixup_gpio1_toggle,
1756                 .chained = true,
1757                 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1758         },
1759         [ALC260_FIXUP_REPLACER] = {
1760                 .type = HDA_FIXUP_VERBS,
1761                 .v.verbs = (const struct hda_verb[]) {
1762                         { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1763                         { 0x1a, AC_VERB_SET_PROC_COEF,  0x3050 },
1764                         { }
1765                 },
1766                 .chained = true,
1767                 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1768         },
1769         [ALC260_FIXUP_HP_B1900] = {
1770                 .type = HDA_FIXUP_FUNC,
1771                 .v.func = alc260_fixup_gpio1_toggle,
1772                 .chained = true,
1773                 .chain_id = ALC260_FIXUP_COEF,
1774         },
1775         [ALC260_FIXUP_KN1] = {
1776                 .type = HDA_FIXUP_FUNC,
1777                 .v.func = alc260_fixup_kn1,
1778         },
1779         [ALC260_FIXUP_FSC_S7020] = {
1780                 .type = HDA_FIXUP_FUNC,
1781                 .v.func = alc260_fixup_fsc_s7020,
1782         },
1783         [ALC260_FIXUP_FSC_S7020_JWSE] = {
1784                 .type = HDA_FIXUP_FUNC,
1785                 .v.func = alc260_fixup_fsc_s7020_jwse,
1786                 .chained = true,
1787                 .chain_id = ALC260_FIXUP_FSC_S7020,
1788         },
1789         [ALC260_FIXUP_VAIO_PINS] = {
1790                 .type = HDA_FIXUP_PINS,
1791                 .v.pins = (const struct hda_pintbl[]) {
1792                         /* Pin configs are missing completely on some VAIOs */
1793                         { 0x0f, 0x01211020 },
1794                         { 0x10, 0x0001003f },
1795                         { 0x11, 0x411111f0 },
1796                         { 0x12, 0x01a15930 },
1797                         { 0x13, 0x411111f0 },
1798                         { 0x14, 0x411111f0 },
1799                         { 0x15, 0x411111f0 },
1800                         { 0x16, 0x411111f0 },
1801                         { 0x17, 0x411111f0 },
1802                         { 0x18, 0x411111f0 },
1803                         { 0x19, 0x411111f0 },
1804                         { }
1805                 }
1806         },
1807 };
1808
1809 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1810         SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1811         SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1812         SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1813         SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1814         SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1815         SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1816         SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1817         SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1818         SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1819         SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1820         SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1821         SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1822         {}
1823 };
1824
1825 static const struct hda_model_fixup alc260_fixup_models[] = {
1826         {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1827         {.id = ALC260_FIXUP_COEF, .name = "coef"},
1828         {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1829         {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1830         {}
1831 };
1832
1833 /*
1834  */
1835 static int patch_alc260(struct hda_codec *codec)
1836 {
1837         struct alc_spec *spec;
1838         int err;
1839
1840         err = alc_alloc_spec(codec, 0x07);
1841         if (err < 0)
1842                 return err;
1843
1844         spec = codec->spec;
1845         /* as quite a few machines require HP amp for speaker outputs,
1846          * it's easier to enable it unconditionally; even if it's unneeded,
1847          * it's almost harmless.
1848          */
1849         spec->gen.prefer_hp_amp = 1;
1850         spec->gen.beep_nid = 0x01;
1851
1852         spec->shutup = alc_eapd_shutup;
1853
1854         alc_pre_init(codec);
1855
1856         snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1857                            alc260_fixups);
1858         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1859
1860         /* automatic parse from the BIOS config */
1861         err = alc260_parse_auto_config(codec);
1862         if (err < 0)
1863                 goto error;
1864
1865         if (!spec->gen.no_analog) {
1866                 err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1867                 if (err < 0)
1868                         goto error;
1869         }
1870
1871         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1872
1873         return 0;
1874
1875  error:
1876         alc_free(codec);
1877         return err;
1878 }
1879
1880
1881 /*
1882  * ALC882/883/885/888/889 support
1883  *
1884  * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1885  * configuration.  Each pin widget can choose any input DACs and a mixer.
1886  * Each ADC is connected from a mixer of all inputs.  This makes possible
1887  * 6-channel independent captures.
1888  *
1889  * In addition, an independent DAC for the multi-playback (not used in this
1890  * driver yet).
1891  */
1892
1893 /*
1894  * Pin config fixes
1895  */
1896 enum {
1897         ALC882_FIXUP_ABIT_AW9D_MAX,
1898         ALC882_FIXUP_LENOVO_Y530,
1899         ALC882_FIXUP_PB_M5210,
1900         ALC882_FIXUP_ACER_ASPIRE_7736,
1901         ALC882_FIXUP_ASUS_W90V,
1902         ALC889_FIXUP_CD,
1903         ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1904         ALC889_FIXUP_VAIO_TT,
1905         ALC888_FIXUP_EEE1601,
1906         ALC886_FIXUP_EAPD,
1907         ALC882_FIXUP_EAPD,
1908         ALC883_FIXUP_EAPD,
1909         ALC883_FIXUP_ACER_EAPD,
1910         ALC882_FIXUP_GPIO1,
1911         ALC882_FIXUP_GPIO2,
1912         ALC882_FIXUP_GPIO3,
1913         ALC889_FIXUP_COEF,
1914         ALC882_FIXUP_ASUS_W2JC,
1915         ALC882_FIXUP_ACER_ASPIRE_4930G,
1916         ALC882_FIXUP_ACER_ASPIRE_8930G,
1917         ALC882_FIXUP_ASPIRE_8930G_VERBS,
1918         ALC885_FIXUP_MACPRO_GPIO,
1919         ALC889_FIXUP_DAC_ROUTE,
1920         ALC889_FIXUP_MBP_VREF,
1921         ALC889_FIXUP_IMAC91_VREF,
1922         ALC889_FIXUP_MBA11_VREF,
1923         ALC889_FIXUP_MBA21_VREF,
1924         ALC889_FIXUP_MP11_VREF,
1925         ALC889_FIXUP_MP41_VREF,
1926         ALC882_FIXUP_INV_DMIC,
1927         ALC882_FIXUP_NO_PRIMARY_HP,
1928         ALC887_FIXUP_ASUS_BASS,
1929         ALC887_FIXUP_BASS_CHMAP,
1930         ALC1220_FIXUP_GB_DUAL_CODECS,
1931         ALC1220_FIXUP_GB_X570,
1932         ALC1220_FIXUP_CLEVO_P950,
1933         ALC1220_FIXUP_CLEVO_PB51ED,
1934         ALC1220_FIXUP_CLEVO_PB51ED_PINS,
1935         ALC887_FIXUP_ASUS_AUDIO,
1936         ALC887_FIXUP_ASUS_HMIC,
1937         ALCS1200A_FIXUP_MIC_VREF,
1938 };
1939
1940 static void alc889_fixup_coef(struct hda_codec *codec,
1941                               const struct hda_fixup *fix, int action)
1942 {
1943         if (action != HDA_FIXUP_ACT_INIT)
1944                 return;
1945         alc_update_coef_idx(codec, 7, 0, 0x2030);
1946 }
1947
1948 /* set up GPIO at initialization */
1949 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1950                                      const struct hda_fixup *fix, int action)
1951 {
1952         struct alc_spec *spec = codec->spec;
1953
1954         spec->gpio_write_delay = true;
1955         alc_fixup_gpio3(codec, fix, action);
1956 }
1957
1958 /* Fix the connection of some pins for ALC889:
1959  * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1960  * work correctly (bko#42740)
1961  */
1962 static void alc889_fixup_dac_route(struct hda_codec *codec,
1963                                    const struct hda_fixup *fix, int action)
1964 {
1965         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1966                 /* fake the connections during parsing the tree */
1967                 static const hda_nid_t conn1[] = { 0x0c, 0x0d };
1968                 static const hda_nid_t conn2[] = { 0x0e, 0x0f };
1969                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
1970                 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
1971                 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
1972                 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
1973         } else if (action == HDA_FIXUP_ACT_PROBE) {
1974                 /* restore the connections */
1975                 static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1976                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
1977                 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
1978                 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
1979                 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
1980         }
1981 }
1982
1983 /* Set VREF on HP pin */
1984 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1985                                   const struct hda_fixup *fix, int action)
1986 {
1987         static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
1988         struct alc_spec *spec = codec->spec;
1989         int i;
1990
1991         if (action != HDA_FIXUP_ACT_INIT)
1992                 return;
1993         for (i = 0; i < ARRAY_SIZE(nids); i++) {
1994                 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1995                 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1996                         continue;
1997                 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1998                 val |= AC_PINCTL_VREF_80;
1999                 snd_hda_set_pin_ctl(codec, nids[i], val);
2000                 spec->gen.keep_vref_in_automute = 1;
2001                 break;
2002         }
2003 }
2004
2005 static void alc889_fixup_mac_pins(struct hda_codec *codec,
2006                                   const hda_nid_t *nids, int num_nids)
2007 {
2008         struct alc_spec *spec = codec->spec;
2009         int i;
2010
2011         for (i = 0; i < num_nids; i++) {
2012                 unsigned int val;
2013                 val = snd_hda_codec_get_pin_target(codec, nids[i]);
2014                 val |= AC_PINCTL_VREF_50;
2015                 snd_hda_set_pin_ctl(codec, nids[i], val);
2016         }
2017         spec->gen.keep_vref_in_automute = 1;
2018 }
2019
2020 /* Set VREF on speaker pins on imac91 */
2021 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2022                                      const struct hda_fixup *fix, int action)
2023 {
2024         static const hda_nid_t nids[] = { 0x18, 0x1a };
2025
2026         if (action == HDA_FIXUP_ACT_INIT)
2027                 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2028 }
2029
2030 /* Set VREF on speaker pins on mba11 */
2031 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2032                                     const struct hda_fixup *fix, int action)
2033 {
2034         static const hda_nid_t nids[] = { 0x18 };
2035
2036         if (action == HDA_FIXUP_ACT_INIT)
2037                 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2038 }
2039
2040 /* Set VREF on speaker pins on mba21 */
2041 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2042                                     const struct hda_fixup *fix, int action)
2043 {
2044         static const hda_nid_t nids[] = { 0x18, 0x19 };
2045
2046         if (action == HDA_FIXUP_ACT_INIT)
2047                 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2048 }
2049
2050 /* Don't take HP output as primary
2051  * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
2052  * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2053  */
2054 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2055                                        const struct hda_fixup *fix, int action)
2056 {
2057         struct alc_spec *spec = codec->spec;
2058         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2059                 spec->gen.no_primary_hp = 1;
2060                 spec->gen.no_multi_io = 1;
2061         }
2062 }
2063
2064 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2065                                  const struct hda_fixup *fix, int action);
2066
2067 /* For dual-codec configuration, we need to disable some features to avoid
2068  * conflicts of kctls and PCM streams
2069  */
2070 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2071                                   const struct hda_fixup *fix, int action)
2072 {
2073         struct alc_spec *spec = codec->spec;
2074
2075         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2076                 return;
2077         /* disable vmaster */
2078         spec->gen.suppress_vmaster = 1;
2079         /* auto-mute and auto-mic switch don't work with multiple codecs */
2080         spec->gen.suppress_auto_mute = 1;
2081         spec->gen.suppress_auto_mic = 1;
2082         /* disable aamix as well */
2083         spec->gen.mixer_nid = 0;
2084         /* add location prefix to avoid conflicts */
2085         codec->force_pin_prefix = 1;
2086 }
2087
2088 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2089                        const char *newname)
2090 {
2091         struct snd_kcontrol *kctl;
2092
2093         kctl = snd_hda_find_mixer_ctl(codec, oldname);
2094         if (kctl)
2095                 strcpy(kctl->id.name, newname);
2096 }
2097
2098 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2099                                          const struct hda_fixup *fix,
2100                                          int action)
2101 {
2102         alc_fixup_dual_codecs(codec, fix, action);
2103         switch (action) {
2104         case HDA_FIXUP_ACT_PRE_PROBE:
2105                 /* override card longname to provide a unique UCM profile */
2106                 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2107                 break;
2108         case HDA_FIXUP_ACT_BUILD:
2109                 /* rename Capture controls depending on the codec */
2110                 rename_ctl(codec, "Capture Volume",
2111                            codec->addr == 0 ?
2112                            "Rear-Panel Capture Volume" :
2113                            "Front-Panel Capture Volume");
2114                 rename_ctl(codec, "Capture Switch",
2115                            codec->addr == 0 ?
2116                            "Rear-Panel Capture Switch" :
2117                            "Front-Panel Capture Switch");
2118                 break;
2119         }
2120 }
2121
2122 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
2123                                      const struct hda_fixup *fix,
2124                                      int action)
2125 {
2126         static const hda_nid_t conn1[] = { 0x0c };
2127         static const struct coef_fw gb_x570_coefs[] = {
2128                 WRITE_COEF(0x07, 0x03c0),
2129                 WRITE_COEF(0x1a, 0x01c1),
2130                 WRITE_COEF(0x1b, 0x0202),
2131                 WRITE_COEF(0x43, 0x3005),
2132                 {}
2133         };
2134
2135         switch (action) {
2136         case HDA_FIXUP_ACT_PRE_PROBE:
2137                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2138                 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2139                 break;
2140         case HDA_FIXUP_ACT_INIT:
2141                 alc_process_coef_fw(codec, gb_x570_coefs);
2142                 break;
2143         }
2144 }
2145
2146 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2147                                      const struct hda_fixup *fix,
2148                                      int action)
2149 {
2150         static const hda_nid_t conn1[] = { 0x0c };
2151
2152         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2153                 return;
2154
2155         alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2156         /* We therefore want to make sure 0x14 (front headphone) and
2157          * 0x1b (speakers) use the stereo DAC 0x02
2158          */
2159         snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2160         snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2161 }
2162
2163 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2164                                 const struct hda_fixup *fix, int action);
2165
2166 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2167                                      const struct hda_fixup *fix,
2168                                      int action)
2169 {
2170         alc1220_fixup_clevo_p950(codec, fix, action);
2171         alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2172 }
2173
2174 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2175                                          struct hda_jack_callback *jack)
2176 {
2177         struct alc_spec *spec = codec->spec;
2178         unsigned int vref;
2179
2180         snd_hda_gen_hp_automute(codec, jack);
2181
2182         if (spec->gen.hp_jack_present)
2183                 vref = AC_PINCTL_VREF_80;
2184         else
2185                 vref = AC_PINCTL_VREF_HIZ;
2186         snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2187 }
2188
2189 static void alc887_fixup_asus_jack(struct hda_codec *codec,
2190                                      const struct hda_fixup *fix, int action)
2191 {
2192         struct alc_spec *spec = codec->spec;
2193         if (action != HDA_FIXUP_ACT_PROBE)
2194                 return;
2195         snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2196         spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
2197 }
2198
2199 static const struct hda_fixup alc882_fixups[] = {
2200         [ALC882_FIXUP_ABIT_AW9D_MAX] = {
2201                 .type = HDA_FIXUP_PINS,
2202                 .v.pins = (const struct hda_pintbl[]) {
2203                         { 0x15, 0x01080104 }, /* side */
2204                         { 0x16, 0x01011012 }, /* rear */
2205                         { 0x17, 0x01016011 }, /* clfe */
2206                         { }
2207                 }
2208         },
2209         [ALC882_FIXUP_LENOVO_Y530] = {
2210                 .type = HDA_FIXUP_PINS,
2211                 .v.pins = (const struct hda_pintbl[]) {
2212                         { 0x15, 0x99130112 }, /* rear int speakers */
2213                         { 0x16, 0x99130111 }, /* subwoofer */
2214                         { }
2215                 }
2216         },
2217         [ALC882_FIXUP_PB_M5210] = {
2218                 .type = HDA_FIXUP_PINCTLS,
2219                 .v.pins = (const struct hda_pintbl[]) {
2220                         { 0x19, PIN_VREF50 },
2221                         {}
2222                 }
2223         },
2224         [ALC882_FIXUP_ACER_ASPIRE_7736] = {
2225                 .type = HDA_FIXUP_FUNC,
2226                 .v.func = alc_fixup_sku_ignore,
2227         },
2228         [ALC882_FIXUP_ASUS_W90V] = {
2229                 .type = HDA_FIXUP_PINS,
2230                 .v.pins = (const struct hda_pintbl[]) {
2231                         { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2232                         { }
2233                 }
2234         },
2235         [ALC889_FIXUP_CD] = {
2236                 .type = HDA_FIXUP_PINS,
2237                 .v.pins = (const struct hda_pintbl[]) {
2238                         { 0x1c, 0x993301f0 }, /* CD */
2239                         { }
2240                 }
2241         },
2242         [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2243                 .type = HDA_FIXUP_PINS,
2244                 .v.pins = (const struct hda_pintbl[]) {
2245                         { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2246                         { }
2247                 },
2248                 .chained = true,
2249                 .chain_id = ALC889_FIXUP_CD,
2250         },
2251         [ALC889_FIXUP_VAIO_TT] = {
2252                 .type = HDA_FIXUP_PINS,
2253                 .v.pins = (const struct hda_pintbl[]) {
2254                         { 0x17, 0x90170111 }, /* hidden surround speaker */
2255                         { }
2256                 }
2257         },
2258         [ALC888_FIXUP_EEE1601] = {
2259                 .type = HDA_FIXUP_VERBS,
2260                 .v.verbs = (const struct hda_verb[]) {
2261                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2262                         { 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
2263                         { }
2264                 }
2265         },
2266         [ALC886_FIXUP_EAPD] = {
2267                 .type = HDA_FIXUP_VERBS,
2268                 .v.verbs = (const struct hda_verb[]) {
2269                         /* change to EAPD mode */
2270                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2271                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0068 },
2272                         { }
2273                 }
2274         },
2275         [ALC882_FIXUP_EAPD] = {
2276                 .type = HDA_FIXUP_VERBS,
2277                 .v.verbs = (const struct hda_verb[]) {
2278                         /* change to EAPD mode */
2279                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2280                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2281                         { }
2282                 }
2283         },
2284         [ALC883_FIXUP_EAPD] = {
2285                 .type = HDA_FIXUP_VERBS,
2286                 .v.verbs = (const struct hda_verb[]) {
2287                         /* change to EAPD mode */
2288                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2289                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2290                         { }
2291                 }
2292         },
2293         [ALC883_FIXUP_ACER_EAPD] = {
2294                 .type = HDA_FIXUP_VERBS,
2295                 .v.verbs = (const struct hda_verb[]) {
2296                         /* eanable EAPD on Acer laptops */
2297                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2298                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2299                         { }
2300                 }
2301         },
2302         [ALC882_FIXUP_GPIO1] = {
2303                 .type = HDA_FIXUP_FUNC,
2304                 .v.func = alc_fixup_gpio1,
2305         },
2306         [ALC882_FIXUP_GPIO2] = {
2307                 .type = HDA_FIXUP_FUNC,
2308                 .v.func = alc_fixup_gpio2,
2309         },
2310         [ALC882_FIXUP_GPIO3] = {
2311                 .type = HDA_FIXUP_FUNC,
2312                 .v.func = alc_fixup_gpio3,
2313         },
2314         [ALC882_FIXUP_ASUS_W2JC] = {
2315                 .type = HDA_FIXUP_FUNC,
2316                 .v.func = alc_fixup_gpio1,
2317                 .chained = true,
2318                 .chain_id = ALC882_FIXUP_EAPD,
2319         },
2320         [ALC889_FIXUP_COEF] = {
2321                 .type = HDA_FIXUP_FUNC,
2322                 .v.func = alc889_fixup_coef,
2323         },
2324         [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2325                 .type = HDA_FIXUP_PINS,
2326                 .v.pins = (const struct hda_pintbl[]) {
2327                         { 0x16, 0x99130111 }, /* CLFE speaker */
2328                         { 0x17, 0x99130112 }, /* surround speaker */
2329                         { }
2330                 },
2331                 .chained = true,
2332                 .chain_id = ALC882_FIXUP_GPIO1,
2333         },
2334         [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2335                 .type = HDA_FIXUP_PINS,
2336                 .v.pins = (const struct hda_pintbl[]) {
2337                         { 0x16, 0x99130111 }, /* CLFE speaker */
2338                         { 0x1b, 0x99130112 }, /* surround speaker */
2339                         { }
2340                 },
2341                 .chained = true,
2342                 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2343         },
2344         [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2345                 /* additional init verbs for Acer Aspire 8930G */
2346                 .type = HDA_FIXUP_VERBS,
2347                 .v.verbs = (const struct hda_verb[]) {
2348                         /* Enable all DACs */
2349                         /* DAC DISABLE/MUTE 1? */
2350                         /*  setting bits 1-5 disables DAC nids 0x02-0x06
2351                          *  apparently. Init=0x38 */
2352                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2353                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2354                         /* DAC DISABLE/MUTE 2? */
2355                         /*  some bit here disables the other DACs.
2356                          *  Init=0x4900 */
2357                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2358                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2359                         /* DMIC fix
2360                          * This laptop has a stereo digital microphone.
2361                          * The mics are only 1cm apart which makes the stereo
2362                          * useless. However, either the mic or the ALC889
2363                          * makes the signal become a difference/sum signal
2364                          * instead of standard stereo, which is annoying.
2365                          * So instead we flip this bit which makes the
2366                          * codec replicate the sum signal to both channels,
2367                          * turning it into a normal mono mic.
2368                          */
2369                         /* DMIC_CONTROL? Init value = 0x0001 */
2370                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2371                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2372                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2373                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2374                         { }
2375                 },
2376                 .chained = true,
2377                 .chain_id = ALC882_FIXUP_GPIO1,
2378         },
2379         [ALC885_FIXUP_MACPRO_GPIO] = {
2380                 .type = HDA_FIXUP_FUNC,
2381                 .v.func = alc885_fixup_macpro_gpio,
2382         },
2383         [ALC889_FIXUP_DAC_ROUTE] = {
2384                 .type = HDA_FIXUP_FUNC,
2385                 .v.func = alc889_fixup_dac_route,
2386         },
2387         [ALC889_FIXUP_MBP_VREF] = {
2388                 .type = HDA_FIXUP_FUNC,
2389                 .v.func = alc889_fixup_mbp_vref,
2390                 .chained = true,
2391                 .chain_id = ALC882_FIXUP_GPIO1,
2392         },
2393         [ALC889_FIXUP_IMAC91_VREF] = {
2394                 .type = HDA_FIXUP_FUNC,
2395                 .v.func = alc889_fixup_imac91_vref,
2396                 .chained = true,
2397                 .chain_id = ALC882_FIXUP_GPIO1,
2398         },
2399         [ALC889_FIXUP_MBA11_VREF] = {
2400                 .type = HDA_FIXUP_FUNC,
2401                 .v.func = alc889_fixup_mba11_vref,
2402                 .chained = true,
2403                 .chain_id = ALC889_FIXUP_MBP_VREF,
2404         },
2405         [ALC889_FIXUP_MBA21_VREF] = {
2406                 .type = HDA_FIXUP_FUNC,
2407                 .v.func = alc889_fixup_mba21_vref,
2408                 .chained = true,
2409                 .chain_id = ALC889_FIXUP_MBP_VREF,
2410         },
2411         [ALC889_FIXUP_MP11_VREF] = {
2412                 .type = HDA_FIXUP_FUNC,
2413                 .v.func = alc889_fixup_mba11_vref,
2414                 .chained = true,
2415                 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2416         },
2417         [ALC889_FIXUP_MP41_VREF] = {
2418                 .type = HDA_FIXUP_FUNC,
2419                 .v.func = alc889_fixup_mbp_vref,
2420                 .chained = true,
2421                 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2422         },
2423         [ALC882_FIXUP_INV_DMIC] = {
2424                 .type = HDA_FIXUP_FUNC,
2425                 .v.func = alc_fixup_inv_dmic,
2426         },
2427         [ALC882_FIXUP_NO_PRIMARY_HP] = {
2428                 .type = HDA_FIXUP_FUNC,
2429                 .v.func = alc882_fixup_no_primary_hp,
2430         },
2431         [ALC887_FIXUP_ASUS_BASS] = {
2432                 .type = HDA_FIXUP_PINS,
2433                 .v.pins = (const struct hda_pintbl[]) {
2434                         {0x16, 0x99130130}, /* bass speaker */
2435                         {}
2436                 },
2437                 .chained = true,
2438                 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2439         },
2440         [ALC887_FIXUP_BASS_CHMAP] = {
2441                 .type = HDA_FIXUP_FUNC,
2442                 .v.func = alc_fixup_bass_chmap,
2443         },
2444         [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2445                 .type = HDA_FIXUP_FUNC,
2446                 .v.func = alc1220_fixup_gb_dual_codecs,
2447         },
2448         [ALC1220_FIXUP_GB_X570] = {
2449                 .type = HDA_FIXUP_FUNC,
2450                 .v.func = alc1220_fixup_gb_x570,
2451         },
2452         [ALC1220_FIXUP_CLEVO_P950] = {
2453                 .type = HDA_FIXUP_FUNC,
2454                 .v.func = alc1220_fixup_clevo_p950,
2455         },
2456         [ALC1220_FIXUP_CLEVO_PB51ED] = {
2457                 .type = HDA_FIXUP_FUNC,
2458                 .v.func = alc1220_fixup_clevo_pb51ed,
2459         },
2460         [ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
2461                 .type = HDA_FIXUP_PINS,
2462                 .v.pins = (const struct hda_pintbl[]) {
2463                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2464                         {}
2465                 },
2466                 .chained = true,
2467                 .chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
2468         },
2469         [ALC887_FIXUP_ASUS_AUDIO] = {
2470                 .type = HDA_FIXUP_PINS,
2471                 .v.pins = (const struct hda_pintbl[]) {
2472                         { 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
2473                         { 0x19, 0x22219420 },
2474                         {}
2475                 },
2476         },
2477         [ALC887_FIXUP_ASUS_HMIC] = {
2478                 .type = HDA_FIXUP_FUNC,
2479                 .v.func = alc887_fixup_asus_jack,
2480                 .chained = true,
2481                 .chain_id = ALC887_FIXUP_ASUS_AUDIO,
2482         },
2483         [ALCS1200A_FIXUP_MIC_VREF] = {
2484                 .type = HDA_FIXUP_PINCTLS,
2485                 .v.pins = (const struct hda_pintbl[]) {
2486                         { 0x18, PIN_VREF50 }, /* rear mic */
2487                         { 0x19, PIN_VREF50 }, /* front mic */
2488                         {}
2489                 }
2490         },
2491 };
2492
2493 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2494         SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2495         SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2496         SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2497         SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2498         SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2499         SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2500         SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2501         SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2502                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2503         SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2504                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2505         SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2506                       ALC882_FIXUP_ACER_ASPIRE_8930G),
2507         SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2508                       ALC882_FIXUP_ACER_ASPIRE_8930G),
2509         SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2510                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2511         SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2512         SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2513                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2514         SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2515                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2516         SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2517                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2518         SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2519         SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2520         SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2521         SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2522         SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2523         SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2524         SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
2525         SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2526         SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2527         SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2528         SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF),
2529         SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2530         SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2531         SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2532         SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2533         SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2534
2535         /* All Apple entries are in codec SSIDs */
2536         SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2537         SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2538         SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2539         SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2540         SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2541         SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2542         SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2543         SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2544         SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2545         SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2546         SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2547         SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2548         SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2549         SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2550         SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2551         SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2552         SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2553         SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2554         SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2555         SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2556         SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2557         SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2558
2559         SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2560         SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
2561         SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2562         SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2563         SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570),
2564         SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570),
2565         SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570),
2566         SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
2567         SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
2568         SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
2569         SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
2570         SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
2571         SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
2572         SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2573         SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS),
2574         SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2575         SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2576         SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2577         SND_PCI_QUIRK(0x1558, 0x3702, "Clevo X370SN[VW]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2578         SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2579         SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2580         SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2581         SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2582         SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2583         SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2584         SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2585         SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2586         SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2587         SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2588         SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2589         SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2590         SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2591         SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2592         SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
2593         SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2594         SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
2595         SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
2596         SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2597         SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2598         SND_PCI_QUIRK(0x1558, 0x95e3, "Clevo P955[ER]T", ALC1220_FIXUP_CLEVO_P950),
2599         SND_PCI_QUIRK(0x1558, 0x95e4, "Clevo P955ER", ALC1220_FIXUP_CLEVO_P950),
2600         SND_PCI_QUIRK(0x1558, 0x95e5, "Clevo P955EE6", ALC1220_FIXUP_CLEVO_P950),
2601         SND_PCI_QUIRK(0x1558, 0x95e6, "Clevo P950R[CDF]", ALC1220_FIXUP_CLEVO_P950),
2602         SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2603         SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2604         SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
2605         SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2606         SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2607         SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2608         SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2609         {}
2610 };
2611
2612 static const struct hda_model_fixup alc882_fixup_models[] = {
2613         {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2614         {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2615         {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2616         {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2617         {.id = ALC889_FIXUP_CD, .name = "cd"},
2618         {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2619         {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2620         {.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2621         {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2622         {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2623         {.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2624         {.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2625         {.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2626         {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2627         {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2628         {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2629         {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2630         {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2631         {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2632         {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2633         {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2634         {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2635         {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2636         {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2637         {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2638         {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2639         {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2640         {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2641         {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2642         {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2643         {.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
2644         {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2645         {}
2646 };
2647
2648 static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = {
2649         SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950,
2650                 {0x14, 0x01014010},
2651                 {0x15, 0x01011012},
2652                 {0x16, 0x01016011},
2653                 {0x18, 0x01a19040},
2654                 {0x19, 0x02a19050},
2655                 {0x1a, 0x0181304f},
2656                 {0x1b, 0x0221401f},
2657                 {0x1e, 0x01456130}),
2658         SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
2659                 {0x14, 0x01015010},
2660                 {0x15, 0x01011012},
2661                 {0x16, 0x01011011},
2662                 {0x18, 0x01a11040},
2663                 {0x19, 0x02a19050},
2664                 {0x1a, 0x0181104f},
2665                 {0x1b, 0x0221401f},
2666                 {0x1e, 0x01451130}),
2667         {}
2668 };
2669
2670 /*
2671  * BIOS auto configuration
2672  */
2673 /* almost identical with ALC880 parser... */
2674 static int alc882_parse_auto_config(struct hda_codec *codec)
2675 {
2676         static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2677         static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2678         return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2679 }
2680
2681 /*
2682  */
2683 static int patch_alc882(struct hda_codec *codec)
2684 {
2685         struct alc_spec *spec;
2686         int err;
2687
2688         err = alc_alloc_spec(codec, 0x0b);
2689         if (err < 0)
2690                 return err;
2691
2692         spec = codec->spec;
2693
2694         switch (codec->core.vendor_id) {
2695         case 0x10ec0882:
2696         case 0x10ec0885:
2697         case 0x10ec0900:
2698         case 0x10ec0b00:
2699         case 0x10ec1220:
2700                 break;
2701         default:
2702                 /* ALC883 and variants */
2703                 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2704                 break;
2705         }
2706
2707         alc_pre_init(codec);
2708
2709         snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2710                        alc882_fixups);
2711         snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
2712         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2713
2714         alc_auto_parse_customize_define(codec);
2715
2716         if (has_cdefine_beep(codec))
2717                 spec->gen.beep_nid = 0x01;
2718
2719         /* automatic parse from the BIOS config */
2720         err = alc882_parse_auto_config(codec);
2721         if (err < 0)
2722                 goto error;
2723
2724         if (!spec->gen.no_analog && spec->gen.beep_nid) {
2725                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2726                 if (err < 0)
2727                         goto error;
2728         }
2729
2730         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2731
2732         return 0;
2733
2734  error:
2735         alc_free(codec);
2736         return err;
2737 }
2738
2739
2740 /*
2741  * ALC262 support
2742  */
2743 static int alc262_parse_auto_config(struct hda_codec *codec)
2744 {
2745         static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2746         static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2747         return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2748 }
2749
2750 /*
2751  * Pin config fixes
2752  */
2753 enum {
2754         ALC262_FIXUP_FSC_H270,
2755         ALC262_FIXUP_FSC_S7110,
2756         ALC262_FIXUP_HP_Z200,
2757         ALC262_FIXUP_TYAN,
2758         ALC262_FIXUP_LENOVO_3000,
2759         ALC262_FIXUP_BENQ,
2760         ALC262_FIXUP_BENQ_T31,
2761         ALC262_FIXUP_INV_DMIC,
2762         ALC262_FIXUP_INTEL_BAYLEYBAY,
2763 };
2764
2765 static const struct hda_fixup alc262_fixups[] = {
2766         [ALC262_FIXUP_FSC_H270] = {
2767                 .type = HDA_FIXUP_PINS,
2768                 .v.pins = (const struct hda_pintbl[]) {
2769                         { 0x14, 0x99130110 }, /* speaker */
2770                         { 0x15, 0x0221142f }, /* front HP */
2771                         { 0x1b, 0x0121141f }, /* rear HP */
2772                         { }
2773                 }
2774         },
2775         [ALC262_FIXUP_FSC_S7110] = {
2776                 .type = HDA_FIXUP_PINS,
2777                 .v.pins = (const struct hda_pintbl[]) {
2778                         { 0x15, 0x90170110 }, /* speaker */
2779                         { }
2780                 },
2781                 .chained = true,
2782                 .chain_id = ALC262_FIXUP_BENQ,
2783         },
2784         [ALC262_FIXUP_HP_Z200] = {
2785                 .type = HDA_FIXUP_PINS,
2786                 .v.pins = (const struct hda_pintbl[]) {
2787                         { 0x16, 0x99130120 }, /* internal speaker */
2788                         { }
2789                 }
2790         },
2791         [ALC262_FIXUP_TYAN] = {
2792                 .type = HDA_FIXUP_PINS,
2793                 .v.pins = (const struct hda_pintbl[]) {
2794                         { 0x14, 0x1993e1f0 }, /* int AUX */
2795                         { }
2796                 }
2797         },
2798         [ALC262_FIXUP_LENOVO_3000] = {
2799                 .type = HDA_FIXUP_PINCTLS,
2800                 .v.pins = (const struct hda_pintbl[]) {
2801                         { 0x19, PIN_VREF50 },
2802                         {}
2803                 },
2804                 .chained = true,
2805                 .chain_id = ALC262_FIXUP_BENQ,
2806         },
2807         [ALC262_FIXUP_BENQ] = {
2808                 .type = HDA_FIXUP_VERBS,
2809                 .v.verbs = (const struct hda_verb[]) {
2810                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2811                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2812                         {}
2813                 }
2814         },
2815         [ALC262_FIXUP_BENQ_T31] = {
2816                 .type = HDA_FIXUP_VERBS,
2817                 .v.verbs = (const struct hda_verb[]) {
2818                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2819                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2820                         {}
2821                 }
2822         },
2823         [ALC262_FIXUP_INV_DMIC] = {
2824                 .type = HDA_FIXUP_FUNC,
2825                 .v.func = alc_fixup_inv_dmic,
2826         },
2827         [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2828                 .type = HDA_FIXUP_FUNC,
2829                 .v.func = alc_fixup_no_depop_delay,
2830         },
2831 };
2832
2833 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2834         SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2835         SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2836         SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2837         SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2838         SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2839         SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2840         SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2841         SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2842         SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2843         SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2844         {}
2845 };
2846
2847 static const struct hda_model_fixup alc262_fixup_models[] = {
2848         {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2849         {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2850         {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2851         {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2852         {.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2853         {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2854         {.id = ALC262_FIXUP_BENQ, .name = "benq"},
2855         {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2856         {.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2857         {}
2858 };
2859
2860 /*
2861  */
2862 static int patch_alc262(struct hda_codec *codec)
2863 {
2864         struct alc_spec *spec;
2865         int err;
2866
2867         err = alc_alloc_spec(codec, 0x0b);
2868         if (err < 0)
2869                 return err;
2870
2871         spec = codec->spec;
2872         spec->gen.shared_mic_vref_pin = 0x18;
2873
2874         spec->shutup = alc_eapd_shutup;
2875
2876 #if 0
2877         /* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is
2878          * under-run
2879          */
2880         alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2881 #endif
2882         alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2883
2884         alc_pre_init(codec);
2885
2886         snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2887                        alc262_fixups);
2888         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2889
2890         alc_auto_parse_customize_define(codec);
2891
2892         if (has_cdefine_beep(codec))
2893                 spec->gen.beep_nid = 0x01;
2894
2895         /* automatic parse from the BIOS config */
2896         err = alc262_parse_auto_config(codec);
2897         if (err < 0)
2898                 goto error;
2899
2900         if (!spec->gen.no_analog && spec->gen.beep_nid) {
2901                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2902                 if (err < 0)
2903                         goto error;
2904         }
2905
2906         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2907
2908         return 0;
2909
2910  error:
2911         alc_free(codec);
2912         return err;
2913 }
2914
2915 /*
2916  *  ALC268
2917  */
2918 /* bind Beep switches of both NID 0x0f and 0x10 */
2919 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2920                                   struct snd_ctl_elem_value *ucontrol)
2921 {
2922         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2923         unsigned long pval;
2924         int err;
2925
2926         mutex_lock(&codec->control_mutex);
2927         pval = kcontrol->private_value;
2928         kcontrol->private_value = (pval & ~0xff) | 0x0f;
2929         err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2930         if (err >= 0) {
2931                 kcontrol->private_value = (pval & ~0xff) | 0x10;
2932                 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2933         }
2934         kcontrol->private_value = pval;
2935         mutex_unlock(&codec->control_mutex);
2936         return err;
2937 }
2938
2939 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2940         HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2941         {
2942                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2943                 .name = "Beep Playback Switch",
2944                 .subdevice = HDA_SUBDEV_AMP_FLAG,
2945                 .info = snd_hda_mixer_amp_switch_info,
2946                 .get = snd_hda_mixer_amp_switch_get,
2947                 .put = alc268_beep_switch_put,
2948                 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2949         },
2950 };
2951
2952 /* set PCBEEP vol = 0, mute connections */
2953 static const struct hda_verb alc268_beep_init_verbs[] = {
2954         {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2955         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2956         {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2957         { }
2958 };
2959
2960 enum {
2961         ALC268_FIXUP_INV_DMIC,
2962         ALC268_FIXUP_HP_EAPD,
2963         ALC268_FIXUP_SPDIF,
2964 };
2965
2966 static const struct hda_fixup alc268_fixups[] = {
2967         [ALC268_FIXUP_INV_DMIC] = {
2968                 .type = HDA_FIXUP_FUNC,
2969                 .v.func = alc_fixup_inv_dmic,
2970         },
2971         [ALC268_FIXUP_HP_EAPD] = {
2972                 .type = HDA_FIXUP_VERBS,
2973                 .v.verbs = (const struct hda_verb[]) {
2974                         {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2975                         {}
2976                 }
2977         },
2978         [ALC268_FIXUP_SPDIF] = {
2979                 .type = HDA_FIXUP_PINS,
2980                 .v.pins = (const struct hda_pintbl[]) {
2981                         { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2982                         {}
2983                 }
2984         },
2985 };
2986
2987 static const struct hda_model_fixup alc268_fixup_models[] = {
2988         {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2989         {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2990         {.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2991         {}
2992 };
2993
2994 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2995         SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2996         SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2997         /* below is codec SSID since multiple Toshiba laptops have the
2998          * same PCI SSID 1179:ff00
2999          */
3000         SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
3001         {}
3002 };
3003
3004 /*
3005  * BIOS auto configuration
3006  */
3007 static int alc268_parse_auto_config(struct hda_codec *codec)
3008 {
3009         static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3010         return alc_parse_auto_config(codec, NULL, alc268_ssids);
3011 }
3012
3013 /*
3014  */
3015 static int patch_alc268(struct hda_codec *codec)
3016 {
3017         struct alc_spec *spec;
3018         int i, err;
3019
3020         /* ALC268 has no aa-loopback mixer */
3021         err = alc_alloc_spec(codec, 0);
3022         if (err < 0)
3023                 return err;
3024
3025         spec = codec->spec;
3026         if (has_cdefine_beep(codec))
3027                 spec->gen.beep_nid = 0x01;
3028
3029         spec->shutup = alc_eapd_shutup;
3030
3031         alc_pre_init(codec);
3032
3033         snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
3034         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3035
3036         /* automatic parse from the BIOS config */
3037         err = alc268_parse_auto_config(codec);
3038         if (err < 0)
3039                 goto error;
3040
3041         if (err > 0 && !spec->gen.no_analog &&
3042             spec->gen.autocfg.speaker_pins[0] != 0x1d) {
3043                 for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
3044                         if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
3045                                                   &alc268_beep_mixer[i])) {
3046                                 err = -ENOMEM;
3047                                 goto error;
3048                         }
3049                 }
3050                 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
3051                 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
3052                         /* override the amp caps for beep generator */
3053                         snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
3054                                           (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
3055                                           (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
3056                                           (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3057                                           (0 << AC_AMPCAP_MUTE_SHIFT));
3058         }
3059
3060         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3061
3062         return 0;
3063
3064  error:
3065         alc_free(codec);
3066         return err;
3067 }
3068
3069 /*
3070  * ALC269
3071  */
3072
3073 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
3074         .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3075 };
3076
3077 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
3078         .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3079 };
3080
3081 /* different alc269-variants */
3082 enum {
3083         ALC269_TYPE_ALC269VA,
3084         ALC269_TYPE_ALC269VB,
3085         ALC269_TYPE_ALC269VC,
3086         ALC269_TYPE_ALC269VD,
3087         ALC269_TYPE_ALC280,
3088         ALC269_TYPE_ALC282,
3089         ALC269_TYPE_ALC283,
3090         ALC269_TYPE_ALC284,
3091         ALC269_TYPE_ALC293,
3092         ALC269_TYPE_ALC286,
3093         ALC269_TYPE_ALC298,
3094         ALC269_TYPE_ALC255,
3095         ALC269_TYPE_ALC256,
3096         ALC269_TYPE_ALC257,
3097         ALC269_TYPE_ALC215,
3098         ALC269_TYPE_ALC225,
3099         ALC269_TYPE_ALC294,
3100         ALC269_TYPE_ALC300,
3101         ALC269_TYPE_ALC623,
3102         ALC269_TYPE_ALC700,
3103 };
3104
3105 /*
3106  * BIOS auto configuration
3107  */
3108 static int alc269_parse_auto_config(struct hda_codec *codec)
3109 {
3110         static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3111         static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
3112         static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3113         struct alc_spec *spec = codec->spec;
3114         const hda_nid_t *ssids;
3115
3116         switch (spec->codec_variant) {
3117         case ALC269_TYPE_ALC269VA:
3118         case ALC269_TYPE_ALC269VC:
3119         case ALC269_TYPE_ALC280:
3120         case ALC269_TYPE_ALC284:
3121         case ALC269_TYPE_ALC293:
3122                 ssids = alc269va_ssids;
3123                 break;
3124         case ALC269_TYPE_ALC269VB:
3125         case ALC269_TYPE_ALC269VD:
3126         case ALC269_TYPE_ALC282:
3127         case ALC269_TYPE_ALC283:
3128         case ALC269_TYPE_ALC286:
3129         case ALC269_TYPE_ALC298:
3130         case ALC269_TYPE_ALC255:
3131         case ALC269_TYPE_ALC256:
3132         case ALC269_TYPE_ALC257:
3133         case ALC269_TYPE_ALC215:
3134         case ALC269_TYPE_ALC225:
3135         case ALC269_TYPE_ALC294:
3136         case ALC269_TYPE_ALC300:
3137         case ALC269_TYPE_ALC623:
3138         case ALC269_TYPE_ALC700:
3139                 ssids = alc269_ssids;
3140                 break;
3141         default:
3142                 ssids = alc269_ssids;
3143                 break;
3144         }
3145
3146         return alc_parse_auto_config(codec, alc269_ignore, ssids);
3147 }
3148
3149 static const struct hda_jack_keymap alc_headset_btn_keymap[] = {
3150         { SND_JACK_BTN_0, KEY_PLAYPAUSE },
3151         { SND_JACK_BTN_1, KEY_VOICECOMMAND },
3152         { SND_JACK_BTN_2, KEY_VOLUMEUP },
3153         { SND_JACK_BTN_3, KEY_VOLUMEDOWN },
3154         {}
3155 };
3156
3157 static void alc_headset_btn_callback(struct hda_codec *codec,
3158                                      struct hda_jack_callback *jack)
3159 {
3160         int report = 0;
3161
3162         if (jack->unsol_res & (7 << 13))
3163                 report |= SND_JACK_BTN_0;
3164
3165         if (jack->unsol_res  & (1 << 16 | 3 << 8))
3166                 report |= SND_JACK_BTN_1;
3167
3168         /* Volume up key */
3169         if (jack->unsol_res & (7 << 23))
3170                 report |= SND_JACK_BTN_2;
3171
3172         /* Volume down key */
3173         if (jack->unsol_res & (7 << 10))
3174                 report |= SND_JACK_BTN_3;
3175
3176         jack->jack->button_state = report;
3177 }
3178
3179 static void alc_disable_headset_jack_key(struct hda_codec *codec)
3180 {
3181         struct alc_spec *spec = codec->spec;
3182
3183         if (!spec->has_hs_key)
3184                 return;
3185
3186         switch (codec->core.vendor_id) {
3187         case 0x10ec0215:
3188         case 0x10ec0225:
3189         case 0x10ec0285:
3190         case 0x10ec0287:
3191         case 0x10ec0295:
3192         case 0x10ec0289:
3193         case 0x10ec0299:
3194                 alc_write_coef_idx(codec, 0x48, 0x0);
3195                 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3196                 alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
3197                 break;
3198         case 0x10ec0230:
3199         case 0x10ec0236:
3200         case 0x10ec0256:
3201         case 0x19e58326:
3202                 alc_write_coef_idx(codec, 0x48, 0x0);
3203                 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3204                 break;
3205         }
3206 }
3207
3208 static void alc_enable_headset_jack_key(struct hda_codec *codec)
3209 {
3210         struct alc_spec *spec = codec->spec;
3211
3212         if (!spec->has_hs_key)
3213                 return;
3214
3215         switch (codec->core.vendor_id) {
3216         case 0x10ec0215:
3217         case 0x10ec0225:
3218         case 0x10ec0285:
3219         case 0x10ec0287:
3220         case 0x10ec0295:
3221         case 0x10ec0289:
3222         case 0x10ec0299:
3223                 alc_write_coef_idx(codec, 0x48, 0xd011);
3224                 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3225                 alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
3226                 break;
3227         case 0x10ec0230:
3228         case 0x10ec0236:
3229         case 0x10ec0256:
3230         case 0x19e58326:
3231                 alc_write_coef_idx(codec, 0x48, 0xd011);
3232                 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3233                 break;
3234         }
3235 }
3236
3237 static void alc_fixup_headset_jack(struct hda_codec *codec,
3238                                     const struct hda_fixup *fix, int action)
3239 {
3240         struct alc_spec *spec = codec->spec;
3241
3242         switch (action) {
3243         case HDA_FIXUP_ACT_PRE_PROBE:
3244                 spec->has_hs_key = 1;
3245                 snd_hda_jack_detect_enable_callback(codec, 0x55,
3246                                                     alc_headset_btn_callback);
3247                 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false,
3248                                       SND_JACK_HEADSET, alc_headset_btn_keymap);
3249                 break;
3250         case HDA_FIXUP_ACT_INIT:
3251                 alc_enable_headset_jack_key(codec);
3252                 break;
3253         }
3254 }
3255
3256 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3257 {
3258         alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3259 }
3260
3261 static void alc269_shutup(struct hda_codec *codec)
3262 {
3263         struct alc_spec *spec = codec->spec;
3264
3265         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3266                 alc269vb_toggle_power_output(codec, 0);
3267         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3268                         (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3269                 msleep(150);
3270         }
3271         alc_shutup_pins(codec);
3272 }
3273
3274 static const struct coef_fw alc282_coefs[] = {
3275         WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3276         UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3277         WRITE_COEF(0x07, 0x0200), /* DMIC control */
3278         UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3279         UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3280         WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3281         WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3282         WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
3283         UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3284         UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3285         WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
3286         UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
3287         WRITE_COEF(0x34, 0xa0c0), /* ANC */
3288         UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
3289         UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3290         UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3291         WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3292         WRITE_COEF(0x63, 0x2902), /* PLL */
3293         WRITE_COEF(0x68, 0xa080), /* capless control 2 */
3294         WRITE_COEF(0x69, 0x3400), /* capless control 3 */
3295         WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
3296         WRITE_COEF(0x6b, 0x0), /* capless control 5 */
3297         UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
3298         WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
3299         UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
3300         WRITE_COEF(0x71, 0x0014), /* class D test 6 */
3301         WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
3302         UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
3303         WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
3304         {}
3305 };
3306
3307 static void alc282_restore_default_value(struct hda_codec *codec)
3308 {
3309         alc_process_coef_fw(codec, alc282_coefs);
3310 }
3311
3312 static void alc282_init(struct hda_codec *codec)
3313 {
3314         struct alc_spec *spec = codec->spec;
3315         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3316         bool hp_pin_sense;
3317         int coef78;
3318
3319         alc282_restore_default_value(codec);
3320
3321         if (!hp_pin)
3322                 return;
3323         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3324         coef78 = alc_read_coef_idx(codec, 0x78);
3325
3326         /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3327         /* Headphone capless set to high power mode */
3328         alc_write_coef_idx(codec, 0x78, 0x9004);
3329
3330         if (hp_pin_sense)
3331                 msleep(2);
3332
3333         snd_hda_codec_write(codec, hp_pin, 0,
3334                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3335
3336         if (hp_pin_sense)
3337                 msleep(85);
3338
3339         snd_hda_codec_write(codec, hp_pin, 0,
3340                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3341
3342         if (hp_pin_sense)
3343                 msleep(100);
3344
3345         /* Headphone capless set to normal mode */
3346         alc_write_coef_idx(codec, 0x78, coef78);
3347 }
3348
3349 static void alc282_shutup(struct hda_codec *codec)
3350 {
3351         struct alc_spec *spec = codec->spec;
3352         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3353         bool hp_pin_sense;
3354         int coef78;
3355
3356         if (!hp_pin) {
3357                 alc269_shutup(codec);
3358                 return;
3359         }
3360
3361         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3362         coef78 = alc_read_coef_idx(codec, 0x78);
3363         alc_write_coef_idx(codec, 0x78, 0x9004);
3364
3365         if (hp_pin_sense)
3366                 msleep(2);
3367
3368         snd_hda_codec_write(codec, hp_pin, 0,
3369                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3370
3371         if (hp_pin_sense)
3372                 msleep(85);
3373
3374         if (!spec->no_shutup_pins)
3375                 snd_hda_codec_write(codec, hp_pin, 0,
3376                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3377
3378         if (hp_pin_sense)
3379                 msleep(100);
3380
3381         alc_auto_setup_eapd(codec, false);
3382         alc_shutup_pins(codec);
3383         alc_write_coef_idx(codec, 0x78, coef78);
3384 }
3385
3386 static const struct coef_fw alc283_coefs[] = {
3387         WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3388         UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3389         WRITE_COEF(0x07, 0x0200), /* DMIC control */
3390         UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3391         UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3392         WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3393         WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3394         WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3395         UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3396         UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3397         WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3398         UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3399         WRITE_COEF(0x22, 0xa0c0), /* ANC */
3400         UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3401         UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3402         UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3403         WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3404         WRITE_COEF(0x2e, 0x2902), /* PLL */
3405         WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3406         WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3407         WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3408         WRITE_COEF(0x36, 0x0), /* capless control 5 */
3409         UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3410         WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3411         UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3412         WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3413         WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3414         UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3415         WRITE_COEF(0x49, 0x0), /* test mode */
3416         UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3417         UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3418         WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3419         UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3420         {}
3421 };
3422
3423 static void alc283_restore_default_value(struct hda_codec *codec)
3424 {
3425         alc_process_coef_fw(codec, alc283_coefs);
3426 }
3427
3428 static void alc283_init(struct hda_codec *codec)
3429 {
3430         struct alc_spec *spec = codec->spec;
3431         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3432         bool hp_pin_sense;
3433
3434         alc283_restore_default_value(codec);
3435
3436         if (!hp_pin)
3437                 return;
3438
3439         msleep(30);
3440         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3441
3442         /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3443         /* Headphone capless set to high power mode */
3444         alc_write_coef_idx(codec, 0x43, 0x9004);
3445
3446         snd_hda_codec_write(codec, hp_pin, 0,
3447                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3448
3449         if (hp_pin_sense)
3450                 msleep(85);
3451
3452         snd_hda_codec_write(codec, hp_pin, 0,
3453                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3454
3455         if (hp_pin_sense)
3456                 msleep(85);
3457         /* Index 0x46 Combo jack auto switch control 2 */
3458         /* 3k pull low control for Headset jack. */
3459         alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3460         /* Headphone capless set to normal mode */
3461         alc_write_coef_idx(codec, 0x43, 0x9614);
3462 }
3463
3464 static void alc283_shutup(struct hda_codec *codec)
3465 {
3466         struct alc_spec *spec = codec->spec;
3467         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3468         bool hp_pin_sense;
3469
3470         if (!hp_pin) {
3471                 alc269_shutup(codec);
3472                 return;
3473         }
3474
3475         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3476
3477         alc_write_coef_idx(codec, 0x43, 0x9004);
3478
3479         /*depop hp during suspend*/
3480         alc_write_coef_idx(codec, 0x06, 0x2100);
3481
3482         snd_hda_codec_write(codec, hp_pin, 0,
3483                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3484
3485         if (hp_pin_sense)
3486                 msleep(100);
3487
3488         if (!spec->no_shutup_pins)
3489                 snd_hda_codec_write(codec, hp_pin, 0,
3490                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3491
3492         alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3493
3494         if (hp_pin_sense)
3495                 msleep(100);
3496         alc_auto_setup_eapd(codec, false);
3497         alc_shutup_pins(codec);
3498         alc_write_coef_idx(codec, 0x43, 0x9614);
3499 }
3500
3501 static void alc256_init(struct hda_codec *codec)
3502 {
3503         struct alc_spec *spec = codec->spec;
3504         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3505         bool hp_pin_sense;
3506
3507         if (spec->ultra_low_power) {
3508                 alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3509                 alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3510                 alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3511                 alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3512                 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3513                 msleep(30);
3514         }
3515
3516         if (!hp_pin)
3517                 hp_pin = 0x21;
3518
3519         msleep(30);
3520
3521         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3522
3523         if (hp_pin_sense)
3524                 msleep(2);
3525
3526         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3527
3528         snd_hda_codec_write(codec, hp_pin, 0,
3529                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3530
3531         if (hp_pin_sense || spec->ultra_low_power)
3532                 msleep(85);
3533
3534         snd_hda_codec_write(codec, hp_pin, 0,
3535                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3536
3537         if (hp_pin_sense || spec->ultra_low_power)
3538                 msleep(100);
3539
3540         alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3541         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3542         alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3543         alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3544         /*
3545          * Expose headphone mic (or possibly Line In on some machines) instead
3546          * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3547          * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3548          * this register.
3549          */
3550         alc_write_coef_idx(codec, 0x36, 0x5757);
3551 }
3552
3553 static void alc256_shutup(struct hda_codec *codec)
3554 {
3555         struct alc_spec *spec = codec->spec;
3556         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3557         bool hp_pin_sense;
3558
3559         if (!hp_pin)
3560                 hp_pin = 0x21;
3561
3562         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3563
3564         if (hp_pin_sense)
3565                 msleep(2);
3566
3567         snd_hda_codec_write(codec, hp_pin, 0,
3568                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3569
3570         if (hp_pin_sense || spec->ultra_low_power)
3571                 msleep(85);
3572
3573         /* 3k pull low control for Headset jack. */
3574         /* NOTE: call this before clearing the pin, otherwise codec stalls */
3575         /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
3576          * when booting with headset plugged. So skip setting it for the codec alc257
3577          */
3578         if (codec->core.vendor_id != 0x10ec0236 &&
3579             codec->core.vendor_id != 0x10ec0257)
3580                 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3581
3582         if (!spec->no_shutup_pins)
3583                 snd_hda_codec_write(codec, hp_pin, 0,
3584                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3585
3586         if (hp_pin_sense || spec->ultra_low_power)
3587                 msleep(100);
3588
3589         alc_auto_setup_eapd(codec, false);
3590         alc_shutup_pins(codec);
3591         if (spec->ultra_low_power) {
3592                 msleep(50);
3593                 alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3594                 alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3595                 alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3596                 alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3597                 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3598                 msleep(30);
3599         }
3600 }
3601
3602 static void alc225_init(struct hda_codec *codec)
3603 {
3604         struct alc_spec *spec = codec->spec;
3605         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3606         bool hp1_pin_sense, hp2_pin_sense;
3607
3608         if (spec->ultra_low_power) {
3609                 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3610                 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3611                 alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3612                 msleep(30);
3613         }
3614
3615         if (!hp_pin)
3616                 hp_pin = 0x21;
3617         msleep(30);
3618
3619         hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3620         hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3621
3622         if (hp1_pin_sense || hp2_pin_sense)
3623                 msleep(2);
3624
3625         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3626
3627         if (hp1_pin_sense || spec->ultra_low_power)
3628                 snd_hda_codec_write(codec, hp_pin, 0,
3629                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3630         if (hp2_pin_sense)
3631                 snd_hda_codec_write(codec, 0x16, 0,
3632                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3633
3634         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3635                 msleep(85);
3636
3637         if (hp1_pin_sense || spec->ultra_low_power)
3638                 snd_hda_codec_write(codec, hp_pin, 0,
3639                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3640         if (hp2_pin_sense)
3641                 snd_hda_codec_write(codec, 0x16, 0,
3642                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3643
3644         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3645                 msleep(100);
3646
3647         alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3648         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3649 }
3650
3651 static void alc225_shutup(struct hda_codec *codec)
3652 {
3653         struct alc_spec *spec = codec->spec;
3654         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3655         bool hp1_pin_sense, hp2_pin_sense;
3656
3657         if (!hp_pin)
3658                 hp_pin = 0x21;
3659
3660         alc_disable_headset_jack_key(codec);
3661         /* 3k pull low control for Headset jack. */
3662         alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3663
3664         hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3665         hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3666
3667         if (hp1_pin_sense || hp2_pin_sense)
3668                 msleep(2);
3669
3670         if (hp1_pin_sense || spec->ultra_low_power)
3671                 snd_hda_codec_write(codec, hp_pin, 0,
3672                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3673         if (hp2_pin_sense)
3674                 snd_hda_codec_write(codec, 0x16, 0,
3675                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3676
3677         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3678                 msleep(85);
3679
3680         if (hp1_pin_sense || spec->ultra_low_power)
3681                 snd_hda_codec_write(codec, hp_pin, 0,
3682                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3683         if (hp2_pin_sense)
3684                 snd_hda_codec_write(codec, 0x16, 0,
3685                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3686
3687         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3688                 msleep(100);
3689
3690         alc_auto_setup_eapd(codec, false);
3691         alc_shutup_pins(codec);
3692         if (spec->ultra_low_power) {
3693                 msleep(50);
3694                 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3695                 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3696                 alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3697                 alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3698                 msleep(30);
3699         }
3700
3701         alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3702         alc_enable_headset_jack_key(codec);
3703 }
3704
3705 static void alc_default_init(struct hda_codec *codec)
3706 {
3707         struct alc_spec *spec = codec->spec;
3708         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3709         bool hp_pin_sense;
3710
3711         if (!hp_pin)
3712                 return;
3713
3714         msleep(30);
3715
3716         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3717
3718         if (hp_pin_sense)
3719                 msleep(2);
3720
3721         snd_hda_codec_write(codec, hp_pin, 0,
3722                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3723
3724         if (hp_pin_sense)
3725                 msleep(85);
3726
3727         snd_hda_codec_write(codec, hp_pin, 0,
3728                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3729
3730         if (hp_pin_sense)
3731                 msleep(100);
3732 }
3733
3734 static void alc_default_shutup(struct hda_codec *codec)
3735 {
3736         struct alc_spec *spec = codec->spec;
3737         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3738         bool hp_pin_sense;
3739
3740         if (!hp_pin) {
3741                 alc269_shutup(codec);
3742                 return;
3743         }
3744
3745         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3746
3747         if (hp_pin_sense)
3748                 msleep(2);
3749
3750         snd_hda_codec_write(codec, hp_pin, 0,
3751                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3752
3753         if (hp_pin_sense)
3754                 msleep(85);
3755
3756         if (!spec->no_shutup_pins)
3757                 snd_hda_codec_write(codec, hp_pin, 0,
3758                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3759
3760         if (hp_pin_sense)
3761                 msleep(100);
3762
3763         alc_auto_setup_eapd(codec, false);
3764         alc_shutup_pins(codec);
3765 }
3766
3767 static void alc294_hp_init(struct hda_codec *codec)
3768 {
3769         struct alc_spec *spec = codec->spec;
3770         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3771         int i, val;
3772
3773         if (!hp_pin)
3774                 return;
3775
3776         snd_hda_codec_write(codec, hp_pin, 0,
3777                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3778
3779         msleep(100);
3780
3781         if (!spec->no_shutup_pins)
3782                 snd_hda_codec_write(codec, hp_pin, 0,
3783                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3784
3785         alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3786         alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3787
3788         /* Wait for depop procedure finish  */
3789         val = alc_read_coefex_idx(codec, 0x58, 0x01);
3790         for (i = 0; i < 20 && val & 0x0080; i++) {
3791                 msleep(50);
3792                 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3793         }
3794         /* Set HP depop to auto mode */
3795         alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3796         msleep(50);
3797 }
3798
3799 static void alc294_init(struct hda_codec *codec)
3800 {
3801         struct alc_spec *spec = codec->spec;
3802
3803         /* required only at boot or S4 resume time */
3804         if (!spec->done_hp_init ||
3805             codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3806                 alc294_hp_init(codec);
3807                 spec->done_hp_init = true;
3808         }
3809         alc_default_init(codec);
3810 }
3811
3812 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3813                              unsigned int val)
3814 {
3815         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3816         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3817         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3818 }
3819
3820 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3821 {
3822         unsigned int val;
3823
3824         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3825         val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3826                 & 0xffff;
3827         val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3828                 << 16;
3829         return val;
3830 }
3831
3832 static void alc5505_dsp_halt(struct hda_codec *codec)
3833 {
3834         unsigned int val;
3835
3836         alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3837         alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3838         alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3839         alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3840         alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3841         alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3842         alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3843         val = alc5505_coef_get(codec, 0x6220);
3844         alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3845 }
3846
3847 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3848 {
3849         alc5505_coef_set(codec, 0x61b8, 0x04133302);
3850         alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3851         alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3852         alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3853         alc5505_coef_set(codec, 0x6220, 0x2002010f);
3854         alc5505_coef_set(codec, 0x880c, 0x00000004);
3855 }
3856
3857 static void alc5505_dsp_init(struct hda_codec *codec)
3858 {
3859         unsigned int val;
3860
3861         alc5505_dsp_halt(codec);
3862         alc5505_dsp_back_from_halt(codec);
3863         alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3864         alc5505_coef_set(codec, 0x61b0, 0x5b16);
3865         alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3866         alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3867         alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3868         alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3869         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3870         alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3871         alc5505_coef_set(codec, 0x61b8, 0x04173302);
3872         alc5505_coef_set(codec, 0x61b8, 0x04163302);
3873         alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3874         alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3875         alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3876
3877         val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3878         if (val <= 3)
3879                 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3880         else
3881                 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3882
3883         alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3884         alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3885         alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3886         alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3887         alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3888         alc5505_coef_set(codec, 0x880c, 0x00000003);
3889         alc5505_coef_set(codec, 0x880c, 0x00000010);
3890
3891 #ifdef HALT_REALTEK_ALC5505
3892         alc5505_dsp_halt(codec);
3893 #endif
3894 }
3895
3896 #ifdef HALT_REALTEK_ALC5505
3897 #define alc5505_dsp_suspend(codec)      do { } while (0) /* NOP */
3898 #define alc5505_dsp_resume(codec)       do { } while (0) /* NOP */
3899 #else
3900 #define alc5505_dsp_suspend(codec)      alc5505_dsp_halt(codec)
3901 #define alc5505_dsp_resume(codec)       alc5505_dsp_back_from_halt(codec)
3902 #endif
3903
3904 #ifdef CONFIG_PM
3905 static int alc269_suspend(struct hda_codec *codec)
3906 {
3907         struct alc_spec *spec = codec->spec;
3908
3909         if (spec->has_alc5505_dsp)
3910                 alc5505_dsp_suspend(codec);
3911         return alc_suspend(codec);
3912 }
3913
3914 static int alc269_resume(struct hda_codec *codec)
3915 {
3916         struct alc_spec *spec = codec->spec;
3917
3918         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3919                 alc269vb_toggle_power_output(codec, 0);
3920         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3921                         (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3922                 msleep(150);
3923         }
3924
3925         codec->patch_ops.init(codec);
3926
3927         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3928                 alc269vb_toggle_power_output(codec, 1);
3929         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3930                         (alc_get_coef0(codec) & 0x00ff) == 0x017) {
3931                 msleep(200);
3932         }
3933
3934         snd_hda_regmap_sync(codec);
3935         hda_call_check_power_status(codec, 0x01);
3936
3937         /* on some machine, the BIOS will clear the codec gpio data when enter
3938          * suspend, and won't restore the data after resume, so we restore it
3939          * in the driver.
3940          */
3941         if (spec->gpio_data)
3942                 alc_write_gpio_data(codec);
3943
3944         if (spec->has_alc5505_dsp)
3945                 alc5505_dsp_resume(codec);
3946
3947         return 0;
3948 }
3949 #endif /* CONFIG_PM */
3950
3951 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
3952                                                  const struct hda_fixup *fix, int action)
3953 {
3954         struct alc_spec *spec = codec->spec;
3955
3956         if (action == HDA_FIXUP_ACT_PRE_PROBE)
3957                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3958 }
3959
3960 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3961                                                  const struct hda_fixup *fix,
3962                                                  int action)
3963 {
3964         unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3965         unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3966
3967         if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3968                 snd_hda_codec_set_pincfg(codec, 0x19,
3969                         (cfg_headphone & ~AC_DEFCFG_DEVICE) |
3970                         (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3971 }
3972
3973 static void alc269_fixup_hweq(struct hda_codec *codec,
3974                                const struct hda_fixup *fix, int action)
3975 {
3976         if (action == HDA_FIXUP_ACT_INIT)
3977                 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
3978 }
3979
3980 static void alc269_fixup_headset_mic(struct hda_codec *codec,
3981                                        const struct hda_fixup *fix, int action)
3982 {
3983         struct alc_spec *spec = codec->spec;
3984
3985         if (action == HDA_FIXUP_ACT_PRE_PROBE)
3986                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3987 }
3988
3989 static void alc271_fixup_dmic(struct hda_codec *codec,
3990                               const struct hda_fixup *fix, int action)
3991 {
3992         static const struct hda_verb verbs[] = {
3993                 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3994                 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3995                 {}
3996         };
3997         unsigned int cfg;
3998
3999         if (strcmp(codec->core.chip_name, "ALC271X") &&
4000             strcmp(codec->core.chip_name, "ALC269VB"))
4001                 return;
4002         cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4003         if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
4004                 snd_hda_sequence_write(codec, verbs);
4005 }
4006
4007 /* Fix the speaker amp after resume, etc */
4008 static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4009                                           const struct hda_fixup *fix,
4010                                           int action)
4011 {
4012         if (action == HDA_FIXUP_ACT_INIT)
4013                 alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4014 }
4015
4016 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4017                                  const struct hda_fixup *fix, int action)
4018 {
4019         struct alc_spec *spec = codec->spec;
4020
4021         if (action != HDA_FIXUP_ACT_PROBE)
4022                 return;
4023
4024         /* Due to a hardware problem on Lenovo Ideadpad, we need to
4025          * fix the sample rate of analog I/O to 44.1kHz
4026          */
4027         spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
4028         spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
4029 }
4030
4031 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4032                                      const struct hda_fixup *fix, int action)
4033 {
4034         /* The digital-mic unit sends PDM (differential signal) instead of
4035          * the standard PCM, thus you can't record a valid mono stream as is.
4036          * Below is a workaround specific to ALC269 to control the dmic
4037          * signal source as mono.
4038          */
4039         if (action == HDA_FIXUP_ACT_INIT)
4040                 alc_update_coef_idx(codec, 0x07, 0, 0x80);
4041 }
4042
4043 static void alc269_quanta_automute(struct hda_codec *codec)
4044 {
4045         snd_hda_gen_update_outputs(codec);
4046
4047         alc_write_coef_idx(codec, 0x0c, 0x680);
4048         alc_write_coef_idx(codec, 0x0c, 0x480);
4049 }
4050
4051 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4052                                      const struct hda_fixup *fix, int action)
4053 {
4054         struct alc_spec *spec = codec->spec;
4055         if (action != HDA_FIXUP_ACT_PROBE)
4056                 return;
4057         spec->gen.automute_hook = alc269_quanta_automute;
4058 }
4059
4060 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4061                                          struct hda_jack_callback *jack)
4062 {
4063         struct alc_spec *spec = codec->spec;
4064         int vref;
4065         msleep(200);
4066         snd_hda_gen_hp_automute(codec, jack);
4067
4068         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4069         msleep(100);
4070         snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4071                             vref);
4072         msleep(500);
4073         snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4074                             vref);
4075 }
4076
4077 /*
4078  * Magic sequence to make Huawei Matebook X right speaker working (bko#197801)
4079  */
4080 struct hda_alc298_mbxinit {
4081         unsigned char value_0x23;
4082         unsigned char value_0x25;
4083 };
4084
4085 static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4086                                          const struct hda_alc298_mbxinit *initval,
4087                                          bool first)
4088 {
4089         snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4090         alc_write_coef_idx(codec, 0x26, 0xb000);
4091
4092         if (first)
4093                 snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4094
4095         snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4096         alc_write_coef_idx(codec, 0x26, 0xf000);
4097         alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4098
4099         if (initval->value_0x23 != 0x1e)
4100                 alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4101
4102         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4103         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4104 }
4105
4106 static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4107                                            const struct hda_fixup *fix,
4108                                            int action)
4109 {
4110         /* Initialization magic */
4111         static const struct hda_alc298_mbxinit dac_init[] = {
4112                 {0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00},
4113                 {0x10, 0x00}, {0x1a, 0x40}, {0x1b, 0x82}, {0x1c, 0x00},
4114                 {0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00},
4115                 {0x20, 0xc2}, {0x21, 0xc8}, {0x22, 0x26}, {0x23, 0x24},
4116                 {0x27, 0xff}, {0x28, 0xff}, {0x29, 0xff}, {0x2a, 0x8f},
4117                 {0x2b, 0x02}, {0x2c, 0x48}, {0x2d, 0x34}, {0x2e, 0x00},
4118                 {0x2f, 0x00},
4119                 {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00},
4120                 {0x34, 0x00}, {0x35, 0x01}, {0x36, 0x93}, {0x37, 0x0c},
4121                 {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0xf8}, {0x38, 0x80},
4122                 {}
4123         };
4124         const struct hda_alc298_mbxinit *seq;
4125
4126         if (action != HDA_FIXUP_ACT_INIT)
4127                 return;
4128
4129         /* Start */
4130         snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4131         snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4132         alc_write_coef_idx(codec, 0x26, 0xf000);
4133         alc_write_coef_idx(codec, 0x22, 0x31);
4134         alc_write_coef_idx(codec, 0x23, 0x0b);
4135         alc_write_coef_idx(codec, 0x25, 0x00);
4136         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4137         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4138
4139         for (seq = dac_init; seq->value_0x23; seq++)
4140                 alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4141 }
4142
4143 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4144                                      const struct hda_fixup *fix, int action)
4145 {
4146         struct alc_spec *spec = codec->spec;
4147         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4148                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4149                 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
4150         }
4151 }
4152
4153
4154 /* update mute-LED according to the speaker mute state via mic VREF pin */
4155 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
4156 {
4157         struct hda_codec *codec = private_data;
4158         struct alc_spec *spec = codec->spec;
4159         unsigned int pinval;
4160
4161         if (spec->mute_led_polarity)
4162                 enabled = !enabled;
4163         pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
4164         pinval &= ~AC_PINCTL_VREFEN;
4165         pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
4166         if (spec->mute_led_nid) {
4167                 /* temporarily power up/down for setting VREF */
4168                 snd_hda_power_up_pm(codec);
4169                 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
4170                 snd_hda_power_down_pm(codec);
4171         }
4172 }
4173
4174 /* Make sure the led works even in runtime suspend */
4175 static unsigned int led_power_filter(struct hda_codec *codec,
4176                                                   hda_nid_t nid,
4177                                                   unsigned int power_state)
4178 {
4179         struct alc_spec *spec = codec->spec;
4180
4181         if (power_state != AC_PWRST_D3 || nid == 0 ||
4182             (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
4183                 return power_state;
4184
4185         /* Set pin ctl again, it might have just been set to 0 */
4186         snd_hda_set_pin_ctl(codec, nid,
4187                             snd_hda_codec_get_pin_target(codec, nid));
4188
4189         return snd_hda_gen_path_power_filter(codec, nid, power_state);
4190 }
4191
4192 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4193                                      const struct hda_fixup *fix, int action)
4194 {
4195         struct alc_spec *spec = codec->spec;
4196         const struct dmi_device *dev = NULL;
4197
4198         if (action != HDA_FIXUP_ACT_PRE_PROBE)
4199                 return;
4200
4201         while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
4202                 int pol, pin;
4203                 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
4204                         continue;
4205                 if (pin < 0x0a || pin >= 0x10)
4206                         break;
4207                 spec->mute_led_polarity = pol;
4208                 spec->mute_led_nid = pin - 0x0a + 0x18;
4209                 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
4210                 spec->gen.vmaster_mute_enum = 1;
4211                 codec->power_filter = led_power_filter;
4212                 codec_dbg(codec,
4213                           "Detected mute LED for %x:%d\n", spec->mute_led_nid,
4214                            spec->mute_led_polarity);
4215                 break;
4216         }
4217 }
4218
4219 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4220                                           const struct hda_fixup *fix,
4221                                           int action, hda_nid_t pin)
4222 {
4223         struct alc_spec *spec = codec->spec;
4224
4225         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4226                 spec->mute_led_polarity = 0;
4227                 spec->mute_led_nid = pin;
4228                 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
4229                 spec->gen.vmaster_mute_enum = 1;
4230                 codec->power_filter = led_power_filter;
4231         }
4232 }
4233
4234 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4235                                 const struct hda_fixup *fix, int action)
4236 {
4237         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4238 }
4239
4240 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4241                                 const struct hda_fixup *fix, int action)
4242 {
4243         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4244 }
4245
4246 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4247                                 const struct hda_fixup *fix, int action)
4248 {
4249         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4250 }
4251
4252 /* update LED status via GPIO */
4253 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4254                                 int polarity, bool enabled)
4255 {
4256         if (polarity)
4257                 enabled = !enabled;
4258         alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4259 }
4260
4261 /* turn on/off mute LED via GPIO per vmaster hook */
4262 static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
4263 {
4264         struct hda_codec *codec = private_data;
4265         struct alc_spec *spec = codec->spec;
4266
4267         alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
4268                             spec->mute_led_polarity, enabled);
4269 }
4270
4271 /* turn on/off mic-mute LED via GPIO per capture hook */
4272 static void alc_gpio_micmute_update(struct hda_codec *codec)
4273 {
4274         struct alc_spec *spec = codec->spec;
4275
4276         alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4277                             spec->micmute_led_polarity,
4278                             spec->gen.micmute_led.led_value);
4279 }
4280
4281 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
4282 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4283                                   int action,
4284                                   unsigned int mute_mask,
4285                                   unsigned int micmute_mask)
4286 {
4287         struct alc_spec *spec = codec->spec;
4288
4289         alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4290
4291         if (action != HDA_FIXUP_ACT_PRE_PROBE)
4292                 return;
4293         if (mute_mask) {
4294                 spec->gpio_mute_led_mask = mute_mask;
4295                 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
4296         }
4297         if (micmute_mask) {
4298                 spec->gpio_mic_led_mask = micmute_mask;
4299                 snd_hda_gen_add_micmute_led(codec, alc_gpio_micmute_update);
4300         }
4301 }
4302
4303 static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
4304                                 const struct hda_fixup *fix, int action)
4305 {
4306         alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
4307 }
4308
4309 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4310                                 const struct hda_fixup *fix, int action)
4311 {
4312         alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4313 }
4314
4315 static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4316                                 const struct hda_fixup *fix, int action)
4317 {
4318         alc_fixup_hp_gpio_led(codec, action, 0x04, 0x00);
4319 }
4320
4321 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4322                                 const struct hda_fixup *fix, int action)
4323 {
4324         alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4325 }
4326
4327 /* turn on/off mic-mute LED per capture hook */
4328 static void alc_cap_micmute_update(struct hda_codec *codec)
4329 {
4330         struct alc_spec *spec = codec->spec;
4331         unsigned int pinval;
4332
4333         if (!spec->cap_mute_led_nid)
4334                 return;
4335         pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
4336         pinval &= ~AC_PINCTL_VREFEN;
4337         if (spec->gen.micmute_led.led_value)
4338                 pinval |= AC_PINCTL_VREF_80;
4339         else
4340                 pinval |= AC_PINCTL_VREF_HIZ;
4341         snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
4342 }
4343
4344 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4345                                 const struct hda_fixup *fix, int action)
4346 {
4347         struct alc_spec *spec = codec->spec;
4348
4349         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4350         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4351                 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to
4352                  * enable headphone amp
4353                  */
4354                 spec->gpio_mask |= 0x10;
4355                 spec->gpio_dir |= 0x10;
4356                 spec->cap_mute_led_nid = 0x18;
4357                 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
4358                 codec->power_filter = led_power_filter;
4359         }
4360 }
4361
4362 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4363                                    const struct hda_fixup *fix, int action)
4364 {
4365         struct alc_spec *spec = codec->spec;
4366
4367         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4368         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4369                 spec->cap_mute_led_nid = 0x18;
4370                 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
4371                 codec->power_filter = led_power_filter;
4372         }
4373 }
4374
4375 /* update mute-LED according to the speaker mute state via COEF bit */
4376 static void alc_fixup_mute_led_coefbit_hook(void *private_data, int enabled)
4377 {
4378         struct hda_codec *codec = private_data;
4379         struct alc_spec *spec = codec->spec;
4380
4381         if (spec->mute_led_polarity)
4382                 enabled = !enabled;
4383
4384         /* temporarily power up/down for setting COEF bit */
4385         enabled ? alc_update_coef_idx(codec, spec->mute_led_coef_idx,
4386                 spec->mute_led_coefbit_mask, spec->mute_led_coefbit_off) :
4387                   alc_update_coef_idx(codec, spec->mute_led_coef_idx,
4388                 spec->mute_led_coefbit_mask, spec->mute_led_coefbit_on);
4389 }
4390
4391 static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4392                                           const struct hda_fixup *fix,
4393                                           int action)
4394 {
4395         struct alc_spec *spec = codec->spec;
4396
4397         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4398                 spec->mute_led_polarity = 0;
4399                 spec->mute_led_coef_idx = 0x0b;
4400                 spec->mute_led_coefbit_mask = 1<<3;
4401                 spec->mute_led_coefbit_on = 1<<3;
4402                 spec->mute_led_coefbit_off = 0;
4403                 spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook;
4404                 spec->gen.vmaster_mute_enum = 1;
4405         }
4406 }
4407
4408 static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4409                                           const struct hda_fixup *fix,
4410                                           int action)
4411 {
4412         struct alc_spec *spec = codec->spec;
4413
4414         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4415                 spec->mute_led_polarity = 0;
4416                 spec->mute_led_coef_idx = 0x34;
4417                 spec->mute_led_coefbit_mask = 1<<5;
4418                 spec->mute_led_coefbit_on = 0;
4419                 spec->mute_led_coefbit_off = 1<<5;
4420                 spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook;
4421                 spec->gen.vmaster_mute_enum = 1;
4422         }
4423 }
4424
4425 /* turn on/off mic-mute LED per capture hook by coef bit */
4426 static void alc_hp_cap_micmute_update(struct hda_codec *codec)
4427 {
4428         struct alc_spec *spec = codec->spec;
4429
4430         if (spec->gen.micmute_led.led_value)
4431                 alc_update_coef_idx(codec, spec->mic_led_coef_idx,
4432                         spec->mic_led_coefbit_mask, spec->mic_led_coefbit_on);
4433         else
4434                 alc_update_coef_idx(codec, spec->mic_led_coef_idx,
4435                         spec->mic_led_coefbit_mask, spec->mic_led_coefbit_off);
4436 }
4437
4438 static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4439                                 const struct hda_fixup *fix, int action)
4440 {
4441         struct alc_spec *spec = codec->spec;
4442
4443         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4444                 spec->mic_led_coef_idx = 0x19;
4445                 spec->mic_led_coefbit_mask = 1<<13;
4446                 spec->mic_led_coefbit_on = 1<<13;
4447                 spec->mic_led_coefbit_off = 0;
4448                 snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update);
4449         }
4450 }
4451
4452 static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4453                                 const struct hda_fixup *fix, int action)
4454 {
4455         struct alc_spec *spec = codec->spec;
4456
4457         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4458                 spec->mic_led_coef_idx = 0x35;
4459                 spec->mic_led_coefbit_mask = 3<<2;
4460                 spec->mic_led_coefbit_on = 2<<2;
4461                 spec->mic_led_coefbit_off = 1<<2;
4462                 snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update);
4463         }
4464 }
4465
4466 static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4467                                 const struct hda_fixup *fix, int action)
4468 {
4469         alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4470         alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4471 }
4472
4473 static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4474                                 const struct hda_fixup *fix, int action)
4475 {
4476         alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4477         alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4478 }
4479
4480 #if IS_REACHABLE(CONFIG_INPUT)
4481 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4482                                    struct hda_jack_callback *event)
4483 {
4484         struct alc_spec *spec = codec->spec;
4485
4486         /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4487            send both key on and key off event for every interrupt. */
4488         input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4489         input_sync(spec->kb_dev);
4490         input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4491         input_sync(spec->kb_dev);
4492 }
4493
4494 static int alc_register_micmute_input_device(struct hda_codec *codec)
4495 {
4496         struct alc_spec *spec = codec->spec;
4497         int i;
4498
4499         spec->kb_dev = input_allocate_device();
4500         if (!spec->kb_dev) {
4501                 codec_err(codec, "Out of memory (input_allocate_device)\n");
4502                 return -ENOMEM;
4503         }
4504
4505         spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4506
4507         spec->kb_dev->name = "Microphone Mute Button";
4508         spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4509         spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4510         spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4511         spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4512         for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4513                 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4514
4515         if (input_register_device(spec->kb_dev)) {
4516                 codec_err(codec, "input_register_device failed\n");
4517                 input_free_device(spec->kb_dev);
4518                 spec->kb_dev = NULL;
4519                 return -ENOMEM;
4520         }
4521
4522         return 0;
4523 }
4524
4525 /* GPIO1 = set according to SKU external amp
4526  * GPIO2 = mic mute hotkey
4527  * GPIO3 = mute LED
4528  * GPIO4 = mic mute LED
4529  */
4530 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4531                                              const struct hda_fixup *fix, int action)
4532 {
4533         struct alc_spec *spec = codec->spec;
4534
4535         alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4536         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4537                 spec->init_amp = ALC_INIT_DEFAULT;
4538                 if (alc_register_micmute_input_device(codec) != 0)
4539                         return;
4540
4541                 spec->gpio_mask |= 0x06;
4542                 spec->gpio_dir |= 0x02;
4543                 spec->gpio_data |= 0x02;
4544                 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4545                                           AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
4546                 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4547                                                     gpio2_mic_hotkey_event);
4548                 return;
4549         }
4550
4551         if (!spec->kb_dev)
4552                 return;
4553
4554         switch (action) {
4555         case HDA_FIXUP_ACT_FREE:
4556                 input_unregister_device(spec->kb_dev);
4557                 spec->kb_dev = NULL;
4558         }
4559 }
4560
4561 /* Line2 = mic mute hotkey
4562  * GPIO2 = mic mute LED
4563  */
4564 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4565                                              const struct hda_fixup *fix, int action)
4566 {
4567         struct alc_spec *spec = codec->spec;
4568
4569         spec->micmute_led_polarity = 1;
4570         alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4571         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4572                 spec->init_amp = ALC_INIT_DEFAULT;
4573                 if (alc_register_micmute_input_device(codec) != 0)
4574                         return;
4575
4576                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4577                                                     gpio2_mic_hotkey_event);
4578                 return;
4579         }
4580
4581         if (!spec->kb_dev)
4582                 return;
4583
4584         switch (action) {
4585         case HDA_FIXUP_ACT_FREE:
4586                 input_unregister_device(spec->kb_dev);
4587                 spec->kb_dev = NULL;
4588         }
4589 }
4590 #else /* INPUT */
4591 #define alc280_fixup_hp_gpio2_mic_hotkey        NULL
4592 #define alc233_fixup_lenovo_line2_mic_hotkey    NULL
4593 #endif /* INPUT */
4594
4595 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4596                                 const struct hda_fixup *fix, int action)
4597 {
4598         struct alc_spec *spec = codec->spec;
4599
4600         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4601         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4602                 spec->cap_mute_led_nid = 0x18;
4603                 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
4604         }
4605 }
4606
4607 static const struct coef_fw alc225_pre_hsmode[] = {
4608         UPDATE_COEF(0x4a, 1<<8, 0),
4609         UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4610         UPDATE_COEF(0x63, 3<<14, 3<<14),
4611         UPDATE_COEF(0x4a, 3<<4, 2<<4),
4612         UPDATE_COEF(0x4a, 3<<10, 3<<10),
4613         UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4614         UPDATE_COEF(0x4a, 3<<10, 0),
4615         {}
4616 };
4617
4618 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4619 {
4620         static const struct coef_fw coef0255[] = {
4621                 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4622                 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4623                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4624                 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4625                 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4626                 {}
4627         };
4628         static const struct coef_fw coef0256[] = {
4629                 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4630                 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4631                 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4632                 WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4633                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4634                 {}
4635         };
4636         static const struct coef_fw coef0233[] = {
4637                 WRITE_COEF(0x1b, 0x0c0b),
4638                 WRITE_COEF(0x45, 0xc429),
4639                 UPDATE_COEF(0x35, 0x4000, 0),
4640                 WRITE_COEF(0x06, 0x2104),
4641                 WRITE_COEF(0x1a, 0x0001),
4642                 WRITE_COEF(0x26, 0x0004),
4643                 WRITE_COEF(0x32, 0x42a3),
4644                 {}
4645         };
4646         static const struct coef_fw coef0288[] = {
4647                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4648                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4649                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4650                 UPDATE_COEF(0x66, 0x0008, 0),
4651                 UPDATE_COEF(0x67, 0x2000, 0),
4652                 {}
4653         };
4654         static const struct coef_fw coef0298[] = {
4655                 UPDATE_COEF(0x19, 0x1300, 0x0300),
4656                 {}
4657         };
4658         static const struct coef_fw coef0292[] = {
4659                 WRITE_COEF(0x76, 0x000e),
4660                 WRITE_COEF(0x6c, 0x2400),
4661                 WRITE_COEF(0x18, 0x7308),
4662                 WRITE_COEF(0x6b, 0xc429),
4663                 {}
4664         };
4665         static const struct coef_fw coef0293[] = {
4666                 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4667                 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4668                 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4669                 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4670                 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4671                 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4672                 {}
4673         };
4674         static const struct coef_fw coef0668[] = {
4675                 WRITE_COEF(0x15, 0x0d40),
4676                 WRITE_COEF(0xb7, 0x802b),
4677                 {}
4678         };
4679         static const struct coef_fw coef0225[] = {
4680                 UPDATE_COEF(0x63, 3<<14, 0),
4681                 {}
4682         };
4683         static const struct coef_fw coef0274[] = {
4684                 UPDATE_COEF(0x4a, 0x0100, 0),
4685                 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4686                 UPDATE_COEF(0x6b, 0xf000, 0x5000),
4687                 UPDATE_COEF(0x4a, 0x0010, 0),
4688                 UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4689                 WRITE_COEF(0x45, 0x5289),
4690                 UPDATE_COEF(0x4a, 0x0c00, 0),
4691                 {}
4692         };
4693
4694         switch (codec->core.vendor_id) {
4695         case 0x10ec0255:
4696                 alc_process_coef_fw(codec, coef0255);
4697                 break;
4698         case 0x10ec0230:
4699         case 0x10ec0236:
4700         case 0x10ec0256:
4701         case 0x19e58326:
4702                 alc_process_coef_fw(codec, coef0256);
4703                 break;
4704         case 0x10ec0234:
4705         case 0x10ec0274:
4706         case 0x10ec0294:
4707                 alc_process_coef_fw(codec, coef0274);
4708                 break;
4709         case 0x10ec0233:
4710         case 0x10ec0283:
4711                 alc_process_coef_fw(codec, coef0233);
4712                 break;
4713         case 0x10ec0286:
4714         case 0x10ec0288:
4715                 alc_process_coef_fw(codec, coef0288);
4716                 break;
4717         case 0x10ec0298:
4718                 alc_process_coef_fw(codec, coef0298);
4719                 alc_process_coef_fw(codec, coef0288);
4720                 break;
4721         case 0x10ec0292:
4722                 alc_process_coef_fw(codec, coef0292);
4723                 break;
4724         case 0x10ec0293:
4725                 alc_process_coef_fw(codec, coef0293);
4726                 break;
4727         case 0x10ec0668:
4728                 alc_process_coef_fw(codec, coef0668);
4729                 break;
4730         case 0x10ec0215:
4731         case 0x10ec0225:
4732         case 0x10ec0285:
4733         case 0x10ec0295:
4734         case 0x10ec0289:
4735         case 0x10ec0299:
4736                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4737                 alc_process_coef_fw(codec, coef0225);
4738                 break;
4739         case 0x10ec0867:
4740                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4741                 break;
4742         }
4743         codec_dbg(codec, "Headset jack set to unplugged mode.\n");
4744 }
4745
4746
4747 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4748                                     hda_nid_t mic_pin)
4749 {
4750         static const struct coef_fw coef0255[] = {
4751                 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4752                 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4753                 {}
4754         };
4755         static const struct coef_fw coef0256[] = {
4756                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
4757                 WRITE_COEFEX(0x57, 0x03, 0x09a3),
4758                 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4759                 {}
4760         };
4761         static const struct coef_fw coef0233[] = {
4762                 UPDATE_COEF(0x35, 0, 1<<14),
4763                 WRITE_COEF(0x06, 0x2100),
4764                 WRITE_COEF(0x1a, 0x0021),
4765                 WRITE_COEF(0x26, 0x008c),
4766                 {}
4767         };
4768         static const struct coef_fw coef0288[] = {
4769                 UPDATE_COEF(0x4f, 0x00c0, 0),
4770                 UPDATE_COEF(0x50, 0x2000, 0),
4771                 UPDATE_COEF(0x56, 0x0006, 0),
4772                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4773                 UPDATE_COEF(0x66, 0x0008, 0x0008),
4774                 UPDATE_COEF(0x67, 0x2000, 0x2000),
4775                 {}
4776         };
4777         static const struct coef_fw coef0292[] = {
4778                 WRITE_COEF(0x19, 0xa208),
4779                 WRITE_COEF(0x2e, 0xacf0),
4780                 {}
4781         };
4782         static const struct coef_fw coef0293[] = {
4783                 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4784                 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4785                 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4786                 {}
4787         };
4788         static const struct coef_fw coef0688[] = {
4789                 WRITE_COEF(0xb7, 0x802b),
4790                 WRITE_COEF(0xb5, 0x1040),
4791                 UPDATE_COEF(0xc3, 0, 1<<12),
4792                 {}
4793         };
4794         static const struct coef_fw coef0225[] = {
4795                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4796                 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4797                 UPDATE_COEF(0x63, 3<<14, 0),
4798                 {}
4799         };
4800         static const struct coef_fw coef0274[] = {
4801                 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4802                 UPDATE_COEF(0x4a, 0x0010, 0),
4803                 UPDATE_COEF(0x6b, 0xf000, 0),
4804                 {}
4805         };
4806
4807         switch (codec->core.vendor_id) {
4808         case 0x10ec0255:
4809                 alc_write_coef_idx(codec, 0x45, 0xc489);
4810                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4811                 alc_process_coef_fw(codec, coef0255);
4812                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4813                 break;
4814         case 0x10ec0230:
4815         case 0x10ec0236:
4816         case 0x10ec0256:
4817         case 0x19e58326:
4818                 alc_write_coef_idx(codec, 0x45, 0xc489);
4819                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4820                 alc_process_coef_fw(codec, coef0256);
4821                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4822                 break;
4823         case 0x10ec0234:
4824         case 0x10ec0274:
4825         case 0x10ec0294:
4826                 alc_write_coef_idx(codec, 0x45, 0x4689);
4827                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4828                 alc_process_coef_fw(codec, coef0274);
4829                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4830                 break;
4831         case 0x10ec0233:
4832         case 0x10ec0283:
4833                 alc_write_coef_idx(codec, 0x45, 0xc429);
4834                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4835                 alc_process_coef_fw(codec, coef0233);
4836                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4837                 break;
4838         case 0x10ec0286:
4839         case 0x10ec0288:
4840         case 0x10ec0298:
4841                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4842                 alc_process_coef_fw(codec, coef0288);
4843                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4844                 break;
4845         case 0x10ec0292:
4846                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4847                 alc_process_coef_fw(codec, coef0292);
4848                 break;
4849         case 0x10ec0293:
4850                 /* Set to TRS mode */
4851                 alc_write_coef_idx(codec, 0x45, 0xc429);
4852                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4853                 alc_process_coef_fw(codec, coef0293);
4854                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4855                 break;
4856         case 0x10ec0867:
4857                 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4858                 /* fallthru */
4859         case 0x10ec0221:
4860         case 0x10ec0662:
4861                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4862                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4863                 break;
4864         case 0x10ec0668:
4865                 alc_write_coef_idx(codec, 0x11, 0x0001);
4866                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4867                 alc_process_coef_fw(codec, coef0688);
4868                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4869                 break;
4870         case 0x10ec0215:
4871         case 0x10ec0225:
4872         case 0x10ec0285:
4873         case 0x10ec0295:
4874         case 0x10ec0289:
4875         case 0x10ec0299:
4876                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4877                 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4878                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4879                 alc_process_coef_fw(codec, coef0225);
4880                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4881                 break;
4882         }
4883         codec_dbg(codec, "Headset jack set to mic-in mode.\n");
4884 }
4885
4886 static void alc_headset_mode_default(struct hda_codec *codec)
4887 {
4888         static const struct coef_fw coef0225[] = {
4889                 UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4890                 UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4891                 UPDATE_COEF(0x49, 3<<8, 0<<8),
4892                 UPDATE_COEF(0x4a, 3<<4, 3<<4),
4893                 UPDATE_COEF(0x63, 3<<14, 0),
4894                 UPDATE_COEF(0x67, 0xf000, 0x3000),
4895                 {}
4896         };
4897         static const struct coef_fw coef0255[] = {
4898                 WRITE_COEF(0x45, 0xc089),
4899                 WRITE_COEF(0x45, 0xc489),
4900                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4901                 WRITE_COEF(0x49, 0x0049),
4902                 {}
4903         };
4904         static const struct coef_fw coef0256[] = {
4905                 WRITE_COEF(0x45, 0xc489),
4906                 WRITE_COEFEX(0x57, 0x03, 0x0da3),
4907                 WRITE_COEF(0x49, 0x0049),
4908                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4909                 WRITE_COEF(0x06, 0x6100),
4910                 {}
4911         };
4912         static const struct coef_fw coef0233[] = {
4913                 WRITE_COEF(0x06, 0x2100),
4914                 WRITE_COEF(0x32, 0x4ea3),
4915                 {}
4916         };
4917         static const struct coef_fw coef0288[] = {
4918                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
4919                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4920                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4921                 UPDATE_COEF(0x66, 0x0008, 0),
4922                 UPDATE_COEF(0x67, 0x2000, 0),
4923                 {}
4924         };
4925         static const struct coef_fw coef0292[] = {
4926                 WRITE_COEF(0x76, 0x000e),
4927                 WRITE_COEF(0x6c, 0x2400),
4928                 WRITE_COEF(0x6b, 0xc429),
4929                 WRITE_COEF(0x18, 0x7308),
4930                 {}
4931         };
4932         static const struct coef_fw coef0293[] = {
4933                 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4934                 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
4935                 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4936                 {}
4937         };
4938         static const struct coef_fw coef0688[] = {
4939                 WRITE_COEF(0x11, 0x0041),
4940                 WRITE_COEF(0x15, 0x0d40),
4941                 WRITE_COEF(0xb7, 0x802b),
4942                 {}
4943         };
4944         static const struct coef_fw coef0274[] = {
4945                 WRITE_COEF(0x45, 0x4289),
4946                 UPDATE_COEF(0x4a, 0x0010, 0x0010),
4947                 UPDATE_COEF(0x6b, 0x0f00, 0),
4948                 UPDATE_COEF(0x49, 0x0300, 0x0300),
4949                 {}
4950         };
4951
4952         switch (codec->core.vendor_id) {
4953         case 0x10ec0215:
4954         case 0x10ec0225:
4955         case 0x10ec0285:
4956         case 0x10ec0295:
4957         case 0x10ec0289:
4958         case 0x10ec0299:
4959                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4960                 alc_process_coef_fw(codec, coef0225);
4961                 break;
4962         case 0x10ec0255:
4963                 alc_process_coef_fw(codec, coef0255);
4964                 break;
4965         case 0x10ec0230:
4966         case 0x10ec0236:
4967         case 0x10ec0256:
4968         case 0x19e58326:
4969                 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4970                 alc_write_coef_idx(codec, 0x45, 0xc089);
4971                 msleep(50);
4972                 alc_process_coef_fw(codec, coef0256);
4973                 break;
4974         case 0x10ec0234:
4975         case 0x10ec0274:
4976         case 0x10ec0294:
4977                 alc_process_coef_fw(codec, coef0274);
4978                 break;
4979         case 0x10ec0233:
4980         case 0x10ec0283:
4981                 alc_process_coef_fw(codec, coef0233);
4982                 break;
4983         case 0x10ec0286:
4984         case 0x10ec0288:
4985         case 0x10ec0298:
4986                 alc_process_coef_fw(codec, coef0288);
4987                 break;
4988         case 0x10ec0292:
4989                 alc_process_coef_fw(codec, coef0292);
4990                 break;
4991         case 0x10ec0293:
4992                 alc_process_coef_fw(codec, coef0293);
4993                 break;
4994         case 0x10ec0668:
4995                 alc_process_coef_fw(codec, coef0688);
4996                 break;
4997         case 0x10ec0867:
4998                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4999                 break;
5000         }
5001         codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5002 }
5003
5004 /* Iphone type */
5005 static void alc_headset_mode_ctia(struct hda_codec *codec)
5006 {
5007         int val;
5008
5009         static const struct coef_fw coef0255[] = {
5010                 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5011                 WRITE_COEF(0x1b, 0x0c2b),
5012                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5013                 {}
5014         };
5015         static const struct coef_fw coef0256[] = {
5016                 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5017                 WRITE_COEF(0x1b, 0x0e6b),
5018                 {}
5019         };
5020         static const struct coef_fw coef0233[] = {
5021                 WRITE_COEF(0x45, 0xd429),
5022                 WRITE_COEF(0x1b, 0x0c2b),
5023                 WRITE_COEF(0x32, 0x4ea3),
5024                 {}
5025         };
5026         static const struct coef_fw coef0288[] = {
5027                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5028                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5029                 UPDATE_COEF(0x66, 0x0008, 0),
5030                 UPDATE_COEF(0x67, 0x2000, 0),
5031                 {}
5032         };
5033         static const struct coef_fw coef0292[] = {
5034                 WRITE_COEF(0x6b, 0xd429),
5035                 WRITE_COEF(0x76, 0x0008),
5036                 WRITE_COEF(0x18, 0x7388),
5037                 {}
5038         };
5039         static const struct coef_fw coef0293[] = {
5040                 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
5041                 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5042                 {}
5043         };
5044         static const struct coef_fw coef0688[] = {
5045                 WRITE_COEF(0x11, 0x0001),
5046                 WRITE_COEF(0x15, 0x0d60),
5047                 WRITE_COEF(0xc3, 0x0000),
5048                 {}
5049         };
5050         static const struct coef_fw coef0225_1[] = {
5051                 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5052                 UPDATE_COEF(0x63, 3<<14, 2<<14),
5053                 {}
5054         };
5055         static const struct coef_fw coef0225_2[] = {
5056                 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5057                 UPDATE_COEF(0x63, 3<<14, 1<<14),
5058                 {}
5059         };
5060
5061         switch (codec->core.vendor_id) {
5062         case 0x10ec0255:
5063                 alc_process_coef_fw(codec, coef0255);
5064                 break;
5065         case 0x10ec0230:
5066         case 0x10ec0236:
5067         case 0x10ec0256:
5068         case 0x19e58326:
5069                 alc_process_coef_fw(codec, coef0256);
5070                 break;
5071         case 0x10ec0234:
5072         case 0x10ec0274:
5073         case 0x10ec0294:
5074                 alc_write_coef_idx(codec, 0x45, 0xd689);
5075                 break;
5076         case 0x10ec0233:
5077         case 0x10ec0283:
5078                 alc_process_coef_fw(codec, coef0233);
5079                 break;
5080         case 0x10ec0298:
5081                 val = alc_read_coef_idx(codec, 0x50);
5082                 if (val & (1 << 12)) {
5083                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5084                         alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5085                         msleep(300);
5086                 } else {
5087                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5088                         alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5089                         msleep(300);
5090                 }
5091                 break;
5092         case 0x10ec0286:
5093         case 0x10ec0288:
5094                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5095                 msleep(300);
5096                 alc_process_coef_fw(codec, coef0288);
5097                 break;
5098         case 0x10ec0292:
5099                 alc_process_coef_fw(codec, coef0292);
5100                 break;
5101         case 0x10ec0293:
5102                 alc_process_coef_fw(codec, coef0293);
5103                 break;
5104         case 0x10ec0668:
5105                 alc_process_coef_fw(codec, coef0688);
5106                 break;
5107         case 0x10ec0215:
5108         case 0x10ec0225:
5109         case 0x10ec0285:
5110         case 0x10ec0295:
5111         case 0x10ec0289:
5112         case 0x10ec0299:
5113                 val = alc_read_coef_idx(codec, 0x45);
5114                 if (val & (1 << 9))
5115                         alc_process_coef_fw(codec, coef0225_2);
5116                 else
5117                         alc_process_coef_fw(codec, coef0225_1);
5118                 break;
5119         case 0x10ec0867:
5120                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5121                 break;
5122         }
5123         codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5124 }
5125
5126 /* Nokia type */
5127 static void alc_headset_mode_omtp(struct hda_codec *codec)
5128 {
5129         static const struct coef_fw coef0255[] = {
5130                 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5131                 WRITE_COEF(0x1b, 0x0c2b),
5132                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5133                 {}
5134         };
5135         static const struct coef_fw coef0256[] = {
5136                 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5137                 WRITE_COEF(0x1b, 0x0e6b),
5138                 {}
5139         };
5140         static const struct coef_fw coef0233[] = {
5141                 WRITE_COEF(0x45, 0xe429),
5142                 WRITE_COEF(0x1b, 0x0c2b),
5143                 WRITE_COEF(0x32, 0x4ea3),
5144                 {}
5145         };
5146         static const struct coef_fw coef0288[] = {
5147                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5148                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5149                 UPDATE_COEF(0x66, 0x0008, 0),
5150                 UPDATE_COEF(0x67, 0x2000, 0),
5151                 {}
5152         };
5153         static const struct coef_fw coef0292[] = {
5154                 WRITE_COEF(0x6b, 0xe429),
5155                 WRITE_COEF(0x76, 0x0008),
5156                 WRITE_COEF(0x18, 0x7388),
5157                 {}
5158         };
5159         static const struct coef_fw coef0293[] = {
5160                 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
5161                 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5162                 {}
5163         };
5164         static const struct coef_fw coef0688[] = {
5165                 WRITE_COEF(0x11, 0x0001),
5166                 WRITE_COEF(0x15, 0x0d50),
5167                 WRITE_COEF(0xc3, 0x0000),
5168                 {}
5169         };
5170         static const struct coef_fw coef0225[] = {
5171                 UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5172                 UPDATE_COEF(0x63, 3<<14, 2<<14),
5173                 {}
5174         };
5175
5176         switch (codec->core.vendor_id) {
5177         case 0x10ec0255:
5178                 alc_process_coef_fw(codec, coef0255);
5179                 break;
5180         case 0x10ec0230:
5181         case 0x10ec0236:
5182         case 0x10ec0256:
5183         case 0x19e58326:
5184                 alc_process_coef_fw(codec, coef0256);
5185                 break;
5186         case 0x10ec0234:
5187         case 0x10ec0274:
5188         case 0x10ec0294:
5189                 alc_write_coef_idx(codec, 0x45, 0xe689);
5190                 break;
5191         case 0x10ec0233:
5192         case 0x10ec0283:
5193                 alc_process_coef_fw(codec, coef0233);
5194                 break;
5195         case 0x10ec0298:
5196                 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5197                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5198                 msleep(300);
5199                 break;
5200         case 0x10ec0286:
5201         case 0x10ec0288:
5202                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5203                 msleep(300);
5204                 alc_process_coef_fw(codec, coef0288);
5205                 break;
5206         case 0x10ec0292:
5207                 alc_process_coef_fw(codec, coef0292);
5208                 break;
5209         case 0x10ec0293:
5210                 alc_process_coef_fw(codec, coef0293);
5211                 break;
5212         case 0x10ec0668:
5213                 alc_process_coef_fw(codec, coef0688);
5214                 break;
5215         case 0x10ec0215:
5216         case 0x10ec0225:
5217         case 0x10ec0285:
5218         case 0x10ec0295:
5219         case 0x10ec0289:
5220         case 0x10ec0299:
5221                 alc_process_coef_fw(codec, coef0225);
5222                 break;
5223         }
5224         codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5225 }
5226
5227 static void alc_determine_headset_type(struct hda_codec *codec)
5228 {
5229         int val;
5230         bool is_ctia = false;
5231         struct alc_spec *spec = codec->spec;
5232         static const struct coef_fw coef0255[] = {
5233                 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
5234                 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
5235  conteol) */
5236                 {}
5237         };
5238         static const struct coef_fw coef0288[] = {
5239                 UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
5240                 {}
5241         };
5242         static const struct coef_fw coef0298[] = {
5243                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5244                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5245                 UPDATE_COEF(0x66, 0x0008, 0),
5246                 UPDATE_COEF(0x67, 0x2000, 0),
5247                 UPDATE_COEF(0x19, 0x1300, 0x1300),
5248                 {}
5249         };
5250         static const struct coef_fw coef0293[] = {
5251                 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
5252                 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
5253                 {}
5254         };
5255         static const struct coef_fw coef0688[] = {
5256                 WRITE_COEF(0x11, 0x0001),
5257                 WRITE_COEF(0xb7, 0x802b),
5258                 WRITE_COEF(0x15, 0x0d60),
5259                 WRITE_COEF(0xc3, 0x0c00),
5260                 {}
5261         };
5262         static const struct coef_fw coef0274[] = {
5263                 UPDATE_COEF(0x4a, 0x0010, 0),
5264                 UPDATE_COEF(0x4a, 0x8000, 0),
5265                 WRITE_COEF(0x45, 0xd289),
5266                 UPDATE_COEF(0x49, 0x0300, 0x0300),
5267                 {}
5268         };
5269
5270         switch (codec->core.vendor_id) {
5271         case 0x10ec0255:
5272                 alc_process_coef_fw(codec, coef0255);
5273                 msleep(300);
5274                 val = alc_read_coef_idx(codec, 0x46);
5275                 is_ctia = (val & 0x0070) == 0x0070;
5276                 break;
5277         case 0x10ec0230:
5278         case 0x10ec0236:
5279         case 0x10ec0256:
5280         case 0x19e58326:
5281                 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5282                 alc_write_coef_idx(codec, 0x06, 0x6104);
5283                 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5284
5285                 snd_hda_codec_write(codec, 0x21, 0,
5286                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5287                 msleep(80);
5288                 snd_hda_codec_write(codec, 0x21, 0,
5289                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5290
5291                 alc_process_coef_fw(codec, coef0255);
5292                 msleep(300);
5293                 val = alc_read_coef_idx(codec, 0x46);
5294                 is_ctia = (val & 0x0070) == 0x0070;
5295
5296                 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5297                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5298
5299                 snd_hda_codec_write(codec, 0x21, 0,
5300                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5301                 msleep(80);
5302                 snd_hda_codec_write(codec, 0x21, 0,
5303                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5304                 break;
5305         case 0x10ec0234:
5306         case 0x10ec0274:
5307         case 0x10ec0294:
5308                 alc_process_coef_fw(codec, coef0274);
5309                 msleep(850);
5310                 val = alc_read_coef_idx(codec, 0x46);
5311                 is_ctia = (val & 0x00f0) == 0x00f0;
5312                 break;
5313         case 0x10ec0233:
5314         case 0x10ec0283:
5315                 alc_write_coef_idx(codec, 0x45, 0xd029);
5316                 msleep(300);
5317                 val = alc_read_coef_idx(codec, 0x46);
5318                 is_ctia = (val & 0x0070) == 0x0070;
5319                 break;
5320         case 0x10ec0298:
5321                 snd_hda_codec_write(codec, 0x21, 0,
5322                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5323                 msleep(100);
5324                 snd_hda_codec_write(codec, 0x21, 0,
5325                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5326                 msleep(200);
5327
5328                 val = alc_read_coef_idx(codec, 0x50);
5329                 if (val & (1 << 12)) {
5330                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5331                         alc_process_coef_fw(codec, coef0288);
5332                         msleep(350);
5333                         val = alc_read_coef_idx(codec, 0x50);
5334                         is_ctia = (val & 0x0070) == 0x0070;
5335                 } else {
5336                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5337                         alc_process_coef_fw(codec, coef0288);
5338                         msleep(350);
5339                         val = alc_read_coef_idx(codec, 0x50);
5340                         is_ctia = (val & 0x0070) == 0x0070;
5341                 }
5342                 alc_process_coef_fw(codec, coef0298);
5343                 snd_hda_codec_write(codec, 0x21, 0,
5344                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
5345                 msleep(75);
5346                 snd_hda_codec_write(codec, 0x21, 0,
5347                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5348                 break;
5349         case 0x10ec0286:
5350         case 0x10ec0288:
5351                 alc_process_coef_fw(codec, coef0288);
5352                 msleep(350);
5353                 val = alc_read_coef_idx(codec, 0x50);
5354                 is_ctia = (val & 0x0070) == 0x0070;
5355                 break;
5356         case 0x10ec0292:
5357                 alc_write_coef_idx(codec, 0x6b, 0xd429);
5358                 msleep(300);
5359                 val = alc_read_coef_idx(codec, 0x6c);
5360                 is_ctia = (val & 0x001c) == 0x001c;
5361                 break;
5362         case 0x10ec0293:
5363                 alc_process_coef_fw(codec, coef0293);
5364                 msleep(300);
5365                 val = alc_read_coef_idx(codec, 0x46);
5366                 is_ctia = (val & 0x0070) == 0x0070;
5367                 break;
5368         case 0x10ec0668:
5369                 alc_process_coef_fw(codec, coef0688);
5370                 msleep(300);
5371                 val = alc_read_coef_idx(codec, 0xbe);
5372                 is_ctia = (val & 0x1c02) == 0x1c02;
5373                 break;
5374         case 0x10ec0215:
5375         case 0x10ec0225:
5376         case 0x10ec0285:
5377         case 0x10ec0295:
5378         case 0x10ec0289:
5379         case 0x10ec0299:
5380                 snd_hda_codec_write(codec, 0x21, 0,
5381                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5382                 msleep(80);
5383                 snd_hda_codec_write(codec, 0x21, 0,
5384                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5385
5386                 alc_process_coef_fw(codec, alc225_pre_hsmode);
5387                 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5388                 val = alc_read_coef_idx(codec, 0x45);
5389                 if (val & (1 << 9)) {
5390                         alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5391                         alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5392                         msleep(800);
5393                         val = alc_read_coef_idx(codec, 0x46);
5394                         is_ctia = (val & 0x00f0) == 0x00f0;
5395                 } else {
5396                         alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5397                         alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5398                         msleep(800);
5399                         val = alc_read_coef_idx(codec, 0x46);
5400                         is_ctia = (val & 0x00f0) == 0x00f0;
5401                 }
5402                 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5403                 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5404                 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5405
5406                 snd_hda_codec_write(codec, 0x21, 0,
5407                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5408                 msleep(80);
5409                 snd_hda_codec_write(codec, 0x21, 0,
5410                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5411                 break;
5412         case 0x10ec0867:
5413                 is_ctia = true;
5414                 break;
5415         }
5416
5417         codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5418                     is_ctia ? "yes" : "no");
5419         spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5420 }
5421
5422 static void alc_update_headset_mode(struct hda_codec *codec)
5423 {
5424         struct alc_spec *spec = codec->spec;
5425
5426         hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5427         hda_nid_t hp_pin = alc_get_hp_pin(spec);
5428
5429         int new_headset_mode;
5430
5431         if (!snd_hda_jack_detect(codec, hp_pin))
5432                 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
5433         else if (mux_pin == spec->headset_mic_pin)
5434                 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
5435         else if (mux_pin == spec->headphone_mic_pin)
5436                 new_headset_mode = ALC_HEADSET_MODE_MIC;
5437         else
5438                 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
5439
5440         if (new_headset_mode == spec->current_headset_mode) {
5441                 snd_hda_gen_update_outputs(codec);
5442                 return;
5443         }
5444
5445         switch (new_headset_mode) {
5446         case ALC_HEADSET_MODE_UNPLUGGED:
5447                 alc_headset_mode_unplugged(codec);
5448                 spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5449                 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5450                 spec->gen.hp_jack_present = false;
5451                 break;
5452         case ALC_HEADSET_MODE_HEADSET:
5453                 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5454                         alc_determine_headset_type(codec);
5455                 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5456                         alc_headset_mode_ctia(codec);
5457                 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5458                         alc_headset_mode_omtp(codec);
5459                 spec->gen.hp_jack_present = true;
5460                 break;
5461         case ALC_HEADSET_MODE_MIC:
5462                 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5463                 spec->gen.hp_jack_present = false;
5464                 break;
5465         case ALC_HEADSET_MODE_HEADPHONE:
5466                 alc_headset_mode_default(codec);
5467                 spec->gen.hp_jack_present = true;
5468                 break;
5469         }
5470         if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5471                 snd_hda_set_pin_ctl_cache(codec, hp_pin,
5472                                           AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5473                 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5474                         snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5475                                                   PIN_VREFHIZ);
5476         }
5477         spec->current_headset_mode = new_headset_mode;
5478
5479         snd_hda_gen_update_outputs(codec);
5480 }
5481
5482 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5483                                          struct snd_kcontrol *kcontrol,
5484                                          struct snd_ctl_elem_value *ucontrol)
5485 {
5486         alc_update_headset_mode(codec);
5487 }
5488
5489 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5490                                        struct hda_jack_callback *jack)
5491 {
5492         snd_hda_gen_hp_automute(codec, jack);
5493         alc_update_headset_mode(codec);
5494 }
5495
5496 static void alc_probe_headset_mode(struct hda_codec *codec)
5497 {
5498         int i;
5499         struct alc_spec *spec = codec->spec;
5500         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5501
5502         /* Find mic pins */
5503         for (i = 0; i < cfg->num_inputs; i++) {
5504                 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5505                         spec->headset_mic_pin = cfg->inputs[i].pin;
5506                 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5507                         spec->headphone_mic_pin = cfg->inputs[i].pin;
5508         }
5509
5510         WARN_ON(spec->gen.cap_sync_hook);
5511         spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5512         spec->gen.automute_hook = alc_update_headset_mode;
5513         spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5514 }
5515
5516 static void alc_fixup_headset_mode(struct hda_codec *codec,
5517                                 const struct hda_fixup *fix, int action)
5518 {
5519         struct alc_spec *spec = codec->spec;
5520
5521         switch (action) {
5522         case HDA_FIXUP_ACT_PRE_PROBE:
5523                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5524                 break;
5525         case HDA_FIXUP_ACT_PROBE:
5526                 alc_probe_headset_mode(codec);
5527                 break;
5528         case HDA_FIXUP_ACT_INIT:
5529                 if (is_s3_resume(codec) || is_s4_resume(codec)) {
5530                         spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5531                         spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5532                 }
5533                 alc_update_headset_mode(codec);
5534                 break;
5535         }
5536 }
5537
5538 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5539                                 const struct hda_fixup *fix, int action)
5540 {
5541         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5542                 struct alc_spec *spec = codec->spec;
5543                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5544         }
5545         else
5546                 alc_fixup_headset_mode(codec, fix, action);
5547 }
5548
5549 static void alc255_set_default_jack_type(struct hda_codec *codec)
5550 {
5551         /* Set to iphone type */
5552         static const struct coef_fw alc255fw[] = {
5553                 WRITE_COEF(0x1b, 0x880b),
5554                 WRITE_COEF(0x45, 0xd089),
5555                 WRITE_COEF(0x1b, 0x080b),
5556                 WRITE_COEF(0x46, 0x0004),
5557                 WRITE_COEF(0x1b, 0x0c0b),
5558                 {}
5559         };
5560         static const struct coef_fw alc256fw[] = {
5561                 WRITE_COEF(0x1b, 0x884b),
5562                 WRITE_COEF(0x45, 0xd089),
5563                 WRITE_COEF(0x1b, 0x084b),
5564                 WRITE_COEF(0x46, 0x0004),
5565                 WRITE_COEF(0x1b, 0x0c4b),
5566                 {}
5567         };
5568         switch (codec->core.vendor_id) {
5569         case 0x10ec0255:
5570                 alc_process_coef_fw(codec, alc255fw);
5571                 break;
5572         case 0x10ec0230:
5573         case 0x10ec0236:
5574         case 0x10ec0256:
5575         case 0x19e58326:
5576                 alc_process_coef_fw(codec, alc256fw);
5577                 break;
5578         }
5579         msleep(30);
5580 }
5581
5582 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5583                                 const struct hda_fixup *fix, int action)
5584 {
5585         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5586                 alc255_set_default_jack_type(codec);
5587         }
5588         alc_fixup_headset_mode(codec, fix, action);
5589 }
5590
5591 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5592                                 const struct hda_fixup *fix, int action)
5593 {
5594         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5595                 struct alc_spec *spec = codec->spec;
5596                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5597                 alc255_set_default_jack_type(codec);
5598         } 
5599         else
5600                 alc_fixup_headset_mode(codec, fix, action);
5601 }
5602
5603 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5604                                        struct hda_jack_callback *jack)
5605 {
5606         struct alc_spec *spec = codec->spec;
5607
5608         alc_update_headset_jack_cb(codec, jack);
5609         /* Headset Mic enable or disable, only for Dell Dino */
5610         alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5611 }
5612
5613 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5614                                 const struct hda_fixup *fix, int action)
5615 {
5616         alc_fixup_headset_mode(codec, fix, action);
5617         if (action == HDA_FIXUP_ACT_PROBE) {
5618                 struct alc_spec *spec = codec->spec;
5619                 /* toggled via hp_automute_hook */
5620                 spec->gpio_mask |= 0x40;
5621                 spec->gpio_dir |= 0x40;
5622                 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5623         }
5624 }
5625
5626 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5627                                         const struct hda_fixup *fix, int action)
5628 {
5629         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5630                 struct alc_spec *spec = codec->spec;
5631                 spec->gen.auto_mute_via_amp = 1;
5632         }
5633 }
5634
5635 static void alc_fixup_no_shutup(struct hda_codec *codec,
5636                                 const struct hda_fixup *fix, int action)
5637 {
5638         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5639                 struct alc_spec *spec = codec->spec;
5640                 spec->no_shutup_pins = 1;
5641         }
5642 }
5643
5644 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5645                                     const struct hda_fixup *fix, int action)
5646 {
5647         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5648                 struct alc_spec *spec = codec->spec;
5649                 /* Disable AA-loopback as it causes white noise */
5650                 spec->gen.mixer_nid = 0;
5651         }
5652 }
5653
5654 /* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
5655 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5656                                   const struct hda_fixup *fix, int action)
5657 {
5658         static const struct hda_pintbl pincfgs[] = {
5659                 { 0x16, 0x21211010 }, /* dock headphone */
5660                 { 0x19, 0x21a11010 }, /* dock mic */
5661                 { }
5662         };
5663         struct alc_spec *spec = codec->spec;
5664
5665         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5666                 spec->reboot_notify = snd_hda_gen_reboot_notify; /* reduce noise */
5667                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5668                 codec->power_save_node = 0; /* avoid click noises */
5669                 snd_hda_apply_pincfgs(codec, pincfgs);
5670         }
5671 }
5672
5673 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5674                                   const struct hda_fixup *fix, int action)
5675 {
5676         static const struct hda_pintbl pincfgs[] = {
5677                 { 0x17, 0x21211010 }, /* dock headphone */
5678                 { 0x19, 0x21a11010 }, /* dock mic */
5679                 { }
5680         };
5681         struct alc_spec *spec = codec->spec;
5682
5683         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5684                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5685                 snd_hda_apply_pincfgs(codec, pincfgs);
5686         } else if (action == HDA_FIXUP_ACT_INIT) {
5687                 /* Enable DOCK device */
5688                 snd_hda_codec_write(codec, 0x17, 0,
5689                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5690                 /* Enable DOCK device */
5691                 snd_hda_codec_write(codec, 0x19, 0,
5692                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5693         }
5694 }
5695
5696 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
5697                                   const struct hda_fixup *fix, int action)
5698 {
5699         /* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5700          * the speaker output becomes too low by some reason on Thinkpads with
5701          * ALC298 codec
5702          */
5703         static const hda_nid_t preferred_pairs[] = {
5704                 0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5705                 0
5706         };
5707         struct alc_spec *spec = codec->spec;
5708
5709         if (action == HDA_FIXUP_ACT_PRE_PROBE)
5710                 spec->gen.preferred_dacs = preferred_pairs;
5711 }
5712
5713 static void alc295_fixup_asus_dacs(struct hda_codec *codec,
5714                                    const struct hda_fixup *fix, int action)
5715 {
5716         static const hda_nid_t preferred_pairs[] = {
5717                 0x17, 0x02, 0x21, 0x03, 0
5718         };
5719         struct alc_spec *spec = codec->spec;
5720
5721         if (action == HDA_FIXUP_ACT_PRE_PROBE)
5722                 spec->gen.preferred_dacs = preferred_pairs;
5723 }
5724
5725 static void alc_shutup_dell_xps13(struct hda_codec *codec)
5726 {
5727         struct alc_spec *spec = codec->spec;
5728         int hp_pin = alc_get_hp_pin(spec);
5729
5730         /* Prevent pop noises when headphones are plugged in */
5731         snd_hda_codec_write(codec, hp_pin, 0,
5732                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5733         msleep(20);
5734 }
5735
5736 static void alc_fixup_dell_xps13(struct hda_codec *codec,
5737                                 const struct hda_fixup *fix, int action)
5738 {
5739         struct alc_spec *spec = codec->spec;
5740         struct hda_input_mux *imux = &spec->gen.input_mux;
5741         int i;
5742
5743         switch (action) {
5744         case HDA_FIXUP_ACT_PRE_PROBE:
5745                 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
5746                  * it causes a click noise at start up
5747                  */
5748                 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5749                 spec->shutup = alc_shutup_dell_xps13;
5750                 break;
5751         case HDA_FIXUP_ACT_PROBE:
5752                 /* Make the internal mic the default input source. */
5753                 for (i = 0; i < imux->num_items; i++) {
5754                         if (spec->gen.imux_pins[i] == 0x12) {
5755                                 spec->gen.cur_mux[0] = i;
5756                                 break;
5757                         }
5758                 }
5759                 break;
5760         }
5761 }
5762
5763 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5764                                 const struct hda_fixup *fix, int action)
5765 {
5766         struct alc_spec *spec = codec->spec;
5767
5768         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5769                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5770                 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
5771
5772                 /* Disable boost for mic-in permanently. (This code is only called
5773                    from quirks that guarantee that the headphone is at NID 0x1b.) */
5774                 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5775                 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
5776         } else
5777                 alc_fixup_headset_mode(codec, fix, action);
5778 }
5779
5780 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5781                                 const struct hda_fixup *fix, int action)
5782 {
5783         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5784                 alc_write_coef_idx(codec, 0xc4, 0x8000);
5785                 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
5786                 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
5787         }
5788         alc_fixup_headset_mode(codec, fix, action);
5789 }
5790
5791 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
5792 static int find_ext_mic_pin(struct hda_codec *codec)
5793 {
5794         struct alc_spec *spec = codec->spec;
5795         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5796         hda_nid_t nid;
5797         unsigned int defcfg;
5798         int i;
5799
5800         for (i = 0; i < cfg->num_inputs; i++) {
5801                 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5802                         continue;
5803                 nid = cfg->inputs[i].pin;
5804                 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5805                 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
5806                         continue;
5807                 return nid;
5808         }
5809
5810         return 0;
5811 }
5812
5813 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
5814                                     const struct hda_fixup *fix,
5815                                     int action)
5816 {
5817         struct alc_spec *spec = codec->spec;
5818
5819         if (action == HDA_FIXUP_ACT_PROBE) {
5820                 int mic_pin = find_ext_mic_pin(codec);
5821                 int hp_pin = alc_get_hp_pin(spec);
5822
5823                 if (snd_BUG_ON(!mic_pin || !hp_pin))
5824                         return;
5825                 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
5826         }
5827 }
5828
5829 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
5830                                              const struct hda_fixup *fix,
5831                                              int action)
5832 {
5833         struct alc_spec *spec = codec->spec;
5834         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5835         int i;
5836
5837         /* The mic boosts on level 2 and 3 are too noisy
5838            on the internal mic input.
5839            Therefore limit the boost to 0 or 1. */
5840
5841         if (action != HDA_FIXUP_ACT_PROBE)
5842                 return;
5843
5844         for (i = 0; i < cfg->num_inputs; i++) {
5845                 hda_nid_t nid = cfg->inputs[i].pin;
5846                 unsigned int defcfg;
5847                 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5848                         continue;
5849                 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5850                 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
5851                         continue;
5852
5853                 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
5854                                           (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
5855                                           (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5856                                           (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
5857                                           (0 << AC_AMPCAP_MUTE_SHIFT));
5858         }
5859 }
5860
5861 static void alc283_hp_automute_hook(struct hda_codec *codec,
5862                                     struct hda_jack_callback *jack)
5863 {
5864         struct alc_spec *spec = codec->spec;
5865         int vref;
5866
5867         msleep(200);
5868         snd_hda_gen_hp_automute(codec, jack);
5869
5870         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
5871
5872         msleep(600);
5873         snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5874                             vref);
5875 }
5876
5877 static void alc283_fixup_chromebook(struct hda_codec *codec,
5878                                     const struct hda_fixup *fix, int action)
5879 {
5880         struct alc_spec *spec = codec->spec;
5881
5882         switch (action) {
5883         case HDA_FIXUP_ACT_PRE_PROBE:
5884                 snd_hda_override_wcaps(codec, 0x03, 0);
5885                 /* Disable AA-loopback as it causes white noise */
5886                 spec->gen.mixer_nid = 0;
5887                 break;
5888         case HDA_FIXUP_ACT_INIT:
5889                 /* MIC2-VREF control */
5890                 /* Set to manual mode */
5891                 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5892                 /* Enable Line1 input control by verb */
5893                 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
5894                 break;
5895         }
5896 }
5897
5898 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
5899                                     const struct hda_fixup *fix, int action)
5900 {
5901         struct alc_spec *spec = codec->spec;
5902
5903         switch (action) {
5904         case HDA_FIXUP_ACT_PRE_PROBE:
5905                 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
5906                 break;
5907         case HDA_FIXUP_ACT_INIT:
5908                 /* MIC2-VREF control */
5909                 /* Set to manual mode */
5910                 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5911                 break;
5912         }
5913 }
5914
5915 /* mute tablet speaker pin (0x14) via dock plugging in addition */
5916 static void asus_tx300_automute(struct hda_codec *codec)
5917 {
5918         struct alc_spec *spec = codec->spec;
5919         snd_hda_gen_update_outputs(codec);
5920         if (snd_hda_jack_detect(codec, 0x1b))
5921                 spec->gen.mute_bits |= (1ULL << 0x14);
5922 }
5923
5924 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
5925                                     const struct hda_fixup *fix, int action)
5926 {
5927         struct alc_spec *spec = codec->spec;
5928         static const struct hda_pintbl dock_pins[] = {
5929                 { 0x1b, 0x21114000 }, /* dock speaker pin */
5930                 {}
5931         };
5932
5933         switch (action) {
5934         case HDA_FIXUP_ACT_PRE_PROBE:
5935                 spec->init_amp = ALC_INIT_DEFAULT;
5936                 /* TX300 needs to set up GPIO2 for the speaker amp */
5937                 alc_setup_gpio(codec, 0x04);
5938                 snd_hda_apply_pincfgs(codec, dock_pins);
5939                 spec->gen.auto_mute_via_amp = 1;
5940                 spec->gen.automute_hook = asus_tx300_automute;
5941                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
5942                                                     snd_hda_gen_hp_automute);
5943                 break;
5944         case HDA_FIXUP_ACT_PROBE:
5945                 spec->init_amp = ALC_INIT_DEFAULT;
5946                 break;
5947         case HDA_FIXUP_ACT_BUILD:
5948                 /* this is a bit tricky; give more sane names for the main
5949                  * (tablet) speaker and the dock speaker, respectively
5950                  */
5951                 rename_ctl(codec, "Speaker Playback Switch",
5952                            "Dock Speaker Playback Switch");
5953                 rename_ctl(codec, "Bass Speaker Playback Switch",
5954                            "Speaker Playback Switch");
5955                 break;
5956         }
5957 }
5958
5959 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
5960                                        const struct hda_fixup *fix, int action)
5961 {
5962         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5963                 /* DAC node 0x03 is giving mono output. We therefore want to
5964                    make sure 0x14 (front speaker) and 0x15 (headphones) use the
5965                    stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
5966                 static const hda_nid_t conn1[] = { 0x0c };
5967                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
5968                 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
5969         }
5970 }
5971
5972 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
5973                                         const struct hda_fixup *fix, int action)
5974 {
5975         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5976                 /* The speaker is routed to the Node 0x06 by a mistake, as a result
5977                    we can't adjust the speaker's volume since this node does not has
5978                    Amp-out capability. we change the speaker's route to:
5979                    Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
5980                    Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
5981                    speaker's volume now. */
5982
5983                 static const hda_nid_t conn1[] = { 0x0c };
5984                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
5985         }
5986 }
5987
5988 /* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
5989 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
5990                                       const struct hda_fixup *fix, int action)
5991 {
5992         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5993                 static const hda_nid_t conn[] = { 0x02, 0x03 };
5994                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
5995         }
5996 }
5997
5998 /* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
5999 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6000                                           const struct hda_fixup *fix, int action)
6001 {
6002         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6003                 static const hda_nid_t conn[] = { 0x02 };
6004                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6005         }
6006 }
6007
6008 /* Hook to update amp GPIO4 for automute */
6009 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6010                                           struct hda_jack_callback *jack)
6011 {
6012         struct alc_spec *spec = codec->spec;
6013
6014         snd_hda_gen_hp_automute(codec, jack);
6015         /* mute_led_polarity is set to 0, so we pass inverted value here */
6016         alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6017                             !spec->gen.hp_jack_present);
6018 }
6019
6020 /* Manage GPIOs for HP EliteBook Folio 9480m.
6021  *
6022  * GPIO4 is the headphone amplifier power control
6023  * GPIO3 is the audio output mute indicator LED
6024  */
6025
6026 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6027                                   const struct hda_fixup *fix,
6028                                   int action)
6029 {
6030         struct alc_spec *spec = codec->spec;
6031
6032         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6033         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6034                 /* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
6035                 spec->gpio_mask |= 0x10;
6036                 spec->gpio_dir |= 0x10;
6037                 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
6038         }
6039 }
6040
6041 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6042                                    const struct hda_fixup *fix,
6043                                    int action)
6044 {
6045         struct alc_spec *spec = codec->spec;
6046
6047         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6048                 spec->gpio_mask |= 0x04;
6049                 spec->gpio_dir |= 0x04;
6050                 /* set data bit low */
6051         }
6052 }
6053
6054 /* Quirk for Thinkpad X1 7th and 8th Gen
6055  * The following fixed routing needed
6056  * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
6057  * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
6058  * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
6059  */
6060 static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6061                                           const struct hda_fixup *fix, int action)
6062 {
6063         static const hda_nid_t conn[] = { 0x02, 0x03 }; /* exclude 0x06 */
6064         static const hda_nid_t preferred_pairs[] = {
6065                 0x14, 0x02, 0x17, 0x03, 0x21, 0x03, 0
6066         };
6067         struct alc_spec *spec = codec->spec;
6068
6069         switch (action) {
6070         case HDA_FIXUP_ACT_PRE_PROBE:
6071                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6072                 spec->gen.preferred_dacs = preferred_pairs;
6073                 break;
6074         case HDA_FIXUP_ACT_BUILD:
6075                 /* The generic parser creates somewhat unintuitive volume ctls
6076                  * with the fixed routing above, and the shared DAC2 may be
6077                  * confusing for PA.
6078                  * Rename those to unique names so that PA doesn't touch them
6079                  * and use only Master volume.
6080                  */
6081                 rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6082                 rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6083                 break;
6084         }
6085 }
6086
6087 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6088                                          const struct hda_fixup *fix,
6089                                          int action)
6090 {
6091         alc_fixup_dual_codecs(codec, fix, action);
6092         switch (action) {
6093         case HDA_FIXUP_ACT_PRE_PROBE:
6094                 /* override card longname to provide a unique UCM profile */
6095                 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6096                 break;
6097         case HDA_FIXUP_ACT_BUILD:
6098                 /* rename Capture controls depending on the codec */
6099                 rename_ctl(codec, "Capture Volume",
6100                            codec->addr == 0 ?
6101                            "Rear-Panel Capture Volume" :
6102                            "Front-Panel Capture Volume");
6103                 rename_ctl(codec, "Capture Switch",
6104                            codec->addr == 0 ?
6105                            "Rear-Panel Capture Switch" :
6106                            "Front-Panel Capture Switch");
6107                 break;
6108         }
6109 }
6110
6111 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6112                                       const struct hda_fixup *fix, int action)
6113 {
6114         if (action != HDA_FIXUP_ACT_PRE_PROBE)
6115                 return;
6116
6117         codec->power_save_node = 1;
6118 }
6119
6120 /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
6121 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6122                                     const struct hda_fixup *fix, int action)
6123 {
6124         struct alc_spec *spec = codec->spec;
6125         static const hda_nid_t preferred_pairs[] = {
6126                 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
6127                 0
6128         };
6129
6130         if (action != HDA_FIXUP_ACT_PRE_PROBE)
6131                 return;
6132
6133         spec->gen.preferred_dacs = preferred_pairs;
6134         spec->gen.auto_mute_via_amp = 1;
6135         codec->power_save_node = 0;
6136 }
6137
6138 /* avoid DAC 0x06 for bass speaker 0x17; it has no volume control */
6139 static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6140                                     const struct hda_fixup *fix, int action)
6141 {
6142         static const hda_nid_t preferred_pairs[] = {
6143                 0x14, 0x02, 0x17, 0x02, 0x21, 0x03, 0
6144         };
6145         struct alc_spec *spec = codec->spec;
6146
6147         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6148                 spec->gen.preferred_dacs = preferred_pairs;
6149                 spec->gen.obey_preferred_dacs = 1;
6150         }
6151 }
6152
6153 /* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
6154 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6155                               const struct hda_fixup *fix, int action)
6156 {
6157         if (action != HDA_FIXUP_ACT_PRE_PROBE)
6158                 return;
6159
6160         snd_hda_override_wcaps(codec, 0x03, 0);
6161 }
6162
6163 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6164 {
6165         switch (codec->core.vendor_id) {
6166         case 0x10ec0274:
6167         case 0x10ec0294:
6168         case 0x10ec0225:
6169         case 0x10ec0295:
6170         case 0x10ec0299:
6171                 alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6172                 alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6173                 break;
6174         case 0x10ec0230:
6175         case 0x10ec0235:
6176         case 0x10ec0236:
6177         case 0x10ec0255:
6178         case 0x10ec0256:
6179         case 0x19e58326:
6180                 alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6181                 alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6182                 break;
6183         }
6184 }
6185
6186 static void alc295_fixup_chromebook(struct hda_codec *codec,
6187                                     const struct hda_fixup *fix, int action)
6188 {
6189         struct alc_spec *spec = codec->spec;
6190
6191         switch (action) {
6192         case HDA_FIXUP_ACT_PRE_PROBE:
6193                 spec->ultra_low_power = true;
6194                 break;
6195         case HDA_FIXUP_ACT_INIT:
6196                 alc_combo_jack_hp_jd_restart(codec);
6197                 break;
6198         }
6199 }
6200
6201 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6202                                   const struct hda_fixup *fix, int action)
6203 {
6204         if (action == HDA_FIXUP_ACT_PRE_PROBE)
6205                 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6206 }
6207
6208
6209 static void alc294_gx502_toggle_output(struct hda_codec *codec,
6210                                         struct hda_jack_callback *cb)
6211 {
6212         /* The Windows driver sets the codec up in a very different way where
6213          * it appears to leave 0x10 = 0x8a20 set. For Linux we need to toggle it
6214          */
6215         if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6216                 alc_write_coef_idx(codec, 0x10, 0x8a20);
6217         else
6218                 alc_write_coef_idx(codec, 0x10, 0x0a20);
6219 }
6220
6221 static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6222                                         const struct hda_fixup *fix, int action)
6223 {
6224         /* Pin 0x21: headphones/headset mic */
6225         if (!is_jack_detectable(codec, 0x21))
6226                 return;
6227
6228         switch (action) {
6229         case HDA_FIXUP_ACT_PRE_PROBE:
6230                 snd_hda_jack_detect_enable_callback(codec, 0x21,
6231                                 alc294_gx502_toggle_output);
6232                 break;
6233         case HDA_FIXUP_ACT_INIT:
6234                 /* Make sure to start in a correct state, i.e. if
6235                  * headphones have been plugged in before powering up the system
6236                  */
6237                 alc294_gx502_toggle_output(codec, NULL);
6238                 break;
6239         }
6240 }
6241
6242 static void alc294_gu502_toggle_output(struct hda_codec *codec,
6243                                        struct hda_jack_callback *cb)
6244 {
6245         /* Windows sets 0x10 to 0x8420 for Node 0x20 which is
6246          * responsible from changes between speakers and headphones
6247          */
6248         if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6249                 alc_write_coef_idx(codec, 0x10, 0x8420);
6250         else
6251                 alc_write_coef_idx(codec, 0x10, 0x0a20);
6252 }
6253
6254 static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6255                                   const struct hda_fixup *fix, int action)
6256 {
6257         if (!is_jack_detectable(codec, 0x21))
6258                 return;
6259
6260         switch (action) {
6261         case HDA_FIXUP_ACT_PRE_PROBE:
6262                 snd_hda_jack_detect_enable_callback(codec, 0x21,
6263                                 alc294_gu502_toggle_output);
6264                 break;
6265         case HDA_FIXUP_ACT_INIT:
6266                 alc294_gu502_toggle_output(codec, NULL);
6267                 break;
6268         }
6269 }
6270
6271 static void  alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6272                               const struct hda_fixup *fix, int action)
6273 {
6274         if (action != HDA_FIXUP_ACT_INIT)
6275                 return;
6276
6277         msleep(100);
6278         alc_write_coef_idx(codec, 0x65, 0x0);
6279 }
6280
6281 static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6282                                     const struct hda_fixup *fix, int action)
6283 {
6284         switch (action) {
6285         case HDA_FIXUP_ACT_INIT:
6286                 alc_combo_jack_hp_jd_restart(codec);
6287                 break;
6288         }
6289 }
6290
6291 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6292                                           const struct hda_fixup *fix, int action)
6293 {
6294         static const hda_nid_t conn[] = { 0x02 };
6295         static const struct hda_pintbl pincfgs[] = {
6296                 { 0x14, 0x90170110 },  /* rear speaker */
6297                 { }
6298         };
6299
6300         switch (action) {
6301         case HDA_FIXUP_ACT_PRE_PROBE:
6302                 snd_hda_apply_pincfgs(codec, pincfgs);
6303                 /* force front speaker to DAC1 */
6304                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6305                 break;
6306         }
6307 }
6308
6309 /* for hda_fixup_thinkpad_acpi() */
6310 #include "thinkpad_helper.c"
6311
6312 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6313                                     const struct hda_fixup *fix, int action)
6314 {
6315         alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6316         hda_fixup_thinkpad_acpi(codec, fix, action);
6317 }
6318
6319 /* for alc295_fixup_hp_top_speakers */
6320 #include "hp_x360_helper.c"
6321
6322 enum {
6323         ALC269_FIXUP_GPIO2,
6324         ALC269_FIXUP_SONY_VAIO,
6325         ALC275_FIXUP_SONY_VAIO_GPIO2,
6326         ALC269_FIXUP_DELL_M101Z,
6327         ALC269_FIXUP_SKU_IGNORE,
6328         ALC269_FIXUP_ASUS_G73JW,
6329         ALC269_FIXUP_LENOVO_EAPD,
6330         ALC275_FIXUP_SONY_HWEQ,
6331         ALC275_FIXUP_SONY_DISABLE_AAMIX,
6332         ALC271_FIXUP_DMIC,
6333         ALC269_FIXUP_PCM_44K,
6334         ALC269_FIXUP_STEREO_DMIC,
6335         ALC269_FIXUP_HEADSET_MIC,
6336         ALC269_FIXUP_QUANTA_MUTE,
6337         ALC269_FIXUP_LIFEBOOK,
6338         ALC269_FIXUP_LIFEBOOK_EXTMIC,
6339         ALC269_FIXUP_LIFEBOOK_HP_PIN,
6340         ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
6341         ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
6342         ALC269_FIXUP_AMIC,
6343         ALC269_FIXUP_DMIC,
6344         ALC269VB_FIXUP_AMIC,
6345         ALC269VB_FIXUP_DMIC,
6346         ALC269_FIXUP_HP_MUTE_LED,
6347         ALC269_FIXUP_HP_MUTE_LED_MIC1,
6348         ALC269_FIXUP_HP_MUTE_LED_MIC2,
6349         ALC269_FIXUP_HP_MUTE_LED_MIC3,
6350         ALC269_FIXUP_HP_GPIO_LED,
6351         ALC269_FIXUP_HP_GPIO_MIC1_LED,
6352         ALC269_FIXUP_HP_LINE1_MIC1_LED,
6353         ALC269_FIXUP_INV_DMIC,
6354         ALC269_FIXUP_LENOVO_DOCK,
6355         ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
6356         ALC269_FIXUP_NO_SHUTUP,
6357         ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
6358         ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
6359         ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6360         ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
6361         ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6362         ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6363         ALC269_FIXUP_HEADSET_MODE,
6364         ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
6365         ALC269_FIXUP_ASPIRE_HEADSET_MIC,
6366         ALC269_FIXUP_ASUS_X101_FUNC,
6367         ALC269_FIXUP_ASUS_X101_VERB,
6368         ALC269_FIXUP_ASUS_X101,
6369         ALC271_FIXUP_AMIC_MIC2,
6370         ALC271_FIXUP_HP_GATE_MIC_JACK,
6371         ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
6372         ALC269_FIXUP_ACER_AC700,
6373         ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
6374         ALC269VB_FIXUP_ASUS_ZENBOOK,
6375         ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
6376         ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE,
6377         ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
6378         ALC269VB_FIXUP_ORDISSIMO_EVE2,
6379         ALC283_FIXUP_CHROME_BOOK,
6380         ALC283_FIXUP_SENSE_COMBO_JACK,
6381         ALC282_FIXUP_ASUS_TX300,
6382         ALC283_FIXUP_INT_MIC,
6383         ALC290_FIXUP_MONO_SPEAKERS,
6384         ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6385         ALC290_FIXUP_SUBWOOFER,
6386         ALC290_FIXUP_SUBWOOFER_HSJACK,
6387         ALC269_FIXUP_THINKPAD_ACPI,
6388         ALC269_FIXUP_DMIC_THINKPAD_ACPI,
6389         ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6390         ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6391         ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6392         ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
6393         ALC255_FIXUP_HEADSET_MODE,
6394         ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
6395         ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
6396         ALC292_FIXUP_TPT440_DOCK,
6397         ALC292_FIXUP_TPT440,
6398         ALC283_FIXUP_HEADSET_MIC,
6399         ALC255_FIXUP_MIC_MUTE_LED,
6400         ALC282_FIXUP_ASPIRE_V5_PINS,
6401         ALC269VB_FIXUP_ASPIRE_E1_COEF,
6402         ALC280_FIXUP_HP_GPIO4,
6403         ALC286_FIXUP_HP_GPIO_LED,
6404         ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
6405         ALC280_FIXUP_HP_DOCK_PINS,
6406         ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
6407         ALC280_FIXUP_HP_9480M,
6408         ALC288_FIXUP_DELL_HEADSET_MODE,
6409         ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
6410         ALC288_FIXUP_DELL_XPS_13,
6411         ALC288_FIXUP_DISABLE_AAMIX,
6412         ALC292_FIXUP_DELL_E7X_AAMIX,
6413         ALC292_FIXUP_DELL_E7X,
6414         ALC292_FIXUP_DISABLE_AAMIX,
6415         ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
6416         ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
6417         ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6418         ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6419         ALC275_FIXUP_DELL_XPS,
6420         ALC293_FIXUP_LENOVO_SPK_NOISE,
6421         ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
6422         ALC255_FIXUP_DELL_SPK_NOISE,
6423         ALC225_FIXUP_DISABLE_MIC_VREF,
6424         ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6425         ALC295_FIXUP_DISABLE_DAC3,
6426         ALC285_FIXUP_SPEAKER2_TO_DAC1,
6427         ALC280_FIXUP_HP_HEADSET_MIC,
6428         ALC221_FIXUP_HP_FRONT_MIC,
6429         ALC292_FIXUP_TPT460,
6430         ALC298_FIXUP_SPK_VOLUME,
6431         ALC298_FIXUP_LENOVO_SPK_VOLUME,
6432         ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
6433         ALC269_FIXUP_ATIV_BOOK_8,
6434         ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE,
6435         ALC221_FIXUP_HP_MIC_NO_PRESENCE,
6436         ALC256_FIXUP_ASUS_HEADSET_MODE,
6437         ALC256_FIXUP_ASUS_MIC,
6438         ALC256_FIXUP_ASUS_AIO_GPIO2,
6439         ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
6440         ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
6441         ALC233_FIXUP_LENOVO_MULTI_CODECS,
6442         ALC233_FIXUP_ACER_HEADSET_MIC,
6443         ALC294_FIXUP_LENOVO_MIC_LOCATION,
6444         ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
6445         ALC225_FIXUP_S3_POP_NOISE,
6446         ALC700_FIXUP_INTEL_REFERENCE,
6447         ALC274_FIXUP_DELL_BIND_DACS,
6448         ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6449         ALC298_FIXUP_TPT470_DOCK_FIX,
6450         ALC298_FIXUP_TPT470_DOCK,
6451         ALC255_FIXUP_DUMMY_LINEOUT_VERB,
6452         ALC255_FIXUP_DELL_HEADSET_MIC,
6453         ALC256_FIXUP_HUAWEI_MACH_WX9_PINS,
6454         ALC298_FIXUP_HUAWEI_MBX_STEREO,
6455         ALC295_FIXUP_HP_X360,
6456         ALC221_FIXUP_HP_HEADSET_MIC,
6457         ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
6458         ALC295_FIXUP_HP_AUTO_MUTE,
6459         ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
6460         ALC294_FIXUP_ASUS_MIC,
6461         ALC294_FIXUP_ASUS_HEADSET_MIC,
6462         ALC294_FIXUP_ASUS_SPK,
6463         ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
6464         ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
6465         ALC255_FIXUP_ACER_HEADSET_MIC,
6466         ALC295_FIXUP_CHROME_BOOK,
6467         ALC225_FIXUP_HEADSET_JACK,
6468         ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
6469         ALC225_FIXUP_WYSE_AUTO_MUTE,
6470         ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
6471         ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
6472         ALC256_FIXUP_ASUS_HEADSET_MIC,
6473         ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
6474         ALC299_FIXUP_PREDATOR_SPK,
6475         ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
6476         ALC289_FIXUP_DELL_SPK2,
6477         ALC289_FIXUP_DUAL_SPK,
6478         ALC294_FIXUP_SPK2_TO_DAC1,
6479         ALC294_FIXUP_ASUS_DUAL_SPK,
6480         ALC285_FIXUP_THINKPAD_X1_GEN7,
6481         ALC285_FIXUP_THINKPAD_HEADSET_JACK,
6482         ALC294_FIXUP_ASUS_HPE,
6483         ALC294_FIXUP_ASUS_COEF_1B,
6484         ALC294_FIXUP_ASUS_GX502_HP,
6485         ALC294_FIXUP_ASUS_GX502_PINS,
6486         ALC294_FIXUP_ASUS_GX502_VERBS,
6487         ALC294_FIXUP_ASUS_GU502_HP,
6488         ALC294_FIXUP_ASUS_GU502_PINS,
6489         ALC294_FIXUP_ASUS_GU502_VERBS,
6490         ALC294_FIXUP_ASUS_G513_PINS,
6491         ALC285_FIXUP_ASUS_G533Z_PINS,
6492         ALC285_FIXUP_HP_GPIO_LED,
6493         ALC285_FIXUP_HP_MUTE_LED,
6494         ALC236_FIXUP_HP_GPIO_LED,
6495         ALC236_FIXUP_HP_MUTE_LED,
6496         ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6497         ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6498         ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
6499         ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
6500         ALC269VC_FIXUP_ACER_HEADSET_MIC,
6501         ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE,
6502         ALC289_FIXUP_ASUS_GA401,
6503         ALC289_FIXUP_ASUS_GA502,
6504         ALC256_FIXUP_ACER_MIC_NO_PRESENCE,
6505         ALC285_FIXUP_HP_GPIO_AMP_INIT,
6506         ALC269_FIXUP_CZC_B20,
6507         ALC269_FIXUP_CZC_TMI,
6508         ALC269_FIXUP_CZC_L101,
6509         ALC269_FIXUP_LEMOTE_A1802,
6510         ALC269_FIXUP_LEMOTE_A190X,
6511         ALC256_FIXUP_INTEL_NUC8_RUGGED,
6512         ALC233_FIXUP_INTEL_NUC8_DMIC,
6513         ALC233_FIXUP_INTEL_NUC8_BOOST,
6514         ALC256_FIXUP_INTEL_NUC10,
6515         ALC255_FIXUP_XIAOMI_HEADSET_MIC,
6516         ALC274_FIXUP_HP_MIC,
6517         ALC274_FIXUP_HP_HEADSET_MIC,
6518         ALC256_FIXUP_ASUS_HPE,
6519         ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
6520         ALC295_FIXUP_ASUS_DACS,
6521         ALC295_FIXUP_HP_OMEN,
6522         ALC285_FIXUP_HP_SPECTRE_X360,
6523 };
6524
6525 static const struct hda_fixup alc269_fixups[] = {
6526         [ALC269_FIXUP_GPIO2] = {
6527                 .type = HDA_FIXUP_FUNC,
6528                 .v.func = alc_fixup_gpio2,
6529         },
6530         [ALC269_FIXUP_SONY_VAIO] = {
6531                 .type = HDA_FIXUP_PINCTLS,
6532                 .v.pins = (const struct hda_pintbl[]) {
6533                         {0x19, PIN_VREFGRD},
6534                         {}
6535                 }
6536         },
6537         [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
6538                 .type = HDA_FIXUP_FUNC,
6539                 .v.func = alc275_fixup_gpio4_off,
6540                 .chained = true,
6541                 .chain_id = ALC269_FIXUP_SONY_VAIO
6542         },
6543         [ALC269_FIXUP_DELL_M101Z] = {
6544                 .type = HDA_FIXUP_VERBS,
6545                 .v.verbs = (const struct hda_verb[]) {
6546                         /* Enables internal speaker */
6547                         {0x20, AC_VERB_SET_COEF_INDEX, 13},
6548                         {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
6549                         {}
6550                 }
6551         },
6552         [ALC269_FIXUP_SKU_IGNORE] = {
6553                 .type = HDA_FIXUP_FUNC,
6554                 .v.func = alc_fixup_sku_ignore,
6555         },
6556         [ALC269_FIXUP_ASUS_G73JW] = {
6557                 .type = HDA_FIXUP_PINS,
6558                 .v.pins = (const struct hda_pintbl[]) {
6559                         { 0x17, 0x99130111 }, /* subwoofer */
6560                         { }
6561                 }
6562         },
6563         [ALC269_FIXUP_LENOVO_EAPD] = {
6564                 .type = HDA_FIXUP_VERBS,
6565                 .v.verbs = (const struct hda_verb[]) {
6566                         {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
6567                         {}
6568                 }
6569         },
6570         [ALC275_FIXUP_SONY_HWEQ] = {
6571                 .type = HDA_FIXUP_FUNC,
6572                 .v.func = alc269_fixup_hweq,
6573                 .chained = true,
6574                 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
6575         },
6576         [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
6577                 .type = HDA_FIXUP_FUNC,
6578                 .v.func = alc_fixup_disable_aamix,
6579                 .chained = true,
6580                 .chain_id = ALC269_FIXUP_SONY_VAIO
6581         },
6582         [ALC271_FIXUP_DMIC] = {
6583                 .type = HDA_FIXUP_FUNC,
6584                 .v.func = alc271_fixup_dmic,
6585         },
6586         [ALC269_FIXUP_PCM_44K] = {
6587                 .type = HDA_FIXUP_FUNC,
6588                 .v.func = alc269_fixup_pcm_44k,
6589                 .chained = true,
6590                 .chain_id = ALC269_FIXUP_QUANTA_MUTE
6591         },
6592         [ALC269_FIXUP_STEREO_DMIC] = {
6593                 .type = HDA_FIXUP_FUNC,
6594                 .v.func = alc269_fixup_stereo_dmic,
6595         },
6596         [ALC269_FIXUP_HEADSET_MIC] = {
6597                 .type = HDA_FIXUP_FUNC,
6598                 .v.func = alc269_fixup_headset_mic,
6599         },
6600         [ALC269_FIXUP_QUANTA_MUTE] = {
6601                 .type = HDA_FIXUP_FUNC,
6602                 .v.func = alc269_fixup_quanta_mute,
6603         },
6604         [ALC269_FIXUP_LIFEBOOK] = {
6605                 .type = HDA_FIXUP_PINS,
6606                 .v.pins = (const struct hda_pintbl[]) {
6607                         { 0x1a, 0x2101103f }, /* dock line-out */
6608                         { 0x1b, 0x23a11040 }, /* dock mic-in */
6609                         { }
6610                 },
6611                 .chained = true,
6612                 .chain_id = ALC269_FIXUP_QUANTA_MUTE
6613         },
6614         [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
6615                 .type = HDA_FIXUP_PINS,
6616                 .v.pins = (const struct hda_pintbl[]) {
6617                         { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
6618                         { }
6619                 },
6620         },
6621         [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
6622                 .type = HDA_FIXUP_PINS,
6623                 .v.pins = (const struct hda_pintbl[]) {
6624                         { 0x21, 0x0221102f }, /* HP out */
6625                         { }
6626                 },
6627         },
6628         [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
6629                 .type = HDA_FIXUP_FUNC,
6630                 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
6631         },
6632         [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
6633                 .type = HDA_FIXUP_FUNC,
6634                 .v.func = alc269_fixup_pincfg_U7x7_headset_mic,
6635         },
6636         [ALC269_FIXUP_AMIC] = {
6637                 .type = HDA_FIXUP_PINS,
6638                 .v.pins = (const struct hda_pintbl[]) {
6639                         { 0x14, 0x99130110 }, /* speaker */
6640                         { 0x15, 0x0121401f }, /* HP out */
6641                         { 0x18, 0x01a19c20 }, /* mic */
6642                         { 0x19, 0x99a3092f }, /* int-mic */
6643                         { }
6644                 },
6645         },
6646         [ALC269_FIXUP_DMIC] = {
6647                 .type = HDA_FIXUP_PINS,
6648                 .v.pins = (const struct hda_pintbl[]) {
6649                         { 0x12, 0x99a3092f }, /* int-mic */
6650                         { 0x14, 0x99130110 }, /* speaker */
6651                         { 0x15, 0x0121401f }, /* HP out */
6652                         { 0x18, 0x01a19c20 }, /* mic */
6653                         { }
6654                 },
6655         },
6656         [ALC269VB_FIXUP_AMIC] = {
6657                 .type = HDA_FIXUP_PINS,
6658                 .v.pins = (const struct hda_pintbl[]) {
6659                         { 0x14, 0x99130110 }, /* speaker */
6660                         { 0x18, 0x01a19c20 }, /* mic */
6661                         { 0x19, 0x99a3092f }, /* int-mic */
6662                         { 0x21, 0x0121401f }, /* HP out */
6663                         { }
6664                 },
6665         },
6666         [ALC269VB_FIXUP_DMIC] = {
6667                 .type = HDA_FIXUP_PINS,
6668                 .v.pins = (const struct hda_pintbl[]) {
6669                         { 0x12, 0x99a3092f }, /* int-mic */
6670                         { 0x14, 0x99130110 }, /* speaker */
6671                         { 0x18, 0x01a19c20 }, /* mic */
6672                         { 0x21, 0x0121401f }, /* HP out */
6673                         { }
6674                 },
6675         },
6676         [ALC269_FIXUP_HP_MUTE_LED] = {
6677                 .type = HDA_FIXUP_FUNC,
6678                 .v.func = alc269_fixup_hp_mute_led,
6679         },
6680         [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
6681                 .type = HDA_FIXUP_FUNC,
6682                 .v.func = alc269_fixup_hp_mute_led_mic1,
6683         },
6684         [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
6685                 .type = HDA_FIXUP_FUNC,
6686                 .v.func = alc269_fixup_hp_mute_led_mic2,
6687         },
6688         [ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
6689                 .type = HDA_FIXUP_FUNC,
6690                 .v.func = alc269_fixup_hp_mute_led_mic3,
6691                 .chained = true,
6692                 .chain_id = ALC295_FIXUP_HP_AUTO_MUTE
6693         },
6694         [ALC269_FIXUP_HP_GPIO_LED] = {
6695                 .type = HDA_FIXUP_FUNC,
6696                 .v.func = alc269_fixup_hp_gpio_led,
6697         },
6698         [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
6699                 .type = HDA_FIXUP_FUNC,
6700                 .v.func = alc269_fixup_hp_gpio_mic1_led,
6701         },
6702         [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
6703                 .type = HDA_FIXUP_FUNC,
6704                 .v.func = alc269_fixup_hp_line1_mic1_led,
6705         },
6706         [ALC269_FIXUP_INV_DMIC] = {
6707                 .type = HDA_FIXUP_FUNC,
6708                 .v.func = alc_fixup_inv_dmic,
6709         },
6710         [ALC269_FIXUP_NO_SHUTUP] = {
6711                 .type = HDA_FIXUP_FUNC,
6712                 .v.func = alc_fixup_no_shutup,
6713         },
6714         [ALC269_FIXUP_LENOVO_DOCK] = {
6715                 .type = HDA_FIXUP_PINS,
6716                 .v.pins = (const struct hda_pintbl[]) {
6717                         { 0x19, 0x23a11040 }, /* dock mic */
6718                         { 0x1b, 0x2121103f }, /* dock headphone */
6719                         { }
6720                 },
6721                 .chained = true,
6722                 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
6723         },
6724         [ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
6725                 .type = HDA_FIXUP_FUNC,
6726                 .v.func = alc269_fixup_limit_int_mic_boost,
6727                 .chained = true,
6728                 .chain_id = ALC269_FIXUP_LENOVO_DOCK,
6729         },
6730         [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
6731                 .type = HDA_FIXUP_FUNC,
6732                 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
6733                 .chained = true,
6734                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6735         },
6736         [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6737                 .type = HDA_FIXUP_PINS,
6738                 .v.pins = (const struct hda_pintbl[]) {
6739                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6740                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6741                         { }
6742                 },
6743                 .chained = true,
6744                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6745         },
6746         [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6747                 .type = HDA_FIXUP_PINS,
6748                 .v.pins = (const struct hda_pintbl[]) {
6749                         { 0x16, 0x21014020 }, /* dock line out */
6750                         { 0x19, 0x21a19030 }, /* dock mic */
6751                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6752                         { }
6753                 },
6754                 .chained = true,
6755                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6756         },
6757         [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
6758                 .type = HDA_FIXUP_PINS,
6759                 .v.pins = (const struct hda_pintbl[]) {
6760                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6761                         { }
6762                 },
6763                 .chained = true,
6764                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6765         },
6766         [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
6767                 .type = HDA_FIXUP_PINS,
6768                 .v.pins = (const struct hda_pintbl[]) {
6769                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6770                         { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6771                         { }
6772                 },
6773                 .chained = true,
6774                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6775         },
6776         [ALC269_FIXUP_HEADSET_MODE] = {
6777                 .type = HDA_FIXUP_FUNC,
6778                 .v.func = alc_fixup_headset_mode,
6779                 .chained = true,
6780                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
6781         },
6782         [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6783                 .type = HDA_FIXUP_FUNC,
6784                 .v.func = alc_fixup_headset_mode_no_hp_mic,
6785         },
6786         [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
6787                 .type = HDA_FIXUP_PINS,
6788                 .v.pins = (const struct hda_pintbl[]) {
6789                         { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
6790                         { }
6791                 },
6792                 .chained = true,
6793                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
6794         },
6795         [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
6796                 .type = HDA_FIXUP_PINS,
6797                 .v.pins = (const struct hda_pintbl[]) {
6798                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6799                         { }
6800                 },
6801                 .chained = true,
6802                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6803         },
6804         [ALC256_FIXUP_HUAWEI_MACH_WX9_PINS] = {
6805                 .type = HDA_FIXUP_PINS,
6806                 .v.pins = (const struct hda_pintbl[]) {
6807                         {0x12, 0x90a60130},
6808                         {0x13, 0x40000000},
6809                         {0x14, 0x90170110},
6810                         {0x18, 0x411111f0},
6811                         {0x19, 0x04a11040},
6812                         {0x1a, 0x411111f0},
6813                         {0x1b, 0x90170112},
6814                         {0x1d, 0x40759a05},
6815                         {0x1e, 0x411111f0},
6816                         {0x21, 0x04211020},
6817                         { }
6818                 },
6819                 .chained = true,
6820                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
6821         },
6822         [ALC298_FIXUP_HUAWEI_MBX_STEREO] = {
6823                 .type = HDA_FIXUP_FUNC,
6824                 .v.func = alc298_fixup_huawei_mbx_stereo,
6825                 .chained = true,
6826                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
6827         },
6828         [ALC269_FIXUP_ASUS_X101_FUNC] = {
6829                 .type = HDA_FIXUP_FUNC,
6830                 .v.func = alc269_fixup_x101_headset_mic,
6831         },
6832         [ALC269_FIXUP_ASUS_X101_VERB] = {
6833                 .type = HDA_FIXUP_VERBS,
6834                 .v.verbs = (const struct hda_verb[]) {
6835                         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6836                         {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
6837                         {0x20, AC_VERB_SET_PROC_COEF,  0x0310},
6838                         { }
6839                 },
6840                 .chained = true,
6841                 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
6842         },
6843         [ALC269_FIXUP_ASUS_X101] = {
6844                 .type = HDA_FIXUP_PINS,
6845                 .v.pins = (const struct hda_pintbl[]) {
6846                         { 0x18, 0x04a1182c }, /* Headset mic */
6847                         { }
6848                 },
6849                 .chained = true,
6850                 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
6851         },
6852         [ALC271_FIXUP_AMIC_MIC2] = {
6853                 .type = HDA_FIXUP_PINS,
6854                 .v.pins = (const struct hda_pintbl[]) {
6855                         { 0x14, 0x99130110 }, /* speaker */
6856                         { 0x19, 0x01a19c20 }, /* mic */
6857                         { 0x1b, 0x99a7012f }, /* int-mic */
6858                         { 0x21, 0x0121401f }, /* HP out */
6859                         { }
6860                 },
6861         },
6862         [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
6863                 .type = HDA_FIXUP_FUNC,
6864                 .v.func = alc271_hp_gate_mic_jack,
6865                 .chained = true,
6866                 .chain_id = ALC271_FIXUP_AMIC_MIC2,
6867         },
6868         [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
6869                 .type = HDA_FIXUP_FUNC,
6870                 .v.func = alc269_fixup_limit_int_mic_boost,
6871                 .chained = true,
6872                 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
6873         },
6874         [ALC269_FIXUP_ACER_AC700] = {
6875                 .type = HDA_FIXUP_PINS,
6876                 .v.pins = (const struct hda_pintbl[]) {
6877                         { 0x12, 0x99a3092f }, /* int-mic */
6878                         { 0x14, 0x99130110 }, /* speaker */
6879                         { 0x18, 0x03a11c20 }, /* mic */
6880                         { 0x1e, 0x0346101e }, /* SPDIF1 */
6881                         { 0x21, 0x0321101f }, /* HP out */
6882                         { }
6883                 },
6884                 .chained = true,
6885                 .chain_id = ALC271_FIXUP_DMIC,
6886         },
6887         [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
6888                 .type = HDA_FIXUP_FUNC,
6889                 .v.func = alc269_fixup_limit_int_mic_boost,
6890                 .chained = true,
6891                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6892         },
6893         [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
6894                 .type = HDA_FIXUP_FUNC,
6895                 .v.func = alc269_fixup_limit_int_mic_boost,
6896                 .chained = true,
6897                 .chain_id = ALC269VB_FIXUP_DMIC,
6898         },
6899         [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
6900                 .type = HDA_FIXUP_VERBS,
6901                 .v.verbs = (const struct hda_verb[]) {
6902                         /* class-D output amp +5dB */
6903                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
6904                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
6905                         {}
6906                 },
6907                 .chained = true,
6908                 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
6909         },
6910         [ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6911                 .type = HDA_FIXUP_PINS,
6912                 .v.pins = (const struct hda_pintbl[]) {
6913                         { 0x18, 0x01a110f0 },  /* use as headset mic */
6914                         { }
6915                 },
6916                 .chained = true,
6917                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6918         },
6919         [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
6920                 .type = HDA_FIXUP_FUNC,
6921                 .v.func = alc269_fixup_limit_int_mic_boost,
6922                 .chained = true,
6923                 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
6924         },
6925         [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
6926                 .type = HDA_FIXUP_PINS,
6927                 .v.pins = (const struct hda_pintbl[]) {
6928                         { 0x12, 0x99a3092f }, /* int-mic */
6929                         { 0x18, 0x03a11d20 }, /* mic */
6930                         { 0x19, 0x411111f0 }, /* Unused bogus pin */
6931                         { }
6932                 },
6933         },
6934         [ALC283_FIXUP_CHROME_BOOK] = {
6935                 .type = HDA_FIXUP_FUNC,
6936                 .v.func = alc283_fixup_chromebook,
6937         },
6938         [ALC283_FIXUP_SENSE_COMBO_JACK] = {
6939                 .type = HDA_FIXUP_FUNC,
6940                 .v.func = alc283_fixup_sense_combo_jack,
6941                 .chained = true,
6942                 .chain_id = ALC283_FIXUP_CHROME_BOOK,
6943         },
6944         [ALC282_FIXUP_ASUS_TX300] = {
6945                 .type = HDA_FIXUP_FUNC,
6946                 .v.func = alc282_fixup_asus_tx300,
6947         },
6948         [ALC283_FIXUP_INT_MIC] = {
6949                 .type = HDA_FIXUP_VERBS,
6950                 .v.verbs = (const struct hda_verb[]) {
6951                         {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
6952                         {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
6953                         { }
6954                 },
6955                 .chained = true,
6956                 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6957         },
6958         [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
6959                 .type = HDA_FIXUP_PINS,
6960                 .v.pins = (const struct hda_pintbl[]) {
6961                         { 0x17, 0x90170112 }, /* subwoofer */
6962                         { }
6963                 },
6964                 .chained = true,
6965                 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6966         },
6967         [ALC290_FIXUP_SUBWOOFER] = {
6968                 .type = HDA_FIXUP_PINS,
6969                 .v.pins = (const struct hda_pintbl[]) {
6970                         { 0x17, 0x90170112 }, /* subwoofer */
6971                         { }
6972                 },
6973                 .chained = true,
6974                 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
6975         },
6976         [ALC290_FIXUP_MONO_SPEAKERS] = {
6977                 .type = HDA_FIXUP_FUNC,
6978                 .v.func = alc290_fixup_mono_speakers,
6979         },
6980         [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
6981                 .type = HDA_FIXUP_FUNC,
6982                 .v.func = alc290_fixup_mono_speakers,
6983                 .chained = true,
6984                 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6985         },
6986         [ALC269_FIXUP_THINKPAD_ACPI] = {
6987                 .type = HDA_FIXUP_FUNC,
6988                 .v.func = alc_fixup_thinkpad_acpi,
6989                 .chained = true,
6990                 .chain_id = ALC269_FIXUP_SKU_IGNORE,
6991         },
6992         [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
6993                 .type = HDA_FIXUP_FUNC,
6994                 .v.func = alc_fixup_inv_dmic,
6995                 .chained = true,
6996                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6997         },
6998         [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
6999                 .type = HDA_FIXUP_PINS,
7000                 .v.pins = (const struct hda_pintbl[]) {
7001                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7002                         { }
7003                 },
7004                 .chained = true,
7005                 .chain_id = ALC255_FIXUP_HEADSET_MODE
7006         },
7007         [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7008                 .type = HDA_FIXUP_PINS,
7009                 .v.pins = (const struct hda_pintbl[]) {
7010                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7011                         { }
7012                 },
7013                 .chained = true,
7014                 .chain_id = ALC255_FIXUP_HEADSET_MODE
7015         },
7016         [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7017                 .type = HDA_FIXUP_PINS,
7018                 .v.pins = (const struct hda_pintbl[]) {
7019                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7020                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7021                         { }
7022                 },
7023                 .chained = true,
7024                 .chain_id = ALC255_FIXUP_HEADSET_MODE
7025         },
7026         [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7027                 .type = HDA_FIXUP_PINS,
7028                 .v.pins = (const struct hda_pintbl[]) {
7029                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7030                         { }
7031                 },
7032                 .chained = true,
7033                 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7034         },
7035         [ALC255_FIXUP_HEADSET_MODE] = {
7036                 .type = HDA_FIXUP_FUNC,
7037                 .v.func = alc_fixup_headset_mode_alc255,
7038                 .chained = true,
7039                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7040         },
7041         [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7042                 .type = HDA_FIXUP_FUNC,
7043                 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
7044         },
7045         [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7046                 .type = HDA_FIXUP_PINS,
7047                 .v.pins = (const struct hda_pintbl[]) {
7048                         { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7049                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7050                         { }
7051                 },
7052                 .chained = true,
7053                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7054         },
7055         [ALC292_FIXUP_TPT440_DOCK] = {
7056                 .type = HDA_FIXUP_FUNC,
7057                 .v.func = alc_fixup_tpt440_dock,
7058                 .chained = true,
7059                 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7060         },
7061         [ALC292_FIXUP_TPT440] = {
7062                 .type = HDA_FIXUP_FUNC,
7063                 .v.func = alc_fixup_disable_aamix,
7064                 .chained = true,
7065                 .chain_id = ALC292_FIXUP_TPT440_DOCK,
7066         },
7067         [ALC283_FIXUP_HEADSET_MIC] = {
7068                 .type = HDA_FIXUP_PINS,
7069                 .v.pins = (const struct hda_pintbl[]) {
7070                         { 0x19, 0x04a110f0 },
7071                         { },
7072                 },
7073         },
7074         [ALC255_FIXUP_MIC_MUTE_LED] = {
7075                 .type = HDA_FIXUP_FUNC,
7076                 .v.func = snd_hda_gen_fixup_micmute_led,
7077         },
7078         [ALC282_FIXUP_ASPIRE_V5_PINS] = {
7079                 .type = HDA_FIXUP_PINS,
7080                 .v.pins = (const struct hda_pintbl[]) {
7081                         { 0x12, 0x90a60130 },
7082                         { 0x14, 0x90170110 },
7083                         { 0x17, 0x40000008 },
7084                         { 0x18, 0x411111f0 },
7085                         { 0x19, 0x01a1913c },
7086                         { 0x1a, 0x411111f0 },
7087                         { 0x1b, 0x411111f0 },
7088                         { 0x1d, 0x40f89b2d },
7089                         { 0x1e, 0x411111f0 },
7090                         { 0x21, 0x0321101f },
7091                         { },
7092                 },
7093         },
7094         [ALC269VB_FIXUP_ASPIRE_E1_COEF] = {
7095                 .type = HDA_FIXUP_FUNC,
7096                 .v.func = alc269vb_fixup_aspire_e1_coef,
7097         },
7098         [ALC280_FIXUP_HP_GPIO4] = {
7099                 .type = HDA_FIXUP_FUNC,
7100                 .v.func = alc280_fixup_hp_gpio4,
7101         },
7102         [ALC286_FIXUP_HP_GPIO_LED] = {
7103                 .type = HDA_FIXUP_FUNC,
7104                 .v.func = alc286_fixup_hp_gpio_led,
7105         },
7106         [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
7107                 .type = HDA_FIXUP_FUNC,
7108                 .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
7109         },
7110         [ALC280_FIXUP_HP_DOCK_PINS] = {
7111                 .type = HDA_FIXUP_PINS,
7112                 .v.pins = (const struct hda_pintbl[]) {
7113                         { 0x1b, 0x21011020 }, /* line-out */
7114                         { 0x1a, 0x01a1903c }, /* headset mic */
7115                         { 0x18, 0x2181103f }, /* line-in */
7116                         { },
7117                 },
7118                 .chained = true,
7119                 .chain_id = ALC280_FIXUP_HP_GPIO4
7120         },
7121         [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
7122                 .type = HDA_FIXUP_PINS,
7123                 .v.pins = (const struct hda_pintbl[]) {
7124                         { 0x1b, 0x21011020 }, /* line-out */
7125                         { 0x18, 0x2181103f }, /* line-in */
7126                         { },
7127                 },
7128                 .chained = true,
7129                 .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
7130         },
7131         [ALC280_FIXUP_HP_9480M] = {
7132                 .type = HDA_FIXUP_FUNC,
7133                 .v.func = alc280_fixup_hp_9480m,
7134         },
7135         [ALC288_FIXUP_DELL_HEADSET_MODE] = {
7136                 .type = HDA_FIXUP_FUNC,
7137                 .v.func = alc_fixup_headset_mode_dell_alc288,
7138                 .chained = true,
7139                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7140         },
7141         [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7142                 .type = HDA_FIXUP_PINS,
7143                 .v.pins = (const struct hda_pintbl[]) {
7144                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7145                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7146                         { }
7147                 },
7148                 .chained = true,
7149                 .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
7150         },
7151         [ALC288_FIXUP_DISABLE_AAMIX] = {
7152                 .type = HDA_FIXUP_FUNC,
7153                 .v.func = alc_fixup_disable_aamix,
7154                 .chained = true,
7155                 .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
7156         },
7157         [ALC288_FIXUP_DELL_XPS_13] = {
7158                 .type = HDA_FIXUP_FUNC,
7159                 .v.func = alc_fixup_dell_xps13,
7160                 .chained = true,
7161                 .chain_id = ALC288_FIXUP_DISABLE_AAMIX
7162         },
7163         [ALC292_FIXUP_DISABLE_AAMIX] = {
7164                 .type = HDA_FIXUP_FUNC,
7165                 .v.func = alc_fixup_disable_aamix,
7166                 .chained = true,
7167                 .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
7168         },
7169         [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
7170                 .type = HDA_FIXUP_FUNC,
7171                 .v.func = alc_fixup_disable_aamix,
7172                 .chained = true,
7173                 .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
7174         },
7175         [ALC292_FIXUP_DELL_E7X_AAMIX] = {
7176                 .type = HDA_FIXUP_FUNC,
7177                 .v.func = alc_fixup_dell_xps13,
7178                 .chained = true,
7179                 .chain_id = ALC292_FIXUP_DISABLE_AAMIX
7180         },
7181         [ALC292_FIXUP_DELL_E7X] = {
7182                 .type = HDA_FIXUP_FUNC,
7183                 .v.func = snd_hda_gen_fixup_micmute_led,
7184                 /* micmute fixup must be applied at last */
7185                 .chained_before = true,
7186                 .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
7187         },
7188         [ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = {
7189                 .type = HDA_FIXUP_PINS,
7190                 .v.pins = (const struct hda_pintbl[]) {
7191                         { 0x18, 0x01a1913c }, /* headset mic w/o jack detect */
7192                         { }
7193                 },
7194                 .chained_before = true,
7195                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
7196         },
7197         [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7198                 .type = HDA_FIXUP_PINS,
7199                 .v.pins = (const struct hda_pintbl[]) {
7200                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7201                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7202                         { }
7203                 },
7204                 .chained = true,
7205                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7206         },
7207         [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
7208                 .type = HDA_FIXUP_PINS,
7209                 .v.pins = (const struct hda_pintbl[]) {
7210                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7211                         { }
7212                 },
7213                 .chained = true,
7214                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7215         },
7216         [ALC275_FIXUP_DELL_XPS] = {
7217                 .type = HDA_FIXUP_VERBS,
7218                 .v.verbs = (const struct hda_verb[]) {
7219                         /* Enables internal speaker */
7220                         {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
7221                         {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
7222                         {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
7223                         {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
7224                         {}
7225                 }
7226         },
7227         [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
7228                 .type = HDA_FIXUP_FUNC,
7229                 .v.func = alc_fixup_disable_aamix,
7230                 .chained = true,
7231                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7232         },
7233         [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
7234                 .type = HDA_FIXUP_FUNC,
7235                 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
7236         },
7237         [ALC233_FIXUP_INTEL_NUC8_DMIC] = {
7238                 .type = HDA_FIXUP_FUNC,
7239                 .v.func = alc_fixup_inv_dmic,
7240                 .chained = true,
7241                 .chain_id = ALC233_FIXUP_INTEL_NUC8_BOOST,
7242         },
7243         [ALC233_FIXUP_INTEL_NUC8_BOOST] = {
7244                 .type = HDA_FIXUP_FUNC,
7245                 .v.func = alc269_fixup_limit_int_mic_boost
7246         },
7247         [ALC255_FIXUP_DELL_SPK_NOISE] = {
7248                 .type = HDA_FIXUP_FUNC,
7249                 .v.func = alc_fixup_disable_aamix,
7250                 .chained = true,
7251                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7252         },
7253         [ALC225_FIXUP_DISABLE_MIC_VREF] = {
7254                 .type = HDA_FIXUP_FUNC,
7255                 .v.func = alc_fixup_disable_mic_vref,
7256                 .chained = true,
7257                 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7258         },
7259         [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7260                 .type = HDA_FIXUP_VERBS,
7261                 .v.verbs = (const struct hda_verb[]) {
7262                         /* Disable pass-through path for FRONT 14h */
7263                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7264                         { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7265                         {}
7266                 },
7267                 .chained = true,
7268                 .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
7269         },
7270         [ALC280_FIXUP_HP_HEADSET_MIC] = {
7271                 .type = HDA_FIXUP_FUNC,
7272                 .v.func = alc_fixup_disable_aamix,
7273                 .chained = true,
7274                 .chain_id = ALC269_FIXUP_HEADSET_MIC,
7275         },
7276         [ALC221_FIXUP_HP_FRONT_MIC] = {
7277                 .type = HDA_FIXUP_PINS,
7278                 .v.pins = (const struct hda_pintbl[]) {
7279                         { 0x19, 0x02a19020 }, /* Front Mic */
7280                         { }
7281                 },
7282         },
7283         [ALC292_FIXUP_TPT460] = {
7284                 .type = HDA_FIXUP_FUNC,
7285                 .v.func = alc_fixup_tpt440_dock,
7286                 .chained = true,
7287                 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
7288         },
7289         [ALC298_FIXUP_SPK_VOLUME] = {
7290                 .type = HDA_FIXUP_FUNC,
7291                 .v.func = alc298_fixup_speaker_volume,
7292                 .chained = true,
7293                 .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
7294         },
7295         [ALC298_FIXUP_LENOVO_SPK_VOLUME] = {
7296                 .type = HDA_FIXUP_FUNC,
7297                 .v.func = alc298_fixup_speaker_volume,
7298         },
7299         [ALC295_FIXUP_DISABLE_DAC3] = {
7300                 .type = HDA_FIXUP_FUNC,
7301                 .v.func = alc295_fixup_disable_dac3,
7302         },
7303         [ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
7304                 .type = HDA_FIXUP_FUNC,
7305                 .v.func = alc285_fixup_speaker2_to_dac1,
7306                 .chained = true,
7307                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7308         },
7309         [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
7310                 .type = HDA_FIXUP_PINS,
7311                 .v.pins = (const struct hda_pintbl[]) {
7312                         { 0x1b, 0x90170151 },
7313                         { }
7314                 },
7315                 .chained = true,
7316                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7317         },
7318         [ALC269_FIXUP_ATIV_BOOK_8] = {
7319                 .type = HDA_FIXUP_FUNC,
7320                 .v.func = alc_fixup_auto_mute_via_amp,
7321                 .chained = true,
7322                 .chain_id = ALC269_FIXUP_NO_SHUTUP
7323         },
7324         [ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE] = {
7325                 .type = HDA_FIXUP_PINS,
7326                 .v.pins = (const struct hda_pintbl[]) {
7327                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7328                         { 0x1a, 0x01813030 }, /* use as headphone mic, without its own jack detect */
7329                         { }
7330                 },
7331                 .chained = true,
7332                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7333         },
7334         [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
7335                 .type = HDA_FIXUP_PINS,
7336                 .v.pins = (const struct hda_pintbl[]) {
7337                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7338                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7339                         { }
7340                 },
7341                 .chained = true,
7342                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7343         },
7344         [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
7345                 .type = HDA_FIXUP_FUNC,
7346                 .v.func = alc_fixup_headset_mode,
7347         },
7348         [ALC256_FIXUP_ASUS_MIC] = {
7349                 .type = HDA_FIXUP_PINS,
7350                 .v.pins = (const struct hda_pintbl[]) {
7351                         { 0x13, 0x90a60160 }, /* use as internal mic */
7352                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7353                         { }
7354                 },
7355                 .chained = true,
7356                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7357         },
7358         [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
7359                 .type = HDA_FIXUP_FUNC,
7360                 /* Set up GPIO2 for the speaker amp */
7361                 .v.func = alc_fixup_gpio4,
7362         },
7363         [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7364                 .type = HDA_FIXUP_PINS,
7365                 .v.pins = (const struct hda_pintbl[]) {
7366                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7367                         { }
7368                 },
7369                 .chained = true,
7370                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7371         },
7372         [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
7373                 .type = HDA_FIXUP_VERBS,
7374                 .v.verbs = (const struct hda_verb[]) {
7375                         /* Enables internal speaker */
7376                         {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
7377                         {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
7378                         {}
7379                 },
7380                 .chained = true,
7381                 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7382         },
7383         [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
7384                 .type = HDA_FIXUP_FUNC,
7385                 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
7386                 .chained = true,
7387                 .chain_id = ALC269_FIXUP_GPIO2
7388         },
7389         [ALC233_FIXUP_ACER_HEADSET_MIC] = {
7390                 .type = HDA_FIXUP_VERBS,
7391                 .v.verbs = (const struct hda_verb[]) {
7392                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
7393                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
7394                         { }
7395                 },
7396                 .chained = true,
7397                 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7398         },
7399         [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
7400                 .type = HDA_FIXUP_PINS,
7401                 .v.pins = (const struct hda_pintbl[]) {
7402                         /* Change the mic location from front to right, otherwise there are
7403                            two front mics with the same name, pulseaudio can't handle them.
7404                            This is just a temporary workaround, after applying this fixup,
7405                            there will be one "Front Mic" and one "Mic" in this machine.
7406                          */
7407                         { 0x1a, 0x04a19040 },
7408                         { }
7409                 },
7410         },
7411         [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
7412                 .type = HDA_FIXUP_PINS,
7413                 .v.pins = (const struct hda_pintbl[]) {
7414                         { 0x16, 0x0101102f }, /* Rear Headset HP */
7415                         { 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
7416                         { 0x1a, 0x01a19030 }, /* Rear Headset MIC */
7417                         { 0x1b, 0x02011020 },
7418                         { }
7419                 },
7420                 .chained = true,
7421                 .chain_id = ALC225_FIXUP_S3_POP_NOISE
7422         },
7423         [ALC225_FIXUP_S3_POP_NOISE] = {
7424                 .type = HDA_FIXUP_FUNC,
7425                 .v.func = alc225_fixup_s3_pop_noise,
7426                 .chained = true,
7427                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7428         },
7429         [ALC700_FIXUP_INTEL_REFERENCE] = {
7430                 .type = HDA_FIXUP_VERBS,
7431                 .v.verbs = (const struct hda_verb[]) {
7432                         /* Enables internal speaker */
7433                         {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
7434                         {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
7435                         {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
7436                         {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
7437                         {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
7438                         {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
7439                         {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
7440                         {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
7441                         {}
7442                 }
7443         },
7444         [ALC274_FIXUP_DELL_BIND_DACS] = {
7445                 .type = HDA_FIXUP_FUNC,
7446                 .v.func = alc274_fixup_bind_dacs,
7447                 .chained = true,
7448                 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7449         },
7450         [ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
7451                 .type = HDA_FIXUP_PINS,
7452                 .v.pins = (const struct hda_pintbl[]) {
7453                         { 0x1b, 0x0401102f },
7454                         { }
7455                 },
7456                 .chained = true,
7457                 .chain_id = ALC274_FIXUP_DELL_BIND_DACS
7458         },
7459         [ALC298_FIXUP_TPT470_DOCK_FIX] = {
7460                 .type = HDA_FIXUP_FUNC,
7461                 .v.func = alc_fixup_tpt470_dock,
7462                 .chained = true,
7463                 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
7464         },
7465         [ALC298_FIXUP_TPT470_DOCK] = {
7466                 .type = HDA_FIXUP_FUNC,
7467                 .v.func = alc_fixup_tpt470_dacs,
7468                 .chained = true,
7469                 .chain_id = ALC298_FIXUP_TPT470_DOCK_FIX
7470         },
7471         [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
7472                 .type = HDA_FIXUP_PINS,
7473                 .v.pins = (const struct hda_pintbl[]) {
7474                         { 0x14, 0x0201101f },
7475                         { }
7476                 },
7477                 .chained = true,
7478                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7479         },
7480         [ALC255_FIXUP_DELL_HEADSET_MIC] = {
7481                 .type = HDA_FIXUP_PINS,
7482                 .v.pins = (const struct hda_pintbl[]) {
7483                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7484                         { }
7485                 },
7486                 .chained = true,
7487                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7488         },
7489         [ALC295_FIXUP_HP_X360] = {
7490                 .type = HDA_FIXUP_FUNC,
7491                 .v.func = alc295_fixup_hp_top_speakers,
7492                 .chained = true,
7493                 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
7494         },
7495         [ALC221_FIXUP_HP_HEADSET_MIC] = {
7496                 .type = HDA_FIXUP_PINS,
7497                 .v.pins = (const struct hda_pintbl[]) {
7498                         { 0x19, 0x0181313f},
7499                         { }
7500                 },
7501                 .chained = true,
7502                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7503         },
7504         [ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
7505                 .type = HDA_FIXUP_FUNC,
7506                 .v.func = alc285_fixup_invalidate_dacs,
7507                 .chained = true,
7508                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7509         },
7510         [ALC295_FIXUP_HP_AUTO_MUTE] = {
7511                 .type = HDA_FIXUP_FUNC,
7512                 .v.func = alc_fixup_auto_mute_via_amp,
7513         },
7514         [ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
7515                 .type = HDA_FIXUP_PINS,
7516                 .v.pins = (const struct hda_pintbl[]) {
7517                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7518                         { }
7519                 },
7520                 .chained = true,
7521                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7522         },
7523         [ALC294_FIXUP_ASUS_MIC] = {
7524                 .type = HDA_FIXUP_PINS,
7525                 .v.pins = (const struct hda_pintbl[]) {
7526                         { 0x13, 0x90a60160 }, /* use as internal mic */
7527                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7528                         { }
7529                 },
7530                 .chained = true,
7531                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7532         },
7533         [ALC294_FIXUP_ASUS_HEADSET_MIC] = {
7534                 .type = HDA_FIXUP_PINS,
7535                 .v.pins = (const struct hda_pintbl[]) {
7536                         { 0x19, 0x01a1103c }, /* use as headset mic */
7537                         { }
7538                 },
7539                 .chained = true,
7540                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7541         },
7542         [ALC294_FIXUP_ASUS_SPK] = {
7543                 .type = HDA_FIXUP_VERBS,
7544                 .v.verbs = (const struct hda_verb[]) {
7545                         /* Set EAPD high */
7546                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
7547                         { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
7548                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
7549                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
7550                         { }
7551                 },
7552                 .chained = true,
7553                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7554         },
7555         [ALC295_FIXUP_CHROME_BOOK] = {
7556                 .type = HDA_FIXUP_FUNC,
7557                 .v.func = alc295_fixup_chromebook,
7558                 .chained = true,
7559                 .chain_id = ALC225_FIXUP_HEADSET_JACK
7560         },
7561         [ALC225_FIXUP_HEADSET_JACK] = {
7562                 .type = HDA_FIXUP_FUNC,
7563                 .v.func = alc_fixup_headset_jack,
7564         },
7565         [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
7566                 .type = HDA_FIXUP_PINS,
7567                 .v.pins = (const struct hda_pintbl[]) {
7568                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7569                         { }
7570                 },
7571                 .chained = true,
7572                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7573         },
7574         [ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
7575                 .type = HDA_FIXUP_VERBS,
7576                 .v.verbs = (const struct hda_verb[]) {
7577                         /* Disable PCBEEP-IN passthrough */
7578                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7579                         { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7580                         { }
7581                 },
7582                 .chained = true,
7583                 .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
7584         },
7585         [ALC255_FIXUP_ACER_HEADSET_MIC] = {
7586                 .type = HDA_FIXUP_PINS,
7587                 .v.pins = (const struct hda_pintbl[]) {
7588                         { 0x19, 0x03a11130 },
7589                         { 0x1a, 0x90a60140 }, /* use as internal mic */
7590                         { }
7591                 },
7592                 .chained = true,
7593                 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7594         },
7595         [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
7596                 .type = HDA_FIXUP_PINS,
7597                 .v.pins = (const struct hda_pintbl[]) {
7598                         { 0x16, 0x01011020 }, /* Rear Line out */
7599                         { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
7600                         { }
7601                 },
7602                 .chained = true,
7603                 .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
7604         },
7605         [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
7606                 .type = HDA_FIXUP_FUNC,
7607                 .v.func = alc_fixup_auto_mute_via_amp,
7608                 .chained = true,
7609                 .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
7610         },
7611         [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
7612                 .type = HDA_FIXUP_FUNC,
7613                 .v.func = alc_fixup_disable_mic_vref,
7614                 .chained = true,
7615                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7616         },
7617         [ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
7618                 .type = HDA_FIXUP_VERBS,
7619                 .v.verbs = (const struct hda_verb[]) {
7620                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
7621                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
7622                         { }
7623                 },
7624                 .chained = true,
7625                 .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
7626         },
7627         [ALC256_FIXUP_ASUS_HEADSET_MIC] = {
7628                 .type = HDA_FIXUP_PINS,
7629                 .v.pins = (const struct hda_pintbl[]) {
7630                         { 0x19, 0x03a11020 }, /* headset mic with jack detect */
7631                         { }
7632                 },
7633                 .chained = true,
7634                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7635         },
7636         [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7637                 .type = HDA_FIXUP_PINS,
7638                 .v.pins = (const struct hda_pintbl[]) {
7639                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7640                         { }
7641                 },
7642                 .chained = true,
7643                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7644         },
7645         [ALC299_FIXUP_PREDATOR_SPK] = {
7646                 .type = HDA_FIXUP_PINS,
7647                 .v.pins = (const struct hda_pintbl[]) {
7648                         { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
7649                         { }
7650                 }
7651         },
7652         [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
7653                 .type = HDA_FIXUP_PINS,
7654                 .v.pins = (const struct hda_pintbl[]) {
7655                         { 0x19, 0x04a11040 },
7656                         { 0x21, 0x04211020 },
7657                         { }
7658                 },
7659                 .chained = true,
7660                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7661         },
7662         [ALC289_FIXUP_DELL_SPK2] = {
7663                 .type = HDA_FIXUP_PINS,
7664                 .v.pins = (const struct hda_pintbl[]) {
7665                         { 0x17, 0x90170130 }, /* bass spk */
7666                         { }
7667                 },
7668                 .chained = true,
7669                 .chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
7670         },
7671         [ALC289_FIXUP_DUAL_SPK] = {
7672                 .type = HDA_FIXUP_FUNC,
7673                 .v.func = alc285_fixup_speaker2_to_dac1,
7674                 .chained = true,
7675                 .chain_id = ALC289_FIXUP_DELL_SPK2
7676         },
7677         [ALC294_FIXUP_SPK2_TO_DAC1] = {
7678                 .type = HDA_FIXUP_FUNC,
7679                 .v.func = alc285_fixup_speaker2_to_dac1,
7680                 .chained = true,
7681                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7682         },
7683         [ALC294_FIXUP_ASUS_DUAL_SPK] = {
7684                 .type = HDA_FIXUP_FUNC,
7685                 /* The GPIO must be pulled to initialize the AMP */
7686                 .v.func = alc_fixup_gpio4,
7687                 .chained = true,
7688                 .chain_id = ALC294_FIXUP_SPK2_TO_DAC1
7689         },
7690         [ALC285_FIXUP_THINKPAD_X1_GEN7] = {
7691                 .type = HDA_FIXUP_FUNC,
7692                 .v.func = alc285_fixup_thinkpad_x1_gen7,
7693                 .chained = true,
7694                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7695         },
7696         [ALC285_FIXUP_THINKPAD_HEADSET_JACK] = {
7697                 .type = HDA_FIXUP_FUNC,
7698                 .v.func = alc_fixup_headset_jack,
7699                 .chained = true,
7700                 .chain_id = ALC285_FIXUP_THINKPAD_X1_GEN7
7701         },
7702         [ALC294_FIXUP_ASUS_HPE] = {
7703                 .type = HDA_FIXUP_VERBS,
7704                 .v.verbs = (const struct hda_verb[]) {
7705                         /* Set EAPD high */
7706                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
7707                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
7708                         { }
7709                 },
7710                 .chained = true,
7711                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7712         },
7713         [ALC294_FIXUP_ASUS_GX502_PINS] = {
7714                 .type = HDA_FIXUP_PINS,
7715                 .v.pins = (const struct hda_pintbl[]) {
7716                         { 0x19, 0x03a11050 }, /* front HP mic */
7717                         { 0x1a, 0x01a11830 }, /* rear external mic */
7718                         { 0x21, 0x03211020 }, /* front HP out */
7719                         { }
7720                 },
7721                 .chained = true,
7722                 .chain_id = ALC294_FIXUP_ASUS_GX502_VERBS
7723         },
7724         [ALC294_FIXUP_ASUS_GX502_VERBS] = {
7725                 .type = HDA_FIXUP_VERBS,
7726                 .v.verbs = (const struct hda_verb[]) {
7727                         /* set 0x15 to HP-OUT ctrl */
7728                         { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7729                         /* unmute the 0x15 amp */
7730                         { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
7731                         { }
7732                 },
7733                 .chained = true,
7734                 .chain_id = ALC294_FIXUP_ASUS_GX502_HP
7735         },
7736         [ALC294_FIXUP_ASUS_GX502_HP] = {
7737                 .type = HDA_FIXUP_FUNC,
7738                 .v.func = alc294_fixup_gx502_hp,
7739         },
7740         [ALC294_FIXUP_ASUS_GU502_PINS] = {
7741                 .type = HDA_FIXUP_PINS,
7742                 .v.pins = (const struct hda_pintbl[]) {
7743                         { 0x19, 0x01a11050 }, /* rear HP mic */
7744                         { 0x1a, 0x01a11830 }, /* rear external mic */
7745                         { 0x21, 0x012110f0 }, /* rear HP out */
7746                         { }
7747                 },
7748                 .chained = true,
7749                 .chain_id = ALC294_FIXUP_ASUS_GU502_VERBS
7750         },
7751         [ALC294_FIXUP_ASUS_GU502_VERBS] = {
7752                 .type = HDA_FIXUP_VERBS,
7753                 .v.verbs = (const struct hda_verb[]) {
7754                         /* set 0x15 to HP-OUT ctrl */
7755                         { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7756                         /* unmute the 0x15 amp */
7757                         { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
7758                         /* set 0x1b to HP-OUT */
7759                         { 0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7760                         { }
7761                 },
7762                 .chained = true,
7763                 .chain_id = ALC294_FIXUP_ASUS_GU502_HP
7764         },
7765         [ALC294_FIXUP_ASUS_GU502_HP] = {
7766                 .type = HDA_FIXUP_FUNC,
7767                 .v.func = alc294_fixup_gu502_hp,
7768         },
7769          [ALC294_FIXUP_ASUS_G513_PINS] = {
7770                 .type = HDA_FIXUP_PINS,
7771                 .v.pins = (const struct hda_pintbl[]) {
7772                                 { 0x19, 0x03a11050 }, /* front HP mic */
7773                                 { 0x1a, 0x03a11c30 }, /* rear external mic */
7774                                 { 0x21, 0x03211420 }, /* front HP out */
7775                                 { }
7776                 },
7777         },
7778         [ALC285_FIXUP_ASUS_G533Z_PINS] = {
7779                 .type = HDA_FIXUP_PINS,
7780                 .v.pins = (const struct hda_pintbl[]) {
7781                         { 0x14, 0x90170152 }, /* Speaker Surround Playback Switch */
7782                         { 0x19, 0x03a19020 }, /* Mic Boost Volume */
7783                         { 0x1a, 0x03a11c30 }, /* Mic Boost Volume */
7784                         { 0x1e, 0x90170151 }, /* Rear jack, IN OUT EAPD Detect */
7785                         { 0x21, 0x03211420 },
7786                         { }
7787                 },
7788         },
7789         [ALC294_FIXUP_ASUS_COEF_1B] = {
7790                 .type = HDA_FIXUP_VERBS,
7791                 .v.verbs = (const struct hda_verb[]) {
7792                         /* Set bit 10 to correct noisy output after reboot from
7793                          * Windows 10 (due to pop noise reduction?)
7794                          */
7795                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
7796                         { 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
7797                         { }
7798                 },
7799                 .chained = true,
7800                 .chain_id = ALC289_FIXUP_ASUS_GA401,
7801         },
7802         [ALC285_FIXUP_HP_GPIO_LED] = {
7803                 .type = HDA_FIXUP_FUNC,
7804                 .v.func = alc285_fixup_hp_gpio_led,
7805         },
7806         [ALC285_FIXUP_HP_MUTE_LED] = {
7807                 .type = HDA_FIXUP_FUNC,
7808                 .v.func = alc285_fixup_hp_mute_led,
7809         },
7810         [ALC236_FIXUP_HP_GPIO_LED] = {
7811                 .type = HDA_FIXUP_FUNC,
7812                 .v.func = alc236_fixup_hp_gpio_led,
7813         },
7814         [ALC236_FIXUP_HP_MUTE_LED] = {
7815                 .type = HDA_FIXUP_FUNC,
7816                 .v.func = alc236_fixup_hp_mute_led,
7817         },
7818         [ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
7819                 .type = HDA_FIXUP_VERBS,
7820                 .v.verbs = (const struct hda_verb[]) {
7821                         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
7822                         { }
7823                 },
7824         },
7825         [ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
7826                 .type = HDA_FIXUP_VERBS,
7827                 .v.verbs = (const struct hda_verb[]) {
7828                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x08},
7829                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf},
7830                         { }
7831                 },
7832         },
7833         [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7834                 .type = HDA_FIXUP_PINS,
7835                 .v.pins = (const struct hda_pintbl[]) {
7836                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7837                         { }
7838                 },
7839                 .chained = true,
7840                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7841         },
7842         [ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS] = {
7843                 .type = HDA_FIXUP_PINS,
7844                 .v.pins = (const struct hda_pintbl[]) {
7845                         { 0x14, 0x90100120 }, /* use as internal speaker */
7846                         { 0x18, 0x02a111f0 }, /* use as headset mic, without its own jack detect */
7847                         { 0x1a, 0x01011020 }, /* use as line out */
7848                         { },
7849                 },
7850                 .chained = true,
7851                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7852         },
7853         [ALC269VC_FIXUP_ACER_HEADSET_MIC] = {
7854                 .type = HDA_FIXUP_PINS,
7855                 .v.pins = (const struct hda_pintbl[]) {
7856                         { 0x18, 0x02a11030 }, /* use as headset mic */
7857                         { }
7858                 },
7859                 .chained = true,
7860                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7861         },
7862         [ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE] = {
7863                 .type = HDA_FIXUP_PINS,
7864                 .v.pins = (const struct hda_pintbl[]) {
7865                         { 0x18, 0x01a11130 }, /* use as headset mic, without its own jack detect */
7866                         { }
7867                 },
7868                 .chained = true,
7869                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7870         },
7871         [ALC289_FIXUP_ASUS_GA401] = {
7872                 .type = HDA_FIXUP_FUNC,
7873                 .v.func = alc289_fixup_asus_ga401,
7874                 .chained = true,
7875                 .chain_id = ALC289_FIXUP_ASUS_GA502,
7876         },
7877         [ALC289_FIXUP_ASUS_GA502] = {
7878                 .type = HDA_FIXUP_PINS,
7879                 .v.pins = (const struct hda_pintbl[]) {
7880                         { 0x19, 0x03a11020 }, /* headset mic with jack detect */
7881                         { }
7882                 },
7883         },
7884         [ALC256_FIXUP_ACER_MIC_NO_PRESENCE] = {
7885                 .type = HDA_FIXUP_PINS,
7886                 .v.pins = (const struct hda_pintbl[]) {
7887                         { 0x19, 0x02a11120 }, /* use as headset mic, without its own jack detect */
7888                         { }
7889                 },
7890                 .chained = true,
7891                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7892         },
7893         [ALC285_FIXUP_HP_GPIO_AMP_INIT] = {
7894                 .type = HDA_FIXUP_FUNC,
7895                 .v.func = alc285_fixup_hp_gpio_amp_init,
7896                 .chained = true,
7897                 .chain_id = ALC285_FIXUP_HP_GPIO_LED
7898         },
7899         [ALC269_FIXUP_CZC_B20] = {
7900                 .type = HDA_FIXUP_PINS,
7901                 .v.pins = (const struct hda_pintbl[]) {
7902                         { 0x12, 0x411111f0 },
7903                         { 0x14, 0x90170110 }, /* speaker */
7904                         { 0x15, 0x032f1020 }, /* HP out */
7905                         { 0x17, 0x411111f0 },
7906                         { 0x18, 0x03ab1040 }, /* mic */
7907                         { 0x19, 0xb7a7013f },
7908                         { 0x1a, 0x0181305f },
7909                         { 0x1b, 0x411111f0 },
7910                         { 0x1d, 0x411111f0 },
7911                         { 0x1e, 0x411111f0 },
7912                         { }
7913                 },
7914                 .chain_id = ALC269_FIXUP_DMIC,
7915         },
7916         [ALC269_FIXUP_CZC_TMI] = {
7917                 .type = HDA_FIXUP_PINS,
7918                 .v.pins = (const struct hda_pintbl[]) {
7919                         { 0x12, 0x4000c000 },
7920                         { 0x14, 0x90170110 }, /* speaker */
7921                         { 0x15, 0x0421401f }, /* HP out */
7922                         { 0x17, 0x411111f0 },
7923                         { 0x18, 0x04a19020 }, /* mic */
7924                         { 0x19, 0x411111f0 },
7925                         { 0x1a, 0x411111f0 },
7926                         { 0x1b, 0x411111f0 },
7927                         { 0x1d, 0x40448505 },
7928                         { 0x1e, 0x411111f0 },
7929                         { 0x20, 0x8000ffff },
7930                         { }
7931                 },
7932                 .chain_id = ALC269_FIXUP_DMIC,
7933         },
7934         [ALC269_FIXUP_CZC_L101] = {
7935                 .type = HDA_FIXUP_PINS,
7936                 .v.pins = (const struct hda_pintbl[]) {
7937                         { 0x12, 0x40000000 },
7938                         { 0x14, 0x01014010 }, /* speaker */
7939                         { 0x15, 0x411111f0 }, /* HP out */
7940                         { 0x16, 0x411111f0 },
7941                         { 0x18, 0x01a19020 }, /* mic */
7942                         { 0x19, 0x02a19021 },
7943                         { 0x1a, 0x0181302f },
7944                         { 0x1b, 0x0221401f },
7945                         { 0x1c, 0x411111f0 },
7946                         { 0x1d, 0x4044c601 },
7947                         { 0x1e, 0x411111f0 },
7948                         { }
7949                 },
7950                 .chain_id = ALC269_FIXUP_DMIC,
7951         },
7952         [ALC269_FIXUP_LEMOTE_A1802] = {
7953                 .type = HDA_FIXUP_PINS,
7954                 .v.pins = (const struct hda_pintbl[]) {
7955                         { 0x12, 0x40000000 },
7956                         { 0x14, 0x90170110 }, /* speaker */
7957                         { 0x17, 0x411111f0 },
7958                         { 0x18, 0x03a19040 }, /* mic1 */
7959                         { 0x19, 0x90a70130 }, /* mic2 */
7960                         { 0x1a, 0x411111f0 },
7961                         { 0x1b, 0x411111f0 },
7962                         { 0x1d, 0x40489d2d },
7963                         { 0x1e, 0x411111f0 },
7964                         { 0x20, 0x0003ffff },
7965                         { 0x21, 0x03214020 },
7966                         { }
7967                 },
7968                 .chain_id = ALC269_FIXUP_DMIC,
7969         },
7970         [ALC269_FIXUP_LEMOTE_A190X] = {
7971                 .type = HDA_FIXUP_PINS,
7972                 .v.pins = (const struct hda_pintbl[]) {
7973                         { 0x14, 0x99130110 }, /* speaker */
7974                         { 0x15, 0x0121401f }, /* HP out */
7975                         { 0x18, 0x01a19c20 }, /* rear  mic */
7976                         { 0x19, 0x99a3092f }, /* front mic */
7977                         { 0x1b, 0x0201401f }, /* front lineout */
7978                         { }
7979                 },
7980                 .chain_id = ALC269_FIXUP_DMIC,
7981         },
7982         [ALC256_FIXUP_INTEL_NUC8_RUGGED] = {
7983                 .type = HDA_FIXUP_PINS,
7984                 .v.pins = (const struct hda_pintbl[]) {
7985                         { 0x1b, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7986                         { }
7987                 },
7988                 .chained = true,
7989                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7990         },
7991         [ALC256_FIXUP_INTEL_NUC10] = {
7992                 .type = HDA_FIXUP_PINS,
7993                 .v.pins = (const struct hda_pintbl[]) {
7994                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7995                         { }
7996                 },
7997                 .chained = true,
7998                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7999         },
8000         [ALC255_FIXUP_XIAOMI_HEADSET_MIC] = {
8001                 .type = HDA_FIXUP_VERBS,
8002                 .v.verbs = (const struct hda_verb[]) {
8003                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8004                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8005                         { }
8006                 },
8007                 .chained = true,
8008                 .chain_id = ALC289_FIXUP_ASUS_GA502
8009         },
8010         [ALC274_FIXUP_HP_MIC] = {
8011                 .type = HDA_FIXUP_VERBS,
8012                 .v.verbs = (const struct hda_verb[]) {
8013                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8014                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8015                         { }
8016                 },
8017         },
8018         [ALC274_FIXUP_HP_HEADSET_MIC] = {
8019                 .type = HDA_FIXUP_FUNC,
8020                 .v.func = alc274_fixup_hp_headset_mic,
8021                 .chained = true,
8022                 .chain_id = ALC274_FIXUP_HP_MIC
8023         },
8024         [ALC256_FIXUP_ASUS_HPE] = {
8025                 .type = HDA_FIXUP_VERBS,
8026                 .v.verbs = (const struct hda_verb[]) {
8027                         /* Set EAPD high */
8028                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8029                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7778 },
8030                         { }
8031                 },
8032                 .chained = true,
8033                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8034         },
8035         [ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK] = {
8036                 .type = HDA_FIXUP_FUNC,
8037                 .v.func = alc_fixup_headset_jack,
8038                 .chained = true,
8039                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
8040         },
8041         [ALC295_FIXUP_ASUS_DACS] = {
8042                 .type = HDA_FIXUP_FUNC,
8043                 .v.func = alc295_fixup_asus_dacs,
8044         },
8045         [ALC295_FIXUP_HP_OMEN] = {
8046                 .type = HDA_FIXUP_PINS,
8047                 .v.pins = (const struct hda_pintbl[]) {
8048                         { 0x12, 0xb7a60130 },
8049                         { 0x13, 0x40000000 },
8050                         { 0x14, 0x411111f0 },
8051                         { 0x16, 0x411111f0 },
8052                         { 0x17, 0x90170110 },
8053                         { 0x18, 0x411111f0 },
8054                         { 0x19, 0x02a11030 },
8055                         { 0x1a, 0x411111f0 },
8056                         { 0x1b, 0x04a19030 },
8057                         { 0x1d, 0x40600001 },
8058                         { 0x1e, 0x411111f0 },
8059                         { 0x21, 0x03211020 },
8060                         {}
8061                 },
8062                 .chained = true,
8063                 .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
8064         },
8065         [ALC285_FIXUP_HP_SPECTRE_X360] = {
8066                 .type = HDA_FIXUP_FUNC,
8067                 .v.func = alc285_fixup_hp_spectre_x360,
8068         },
8069 };
8070
8071 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
8072         SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
8073         SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
8074         SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
8075         SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
8076         SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8077         SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
8078         SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
8079         SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8080         SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8081         SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
8082         SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8083         SND_PCI_QUIRK(0x1025, 0x0840, "Acer Aspire E1", ALC269VB_FIXUP_ASPIRE_E1_COEF),
8084         SND_PCI_QUIRK(0x1025, 0x101c, "Acer Veriton N2510G", ALC269_FIXUP_LIFEBOOK),
8085         SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
8086         SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
8087         SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
8088         SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8089         SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8090         SND_PCI_QUIRK(0x1025, 0x1166, "Acer Veriton N4640G", ALC269_FIXUP_LIFEBOOK),
8091         SND_PCI_QUIRK(0x1025, 0x1167, "Acer Veriton N6640G", ALC269_FIXUP_LIFEBOOK),
8092         SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
8093         SND_PCI_QUIRK(0x1025, 0x1247, "Acer vCopperbox", ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS),
8094         SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
8095         SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8096         SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8097         SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8098         SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8099         SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
8100         SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
8101         SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8102         SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8103         SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8104         SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
8105         SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
8106         SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
8107         SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
8108         SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8109         SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
8110         SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
8111         SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
8112         SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8113         SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8114         SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8115         SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8116         SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8117         SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
8118         SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
8119         SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
8120         SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8121         SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8122         SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
8123         SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8124         SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8125         SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8126         SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8127         SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8128         SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8129         SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8130         SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8131         SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8132         SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8133         SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8134         SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
8135         SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
8136         SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
8137         SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
8138         SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8139         SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
8140         SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
8141         SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8142         SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8143         SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8144         SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8145         SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
8146         SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
8147         SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
8148         SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8149         SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8150         SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8151         SND_PCI_QUIRK(0x1028, 0x098d, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8152         SND_PCI_QUIRK(0x1028, 0x09bf, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8153         SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8154         SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8155         SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
8156         SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8157         SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
8158         SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8159         SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8160         SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8161         SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8162         SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
8163         SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8164         SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8165         SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8166         SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8167         SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8168         SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8169         SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8170         SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8171         SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8172         SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8173         SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8174         SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8175         SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8176         SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
8177         SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
8178         SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8179         SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8180         SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8181         SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8182         SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8183         SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8184         SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8185         SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8186         SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
8187         SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8188         SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
8189         SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8190         SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
8191         SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8192         SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8193         SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8194         SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8195         SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8196         SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8197         SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8198         SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8199         SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8200         SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8201         SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8202         SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8203         SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8204         SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8205         SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
8206         SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8207         SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8208         SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8209         SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8210         SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8211         SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8212         SND_PCI_QUIRK(0x103c, 0x2b5e, "HP 288 Pro G2 MT", ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE),
8213         SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8214         SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8215         SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8216         SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
8217         SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
8218         SND_PCI_QUIRK(0x103c, 0x827f, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8219         SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8220         SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8221         SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8222         SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8223         SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8224         SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
8225         SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8226         SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
8227         SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8228         SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8229         SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
8230         SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
8231         SND_PCI_QUIRK(0x103c, 0x8728, "HP EliteBook 840 G7", ALC285_FIXUP_HP_GPIO_LED),
8232         SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
8233         SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8234         SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
8235         SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
8236         SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
8237         SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8238         SND_PCI_QUIRK(0x103c, 0x89aa, "HP EliteBook 630 G9", ALC236_FIXUP_HP_GPIO_LED),
8239         SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
8240         SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
8241         SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8242         SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
8243         SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
8244         SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8245         SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8246         SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8247         SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8248         SND_PCI_QUIRK(0x1043, 0x1271, "ASUS X430UN", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
8249         SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
8250         SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
8251         SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
8252         SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
8253         SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE),
8254         SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
8255         SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
8256         SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
8257         SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK),
8258         SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
8259         SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
8260         SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS),
8261         SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
8262         SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
8263         SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
8264         SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
8265         SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE),
8266         SND_PCI_QUIRK(0x1043, 0x1970, "ASUS UX550VE", ALC289_FIXUP_ASUS_GA401),
8267         SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE),
8268         SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
8269         SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
8270         SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
8271         SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
8272         SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
8273         SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
8274         SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8275         SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8276         SND_PCI_QUIRK(0x1043, 0x1c62, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
8277         SND_PCI_QUIRK(0x1043, 0x1c92, "ASUS ROG Strix G15", ALC285_FIXUP_ASUS_G533Z_PINS),
8278         SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
8279         SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401),
8280         SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
8281         SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
8282         SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS),
8283         SND_PCI_QUIRK(0x1043, 0x1e5e, "ASUS ROG Strix G513", ALC294_FIXUP_ASUS_G513_PINS),
8284         SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
8285         SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401),
8286         SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
8287         SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401),
8288         SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
8289         SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
8290         SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
8291         SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
8292         SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
8293         SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
8294         SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
8295         SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
8296         SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
8297         SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
8298         SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
8299         SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
8300         SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
8301         SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
8302         SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
8303         SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
8304         SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
8305         SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
8306         SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
8307         SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
8308         SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8309         SND_PCI_QUIRK(0x10ec, 0x124c, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8310         SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8311         SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8312         SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
8313         SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
8314         SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8315         SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8316         SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8317         SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8318         SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
8319         SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8320         SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8321         SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8322         SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
8323         SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
8324         SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
8325         SND_PCI_QUIRK(0x152d, 0x1082, "Quanta NL3", ALC269_FIXUP_LIFEBOOK),
8326         SND_PCI_QUIRK(0x1558, 0x1323, "Clevo N130ZU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8327         SND_PCI_QUIRK(0x1558, 0x1325, "System76 Darter Pro (darp5)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8328         SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8329         SND_PCI_QUIRK(0x1558, 0x1403, "Clevo N140CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8330         SND_PCI_QUIRK(0x1558, 0x1404, "Clevo N150CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8331         SND_PCI_QUIRK(0x1558, 0x14a1, "Clevo L141MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8332         SND_PCI_QUIRK(0x1558, 0x4018, "Clevo NV40M[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8333         SND_PCI_QUIRK(0x1558, 0x4019, "Clevo NV40MZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8334         SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8335         SND_PCI_QUIRK(0x1558, 0x40a1, "Clevo NL40GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8336         SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8337         SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8338         SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8339         SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8340         SND_PCI_QUIRK(0x1558, 0x50b6, "Clevo NK50S5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8341         SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8342         SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8343         SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8344         SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8345         SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8346         SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8347         SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8348         SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8349         SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8350         SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8351         SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8352         SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8353         SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8354         SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8355         SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8356         SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8357         SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8358         SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8359         SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8360         SND_PCI_QUIRK(0x1558, 0x8535, "Clevo NH50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8361         SND_PCI_QUIRK(0x1558, 0x8536, "Clevo NH79D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8362         SND_PCI_QUIRK(0x1558, 0x8550, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8363         SND_PCI_QUIRK(0x1558, 0x8551, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8364         SND_PCI_QUIRK(0x1558, 0x8560, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
8365         SND_PCI_QUIRK(0x1558, 0x8561, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
8366         SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[5|7][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
8367         SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8368         SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8369         SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8370         SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8371         SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8372         SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8373         SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8374         SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8375         SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8376         SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8377         SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL53RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8378         SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL5XNU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8379         SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8380         SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8381         SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8382         SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8383         SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8384         SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8385         SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
8386         SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8387         SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
8388         SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
8389         SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
8390         SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
8391         SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
8392         SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
8393         SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
8394         SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
8395         SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
8396         SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
8397         SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
8398         SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
8399         SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
8400         SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
8401         SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
8402         SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
8403         SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
8404         SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8405         SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
8406         SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
8407         SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
8408         SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8409         SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8410         SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
8411         SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
8412         SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
8413         SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8414         SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8415         SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
8416         SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8417         SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8418         SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8419         SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8420         SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
8421         SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
8422         SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
8423         SND_PCI_QUIRK(0x17aa, 0x22c2, "Thinkpad X1 Extreme Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
8424         SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
8425         SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
8426         SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8427         SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8428         SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8429         SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8430         SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8431         SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8432         SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8433         SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8434         SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
8435         SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
8436         SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
8437         SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
8438         SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
8439         SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8440         SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
8441         SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
8442         SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8443         SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
8444         SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
8445         SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
8446         SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
8447         SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
8448         SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
8449         SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
8450         SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
8451         SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8452         SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8453         SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8454         SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8455         SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8456         SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8457         SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
8458         SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
8459         SND_PCI_QUIRK(0x19e5, 0x320f, "Huawei WRT-WX9 ", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
8460         SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20),
8461         SND_PCI_QUIRK(0x1b35, 0x1236, "CZC TMI", ALC269_FIXUP_CZC_TMI),
8462         SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
8463         SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
8464         SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
8465         SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
8466         SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
8467         SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
8468         SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
8469         SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC),
8470         SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
8471         SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
8472         SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
8473         SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10),
8474
8475 #if 0
8476         /* Below is a quirk table taken from the old code.
8477          * Basically the device should work as is without the fixup table.
8478          * If BIOS doesn't give a proper info, enable the corresponding
8479          * fixup entry.
8480          */
8481         SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
8482                       ALC269_FIXUP_AMIC),
8483         SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
8484         SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
8485         SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
8486         SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
8487         SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
8488         SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
8489         SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
8490         SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
8491         SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
8492         SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
8493         SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
8494         SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
8495         SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
8496         SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
8497         SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
8498         SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
8499         SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
8500         SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
8501         SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
8502         SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
8503         SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
8504         SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
8505         SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
8506         SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
8507         SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
8508         SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
8509         SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
8510         SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
8511         SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
8512         SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
8513         SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
8514         SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
8515         SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
8516         SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
8517         SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
8518         SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
8519         SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
8520         SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
8521         SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
8522 #endif
8523         {}
8524 };
8525
8526 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
8527         SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
8528         SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
8529         SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
8530         SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
8531         SND_PCI_QUIRK_VENDOR(0x19e5, "Huawei Matebook", ALC255_FIXUP_MIC_MUTE_LED),
8532         {}
8533 };
8534
8535 static const struct hda_model_fixup alc269_fixup_models[] = {
8536         {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
8537         {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
8538         {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
8539         {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
8540         {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
8541         {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
8542         {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
8543         {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
8544         {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
8545         {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
8546         {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
8547         {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
8548         {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
8549         {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
8550         {.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
8551         {.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
8552         {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
8553         {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
8554         {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
8555         {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
8556         {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
8557         {.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
8558         {.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
8559         {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
8560         {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
8561         {.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
8562         {.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
8563         {.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
8564         {.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
8565         {.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
8566         {.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
8567         {.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
8568         {.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
8569         {.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
8570         {.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
8571         {.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
8572         {.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
8573         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
8574         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
8575         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
8576         {.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
8577         {.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
8578         {.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
8579         {.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
8580         {.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
8581         {.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
8582         {.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
8583         {.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
8584         {.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
8585         {.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
8586         {.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
8587         {.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
8588         {.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
8589         {.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
8590         {.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
8591         {.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
8592         {.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
8593         {.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
8594         {.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
8595         {.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
8596         {.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
8597         {.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
8598         {.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
8599         {.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
8600         {.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
8601         {.id = ALC255_FIXUP_MIC_MUTE_LED, .name = "alc255-dell-mute"},
8602         {.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
8603         {.id = ALC269VB_FIXUP_ASPIRE_E1_COEF, .name = "aspire-e1-coef"},
8604         {.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
8605         {.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
8606         {.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
8607         {.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
8608         {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
8609         {.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
8610         {.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
8611         {.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
8612         {.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
8613         {.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
8614         {.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
8615         {.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
8616         {.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
8617         {.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
8618         {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
8619         {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
8620         {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
8621         {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
8622         {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
8623         {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
8624         {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
8625         {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
8626         {.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
8627         {.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
8628         {.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
8629         {.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
8630         {.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
8631         {.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
8632         {.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
8633         {.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
8634         {.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
8635         {.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
8636         {.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
8637         {.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
8638         {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
8639         {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
8640         {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
8641         {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
8642         {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
8643         {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
8644         {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
8645         {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
8646         {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
8647         {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
8648         {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
8649         {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
8650         {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
8651         {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
8652         {}
8653 };
8654 #define ALC225_STANDARD_PINS \
8655         {0x21, 0x04211020}
8656
8657 #define ALC256_STANDARD_PINS \
8658         {0x12, 0x90a60140}, \
8659         {0x14, 0x90170110}, \
8660         {0x21, 0x02211020}
8661
8662 #define ALC282_STANDARD_PINS \
8663         {0x14, 0x90170110}
8664
8665 #define ALC290_STANDARD_PINS \
8666         {0x12, 0x99a30130}
8667
8668 #define ALC292_STANDARD_PINS \
8669         {0x14, 0x90170110}, \
8670         {0x15, 0x0221401f}
8671
8672 #define ALC295_STANDARD_PINS \
8673         {0x12, 0xb7a60130}, \
8674         {0x14, 0x90170110}, \
8675         {0x21, 0x04211020}
8676
8677 #define ALC298_STANDARD_PINS \
8678         {0x12, 0x90a60130}, \
8679         {0x21, 0x03211020}
8680
8681 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
8682         SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
8683                 {0x14, 0x01014020},
8684                 {0x17, 0x90170110},
8685                 {0x18, 0x02a11030},
8686                 {0x19, 0x0181303F},
8687                 {0x21, 0x0221102f}),
8688         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
8689                 {0x12, 0x90a601c0},
8690                 {0x14, 0x90171120},
8691                 {0x21, 0x02211030}),
8692         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
8693                 {0x14, 0x90170110},
8694                 {0x1b, 0x90a70130},
8695                 {0x21, 0x03211020}),
8696         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
8697                 {0x1a, 0x90a70130},
8698                 {0x1b, 0x90170110},
8699                 {0x21, 0x03211020}),
8700         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
8701                 ALC225_STANDARD_PINS,
8702                 {0x12, 0xb7a60130},
8703                 {0x14, 0x901701a0}),
8704         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
8705                 ALC225_STANDARD_PINS,
8706                 {0x12, 0xb7a60130},
8707                 {0x14, 0x901701b0}),
8708         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
8709                 ALC225_STANDARD_PINS,
8710                 {0x12, 0xb7a60150},
8711                 {0x14, 0x901701a0}),
8712         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
8713                 ALC225_STANDARD_PINS,
8714                 {0x12, 0xb7a60150},
8715                 {0x14, 0x901701b0}),
8716         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
8717                 ALC225_STANDARD_PINS,
8718                 {0x12, 0xb7a60130},
8719                 {0x1b, 0x90170110}),
8720         SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
8721                 {0x1b, 0x01111010},
8722                 {0x1e, 0x01451130},
8723                 {0x21, 0x02211020}),
8724         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
8725                 {0x12, 0x90a60140},
8726                 {0x14, 0x90170110},
8727                 {0x19, 0x02a11030},
8728                 {0x21, 0x02211020}),
8729         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
8730                 {0x14, 0x90170110},
8731                 {0x19, 0x02a11030},
8732                 {0x1a, 0x02a11040},
8733                 {0x1b, 0x01014020},
8734                 {0x21, 0x0221101f}),
8735         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
8736                 {0x14, 0x90170110},
8737                 {0x19, 0x02a11030},
8738                 {0x1a, 0x02a11040},
8739                 {0x1b, 0x01011020},
8740                 {0x21, 0x0221101f}),
8741         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
8742                 {0x14, 0x90170110},
8743                 {0x19, 0x02a11020},
8744                 {0x1a, 0x02a11030},
8745                 {0x21, 0x0221101f}),
8746         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
8747                 {0x14, 0x90170110},
8748                 {0x21, 0x02211020}),
8749         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8750                 {0x14, 0x90170130},
8751                 {0x21, 0x02211040}),
8752         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8753                 {0x12, 0x90a60140},
8754                 {0x14, 0x90170110},
8755                 {0x21, 0x02211020}),
8756         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8757                 {0x12, 0x90a60160},
8758                 {0x14, 0x90170120},
8759                 {0x21, 0x02211030}),
8760         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8761                 {0x14, 0x90170110},
8762                 {0x1b, 0x02011020},
8763                 {0x21, 0x0221101f}),
8764         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8765                 {0x14, 0x90170110},
8766                 {0x1b, 0x01011020},
8767                 {0x21, 0x0221101f}),
8768         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8769                 {0x14, 0x90170130},
8770                 {0x1b, 0x01014020},
8771                 {0x21, 0x0221103f}),
8772         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8773                 {0x14, 0x90170130},
8774                 {0x1b, 0x01011020},
8775                 {0x21, 0x0221103f}),
8776         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8777                 {0x14, 0x90170130},
8778                 {0x1b, 0x02011020},
8779                 {0x21, 0x0221103f}),
8780         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8781                 {0x14, 0x90170150},
8782                 {0x1b, 0x02011020},
8783                 {0x21, 0x0221105f}),
8784         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8785                 {0x14, 0x90170110},
8786                 {0x1b, 0x01014020},
8787                 {0x21, 0x0221101f}),
8788         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8789                 {0x12, 0x90a60160},
8790                 {0x14, 0x90170120},
8791                 {0x17, 0x90170140},
8792                 {0x21, 0x0321102f}),
8793         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8794                 {0x12, 0x90a60160},
8795                 {0x14, 0x90170130},
8796                 {0x21, 0x02211040}),
8797         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8798                 {0x12, 0x90a60160},
8799                 {0x14, 0x90170140},
8800                 {0x21, 0x02211050}),
8801         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8802                 {0x12, 0x90a60170},
8803                 {0x14, 0x90170120},
8804                 {0x21, 0x02211030}),
8805         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8806                 {0x12, 0x90a60170},
8807                 {0x14, 0x90170130},
8808                 {0x21, 0x02211040}),
8809         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8810                 {0x12, 0x90a60170},
8811                 {0x14, 0x90171130},
8812                 {0x21, 0x02211040}),
8813         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8814                 {0x12, 0x90a60170},
8815                 {0x14, 0x90170140},
8816                 {0x21, 0x02211050}),
8817         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8818                 {0x12, 0x90a60180},
8819                 {0x14, 0x90170130},
8820                 {0x21, 0x02211040}),
8821         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8822                 {0x12, 0x90a60180},
8823                 {0x14, 0x90170120},
8824                 {0x21, 0x02211030}),
8825         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8826                 {0x1b, 0x01011020},
8827                 {0x21, 0x02211010}),
8828         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8829                 {0x12, 0x90a60130},
8830                 {0x14, 0x90170110},
8831                 {0x1b, 0x01011020},
8832                 {0x21, 0x0221101f}),
8833         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8834                 {0x12, 0x90a60160},
8835                 {0x14, 0x90170120},
8836                 {0x21, 0x02211030}),
8837         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8838                 {0x12, 0x90a60170},
8839                 {0x14, 0x90170120},
8840                 {0x21, 0x02211030}),
8841         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8842                 {0x12, 0x90a60180},
8843                 {0x14, 0x90170120},
8844                 {0x21, 0x02211030}),
8845         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8846                 {0x12, 0xb7a60130},
8847                 {0x14, 0x90170110},
8848                 {0x21, 0x02211020}),
8849         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8850                 {0x12, 0x90a60130},
8851                 {0x14, 0x90170110},
8852                 {0x14, 0x01011020},
8853                 {0x21, 0x0221101f}),
8854         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8855                 ALC256_STANDARD_PINS),
8856         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
8857                 {0x14, 0x90170110},
8858                 {0x1b, 0x01011020},
8859                 {0x21, 0x0221101f}),
8860         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
8861                 {0x14, 0x90170110},
8862                 {0x1b, 0x90a70130},
8863                 {0x21, 0x04211020}),
8864         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
8865                 {0x14, 0x90170110},
8866                 {0x1b, 0x90a70130},
8867                 {0x21, 0x03211020}),
8868         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
8869                 {0x12, 0x90a60130},
8870                 {0x14, 0x90170110},
8871                 {0x21, 0x03211020}),
8872         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
8873                 {0x12, 0x90a60130},
8874                 {0x14, 0x90170110},
8875                 {0x21, 0x04211020}),
8876         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
8877                 {0x1a, 0x90a70130},
8878                 {0x1b, 0x90170110},
8879                 {0x21, 0x03211020}),
8880        SND_HDA_PIN_QUIRK(0x10ec0274, 0x103c, "HP", ALC274_FIXUP_HP_HEADSET_MIC,
8881                 {0x17, 0x90170110},
8882                 {0x19, 0x03a11030},
8883                 {0x21, 0x03211020}),
8884         SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
8885                 {0x12, 0x90a60130},
8886                 {0x14, 0x90170110},
8887                 {0x15, 0x0421101f},
8888                 {0x1a, 0x04a11020}),
8889         SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
8890                 {0x12, 0x90a60140},
8891                 {0x14, 0x90170110},
8892                 {0x15, 0x0421101f},
8893                 {0x18, 0x02811030},
8894                 {0x1a, 0x04a1103f},
8895                 {0x1b, 0x02011020}),
8896         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8897                 ALC282_STANDARD_PINS,
8898                 {0x12, 0x99a30130},
8899                 {0x19, 0x03a11020},
8900                 {0x21, 0x0321101f}),
8901         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8902                 ALC282_STANDARD_PINS,
8903                 {0x12, 0x99a30130},
8904                 {0x19, 0x03a11020},
8905                 {0x21, 0x03211040}),
8906         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8907                 ALC282_STANDARD_PINS,
8908                 {0x12, 0x99a30130},
8909                 {0x19, 0x03a11030},
8910                 {0x21, 0x03211020}),
8911         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8912                 ALC282_STANDARD_PINS,
8913                 {0x12, 0x99a30130},
8914                 {0x19, 0x04a11020},
8915                 {0x21, 0x0421101f}),
8916         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
8917                 ALC282_STANDARD_PINS,
8918                 {0x12, 0x90a60140},
8919                 {0x19, 0x04a11030},
8920                 {0x21, 0x04211020}),
8921         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
8922                 ALC282_STANDARD_PINS,
8923                 {0x12, 0x90a60130},
8924                 {0x21, 0x0321101f}),
8925         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
8926                 {0x12, 0x90a60160},
8927                 {0x14, 0x90170120},
8928                 {0x21, 0x02211030}),
8929         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
8930                 ALC282_STANDARD_PINS,
8931                 {0x12, 0x90a60130},
8932                 {0x19, 0x03a11020},
8933                 {0x21, 0x0321101f}),
8934         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
8935                 {0x12, 0x90a60130},
8936                 {0x14, 0x90170110},
8937                 {0x19, 0x04a11040},
8938                 {0x21, 0x04211020}),
8939         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
8940                 {0x14, 0x90170110},
8941                 {0x19, 0x04a11040},
8942                 {0x1d, 0x40600001},
8943                 {0x21, 0x04211020}),
8944         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
8945                 {0x14, 0x90170110},
8946                 {0x19, 0x04a11040},
8947                 {0x21, 0x04211020}),
8948         SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_HEADSET_JACK,
8949                 {0x14, 0x90170110},
8950                 {0x17, 0x90170111},
8951                 {0x19, 0x03a11030},
8952                 {0x21, 0x03211020}),
8953         SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
8954                 {0x12, 0x90a60130},
8955                 {0x17, 0x90170110},
8956                 {0x21, 0x02211020}),
8957         SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
8958                 {0x12, 0x90a60120},
8959                 {0x14, 0x90170110},
8960                 {0x21, 0x0321101f}),
8961         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8962                 ALC290_STANDARD_PINS,
8963                 {0x15, 0x04211040},
8964                 {0x18, 0x90170112},
8965                 {0x1a, 0x04a11020}),
8966         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8967                 ALC290_STANDARD_PINS,
8968                 {0x15, 0x04211040},
8969                 {0x18, 0x90170110},
8970                 {0x1a, 0x04a11020}),
8971         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8972                 ALC290_STANDARD_PINS,
8973                 {0x15, 0x0421101f},
8974                 {0x1a, 0x04a11020}),
8975         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8976                 ALC290_STANDARD_PINS,
8977                 {0x15, 0x04211020},
8978                 {0x1a, 0x04a11040}),
8979         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8980                 ALC290_STANDARD_PINS,
8981                 {0x14, 0x90170110},
8982                 {0x15, 0x04211020},
8983                 {0x1a, 0x04a11040}),
8984         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8985                 ALC290_STANDARD_PINS,
8986                 {0x14, 0x90170110},
8987                 {0x15, 0x04211020},
8988                 {0x1a, 0x04a11020}),
8989         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
8990                 ALC290_STANDARD_PINS,
8991                 {0x14, 0x90170110},
8992                 {0x15, 0x0421101f},
8993                 {0x1a, 0x04a11020}),
8994         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
8995                 ALC292_STANDARD_PINS,
8996                 {0x12, 0x90a60140},
8997                 {0x16, 0x01014020},
8998                 {0x19, 0x01a19030}),
8999         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9000                 ALC292_STANDARD_PINS,
9001                 {0x12, 0x90a60140},
9002                 {0x16, 0x01014020},
9003                 {0x18, 0x02a19031},
9004                 {0x19, 0x01a1903e}),
9005         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
9006                 ALC292_STANDARD_PINS,
9007                 {0x12, 0x90a60140}),
9008         SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9009                 ALC292_STANDARD_PINS,
9010                 {0x13, 0x90a60140},
9011                 {0x16, 0x21014020},
9012                 {0x19, 0x21a19030}),
9013         SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9014                 ALC292_STANDARD_PINS,
9015                 {0x13, 0x90a60140}),
9016         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_HPE,
9017                 {0x17, 0x90170110},
9018                 {0x21, 0x04211020}),
9019         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
9020                 {0x14, 0x90170110},
9021                 {0x1b, 0x90a70130},
9022                 {0x21, 0x04211020}),
9023         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9024                 {0x12, 0x90a60130},
9025                 {0x17, 0x90170110},
9026                 {0x21, 0x03211020}),
9027         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9028                 {0x12, 0x90a60130},
9029                 {0x17, 0x90170110},
9030                 {0x21, 0x04211020}),
9031         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9032                 {0x12, 0x90a60130},
9033                 {0x17, 0x90170110},
9034                 {0x21, 0x03211020}),
9035         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9036                 {0x12, 0x90a60120},
9037                 {0x17, 0x90170110},
9038                 {0x21, 0x04211030}),
9039         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9040                 {0x12, 0x90a60130},
9041                 {0x17, 0x90170110},
9042                 {0x21, 0x03211020}),
9043         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9044                 {0x12, 0x90a60130},
9045                 {0x17, 0x90170110},
9046                 {0x21, 0x03211020}),
9047         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9048                 {0x14, 0x90170110},
9049                 {0x21, 0x04211020}),
9050         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9051                 {0x14, 0x90170110},
9052                 {0x21, 0x04211030}),
9053         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9054                 ALC295_STANDARD_PINS,
9055                 {0x17, 0x21014020},
9056                 {0x18, 0x21a19030}),
9057         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9058                 ALC295_STANDARD_PINS,
9059                 {0x17, 0x21014040},
9060                 {0x18, 0x21a19050}),
9061         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9062                 ALC295_STANDARD_PINS),
9063         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9064                 ALC298_STANDARD_PINS,
9065                 {0x17, 0x90170110}),
9066         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9067                 ALC298_STANDARD_PINS,
9068                 {0x17, 0x90170140}),
9069         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9070                 ALC298_STANDARD_PINS,
9071                 {0x17, 0x90170150}),
9072         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
9073                 {0x12, 0xb7a60140},
9074                 {0x13, 0xb7a60150},
9075                 {0x17, 0x90170110},
9076                 {0x1a, 0x03011020},
9077                 {0x21, 0x03211030}),
9078         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
9079                 {0x12, 0xb7a60140},
9080                 {0x17, 0x90170110},
9081                 {0x1a, 0x03a11030},
9082                 {0x21, 0x03211020}),
9083         SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9084                 ALC225_STANDARD_PINS,
9085                 {0x12, 0xb7a60130},
9086                 {0x17, 0x90170110}),
9087         SND_HDA_PIN_QUIRK(0x10ec0623, 0x17aa, "Lenovo", ALC283_FIXUP_HEADSET_MIC,
9088                 {0x14, 0x01014010},
9089                 {0x17, 0x90170120},
9090                 {0x18, 0x02a11030},
9091                 {0x19, 0x02a1103f},
9092                 {0x21, 0x0221101f}),
9093         {}
9094 };
9095
9096 /* This is the fallback pin_fixup_tbl for alc269 family, to make the tbl match
9097  * more machines, don't need to match all valid pins, just need to match
9098  * all the pins defined in the tbl. Just because of this reason, it is possible
9099  * that a single machine matches multiple tbls, so there is one limitation:
9100  *   at most one tbl is allowed to define for the same vendor and same codec
9101  */
9102 static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
9103         SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9104                 {0x19, 0x40000000},
9105                 {0x1b, 0x40000000}),
9106         SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
9107                 {0x19, 0x40000000},
9108                 {0x1a, 0x40000000}),
9109         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9110                 {0x19, 0x40000000},
9111                 {0x1a, 0x40000000}),
9112         {}
9113 };
9114
9115 static void alc269_fill_coef(struct hda_codec *codec)
9116 {
9117         struct alc_spec *spec = codec->spec;
9118         int val;
9119
9120         if (spec->codec_variant != ALC269_TYPE_ALC269VB)
9121                 return;
9122
9123         if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
9124                 alc_write_coef_idx(codec, 0xf, 0x960b);
9125                 alc_write_coef_idx(codec, 0xe, 0x8817);
9126         }
9127
9128         if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
9129                 alc_write_coef_idx(codec, 0xf, 0x960b);
9130                 alc_write_coef_idx(codec, 0xe, 0x8814);
9131         }
9132
9133         if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
9134                 /* Power up output pin */
9135                 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
9136         }
9137
9138         if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
9139                 val = alc_read_coef_idx(codec, 0xd);
9140                 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
9141                         /* Capless ramp up clock control */
9142                         alc_write_coef_idx(codec, 0xd, val | (1<<10));
9143                 }
9144                 val = alc_read_coef_idx(codec, 0x17);
9145                 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
9146                         /* Class D power on reset */
9147                         alc_write_coef_idx(codec, 0x17, val | (1<<7));
9148                 }
9149         }
9150
9151         /* HP */
9152         alc_update_coef_idx(codec, 0x4, 0, 1<<11);
9153 }
9154
9155 /*
9156  */
9157 static int patch_alc269(struct hda_codec *codec)
9158 {
9159         struct alc_spec *spec;
9160         int err;
9161
9162         err = alc_alloc_spec(codec, 0x0b);
9163         if (err < 0)
9164                 return err;
9165
9166         spec = codec->spec;
9167         spec->gen.shared_mic_vref_pin = 0x18;
9168         codec->power_save_node = 0;
9169
9170 #ifdef CONFIG_PM
9171         codec->patch_ops.suspend = alc269_suspend;
9172         codec->patch_ops.resume = alc269_resume;
9173 #endif
9174         spec->shutup = alc_default_shutup;
9175         spec->init_hook = alc_default_init;
9176
9177         switch (codec->core.vendor_id) {
9178         case 0x10ec0269:
9179                 spec->codec_variant = ALC269_TYPE_ALC269VA;
9180                 switch (alc_get_coef0(codec) & 0x00f0) {
9181                 case 0x0010:
9182                         if (codec->bus->pci &&
9183                             codec->bus->pci->subsystem_vendor == 0x1025 &&
9184                             spec->cdefine.platform_type == 1)
9185                                 err = alc_codec_rename(codec, "ALC271X");
9186                         spec->codec_variant = ALC269_TYPE_ALC269VB;
9187                         break;
9188                 case 0x0020:
9189                         if (codec->bus->pci &&
9190                             codec->bus->pci->subsystem_vendor == 0x17aa &&
9191                             codec->bus->pci->subsystem_device == 0x21f3)
9192                                 err = alc_codec_rename(codec, "ALC3202");
9193                         spec->codec_variant = ALC269_TYPE_ALC269VC;
9194                         break;
9195                 case 0x0030:
9196                         spec->codec_variant = ALC269_TYPE_ALC269VD;
9197                         break;
9198                 default:
9199                         alc_fix_pll_init(codec, 0x20, 0x04, 15);
9200                 }
9201                 if (err < 0)
9202                         goto error;
9203                 spec->shutup = alc269_shutup;
9204                 spec->init_hook = alc269_fill_coef;
9205                 alc269_fill_coef(codec);
9206                 break;
9207
9208         case 0x10ec0280:
9209         case 0x10ec0290:
9210                 spec->codec_variant = ALC269_TYPE_ALC280;
9211                 break;
9212         case 0x10ec0282:
9213                 spec->codec_variant = ALC269_TYPE_ALC282;
9214                 spec->shutup = alc282_shutup;
9215                 spec->init_hook = alc282_init;
9216                 break;
9217         case 0x10ec0233:
9218         case 0x10ec0283:
9219                 spec->codec_variant = ALC269_TYPE_ALC283;
9220                 spec->shutup = alc283_shutup;
9221                 spec->init_hook = alc283_init;
9222                 break;
9223         case 0x10ec0284:
9224         case 0x10ec0292:
9225                 spec->codec_variant = ALC269_TYPE_ALC284;
9226                 break;
9227         case 0x10ec0293:
9228                 spec->codec_variant = ALC269_TYPE_ALC293;
9229                 break;
9230         case 0x10ec0286:
9231         case 0x10ec0288:
9232                 spec->codec_variant = ALC269_TYPE_ALC286;
9233                 break;
9234         case 0x10ec0298:
9235                 spec->codec_variant = ALC269_TYPE_ALC298;
9236                 break;
9237         case 0x10ec0235:
9238         case 0x10ec0255:
9239                 spec->codec_variant = ALC269_TYPE_ALC255;
9240                 spec->shutup = alc256_shutup;
9241                 spec->init_hook = alc256_init;
9242                 break;
9243         case 0x10ec0230:
9244         case 0x10ec0236:
9245         case 0x10ec0256:
9246         case 0x19e58326:
9247                 spec->codec_variant = ALC269_TYPE_ALC256;
9248                 spec->shutup = alc256_shutup;
9249                 spec->init_hook = alc256_init;
9250                 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
9251                 break;
9252         case 0x10ec0257:
9253                 spec->codec_variant = ALC269_TYPE_ALC257;
9254                 spec->shutup = alc256_shutup;
9255                 spec->init_hook = alc256_init;
9256                 spec->gen.mixer_nid = 0;
9257                 break;
9258         case 0x10ec0215:
9259         case 0x10ec0245:
9260         case 0x10ec0285:
9261         case 0x10ec0287:
9262         case 0x10ec0289:
9263                 spec->codec_variant = ALC269_TYPE_ALC215;
9264                 spec->shutup = alc225_shutup;
9265                 spec->init_hook = alc225_init;
9266                 spec->gen.mixer_nid = 0;
9267                 break;
9268         case 0x10ec0225:
9269         case 0x10ec0295:
9270         case 0x10ec0299:
9271                 spec->codec_variant = ALC269_TYPE_ALC225;
9272                 spec->shutup = alc225_shutup;
9273                 spec->init_hook = alc225_init;
9274                 spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
9275                 break;
9276         case 0x10ec0234:
9277         case 0x10ec0274:
9278         case 0x10ec0294:
9279                 spec->codec_variant = ALC269_TYPE_ALC294;
9280                 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
9281                 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
9282                 spec->init_hook = alc294_init;
9283                 break;
9284         case 0x10ec0300:
9285                 spec->codec_variant = ALC269_TYPE_ALC300;
9286                 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
9287                 break;
9288         case 0x10ec0623:
9289                 spec->codec_variant = ALC269_TYPE_ALC623;
9290                 break;
9291         case 0x10ec0700:
9292         case 0x10ec0701:
9293         case 0x10ec0703:
9294         case 0x10ec0711:
9295                 spec->codec_variant = ALC269_TYPE_ALC700;
9296                 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
9297                 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
9298                 spec->init_hook = alc294_init;
9299                 break;
9300
9301         }
9302
9303         if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
9304                 spec->has_alc5505_dsp = 1;
9305                 spec->init_hook = alc5505_dsp_init;
9306         }
9307
9308         alc_pre_init(codec);
9309
9310         snd_hda_pick_fixup(codec, alc269_fixup_models,
9311                        alc269_fixup_tbl, alc269_fixups);
9312         /* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
9313          * the quirk breaks the latter (bko#214101).
9314          * Clear the wrong entry.
9315          */
9316         if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
9317             codec->core.vendor_id == 0x10ec0294) {
9318                 codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
9319                 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
9320         }
9321
9322         snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
9323         snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
9324         snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
9325                            alc269_fixups);
9326         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9327
9328         alc_auto_parse_customize_define(codec);
9329
9330         if (has_cdefine_beep(codec))
9331                 spec->gen.beep_nid = 0x01;
9332
9333         /* automatic parse from the BIOS config */
9334         err = alc269_parse_auto_config(codec);
9335         if (err < 0)
9336                 goto error;
9337
9338         if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
9339                 err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
9340                 if (err < 0)
9341                         goto error;
9342         }
9343
9344         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9345
9346         return 0;
9347
9348  error:
9349         alc_free(codec);
9350         return err;
9351 }
9352
9353 /*
9354  * ALC861
9355  */
9356
9357 static int alc861_parse_auto_config(struct hda_codec *codec)
9358 {
9359         static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9360         static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
9361         return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
9362 }
9363
9364 /* Pin config fixes */
9365 enum {
9366         ALC861_FIXUP_FSC_AMILO_PI1505,
9367         ALC861_FIXUP_AMP_VREF_0F,
9368         ALC861_FIXUP_NO_JACK_DETECT,
9369         ALC861_FIXUP_ASUS_A6RP,
9370         ALC660_FIXUP_ASUS_W7J,
9371 };
9372
9373 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
9374 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
9375                         const struct hda_fixup *fix, int action)
9376 {
9377         struct alc_spec *spec = codec->spec;
9378         unsigned int val;
9379
9380         if (action != HDA_FIXUP_ACT_INIT)
9381                 return;
9382         val = snd_hda_codec_get_pin_target(codec, 0x0f);
9383         if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
9384                 val |= AC_PINCTL_IN_EN;
9385         val |= AC_PINCTL_VREF_50;
9386         snd_hda_set_pin_ctl(codec, 0x0f, val);
9387         spec->gen.keep_vref_in_automute = 1;
9388 }
9389
9390 /* suppress the jack-detection */
9391 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
9392                                      const struct hda_fixup *fix, int action)
9393 {
9394         if (action == HDA_FIXUP_ACT_PRE_PROBE)
9395                 codec->no_jack_detect = 1;
9396 }
9397
9398 static const struct hda_fixup alc861_fixups[] = {
9399         [ALC861_FIXUP_FSC_AMILO_PI1505] = {
9400                 .type = HDA_FIXUP_PINS,
9401                 .v.pins = (const struct hda_pintbl[]) {
9402                         { 0x0b, 0x0221101f }, /* HP */
9403                         { 0x0f, 0x90170310 }, /* speaker */
9404                         { }
9405                 }
9406         },
9407         [ALC861_FIXUP_AMP_VREF_0F] = {
9408                 .type = HDA_FIXUP_FUNC,
9409                 .v.func = alc861_fixup_asus_amp_vref_0f,
9410         },
9411         [ALC861_FIXUP_NO_JACK_DETECT] = {
9412                 .type = HDA_FIXUP_FUNC,
9413                 .v.func = alc_fixup_no_jack_detect,
9414         },
9415         [ALC861_FIXUP_ASUS_A6RP] = {
9416                 .type = HDA_FIXUP_FUNC,
9417                 .v.func = alc861_fixup_asus_amp_vref_0f,
9418                 .chained = true,
9419                 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
9420         },
9421         [ALC660_FIXUP_ASUS_W7J] = {
9422                 .type = HDA_FIXUP_VERBS,
9423                 .v.verbs = (const struct hda_verb[]) {
9424                         /* ASUS W7J needs a magic pin setup on unused NID 0x10
9425                          * for enabling outputs
9426                          */
9427                         {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9428                         { }
9429                 },
9430         }
9431 };
9432
9433 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
9434         SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
9435         SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
9436         SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
9437         SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
9438         SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
9439         SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
9440         SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
9441         {}
9442 };
9443
9444 /*
9445  */
9446 static int patch_alc861(struct hda_codec *codec)
9447 {
9448         struct alc_spec *spec;
9449         int err;
9450
9451         err = alc_alloc_spec(codec, 0x15);
9452         if (err < 0)
9453                 return err;
9454
9455         spec = codec->spec;
9456         if (has_cdefine_beep(codec))
9457                 spec->gen.beep_nid = 0x23;
9458
9459 #ifdef CONFIG_PM
9460         spec->power_hook = alc_power_eapd;
9461 #endif
9462
9463         alc_pre_init(codec);
9464
9465         snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
9466         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9467
9468         /* automatic parse from the BIOS config */
9469         err = alc861_parse_auto_config(codec);
9470         if (err < 0)
9471                 goto error;
9472
9473         if (!spec->gen.no_analog) {
9474                 err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
9475                 if (err < 0)
9476                         goto error;
9477         }
9478
9479         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9480
9481         return 0;
9482
9483  error:
9484         alc_free(codec);
9485         return err;
9486 }
9487
9488 /*
9489  * ALC861-VD support
9490  *
9491  * Based on ALC882
9492  *
9493  * In addition, an independent DAC
9494  */
9495 static int alc861vd_parse_auto_config(struct hda_codec *codec)
9496 {
9497         static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
9498         static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
9499         return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
9500 }
9501
9502 enum {
9503         ALC660VD_FIX_ASUS_GPIO1,
9504         ALC861VD_FIX_DALLAS,
9505 };
9506
9507 /* exclude VREF80 */
9508 static void alc861vd_fixup_dallas(struct hda_codec *codec,
9509                                   const struct hda_fixup *fix, int action)
9510 {
9511         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
9512                 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
9513                 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
9514         }
9515 }
9516
9517 /* reset GPIO1 */
9518 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
9519                                       const struct hda_fixup *fix, int action)
9520 {
9521         struct alc_spec *spec = codec->spec;
9522
9523         if (action == HDA_FIXUP_ACT_PRE_PROBE)
9524                 spec->gpio_mask |= 0x02;
9525         alc_fixup_gpio(codec, action, 0x01);
9526 }
9527
9528 static const struct hda_fixup alc861vd_fixups[] = {
9529         [ALC660VD_FIX_ASUS_GPIO1] = {
9530                 .type = HDA_FIXUP_FUNC,
9531                 .v.func = alc660vd_fixup_asus_gpio1,
9532         },
9533         [ALC861VD_FIX_DALLAS] = {
9534                 .type = HDA_FIXUP_FUNC,
9535                 .v.func = alc861vd_fixup_dallas,
9536         },
9537 };
9538
9539 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
9540         SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
9541         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
9542         SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
9543         {}
9544 };
9545
9546 /*
9547  */
9548 static int patch_alc861vd(struct hda_codec *codec)
9549 {
9550         struct alc_spec *spec;
9551         int err;
9552
9553         err = alc_alloc_spec(codec, 0x0b);
9554         if (err < 0)
9555                 return err;
9556
9557         spec = codec->spec;
9558         if (has_cdefine_beep(codec))
9559                 spec->gen.beep_nid = 0x23;
9560
9561         spec->shutup = alc_eapd_shutup;
9562
9563         alc_pre_init(codec);
9564
9565         snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
9566         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9567
9568         /* automatic parse from the BIOS config */
9569         err = alc861vd_parse_auto_config(codec);
9570         if (err < 0)
9571                 goto error;
9572
9573         if (!spec->gen.no_analog) {
9574                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9575                 if (err < 0)
9576                         goto error;
9577         }
9578
9579         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9580
9581         return 0;
9582
9583  error:
9584         alc_free(codec);
9585         return err;
9586 }
9587
9588 /*
9589  * ALC662 support
9590  *
9591  * ALC662 is almost identical with ALC880 but has cleaner and more flexible
9592  * configuration.  Each pin widget can choose any input DACs and a mixer.
9593  * Each ADC is connected from a mixer of all inputs.  This makes possible
9594  * 6-channel independent captures.
9595  *
9596  * In addition, an independent DAC for the multi-playback (not used in this
9597  * driver yet).
9598  */
9599
9600 /*
9601  * BIOS auto configuration
9602  */
9603
9604 static int alc662_parse_auto_config(struct hda_codec *codec)
9605 {
9606         static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
9607         static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
9608         static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
9609         const hda_nid_t *ssids;
9610
9611         if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
9612             codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
9613             codec->core.vendor_id == 0x10ec0671)
9614                 ssids = alc663_ssids;
9615         else
9616                 ssids = alc662_ssids;
9617         return alc_parse_auto_config(codec, alc662_ignore, ssids);
9618 }
9619
9620 static void alc272_fixup_mario(struct hda_codec *codec,
9621                                const struct hda_fixup *fix, int action)
9622 {
9623         if (action != HDA_FIXUP_ACT_PRE_PROBE)
9624                 return;
9625         if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
9626                                       (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
9627                                       (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
9628                                       (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
9629                                       (0 << AC_AMPCAP_MUTE_SHIFT)))
9630                 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
9631 }
9632
9633 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
9634         { .channels = 2,
9635           .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
9636         { .channels = 4,
9637           .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
9638                    SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
9639         { }
9640 };
9641
9642 /* override the 2.1 chmap */
9643 static void alc_fixup_bass_chmap(struct hda_codec *codec,
9644                                     const struct hda_fixup *fix, int action)
9645 {
9646         if (action == HDA_FIXUP_ACT_BUILD) {
9647                 struct alc_spec *spec = codec->spec;
9648                 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
9649         }
9650 }
9651
9652 /* avoid D3 for keeping GPIO up */
9653 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
9654                                           hda_nid_t nid,
9655                                           unsigned int power_state)
9656 {
9657         struct alc_spec *spec = codec->spec;
9658         if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
9659                 return AC_PWRST_D0;
9660         return power_state;
9661 }
9662
9663 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
9664                                    const struct hda_fixup *fix, int action)
9665 {
9666         struct alc_spec *spec = codec->spec;
9667
9668         alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
9669         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
9670                 spec->mute_led_polarity = 1;
9671                 codec->power_filter = gpio_led_power_filter;
9672         }
9673 }
9674
9675 static void alc662_usi_automute_hook(struct hda_codec *codec,
9676                                          struct hda_jack_callback *jack)
9677 {
9678         struct alc_spec *spec = codec->spec;
9679         int vref;
9680         msleep(200);
9681         snd_hda_gen_hp_automute(codec, jack);
9682
9683         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
9684         msleep(100);
9685         snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9686                             vref);
9687 }
9688
9689 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
9690                                      const struct hda_fixup *fix, int action)
9691 {
9692         struct alc_spec *spec = codec->spec;
9693         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
9694                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
9695                 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
9696         }
9697 }
9698
9699 static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
9700                                         struct hda_jack_callback *cb)
9701 {
9702         /* surround speakers at 0x1b already get muted automatically when
9703          * headphones are plugged in, but we have to mute/unmute the remaining
9704          * channels manually:
9705          * 0x15 - front left/front right
9706          * 0x18 - front center/ LFE
9707          */
9708         if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
9709                 snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
9710                 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
9711         } else {
9712                 snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
9713                 snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
9714         }
9715 }
9716
9717 static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
9718                                         const struct hda_fixup *fix, int action)
9719 {
9720     /* Pin 0x1b: shared headphones jack and surround speakers */
9721         if (!is_jack_detectable(codec, 0x1b))
9722                 return;
9723
9724         switch (action) {
9725         case HDA_FIXUP_ACT_PRE_PROBE:
9726                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
9727                                 alc662_aspire_ethos_mute_speakers);
9728                 /* subwoofer needs an extra GPIO setting to become audible */
9729                 alc_setup_gpio(codec, 0x02);
9730                 break;
9731         case HDA_FIXUP_ACT_INIT:
9732                 /* Make sure to start in a correct state, i.e. if
9733                  * headphones have been plugged in before powering up the system
9734                  */
9735                 alc662_aspire_ethos_mute_speakers(codec, NULL);
9736                 break;
9737         }
9738 }
9739
9740 static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
9741                                              const struct hda_fixup *fix, int action)
9742 {
9743         struct alc_spec *spec = codec->spec;
9744
9745         static const struct hda_pintbl pincfgs[] = {
9746                 { 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */
9747                 { 0x1b, 0x0181304f },
9748                 { }
9749         };
9750
9751         switch (action) {
9752         case HDA_FIXUP_ACT_PRE_PROBE:
9753                 spec->gen.mixer_nid = 0;
9754                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
9755                 snd_hda_apply_pincfgs(codec, pincfgs);
9756                 break;
9757         case HDA_FIXUP_ACT_INIT:
9758                 alc_write_coef_idx(codec, 0x19, 0xa054);
9759                 break;
9760         }
9761 }
9762
9763 static void alc897_hp_automute_hook(struct hda_codec *codec,
9764                                          struct hda_jack_callback *jack)
9765 {
9766         struct alc_spec *spec = codec->spec;
9767         int vref;
9768
9769         snd_hda_gen_hp_automute(codec, jack);
9770         vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP;
9771         snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9772                             vref);
9773 }
9774
9775 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
9776                                      const struct hda_fixup *fix, int action)
9777 {
9778         struct alc_spec *spec = codec->spec;
9779         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
9780                 spec->gen.hp_automute_hook = alc897_hp_automute_hook;
9781         }
9782 }
9783
9784 static void alc897_fixup_lenovo_headset_mode(struct hda_codec *codec,
9785                                      const struct hda_fixup *fix, int action)
9786 {
9787         struct alc_spec *spec = codec->spec;
9788
9789         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
9790                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
9791                 spec->gen.hp_automute_hook = alc897_hp_automute_hook;
9792         }
9793 }
9794
9795 static const struct coef_fw alc668_coefs[] = {
9796         WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
9797         WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
9798         WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
9799         WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
9800         WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
9801         WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
9802         WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
9803         WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
9804         WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
9805         WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
9806         WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
9807         WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
9808         WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
9809         WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
9810         WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
9811         WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
9812         WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
9813         WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
9814         WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
9815         WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
9816         {}
9817 };
9818
9819 static void alc668_restore_default_value(struct hda_codec *codec)
9820 {
9821         alc_process_coef_fw(codec, alc668_coefs);
9822 }
9823
9824 enum {
9825         ALC662_FIXUP_ASPIRE,
9826         ALC662_FIXUP_LED_GPIO1,
9827         ALC662_FIXUP_IDEAPAD,
9828         ALC272_FIXUP_MARIO,
9829         ALC662_FIXUP_CZC_ET26,
9830         ALC662_FIXUP_CZC_P10T,
9831         ALC662_FIXUP_SKU_IGNORE,
9832         ALC662_FIXUP_HP_RP5800,
9833         ALC662_FIXUP_ASUS_MODE1,
9834         ALC662_FIXUP_ASUS_MODE2,
9835         ALC662_FIXUP_ASUS_MODE3,
9836         ALC662_FIXUP_ASUS_MODE4,
9837         ALC662_FIXUP_ASUS_MODE5,
9838         ALC662_FIXUP_ASUS_MODE6,
9839         ALC662_FIXUP_ASUS_MODE7,
9840         ALC662_FIXUP_ASUS_MODE8,
9841         ALC662_FIXUP_NO_JACK_DETECT,
9842         ALC662_FIXUP_ZOTAC_Z68,
9843         ALC662_FIXUP_INV_DMIC,
9844         ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
9845         ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
9846         ALC662_FIXUP_HEADSET_MODE,
9847         ALC668_FIXUP_HEADSET_MODE,
9848         ALC662_FIXUP_BASS_MODE4_CHMAP,
9849         ALC662_FIXUP_BASS_16,
9850         ALC662_FIXUP_BASS_1A,
9851         ALC662_FIXUP_BASS_CHMAP,
9852         ALC668_FIXUP_AUTO_MUTE,
9853         ALC668_FIXUP_DELL_DISABLE_AAMIX,
9854         ALC668_FIXUP_DELL_XPS13,
9855         ALC662_FIXUP_ASUS_Nx50,
9856         ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
9857         ALC668_FIXUP_ASUS_Nx51,
9858         ALC668_FIXUP_MIC_COEF,
9859         ALC668_FIXUP_ASUS_G751,
9860         ALC891_FIXUP_HEADSET_MODE,
9861         ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
9862         ALC662_FIXUP_ACER_VERITON,
9863         ALC892_FIXUP_ASROCK_MOBO,
9864         ALC662_FIXUP_USI_FUNC,
9865         ALC662_FIXUP_USI_HEADSET_MODE,
9866         ALC662_FIXUP_LENOVO_MULTI_CODECS,
9867         ALC669_FIXUP_ACER_ASPIRE_ETHOS,
9868         ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET,
9869         ALC671_FIXUP_HP_HEADSET_MIC2,
9870         ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
9871         ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
9872         ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
9873         ALC668_FIXUP_HEADSET_MIC,
9874         ALC668_FIXUP_MIC_DET_COEF,
9875         ALC897_FIXUP_LENOVO_HEADSET_MIC,
9876         ALC897_FIXUP_HEADSET_MIC_PIN,
9877         ALC897_FIXUP_HP_HSMIC_VERB,
9878         ALC897_FIXUP_LENOVO_HEADSET_MODE,
9879         ALC897_FIXUP_HEADSET_MIC_PIN2,
9880         ALC897_FIXUP_UNIS_H3C_X500S,
9881 };
9882
9883 static const struct hda_fixup alc662_fixups[] = {
9884         [ALC662_FIXUP_ASPIRE] = {
9885                 .type = HDA_FIXUP_PINS,
9886                 .v.pins = (const struct hda_pintbl[]) {
9887                         { 0x15, 0x99130112 }, /* subwoofer */
9888                         { }
9889                 }
9890         },
9891         [ALC662_FIXUP_LED_GPIO1] = {
9892                 .type = HDA_FIXUP_FUNC,
9893                 .v.func = alc662_fixup_led_gpio1,
9894         },
9895         [ALC662_FIXUP_IDEAPAD] = {
9896                 .type = HDA_FIXUP_PINS,
9897                 .v.pins = (const struct hda_pintbl[]) {
9898                         { 0x17, 0x99130112 }, /* subwoofer */
9899                         { }
9900                 },
9901                 .chained = true,
9902                 .chain_id = ALC662_FIXUP_LED_GPIO1,
9903         },
9904         [ALC272_FIXUP_MARIO] = {
9905                 .type = HDA_FIXUP_FUNC,
9906                 .v.func = alc272_fixup_mario,
9907         },
9908         [ALC662_FIXUP_CZC_ET26] = {
9909                 .type = HDA_FIXUP_PINS,
9910                 .v.pins = (const struct hda_pintbl[]) {
9911                         {0x12, 0x403cc000},
9912                         {0x14, 0x90170110}, /* speaker */
9913                         {0x15, 0x411111f0},
9914                         {0x16, 0x411111f0},
9915                         {0x18, 0x01a19030}, /* mic */
9916                         {0x19, 0x90a7013f}, /* int-mic */
9917                         {0x1a, 0x01014020},
9918                         {0x1b, 0x0121401f},
9919                         {0x1c, 0x411111f0},
9920                         {0x1d, 0x411111f0},
9921                         {0x1e, 0x40478e35},
9922                         {}
9923                 },
9924                 .chained = true,
9925                 .chain_id = ALC662_FIXUP_SKU_IGNORE
9926         },
9927         [ALC662_FIXUP_CZC_P10T] = {
9928                 .type = HDA_FIXUP_VERBS,
9929                 .v.verbs = (const struct hda_verb[]) {
9930                         {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
9931                         {}
9932                 }
9933         },
9934         [ALC662_FIXUP_SKU_IGNORE] = {
9935                 .type = HDA_FIXUP_FUNC,
9936                 .v.func = alc_fixup_sku_ignore,
9937         },
9938         [ALC662_FIXUP_HP_RP5800] = {
9939                 .type = HDA_FIXUP_PINS,
9940                 .v.pins = (const struct hda_pintbl[]) {
9941                         { 0x14, 0x0221201f }, /* HP out */
9942                         { }
9943                 },
9944                 .chained = true,
9945                 .chain_id = ALC662_FIXUP_SKU_IGNORE
9946         },
9947         [ALC662_FIXUP_ASUS_MODE1] = {
9948                 .type = HDA_FIXUP_PINS,
9949                 .v.pins = (const struct hda_pintbl[]) {
9950                         { 0x14, 0x99130110 }, /* speaker */
9951                         { 0x18, 0x01a19c20 }, /* mic */
9952                         { 0x19, 0x99a3092f }, /* int-mic */
9953                         { 0x21, 0x0121401f }, /* HP out */
9954                         { }
9955                 },
9956                 .chained = true,
9957                 .chain_id = ALC662_FIXUP_SKU_IGNORE
9958         },
9959         [ALC662_FIXUP_ASUS_MODE2] = {
9960                 .type = HDA_FIXUP_PINS,
9961                 .v.pins = (const struct hda_pintbl[]) {
9962                         { 0x14, 0x99130110 }, /* speaker */
9963                         { 0x18, 0x01a19820 }, /* mic */
9964                         { 0x19, 0x99a3092f }, /* int-mic */
9965                         { 0x1b, 0x0121401f }, /* HP out */
9966                         { }
9967                 },
9968                 .chained = true,
9969                 .chain_id = ALC662_FIXUP_SKU_IGNORE
9970         },
9971         [ALC662_FIXUP_ASUS_MODE3] = {
9972                 .type = HDA_FIXUP_PINS,
9973                 .v.pins = (const struct hda_pintbl[]) {
9974                         { 0x14, 0x99130110 }, /* speaker */
9975                         { 0x15, 0x0121441f }, /* HP */
9976                         { 0x18, 0x01a19840 }, /* mic */
9977                         { 0x19, 0x99a3094f }, /* int-mic */
9978                         { 0x21, 0x01211420 }, /* HP2 */
9979                         { }
9980                 },
9981                 .chained = true,
9982                 .chain_id = ALC662_FIXUP_SKU_IGNORE
9983         },
9984         [ALC662_FIXUP_ASUS_MODE4] = {
9985                 .type = HDA_FIXUP_PINS,
9986                 .v.pins = (const struct hda_pintbl[]) {
9987                         { 0x14, 0x99130110 }, /* speaker */
9988                         { 0x16, 0x99130111 }, /* speaker */
9989                         { 0x18, 0x01a19840 }, /* mic */
9990                         { 0x19, 0x99a3094f }, /* int-mic */
9991                         { 0x21, 0x0121441f }, /* HP */
9992                         { }
9993                 },
9994                 .chained = true,
9995                 .chain_id = ALC662_FIXUP_SKU_IGNORE
9996         },
9997         [ALC662_FIXUP_ASUS_MODE5] = {
9998                 .type = HDA_FIXUP_PINS,
9999                 .v.pins = (const struct hda_pintbl[]) {
10000                         { 0x14, 0x99130110 }, /* speaker */
10001                         { 0x15, 0x0121441f }, /* HP */
10002                         { 0x16, 0x99130111 }, /* speaker */
10003                         { 0x18, 0x01a19840 }, /* mic */
10004                         { 0x19, 0x99a3094f }, /* int-mic */
10005                         { }
10006                 },
10007                 .chained = true,
10008                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10009         },
10010         [ALC662_FIXUP_ASUS_MODE6] = {
10011                 .type = HDA_FIXUP_PINS,
10012                 .v.pins = (const struct hda_pintbl[]) {
10013                         { 0x14, 0x99130110 }, /* speaker */
10014                         { 0x15, 0x01211420 }, /* HP2 */
10015                         { 0x18, 0x01a19840 }, /* mic */
10016                         { 0x19, 0x99a3094f }, /* int-mic */
10017                         { 0x1b, 0x0121441f }, /* HP */
10018                         { }
10019                 },
10020                 .chained = true,
10021                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10022         },
10023         [ALC662_FIXUP_ASUS_MODE7] = {
10024                 .type = HDA_FIXUP_PINS,
10025                 .v.pins = (const struct hda_pintbl[]) {
10026                         { 0x14, 0x99130110 }, /* speaker */
10027                         { 0x17, 0x99130111 }, /* speaker */
10028                         { 0x18, 0x01a19840 }, /* mic */
10029                         { 0x19, 0x99a3094f }, /* int-mic */
10030                         { 0x1b, 0x01214020 }, /* HP */
10031                         { 0x21, 0x0121401f }, /* HP */
10032                         { }
10033                 },
10034                 .chained = true,
10035                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10036         },
10037         [ALC662_FIXUP_ASUS_MODE8] = {
10038                 .type = HDA_FIXUP_PINS,
10039                 .v.pins = (const struct hda_pintbl[]) {
10040                         { 0x14, 0x99130110 }, /* speaker */
10041                         { 0x12, 0x99a30970 }, /* int-mic */
10042                         { 0x15, 0x01214020 }, /* HP */
10043                         { 0x17, 0x99130111 }, /* speaker */
10044                         { 0x18, 0x01a19840 }, /* mic */
10045                         { 0x21, 0x0121401f }, /* HP */
10046                         { }
10047                 },
10048                 .chained = true,
10049                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10050         },
10051         [ALC662_FIXUP_NO_JACK_DETECT] = {
10052                 .type = HDA_FIXUP_FUNC,
10053                 .v.func = alc_fixup_no_jack_detect,
10054         },
10055         [ALC662_FIXUP_ZOTAC_Z68] = {
10056                 .type = HDA_FIXUP_PINS,
10057                 .v.pins = (const struct hda_pintbl[]) {
10058                         { 0x1b, 0x02214020 }, /* Front HP */
10059                         { }
10060                 }
10061         },
10062         [ALC662_FIXUP_INV_DMIC] = {
10063                 .type = HDA_FIXUP_FUNC,
10064                 .v.func = alc_fixup_inv_dmic,
10065         },
10066         [ALC668_FIXUP_DELL_XPS13] = {
10067                 .type = HDA_FIXUP_FUNC,
10068                 .v.func = alc_fixup_dell_xps13,
10069                 .chained = true,
10070                 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
10071         },
10072         [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
10073                 .type = HDA_FIXUP_FUNC,
10074                 .v.func = alc_fixup_disable_aamix,
10075                 .chained = true,
10076                 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
10077         },
10078         [ALC668_FIXUP_AUTO_MUTE] = {
10079                 .type = HDA_FIXUP_FUNC,
10080                 .v.func = alc_fixup_auto_mute_via_amp,
10081                 .chained = true,
10082                 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
10083         },
10084         [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
10085                 .type = HDA_FIXUP_PINS,
10086                 .v.pins = (const struct hda_pintbl[]) {
10087                         { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10088                         /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
10089                         { }
10090                 },
10091                 .chained = true,
10092                 .chain_id = ALC662_FIXUP_HEADSET_MODE
10093         },
10094         [ALC662_FIXUP_HEADSET_MODE] = {
10095                 .type = HDA_FIXUP_FUNC,
10096                 .v.func = alc_fixup_headset_mode_alc662,
10097         },
10098         [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
10099                 .type = HDA_FIXUP_PINS,
10100                 .v.pins = (const struct hda_pintbl[]) {
10101                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10102                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10103                         { }
10104                 },
10105                 .chained = true,
10106                 .chain_id = ALC668_FIXUP_HEADSET_MODE
10107         },
10108         [ALC668_FIXUP_HEADSET_MODE] = {
10109                 .type = HDA_FIXUP_FUNC,
10110                 .v.func = alc_fixup_headset_mode_alc668,
10111         },
10112         [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
10113                 .type = HDA_FIXUP_FUNC,
10114                 .v.func = alc_fixup_bass_chmap,
10115                 .chained = true,
10116                 .chain_id = ALC662_FIXUP_ASUS_MODE4
10117         },
10118         [ALC662_FIXUP_BASS_16] = {
10119                 .type = HDA_FIXUP_PINS,
10120                 .v.pins = (const struct hda_pintbl[]) {
10121                         {0x16, 0x80106111}, /* bass speaker */
10122                         {}
10123                 },
10124                 .chained = true,
10125                 .chain_id = ALC662_FIXUP_BASS_CHMAP,
10126         },
10127         [ALC662_FIXUP_BASS_1A] = {
10128                 .type = HDA_FIXUP_PINS,
10129                 .v.pins = (const struct hda_pintbl[]) {
10130                         {0x1a, 0x80106111}, /* bass speaker */
10131                         {}
10132                 },
10133                 .chained = true,
10134                 .chain_id = ALC662_FIXUP_BASS_CHMAP,
10135         },
10136         [ALC662_FIXUP_BASS_CHMAP] = {
10137                 .type = HDA_FIXUP_FUNC,
10138                 .v.func = alc_fixup_bass_chmap,
10139         },
10140         [ALC662_FIXUP_ASUS_Nx50] = {
10141                 .type = HDA_FIXUP_FUNC,
10142                 .v.func = alc_fixup_auto_mute_via_amp,
10143                 .chained = true,
10144                 .chain_id = ALC662_FIXUP_BASS_1A
10145         },
10146         [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
10147                 .type = HDA_FIXUP_FUNC,
10148                 .v.func = alc_fixup_headset_mode_alc668,
10149                 .chain_id = ALC662_FIXUP_BASS_CHMAP
10150         },
10151         [ALC668_FIXUP_ASUS_Nx51] = {
10152                 .type = HDA_FIXUP_PINS,
10153                 .v.pins = (const struct hda_pintbl[]) {
10154                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10155                         { 0x1a, 0x90170151 }, /* bass speaker */
10156                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10157                         {}
10158                 },
10159                 .chained = true,
10160                 .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10161         },
10162         [ALC668_FIXUP_MIC_COEF] = {
10163                 .type = HDA_FIXUP_VERBS,
10164                 .v.verbs = (const struct hda_verb[]) {
10165                         { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
10166                         { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
10167                         {}
10168                 },
10169         },
10170         [ALC668_FIXUP_ASUS_G751] = {
10171                 .type = HDA_FIXUP_PINS,
10172                 .v.pins = (const struct hda_pintbl[]) {
10173                         { 0x16, 0x0421101f }, /* HP */
10174                         {}
10175                 },
10176                 .chained = true,
10177                 .chain_id = ALC668_FIXUP_MIC_COEF
10178         },
10179         [ALC891_FIXUP_HEADSET_MODE] = {
10180                 .type = HDA_FIXUP_FUNC,
10181                 .v.func = alc_fixup_headset_mode,
10182         },
10183         [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
10184                 .type = HDA_FIXUP_PINS,
10185                 .v.pins = (const struct hda_pintbl[]) {
10186                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10187                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10188                         { }
10189                 },
10190                 .chained = true,
10191                 .chain_id = ALC891_FIXUP_HEADSET_MODE
10192         },
10193         [ALC662_FIXUP_ACER_VERITON] = {
10194                 .type = HDA_FIXUP_PINS,
10195                 .v.pins = (const struct hda_pintbl[]) {
10196                         { 0x15, 0x50170120 }, /* no internal speaker */
10197                         { }
10198                 }
10199         },
10200         [ALC892_FIXUP_ASROCK_MOBO] = {
10201                 .type = HDA_FIXUP_PINS,
10202                 .v.pins = (const struct hda_pintbl[]) {
10203                         { 0x15, 0x40f000f0 }, /* disabled */
10204                         { 0x16, 0x40f000f0 }, /* disabled */
10205                         { }
10206                 }
10207         },
10208         [ALC662_FIXUP_USI_FUNC] = {
10209                 .type = HDA_FIXUP_FUNC,
10210                 .v.func = alc662_fixup_usi_headset_mic,
10211         },
10212         [ALC662_FIXUP_USI_HEADSET_MODE] = {
10213                 .type = HDA_FIXUP_PINS,
10214                 .v.pins = (const struct hda_pintbl[]) {
10215                         { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
10216                         { 0x18, 0x01a1903d },
10217                         { }
10218                 },
10219                 .chained = true,
10220                 .chain_id = ALC662_FIXUP_USI_FUNC
10221         },
10222         [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
10223                 .type = HDA_FIXUP_FUNC,
10224                 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
10225         },
10226         [ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET] = {
10227                 .type = HDA_FIXUP_FUNC,
10228                 .v.func = alc662_fixup_aspire_ethos_hp,
10229         },
10230         [ALC669_FIXUP_ACER_ASPIRE_ETHOS] = {
10231                 .type = HDA_FIXUP_PINS,
10232                 .v.pins = (const struct hda_pintbl[]) {
10233                         { 0x15, 0x92130110 }, /* front speakers */
10234                         { 0x18, 0x99130111 }, /* center/subwoofer */
10235                         { 0x1b, 0x11130012 }, /* surround plus jack for HP */
10236                         { }
10237                 },
10238                 .chained = true,
10239                 .chain_id = ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET
10240         },
10241         [ALC671_FIXUP_HP_HEADSET_MIC2] = {
10242                 .type = HDA_FIXUP_FUNC,
10243                 .v.func = alc671_fixup_hp_headset_mic2,
10244         },
10245         [ALC662_FIXUP_ACER_X2660G_HEADSET_MODE] = {
10246                 .type = HDA_FIXUP_PINS,
10247                 .v.pins = (const struct hda_pintbl[]) {
10248                         { 0x1a, 0x02a1113c }, /* use as headset mic, without its own jack detect */
10249                         { }
10250                 },
10251                 .chained = true,
10252                 .chain_id = ALC662_FIXUP_USI_FUNC
10253         },
10254         [ALC662_FIXUP_ACER_NITRO_HEADSET_MODE] = {
10255                 .type = HDA_FIXUP_PINS,
10256                 .v.pins = (const struct hda_pintbl[]) {
10257                         { 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
10258                         { 0x1b, 0x0221144f },
10259                         { }
10260                 },
10261                 .chained = true,
10262                 .chain_id = ALC662_FIXUP_USI_FUNC
10263         },
10264         [ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
10265                 .type = HDA_FIXUP_PINS,
10266                 .v.pins = (const struct hda_pintbl[]) {
10267                         { 0x1b, 0x04a1112c },
10268                         { }
10269                 },
10270                 .chained = true,
10271                 .chain_id = ALC668_FIXUP_HEADSET_MIC
10272         },
10273         [ALC668_FIXUP_HEADSET_MIC] = {
10274                 .type = HDA_FIXUP_FUNC,
10275                 .v.func = alc269_fixup_headset_mic,
10276                 .chained = true,
10277                 .chain_id = ALC668_FIXUP_MIC_DET_COEF
10278         },
10279         [ALC668_FIXUP_MIC_DET_COEF] = {
10280                 .type = HDA_FIXUP_VERBS,
10281                 .v.verbs = (const struct hda_verb[]) {
10282                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
10283                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
10284                         {}
10285                 },
10286         },
10287         [ALC897_FIXUP_LENOVO_HEADSET_MIC] = {
10288                 .type = HDA_FIXUP_FUNC,
10289                 .v.func = alc897_fixup_lenovo_headset_mic,
10290         },
10291         [ALC897_FIXUP_HEADSET_MIC_PIN] = {
10292                 .type = HDA_FIXUP_PINS,
10293                 .v.pins = (const struct hda_pintbl[]) {
10294                         { 0x1a, 0x03a11050 },
10295                         { }
10296                 },
10297                 .chained = true,
10298                 .chain_id = ALC897_FIXUP_LENOVO_HEADSET_MIC
10299         },
10300         [ALC897_FIXUP_HP_HSMIC_VERB] = {
10301                 .type = HDA_FIXUP_PINS,
10302                 .v.pins = (const struct hda_pintbl[]) {
10303                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
10304                         { }
10305                 },
10306         },
10307         [ALC897_FIXUP_LENOVO_HEADSET_MODE] = {
10308                 .type = HDA_FIXUP_FUNC,
10309                 .v.func = alc897_fixup_lenovo_headset_mode,
10310         },
10311         [ALC897_FIXUP_HEADSET_MIC_PIN2] = {
10312                 .type = HDA_FIXUP_PINS,
10313                 .v.pins = (const struct hda_pintbl[]) {
10314                         { 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
10315                         { }
10316                 },
10317                 .chained = true,
10318                 .chain_id = ALC897_FIXUP_LENOVO_HEADSET_MODE
10319         },
10320         [ALC897_FIXUP_UNIS_H3C_X500S] = {
10321                 .type = HDA_FIXUP_VERBS,
10322                 .v.verbs = (const struct hda_verb[]) {
10323                         { 0x14, AC_VERB_SET_EAPD_BTLENABLE, 0 },
10324                         {}
10325                 },
10326         },
10327 };
10328
10329 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
10330         SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
10331         SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
10332         SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
10333         SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
10334         SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
10335         SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
10336         SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
10337         SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
10338         SND_PCI_QUIRK(0x1025, 0x0566, "Acer Aspire Ethos 8951G", ALC669_FIXUP_ACER_ASPIRE_ETHOS),
10339         SND_PCI_QUIRK(0x1025, 0x123c, "Acer Nitro N50-600", ALC662_FIXUP_ACER_NITRO_HEADSET_MODE),
10340         SND_PCI_QUIRK(0x1025, 0x124e, "Acer 2660G", ALC662_FIXUP_ACER_X2660G_HEADSET_MODE),
10341         SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10342         SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10343         SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
10344         SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
10345         SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
10346         SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10347         SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10348         SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10349         SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10350         SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10351         SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
10352         SND_PCI_QUIRK(0x103c, 0x870c, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
10353         SND_PCI_QUIRK(0x103c, 0x8719, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
10354         SND_PCI_QUIRK(0x103c, 0x872b, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
10355         SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
10356         SND_PCI_QUIRK(0x103c, 0x8768, "HP Slim Desktop S01", ALC671_FIXUP_HP_HEADSET_MIC2),
10357         SND_PCI_QUIRK(0x103c, 0x877e, "HP 288 Pro G6", ALC671_FIXUP_HP_HEADSET_MIC2),
10358         SND_PCI_QUIRK(0x103c, 0x885f, "HP 288 Pro G8", ALC671_FIXUP_HP_HEADSET_MIC2),
10359         SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
10360         SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
10361         SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
10362         SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
10363         SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
10364         SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
10365         SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
10366         SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
10367         SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
10368         SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
10369         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
10370         SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
10371         SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
10372         SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
10373         SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
10374         SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
10375         SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
10376         SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
10377         SND_PCI_QUIRK(0x17aa, 0x1057, "Lenovo P360", ALC897_FIXUP_HEADSET_MIC_PIN),
10378         SND_PCI_QUIRK(0x17aa, 0x1064, "Lenovo P3 Tower", ALC897_FIXUP_HEADSET_MIC_PIN),
10379         SND_PCI_QUIRK(0x17aa, 0x32ca, "Lenovo ThinkCentre M80", ALC897_FIXUP_HEADSET_MIC_PIN),
10380         SND_PCI_QUIRK(0x17aa, 0x32cb, "Lenovo ThinkCentre M70", ALC897_FIXUP_HEADSET_MIC_PIN),
10381         SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN),
10382         SND_PCI_QUIRK(0x17aa, 0x32f7, "Lenovo ThinkCentre M90", ALC897_FIXUP_HEADSET_MIC_PIN),
10383         SND_PCI_QUIRK(0x17aa, 0x3321, "Lenovo ThinkCentre M70 Gen4", ALC897_FIXUP_HEADSET_MIC_PIN),
10384         SND_PCI_QUIRK(0x17aa, 0x331b, "Lenovo ThinkCentre M90 Gen4", ALC897_FIXUP_HEADSET_MIC_PIN),
10385         SND_PCI_QUIRK(0x17aa, 0x3742, "Lenovo TianYi510Pro-14IOB", ALC897_FIXUP_HEADSET_MIC_PIN2),
10386         SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
10387         SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
10388         SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
10389         SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
10390         SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
10391         SND_PCI_QUIRK(0x1b35, 0x1234, "CZC ET26", ALC662_FIXUP_CZC_ET26),
10392         SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
10393         SND_PCI_QUIRK(0x1c6c, 0x1239, "Compaq N14JP6-V2", ALC897_FIXUP_HP_HSMIC_VERB),
10394
10395 #if 0
10396         /* Below is a quirk table taken from the old code.
10397          * Basically the device should work as is without the fixup table.
10398          * If BIOS doesn't give a proper info, enable the corresponding
10399          * fixup entry.
10400          */
10401         SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
10402         SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
10403         SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
10404         SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
10405         SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10406         SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10407         SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10408         SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
10409         SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
10410         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10411         SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
10412         SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
10413         SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
10414         SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
10415         SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
10416         SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10417         SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
10418         SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
10419         SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10420         SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
10421         SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
10422         SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10423         SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
10424         SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
10425         SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
10426         SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10427         SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
10428         SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
10429         SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10430         SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
10431         SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10432         SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10433         SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
10434         SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
10435         SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
10436         SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
10437         SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
10438         SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
10439         SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
10440         SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10441         SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
10442         SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
10443         SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10444         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
10445         SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
10446         SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
10447         SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
10448         SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
10449         SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10450         SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
10451 #endif
10452         {}
10453 };
10454
10455 static const struct hda_model_fixup alc662_fixup_models[] = {
10456         {.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
10457         {.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
10458         {.id = ALC272_FIXUP_MARIO, .name = "mario"},
10459         {.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
10460         {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
10461         {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
10462         {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
10463         {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
10464         {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
10465         {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
10466         {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
10467         {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
10468         {.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
10469         {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
10470         {.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
10471         {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
10472         {.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
10473         {.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
10474         {.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
10475         {.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
10476         {.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
10477         {.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
10478         {.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
10479         {.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
10480         {.id = ALC668_FIXUP_ASUS_G751, .name = "asus-g751"},
10481         {.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
10482         {.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
10483         {.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
10484         {.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
10485         {.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
10486         {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
10487         {.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
10488         {.id = ALC897_FIXUP_UNIS_H3C_X500S, .name = "unis-h3c-x500s"},
10489         {}
10490 };
10491
10492 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
10493         SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10494                 {0x17, 0x02211010},
10495                 {0x18, 0x01a19030},
10496                 {0x1a, 0x01813040},
10497                 {0x21, 0x01014020}),
10498         SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10499                 {0x16, 0x01813030},
10500                 {0x17, 0x02211010},
10501                 {0x18, 0x01a19040},
10502                 {0x21, 0x01014020}),
10503         SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
10504                 {0x14, 0x01014010},
10505                 {0x18, 0x01a19020},
10506                 {0x1a, 0x0181302f},
10507                 {0x1b, 0x0221401f}),
10508         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10509                 {0x12, 0x99a30130},
10510                 {0x14, 0x90170110},
10511                 {0x15, 0x0321101f},
10512                 {0x16, 0x03011020}),
10513         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10514                 {0x12, 0x99a30140},
10515                 {0x14, 0x90170110},
10516                 {0x15, 0x0321101f},
10517                 {0x16, 0x03011020}),
10518         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10519                 {0x12, 0x99a30150},
10520                 {0x14, 0x90170110},
10521                 {0x15, 0x0321101f},
10522                 {0x16, 0x03011020}),
10523         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10524                 {0x14, 0x90170110},
10525                 {0x15, 0x0321101f},
10526                 {0x16, 0x03011020}),
10527         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
10528                 {0x12, 0x90a60130},
10529                 {0x14, 0x90170110},
10530                 {0x15, 0x0321101f}),
10531         SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
10532                 {0x14, 0x01014010},
10533                 {0x17, 0x90170150},
10534                 {0x19, 0x02a11060},
10535                 {0x1b, 0x01813030},
10536                 {0x21, 0x02211020}),
10537         SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
10538                 {0x14, 0x01014010},
10539                 {0x18, 0x01a19040},
10540                 {0x1b, 0x01813030},
10541                 {0x21, 0x02211020}),
10542         SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
10543                 {0x14, 0x01014020},
10544                 {0x17, 0x90170110},
10545                 {0x18, 0x01a19050},
10546                 {0x1b, 0x01813040},
10547                 {0x21, 0x02211030}),
10548         {}
10549 };
10550
10551 /*
10552  */
10553 static int patch_alc662(struct hda_codec *codec)
10554 {
10555         struct alc_spec *spec;
10556         int err;
10557
10558         err = alc_alloc_spec(codec, 0x0b);
10559         if (err < 0)
10560                 return err;
10561
10562         spec = codec->spec;
10563
10564         spec->shutup = alc_eapd_shutup;
10565
10566         /* handle multiple HPs as is */
10567         spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
10568
10569         alc_fix_pll_init(codec, 0x20, 0x04, 15);
10570
10571         switch (codec->core.vendor_id) {
10572         case 0x10ec0668:
10573                 spec->init_hook = alc668_restore_default_value;
10574                 break;
10575         }
10576
10577         alc_pre_init(codec);
10578
10579         snd_hda_pick_fixup(codec, alc662_fixup_models,
10580                        alc662_fixup_tbl, alc662_fixups);
10581         snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
10582         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10583
10584         alc_auto_parse_customize_define(codec);
10585
10586         if (has_cdefine_beep(codec))
10587                 spec->gen.beep_nid = 0x01;
10588
10589         if ((alc_get_coef0(codec) & (1 << 14)) &&
10590             codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
10591             spec->cdefine.platform_type == 1) {
10592                 err = alc_codec_rename(codec, "ALC272X");
10593                 if (err < 0)
10594                         goto error;
10595         }
10596
10597         /* automatic parse from the BIOS config */
10598         err = alc662_parse_auto_config(codec);
10599         if (err < 0)
10600                 goto error;
10601
10602         if (!spec->gen.no_analog && spec->gen.beep_nid) {
10603                 switch (codec->core.vendor_id) {
10604                 case 0x10ec0662:
10605                         err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10606                         break;
10607                 case 0x10ec0272:
10608                 case 0x10ec0663:
10609                 case 0x10ec0665:
10610                 case 0x10ec0668:
10611                         err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
10612                         break;
10613                 case 0x10ec0273:
10614                         err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
10615                         break;
10616                 }
10617                 if (err < 0)
10618                         goto error;
10619         }
10620
10621         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10622
10623         return 0;
10624
10625  error:
10626         alc_free(codec);
10627         return err;
10628 }
10629
10630 /*
10631  * ALC680 support
10632  */
10633
10634 static int alc680_parse_auto_config(struct hda_codec *codec)
10635 {
10636         return alc_parse_auto_config(codec, NULL, NULL);
10637 }
10638
10639 /*
10640  */
10641 static int patch_alc680(struct hda_codec *codec)
10642 {
10643         int err;
10644
10645         /* ALC680 has no aa-loopback mixer */
10646         err = alc_alloc_spec(codec, 0);
10647         if (err < 0)
10648                 return err;
10649
10650         /* automatic parse from the BIOS config */
10651         err = alc680_parse_auto_config(codec);
10652         if (err < 0) {
10653                 alc_free(codec);
10654                 return err;
10655         }
10656
10657         return 0;
10658 }
10659
10660 /*
10661  * patch entries
10662  */
10663 static const struct hda_device_id snd_hda_id_realtek[] = {
10664         HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
10665         HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
10666         HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
10667         HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
10668         HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
10669         HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
10670         HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
10671         HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
10672         HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
10673         HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
10674         HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
10675         HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
10676         HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
10677         HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
10678         HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
10679         HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
10680         HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
10681         HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
10682         HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
10683         HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
10684         HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
10685         HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
10686         HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
10687         HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
10688         HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
10689         HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
10690         HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
10691         HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
10692         HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
10693         HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
10694         HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
10695         HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
10696         HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
10697         HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
10698         HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
10699         HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
10700         HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
10701         HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
10702         HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
10703         HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
10704         HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
10705         HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
10706         HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
10707         HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
10708         HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
10709         HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
10710         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
10711         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
10712         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
10713         HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
10714         HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
10715         HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
10716         HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
10717         HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
10718         HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
10719         HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
10720         HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
10721         HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
10722         HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
10723         HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
10724         HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
10725         HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
10726         HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
10727         HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
10728         HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
10729         HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
10730         HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
10731         HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
10732         HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
10733         HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
10734         HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
10735         HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
10736         HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
10737         HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
10738         HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
10739         HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
10740         HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
10741         HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
10742         HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269),
10743         {} /* terminator */
10744 };
10745 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
10746
10747 MODULE_LICENSE("GPL");
10748 MODULE_DESCRIPTION("Realtek HD-audio codec");
10749
10750 static struct hda_codec_driver realtek_driver = {
10751         .id = snd_hda_id_realtek,
10752 };
10753
10754 module_hda_codec_driver(realtek_driver);