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