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