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