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