f8d8a7182989bae7c00e08cdbf6a8831c6c86802
[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 (!hp_pin)
3562                 hp_pin = 0x21;
3563
3564         msleep(30);
3565
3566         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3567
3568         if (hp_pin_sense)
3569                 msleep(2);
3570
3571         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3572         if (spec->ultra_low_power) {
3573                 alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3574                 alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3575                 alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3576                 alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3577                 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3578                 msleep(30);
3579         }
3580
3581         snd_hda_codec_write(codec, hp_pin, 0,
3582                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3583
3584         if (hp_pin_sense || spec->ultra_low_power)
3585                 msleep(85);
3586
3587         snd_hda_codec_write(codec, hp_pin, 0,
3588                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3589
3590         if (hp_pin_sense || spec->ultra_low_power)
3591                 msleep(100);
3592
3593         alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3594         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3595         alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3596         alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3597         /*
3598          * Expose headphone mic (or possibly Line In on some machines) instead
3599          * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3600          * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3601          * this register.
3602          */
3603         alc_write_coef_idx(codec, 0x36, 0x5757);
3604 }
3605
3606 static void alc256_shutup(struct hda_codec *codec)
3607 {
3608         struct alc_spec *spec = codec->spec;
3609         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3610         bool hp_pin_sense;
3611
3612         if (!hp_pin)
3613                 hp_pin = 0x21;
3614
3615         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3616
3617         if (hp_pin_sense)
3618                 msleep(2);
3619
3620         snd_hda_codec_write(codec, hp_pin, 0,
3621                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3622
3623         if (hp_pin_sense || spec->ultra_low_power)
3624                 msleep(85);
3625
3626         /* 3k pull low control for Headset jack. */
3627         /* NOTE: call this before clearing the pin, otherwise codec stalls */
3628         /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
3629          * when booting with headset plugged. So skip setting it for the codec alc257
3630          */
3631         if (codec->core.vendor_id != 0x10ec0236 &&
3632             codec->core.vendor_id != 0x10ec0257)
3633                 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3634
3635         if (!spec->no_shutup_pins)
3636                 snd_hda_codec_write(codec, hp_pin, 0,
3637                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3638
3639         if (hp_pin_sense || spec->ultra_low_power)
3640                 msleep(100);
3641
3642         alc_auto_setup_eapd(codec, false);
3643         alc_shutup_pins(codec);
3644         if (spec->ultra_low_power) {
3645                 msleep(50);
3646                 alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3647                 alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3648                 alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3649                 alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3650                 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3651                 msleep(30);
3652         }
3653 }
3654
3655 static void alc285_hp_init(struct hda_codec *codec)
3656 {
3657         struct alc_spec *spec = codec->spec;
3658         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3659         int i, val;
3660         int coef38, coef0d, coef36;
3661
3662         alc_update_coef_idx(codec, 0x4a, 1<<15, 1<<15); /* Reset HP JD */
3663         coef38 = alc_read_coef_idx(codec, 0x38); /* Amp control */
3664         coef0d = alc_read_coef_idx(codec, 0x0d); /* Digital Misc control */
3665         coef36 = alc_read_coef_idx(codec, 0x36); /* Passthrough Control */
3666         alc_update_coef_idx(codec, 0x38, 1<<4, 0x0);
3667         alc_update_coef_idx(codec, 0x0d, 0x110, 0x0);
3668
3669         alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
3670
3671         if (hp_pin)
3672                 snd_hda_codec_write(codec, hp_pin, 0,
3673                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3674
3675         msleep(130);
3676         alc_update_coef_idx(codec, 0x36, 1<<14, 1<<14);
3677         alc_update_coef_idx(codec, 0x36, 1<<13, 0x0);
3678
3679         if (hp_pin)
3680                 snd_hda_codec_write(codec, hp_pin, 0,
3681                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3682         msleep(10);
3683         alc_write_coef_idx(codec, 0x67, 0x0); /* Set HP depop to manual mode */
3684         alc_write_coefex_idx(codec, 0x58, 0x00, 0x7880);
3685         alc_write_coefex_idx(codec, 0x58, 0x0f, 0xf049);
3686         alc_update_coefex_idx(codec, 0x58, 0x03, 0x00f0, 0x00c0);
3687
3688         alc_write_coefex_idx(codec, 0x58, 0x00, 0xf888); /* HP depop procedure start */
3689         val = alc_read_coefex_idx(codec, 0x58, 0x00);
3690         for (i = 0; i < 20 && val & 0x8000; i++) {
3691                 msleep(50);
3692                 val = alc_read_coefex_idx(codec, 0x58, 0x00);
3693         } /* Wait for depop procedure finish  */
3694
3695         alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the result */
3696         alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
3697         alc_update_coef_idx(codec, 0x0d, 0x110, coef0d);
3698         alc_update_coef_idx(codec, 0x36, 3<<13, coef36);
3699
3700         msleep(50);
3701         alc_update_coef_idx(codec, 0x4a, 1<<15, 0);
3702 }
3703
3704 static void alc225_init(struct hda_codec *codec)
3705 {
3706         struct alc_spec *spec = codec->spec;
3707         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3708         bool hp1_pin_sense, hp2_pin_sense;
3709
3710         if (spec->codec_variant != ALC269_TYPE_ALC287 &&
3711                 spec->codec_variant != ALC269_TYPE_ALC245)
3712                 /* required only at boot or S3 and S4 resume time */
3713                 if (!spec->done_hp_init ||
3714                         is_s3_resume(codec) ||
3715                         is_s4_resume(codec)) {
3716                         alc285_hp_init(codec);
3717                         spec->done_hp_init = true;
3718                 }
3719
3720         if (!hp_pin)
3721                 hp_pin = 0x21;
3722         msleep(30);
3723
3724         hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3725         hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3726
3727         if (hp1_pin_sense || hp2_pin_sense)
3728                 msleep(2);
3729
3730         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3731         if (spec->ultra_low_power) {
3732                 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3733                 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3734                 alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3735                 msleep(30);
3736         }
3737
3738         if (hp1_pin_sense || spec->ultra_low_power)
3739                 snd_hda_codec_write(codec, hp_pin, 0,
3740                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3741         if (hp2_pin_sense)
3742                 snd_hda_codec_write(codec, 0x16, 0,
3743                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3744
3745         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3746                 msleep(85);
3747
3748         if (hp1_pin_sense || spec->ultra_low_power)
3749                 snd_hda_codec_write(codec, hp_pin, 0,
3750                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3751         if (hp2_pin_sense)
3752                 snd_hda_codec_write(codec, 0x16, 0,
3753                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3754
3755         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3756                 msleep(100);
3757
3758         alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3759         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3760 }
3761
3762 static void alc225_shutup(struct hda_codec *codec)
3763 {
3764         struct alc_spec *spec = codec->spec;
3765         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3766         bool hp1_pin_sense, hp2_pin_sense;
3767
3768         if (!hp_pin)
3769                 hp_pin = 0x21;
3770
3771         alc_disable_headset_jack_key(codec);
3772         /* 3k pull low control for Headset jack. */
3773         alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3774
3775         hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3776         hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3777
3778         if (hp1_pin_sense || hp2_pin_sense)
3779                 msleep(2);
3780
3781         if (hp1_pin_sense || spec->ultra_low_power)
3782                 snd_hda_codec_write(codec, hp_pin, 0,
3783                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3784         if (hp2_pin_sense)
3785                 snd_hda_codec_write(codec, 0x16, 0,
3786                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3787
3788         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3789                 msleep(85);
3790
3791         if (hp1_pin_sense || spec->ultra_low_power)
3792                 snd_hda_codec_write(codec, hp_pin, 0,
3793                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3794         if (hp2_pin_sense)
3795                 snd_hda_codec_write(codec, 0x16, 0,
3796                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3797
3798         if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3799                 msleep(100);
3800
3801         alc_auto_setup_eapd(codec, false);
3802         alc_shutup_pins(codec);
3803         if (spec->ultra_low_power) {
3804                 msleep(50);
3805                 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3806                 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3807                 alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3808                 alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3809                 msleep(30);
3810         }
3811
3812         alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3813         alc_enable_headset_jack_key(codec);
3814 }
3815
3816 static void alc_default_init(struct hda_codec *codec)
3817 {
3818         struct alc_spec *spec = codec->spec;
3819         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3820         bool hp_pin_sense;
3821
3822         if (!hp_pin)
3823                 return;
3824
3825         msleep(30);
3826
3827         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3828
3829         if (hp_pin_sense)
3830                 msleep(2);
3831
3832         snd_hda_codec_write(codec, hp_pin, 0,
3833                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3834
3835         if (hp_pin_sense)
3836                 msleep(85);
3837
3838         snd_hda_codec_write(codec, hp_pin, 0,
3839                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3840
3841         if (hp_pin_sense)
3842                 msleep(100);
3843 }
3844
3845 static void alc_default_shutup(struct hda_codec *codec)
3846 {
3847         struct alc_spec *spec = codec->spec;
3848         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3849         bool hp_pin_sense;
3850
3851         if (!hp_pin) {
3852                 alc269_shutup(codec);
3853                 return;
3854         }
3855
3856         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3857
3858         if (hp_pin_sense)
3859                 msleep(2);
3860
3861         snd_hda_codec_write(codec, hp_pin, 0,
3862                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3863
3864         if (hp_pin_sense)
3865                 msleep(85);
3866
3867         if (!spec->no_shutup_pins)
3868                 snd_hda_codec_write(codec, hp_pin, 0,
3869                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3870
3871         if (hp_pin_sense)
3872                 msleep(100);
3873
3874         alc_auto_setup_eapd(codec, false);
3875         alc_shutup_pins(codec);
3876 }
3877
3878 static void alc294_hp_init(struct hda_codec *codec)
3879 {
3880         struct alc_spec *spec = codec->spec;
3881         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3882         int i, val;
3883
3884         if (!hp_pin)
3885                 return;
3886
3887         snd_hda_codec_write(codec, hp_pin, 0,
3888                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3889
3890         msleep(100);
3891
3892         if (!spec->no_shutup_pins)
3893                 snd_hda_codec_write(codec, hp_pin, 0,
3894                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3895
3896         alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3897         alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3898
3899         /* Wait for depop procedure finish  */
3900         val = alc_read_coefex_idx(codec, 0x58, 0x01);
3901         for (i = 0; i < 20 && val & 0x0080; i++) {
3902                 msleep(50);
3903                 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3904         }
3905         /* Set HP depop to auto mode */
3906         alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3907         msleep(50);
3908 }
3909
3910 static void alc294_init(struct hda_codec *codec)
3911 {
3912         struct alc_spec *spec = codec->spec;
3913
3914         /* required only at boot or S4 resume time */
3915         if (!spec->done_hp_init ||
3916             codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3917                 alc294_hp_init(codec);
3918                 spec->done_hp_init = true;
3919         }
3920         alc_default_init(codec);
3921 }
3922
3923 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3924                              unsigned int val)
3925 {
3926         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3927         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3928         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3929 }
3930
3931 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3932 {
3933         unsigned int val;
3934
3935         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3936         val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3937                 & 0xffff;
3938         val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3939                 << 16;
3940         return val;
3941 }
3942
3943 static void alc5505_dsp_halt(struct hda_codec *codec)
3944 {
3945         unsigned int val;
3946
3947         alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3948         alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3949         alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3950         alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3951         alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3952         alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3953         alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3954         val = alc5505_coef_get(codec, 0x6220);
3955         alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3956 }
3957
3958 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3959 {
3960         alc5505_coef_set(codec, 0x61b8, 0x04133302);
3961         alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3962         alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3963         alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3964         alc5505_coef_set(codec, 0x6220, 0x2002010f);
3965         alc5505_coef_set(codec, 0x880c, 0x00000004);
3966 }
3967
3968 static void alc5505_dsp_init(struct hda_codec *codec)
3969 {
3970         unsigned int val;
3971
3972         alc5505_dsp_halt(codec);
3973         alc5505_dsp_back_from_halt(codec);
3974         alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3975         alc5505_coef_set(codec, 0x61b0, 0x5b16);
3976         alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3977         alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3978         alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3979         alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3980         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3981         alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3982         alc5505_coef_set(codec, 0x61b8, 0x04173302);
3983         alc5505_coef_set(codec, 0x61b8, 0x04163302);
3984         alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3985         alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3986         alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3987
3988         val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3989         if (val <= 3)
3990                 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3991         else
3992                 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3993
3994         alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3995         alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3996         alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3997         alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3998         alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3999         alc5505_coef_set(codec, 0x880c, 0x00000003);
4000         alc5505_coef_set(codec, 0x880c, 0x00000010);
4001
4002 #ifdef HALT_REALTEK_ALC5505
4003         alc5505_dsp_halt(codec);
4004 #endif
4005 }
4006
4007 #ifdef HALT_REALTEK_ALC5505
4008 #define alc5505_dsp_suspend(codec)      do { } while (0) /* NOP */
4009 #define alc5505_dsp_resume(codec)       do { } while (0) /* NOP */
4010 #else
4011 #define alc5505_dsp_suspend(codec)      alc5505_dsp_halt(codec)
4012 #define alc5505_dsp_resume(codec)       alc5505_dsp_back_from_halt(codec)
4013 #endif
4014
4015 #ifdef CONFIG_PM
4016 static int alc269_suspend(struct hda_codec *codec)
4017 {
4018         struct alc_spec *spec = codec->spec;
4019
4020         if (spec->has_alc5505_dsp)
4021                 alc5505_dsp_suspend(codec);
4022         return alc_suspend(codec);
4023 }
4024
4025 static int alc269_resume(struct hda_codec *codec)
4026 {
4027         struct alc_spec *spec = codec->spec;
4028
4029         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4030                 alc269vb_toggle_power_output(codec, 0);
4031         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4032                         (alc_get_coef0(codec) & 0x00ff) == 0x018) {
4033                 msleep(150);
4034         }
4035
4036         codec->patch_ops.init(codec);
4037
4038         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4039                 alc269vb_toggle_power_output(codec, 1);
4040         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4041                         (alc_get_coef0(codec) & 0x00ff) == 0x017) {
4042                 msleep(200);
4043         }
4044
4045         snd_hda_regmap_sync(codec);
4046         hda_call_check_power_status(codec, 0x01);
4047
4048         /* on some machine, the BIOS will clear the codec gpio data when enter
4049          * suspend, and won't restore the data after resume, so we restore it
4050          * in the driver.
4051          */
4052         if (spec->gpio_data)
4053                 alc_write_gpio_data(codec);
4054
4055         if (spec->has_alc5505_dsp)
4056                 alc5505_dsp_resume(codec);
4057
4058         return 0;
4059 }
4060 #endif /* CONFIG_PM */
4061
4062 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
4063                                                  const struct hda_fixup *fix, int action)
4064 {
4065         struct alc_spec *spec = codec->spec;
4066
4067         if (action == HDA_FIXUP_ACT_PRE_PROBE)
4068                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4069 }
4070
4071 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
4072                                                  const struct hda_fixup *fix,
4073                                                  int action)
4074 {
4075         unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
4076         unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
4077
4078         if (cfg_headphone && cfg_headset_mic == 0x411111f0)
4079                 snd_hda_codec_set_pincfg(codec, 0x19,
4080                         (cfg_headphone & ~AC_DEFCFG_DEVICE) |
4081                         (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
4082 }
4083
4084 static void alc269_fixup_hweq(struct hda_codec *codec,
4085                                const struct hda_fixup *fix, int action)
4086 {
4087         if (action == HDA_FIXUP_ACT_INIT)
4088                 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
4089 }
4090
4091 static void alc269_fixup_headset_mic(struct hda_codec *codec,
4092                                        const struct hda_fixup *fix, int action)
4093 {
4094         struct alc_spec *spec = codec->spec;
4095
4096         if (action == HDA_FIXUP_ACT_PRE_PROBE)
4097                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4098 }
4099
4100 static void alc271_fixup_dmic(struct hda_codec *codec,
4101                               const struct hda_fixup *fix, int action)
4102 {
4103         static const struct hda_verb verbs[] = {
4104                 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
4105                 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
4106                 {}
4107         };
4108         unsigned int cfg;
4109
4110         if (strcmp(codec->core.chip_name, "ALC271X") &&
4111             strcmp(codec->core.chip_name, "ALC269VB"))
4112                 return;
4113         cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4114         if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
4115                 snd_hda_sequence_write(codec, verbs);
4116 }
4117
4118 /* Fix the speaker amp after resume, etc */
4119 static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4120                                           const struct hda_fixup *fix,
4121                                           int action)
4122 {
4123         if (action == HDA_FIXUP_ACT_INIT)
4124                 alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4125 }
4126
4127 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4128                                  const struct hda_fixup *fix, int action)
4129 {
4130         struct alc_spec *spec = codec->spec;
4131
4132         if (action != HDA_FIXUP_ACT_PROBE)
4133                 return;
4134
4135         /* Due to a hardware problem on Lenovo Ideadpad, we need to
4136          * fix the sample rate of analog I/O to 44.1kHz
4137          */
4138         spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
4139         spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
4140 }
4141
4142 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4143                                      const struct hda_fixup *fix, int action)
4144 {
4145         /* The digital-mic unit sends PDM (differential signal) instead of
4146          * the standard PCM, thus you can't record a valid mono stream as is.
4147          * Below is a workaround specific to ALC269 to control the dmic
4148          * signal source as mono.
4149          */
4150         if (action == HDA_FIXUP_ACT_INIT)
4151                 alc_update_coef_idx(codec, 0x07, 0, 0x80);
4152 }
4153
4154 static void alc269_quanta_automute(struct hda_codec *codec)
4155 {
4156         snd_hda_gen_update_outputs(codec);
4157
4158         alc_write_coef_idx(codec, 0x0c, 0x680);
4159         alc_write_coef_idx(codec, 0x0c, 0x480);
4160 }
4161
4162 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4163                                      const struct hda_fixup *fix, int action)
4164 {
4165         struct alc_spec *spec = codec->spec;
4166         if (action != HDA_FIXUP_ACT_PROBE)
4167                 return;
4168         spec->gen.automute_hook = alc269_quanta_automute;
4169 }
4170
4171 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4172                                          struct hda_jack_callback *jack)
4173 {
4174         struct alc_spec *spec = codec->spec;
4175         int vref;
4176         msleep(200);
4177         snd_hda_gen_hp_automute(codec, jack);
4178
4179         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4180         msleep(100);
4181         snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4182                             vref);
4183         msleep(500);
4184         snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4185                             vref);
4186 }
4187
4188 /*
4189  * Magic sequence to make Huawei Matebook X right speaker working (bko#197801)
4190  */
4191 struct hda_alc298_mbxinit {
4192         unsigned char value_0x23;
4193         unsigned char value_0x25;
4194 };
4195
4196 static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4197                                          const struct hda_alc298_mbxinit *initval,
4198                                          bool first)
4199 {
4200         snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4201         alc_write_coef_idx(codec, 0x26, 0xb000);
4202
4203         if (first)
4204                 snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4205
4206         snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4207         alc_write_coef_idx(codec, 0x26, 0xf000);
4208         alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4209
4210         if (initval->value_0x23 != 0x1e)
4211                 alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4212
4213         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4214         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4215 }
4216
4217 static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4218                                            const struct hda_fixup *fix,
4219                                            int action)
4220 {
4221         /* Initialization magic */
4222         static const struct hda_alc298_mbxinit dac_init[] = {
4223                 {0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00},
4224                 {0x10, 0x00}, {0x1a, 0x40}, {0x1b, 0x82}, {0x1c, 0x00},
4225                 {0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00},
4226                 {0x20, 0xc2}, {0x21, 0xc8}, {0x22, 0x26}, {0x23, 0x24},
4227                 {0x27, 0xff}, {0x28, 0xff}, {0x29, 0xff}, {0x2a, 0x8f},
4228                 {0x2b, 0x02}, {0x2c, 0x48}, {0x2d, 0x34}, {0x2e, 0x00},
4229                 {0x2f, 0x00},
4230                 {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00},
4231                 {0x34, 0x00}, {0x35, 0x01}, {0x36, 0x93}, {0x37, 0x0c},
4232                 {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0xf8}, {0x38, 0x80},
4233                 {}
4234         };
4235         const struct hda_alc298_mbxinit *seq;
4236
4237         if (action != HDA_FIXUP_ACT_INIT)
4238                 return;
4239
4240         /* Start */
4241         snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4242         snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4243         alc_write_coef_idx(codec, 0x26, 0xf000);
4244         alc_write_coef_idx(codec, 0x22, 0x31);
4245         alc_write_coef_idx(codec, 0x23, 0x0b);
4246         alc_write_coef_idx(codec, 0x25, 0x00);
4247         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4248         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4249
4250         for (seq = dac_init; seq->value_0x23; seq++)
4251                 alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4252 }
4253
4254 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4255                                      const struct hda_fixup *fix, int action)
4256 {
4257         struct alc_spec *spec = codec->spec;
4258         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4259                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4260                 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
4261         }
4262 }
4263
4264 static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin,
4265                                 bool polarity, bool on)
4266 {
4267         unsigned int pinval;
4268
4269         if (!pin)
4270                 return;
4271         if (polarity)
4272                 on = !on;
4273         pinval = snd_hda_codec_get_pin_target(codec, pin);
4274         pinval &= ~AC_PINCTL_VREFEN;
4275         pinval |= on ? AC_PINCTL_VREF_80 : AC_PINCTL_VREF_HIZ;
4276         /* temporarily power up/down for setting VREF */
4277         snd_hda_power_up_pm(codec);
4278         snd_hda_set_pin_ctl_cache(codec, pin, pinval);
4279         snd_hda_power_down_pm(codec);
4280 }
4281
4282 /* update mute-LED according to the speaker mute state via mic VREF pin */
4283 static int vref_mute_led_set(struct led_classdev *led_cdev,
4284                              enum led_brightness brightness)
4285 {
4286         struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4287         struct alc_spec *spec = codec->spec;
4288
4289         alc_update_vref_led(codec, spec->mute_led_nid,
4290                             spec->mute_led_polarity, brightness);
4291         return 0;
4292 }
4293
4294 /* Make sure the led works even in runtime suspend */
4295 static unsigned int led_power_filter(struct hda_codec *codec,
4296                                                   hda_nid_t nid,
4297                                                   unsigned int power_state)
4298 {
4299         struct alc_spec *spec = codec->spec;
4300
4301         if (power_state != AC_PWRST_D3 || nid == 0 ||
4302             (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
4303                 return power_state;
4304
4305         /* Set pin ctl again, it might have just been set to 0 */
4306         snd_hda_set_pin_ctl(codec, nid,
4307                             snd_hda_codec_get_pin_target(codec, nid));
4308
4309         return snd_hda_gen_path_power_filter(codec, nid, power_state);
4310 }
4311
4312 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4313                                      const struct hda_fixup *fix, int action)
4314 {
4315         struct alc_spec *spec = codec->spec;
4316         const struct dmi_device *dev = NULL;
4317
4318         if (action != HDA_FIXUP_ACT_PRE_PROBE)
4319                 return;
4320
4321         while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
4322                 int pol, pin;
4323                 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
4324                         continue;
4325                 if (pin < 0x0a || pin >= 0x10)
4326                         break;
4327                 spec->mute_led_polarity = pol;
4328                 spec->mute_led_nid = pin - 0x0a + 0x18;
4329                 snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4330                 codec->power_filter = led_power_filter;
4331                 codec_dbg(codec,
4332                           "Detected mute LED for %x:%d\n", spec->mute_led_nid,
4333                            spec->mute_led_polarity);
4334                 break;
4335         }
4336 }
4337
4338 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4339                                           const struct hda_fixup *fix,
4340                                           int action, hda_nid_t pin)
4341 {
4342         struct alc_spec *spec = codec->spec;
4343
4344         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4345                 spec->mute_led_polarity = 0;
4346                 spec->mute_led_nid = pin;
4347                 snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4348                 codec->power_filter = led_power_filter;
4349         }
4350 }
4351
4352 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4353                                 const struct hda_fixup *fix, int action)
4354 {
4355         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4356 }
4357
4358 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4359                                 const struct hda_fixup *fix, int action)
4360 {
4361         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4362 }
4363
4364 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4365                                 const struct hda_fixup *fix, int action)
4366 {
4367         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4368 }
4369
4370 /* update LED status via GPIO */
4371 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4372                                 int polarity, bool enabled)
4373 {
4374         if (polarity)
4375                 enabled = !enabled;
4376         alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4377 }
4378
4379 /* turn on/off mute LED via GPIO per vmaster hook */
4380 static int gpio_mute_led_set(struct led_classdev *led_cdev,
4381                              enum led_brightness brightness)
4382 {
4383         struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4384         struct alc_spec *spec = codec->spec;
4385
4386         alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
4387                             spec->mute_led_polarity, !brightness);
4388         return 0;
4389 }
4390
4391 /* turn on/off mic-mute LED via GPIO per capture hook */
4392 static int micmute_led_set(struct led_classdev *led_cdev,
4393                            enum led_brightness brightness)
4394 {
4395         struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4396         struct alc_spec *spec = codec->spec;
4397
4398         alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4399                             spec->micmute_led_polarity, !brightness);
4400         return 0;
4401 }
4402
4403 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
4404 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4405                                   int action,
4406                                   unsigned int mute_mask,
4407                                   unsigned int micmute_mask)
4408 {
4409         struct alc_spec *spec = codec->spec;
4410
4411         alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4412
4413         if (action != HDA_FIXUP_ACT_PRE_PROBE)
4414                 return;
4415         if (mute_mask) {
4416                 spec->gpio_mute_led_mask = mute_mask;
4417                 snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set);
4418         }
4419         if (micmute_mask) {
4420                 spec->gpio_mic_led_mask = micmute_mask;
4421                 snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set);
4422         }
4423 }
4424
4425 static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
4426                                 const struct hda_fixup *fix, int action)
4427 {
4428         alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
4429 }
4430
4431 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4432                                 const struct hda_fixup *fix, int action)
4433 {
4434         alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4435 }
4436
4437 static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4438                                 const struct hda_fixup *fix, int action)
4439 {
4440         alc_fixup_hp_gpio_led(codec, action, 0x04, 0x01);
4441 }
4442
4443 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4444                                 const struct hda_fixup *fix, int action)
4445 {
4446         alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4447 }
4448
4449 static void alc287_fixup_hp_gpio_led(struct hda_codec *codec,
4450                                 const struct hda_fixup *fix, int action)
4451 {
4452         alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
4453 }
4454
4455 static void alc245_fixup_hp_gpio_led(struct hda_codec *codec,
4456                                 const struct hda_fixup *fix, int action)
4457 {
4458         struct alc_spec *spec = codec->spec;
4459
4460         if (action == HDA_FIXUP_ACT_PRE_PROBE)
4461                 spec->micmute_led_polarity = 1;
4462         alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4463 }
4464
4465 /* turn on/off mic-mute LED per capture hook via VREF change */
4466 static int vref_micmute_led_set(struct led_classdev *led_cdev,
4467                                 enum led_brightness brightness)
4468 {
4469         struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4470         struct alc_spec *spec = codec->spec;
4471
4472         alc_update_vref_led(codec, spec->cap_mute_led_nid,
4473                             spec->micmute_led_polarity, brightness);
4474         return 0;
4475 }
4476
4477 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4478                                 const struct hda_fixup *fix, int action)
4479 {
4480         struct alc_spec *spec = codec->spec;
4481
4482         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4483         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4484                 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to
4485                  * enable headphone amp
4486                  */
4487                 spec->gpio_mask |= 0x10;
4488                 spec->gpio_dir |= 0x10;
4489                 spec->cap_mute_led_nid = 0x18;
4490                 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4491                 codec->power_filter = led_power_filter;
4492         }
4493 }
4494
4495 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4496                                    const struct hda_fixup *fix, int action)
4497 {
4498         struct alc_spec *spec = codec->spec;
4499
4500         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4501         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4502                 spec->cap_mute_led_nid = 0x18;
4503                 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4504                 codec->power_filter = led_power_filter;
4505         }
4506 }
4507
4508 /* HP Spectre x360 14 model needs a unique workaround for enabling the amp;
4509  * it needs to toggle the GPIO0 once on and off at each time (bko#210633)
4510  */
4511 static void alc245_fixup_hp_x360_amp(struct hda_codec *codec,
4512                                      const struct hda_fixup *fix, int action)
4513 {
4514         struct alc_spec *spec = codec->spec;
4515
4516         switch (action) {
4517         case HDA_FIXUP_ACT_PRE_PROBE:
4518                 spec->gpio_mask |= 0x01;
4519                 spec->gpio_dir |= 0x01;
4520                 break;
4521         case HDA_FIXUP_ACT_INIT:
4522                 /* need to toggle GPIO to enable the amp */
4523                 alc_update_gpio_data(codec, 0x01, true);
4524                 msleep(100);
4525                 alc_update_gpio_data(codec, 0x01, false);
4526                 break;
4527         }
4528 }
4529
4530 /* toggle GPIO2 at each time stream is started; we use PREPARE state instead */
4531 static void alc274_hp_envy_pcm_hook(struct hda_pcm_stream *hinfo,
4532                                     struct hda_codec *codec,
4533                                     struct snd_pcm_substream *substream,
4534                                     int action)
4535 {
4536         switch (action) {
4537         case HDA_GEN_PCM_ACT_PREPARE:
4538                 alc_update_gpio_data(codec, 0x04, true);
4539                 break;
4540         case HDA_GEN_PCM_ACT_CLEANUP:
4541                 alc_update_gpio_data(codec, 0x04, false);
4542                 break;
4543         }
4544 }
4545
4546 static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec,
4547                                       const struct hda_fixup *fix,
4548                                       int action)
4549 {
4550         struct alc_spec *spec = codec->spec;
4551
4552         if (action == HDA_FIXUP_ACT_PROBE) {
4553                 spec->gpio_mask |= 0x04;
4554                 spec->gpio_dir |= 0x04;
4555                 spec->gen.pcm_playback_hook = alc274_hp_envy_pcm_hook;
4556         }
4557 }
4558
4559 static void alc_update_coef_led(struct hda_codec *codec,
4560                                 struct alc_coef_led *led,
4561                                 bool polarity, bool on)
4562 {
4563         if (polarity)
4564                 on = !on;
4565         /* temporarily power up/down for setting COEF bit */
4566         alc_update_coef_idx(codec, led->idx, led->mask,
4567                             on ? led->on : led->off);
4568 }
4569
4570 /* update mute-LED according to the speaker mute state via COEF bit */
4571 static int coef_mute_led_set(struct led_classdev *led_cdev,
4572                              enum led_brightness brightness)
4573 {
4574         struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4575         struct alc_spec *spec = codec->spec;
4576
4577         alc_update_coef_led(codec, &spec->mute_led_coef,
4578                             spec->mute_led_polarity, brightness);
4579         return 0;
4580 }
4581
4582 static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4583                                           const struct hda_fixup *fix,
4584                                           int action)
4585 {
4586         struct alc_spec *spec = codec->spec;
4587
4588         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4589                 spec->mute_led_polarity = 0;
4590                 spec->mute_led_coef.idx = 0x0b;
4591                 spec->mute_led_coef.mask = 1 << 3;
4592                 spec->mute_led_coef.on = 1 << 3;
4593                 spec->mute_led_coef.off = 0;
4594                 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4595         }
4596 }
4597
4598 static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4599                                           const struct hda_fixup *fix,
4600                                           int action)
4601 {
4602         struct alc_spec *spec = codec->spec;
4603
4604         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4605                 spec->mute_led_polarity = 0;
4606                 spec->mute_led_coef.idx = 0x34;
4607                 spec->mute_led_coef.mask = 1 << 5;
4608                 spec->mute_led_coef.on = 0;
4609                 spec->mute_led_coef.off = 1 << 5;
4610                 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4611         }
4612 }
4613
4614 /* turn on/off mic-mute LED per capture hook by coef bit */
4615 static int coef_micmute_led_set(struct led_classdev *led_cdev,
4616                                 enum led_brightness brightness)
4617 {
4618         struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4619         struct alc_spec *spec = codec->spec;
4620
4621         alc_update_coef_led(codec, &spec->mic_led_coef,
4622                             spec->micmute_led_polarity, brightness);
4623         return 0;
4624 }
4625
4626 static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4627                                 const struct hda_fixup *fix, int action)
4628 {
4629         struct alc_spec *spec = codec->spec;
4630
4631         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4632                 spec->mic_led_coef.idx = 0x19;
4633                 spec->mic_led_coef.mask = 1 << 13;
4634                 spec->mic_led_coef.on = 1 << 13;
4635                 spec->mic_led_coef.off = 0;
4636                 snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4637         }
4638 }
4639
4640 static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4641                                 const struct hda_fixup *fix, int action)
4642 {
4643         struct alc_spec *spec = codec->spec;
4644
4645         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4646                 spec->mic_led_coef.idx = 0x35;
4647                 spec->mic_led_coef.mask = 3 << 2;
4648                 spec->mic_led_coef.on = 2 << 2;
4649                 spec->mic_led_coef.off = 1 << 2;
4650                 snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4651         }
4652 }
4653
4654 static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4655                                 const struct hda_fixup *fix, int action)
4656 {
4657         alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4658         alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4659 }
4660
4661 static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4662                                 const struct hda_fixup *fix, int action)
4663 {
4664         alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4665         alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4666 }
4667
4668 static void alc236_fixup_hp_micmute_led_vref(struct hda_codec *codec,
4669                                 const struct hda_fixup *fix, int action)
4670 {
4671         struct alc_spec *spec = codec->spec;
4672
4673         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4674                 spec->cap_mute_led_nid = 0x1a;
4675                 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4676                 codec->power_filter = led_power_filter;
4677         }
4678 }
4679
4680 static void alc236_fixup_hp_mute_led_micmute_vref(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_micmute_led_vref(codec, fix, action);
4685 }
4686
4687 static inline void alc298_samsung_write_coef_pack(struct hda_codec *codec,
4688                                                   const unsigned short coefs[2])
4689 {
4690         alc_write_coef_idx(codec, 0x23, coefs[0]);
4691         alc_write_coef_idx(codec, 0x25, coefs[1]);
4692         alc_write_coef_idx(codec, 0x26, 0xb011);
4693 }
4694
4695 struct alc298_samsung_amp_desc {
4696         unsigned char nid;
4697         unsigned short init_seq[2][2];
4698 };
4699
4700 static void alc298_fixup_samsung_amp(struct hda_codec *codec,
4701                                      const struct hda_fixup *fix, int action)
4702 {
4703         int i, j;
4704         static const unsigned short init_seq[][2] = {
4705                 { 0x19, 0x00 }, { 0x20, 0xc0 }, { 0x22, 0x44 }, { 0x23, 0x08 },
4706                 { 0x24, 0x85 }, { 0x25, 0x41 }, { 0x35, 0x40 }, { 0x36, 0x01 },
4707                 { 0x38, 0x81 }, { 0x3a, 0x03 }, { 0x3b, 0x81 }, { 0x40, 0x3e },
4708                 { 0x41, 0x07 }, { 0x400, 0x1 }
4709         };
4710         static const struct alc298_samsung_amp_desc amps[] = {
4711                 { 0x3a, { { 0x18, 0x1 }, { 0x26, 0x0 } } },
4712                 { 0x39, { { 0x18, 0x2 }, { 0x26, 0x1 } } }
4713         };
4714
4715         if (action != HDA_FIXUP_ACT_INIT)
4716                 return;
4717
4718         for (i = 0; i < ARRAY_SIZE(amps); i++) {
4719                 alc_write_coef_idx(codec, 0x22, amps[i].nid);
4720
4721                 for (j = 0; j < ARRAY_SIZE(amps[i].init_seq); j++)
4722                         alc298_samsung_write_coef_pack(codec, amps[i].init_seq[j]);
4723
4724                 for (j = 0; j < ARRAY_SIZE(init_seq); j++)
4725                         alc298_samsung_write_coef_pack(codec, init_seq[j]);
4726         }
4727 }
4728
4729 #if IS_REACHABLE(CONFIG_INPUT)
4730 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4731                                    struct hda_jack_callback *event)
4732 {
4733         struct alc_spec *spec = codec->spec;
4734
4735         /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4736            send both key on and key off event for every interrupt. */
4737         input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4738         input_sync(spec->kb_dev);
4739         input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4740         input_sync(spec->kb_dev);
4741 }
4742
4743 static int alc_register_micmute_input_device(struct hda_codec *codec)
4744 {
4745         struct alc_spec *spec = codec->spec;
4746         int i;
4747
4748         spec->kb_dev = input_allocate_device();
4749         if (!spec->kb_dev) {
4750                 codec_err(codec, "Out of memory (input_allocate_device)\n");
4751                 return -ENOMEM;
4752         }
4753
4754         spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4755
4756         spec->kb_dev->name = "Microphone Mute Button";
4757         spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4758         spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4759         spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4760         spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4761         for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4762                 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4763
4764         if (input_register_device(spec->kb_dev)) {
4765                 codec_err(codec, "input_register_device failed\n");
4766                 input_free_device(spec->kb_dev);
4767                 spec->kb_dev = NULL;
4768                 return -ENOMEM;
4769         }
4770
4771         return 0;
4772 }
4773
4774 /* GPIO1 = set according to SKU external amp
4775  * GPIO2 = mic mute hotkey
4776  * GPIO3 = mute LED
4777  * GPIO4 = mic mute LED
4778  */
4779 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4780                                              const struct hda_fixup *fix, int action)
4781 {
4782         struct alc_spec *spec = codec->spec;
4783
4784         alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4785         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4786                 spec->init_amp = ALC_INIT_DEFAULT;
4787                 if (alc_register_micmute_input_device(codec) != 0)
4788                         return;
4789
4790                 spec->gpio_mask |= 0x06;
4791                 spec->gpio_dir |= 0x02;
4792                 spec->gpio_data |= 0x02;
4793                 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4794                                           AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
4795                 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4796                                                     gpio2_mic_hotkey_event);
4797                 return;
4798         }
4799
4800         if (!spec->kb_dev)
4801                 return;
4802
4803         switch (action) {
4804         case HDA_FIXUP_ACT_FREE:
4805                 input_unregister_device(spec->kb_dev);
4806                 spec->kb_dev = NULL;
4807         }
4808 }
4809
4810 /* Line2 = mic mute hotkey
4811  * GPIO2 = mic mute LED
4812  */
4813 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4814                                              const struct hda_fixup *fix, int action)
4815 {
4816         struct alc_spec *spec = codec->spec;
4817
4818         alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4819         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4820                 spec->init_amp = ALC_INIT_DEFAULT;
4821                 if (alc_register_micmute_input_device(codec) != 0)
4822                         return;
4823
4824                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4825                                                     gpio2_mic_hotkey_event);
4826                 return;
4827         }
4828
4829         if (!spec->kb_dev)
4830                 return;
4831
4832         switch (action) {
4833         case HDA_FIXUP_ACT_FREE:
4834                 input_unregister_device(spec->kb_dev);
4835                 spec->kb_dev = NULL;
4836         }
4837 }
4838 #else /* INPUT */
4839 #define alc280_fixup_hp_gpio2_mic_hotkey        NULL
4840 #define alc233_fixup_lenovo_line2_mic_hotkey    NULL
4841 #endif /* INPUT */
4842
4843 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4844                                 const struct hda_fixup *fix, int action)
4845 {
4846         struct alc_spec *spec = codec->spec;
4847
4848         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4849         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4850                 spec->cap_mute_led_nid = 0x18;
4851                 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4852         }
4853 }
4854
4855 static const struct coef_fw alc225_pre_hsmode[] = {
4856         UPDATE_COEF(0x4a, 1<<8, 0),
4857         UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4858         UPDATE_COEF(0x63, 3<<14, 3<<14),
4859         UPDATE_COEF(0x4a, 3<<4, 2<<4),
4860         UPDATE_COEF(0x4a, 3<<10, 3<<10),
4861         UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4862         UPDATE_COEF(0x4a, 3<<10, 0),
4863         {}
4864 };
4865
4866 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4867 {
4868         struct alc_spec *spec = codec->spec;
4869         static const struct coef_fw coef0255[] = {
4870                 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4871                 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4872                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4873                 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4874                 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4875                 {}
4876         };
4877         static const struct coef_fw coef0256[] = {
4878                 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4879                 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4880                 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4881                 WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4882                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4883                 {}
4884         };
4885         static const struct coef_fw coef0233[] = {
4886                 WRITE_COEF(0x1b, 0x0c0b),
4887                 WRITE_COEF(0x45, 0xc429),
4888                 UPDATE_COEF(0x35, 0x4000, 0),
4889                 WRITE_COEF(0x06, 0x2104),
4890                 WRITE_COEF(0x1a, 0x0001),
4891                 WRITE_COEF(0x26, 0x0004),
4892                 WRITE_COEF(0x32, 0x42a3),
4893                 {}
4894         };
4895         static const struct coef_fw coef0288[] = {
4896                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4897                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4898                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4899                 UPDATE_COEF(0x66, 0x0008, 0),
4900                 UPDATE_COEF(0x67, 0x2000, 0),
4901                 {}
4902         };
4903         static const struct coef_fw coef0298[] = {
4904                 UPDATE_COEF(0x19, 0x1300, 0x0300),
4905                 {}
4906         };
4907         static const struct coef_fw coef0292[] = {
4908                 WRITE_COEF(0x76, 0x000e),
4909                 WRITE_COEF(0x6c, 0x2400),
4910                 WRITE_COEF(0x18, 0x7308),
4911                 WRITE_COEF(0x6b, 0xc429),
4912                 {}
4913         };
4914         static const struct coef_fw coef0293[] = {
4915                 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4916                 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4917                 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4918                 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4919                 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4920                 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4921                 {}
4922         };
4923         static const struct coef_fw coef0668[] = {
4924                 WRITE_COEF(0x15, 0x0d40),
4925                 WRITE_COEF(0xb7, 0x802b),
4926                 {}
4927         };
4928         static const struct coef_fw coef0225[] = {
4929                 UPDATE_COEF(0x63, 3<<14, 0),
4930                 {}
4931         };
4932         static const struct coef_fw coef0274[] = {
4933                 UPDATE_COEF(0x4a, 0x0100, 0),
4934                 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4935                 UPDATE_COEF(0x6b, 0xf000, 0x5000),
4936                 UPDATE_COEF(0x4a, 0x0010, 0),
4937                 UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4938                 WRITE_COEF(0x45, 0x5289),
4939                 UPDATE_COEF(0x4a, 0x0c00, 0),
4940                 {}
4941         };
4942
4943         if (spec->no_internal_mic_pin) {
4944                 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
4945                 return;
4946         }
4947
4948         switch (codec->core.vendor_id) {
4949         case 0x10ec0255:
4950                 alc_process_coef_fw(codec, coef0255);
4951                 break;
4952         case 0x10ec0230:
4953         case 0x10ec0236:
4954         case 0x10ec0256:
4955         case 0x19e58326:
4956                 alc_process_coef_fw(codec, coef0256);
4957                 break;
4958         case 0x10ec0234:
4959         case 0x10ec0274:
4960         case 0x10ec0294:
4961                 alc_process_coef_fw(codec, coef0274);
4962                 break;
4963         case 0x10ec0233:
4964         case 0x10ec0283:
4965                 alc_process_coef_fw(codec, coef0233);
4966                 break;
4967         case 0x10ec0286:
4968         case 0x10ec0288:
4969                 alc_process_coef_fw(codec, coef0288);
4970                 break;
4971         case 0x10ec0298:
4972                 alc_process_coef_fw(codec, coef0298);
4973                 alc_process_coef_fw(codec, coef0288);
4974                 break;
4975         case 0x10ec0292:
4976                 alc_process_coef_fw(codec, coef0292);
4977                 break;
4978         case 0x10ec0293:
4979                 alc_process_coef_fw(codec, coef0293);
4980                 break;
4981         case 0x10ec0668:
4982                 alc_process_coef_fw(codec, coef0668);
4983                 break;
4984         case 0x10ec0215:
4985         case 0x10ec0225:
4986         case 0x10ec0285:
4987         case 0x10ec0295:
4988         case 0x10ec0289:
4989         case 0x10ec0299:
4990                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4991                 alc_process_coef_fw(codec, coef0225);
4992                 break;
4993         case 0x10ec0867:
4994                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4995                 break;
4996         }
4997         codec_dbg(codec, "Headset jack set to unplugged mode.\n");
4998 }
4999
5000
5001 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5002                                     hda_nid_t mic_pin)
5003 {
5004         static const struct coef_fw coef0255[] = {
5005                 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
5006                 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
5007                 {}
5008         };
5009         static const struct coef_fw coef0256[] = {
5010                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
5011                 WRITE_COEFEX(0x57, 0x03, 0x09a3),
5012                 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
5013                 {}
5014         };
5015         static const struct coef_fw coef0233[] = {
5016                 UPDATE_COEF(0x35, 0, 1<<14),
5017                 WRITE_COEF(0x06, 0x2100),
5018                 WRITE_COEF(0x1a, 0x0021),
5019                 WRITE_COEF(0x26, 0x008c),
5020                 {}
5021         };
5022         static const struct coef_fw coef0288[] = {
5023                 UPDATE_COEF(0x4f, 0x00c0, 0),
5024                 UPDATE_COEF(0x50, 0x2000, 0),
5025                 UPDATE_COEF(0x56, 0x0006, 0),
5026                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
5027                 UPDATE_COEF(0x66, 0x0008, 0x0008),
5028                 UPDATE_COEF(0x67, 0x2000, 0x2000),
5029                 {}
5030         };
5031         static const struct coef_fw coef0292[] = {
5032                 WRITE_COEF(0x19, 0xa208),
5033                 WRITE_COEF(0x2e, 0xacf0),
5034                 {}
5035         };
5036         static const struct coef_fw coef0293[] = {
5037                 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
5038                 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
5039                 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5040                 {}
5041         };
5042         static const struct coef_fw coef0688[] = {
5043                 WRITE_COEF(0xb7, 0x802b),
5044                 WRITE_COEF(0xb5, 0x1040),
5045                 UPDATE_COEF(0xc3, 0, 1<<12),
5046                 {}
5047         };
5048         static const struct coef_fw coef0225[] = {
5049                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
5050                 UPDATE_COEF(0x4a, 3<<4, 2<<4),
5051                 UPDATE_COEF(0x63, 3<<14, 0),
5052                 {}
5053         };
5054         static const struct coef_fw coef0274[] = {
5055                 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
5056                 UPDATE_COEF(0x4a, 0x0010, 0),
5057                 UPDATE_COEF(0x6b, 0xf000, 0),
5058                 {}
5059         };
5060
5061         switch (codec->core.vendor_id) {
5062         case 0x10ec0255:
5063                 alc_write_coef_idx(codec, 0x45, 0xc489);
5064                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5065                 alc_process_coef_fw(codec, coef0255);
5066                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5067                 break;
5068         case 0x10ec0230:
5069         case 0x10ec0236:
5070         case 0x10ec0256:
5071         case 0x19e58326:
5072                 alc_write_coef_idx(codec, 0x45, 0xc489);
5073                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5074                 alc_process_coef_fw(codec, coef0256);
5075                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5076                 break;
5077         case 0x10ec0234:
5078         case 0x10ec0274:
5079         case 0x10ec0294:
5080                 alc_write_coef_idx(codec, 0x45, 0x4689);
5081                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5082                 alc_process_coef_fw(codec, coef0274);
5083                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5084                 break;
5085         case 0x10ec0233:
5086         case 0x10ec0283:
5087                 alc_write_coef_idx(codec, 0x45, 0xc429);
5088                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5089                 alc_process_coef_fw(codec, coef0233);
5090                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5091                 break;
5092         case 0x10ec0286:
5093         case 0x10ec0288:
5094         case 0x10ec0298:
5095                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5096                 alc_process_coef_fw(codec, coef0288);
5097                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5098                 break;
5099         case 0x10ec0292:
5100                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5101                 alc_process_coef_fw(codec, coef0292);
5102                 break;
5103         case 0x10ec0293:
5104                 /* Set to TRS mode */
5105                 alc_write_coef_idx(codec, 0x45, 0xc429);
5106                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5107                 alc_process_coef_fw(codec, coef0293);
5108                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5109                 break;
5110         case 0x10ec0867:
5111                 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
5112                 fallthrough;
5113         case 0x10ec0221:
5114         case 0x10ec0662:
5115                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5116                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5117                 break;
5118         case 0x10ec0668:
5119                 alc_write_coef_idx(codec, 0x11, 0x0001);
5120                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5121                 alc_process_coef_fw(codec, coef0688);
5122                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5123                 break;
5124         case 0x10ec0215:
5125         case 0x10ec0225:
5126         case 0x10ec0285:
5127         case 0x10ec0295:
5128         case 0x10ec0289:
5129         case 0x10ec0299:
5130                 alc_process_coef_fw(codec, alc225_pre_hsmode);
5131                 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
5132                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5133                 alc_process_coef_fw(codec, coef0225);
5134                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5135                 break;
5136         }
5137         codec_dbg(codec, "Headset jack set to mic-in mode.\n");
5138 }
5139
5140 static void alc_headset_mode_default(struct hda_codec *codec)
5141 {
5142         static const struct coef_fw coef0225[] = {
5143                 UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
5144                 UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
5145                 UPDATE_COEF(0x49, 3<<8, 0<<8),
5146                 UPDATE_COEF(0x4a, 3<<4, 3<<4),
5147                 UPDATE_COEF(0x63, 3<<14, 0),
5148                 UPDATE_COEF(0x67, 0xf000, 0x3000),
5149                 {}
5150         };
5151         static const struct coef_fw coef0255[] = {
5152                 WRITE_COEF(0x45, 0xc089),
5153                 WRITE_COEF(0x45, 0xc489),
5154                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5155                 WRITE_COEF(0x49, 0x0049),
5156                 {}
5157         };
5158         static const struct coef_fw coef0256[] = {
5159                 WRITE_COEF(0x45, 0xc489),
5160                 WRITE_COEFEX(0x57, 0x03, 0x0da3),
5161                 WRITE_COEF(0x49, 0x0049),
5162                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
5163                 WRITE_COEF(0x06, 0x6100),
5164                 {}
5165         };
5166         static const struct coef_fw coef0233[] = {
5167                 WRITE_COEF(0x06, 0x2100),
5168                 WRITE_COEF(0x32, 0x4ea3),
5169                 {}
5170         };
5171         static const struct coef_fw coef0288[] = {
5172                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
5173                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5174                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5175                 UPDATE_COEF(0x66, 0x0008, 0),
5176                 UPDATE_COEF(0x67, 0x2000, 0),
5177                 {}
5178         };
5179         static const struct coef_fw coef0292[] = {
5180                 WRITE_COEF(0x76, 0x000e),
5181                 WRITE_COEF(0x6c, 0x2400),
5182                 WRITE_COEF(0x6b, 0xc429),
5183                 WRITE_COEF(0x18, 0x7308),
5184                 {}
5185         };
5186         static const struct coef_fw coef0293[] = {
5187                 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
5188                 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
5189                 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5190                 {}
5191         };
5192         static const struct coef_fw coef0688[] = {
5193                 WRITE_COEF(0x11, 0x0041),
5194                 WRITE_COEF(0x15, 0x0d40),
5195                 WRITE_COEF(0xb7, 0x802b),
5196                 {}
5197         };
5198         static const struct coef_fw coef0274[] = {
5199                 WRITE_COEF(0x45, 0x4289),
5200                 UPDATE_COEF(0x4a, 0x0010, 0x0010),
5201                 UPDATE_COEF(0x6b, 0x0f00, 0),
5202                 UPDATE_COEF(0x49, 0x0300, 0x0300),
5203                 {}
5204         };
5205
5206         switch (codec->core.vendor_id) {
5207         case 0x10ec0215:
5208         case 0x10ec0225:
5209         case 0x10ec0285:
5210         case 0x10ec0295:
5211         case 0x10ec0289:
5212         case 0x10ec0299:
5213                 alc_process_coef_fw(codec, alc225_pre_hsmode);
5214                 alc_process_coef_fw(codec, coef0225);
5215                 break;
5216         case 0x10ec0255:
5217                 alc_process_coef_fw(codec, coef0255);
5218                 break;
5219         case 0x10ec0230:
5220         case 0x10ec0236:
5221         case 0x10ec0256:
5222         case 0x19e58326:
5223                 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5224                 alc_write_coef_idx(codec, 0x45, 0xc089);
5225                 msleep(50);
5226                 alc_process_coef_fw(codec, coef0256);
5227                 break;
5228         case 0x10ec0234:
5229         case 0x10ec0274:
5230         case 0x10ec0294:
5231                 alc_process_coef_fw(codec, coef0274);
5232                 break;
5233         case 0x10ec0233:
5234         case 0x10ec0283:
5235                 alc_process_coef_fw(codec, coef0233);
5236                 break;
5237         case 0x10ec0286:
5238         case 0x10ec0288:
5239         case 0x10ec0298:
5240                 alc_process_coef_fw(codec, coef0288);
5241                 break;
5242         case 0x10ec0292:
5243                 alc_process_coef_fw(codec, coef0292);
5244                 break;
5245         case 0x10ec0293:
5246                 alc_process_coef_fw(codec, coef0293);
5247                 break;
5248         case 0x10ec0668:
5249                 alc_process_coef_fw(codec, coef0688);
5250                 break;
5251         case 0x10ec0867:
5252                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5253                 break;
5254         }
5255         codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5256 }
5257
5258 /* Iphone type */
5259 static void alc_headset_mode_ctia(struct hda_codec *codec)
5260 {
5261         int val;
5262
5263         static const struct coef_fw coef0255[] = {
5264                 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5265                 WRITE_COEF(0x1b, 0x0c2b),
5266                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5267                 {}
5268         };
5269         static const struct coef_fw coef0256[] = {
5270                 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5271                 WRITE_COEF(0x1b, 0x0e6b),
5272                 {}
5273         };
5274         static const struct coef_fw coef0233[] = {
5275                 WRITE_COEF(0x45, 0xd429),
5276                 WRITE_COEF(0x1b, 0x0c2b),
5277                 WRITE_COEF(0x32, 0x4ea3),
5278                 {}
5279         };
5280         static const struct coef_fw coef0288[] = {
5281                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5282                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5283                 UPDATE_COEF(0x66, 0x0008, 0),
5284                 UPDATE_COEF(0x67, 0x2000, 0),
5285                 {}
5286         };
5287         static const struct coef_fw coef0292[] = {
5288                 WRITE_COEF(0x6b, 0xd429),
5289                 WRITE_COEF(0x76, 0x0008),
5290                 WRITE_COEF(0x18, 0x7388),
5291                 {}
5292         };
5293         static const struct coef_fw coef0293[] = {
5294                 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
5295                 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5296                 {}
5297         };
5298         static const struct coef_fw coef0688[] = {
5299                 WRITE_COEF(0x11, 0x0001),
5300                 WRITE_COEF(0x15, 0x0d60),
5301                 WRITE_COEF(0xc3, 0x0000),
5302                 {}
5303         };
5304         static const struct coef_fw coef0225_1[] = {
5305                 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5306                 UPDATE_COEF(0x63, 3<<14, 2<<14),
5307                 {}
5308         };
5309         static const struct coef_fw coef0225_2[] = {
5310                 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5311                 UPDATE_COEF(0x63, 3<<14, 1<<14),
5312                 {}
5313         };
5314
5315         switch (codec->core.vendor_id) {
5316         case 0x10ec0255:
5317                 alc_process_coef_fw(codec, coef0255);
5318                 break;
5319         case 0x10ec0230:
5320         case 0x10ec0236:
5321         case 0x10ec0256:
5322         case 0x19e58326:
5323                 alc_process_coef_fw(codec, coef0256);
5324                 break;
5325         case 0x10ec0234:
5326         case 0x10ec0274:
5327         case 0x10ec0294:
5328                 alc_write_coef_idx(codec, 0x45, 0xd689);
5329                 break;
5330         case 0x10ec0233:
5331         case 0x10ec0283:
5332                 alc_process_coef_fw(codec, coef0233);
5333                 break;
5334         case 0x10ec0298:
5335                 val = alc_read_coef_idx(codec, 0x50);
5336                 if (val & (1 << 12)) {
5337                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5338                         alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5339                         msleep(300);
5340                 } else {
5341                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5342                         alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5343                         msleep(300);
5344                 }
5345                 break;
5346         case 0x10ec0286:
5347         case 0x10ec0288:
5348                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5349                 msleep(300);
5350                 alc_process_coef_fw(codec, coef0288);
5351                 break;
5352         case 0x10ec0292:
5353                 alc_process_coef_fw(codec, coef0292);
5354                 break;
5355         case 0x10ec0293:
5356                 alc_process_coef_fw(codec, coef0293);
5357                 break;
5358         case 0x10ec0668:
5359                 alc_process_coef_fw(codec, coef0688);
5360                 break;
5361         case 0x10ec0215:
5362         case 0x10ec0225:
5363         case 0x10ec0285:
5364         case 0x10ec0295:
5365         case 0x10ec0289:
5366         case 0x10ec0299:
5367                 val = alc_read_coef_idx(codec, 0x45);
5368                 if (val & (1 << 9))
5369                         alc_process_coef_fw(codec, coef0225_2);
5370                 else
5371                         alc_process_coef_fw(codec, coef0225_1);
5372                 break;
5373         case 0x10ec0867:
5374                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5375                 break;
5376         }
5377         codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5378 }
5379
5380 /* Nokia type */
5381 static void alc_headset_mode_omtp(struct hda_codec *codec)
5382 {
5383         static const struct coef_fw coef0255[] = {
5384                 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5385                 WRITE_COEF(0x1b, 0x0c2b),
5386                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5387                 {}
5388         };
5389         static const struct coef_fw coef0256[] = {
5390                 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5391                 WRITE_COEF(0x1b, 0x0e6b),
5392                 {}
5393         };
5394         static const struct coef_fw coef0233[] = {
5395                 WRITE_COEF(0x45, 0xe429),
5396                 WRITE_COEF(0x1b, 0x0c2b),
5397                 WRITE_COEF(0x32, 0x4ea3),
5398                 {}
5399         };
5400         static const struct coef_fw coef0288[] = {
5401                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5402                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5403                 UPDATE_COEF(0x66, 0x0008, 0),
5404                 UPDATE_COEF(0x67, 0x2000, 0),
5405                 {}
5406         };
5407         static const struct coef_fw coef0292[] = {
5408                 WRITE_COEF(0x6b, 0xe429),
5409                 WRITE_COEF(0x76, 0x0008),
5410                 WRITE_COEF(0x18, 0x7388),
5411                 {}
5412         };
5413         static const struct coef_fw coef0293[] = {
5414                 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
5415                 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5416                 {}
5417         };
5418         static const struct coef_fw coef0688[] = {
5419                 WRITE_COEF(0x11, 0x0001),
5420                 WRITE_COEF(0x15, 0x0d50),
5421                 WRITE_COEF(0xc3, 0x0000),
5422                 {}
5423         };
5424         static const struct coef_fw coef0225[] = {
5425                 UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5426                 UPDATE_COEF(0x63, 3<<14, 2<<14),
5427                 {}
5428         };
5429
5430         switch (codec->core.vendor_id) {
5431         case 0x10ec0255:
5432                 alc_process_coef_fw(codec, coef0255);
5433                 break;
5434         case 0x10ec0230:
5435         case 0x10ec0236:
5436         case 0x10ec0256:
5437         case 0x19e58326:
5438                 alc_process_coef_fw(codec, coef0256);
5439                 break;
5440         case 0x10ec0234:
5441         case 0x10ec0274:
5442         case 0x10ec0294:
5443                 alc_write_coef_idx(codec, 0x45, 0xe689);
5444                 break;
5445         case 0x10ec0233:
5446         case 0x10ec0283:
5447                 alc_process_coef_fw(codec, coef0233);
5448                 break;
5449         case 0x10ec0298:
5450                 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5451                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5452                 msleep(300);
5453                 break;
5454         case 0x10ec0286:
5455         case 0x10ec0288:
5456                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5457                 msleep(300);
5458                 alc_process_coef_fw(codec, coef0288);
5459                 break;
5460         case 0x10ec0292:
5461                 alc_process_coef_fw(codec, coef0292);
5462                 break;
5463         case 0x10ec0293:
5464                 alc_process_coef_fw(codec, coef0293);
5465                 break;
5466         case 0x10ec0668:
5467                 alc_process_coef_fw(codec, coef0688);
5468                 break;
5469         case 0x10ec0215:
5470         case 0x10ec0225:
5471         case 0x10ec0285:
5472         case 0x10ec0295:
5473         case 0x10ec0289:
5474         case 0x10ec0299:
5475                 alc_process_coef_fw(codec, coef0225);
5476                 break;
5477         }
5478         codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5479 }
5480
5481 static void alc_determine_headset_type(struct hda_codec *codec)
5482 {
5483         int val;
5484         bool is_ctia = false;
5485         struct alc_spec *spec = codec->spec;
5486         static const struct coef_fw coef0255[] = {
5487                 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
5488                 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
5489  conteol) */
5490                 {}
5491         };
5492         static const struct coef_fw coef0288[] = {
5493                 UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
5494                 {}
5495         };
5496         static const struct coef_fw coef0298[] = {
5497                 UPDATE_COEF(0x50, 0x2000, 0x2000),
5498                 UPDATE_COEF(0x56, 0x0006, 0x0006),
5499                 UPDATE_COEF(0x66, 0x0008, 0),
5500                 UPDATE_COEF(0x67, 0x2000, 0),
5501                 UPDATE_COEF(0x19, 0x1300, 0x1300),
5502                 {}
5503         };
5504         static const struct coef_fw coef0293[] = {
5505                 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
5506                 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
5507                 {}
5508         };
5509         static const struct coef_fw coef0688[] = {
5510                 WRITE_COEF(0x11, 0x0001),
5511                 WRITE_COEF(0xb7, 0x802b),
5512                 WRITE_COEF(0x15, 0x0d60),
5513                 WRITE_COEF(0xc3, 0x0c00),
5514                 {}
5515         };
5516         static const struct coef_fw coef0274[] = {
5517                 UPDATE_COEF(0x4a, 0x0010, 0),
5518                 UPDATE_COEF(0x4a, 0x8000, 0),
5519                 WRITE_COEF(0x45, 0xd289),
5520                 UPDATE_COEF(0x49, 0x0300, 0x0300),
5521                 {}
5522         };
5523
5524         if (spec->no_internal_mic_pin) {
5525                 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5526                 return;
5527         }
5528
5529         switch (codec->core.vendor_id) {
5530         case 0x10ec0255:
5531                 alc_process_coef_fw(codec, coef0255);
5532                 msleep(300);
5533                 val = alc_read_coef_idx(codec, 0x46);
5534                 is_ctia = (val & 0x0070) == 0x0070;
5535                 break;
5536         case 0x10ec0230:
5537         case 0x10ec0236:
5538         case 0x10ec0256:
5539         case 0x19e58326:
5540                 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5541                 alc_write_coef_idx(codec, 0x06, 0x6104);
5542                 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5543
5544                 snd_hda_codec_write(codec, 0x21, 0,
5545                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5546                 msleep(80);
5547                 snd_hda_codec_write(codec, 0x21, 0,
5548                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5549
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
5555                 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5556                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5557
5558                 snd_hda_codec_write(codec, 0x21, 0,
5559                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5560                 msleep(80);
5561                 snd_hda_codec_write(codec, 0x21, 0,
5562                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5563                 break;
5564         case 0x10ec0234:
5565         case 0x10ec0274:
5566         case 0x10ec0294:
5567                 alc_process_coef_fw(codec, coef0274);
5568                 msleep(850);
5569                 val = alc_read_coef_idx(codec, 0x46);
5570                 is_ctia = (val & 0x00f0) == 0x00f0;
5571                 break;
5572         case 0x10ec0233:
5573         case 0x10ec0283:
5574                 alc_write_coef_idx(codec, 0x45, 0xd029);
5575                 msleep(300);
5576                 val = alc_read_coef_idx(codec, 0x46);
5577                 is_ctia = (val & 0x0070) == 0x0070;
5578                 break;
5579         case 0x10ec0298:
5580                 snd_hda_codec_write(codec, 0x21, 0,
5581                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5582                 msleep(100);
5583                 snd_hda_codec_write(codec, 0x21, 0,
5584                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5585                 msleep(200);
5586
5587                 val = alc_read_coef_idx(codec, 0x50);
5588                 if (val & (1 << 12)) {
5589                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5590                         alc_process_coef_fw(codec, coef0288);
5591                         msleep(350);
5592                         val = alc_read_coef_idx(codec, 0x50);
5593                         is_ctia = (val & 0x0070) == 0x0070;
5594                 } else {
5595                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5596                         alc_process_coef_fw(codec, coef0288);
5597                         msleep(350);
5598                         val = alc_read_coef_idx(codec, 0x50);
5599                         is_ctia = (val & 0x0070) == 0x0070;
5600                 }
5601                 alc_process_coef_fw(codec, coef0298);
5602                 snd_hda_codec_write(codec, 0x21, 0,
5603                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
5604                 msleep(75);
5605                 snd_hda_codec_write(codec, 0x21, 0,
5606                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5607                 break;
5608         case 0x10ec0286:
5609         case 0x10ec0288:
5610                 alc_process_coef_fw(codec, coef0288);
5611                 msleep(350);
5612                 val = alc_read_coef_idx(codec, 0x50);
5613                 is_ctia = (val & 0x0070) == 0x0070;
5614                 break;
5615         case 0x10ec0292:
5616                 alc_write_coef_idx(codec, 0x6b, 0xd429);
5617                 msleep(300);
5618                 val = alc_read_coef_idx(codec, 0x6c);
5619                 is_ctia = (val & 0x001c) == 0x001c;
5620                 break;
5621         case 0x10ec0293:
5622                 alc_process_coef_fw(codec, coef0293);
5623                 msleep(300);
5624                 val = alc_read_coef_idx(codec, 0x46);
5625                 is_ctia = (val & 0x0070) == 0x0070;
5626                 break;
5627         case 0x10ec0668:
5628                 alc_process_coef_fw(codec, coef0688);
5629                 msleep(300);
5630                 val = alc_read_coef_idx(codec, 0xbe);
5631                 is_ctia = (val & 0x1c02) == 0x1c02;
5632                 break;
5633         case 0x10ec0215:
5634         case 0x10ec0225:
5635         case 0x10ec0285:
5636         case 0x10ec0295:
5637         case 0x10ec0289:
5638         case 0x10ec0299:
5639                 snd_hda_codec_write(codec, 0x21, 0,
5640                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5641                 msleep(80);
5642                 snd_hda_codec_write(codec, 0x21, 0,
5643                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5644
5645                 alc_process_coef_fw(codec, alc225_pre_hsmode);
5646                 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5647                 val = alc_read_coef_idx(codec, 0x45);
5648                 if (val & (1 << 9)) {
5649                         alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5650                         alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5651                         msleep(800);
5652                         val = alc_read_coef_idx(codec, 0x46);
5653                         is_ctia = (val & 0x00f0) == 0x00f0;
5654                 } else {
5655                         alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5656                         alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5657                         msleep(800);
5658                         val = alc_read_coef_idx(codec, 0x46);
5659                         is_ctia = (val & 0x00f0) == 0x00f0;
5660                 }
5661                 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5662                 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5663                 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5664
5665                 snd_hda_codec_write(codec, 0x21, 0,
5666                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5667                 msleep(80);
5668                 snd_hda_codec_write(codec, 0x21, 0,
5669                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5670                 break;
5671         case 0x10ec0867:
5672                 is_ctia = true;
5673                 break;
5674         }
5675
5676         codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5677                     is_ctia ? "yes" : "no");
5678         spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5679 }
5680
5681 static void alc_update_headset_mode(struct hda_codec *codec)
5682 {
5683         struct alc_spec *spec = codec->spec;
5684
5685         hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5686         hda_nid_t hp_pin = alc_get_hp_pin(spec);
5687
5688         int new_headset_mode;
5689
5690         if (!snd_hda_jack_detect(codec, hp_pin))
5691                 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
5692         else if (mux_pin == spec->headset_mic_pin)
5693                 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
5694         else if (mux_pin == spec->headphone_mic_pin)
5695                 new_headset_mode = ALC_HEADSET_MODE_MIC;
5696         else
5697                 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
5698
5699         if (new_headset_mode == spec->current_headset_mode) {
5700                 snd_hda_gen_update_outputs(codec);
5701                 return;
5702         }
5703
5704         switch (new_headset_mode) {
5705         case ALC_HEADSET_MODE_UNPLUGGED:
5706                 alc_headset_mode_unplugged(codec);
5707                 spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5708                 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5709                 spec->gen.hp_jack_present = false;
5710                 break;
5711         case ALC_HEADSET_MODE_HEADSET:
5712                 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5713                         alc_determine_headset_type(codec);
5714                 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5715                         alc_headset_mode_ctia(codec);
5716                 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5717                         alc_headset_mode_omtp(codec);
5718                 spec->gen.hp_jack_present = true;
5719                 break;
5720         case ALC_HEADSET_MODE_MIC:
5721                 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5722                 spec->gen.hp_jack_present = false;
5723                 break;
5724         case ALC_HEADSET_MODE_HEADPHONE:
5725                 alc_headset_mode_default(codec);
5726                 spec->gen.hp_jack_present = true;
5727                 break;
5728         }
5729         if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5730                 snd_hda_set_pin_ctl_cache(codec, hp_pin,
5731                                           AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5732                 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5733                         snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5734                                                   PIN_VREFHIZ);
5735         }
5736         spec->current_headset_mode = new_headset_mode;
5737
5738         snd_hda_gen_update_outputs(codec);
5739 }
5740
5741 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5742                                          struct snd_kcontrol *kcontrol,
5743                                          struct snd_ctl_elem_value *ucontrol)
5744 {
5745         alc_update_headset_mode(codec);
5746 }
5747
5748 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5749                                        struct hda_jack_callback *jack)
5750 {
5751         snd_hda_gen_hp_automute(codec, jack);
5752         alc_update_headset_mode(codec);
5753 }
5754
5755 static void alc_probe_headset_mode(struct hda_codec *codec)
5756 {
5757         int i;
5758         struct alc_spec *spec = codec->spec;
5759         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5760
5761         /* Find mic pins */
5762         for (i = 0; i < cfg->num_inputs; i++) {
5763                 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5764                         spec->headset_mic_pin = cfg->inputs[i].pin;
5765                 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5766                         spec->headphone_mic_pin = cfg->inputs[i].pin;
5767         }
5768
5769         WARN_ON(spec->gen.cap_sync_hook);
5770         spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5771         spec->gen.automute_hook = alc_update_headset_mode;
5772         spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5773 }
5774
5775 static void alc_fixup_headset_mode(struct hda_codec *codec,
5776                                 const struct hda_fixup *fix, int action)
5777 {
5778         struct alc_spec *spec = codec->spec;
5779
5780         switch (action) {
5781         case HDA_FIXUP_ACT_PRE_PROBE:
5782                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5783                 break;
5784         case HDA_FIXUP_ACT_PROBE:
5785                 alc_probe_headset_mode(codec);
5786                 break;
5787         case HDA_FIXUP_ACT_INIT:
5788                 if (is_s3_resume(codec) || is_s4_resume(codec)) {
5789                         spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5790                         spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5791                 }
5792                 alc_update_headset_mode(codec);
5793                 break;
5794         }
5795 }
5796
5797 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5798                                 const struct hda_fixup *fix, int action)
5799 {
5800         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5801                 struct alc_spec *spec = codec->spec;
5802                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5803         }
5804         else
5805                 alc_fixup_headset_mode(codec, fix, action);
5806 }
5807
5808 static void alc255_set_default_jack_type(struct hda_codec *codec)
5809 {
5810         /* Set to iphone type */
5811         static const struct coef_fw alc255fw[] = {
5812                 WRITE_COEF(0x1b, 0x880b),
5813                 WRITE_COEF(0x45, 0xd089),
5814                 WRITE_COEF(0x1b, 0x080b),
5815                 WRITE_COEF(0x46, 0x0004),
5816                 WRITE_COEF(0x1b, 0x0c0b),
5817                 {}
5818         };
5819         static const struct coef_fw alc256fw[] = {
5820                 WRITE_COEF(0x1b, 0x884b),
5821                 WRITE_COEF(0x45, 0xd089),
5822                 WRITE_COEF(0x1b, 0x084b),
5823                 WRITE_COEF(0x46, 0x0004),
5824                 WRITE_COEF(0x1b, 0x0c4b),
5825                 {}
5826         };
5827         switch (codec->core.vendor_id) {
5828         case 0x10ec0255:
5829                 alc_process_coef_fw(codec, alc255fw);
5830                 break;
5831         case 0x10ec0230:
5832         case 0x10ec0236:
5833         case 0x10ec0256:
5834         case 0x19e58326:
5835                 alc_process_coef_fw(codec, alc256fw);
5836                 break;
5837         }
5838         msleep(30);
5839 }
5840
5841 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5842                                 const struct hda_fixup *fix, int action)
5843 {
5844         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5845                 alc255_set_default_jack_type(codec);
5846         }
5847         alc_fixup_headset_mode(codec, fix, action);
5848 }
5849
5850 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5851                                 const struct hda_fixup *fix, int action)
5852 {
5853         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5854                 struct alc_spec *spec = codec->spec;
5855                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5856                 alc255_set_default_jack_type(codec);
5857         } 
5858         else
5859                 alc_fixup_headset_mode(codec, fix, action);
5860 }
5861
5862 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5863                                        struct hda_jack_callback *jack)
5864 {
5865         struct alc_spec *spec = codec->spec;
5866
5867         alc_update_headset_jack_cb(codec, jack);
5868         /* Headset Mic enable or disable, only for Dell Dino */
5869         alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5870 }
5871
5872 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5873                                 const struct hda_fixup *fix, int action)
5874 {
5875         alc_fixup_headset_mode(codec, fix, action);
5876         if (action == HDA_FIXUP_ACT_PROBE) {
5877                 struct alc_spec *spec = codec->spec;
5878                 /* toggled via hp_automute_hook */
5879                 spec->gpio_mask |= 0x40;
5880                 spec->gpio_dir |= 0x40;
5881                 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5882         }
5883 }
5884
5885 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5886                                         const struct hda_fixup *fix, int action)
5887 {
5888         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5889                 struct alc_spec *spec = codec->spec;
5890                 spec->gen.auto_mute_via_amp = 1;
5891         }
5892 }
5893
5894 static void alc_fixup_no_shutup(struct hda_codec *codec,
5895                                 const struct hda_fixup *fix, int action)
5896 {
5897         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5898                 struct alc_spec *spec = codec->spec;
5899                 spec->no_shutup_pins = 1;
5900         }
5901 }
5902
5903 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5904                                     const struct hda_fixup *fix, int action)
5905 {
5906         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5907                 struct alc_spec *spec = codec->spec;
5908                 /* Disable AA-loopback as it causes white noise */
5909                 spec->gen.mixer_nid = 0;
5910         }
5911 }
5912
5913 /* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
5914 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5915                                   const struct hda_fixup *fix, int action)
5916 {
5917         static const struct hda_pintbl pincfgs[] = {
5918                 { 0x16, 0x21211010 }, /* dock headphone */
5919                 { 0x19, 0x21a11010 }, /* dock mic */
5920                 { }
5921         };
5922         struct alc_spec *spec = codec->spec;
5923
5924         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5925                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5926                 codec->power_save_node = 0; /* avoid click noises */
5927                 snd_hda_apply_pincfgs(codec, pincfgs);
5928         }
5929 }
5930
5931 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5932                                   const struct hda_fixup *fix, int action)
5933 {
5934         static const struct hda_pintbl pincfgs[] = {
5935                 { 0x17, 0x21211010 }, /* dock headphone */
5936                 { 0x19, 0x21a11010 }, /* dock mic */
5937                 { }
5938         };
5939         struct alc_spec *spec = codec->spec;
5940
5941         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5942                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5943                 snd_hda_apply_pincfgs(codec, pincfgs);
5944         } else if (action == HDA_FIXUP_ACT_INIT) {
5945                 /* Enable DOCK device */
5946                 snd_hda_codec_write(codec, 0x17, 0,
5947                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5948                 /* Enable DOCK device */
5949                 snd_hda_codec_write(codec, 0x19, 0,
5950                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5951         }
5952 }
5953
5954 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
5955                                   const struct hda_fixup *fix, int action)
5956 {
5957         /* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5958          * the speaker output becomes too low by some reason on Thinkpads with
5959          * ALC298 codec
5960          */
5961         static const hda_nid_t preferred_pairs[] = {
5962                 0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5963                 0
5964         };
5965         struct alc_spec *spec = codec->spec;
5966
5967         if (action == HDA_FIXUP_ACT_PRE_PROBE)
5968                 spec->gen.preferred_dacs = preferred_pairs;
5969 }
5970
5971 static void alc295_fixup_asus_dacs(struct hda_codec *codec,
5972                                    const struct hda_fixup *fix, int action)
5973 {
5974         static const hda_nid_t preferred_pairs[] = {
5975                 0x17, 0x02, 0x21, 0x03, 0
5976         };
5977         struct alc_spec *spec = codec->spec;
5978
5979         if (action == HDA_FIXUP_ACT_PRE_PROBE)
5980                 spec->gen.preferred_dacs = preferred_pairs;
5981 }
5982
5983 static void alc_shutup_dell_xps13(struct hda_codec *codec)
5984 {
5985         struct alc_spec *spec = codec->spec;
5986         int hp_pin = alc_get_hp_pin(spec);
5987
5988         /* Prevent pop noises when headphones are plugged in */
5989         snd_hda_codec_write(codec, hp_pin, 0,
5990                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5991         msleep(20);
5992 }
5993
5994 static void alc_fixup_dell_xps13(struct hda_codec *codec,
5995                                 const struct hda_fixup *fix, int action)
5996 {
5997         struct alc_spec *spec = codec->spec;
5998         struct hda_input_mux *imux = &spec->gen.input_mux;
5999         int i;
6000
6001         switch (action) {
6002         case HDA_FIXUP_ACT_PRE_PROBE:
6003                 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
6004                  * it causes a click noise at start up
6005                  */
6006                 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6007                 spec->shutup = alc_shutup_dell_xps13;
6008                 break;
6009         case HDA_FIXUP_ACT_PROBE:
6010                 /* Make the internal mic the default input source. */
6011                 for (i = 0; i < imux->num_items; i++) {
6012                         if (spec->gen.imux_pins[i] == 0x12) {
6013                                 spec->gen.cur_mux[0] = i;
6014                                 break;
6015                         }
6016                 }
6017                 break;
6018         }
6019 }
6020
6021 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
6022                                 const struct hda_fixup *fix, int action)
6023 {
6024         struct alc_spec *spec = codec->spec;
6025
6026         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6027                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
6028                 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
6029
6030                 /* Disable boost for mic-in permanently. (This code is only called
6031                    from quirks that guarantee that the headphone is at NID 0x1b.) */
6032                 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
6033                 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
6034         } else
6035                 alc_fixup_headset_mode(codec, fix, action);
6036 }
6037
6038 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
6039                                 const struct hda_fixup *fix, int action)
6040 {
6041         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6042                 alc_write_coef_idx(codec, 0xc4, 0x8000);
6043                 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
6044                 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
6045         }
6046         alc_fixup_headset_mode(codec, fix, action);
6047 }
6048
6049 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
6050 static int find_ext_mic_pin(struct hda_codec *codec)
6051 {
6052         struct alc_spec *spec = codec->spec;
6053         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6054         hda_nid_t nid;
6055         unsigned int defcfg;
6056         int i;
6057
6058         for (i = 0; i < cfg->num_inputs; i++) {
6059                 if (cfg->inputs[i].type != AUTO_PIN_MIC)
6060                         continue;
6061                 nid = cfg->inputs[i].pin;
6062                 defcfg = snd_hda_codec_get_pincfg(codec, nid);
6063                 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
6064                         continue;
6065                 return nid;
6066         }
6067
6068         return 0;
6069 }
6070
6071 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
6072                                     const struct hda_fixup *fix,
6073                                     int action)
6074 {
6075         struct alc_spec *spec = codec->spec;
6076
6077         if (action == HDA_FIXUP_ACT_PROBE) {
6078                 int mic_pin = find_ext_mic_pin(codec);
6079                 int hp_pin = alc_get_hp_pin(spec);
6080
6081                 if (snd_BUG_ON(!mic_pin || !hp_pin))
6082                         return;
6083                 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
6084         }
6085 }
6086
6087 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
6088                                              const struct hda_fixup *fix,
6089                                              int action)
6090 {
6091         struct alc_spec *spec = codec->spec;
6092         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6093         int i;
6094
6095         /* The mic boosts on level 2 and 3 are too noisy
6096            on the internal mic input.
6097            Therefore limit the boost to 0 or 1. */
6098
6099         if (action != HDA_FIXUP_ACT_PROBE)
6100                 return;
6101
6102         for (i = 0; i < cfg->num_inputs; i++) {
6103                 hda_nid_t nid = cfg->inputs[i].pin;
6104                 unsigned int defcfg;
6105                 if (cfg->inputs[i].type != AUTO_PIN_MIC)
6106                         continue;
6107                 defcfg = snd_hda_codec_get_pincfg(codec, nid);
6108                 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
6109                         continue;
6110
6111                 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
6112                                           (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
6113                                           (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6114                                           (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
6115                                           (0 << AC_AMPCAP_MUTE_SHIFT));
6116         }
6117 }
6118
6119 static void alc283_hp_automute_hook(struct hda_codec *codec,
6120                                     struct hda_jack_callback *jack)
6121 {
6122         struct alc_spec *spec = codec->spec;
6123         int vref;
6124
6125         msleep(200);
6126         snd_hda_gen_hp_automute(codec, jack);
6127
6128         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
6129
6130         msleep(600);
6131         snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6132                             vref);
6133 }
6134
6135 static void alc283_fixup_chromebook(struct hda_codec *codec,
6136                                     const struct hda_fixup *fix, int action)
6137 {
6138         struct alc_spec *spec = codec->spec;
6139
6140         switch (action) {
6141         case HDA_FIXUP_ACT_PRE_PROBE:
6142                 snd_hda_override_wcaps(codec, 0x03, 0);
6143                 /* Disable AA-loopback as it causes white noise */
6144                 spec->gen.mixer_nid = 0;
6145                 break;
6146         case HDA_FIXUP_ACT_INIT:
6147                 /* MIC2-VREF control */
6148                 /* Set to manual mode */
6149                 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6150                 /* Enable Line1 input control by verb */
6151                 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
6152                 break;
6153         }
6154 }
6155
6156 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
6157                                     const struct hda_fixup *fix, int action)
6158 {
6159         struct alc_spec *spec = codec->spec;
6160
6161         switch (action) {
6162         case HDA_FIXUP_ACT_PRE_PROBE:
6163                 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
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                 break;
6170         }
6171 }
6172
6173 /* mute tablet speaker pin (0x14) via dock plugging in addition */
6174 static void asus_tx300_automute(struct hda_codec *codec)
6175 {
6176         struct alc_spec *spec = codec->spec;
6177         snd_hda_gen_update_outputs(codec);
6178         if (snd_hda_jack_detect(codec, 0x1b))
6179                 spec->gen.mute_bits |= (1ULL << 0x14);
6180 }
6181
6182 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
6183                                     const struct hda_fixup *fix, int action)
6184 {
6185         struct alc_spec *spec = codec->spec;
6186         static const struct hda_pintbl dock_pins[] = {
6187                 { 0x1b, 0x21114000 }, /* dock speaker pin */
6188                 {}
6189         };
6190
6191         switch (action) {
6192         case HDA_FIXUP_ACT_PRE_PROBE:
6193                 spec->init_amp = ALC_INIT_DEFAULT;
6194                 /* TX300 needs to set up GPIO2 for the speaker amp */
6195                 alc_setup_gpio(codec, 0x04);
6196                 snd_hda_apply_pincfgs(codec, dock_pins);
6197                 spec->gen.auto_mute_via_amp = 1;
6198                 spec->gen.automute_hook = asus_tx300_automute;
6199                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
6200                                                     snd_hda_gen_hp_automute);
6201                 break;
6202         case HDA_FIXUP_ACT_PROBE:
6203                 spec->init_amp = ALC_INIT_DEFAULT;
6204                 break;
6205         case HDA_FIXUP_ACT_BUILD:
6206                 /* this is a bit tricky; give more sane names for the main
6207                  * (tablet) speaker and the dock speaker, respectively
6208                  */
6209                 rename_ctl(codec, "Speaker Playback Switch",
6210                            "Dock Speaker Playback Switch");
6211                 rename_ctl(codec, "Bass Speaker Playback Switch",
6212                            "Speaker Playback Switch");
6213                 break;
6214         }
6215 }
6216
6217 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
6218                                        const struct hda_fixup *fix, int action)
6219 {
6220         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6221                 /* DAC node 0x03 is giving mono output. We therefore want to
6222                    make sure 0x14 (front speaker) and 0x15 (headphones) use the
6223                    stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
6224                 static const hda_nid_t conn1[] = { 0x0c };
6225                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
6226                 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
6227         }
6228 }
6229
6230 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
6231                                         const struct hda_fixup *fix, int action)
6232 {
6233         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6234                 /* The speaker is routed to the Node 0x06 by a mistake, as a result
6235                    we can't adjust the speaker's volume since this node does not has
6236                    Amp-out capability. we change the speaker's route to:
6237                    Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
6238                    Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
6239                    speaker's volume now. */
6240
6241                 static const hda_nid_t conn1[] = { 0x0c };
6242                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
6243         }
6244 }
6245
6246 /* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
6247 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
6248                                       const struct hda_fixup *fix, int action)
6249 {
6250         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6251                 static const hda_nid_t conn[] = { 0x02, 0x03 };
6252                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6253         }
6254 }
6255
6256 /* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
6257 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6258                                           const struct hda_fixup *fix, int action)
6259 {
6260         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6261                 static const hda_nid_t conn[] = { 0x02 };
6262                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6263         }
6264 }
6265
6266 /* Hook to update amp GPIO4 for automute */
6267 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6268                                           struct hda_jack_callback *jack)
6269 {
6270         struct alc_spec *spec = codec->spec;
6271
6272         snd_hda_gen_hp_automute(codec, jack);
6273         /* mute_led_polarity is set to 0, so we pass inverted value here */
6274         alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6275                             !spec->gen.hp_jack_present);
6276 }
6277
6278 /* Manage GPIOs for HP EliteBook Folio 9480m.
6279  *
6280  * GPIO4 is the headphone amplifier power control
6281  * GPIO3 is the audio output mute indicator LED
6282  */
6283
6284 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6285                                   const struct hda_fixup *fix,
6286                                   int action)
6287 {
6288         struct alc_spec *spec = codec->spec;
6289
6290         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6291         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6292                 /* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
6293                 spec->gpio_mask |= 0x10;
6294                 spec->gpio_dir |= 0x10;
6295                 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
6296         }
6297 }
6298
6299 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6300                                    const struct hda_fixup *fix,
6301                                    int action)
6302 {
6303         struct alc_spec *spec = codec->spec;
6304
6305         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6306                 spec->gpio_mask |= 0x04;
6307                 spec->gpio_dir |= 0x04;
6308                 /* set data bit low */
6309         }
6310 }
6311
6312 /* Quirk for Thinkpad X1 7th and 8th Gen
6313  * The following fixed routing needed
6314  * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
6315  * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
6316  * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
6317  */
6318 static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6319                                           const struct hda_fixup *fix, int action)
6320 {
6321         static const hda_nid_t conn[] = { 0x02, 0x03 }; /* exclude 0x06 */
6322         static const hda_nid_t preferred_pairs[] = {
6323                 0x14, 0x02, 0x17, 0x03, 0x21, 0x03, 0
6324         };
6325         struct alc_spec *spec = codec->spec;
6326
6327         switch (action) {
6328         case HDA_FIXUP_ACT_PRE_PROBE:
6329                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6330                 spec->gen.preferred_dacs = preferred_pairs;
6331                 break;
6332         case HDA_FIXUP_ACT_BUILD:
6333                 /* The generic parser creates somewhat unintuitive volume ctls
6334                  * with the fixed routing above, and the shared DAC2 may be
6335                  * confusing for PA.
6336                  * Rename those to unique names so that PA doesn't touch them
6337                  * and use only Master volume.
6338                  */
6339                 rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6340                 rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6341                 break;
6342         }
6343 }
6344
6345 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6346                                          const struct hda_fixup *fix,
6347                                          int action)
6348 {
6349         alc_fixup_dual_codecs(codec, fix, action);
6350         switch (action) {
6351         case HDA_FIXUP_ACT_PRE_PROBE:
6352                 /* override card longname to provide a unique UCM profile */
6353                 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6354                 break;
6355         case HDA_FIXUP_ACT_BUILD:
6356                 /* rename Capture controls depending on the codec */
6357                 rename_ctl(codec, "Capture Volume",
6358                            codec->addr == 0 ?
6359                            "Rear-Panel Capture Volume" :
6360                            "Front-Panel Capture Volume");
6361                 rename_ctl(codec, "Capture Switch",
6362                            codec->addr == 0 ?
6363                            "Rear-Panel Capture Switch" :
6364                            "Front-Panel Capture Switch");
6365                 break;
6366         }
6367 }
6368
6369 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6370                                       const struct hda_fixup *fix, int action)
6371 {
6372         if (action != HDA_FIXUP_ACT_PRE_PROBE)
6373                 return;
6374
6375         codec->power_save_node = 1;
6376 }
6377
6378 /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
6379 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6380                                     const struct hda_fixup *fix, int action)
6381 {
6382         struct alc_spec *spec = codec->spec;
6383         static const hda_nid_t preferred_pairs[] = {
6384                 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
6385                 0
6386         };
6387
6388         if (action != HDA_FIXUP_ACT_PRE_PROBE)
6389                 return;
6390
6391         spec->gen.preferred_dacs = preferred_pairs;
6392         spec->gen.auto_mute_via_amp = 1;
6393         codec->power_save_node = 0;
6394 }
6395
6396 /* avoid DAC 0x06 for bass speaker 0x17; it has no volume control */
6397 static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6398                                     const struct hda_fixup *fix, int action)
6399 {
6400         static const hda_nid_t preferred_pairs[] = {
6401                 0x14, 0x02, 0x17, 0x02, 0x21, 0x03, 0
6402         };
6403         struct alc_spec *spec = codec->spec;
6404
6405         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6406                 spec->gen.preferred_dacs = preferred_pairs;
6407                 spec->gen.obey_preferred_dacs = 1;
6408         }
6409 }
6410
6411 /* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
6412 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6413                               const struct hda_fixup *fix, int action)
6414 {
6415         if (action != HDA_FIXUP_ACT_PRE_PROBE)
6416                 return;
6417
6418         snd_hda_override_wcaps(codec, 0x03, 0);
6419 }
6420
6421 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6422 {
6423         switch (codec->core.vendor_id) {
6424         case 0x10ec0274:
6425         case 0x10ec0294:
6426         case 0x10ec0225:
6427         case 0x10ec0295:
6428         case 0x10ec0299:
6429                 alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6430                 alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6431                 break;
6432         case 0x10ec0230:
6433         case 0x10ec0235:
6434         case 0x10ec0236:
6435         case 0x10ec0255:
6436         case 0x10ec0256:
6437         case 0x19e58326:
6438                 alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6439                 alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6440                 break;
6441         }
6442 }
6443
6444 static void alc295_fixup_chromebook(struct hda_codec *codec,
6445                                     const struct hda_fixup *fix, int action)
6446 {
6447         struct alc_spec *spec = codec->spec;
6448
6449         switch (action) {
6450         case HDA_FIXUP_ACT_PRE_PROBE:
6451                 spec->ultra_low_power = true;
6452                 break;
6453         case HDA_FIXUP_ACT_INIT:
6454                 alc_combo_jack_hp_jd_restart(codec);
6455                 break;
6456         }
6457 }
6458
6459 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6460                                   const struct hda_fixup *fix, int action)
6461 {
6462         if (action == HDA_FIXUP_ACT_PRE_PROBE)
6463                 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6464 }
6465
6466
6467 static void alc294_gx502_toggle_output(struct hda_codec *codec,
6468                                         struct hda_jack_callback *cb)
6469 {
6470         /* The Windows driver sets the codec up in a very different way where
6471          * it appears to leave 0x10 = 0x8a20 set. For Linux we need to toggle it
6472          */
6473         if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6474                 alc_write_coef_idx(codec, 0x10, 0x8a20);
6475         else
6476                 alc_write_coef_idx(codec, 0x10, 0x0a20);
6477 }
6478
6479 static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6480                                         const struct hda_fixup *fix, int action)
6481 {
6482         /* Pin 0x21: headphones/headset mic */
6483         if (!is_jack_detectable(codec, 0x21))
6484                 return;
6485
6486         switch (action) {
6487         case HDA_FIXUP_ACT_PRE_PROBE:
6488                 snd_hda_jack_detect_enable_callback(codec, 0x21,
6489                                 alc294_gx502_toggle_output);
6490                 break;
6491         case HDA_FIXUP_ACT_INIT:
6492                 /* Make sure to start in a correct state, i.e. if
6493                  * headphones have been plugged in before powering up the system
6494                  */
6495                 alc294_gx502_toggle_output(codec, NULL);
6496                 break;
6497         }
6498 }
6499
6500 static void alc294_gu502_toggle_output(struct hda_codec *codec,
6501                                        struct hda_jack_callback *cb)
6502 {
6503         /* Windows sets 0x10 to 0x8420 for Node 0x20 which is
6504          * responsible from changes between speakers and headphones
6505          */
6506         if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6507                 alc_write_coef_idx(codec, 0x10, 0x8420);
6508         else
6509                 alc_write_coef_idx(codec, 0x10, 0x0a20);
6510 }
6511
6512 static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6513                                   const struct hda_fixup *fix, int action)
6514 {
6515         if (!is_jack_detectable(codec, 0x21))
6516                 return;
6517
6518         switch (action) {
6519         case HDA_FIXUP_ACT_PRE_PROBE:
6520                 snd_hda_jack_detect_enable_callback(codec, 0x21,
6521                                 alc294_gu502_toggle_output);
6522                 break;
6523         case HDA_FIXUP_ACT_INIT:
6524                 alc294_gu502_toggle_output(codec, NULL);
6525                 break;
6526         }
6527 }
6528
6529 static void  alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6530                               const struct hda_fixup *fix, int action)
6531 {
6532         if (action != HDA_FIXUP_ACT_INIT)
6533                 return;
6534
6535         msleep(100);
6536         alc_write_coef_idx(codec, 0x65, 0x0);
6537 }
6538
6539 static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6540                                     const struct hda_fixup *fix, int action)
6541 {
6542         switch (action) {
6543         case HDA_FIXUP_ACT_INIT:
6544                 alc_combo_jack_hp_jd_restart(codec);
6545                 break;
6546         }
6547 }
6548
6549 static void alc_fixup_no_int_mic(struct hda_codec *codec,
6550                                     const struct hda_fixup *fix, int action)
6551 {
6552         struct alc_spec *spec = codec->spec;
6553
6554         switch (action) {
6555         case HDA_FIXUP_ACT_PRE_PROBE:
6556                 /* Mic RING SLEEVE swap for combo jack */
6557                 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
6558                 spec->no_internal_mic_pin = true;
6559                 break;
6560         case HDA_FIXUP_ACT_INIT:
6561                 alc_combo_jack_hp_jd_restart(codec);
6562                 break;
6563         }
6564 }
6565
6566 /* GPIO1 = amplifier on/off
6567  * GPIO3 = mic mute LED
6568  */
6569 static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
6570                                           const struct hda_fixup *fix, int action)
6571 {
6572         static const hda_nid_t conn[] = { 0x02 };
6573
6574         struct alc_spec *spec = codec->spec;
6575         static const struct hda_pintbl pincfgs[] = {
6576                 { 0x14, 0x90170110 },  /* front/high speakers */
6577                 { 0x17, 0x90170130 },  /* back/bass speakers */
6578                 { }
6579         };
6580
6581         //enable micmute led
6582         alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
6583
6584         switch (action) {
6585         case HDA_FIXUP_ACT_PRE_PROBE:
6586                 spec->micmute_led_polarity = 1;
6587                 /* needed for amp of back speakers */
6588                 spec->gpio_mask |= 0x01;
6589                 spec->gpio_dir |= 0x01;
6590                 snd_hda_apply_pincfgs(codec, pincfgs);
6591                 /* share DAC to have unified volume control */
6592                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
6593                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6594                 break;
6595         case HDA_FIXUP_ACT_INIT:
6596                 /* need to toggle GPIO to enable the amp of back speakers */
6597                 alc_update_gpio_data(codec, 0x01, true);
6598                 msleep(100);
6599                 alc_update_gpio_data(codec, 0x01, false);
6600                 break;
6601         }
6602 }
6603
6604 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6605                                           const struct hda_fixup *fix, int action)
6606 {
6607         static const hda_nid_t conn[] = { 0x02 };
6608         static const struct hda_pintbl pincfgs[] = {
6609                 { 0x14, 0x90170110 },  /* rear speaker */
6610                 { }
6611         };
6612
6613         switch (action) {
6614         case HDA_FIXUP_ACT_PRE_PROBE:
6615                 snd_hda_apply_pincfgs(codec, pincfgs);
6616                 /* force front speaker to DAC1 */
6617                 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6618                 break;
6619         }
6620 }
6621
6622 /* for hda_fixup_thinkpad_acpi() */
6623 #include "thinkpad_helper.c"
6624
6625 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6626                                     const struct hda_fixup *fix, int action)
6627 {
6628         alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6629         hda_fixup_thinkpad_acpi(codec, fix, action);
6630 }
6631
6632 /* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
6633 static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6634                                                   const struct hda_fixup *fix,
6635                                                   int action)
6636 {
6637         struct alc_spec *spec = codec->spec;
6638
6639         switch (action) {
6640         case HDA_FIXUP_ACT_PRE_PROBE:
6641                 spec->gen.suppress_auto_mute = 1;
6642                 break;
6643         }
6644 }
6645
6646 /* for alc295_fixup_hp_top_speakers */
6647 #include "hp_x360_helper.c"
6648
6649 /* for alc285_fixup_ideapad_s740_coef() */
6650 #include "ideapad_s740_helper.c"
6651
6652 static const struct coef_fw alc256_fixup_set_coef_defaults_coefs[] = {
6653         WRITE_COEF(0x10, 0x0020), WRITE_COEF(0x24, 0x0000),
6654         WRITE_COEF(0x26, 0x0000), WRITE_COEF(0x29, 0x3000),
6655         WRITE_COEF(0x37, 0xfe05), WRITE_COEF(0x45, 0x5089),
6656         {}
6657 };
6658
6659 static void alc256_fixup_set_coef_defaults(struct hda_codec *codec,
6660                                            const struct hda_fixup *fix,
6661                                            int action)
6662 {
6663         /*
6664          * A certain other OS sets these coeffs to different values. On at least
6665          * one TongFang barebone these settings might survive even a cold
6666          * reboot. So to restore a clean slate the values are explicitly reset
6667          * to default here. Without this, the external microphone is always in a
6668          * plugged-in state, while the internal microphone is always in an
6669          * unplugged state, breaking the ability to use the internal microphone.
6670          */
6671         alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs);
6672 }
6673
6674 static const struct coef_fw alc233_fixup_no_audio_jack_coefs[] = {
6675         WRITE_COEF(0x1a, 0x9003), WRITE_COEF(0x1b, 0x0e2b), WRITE_COEF(0x37, 0xfe06),
6676         WRITE_COEF(0x38, 0x4981), WRITE_COEF(0x45, 0xd489), WRITE_COEF(0x46, 0x0074),
6677         WRITE_COEF(0x49, 0x0149),
6678         {}
6679 };
6680
6681 static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
6682                                        const struct hda_fixup *fix,
6683                                        int action)
6684 {
6685         /*
6686          * The audio jack input and output is not detected on the ASRock NUC Box
6687          * 1100 series when cold booting without this fix. Warm rebooting from a
6688          * certain other OS makes the audio functional, as COEF settings are
6689          * preserved in this case. This fix sets these altered COEF values as
6690          * the default.
6691          */
6692         alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
6693 }
6694
6695 static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
6696                                                     const struct hda_fixup *fix,
6697                                                     int action)
6698 {
6699         /*
6700          * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
6701          * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
6702          * needs an additional quirk for sound working after suspend and resume.
6703          */
6704         if (codec->core.vendor_id == 0x10ec0256) {
6705                 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
6706                 snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
6707         } else {
6708                 snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
6709         }
6710 }
6711
6712 enum {
6713         ALC269_FIXUP_GPIO2,
6714         ALC269_FIXUP_SONY_VAIO,
6715         ALC275_FIXUP_SONY_VAIO_GPIO2,
6716         ALC269_FIXUP_DELL_M101Z,
6717         ALC269_FIXUP_SKU_IGNORE,
6718         ALC269_FIXUP_ASUS_G73JW,
6719         ALC269_FIXUP_LENOVO_EAPD,
6720         ALC275_FIXUP_SONY_HWEQ,
6721         ALC275_FIXUP_SONY_DISABLE_AAMIX,
6722         ALC271_FIXUP_DMIC,
6723         ALC269_FIXUP_PCM_44K,
6724         ALC269_FIXUP_STEREO_DMIC,
6725         ALC269_FIXUP_HEADSET_MIC,
6726         ALC269_FIXUP_QUANTA_MUTE,
6727         ALC269_FIXUP_LIFEBOOK,
6728         ALC269_FIXUP_LIFEBOOK_EXTMIC,
6729         ALC269_FIXUP_LIFEBOOK_HP_PIN,
6730         ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
6731         ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
6732         ALC269_FIXUP_AMIC,
6733         ALC269_FIXUP_DMIC,
6734         ALC269VB_FIXUP_AMIC,
6735         ALC269VB_FIXUP_DMIC,
6736         ALC269_FIXUP_HP_MUTE_LED,
6737         ALC269_FIXUP_HP_MUTE_LED_MIC1,
6738         ALC269_FIXUP_HP_MUTE_LED_MIC2,
6739         ALC269_FIXUP_HP_MUTE_LED_MIC3,
6740         ALC269_FIXUP_HP_GPIO_LED,
6741         ALC269_FIXUP_HP_GPIO_MIC1_LED,
6742         ALC269_FIXUP_HP_LINE1_MIC1_LED,
6743         ALC269_FIXUP_INV_DMIC,
6744         ALC269_FIXUP_LENOVO_DOCK,
6745         ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
6746         ALC269_FIXUP_NO_SHUTUP,
6747         ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
6748         ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
6749         ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6750         ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
6751         ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6752         ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6753         ALC269_FIXUP_HEADSET_MODE,
6754         ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
6755         ALC269_FIXUP_ASPIRE_HEADSET_MIC,
6756         ALC269_FIXUP_ASUS_X101_FUNC,
6757         ALC269_FIXUP_ASUS_X101_VERB,
6758         ALC269_FIXUP_ASUS_X101,
6759         ALC271_FIXUP_AMIC_MIC2,
6760         ALC271_FIXUP_HP_GATE_MIC_JACK,
6761         ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
6762         ALC269_FIXUP_ACER_AC700,
6763         ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
6764         ALC269VB_FIXUP_ASUS_ZENBOOK,
6765         ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
6766         ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE,
6767         ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
6768         ALC269VB_FIXUP_ORDISSIMO_EVE2,
6769         ALC283_FIXUP_CHROME_BOOK,
6770         ALC283_FIXUP_SENSE_COMBO_JACK,
6771         ALC282_FIXUP_ASUS_TX300,
6772         ALC283_FIXUP_INT_MIC,
6773         ALC290_FIXUP_MONO_SPEAKERS,
6774         ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6775         ALC290_FIXUP_SUBWOOFER,
6776         ALC290_FIXUP_SUBWOOFER_HSJACK,
6777         ALC269_FIXUP_THINKPAD_ACPI,
6778         ALC269_FIXUP_DMIC_THINKPAD_ACPI,
6779         ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6780         ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6781         ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6782         ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
6783         ALC255_FIXUP_HEADSET_MODE,
6784         ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
6785         ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
6786         ALC292_FIXUP_TPT440_DOCK,
6787         ALC292_FIXUP_TPT440,
6788         ALC283_FIXUP_HEADSET_MIC,
6789         ALC255_FIXUP_MIC_MUTE_LED,
6790         ALC282_FIXUP_ASPIRE_V5_PINS,
6791         ALC269VB_FIXUP_ASPIRE_E1_COEF,
6792         ALC280_FIXUP_HP_GPIO4,
6793         ALC286_FIXUP_HP_GPIO_LED,
6794         ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
6795         ALC280_FIXUP_HP_DOCK_PINS,
6796         ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
6797         ALC280_FIXUP_HP_9480M,
6798         ALC245_FIXUP_HP_X360_AMP,
6799         ALC285_FIXUP_HP_SPECTRE_X360_EB1,
6800         ALC288_FIXUP_DELL_HEADSET_MODE,
6801         ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
6802         ALC288_FIXUP_DELL_XPS_13,
6803         ALC288_FIXUP_DISABLE_AAMIX,
6804         ALC292_FIXUP_DELL_E7X_AAMIX,
6805         ALC292_FIXUP_DELL_E7X,
6806         ALC292_FIXUP_DISABLE_AAMIX,
6807         ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
6808         ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
6809         ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6810         ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6811         ALC275_FIXUP_DELL_XPS,
6812         ALC293_FIXUP_LENOVO_SPK_NOISE,
6813         ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
6814         ALC255_FIXUP_DELL_SPK_NOISE,
6815         ALC225_FIXUP_DISABLE_MIC_VREF,
6816         ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6817         ALC295_FIXUP_DISABLE_DAC3,
6818         ALC285_FIXUP_SPEAKER2_TO_DAC1,
6819         ALC280_FIXUP_HP_HEADSET_MIC,
6820         ALC221_FIXUP_HP_FRONT_MIC,
6821         ALC292_FIXUP_TPT460,
6822         ALC298_FIXUP_SPK_VOLUME,
6823         ALC298_FIXUP_LENOVO_SPK_VOLUME,
6824         ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
6825         ALC269_FIXUP_ATIV_BOOK_8,
6826         ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE,
6827         ALC221_FIXUP_HP_MIC_NO_PRESENCE,
6828         ALC256_FIXUP_ASUS_HEADSET_MODE,
6829         ALC256_FIXUP_ASUS_MIC,
6830         ALC256_FIXUP_ASUS_AIO_GPIO2,
6831         ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
6832         ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
6833         ALC233_FIXUP_LENOVO_MULTI_CODECS,
6834         ALC233_FIXUP_ACER_HEADSET_MIC,
6835         ALC294_FIXUP_LENOVO_MIC_LOCATION,
6836         ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
6837         ALC225_FIXUP_S3_POP_NOISE,
6838         ALC700_FIXUP_INTEL_REFERENCE,
6839         ALC274_FIXUP_DELL_BIND_DACS,
6840         ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6841         ALC298_FIXUP_TPT470_DOCK_FIX,
6842         ALC298_FIXUP_TPT470_DOCK,
6843         ALC255_FIXUP_DUMMY_LINEOUT_VERB,
6844         ALC255_FIXUP_DELL_HEADSET_MIC,
6845         ALC256_FIXUP_HUAWEI_MACH_WX9_PINS,
6846         ALC298_FIXUP_HUAWEI_MBX_STEREO,
6847         ALC295_FIXUP_HP_X360,
6848         ALC221_FIXUP_HP_HEADSET_MIC,
6849         ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
6850         ALC295_FIXUP_HP_AUTO_MUTE,
6851         ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
6852         ALC294_FIXUP_ASUS_MIC,
6853         ALC294_FIXUP_ASUS_HEADSET_MIC,
6854         ALC294_FIXUP_ASUS_SPK,
6855         ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
6856         ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
6857         ALC255_FIXUP_ACER_HEADSET_MIC,
6858         ALC295_FIXUP_CHROME_BOOK,
6859         ALC225_FIXUP_HEADSET_JACK,
6860         ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
6861         ALC225_FIXUP_WYSE_AUTO_MUTE,
6862         ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
6863         ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
6864         ALC256_FIXUP_ASUS_HEADSET_MIC,
6865         ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
6866         ALC299_FIXUP_PREDATOR_SPK,
6867         ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
6868         ALC289_FIXUP_DELL_SPK2,
6869         ALC289_FIXUP_DUAL_SPK,
6870         ALC294_FIXUP_SPK2_TO_DAC1,
6871         ALC294_FIXUP_ASUS_DUAL_SPK,
6872         ALC285_FIXUP_THINKPAD_X1_GEN7,
6873         ALC285_FIXUP_THINKPAD_HEADSET_JACK,
6874         ALC294_FIXUP_ASUS_HPE,
6875         ALC294_FIXUP_ASUS_COEF_1B,
6876         ALC294_FIXUP_ASUS_GX502_HP,
6877         ALC294_FIXUP_ASUS_GX502_PINS,
6878         ALC294_FIXUP_ASUS_GX502_VERBS,
6879         ALC294_FIXUP_ASUS_GU502_HP,
6880         ALC294_FIXUP_ASUS_GU502_PINS,
6881         ALC294_FIXUP_ASUS_GU502_VERBS,
6882         ALC294_FIXUP_ASUS_G513_PINS,
6883         ALC285_FIXUP_ASUS_G533Z_PINS,
6884         ALC285_FIXUP_HP_GPIO_LED,
6885         ALC285_FIXUP_HP_MUTE_LED,
6886         ALC236_FIXUP_HP_GPIO_LED,
6887         ALC236_FIXUP_HP_MUTE_LED,
6888         ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
6889         ALC298_FIXUP_SAMSUNG_AMP,
6890         ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6891         ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6892         ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
6893         ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
6894         ALC269VC_FIXUP_ACER_HEADSET_MIC,
6895         ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE,
6896         ALC289_FIXUP_ASUS_GA401,
6897         ALC289_FIXUP_ASUS_GA502,
6898         ALC256_FIXUP_ACER_MIC_NO_PRESENCE,
6899         ALC285_FIXUP_HP_GPIO_AMP_INIT,
6900         ALC269_FIXUP_CZC_B20,
6901         ALC269_FIXUP_CZC_TMI,
6902         ALC269_FIXUP_CZC_L101,
6903         ALC269_FIXUP_LEMOTE_A1802,
6904         ALC269_FIXUP_LEMOTE_A190X,
6905         ALC256_FIXUP_INTEL_NUC8_RUGGED,
6906         ALC233_FIXUP_INTEL_NUC8_DMIC,
6907         ALC233_FIXUP_INTEL_NUC8_BOOST,
6908         ALC256_FIXUP_INTEL_NUC10,
6909         ALC255_FIXUP_XIAOMI_HEADSET_MIC,
6910         ALC274_FIXUP_HP_MIC,
6911         ALC274_FIXUP_HP_HEADSET_MIC,
6912         ALC274_FIXUP_HP_ENVY_GPIO,
6913         ALC256_FIXUP_ASUS_HPE,
6914         ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
6915         ALC287_FIXUP_HP_GPIO_LED,
6916         ALC256_FIXUP_HP_HEADSET_MIC,
6917         ALC245_FIXUP_HP_GPIO_LED,
6918         ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
6919         ALC282_FIXUP_ACER_DISABLE_LINEOUT,
6920         ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST,
6921         ALC256_FIXUP_ACER_HEADSET_MIC,
6922         ALC285_FIXUP_IDEAPAD_S740_COEF,
6923         ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST,
6924         ALC295_FIXUP_ASUS_DACS,
6925         ALC295_FIXUP_HP_OMEN,
6926         ALC285_FIXUP_HP_SPECTRE_X360,
6927         ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP,
6928         ALC623_FIXUP_LENOVO_THINKSTATION_P340,
6929         ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
6930         ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
6931         ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
6932         ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
6933         ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
6934         ALC298_FIXUP_LENOVO_C940_DUET7,
6935         ALC287_FIXUP_13S_GEN2_SPEAKERS,
6936         ALC256_FIXUP_SET_COEF_DEFAULTS,
6937         ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
6938         ALC233_FIXUP_NO_AUDIO_JACK,
6939         ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME,
6940         ALC285_FIXUP_LEGION_Y9000X_SPEAKERS,
6941         ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
6942         ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED,
6943 };
6944
6945 /* A special fixup for Lenovo C940 and Yoga Duet 7;
6946  * both have the very same PCI SSID, and we need to apply different fixups
6947  * depending on the codec ID
6948  */
6949 static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
6950                                            const struct hda_fixup *fix,
6951                                            int action)
6952 {
6953         int id;
6954
6955         if (codec->core.vendor_id == 0x10ec0298)
6956                 id = ALC298_FIXUP_LENOVO_SPK_VOLUME; /* C940 */
6957         else
6958                 id = ALC287_FIXUP_YOGA7_14ITL_SPEAKERS; /* Duet 7 */
6959         __snd_hda_apply_fixup(codec, id, action, 0);
6960 }
6961
6962 static const struct hda_fixup alc269_fixups[] = {
6963         [ALC269_FIXUP_GPIO2] = {
6964                 .type = HDA_FIXUP_FUNC,
6965                 .v.func = alc_fixup_gpio2,
6966         },
6967         [ALC269_FIXUP_SONY_VAIO] = {
6968                 .type = HDA_FIXUP_PINCTLS,
6969                 .v.pins = (const struct hda_pintbl[]) {
6970                         {0x19, PIN_VREFGRD},
6971                         {}
6972                 }
6973         },
6974         [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
6975                 .type = HDA_FIXUP_FUNC,
6976                 .v.func = alc275_fixup_gpio4_off,
6977                 .chained = true,
6978                 .chain_id = ALC269_FIXUP_SONY_VAIO
6979         },
6980         [ALC269_FIXUP_DELL_M101Z] = {
6981                 .type = HDA_FIXUP_VERBS,
6982                 .v.verbs = (const struct hda_verb[]) {
6983                         /* Enables internal speaker */
6984                         {0x20, AC_VERB_SET_COEF_INDEX, 13},
6985                         {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
6986                         {}
6987                 }
6988         },
6989         [ALC269_FIXUP_SKU_IGNORE] = {
6990                 .type = HDA_FIXUP_FUNC,
6991                 .v.func = alc_fixup_sku_ignore,
6992         },
6993         [ALC269_FIXUP_ASUS_G73JW] = {
6994                 .type = HDA_FIXUP_PINS,
6995                 .v.pins = (const struct hda_pintbl[]) {
6996                         { 0x17, 0x99130111 }, /* subwoofer */
6997                         { }
6998                 }
6999         },
7000         [ALC269_FIXUP_LENOVO_EAPD] = {
7001                 .type = HDA_FIXUP_VERBS,
7002                 .v.verbs = (const struct hda_verb[]) {
7003                         {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
7004                         {}
7005                 }
7006         },
7007         [ALC275_FIXUP_SONY_HWEQ] = {
7008                 .type = HDA_FIXUP_FUNC,
7009                 .v.func = alc269_fixup_hweq,
7010                 .chained = true,
7011                 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
7012         },
7013         [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
7014                 .type = HDA_FIXUP_FUNC,
7015                 .v.func = alc_fixup_disable_aamix,
7016                 .chained = true,
7017                 .chain_id = ALC269_FIXUP_SONY_VAIO
7018         },
7019         [ALC271_FIXUP_DMIC] = {
7020                 .type = HDA_FIXUP_FUNC,
7021                 .v.func = alc271_fixup_dmic,
7022         },
7023         [ALC269_FIXUP_PCM_44K] = {
7024                 .type = HDA_FIXUP_FUNC,
7025                 .v.func = alc269_fixup_pcm_44k,
7026                 .chained = true,
7027                 .chain_id = ALC269_FIXUP_QUANTA_MUTE
7028         },
7029         [ALC269_FIXUP_STEREO_DMIC] = {
7030                 .type = HDA_FIXUP_FUNC,
7031                 .v.func = alc269_fixup_stereo_dmic,
7032         },
7033         [ALC269_FIXUP_HEADSET_MIC] = {
7034                 .type = HDA_FIXUP_FUNC,
7035                 .v.func = alc269_fixup_headset_mic,
7036         },
7037         [ALC269_FIXUP_QUANTA_MUTE] = {
7038                 .type = HDA_FIXUP_FUNC,
7039                 .v.func = alc269_fixup_quanta_mute,
7040         },
7041         [ALC269_FIXUP_LIFEBOOK] = {
7042                 .type = HDA_FIXUP_PINS,
7043                 .v.pins = (const struct hda_pintbl[]) {
7044                         { 0x1a, 0x2101103f }, /* dock line-out */
7045                         { 0x1b, 0x23a11040 }, /* dock mic-in */
7046                         { }
7047                 },
7048                 .chained = true,
7049                 .chain_id = ALC269_FIXUP_QUANTA_MUTE
7050         },
7051         [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
7052                 .type = HDA_FIXUP_PINS,
7053                 .v.pins = (const struct hda_pintbl[]) {
7054                         { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
7055                         { }
7056                 },
7057         },
7058         [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
7059                 .type = HDA_FIXUP_PINS,
7060                 .v.pins = (const struct hda_pintbl[]) {
7061                         { 0x21, 0x0221102f }, /* HP out */
7062                         { }
7063                 },
7064         },
7065         [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
7066                 .type = HDA_FIXUP_FUNC,
7067                 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
7068         },
7069         [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
7070                 .type = HDA_FIXUP_FUNC,
7071                 .v.func = alc269_fixup_pincfg_U7x7_headset_mic,
7072         },
7073         [ALC269_FIXUP_AMIC] = {
7074                 .type = HDA_FIXUP_PINS,
7075                 .v.pins = (const struct hda_pintbl[]) {
7076                         { 0x14, 0x99130110 }, /* speaker */
7077                         { 0x15, 0x0121401f }, /* HP out */
7078                         { 0x18, 0x01a19c20 }, /* mic */
7079                         { 0x19, 0x99a3092f }, /* int-mic */
7080                         { }
7081                 },
7082         },
7083         [ALC269_FIXUP_DMIC] = {
7084                 .type = HDA_FIXUP_PINS,
7085                 .v.pins = (const struct hda_pintbl[]) {
7086                         { 0x12, 0x99a3092f }, /* int-mic */
7087                         { 0x14, 0x99130110 }, /* speaker */
7088                         { 0x15, 0x0121401f }, /* HP out */
7089                         { 0x18, 0x01a19c20 }, /* mic */
7090                         { }
7091                 },
7092         },
7093         [ALC269VB_FIXUP_AMIC] = {
7094                 .type = HDA_FIXUP_PINS,
7095                 .v.pins = (const struct hda_pintbl[]) {
7096                         { 0x14, 0x99130110 }, /* speaker */
7097                         { 0x18, 0x01a19c20 }, /* mic */
7098                         { 0x19, 0x99a3092f }, /* int-mic */
7099                         { 0x21, 0x0121401f }, /* HP out */
7100                         { }
7101                 },
7102         },
7103         [ALC269VB_FIXUP_DMIC] = {
7104                 .type = HDA_FIXUP_PINS,
7105                 .v.pins = (const struct hda_pintbl[]) {
7106                         { 0x12, 0x99a3092f }, /* int-mic */
7107                         { 0x14, 0x99130110 }, /* speaker */
7108                         { 0x18, 0x01a19c20 }, /* mic */
7109                         { 0x21, 0x0121401f }, /* HP out */
7110                         { }
7111                 },
7112         },
7113         [ALC269_FIXUP_HP_MUTE_LED] = {
7114                 .type = HDA_FIXUP_FUNC,
7115                 .v.func = alc269_fixup_hp_mute_led,
7116         },
7117         [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
7118                 .type = HDA_FIXUP_FUNC,
7119                 .v.func = alc269_fixup_hp_mute_led_mic1,
7120         },
7121         [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
7122                 .type = HDA_FIXUP_FUNC,
7123                 .v.func = alc269_fixup_hp_mute_led_mic2,
7124         },
7125         [ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
7126                 .type = HDA_FIXUP_FUNC,
7127                 .v.func = alc269_fixup_hp_mute_led_mic3,
7128                 .chained = true,
7129                 .chain_id = ALC295_FIXUP_HP_AUTO_MUTE
7130         },
7131         [ALC269_FIXUP_HP_GPIO_LED] = {
7132                 .type = HDA_FIXUP_FUNC,
7133                 .v.func = alc269_fixup_hp_gpio_led,
7134         },
7135         [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
7136                 .type = HDA_FIXUP_FUNC,
7137                 .v.func = alc269_fixup_hp_gpio_mic1_led,
7138         },
7139         [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
7140                 .type = HDA_FIXUP_FUNC,
7141                 .v.func = alc269_fixup_hp_line1_mic1_led,
7142         },
7143         [ALC269_FIXUP_INV_DMIC] = {
7144                 .type = HDA_FIXUP_FUNC,
7145                 .v.func = alc_fixup_inv_dmic,
7146         },
7147         [ALC269_FIXUP_NO_SHUTUP] = {
7148                 .type = HDA_FIXUP_FUNC,
7149                 .v.func = alc_fixup_no_shutup,
7150         },
7151         [ALC269_FIXUP_LENOVO_DOCK] = {
7152                 .type = HDA_FIXUP_PINS,
7153                 .v.pins = (const struct hda_pintbl[]) {
7154                         { 0x19, 0x23a11040 }, /* dock mic */
7155                         { 0x1b, 0x2121103f }, /* dock headphone */
7156                         { }
7157                 },
7158                 .chained = true,
7159                 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
7160         },
7161         [ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
7162                 .type = HDA_FIXUP_FUNC,
7163                 .v.func = alc269_fixup_limit_int_mic_boost,
7164                 .chained = true,
7165                 .chain_id = ALC269_FIXUP_LENOVO_DOCK,
7166         },
7167         [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
7168                 .type = HDA_FIXUP_FUNC,
7169                 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
7170                 .chained = true,
7171                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7172         },
7173         [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7174                 .type = HDA_FIXUP_PINS,
7175                 .v.pins = (const struct hda_pintbl[]) {
7176                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7177                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7178                         { }
7179                 },
7180                 .chained = true,
7181                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7182         },
7183         [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7184                 .type = HDA_FIXUP_PINS,
7185                 .v.pins = (const struct hda_pintbl[]) {
7186                         { 0x16, 0x21014020 }, /* dock line out */
7187                         { 0x19, 0x21a19030 }, /* dock mic */
7188                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7189                         { }
7190                 },
7191                 .chained = true,
7192                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7193         },
7194         [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
7195                 .type = HDA_FIXUP_PINS,
7196                 .v.pins = (const struct hda_pintbl[]) {
7197                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7198                         { }
7199                 },
7200                 .chained = true,
7201                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7202         },
7203         [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
7204                 .type = HDA_FIXUP_PINS,
7205                 .v.pins = (const struct hda_pintbl[]) {
7206                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7207                         { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7208                         { }
7209                 },
7210                 .chained = true,
7211                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7212         },
7213         [ALC269_FIXUP_HEADSET_MODE] = {
7214                 .type = HDA_FIXUP_FUNC,
7215                 .v.func = alc_fixup_headset_mode,
7216                 .chained = true,
7217                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7218         },
7219         [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7220                 .type = HDA_FIXUP_FUNC,
7221                 .v.func = alc_fixup_headset_mode_no_hp_mic,
7222         },
7223         [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
7224                 .type = HDA_FIXUP_PINS,
7225                 .v.pins = (const struct hda_pintbl[]) {
7226                         { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
7227                         { }
7228                 },
7229                 .chained = true,
7230                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
7231         },
7232         [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
7233                 .type = HDA_FIXUP_PINS,
7234                 .v.pins = (const struct hda_pintbl[]) {
7235                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7236                         { }
7237                 },
7238                 .chained = true,
7239                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7240         },
7241         [ALC256_FIXUP_HUAWEI_MACH_WX9_PINS] = {
7242                 .type = HDA_FIXUP_PINS,
7243                 .v.pins = (const struct hda_pintbl[]) {
7244                         {0x12, 0x90a60130},
7245                         {0x13, 0x40000000},
7246                         {0x14, 0x90170110},
7247                         {0x18, 0x411111f0},
7248                         {0x19, 0x04a11040},
7249                         {0x1a, 0x411111f0},
7250                         {0x1b, 0x90170112},
7251                         {0x1d, 0x40759a05},
7252                         {0x1e, 0x411111f0},
7253                         {0x21, 0x04211020},
7254                         { }
7255                 },
7256                 .chained = true,
7257                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7258         },
7259         [ALC298_FIXUP_HUAWEI_MBX_STEREO] = {
7260                 .type = HDA_FIXUP_FUNC,
7261                 .v.func = alc298_fixup_huawei_mbx_stereo,
7262                 .chained = true,
7263                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7264         },
7265         [ALC269_FIXUP_ASUS_X101_FUNC] = {
7266                 .type = HDA_FIXUP_FUNC,
7267                 .v.func = alc269_fixup_x101_headset_mic,
7268         },
7269         [ALC269_FIXUP_ASUS_X101_VERB] = {
7270                 .type = HDA_FIXUP_VERBS,
7271                 .v.verbs = (const struct hda_verb[]) {
7272                         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
7273                         {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
7274                         {0x20, AC_VERB_SET_PROC_COEF,  0x0310},
7275                         { }
7276                 },
7277                 .chained = true,
7278                 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
7279         },
7280         [ALC269_FIXUP_ASUS_X101] = {
7281                 .type = HDA_FIXUP_PINS,
7282                 .v.pins = (const struct hda_pintbl[]) {
7283                         { 0x18, 0x04a1182c }, /* Headset mic */
7284                         { }
7285                 },
7286                 .chained = true,
7287                 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
7288         },
7289         [ALC271_FIXUP_AMIC_MIC2] = {
7290                 .type = HDA_FIXUP_PINS,
7291                 .v.pins = (const struct hda_pintbl[]) {
7292                         { 0x14, 0x99130110 }, /* speaker */
7293                         { 0x19, 0x01a19c20 }, /* mic */
7294                         { 0x1b, 0x99a7012f }, /* int-mic */
7295                         { 0x21, 0x0121401f }, /* HP out */
7296                         { }
7297                 },
7298         },
7299         [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
7300                 .type = HDA_FIXUP_FUNC,
7301                 .v.func = alc271_hp_gate_mic_jack,
7302                 .chained = true,
7303                 .chain_id = ALC271_FIXUP_AMIC_MIC2,
7304         },
7305         [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
7306                 .type = HDA_FIXUP_FUNC,
7307                 .v.func = alc269_fixup_limit_int_mic_boost,
7308                 .chained = true,
7309                 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
7310         },
7311         [ALC269_FIXUP_ACER_AC700] = {
7312                 .type = HDA_FIXUP_PINS,
7313                 .v.pins = (const struct hda_pintbl[]) {
7314                         { 0x12, 0x99a3092f }, /* int-mic */
7315                         { 0x14, 0x99130110 }, /* speaker */
7316                         { 0x18, 0x03a11c20 }, /* mic */
7317                         { 0x1e, 0x0346101e }, /* SPDIF1 */
7318                         { 0x21, 0x0321101f }, /* HP out */
7319                         { }
7320                 },
7321                 .chained = true,
7322                 .chain_id = ALC271_FIXUP_DMIC,
7323         },
7324         [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
7325                 .type = HDA_FIXUP_FUNC,
7326                 .v.func = alc269_fixup_limit_int_mic_boost,
7327                 .chained = true,
7328                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7329         },
7330         [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
7331                 .type = HDA_FIXUP_FUNC,
7332                 .v.func = alc269_fixup_limit_int_mic_boost,
7333                 .chained = true,
7334                 .chain_id = ALC269VB_FIXUP_DMIC,
7335         },
7336         [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
7337                 .type = HDA_FIXUP_VERBS,
7338                 .v.verbs = (const struct hda_verb[]) {
7339                         /* class-D output amp +5dB */
7340                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
7341                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
7342                         {}
7343                 },
7344                 .chained = true,
7345                 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
7346         },
7347         [ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7348                 .type = HDA_FIXUP_PINS,
7349                 .v.pins = (const struct hda_pintbl[]) {
7350                         { 0x18, 0x01a110f0 },  /* use as headset mic */
7351                         { }
7352                 },
7353                 .chained = true,
7354                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7355         },
7356         [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
7357                 .type = HDA_FIXUP_FUNC,
7358                 .v.func = alc269_fixup_limit_int_mic_boost,
7359                 .chained = true,
7360                 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
7361         },
7362         [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
7363                 .type = HDA_FIXUP_PINS,
7364                 .v.pins = (const struct hda_pintbl[]) {
7365                         { 0x12, 0x99a3092f }, /* int-mic */
7366                         { 0x18, 0x03a11d20 }, /* mic */
7367                         { 0x19, 0x411111f0 }, /* Unused bogus pin */
7368                         { }
7369                 },
7370         },
7371         [ALC283_FIXUP_CHROME_BOOK] = {
7372                 .type = HDA_FIXUP_FUNC,
7373                 .v.func = alc283_fixup_chromebook,
7374         },
7375         [ALC283_FIXUP_SENSE_COMBO_JACK] = {
7376                 .type = HDA_FIXUP_FUNC,
7377                 .v.func = alc283_fixup_sense_combo_jack,
7378                 .chained = true,
7379                 .chain_id = ALC283_FIXUP_CHROME_BOOK,
7380         },
7381         [ALC282_FIXUP_ASUS_TX300] = {
7382                 .type = HDA_FIXUP_FUNC,
7383                 .v.func = alc282_fixup_asus_tx300,
7384         },
7385         [ALC283_FIXUP_INT_MIC] = {
7386                 .type = HDA_FIXUP_VERBS,
7387                 .v.verbs = (const struct hda_verb[]) {
7388                         {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
7389                         {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
7390                         { }
7391                 },
7392                 .chained = true,
7393                 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7394         },
7395         [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
7396                 .type = HDA_FIXUP_PINS,
7397                 .v.pins = (const struct hda_pintbl[]) {
7398                         { 0x17, 0x90170112 }, /* subwoofer */
7399                         { }
7400                 },
7401                 .chained = true,
7402                 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
7403         },
7404         [ALC290_FIXUP_SUBWOOFER] = {
7405                 .type = HDA_FIXUP_PINS,
7406                 .v.pins = (const struct hda_pintbl[]) {
7407                         { 0x17, 0x90170112 }, /* subwoofer */
7408                         { }
7409                 },
7410                 .chained = true,
7411                 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
7412         },
7413         [ALC290_FIXUP_MONO_SPEAKERS] = {
7414                 .type = HDA_FIXUP_FUNC,
7415                 .v.func = alc290_fixup_mono_speakers,
7416         },
7417         [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
7418                 .type = HDA_FIXUP_FUNC,
7419                 .v.func = alc290_fixup_mono_speakers,
7420                 .chained = true,
7421                 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
7422         },
7423         [ALC269_FIXUP_THINKPAD_ACPI] = {
7424                 .type = HDA_FIXUP_FUNC,
7425                 .v.func = alc_fixup_thinkpad_acpi,
7426                 .chained = true,
7427                 .chain_id = ALC269_FIXUP_SKU_IGNORE,
7428         },
7429         [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
7430                 .type = HDA_FIXUP_FUNC,
7431                 .v.func = alc_fixup_inv_dmic,
7432                 .chained = true,
7433                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7434         },
7435         [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
7436                 .type = HDA_FIXUP_PINS,
7437                 .v.pins = (const struct hda_pintbl[]) {
7438                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7439                         { }
7440                 },
7441                 .chained = true,
7442                 .chain_id = ALC255_FIXUP_HEADSET_MODE
7443         },
7444         [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7445                 .type = HDA_FIXUP_PINS,
7446                 .v.pins = (const struct hda_pintbl[]) {
7447                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7448                         { }
7449                 },
7450                 .chained = true,
7451                 .chain_id = ALC255_FIXUP_HEADSET_MODE
7452         },
7453         [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7454                 .type = HDA_FIXUP_PINS,
7455                 .v.pins = (const struct hda_pintbl[]) {
7456                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7457                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7458                         { }
7459                 },
7460                 .chained = true,
7461                 .chain_id = ALC255_FIXUP_HEADSET_MODE
7462         },
7463         [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7464                 .type = HDA_FIXUP_PINS,
7465                 .v.pins = (const struct hda_pintbl[]) {
7466                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7467                         { }
7468                 },
7469                 .chained = true,
7470                 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7471         },
7472         [ALC255_FIXUP_HEADSET_MODE] = {
7473                 .type = HDA_FIXUP_FUNC,
7474                 .v.func = alc_fixup_headset_mode_alc255,
7475                 .chained = true,
7476                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7477         },
7478         [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7479                 .type = HDA_FIXUP_FUNC,
7480                 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
7481         },
7482         [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7483                 .type = HDA_FIXUP_PINS,
7484                 .v.pins = (const struct hda_pintbl[]) {
7485                         { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7486                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7487                         { }
7488                 },
7489                 .chained = true,
7490                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7491         },
7492         [ALC292_FIXUP_TPT440_DOCK] = {
7493                 .type = HDA_FIXUP_FUNC,
7494                 .v.func = alc_fixup_tpt440_dock,
7495                 .chained = true,
7496                 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7497         },
7498         [ALC292_FIXUP_TPT440] = {
7499                 .type = HDA_FIXUP_FUNC,
7500                 .v.func = alc_fixup_disable_aamix,
7501                 .chained = true,
7502                 .chain_id = ALC292_FIXUP_TPT440_DOCK,
7503         },
7504         [ALC283_FIXUP_HEADSET_MIC] = {
7505                 .type = HDA_FIXUP_PINS,
7506                 .v.pins = (const struct hda_pintbl[]) {
7507                         { 0x19, 0x04a110f0 },
7508                         { },
7509                 },
7510         },
7511         [ALC255_FIXUP_MIC_MUTE_LED] = {
7512                 .type = HDA_FIXUP_FUNC,
7513                 .v.func = alc_fixup_micmute_led,
7514         },
7515         [ALC282_FIXUP_ASPIRE_V5_PINS] = {
7516                 .type = HDA_FIXUP_PINS,
7517                 .v.pins = (const struct hda_pintbl[]) {
7518                         { 0x12, 0x90a60130 },
7519                         { 0x14, 0x90170110 },
7520                         { 0x17, 0x40000008 },
7521                         { 0x18, 0x411111f0 },
7522                         { 0x19, 0x01a1913c },
7523                         { 0x1a, 0x411111f0 },
7524                         { 0x1b, 0x411111f0 },
7525                         { 0x1d, 0x40f89b2d },
7526                         { 0x1e, 0x411111f0 },
7527                         { 0x21, 0x0321101f },
7528                         { },
7529                 },
7530         },
7531         [ALC269VB_FIXUP_ASPIRE_E1_COEF] = {
7532                 .type = HDA_FIXUP_FUNC,
7533                 .v.func = alc269vb_fixup_aspire_e1_coef,
7534         },
7535         [ALC280_FIXUP_HP_GPIO4] = {
7536                 .type = HDA_FIXUP_FUNC,
7537                 .v.func = alc280_fixup_hp_gpio4,
7538         },
7539         [ALC286_FIXUP_HP_GPIO_LED] = {
7540                 .type = HDA_FIXUP_FUNC,
7541                 .v.func = alc286_fixup_hp_gpio_led,
7542         },
7543         [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
7544                 .type = HDA_FIXUP_FUNC,
7545                 .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
7546         },
7547         [ALC280_FIXUP_HP_DOCK_PINS] = {
7548                 .type = HDA_FIXUP_PINS,
7549                 .v.pins = (const struct hda_pintbl[]) {
7550                         { 0x1b, 0x21011020 }, /* line-out */
7551                         { 0x1a, 0x01a1903c }, /* headset mic */
7552                         { 0x18, 0x2181103f }, /* line-in */
7553                         { },
7554                 },
7555                 .chained = true,
7556                 .chain_id = ALC280_FIXUP_HP_GPIO4
7557         },
7558         [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
7559                 .type = HDA_FIXUP_PINS,
7560                 .v.pins = (const struct hda_pintbl[]) {
7561                         { 0x1b, 0x21011020 }, /* line-out */
7562                         { 0x18, 0x2181103f }, /* line-in */
7563                         { },
7564                 },
7565                 .chained = true,
7566                 .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
7567         },
7568         [ALC280_FIXUP_HP_9480M] = {
7569                 .type = HDA_FIXUP_FUNC,
7570                 .v.func = alc280_fixup_hp_9480m,
7571         },
7572         [ALC245_FIXUP_HP_X360_AMP] = {
7573                 .type = HDA_FIXUP_FUNC,
7574                 .v.func = alc245_fixup_hp_x360_amp,
7575                 .chained = true,
7576                 .chain_id = ALC245_FIXUP_HP_GPIO_LED
7577         },
7578         [ALC288_FIXUP_DELL_HEADSET_MODE] = {
7579                 .type = HDA_FIXUP_FUNC,
7580                 .v.func = alc_fixup_headset_mode_dell_alc288,
7581                 .chained = true,
7582                 .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7583         },
7584         [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7585                 .type = HDA_FIXUP_PINS,
7586                 .v.pins = (const struct hda_pintbl[]) {
7587                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7588                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7589                         { }
7590                 },
7591                 .chained = true,
7592                 .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
7593         },
7594         [ALC288_FIXUP_DISABLE_AAMIX] = {
7595                 .type = HDA_FIXUP_FUNC,
7596                 .v.func = alc_fixup_disable_aamix,
7597                 .chained = true,
7598                 .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
7599         },
7600         [ALC288_FIXUP_DELL_XPS_13] = {
7601                 .type = HDA_FIXUP_FUNC,
7602                 .v.func = alc_fixup_dell_xps13,
7603                 .chained = true,
7604                 .chain_id = ALC288_FIXUP_DISABLE_AAMIX
7605         },
7606         [ALC292_FIXUP_DISABLE_AAMIX] = {
7607                 .type = HDA_FIXUP_FUNC,
7608                 .v.func = alc_fixup_disable_aamix,
7609                 .chained = true,
7610                 .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
7611         },
7612         [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
7613                 .type = HDA_FIXUP_FUNC,
7614                 .v.func = alc_fixup_disable_aamix,
7615                 .chained = true,
7616                 .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
7617         },
7618         [ALC292_FIXUP_DELL_E7X_AAMIX] = {
7619                 .type = HDA_FIXUP_FUNC,
7620                 .v.func = alc_fixup_dell_xps13,
7621                 .chained = true,
7622                 .chain_id = ALC292_FIXUP_DISABLE_AAMIX
7623         },
7624         [ALC292_FIXUP_DELL_E7X] = {
7625                 .type = HDA_FIXUP_FUNC,
7626                 .v.func = alc_fixup_micmute_led,
7627                 /* micmute fixup must be applied at last */
7628                 .chained_before = true,
7629                 .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
7630         },
7631         [ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = {
7632                 .type = HDA_FIXUP_PINS,
7633                 .v.pins = (const struct hda_pintbl[]) {
7634                         { 0x18, 0x01a1913c }, /* headset mic w/o jack detect */
7635                         { }
7636                 },
7637                 .chained_before = true,
7638                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
7639         },
7640         [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7641                 .type = HDA_FIXUP_PINS,
7642                 .v.pins = (const struct hda_pintbl[]) {
7643                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7644                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7645                         { }
7646                 },
7647                 .chained = true,
7648                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7649         },
7650         [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
7651                 .type = HDA_FIXUP_PINS,
7652                 .v.pins = (const struct hda_pintbl[]) {
7653                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7654                         { }
7655                 },
7656                 .chained = true,
7657                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7658         },
7659         [ALC275_FIXUP_DELL_XPS] = {
7660                 .type = HDA_FIXUP_VERBS,
7661                 .v.verbs = (const struct hda_verb[]) {
7662                         /* Enables internal speaker */
7663                         {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
7664                         {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
7665                         {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
7666                         {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
7667                         {}
7668                 }
7669         },
7670         [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
7671                 .type = HDA_FIXUP_FUNC,
7672                 .v.func = alc_fixup_disable_aamix,
7673                 .chained = true,
7674                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7675         },
7676         [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
7677                 .type = HDA_FIXUP_FUNC,
7678                 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
7679         },
7680         [ALC233_FIXUP_INTEL_NUC8_DMIC] = {
7681                 .type = HDA_FIXUP_FUNC,
7682                 .v.func = alc_fixup_inv_dmic,
7683                 .chained = true,
7684                 .chain_id = ALC233_FIXUP_INTEL_NUC8_BOOST,
7685         },
7686         [ALC233_FIXUP_INTEL_NUC8_BOOST] = {
7687                 .type = HDA_FIXUP_FUNC,
7688                 .v.func = alc269_fixup_limit_int_mic_boost
7689         },
7690         [ALC255_FIXUP_DELL_SPK_NOISE] = {
7691                 .type = HDA_FIXUP_FUNC,
7692                 .v.func = alc_fixup_disable_aamix,
7693                 .chained = true,
7694                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7695         },
7696         [ALC225_FIXUP_DISABLE_MIC_VREF] = {
7697                 .type = HDA_FIXUP_FUNC,
7698                 .v.func = alc_fixup_disable_mic_vref,
7699                 .chained = true,
7700                 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7701         },
7702         [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7703                 .type = HDA_FIXUP_VERBS,
7704                 .v.verbs = (const struct hda_verb[]) {
7705                         /* Disable pass-through path for FRONT 14h */
7706                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7707                         { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7708                         {}
7709                 },
7710                 .chained = true,
7711                 .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
7712         },
7713         [ALC280_FIXUP_HP_HEADSET_MIC] = {
7714                 .type = HDA_FIXUP_FUNC,
7715                 .v.func = alc_fixup_disable_aamix,
7716                 .chained = true,
7717                 .chain_id = ALC269_FIXUP_HEADSET_MIC,
7718         },
7719         [ALC221_FIXUP_HP_FRONT_MIC] = {
7720                 .type = HDA_FIXUP_PINS,
7721                 .v.pins = (const struct hda_pintbl[]) {
7722                         { 0x19, 0x02a19020 }, /* Front Mic */
7723                         { }
7724                 },
7725         },
7726         [ALC292_FIXUP_TPT460] = {
7727                 .type = HDA_FIXUP_FUNC,
7728                 .v.func = alc_fixup_tpt440_dock,
7729                 .chained = true,
7730                 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
7731         },
7732         [ALC298_FIXUP_SPK_VOLUME] = {
7733                 .type = HDA_FIXUP_FUNC,
7734                 .v.func = alc298_fixup_speaker_volume,
7735                 .chained = true,
7736                 .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
7737         },
7738         [ALC298_FIXUP_LENOVO_SPK_VOLUME] = {
7739                 .type = HDA_FIXUP_FUNC,
7740                 .v.func = alc298_fixup_speaker_volume,
7741         },
7742         [ALC295_FIXUP_DISABLE_DAC3] = {
7743                 .type = HDA_FIXUP_FUNC,
7744                 .v.func = alc295_fixup_disable_dac3,
7745         },
7746         [ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
7747                 .type = HDA_FIXUP_FUNC,
7748                 .v.func = alc285_fixup_speaker2_to_dac1,
7749                 .chained = true,
7750                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7751         },
7752         [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
7753                 .type = HDA_FIXUP_PINS,
7754                 .v.pins = (const struct hda_pintbl[]) {
7755                         { 0x1b, 0x90170151 },
7756                         { }
7757                 },
7758                 .chained = true,
7759                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7760         },
7761         [ALC269_FIXUP_ATIV_BOOK_8] = {
7762                 .type = HDA_FIXUP_FUNC,
7763                 .v.func = alc_fixup_auto_mute_via_amp,
7764                 .chained = true,
7765                 .chain_id = ALC269_FIXUP_NO_SHUTUP
7766         },
7767         [ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE] = {
7768                 .type = HDA_FIXUP_PINS,
7769                 .v.pins = (const struct hda_pintbl[]) {
7770                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7771                         { 0x1a, 0x01813030 }, /* use as headphone mic, without its own jack detect */
7772                         { }
7773                 },
7774                 .chained = true,
7775                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7776         },
7777         [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
7778                 .type = HDA_FIXUP_PINS,
7779                 .v.pins = (const struct hda_pintbl[]) {
7780                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7781                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7782                         { }
7783                 },
7784                 .chained = true,
7785                 .chain_id = ALC269_FIXUP_HEADSET_MODE
7786         },
7787         [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
7788                 .type = HDA_FIXUP_FUNC,
7789                 .v.func = alc_fixup_headset_mode,
7790         },
7791         [ALC256_FIXUP_ASUS_MIC] = {
7792                 .type = HDA_FIXUP_PINS,
7793                 .v.pins = (const struct hda_pintbl[]) {
7794                         { 0x13, 0x90a60160 }, /* use as internal mic */
7795                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7796                         { }
7797                 },
7798                 .chained = true,
7799                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7800         },
7801         [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
7802                 .type = HDA_FIXUP_FUNC,
7803                 /* Set up GPIO2 for the speaker amp */
7804                 .v.func = alc_fixup_gpio4,
7805         },
7806         [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7807                 .type = HDA_FIXUP_PINS,
7808                 .v.pins = (const struct hda_pintbl[]) {
7809                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7810                         { }
7811                 },
7812                 .chained = true,
7813                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7814         },
7815         [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
7816                 .type = HDA_FIXUP_VERBS,
7817                 .v.verbs = (const struct hda_verb[]) {
7818                         /* Enables internal speaker */
7819                         {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
7820                         {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
7821                         {}
7822                 },
7823                 .chained = true,
7824                 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7825         },
7826         [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
7827                 .type = HDA_FIXUP_FUNC,
7828                 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
7829                 .chained = true,
7830                 .chain_id = ALC269_FIXUP_GPIO2
7831         },
7832         [ALC233_FIXUP_ACER_HEADSET_MIC] = {
7833                 .type = HDA_FIXUP_VERBS,
7834                 .v.verbs = (const struct hda_verb[]) {
7835                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
7836                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
7837                         { }
7838                 },
7839                 .chained = true,
7840                 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7841         },
7842         [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
7843                 .type = HDA_FIXUP_PINS,
7844                 .v.pins = (const struct hda_pintbl[]) {
7845                         /* Change the mic location from front to right, otherwise there are
7846                            two front mics with the same name, pulseaudio can't handle them.
7847                            This is just a temporary workaround, after applying this fixup,
7848                            there will be one "Front Mic" and one "Mic" in this machine.
7849                          */
7850                         { 0x1a, 0x04a19040 },
7851                         { }
7852                 },
7853         },
7854         [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
7855                 .type = HDA_FIXUP_PINS,
7856                 .v.pins = (const struct hda_pintbl[]) {
7857                         { 0x16, 0x0101102f }, /* Rear Headset HP */
7858                         { 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
7859                         { 0x1a, 0x01a19030 }, /* Rear Headset MIC */
7860                         { 0x1b, 0x02011020 },
7861                         { }
7862                 },
7863                 .chained = true,
7864                 .chain_id = ALC225_FIXUP_S3_POP_NOISE
7865         },
7866         [ALC225_FIXUP_S3_POP_NOISE] = {
7867                 .type = HDA_FIXUP_FUNC,
7868                 .v.func = alc225_fixup_s3_pop_noise,
7869                 .chained = true,
7870                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7871         },
7872         [ALC700_FIXUP_INTEL_REFERENCE] = {
7873                 .type = HDA_FIXUP_VERBS,
7874                 .v.verbs = (const struct hda_verb[]) {
7875                         /* Enables internal speaker */
7876                         {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
7877                         {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
7878                         {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
7879                         {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
7880                         {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
7881                         {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
7882                         {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
7883                         {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
7884                         {}
7885                 }
7886         },
7887         [ALC274_FIXUP_DELL_BIND_DACS] = {
7888                 .type = HDA_FIXUP_FUNC,
7889                 .v.func = alc274_fixup_bind_dacs,
7890                 .chained = true,
7891                 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7892         },
7893         [ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
7894                 .type = HDA_FIXUP_PINS,
7895                 .v.pins = (const struct hda_pintbl[]) {
7896                         { 0x1b, 0x0401102f },
7897                         { }
7898                 },
7899                 .chained = true,
7900                 .chain_id = ALC274_FIXUP_DELL_BIND_DACS
7901         },
7902         [ALC298_FIXUP_TPT470_DOCK_FIX] = {
7903                 .type = HDA_FIXUP_FUNC,
7904                 .v.func = alc_fixup_tpt470_dock,
7905                 .chained = true,
7906                 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
7907         },
7908         [ALC298_FIXUP_TPT470_DOCK] = {
7909                 .type = HDA_FIXUP_FUNC,
7910                 .v.func = alc_fixup_tpt470_dacs,
7911                 .chained = true,
7912                 .chain_id = ALC298_FIXUP_TPT470_DOCK_FIX
7913         },
7914         [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
7915                 .type = HDA_FIXUP_PINS,
7916                 .v.pins = (const struct hda_pintbl[]) {
7917                         { 0x14, 0x0201101f },
7918                         { }
7919                 },
7920                 .chained = true,
7921                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7922         },
7923         [ALC255_FIXUP_DELL_HEADSET_MIC] = {
7924                 .type = HDA_FIXUP_PINS,
7925                 .v.pins = (const struct hda_pintbl[]) {
7926                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7927                         { }
7928                 },
7929                 .chained = true,
7930                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7931         },
7932         [ALC295_FIXUP_HP_X360] = {
7933                 .type = HDA_FIXUP_FUNC,
7934                 .v.func = alc295_fixup_hp_top_speakers,
7935                 .chained = true,
7936                 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
7937         },
7938         [ALC221_FIXUP_HP_HEADSET_MIC] = {
7939                 .type = HDA_FIXUP_PINS,
7940                 .v.pins = (const struct hda_pintbl[]) {
7941                         { 0x19, 0x0181313f},
7942                         { }
7943                 },
7944                 .chained = true,
7945                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7946         },
7947         [ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
7948                 .type = HDA_FIXUP_FUNC,
7949                 .v.func = alc285_fixup_invalidate_dacs,
7950                 .chained = true,
7951                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7952         },
7953         [ALC295_FIXUP_HP_AUTO_MUTE] = {
7954                 .type = HDA_FIXUP_FUNC,
7955                 .v.func = alc_fixup_auto_mute_via_amp,
7956         },
7957         [ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
7958                 .type = HDA_FIXUP_PINS,
7959                 .v.pins = (const struct hda_pintbl[]) {
7960                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7961                         { }
7962                 },
7963                 .chained = true,
7964                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7965         },
7966         [ALC294_FIXUP_ASUS_MIC] = {
7967                 .type = HDA_FIXUP_PINS,
7968                 .v.pins = (const struct hda_pintbl[]) {
7969                         { 0x13, 0x90a60160 }, /* use as internal mic */
7970                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7971                         { }
7972                 },
7973                 .chained = true,
7974                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7975         },
7976         [ALC294_FIXUP_ASUS_HEADSET_MIC] = {
7977                 .type = HDA_FIXUP_PINS,
7978                 .v.pins = (const struct hda_pintbl[]) {
7979                         { 0x19, 0x01a1103c }, /* use as headset mic */
7980                         { }
7981                 },
7982                 .chained = true,
7983                 .chain_id = ALC269_FIXUP_HEADSET_MIC
7984         },
7985         [ALC294_FIXUP_ASUS_SPK] = {
7986                 .type = HDA_FIXUP_VERBS,
7987                 .v.verbs = (const struct hda_verb[]) {
7988                         /* Set EAPD high */
7989                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
7990                         { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
7991                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
7992                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
7993                         { }
7994                 },
7995                 .chained = true,
7996                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7997         },
7998         [ALC295_FIXUP_CHROME_BOOK] = {
7999                 .type = HDA_FIXUP_FUNC,
8000                 .v.func = alc295_fixup_chromebook,
8001                 .chained = true,
8002                 .chain_id = ALC225_FIXUP_HEADSET_JACK
8003         },
8004         [ALC225_FIXUP_HEADSET_JACK] = {
8005                 .type = HDA_FIXUP_FUNC,
8006                 .v.func = alc_fixup_headset_jack,
8007         },
8008         [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
8009                 .type = HDA_FIXUP_PINS,
8010                 .v.pins = (const struct hda_pintbl[]) {
8011                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8012                         { }
8013                 },
8014                 .chained = true,
8015                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8016         },
8017         [ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
8018                 .type = HDA_FIXUP_VERBS,
8019                 .v.verbs = (const struct hda_verb[]) {
8020                         /* Disable PCBEEP-IN passthrough */
8021                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
8022                         { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
8023                         { }
8024                 },
8025                 .chained = true,
8026                 .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
8027         },
8028         [ALC255_FIXUP_ACER_HEADSET_MIC] = {
8029                 .type = HDA_FIXUP_PINS,
8030                 .v.pins = (const struct hda_pintbl[]) {
8031                         { 0x19, 0x03a11130 },
8032                         { 0x1a, 0x90a60140 }, /* use as internal mic */
8033                         { }
8034                 },
8035                 .chained = true,
8036                 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
8037         },
8038         [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
8039                 .type = HDA_FIXUP_PINS,
8040                 .v.pins = (const struct hda_pintbl[]) {
8041                         { 0x16, 0x01011020 }, /* Rear Line out */
8042                         { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
8043                         { }
8044                 },
8045                 .chained = true,
8046                 .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
8047         },
8048         [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
8049                 .type = HDA_FIXUP_FUNC,
8050                 .v.func = alc_fixup_auto_mute_via_amp,
8051                 .chained = true,
8052                 .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
8053         },
8054         [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
8055                 .type = HDA_FIXUP_FUNC,
8056                 .v.func = alc_fixup_disable_mic_vref,
8057                 .chained = true,
8058                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8059         },
8060         [ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
8061                 .type = HDA_FIXUP_VERBS,
8062                 .v.verbs = (const struct hda_verb[]) {
8063                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
8064                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
8065                         { }
8066                 },
8067                 .chained = true,
8068                 .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
8069         },
8070         [ALC256_FIXUP_ASUS_HEADSET_MIC] = {
8071                 .type = HDA_FIXUP_PINS,
8072                 .v.pins = (const struct hda_pintbl[]) {
8073                         { 0x19, 0x03a11020 }, /* headset mic with jack detect */
8074                         { }
8075                 },
8076                 .chained = true,
8077                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8078         },
8079         [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8080                 .type = HDA_FIXUP_PINS,
8081                 .v.pins = (const struct hda_pintbl[]) {
8082                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
8083                         { }
8084                 },
8085                 .chained = true,
8086                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8087         },
8088         [ALC299_FIXUP_PREDATOR_SPK] = {
8089                 .type = HDA_FIXUP_PINS,
8090                 .v.pins = (const struct hda_pintbl[]) {
8091                         { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
8092                         { }
8093                 }
8094         },
8095         [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
8096                 .type = HDA_FIXUP_PINS,
8097                 .v.pins = (const struct hda_pintbl[]) {
8098                         { 0x19, 0x04a11040 },
8099                         { 0x21, 0x04211020 },
8100                         { }
8101                 },
8102                 .chained = true,
8103                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8104         },
8105         [ALC289_FIXUP_DELL_SPK2] = {
8106                 .type = HDA_FIXUP_PINS,
8107                 .v.pins = (const struct hda_pintbl[]) {
8108                         { 0x17, 0x90170130 }, /* bass spk */
8109                         { }
8110                 },
8111                 .chained = true,
8112                 .chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
8113         },
8114         [ALC289_FIXUP_DUAL_SPK] = {
8115                 .type = HDA_FIXUP_FUNC,
8116                 .v.func = alc285_fixup_speaker2_to_dac1,
8117                 .chained = true,
8118                 .chain_id = ALC289_FIXUP_DELL_SPK2
8119         },
8120         [ALC294_FIXUP_SPK2_TO_DAC1] = {
8121                 .type = HDA_FIXUP_FUNC,
8122                 .v.func = alc285_fixup_speaker2_to_dac1,
8123                 .chained = true,
8124                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8125         },
8126         [ALC294_FIXUP_ASUS_DUAL_SPK] = {
8127                 .type = HDA_FIXUP_FUNC,
8128                 /* The GPIO must be pulled to initialize the AMP */
8129                 .v.func = alc_fixup_gpio4,
8130                 .chained = true,
8131                 .chain_id = ALC294_FIXUP_SPK2_TO_DAC1
8132         },
8133         [ALC285_FIXUP_THINKPAD_X1_GEN7] = {
8134                 .type = HDA_FIXUP_FUNC,
8135                 .v.func = alc285_fixup_thinkpad_x1_gen7,
8136                 .chained = true,
8137                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
8138         },
8139         [ALC285_FIXUP_THINKPAD_HEADSET_JACK] = {
8140                 .type = HDA_FIXUP_FUNC,
8141                 .v.func = alc_fixup_headset_jack,
8142                 .chained = true,
8143                 .chain_id = ALC285_FIXUP_THINKPAD_X1_GEN7
8144         },
8145         [ALC294_FIXUP_ASUS_HPE] = {
8146                 .type = HDA_FIXUP_VERBS,
8147                 .v.verbs = (const struct hda_verb[]) {
8148                         /* Set EAPD high */
8149                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8150                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
8151                         { }
8152                 },
8153                 .chained = true,
8154                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8155         },
8156         [ALC294_FIXUP_ASUS_GX502_PINS] = {
8157                 .type = HDA_FIXUP_PINS,
8158                 .v.pins = (const struct hda_pintbl[]) {
8159                         { 0x19, 0x03a11050 }, /* front HP mic */
8160                         { 0x1a, 0x01a11830 }, /* rear external mic */
8161                         { 0x21, 0x03211020 }, /* front HP out */
8162                         { }
8163                 },
8164                 .chained = true,
8165                 .chain_id = ALC294_FIXUP_ASUS_GX502_VERBS
8166         },
8167         [ALC294_FIXUP_ASUS_GX502_VERBS] = {
8168                 .type = HDA_FIXUP_VERBS,
8169                 .v.verbs = (const struct hda_verb[]) {
8170                         /* set 0x15 to HP-OUT ctrl */
8171                         { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8172                         /* unmute the 0x15 amp */
8173                         { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
8174                         { }
8175                 },
8176                 .chained = true,
8177                 .chain_id = ALC294_FIXUP_ASUS_GX502_HP
8178         },
8179         [ALC294_FIXUP_ASUS_GX502_HP] = {
8180                 .type = HDA_FIXUP_FUNC,
8181                 .v.func = alc294_fixup_gx502_hp,
8182         },
8183         [ALC294_FIXUP_ASUS_GU502_PINS] = {
8184                 .type = HDA_FIXUP_PINS,
8185                 .v.pins = (const struct hda_pintbl[]) {
8186                         { 0x19, 0x01a11050 }, /* rear HP mic */
8187                         { 0x1a, 0x01a11830 }, /* rear external mic */
8188                         { 0x21, 0x012110f0 }, /* rear HP out */
8189                         { }
8190                 },
8191                 .chained = true,
8192                 .chain_id = ALC294_FIXUP_ASUS_GU502_VERBS
8193         },
8194         [ALC294_FIXUP_ASUS_GU502_VERBS] = {
8195                 .type = HDA_FIXUP_VERBS,
8196                 .v.verbs = (const struct hda_verb[]) {
8197                         /* set 0x15 to HP-OUT ctrl */
8198                         { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8199                         /* unmute the 0x15 amp */
8200                         { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
8201                         /* set 0x1b to HP-OUT */
8202                         { 0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8203                         { }
8204                 },
8205                 .chained = true,
8206                 .chain_id = ALC294_FIXUP_ASUS_GU502_HP
8207         },
8208         [ALC294_FIXUP_ASUS_GU502_HP] = {
8209                 .type = HDA_FIXUP_FUNC,
8210                 .v.func = alc294_fixup_gu502_hp,
8211         },
8212          [ALC294_FIXUP_ASUS_G513_PINS] = {
8213                 .type = HDA_FIXUP_PINS,
8214                 .v.pins = (const struct hda_pintbl[]) {
8215                                 { 0x19, 0x03a11050 }, /* front HP mic */
8216                                 { 0x1a, 0x03a11c30 }, /* rear external mic */
8217                                 { 0x21, 0x03211420 }, /* front HP out */
8218                                 { }
8219                 },
8220         },
8221         [ALC285_FIXUP_ASUS_G533Z_PINS] = {
8222                 .type = HDA_FIXUP_PINS,
8223                 .v.pins = (const struct hda_pintbl[]) {
8224                         { 0x14, 0x90170152 }, /* Speaker Surround Playback Switch */
8225                         { 0x19, 0x03a19020 }, /* Mic Boost Volume */
8226                         { 0x1a, 0x03a11c30 }, /* Mic Boost Volume */
8227                         { 0x1e, 0x90170151 }, /* Rear jack, IN OUT EAPD Detect */
8228                         { 0x21, 0x03211420 },
8229                         { }
8230                 },
8231         },
8232         [ALC294_FIXUP_ASUS_COEF_1B] = {
8233                 .type = HDA_FIXUP_VERBS,
8234                 .v.verbs = (const struct hda_verb[]) {
8235                         /* Set bit 10 to correct noisy output after reboot from
8236                          * Windows 10 (due to pop noise reduction?)
8237                          */
8238                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
8239                         { 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
8240                         { }
8241                 },
8242                 .chained = true,
8243                 .chain_id = ALC289_FIXUP_ASUS_GA401,
8244         },
8245         [ALC285_FIXUP_HP_GPIO_LED] = {
8246                 .type = HDA_FIXUP_FUNC,
8247                 .v.func = alc285_fixup_hp_gpio_led,
8248         },
8249         [ALC285_FIXUP_HP_MUTE_LED] = {
8250                 .type = HDA_FIXUP_FUNC,
8251                 .v.func = alc285_fixup_hp_mute_led,
8252         },
8253         [ALC236_FIXUP_HP_GPIO_LED] = {
8254                 .type = HDA_FIXUP_FUNC,
8255                 .v.func = alc236_fixup_hp_gpio_led,
8256         },
8257         [ALC236_FIXUP_HP_MUTE_LED] = {
8258                 .type = HDA_FIXUP_FUNC,
8259                 .v.func = alc236_fixup_hp_mute_led,
8260         },
8261         [ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF] = {
8262                 .type = HDA_FIXUP_FUNC,
8263                 .v.func = alc236_fixup_hp_mute_led_micmute_vref,
8264         },
8265         [ALC298_FIXUP_SAMSUNG_AMP] = {
8266                 .type = HDA_FIXUP_FUNC,
8267                 .v.func = alc298_fixup_samsung_amp,
8268                 .chained = true,
8269                 .chain_id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET
8270         },
8271         [ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
8272                 .type = HDA_FIXUP_VERBS,
8273                 .v.verbs = (const struct hda_verb[]) {
8274                         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
8275                         { }
8276                 },
8277         },
8278         [ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
8279                 .type = HDA_FIXUP_VERBS,
8280                 .v.verbs = (const struct hda_verb[]) {
8281                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x08},
8282                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf},
8283                         { }
8284                 },
8285         },
8286         [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8287                 .type = HDA_FIXUP_PINS,
8288                 .v.pins = (const struct hda_pintbl[]) {
8289                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8290                         { }
8291                 },
8292                 .chained = true,
8293                 .chain_id = ALC269_FIXUP_HEADSET_MODE
8294         },
8295         [ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS] = {
8296                 .type = HDA_FIXUP_PINS,
8297                 .v.pins = (const struct hda_pintbl[]) {
8298                         { 0x14, 0x90100120 }, /* use as internal speaker */
8299                         { 0x18, 0x02a111f0 }, /* use as headset mic, without its own jack detect */
8300                         { 0x1a, 0x01011020 }, /* use as line out */
8301                         { },
8302                 },
8303                 .chained = true,
8304                 .chain_id = ALC269_FIXUP_HEADSET_MIC
8305         },
8306         [ALC269VC_FIXUP_ACER_HEADSET_MIC] = {
8307                 .type = HDA_FIXUP_PINS,
8308                 .v.pins = (const struct hda_pintbl[]) {
8309                         { 0x18, 0x02a11030 }, /* use as headset mic */
8310                         { }
8311                 },
8312                 .chained = true,
8313                 .chain_id = ALC269_FIXUP_HEADSET_MIC
8314         },
8315         [ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE] = {
8316                 .type = HDA_FIXUP_PINS,
8317                 .v.pins = (const struct hda_pintbl[]) {
8318                         { 0x18, 0x01a11130 }, /* use as headset mic, without its own jack detect */
8319                         { }
8320                 },
8321                 .chained = true,
8322                 .chain_id = ALC269_FIXUP_HEADSET_MIC
8323         },
8324         [ALC289_FIXUP_ASUS_GA401] = {
8325                 .type = HDA_FIXUP_FUNC,
8326                 .v.func = alc289_fixup_asus_ga401,
8327                 .chained = true,
8328                 .chain_id = ALC289_FIXUP_ASUS_GA502,
8329         },
8330         [ALC289_FIXUP_ASUS_GA502] = {
8331                 .type = HDA_FIXUP_PINS,
8332                 .v.pins = (const struct hda_pintbl[]) {
8333                         { 0x19, 0x03a11020 }, /* headset mic with jack detect */
8334                         { }
8335                 },
8336         },
8337         [ALC256_FIXUP_ACER_MIC_NO_PRESENCE] = {
8338                 .type = HDA_FIXUP_PINS,
8339                 .v.pins = (const struct hda_pintbl[]) {
8340                         { 0x19, 0x02a11120 }, /* use as headset mic, without its own jack detect */
8341                         { }
8342                 },
8343                 .chained = true,
8344                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8345         },
8346         [ALC285_FIXUP_HP_GPIO_AMP_INIT] = {
8347                 .type = HDA_FIXUP_FUNC,
8348                 .v.func = alc285_fixup_hp_gpio_amp_init,
8349                 .chained = true,
8350                 .chain_id = ALC285_FIXUP_HP_GPIO_LED
8351         },
8352         [ALC269_FIXUP_CZC_B20] = {
8353                 .type = HDA_FIXUP_PINS,
8354                 .v.pins = (const struct hda_pintbl[]) {
8355                         { 0x12, 0x411111f0 },
8356                         { 0x14, 0x90170110 }, /* speaker */
8357                         { 0x15, 0x032f1020 }, /* HP out */
8358                         { 0x17, 0x411111f0 },
8359                         { 0x18, 0x03ab1040 }, /* mic */
8360                         { 0x19, 0xb7a7013f },
8361                         { 0x1a, 0x0181305f },
8362                         { 0x1b, 0x411111f0 },
8363                         { 0x1d, 0x411111f0 },
8364                         { 0x1e, 0x411111f0 },
8365                         { }
8366                 },
8367                 .chain_id = ALC269_FIXUP_DMIC,
8368         },
8369         [ALC269_FIXUP_CZC_TMI] = {
8370                 .type = HDA_FIXUP_PINS,
8371                 .v.pins = (const struct hda_pintbl[]) {
8372                         { 0x12, 0x4000c000 },
8373                         { 0x14, 0x90170110 }, /* speaker */
8374                         { 0x15, 0x0421401f }, /* HP out */
8375                         { 0x17, 0x411111f0 },
8376                         { 0x18, 0x04a19020 }, /* mic */
8377                         { 0x19, 0x411111f0 },
8378                         { 0x1a, 0x411111f0 },
8379                         { 0x1b, 0x411111f0 },
8380                         { 0x1d, 0x40448505 },
8381                         { 0x1e, 0x411111f0 },
8382                         { 0x20, 0x8000ffff },
8383                         { }
8384                 },
8385                 .chain_id = ALC269_FIXUP_DMIC,
8386         },
8387         [ALC269_FIXUP_CZC_L101] = {
8388                 .type = HDA_FIXUP_PINS,
8389                 .v.pins = (const struct hda_pintbl[]) {
8390                         { 0x12, 0x40000000 },
8391                         { 0x14, 0x01014010 }, /* speaker */
8392                         { 0x15, 0x411111f0 }, /* HP out */
8393                         { 0x16, 0x411111f0 },
8394                         { 0x18, 0x01a19020 }, /* mic */
8395                         { 0x19, 0x02a19021 },
8396                         { 0x1a, 0x0181302f },
8397                         { 0x1b, 0x0221401f },
8398                         { 0x1c, 0x411111f0 },
8399                         { 0x1d, 0x4044c601 },
8400                         { 0x1e, 0x411111f0 },
8401                         { }
8402                 },
8403                 .chain_id = ALC269_FIXUP_DMIC,
8404         },
8405         [ALC269_FIXUP_LEMOTE_A1802] = {
8406                 .type = HDA_FIXUP_PINS,
8407                 .v.pins = (const struct hda_pintbl[]) {
8408                         { 0x12, 0x40000000 },
8409                         { 0x14, 0x90170110 }, /* speaker */
8410                         { 0x17, 0x411111f0 },
8411                         { 0x18, 0x03a19040 }, /* mic1 */
8412                         { 0x19, 0x90a70130 }, /* mic2 */
8413                         { 0x1a, 0x411111f0 },
8414                         { 0x1b, 0x411111f0 },
8415                         { 0x1d, 0x40489d2d },
8416                         { 0x1e, 0x411111f0 },
8417                         { 0x20, 0x0003ffff },
8418                         { 0x21, 0x03214020 },
8419                         { }
8420                 },
8421                 .chain_id = ALC269_FIXUP_DMIC,
8422         },
8423         [ALC269_FIXUP_LEMOTE_A190X] = {
8424                 .type = HDA_FIXUP_PINS,
8425                 .v.pins = (const struct hda_pintbl[]) {
8426                         { 0x14, 0x99130110 }, /* speaker */
8427                         { 0x15, 0x0121401f }, /* HP out */
8428                         { 0x18, 0x01a19c20 }, /* rear  mic */
8429                         { 0x19, 0x99a3092f }, /* front mic */
8430                         { 0x1b, 0x0201401f }, /* front lineout */
8431                         { }
8432                 },
8433                 .chain_id = ALC269_FIXUP_DMIC,
8434         },
8435         [ALC256_FIXUP_INTEL_NUC8_RUGGED] = {
8436                 .type = HDA_FIXUP_PINS,
8437                 .v.pins = (const struct hda_pintbl[]) {
8438                         { 0x1b, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8439                         { }
8440                 },
8441                 .chained = true,
8442                 .chain_id = ALC269_FIXUP_HEADSET_MODE
8443         },
8444         [ALC256_FIXUP_INTEL_NUC10] = {
8445                 .type = HDA_FIXUP_PINS,
8446                 .v.pins = (const struct hda_pintbl[]) {
8447                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8448                         { }
8449                 },
8450                 .chained = true,
8451                 .chain_id = ALC269_FIXUP_HEADSET_MODE
8452         },
8453         [ALC255_FIXUP_XIAOMI_HEADSET_MIC] = {
8454                 .type = HDA_FIXUP_VERBS,
8455                 .v.verbs = (const struct hda_verb[]) {
8456                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8457                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8458                         { }
8459                 },
8460                 .chained = true,
8461                 .chain_id = ALC289_FIXUP_ASUS_GA502
8462         },
8463         [ALC274_FIXUP_HP_MIC] = {
8464                 .type = HDA_FIXUP_VERBS,
8465                 .v.verbs = (const struct hda_verb[]) {
8466                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8467                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8468                         { }
8469                 },
8470         },
8471         [ALC274_FIXUP_HP_HEADSET_MIC] = {
8472                 .type = HDA_FIXUP_FUNC,
8473                 .v.func = alc274_fixup_hp_headset_mic,
8474                 .chained = true,
8475                 .chain_id = ALC274_FIXUP_HP_MIC
8476         },
8477         [ALC274_FIXUP_HP_ENVY_GPIO] = {
8478                 .type = HDA_FIXUP_FUNC,
8479                 .v.func = alc274_fixup_hp_envy_gpio,
8480         },
8481         [ALC256_FIXUP_ASUS_HPE] = {
8482                 .type = HDA_FIXUP_VERBS,
8483                 .v.verbs = (const struct hda_verb[]) {
8484                         /* Set EAPD high */
8485                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8486                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7778 },
8487                         { }
8488                 },
8489                 .chained = true,
8490                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8491         },
8492         [ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK] = {
8493                 .type = HDA_FIXUP_FUNC,
8494                 .v.func = alc_fixup_headset_jack,
8495                 .chained = true,
8496                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
8497         },
8498         [ALC287_FIXUP_HP_GPIO_LED] = {
8499                 .type = HDA_FIXUP_FUNC,
8500                 .v.func = alc287_fixup_hp_gpio_led,
8501         },
8502         [ALC256_FIXUP_HP_HEADSET_MIC] = {
8503                 .type = HDA_FIXUP_FUNC,
8504                 .v.func = alc274_fixup_hp_headset_mic,
8505         },
8506         [ALC236_FIXUP_DELL_AIO_HEADSET_MIC] = {
8507                 .type = HDA_FIXUP_FUNC,
8508                 .v.func = alc_fixup_no_int_mic,
8509                 .chained = true,
8510                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
8511         },
8512         [ALC282_FIXUP_ACER_DISABLE_LINEOUT] = {
8513                 .type = HDA_FIXUP_PINS,
8514                 .v.pins = (const struct hda_pintbl[]) {
8515                         { 0x1b, 0x411111f0 },
8516                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8517                         { },
8518                 },
8519                 .chained = true,
8520                 .chain_id = ALC269_FIXUP_HEADSET_MODE
8521         },
8522         [ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST] = {
8523                 .type = HDA_FIXUP_FUNC,
8524                 .v.func = alc269_fixup_limit_int_mic_boost,
8525                 .chained = true,
8526                 .chain_id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
8527         },
8528         [ALC256_FIXUP_ACER_HEADSET_MIC] = {
8529                 .type = HDA_FIXUP_PINS,
8530                 .v.pins = (const struct hda_pintbl[]) {
8531                         { 0x19, 0x02a1113c }, /* use as headset mic, without its own jack detect */
8532                         { 0x1a, 0x90a1092f }, /* use as internal mic */
8533                         { }
8534                 },
8535                 .chained = true,
8536                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8537         },
8538         [ALC285_FIXUP_IDEAPAD_S740_COEF] = {
8539                 .type = HDA_FIXUP_FUNC,
8540                 .v.func = alc285_fixup_ideapad_s740_coef,
8541                 .chained = true,
8542                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8543         },
8544         [ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8545                 .type = HDA_FIXUP_FUNC,
8546                 .v.func = alc269_fixup_limit_int_mic_boost,
8547                 .chained = true,
8548                 .chain_id = ALC285_FIXUP_HP_MUTE_LED,
8549         },
8550         [ALC295_FIXUP_ASUS_DACS] = {
8551                 .type = HDA_FIXUP_FUNC,
8552                 .v.func = alc295_fixup_asus_dacs,
8553         },
8554         [ALC295_FIXUP_HP_OMEN] = {
8555                 .type = HDA_FIXUP_PINS,
8556                 .v.pins = (const struct hda_pintbl[]) {
8557                         { 0x12, 0xb7a60130 },
8558                         { 0x13, 0x40000000 },
8559                         { 0x14, 0x411111f0 },
8560                         { 0x16, 0x411111f0 },
8561                         { 0x17, 0x90170110 },
8562                         { 0x18, 0x411111f0 },
8563                         { 0x19, 0x02a11030 },
8564                         { 0x1a, 0x411111f0 },
8565                         { 0x1b, 0x04a19030 },
8566                         { 0x1d, 0x40600001 },
8567                         { 0x1e, 0x411111f0 },
8568                         { 0x21, 0x03211020 },
8569                         {}
8570                 },
8571                 .chained = true,
8572                 .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
8573         },
8574         [ALC285_FIXUP_HP_SPECTRE_X360] = {
8575                 .type = HDA_FIXUP_FUNC,
8576                 .v.func = alc285_fixup_hp_spectre_x360,
8577         },
8578         [ALC285_FIXUP_HP_SPECTRE_X360_EB1] = {
8579                 .type = HDA_FIXUP_FUNC,
8580                 .v.func = alc285_fixup_hp_spectre_x360_eb1
8581         },
8582         [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = {
8583                 .type = HDA_FIXUP_FUNC,
8584                 .v.func = alc285_fixup_ideapad_s740_coef,
8585                 .chained = true,
8586                 .chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK,
8587         },
8588         [ALC623_FIXUP_LENOVO_THINKSTATION_P340] = {
8589                 .type = HDA_FIXUP_FUNC,
8590                 .v.func = alc_fixup_no_shutup,
8591                 .chained = true,
8592                 .chain_id = ALC283_FIXUP_HEADSET_MIC,
8593         },
8594         [ALC255_FIXUP_ACER_HEADPHONE_AND_MIC] = {
8595                 .type = HDA_FIXUP_PINS,
8596                 .v.pins = (const struct hda_pintbl[]) {
8597                         { 0x21, 0x03211030 }, /* Change the Headphone location to Left */
8598                         { }
8599                 },
8600                 .chained = true,
8601                 .chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC
8602         },
8603         [ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8604                 .type = HDA_FIXUP_FUNC,
8605                 .v.func = alc269_fixup_limit_int_mic_boost,
8606                 .chained = true,
8607                 .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
8608         },
8609         [ALC285_FIXUP_LEGION_Y9000X_SPEAKERS] = {
8610                 .type = HDA_FIXUP_FUNC,
8611                 .v.func = alc285_fixup_ideapad_s740_coef,
8612                 .chained = true,
8613                 .chain_id = ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
8614         },
8615         [ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE] = {
8616                 .type = HDA_FIXUP_FUNC,
8617                 .v.func = alc287_fixup_legion_15imhg05_speakers,
8618                 .chained = true,
8619                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8620         },
8621         [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
8622                 .type = HDA_FIXUP_VERBS,
8623                 //.v.verbs = legion_15imhg05_coefs,
8624                 .v.verbs = (const struct hda_verb[]) {
8625                          // set left speaker Legion 7i.
8626                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8627                          { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8628
8629                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8630                          { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8631                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8632                          { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8633                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8634
8635                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8636                          { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8637                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8638                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8639                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8640
8641                          // set right speaker Legion 7i.
8642                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8643                          { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8644
8645                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8646                          { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8647                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8648                          { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8649                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8650
8651                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8652                          { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8653                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8654                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8655                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8656                          {}
8657                 },
8658                 .chained = true,
8659                 .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
8660         },
8661         [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
8662                 .type = HDA_FIXUP_FUNC,
8663                 .v.func = alc287_fixup_legion_15imhg05_speakers,
8664                 .chained = true,
8665                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
8666         },
8667         [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
8668                 .type = HDA_FIXUP_VERBS,
8669                 .v.verbs = (const struct hda_verb[]) {
8670                          // set left speaker Yoga 7i.
8671                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8672                          { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8673
8674                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8675                          { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8676                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8677                          { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8678                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8679
8680                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8681                          { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8682                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8683                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8684                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8685
8686                          // set right speaker Yoga 7i.
8687                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8688                          { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
8689
8690                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8691                          { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8692                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8693                          { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8694                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8695
8696                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8697                          { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8698                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8699                          { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8700                          { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8701                          {}
8702                 },
8703                 .chained = true,
8704                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
8705         },
8706         [ALC298_FIXUP_LENOVO_C940_DUET7] = {
8707                 .type = HDA_FIXUP_FUNC,
8708                 .v.func = alc298_fixup_lenovo_c940_duet7,
8709         },
8710         [ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
8711                 .type = HDA_FIXUP_VERBS,
8712                 .v.verbs = (const struct hda_verb[]) {
8713                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8714                         { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8715                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8716                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8717                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8718                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8719                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8720                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8721                         { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8722                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8723                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8724                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8725                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8726                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8727                         {}
8728                 },
8729                 .chained = true,
8730                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
8731         },
8732         [ALC256_FIXUP_SET_COEF_DEFAULTS] = {
8733                 .type = HDA_FIXUP_FUNC,
8734                 .v.func = alc256_fixup_set_coef_defaults,
8735         },
8736         [ALC245_FIXUP_HP_GPIO_LED] = {
8737                 .type = HDA_FIXUP_FUNC,
8738                 .v.func = alc245_fixup_hp_gpio_led,
8739         },
8740         [ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
8741                 .type = HDA_FIXUP_PINS,
8742                 .v.pins = (const struct hda_pintbl[]) {
8743                         { 0x19, 0x03a11120 }, /* use as headset mic, without its own jack detect */
8744                         { }
8745                 },
8746                 .chained = true,
8747                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
8748         },
8749         [ALC233_FIXUP_NO_AUDIO_JACK] = {
8750                 .type = HDA_FIXUP_FUNC,
8751                 .v.func = alc233_fixup_no_audio_jack,
8752         },
8753         [ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME] = {
8754                 .type = HDA_FIXUP_FUNC,
8755                 .v.func = alc256_fixup_mic_no_presence_and_resume,
8756                 .chained = true,
8757                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8758         },
8759         [ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED] = {
8760                 .type = HDA_FIXUP_VERBS,
8761                 .v.verbs = (const struct hda_verb[]) {
8762                          { 0x20, AC_VERB_SET_COEF_INDEX, 0x19 },
8763                          { 0x20, AC_VERB_SET_PROC_COEF, 0x8e11 },
8764                          { }
8765                 },
8766                 .chained = true,
8767                 .chain_id = ALC285_FIXUP_HP_MUTE_LED,
8768         },
8769 };
8770
8771 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
8772         SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
8773         SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
8774         SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
8775         SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
8776         SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8777         SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
8778         SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
8779         SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8780         SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8781         SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
8782         SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8783         SND_PCI_QUIRK(0x1025, 0x0840, "Acer Aspire E1", ALC269VB_FIXUP_ASPIRE_E1_COEF),
8784         SND_PCI_QUIRK(0x1025, 0x101c, "Acer Veriton N2510G", ALC269_FIXUP_LIFEBOOK),
8785         SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
8786         SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
8787         SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
8788         SND_PCI_QUIRK(0x1025, 0x1094, "Acer Aspire E5-575T", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST),
8789         SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8790         SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8791         SND_PCI_QUIRK(0x1025, 0x1166, "Acer Veriton N4640G", ALC269_FIXUP_LIFEBOOK),
8792         SND_PCI_QUIRK(0x1025, 0x1167, "Acer Veriton N6640G", ALC269_FIXUP_LIFEBOOK),
8793         SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
8794         SND_PCI_QUIRK(0x1025, 0x1247, "Acer vCopperbox", ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS),
8795         SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
8796         SND_PCI_QUIRK(0x1025, 0x1269, "Acer SWIFT SF314-54", ALC256_FIXUP_ACER_HEADSET_MIC),
8797         SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8798         SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8799         SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8800         SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
8801         SND_PCI_QUIRK(0x1025, 0x129d, "Acer SWIFT SF313-51", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8802         SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8803         SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8804         SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
8805         SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
8806         SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8807         SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8808         SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8809         SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
8810         SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
8811         SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
8812         SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
8813         SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
8814         SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8815         SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
8816         SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
8817         SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
8818         SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8819         SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8820         SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8821         SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8822         SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8823         SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
8824         SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
8825         SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
8826         SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8827         SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8828         SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
8829         SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8830         SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8831         SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8832         SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8833         SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8834         SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8835         SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8836         SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8837         SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8838         SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8839         SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8840         SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
8841         SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
8842         SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
8843         SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
8844         SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8845         SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
8846         SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
8847         SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8848         SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8849         SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8850         SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8851         SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
8852         SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
8853         SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
8854         SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8855         SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8856         SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8857         SND_PCI_QUIRK(0x1028, 0x098d, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8858         SND_PCI_QUIRK(0x1028, 0x09bf, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8859         SND_PCI_QUIRK(0x1028, 0x0a2e, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
8860         SND_PCI_QUIRK(0x1028, 0x0a30, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
8861         SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC),
8862         SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK),
8863         SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK),
8864         SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8865         SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8866         SND_PCI_QUIRK(0x1028, 0x0b19, "Dell XPS 15 9520", ALC289_FIXUP_DUAL_SPK),
8867         SND_PCI_QUIRK(0x1028, 0x0b1a, "Dell Precision 5570", ALC289_FIXUP_DUAL_SPK),
8868         SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8869         SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8870         SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
8871         SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8872         SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
8873         SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8874         SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8875         SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8876         SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8877         SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
8878         SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8879         SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8880         SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8881         SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8882         SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8883         SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8884         SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8885         SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8886         SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8887         SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8888         SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8889         SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8890         SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8891         SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
8892         SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
8893         SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8894         SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8895         SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8896         SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8897         SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8898         SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8899         SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8900         SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8901         SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
8902         SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8903         SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
8904         SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8905         SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
8906         SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8907         SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8908         SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8909         SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8910         SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8911         SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8912         SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8913         SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8914         SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8915         SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8916         SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8917         SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8918         SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8919         SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8920         SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
8921         SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8922         SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8923         SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8924         SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8925         SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8926         SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8927         SND_PCI_QUIRK(0x103c, 0x2b5e, "HP 288 Pro G2 MT", ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE),
8928         SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8929         SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8930         SND_PCI_QUIRK(0x103c, 0x8077, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
8931         SND_PCI_QUIRK(0x103c, 0x8158, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
8932         SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8933         SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
8934         SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
8935         SND_PCI_QUIRK(0x103c, 0x827f, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8936         SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8937         SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8938         SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8939         SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8940         SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8941         SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
8942         SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8943         SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
8944         SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8945         SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8946         SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
8947         SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO),
8948         SND_PCI_QUIRK(0x103c, 0x86e7, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
8949         SND_PCI_QUIRK(0x103c, 0x86e8, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
8950         SND_PCI_QUIRK(0x103c, 0x8716, "HP Elite Dragonfly G2 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8951         SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8952         SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
8953         SND_PCI_QUIRK(0x103c, 0x8728, "HP EliteBook 840 G7", ALC285_FIXUP_HP_GPIO_LED),
8954         SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
8955         SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
8956         SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
8957         SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8958         SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
8959         SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
8960         SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
8961         SND_PCI_QUIRK(0x103c, 0x8780, "HP ZBook Fury 17 G7 Mobile Workstation",
8962                       ALC285_FIXUP_HP_GPIO_AMP_INIT),
8963         SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation",
8964                       ALC285_FIXUP_HP_GPIO_AMP_INIT),
8965         SND_PCI_QUIRK(0x103c, 0x8786, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
8966         SND_PCI_QUIRK(0x103c, 0x8787, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
8967         SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
8968         SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
8969         SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8970         SND_PCI_QUIRK(0x103c, 0x87e7, "HP ProBook 450 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8971         SND_PCI_QUIRK(0x103c, 0x87f1, "HP ProBook 630 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8972         SND_PCI_QUIRK(0x103c, 0x87f2, "HP ProBook 640 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8973         SND_PCI_QUIRK(0x103c, 0x87f4, "HP", ALC287_FIXUP_HP_GPIO_LED),
8974         SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED),
8975         SND_PCI_QUIRK(0x103c, 0x87f6, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
8976         SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
8977         SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8978         SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8979         SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
8980         SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
8981         SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8982         SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8983         SND_PCI_QUIRK(0x103c, 0x884b, "HP EliteBook 840 Aero G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8984         SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8985         SND_PCI_QUIRK(0x103c, 0x8862, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8986         SND_PCI_QUIRK(0x103c, 0x8863, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8987         SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8988         SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8989         SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8990         SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED),
8991         SND_PCI_QUIRK(0x103c, 0x8895, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED),
8992         SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
8993         SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8994         SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
8995         SND_PCI_QUIRK(0x103c, 0x89aa, "HP EliteBook 630 G9", ALC236_FIXUP_HP_GPIO_LED),
8996         SND_PCI_QUIRK(0x103c, 0x89c3, "HP", ALC285_FIXUP_HP_GPIO_LED),
8997         SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
8998         SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8999         SND_PCI_QUIRK(0x103c, 0x8aa0, "HP ProBook 440 G9 (MB 8A9E)", ALC236_FIXUP_HP_GPIO_LED),
9000         SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED),
9001         SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED),
9002         SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED),
9003         SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
9004         SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
9005         SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9006         SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
9007         SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
9008         SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9009         SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9010         SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9011         SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9012         SND_PCI_QUIRK(0x1043, 0x1271, "ASUS X430UN", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
9013         SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9014         SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9015         SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
9016         SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
9017         SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE),
9018         SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
9019         SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
9020         SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
9021         SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK),
9022         SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
9023         SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
9024         SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS),
9025         SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
9026         SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
9027         SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
9028         SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
9029         SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE),
9030         SND_PCI_QUIRK(0x1043, 0x1970, "ASUS UX550VE", ALC289_FIXUP_ASUS_GA401),
9031         SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE),
9032         SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
9033         SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
9034         SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
9035         SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
9036         SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
9037         SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
9038         SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
9039         SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9040         SND_PCI_QUIRK(0x1043, 0x1c92, "ASUS ROG Strix G15", ALC285_FIXUP_ASUS_G533Z_PINS),
9041         SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
9042         SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401),
9043         SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
9044         SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
9045         SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS),
9046         SND_PCI_QUIRK(0x1043, 0x1e5e, "ASUS ROG Strix G513", ALC294_FIXUP_ASUS_G513_PINS),
9047         SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
9048         SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401),
9049         SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
9050         SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401),
9051         SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
9052         SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
9053         SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
9054         SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
9055         SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
9056         SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
9057         SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
9058         SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
9059         SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
9060         SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
9061         SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9062         SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
9063         SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
9064         SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
9065         SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
9066         SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
9067         SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
9068         SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
9069         SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
9070         SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
9071         SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9072         SND_PCI_QUIRK(0x10ec, 0x124c, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9073         SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9074         SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
9075         SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
9076         SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
9077         SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9078         SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_AMP),
9079         SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_AMP),
9080         SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9081         SND_PCI_QUIRK(0x144d, 0xc1a3, "Samsung Galaxy Book Pro (NP935XDB-KC1SE)", ALC298_FIXUP_SAMSUNG_AMP),
9082         SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
9083         SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_AMP),
9084         SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
9085         SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9086         SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
9087         SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
9088         SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
9089         SND_PCI_QUIRK(0x152d, 0x1082, "Quanta NL3", ALC269_FIXUP_LIFEBOOK),
9090         SND_PCI_QUIRK(0x1558, 0x1323, "Clevo N130ZU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9091         SND_PCI_QUIRK(0x1558, 0x1325, "Clevo N15[01][CW]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9092         SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9093         SND_PCI_QUIRK(0x1558, 0x1403, "Clevo N140CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9094         SND_PCI_QUIRK(0x1558, 0x1404, "Clevo N150CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9095         SND_PCI_QUIRK(0x1558, 0x14a1, "Clevo L141MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9096         SND_PCI_QUIRK(0x1558, 0x4018, "Clevo NV40M[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9097         SND_PCI_QUIRK(0x1558, 0x4019, "Clevo NV40MZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9098         SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9099         SND_PCI_QUIRK(0x1558, 0x4041, "Clevo NV4[15]PZ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9100         SND_PCI_QUIRK(0x1558, 0x40a1, "Clevo NL40GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9101         SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9102         SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9103         SND_PCI_QUIRK(0x1558, 0x5015, "Clevo NH5[58]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9104         SND_PCI_QUIRK(0x1558, 0x5017, "Clevo NH7[79]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9105         SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9106         SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9107         SND_PCI_QUIRK(0x1558, 0x50b6, "Clevo NK50S5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9108         SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9109         SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9110         SND_PCI_QUIRK(0x1558, 0x50e1, "Clevo NH5[58]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9111         SND_PCI_QUIRK(0x1558, 0x50e2, "Clevo NH7[79]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9112         SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9113         SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9114         SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9115         SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9116         SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9117         SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9118         SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9119         SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9120         SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9121         SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9122         SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9123         SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9124         SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9125         SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9126         SND_PCI_QUIRK(0x1558, 0x7716, "Clevo NS50PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9127         SND_PCI_QUIRK(0x1558, 0x7717, "Clevo NS70PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9128         SND_PCI_QUIRK(0x1558, 0x7718, "Clevo L140PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9129         SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9130         SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9131         SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9132         SND_PCI_QUIRK(0x1558, 0x8535, "Clevo NH50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9133         SND_PCI_QUIRK(0x1558, 0x8536, "Clevo NH79D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9134         SND_PCI_QUIRK(0x1558, 0x8550, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9135         SND_PCI_QUIRK(0x1558, 0x8551, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9136         SND_PCI_QUIRK(0x1558, 0x8560, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
9137         SND_PCI_QUIRK(0x1558, 0x8561, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
9138         SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
9139         SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9140         SND_PCI_QUIRK(0x1558, 0x866d, "Clevo NP5[05]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9141         SND_PCI_QUIRK(0x1558, 0x867c, "Clevo NP7[01]PNP", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9142         SND_PCI_QUIRK(0x1558, 0x867d, "Clevo NP7[01]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9143         SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9144         SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME),
9145         SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9146         SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9147         SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9148         SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9149         SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9150         SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9151         SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9152         SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL5[03]RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9153         SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL50NU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9154         SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9155         SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9156         SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9157         SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9158         SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9159         SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9160         SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
9161         SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
9162         SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
9163         SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
9164         SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
9165         SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
9166         SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
9167         SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
9168         SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
9169         SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
9170         SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
9171         SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
9172         SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
9173         SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
9174         SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
9175         SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
9176         SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
9177         SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
9178         SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
9179         SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9180         SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
9181         SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
9182         SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
9183         SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9184         SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9185         SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
9186         SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
9187         SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
9188         SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9189         SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9190         SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
9191         SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9192         SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9193         SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9194         SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9195         SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
9196         SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
9197         SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
9198         SND_PCI_QUIRK(0x17aa, 0x22c2, "Thinkpad X1 Extreme Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
9199         SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
9200         SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
9201         SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9202         SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9203         SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9204         SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9205         SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
9206         SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9207         SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9208         SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
9209         SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
9210         SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo Yoga DuetITL 2021", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9211         SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9212         SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940 / Yoga Duet 7", ALC298_FIXUP_LENOVO_C940_DUET7),
9213         SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
9214         SND_PCI_QUIRK(0x17aa, 0x3820, "Yoga Duet 7 13ITL6", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9215         SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
9216         SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
9217         SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9218         SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
9219         SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
9220         SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9221         SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9222         SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
9223         SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
9224         SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
9225         SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
9226         SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
9227         SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9228         SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
9229         SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
9230         SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9231         SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
9232         SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
9233         SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
9234         SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
9235         SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
9236         SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
9237         SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
9238         SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
9239         SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9240         SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9241         SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9242         SND_PCI_QUIRK(0x17aa, 0x508b, "Thinkpad X12 Gen 1", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
9243         SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9244         SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9245         SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
9246         SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
9247         SND_PCI_QUIRK(0x1849, 0x1233, "ASRock NUC Box 1100", ALC233_FIXUP_NO_AUDIO_JACK),
9248         SND_PCI_QUIRK(0x1849, 0xa233, "Positivo Master C6300", ALC269_FIXUP_HEADSET_MIC),
9249         SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
9250         SND_PCI_QUIRK(0x19e5, 0x320f, "Huawei WRT-WX9 ", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
9251         SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20),
9252         SND_PCI_QUIRK(0x1b35, 0x1236, "CZC TMI", ALC269_FIXUP_CZC_TMI),
9253         SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
9254         SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
9255         SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
9256         SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
9257         SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_SET_COEF_DEFAULTS),
9258         SND_PCI_QUIRK(0x1d05, 0x1096, "TongFang GMxMRxx", ALC269_FIXUP_NO_SHUTUP),
9259         SND_PCI_QUIRK(0x1d05, 0x1100, "TongFang GKxNRxx", ALC269_FIXUP_NO_SHUTUP),
9260         SND_PCI_QUIRK(0x1d05, 0x1111, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9261         SND_PCI_QUIRK(0x1d05, 0x1119, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9262         SND_PCI_QUIRK(0x1d05, 0x1129, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
9263         SND_PCI_QUIRK(0x1d05, 0x1147, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
9264         SND_PCI_QUIRK(0x1d05, 0x115c, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
9265         SND_PCI_QUIRK(0x1d05, 0x121b, "TongFang GMxAGxx", ALC269_FIXUP_NO_SHUTUP),
9266         SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
9267         SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
9268         SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
9269         SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC),
9270         SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
9271         SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
9272         SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
9273         SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10),
9274
9275 #if 0
9276         /* Below is a quirk table taken from the old code.
9277          * Basically the device should work as is without the fixup table.
9278          * If BIOS doesn't give a proper info, enable the corresponding
9279          * fixup entry.
9280          */
9281         SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
9282                       ALC269_FIXUP_AMIC),
9283         SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
9284         SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
9285         SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
9286         SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
9287         SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
9288         SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
9289         SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
9290         SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
9291         SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
9292         SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
9293         SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
9294         SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
9295         SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
9296         SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
9297         SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
9298         SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
9299         SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
9300         SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
9301         SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
9302         SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
9303         SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
9304         SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
9305         SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
9306         SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
9307         SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
9308         SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
9309         SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
9310         SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
9311         SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
9312         SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
9313         SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
9314         SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
9315         SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
9316         SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
9317         SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
9318         SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
9319         SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
9320         SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
9321         SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
9322 #endif
9323         {}
9324 };
9325
9326 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
9327         SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
9328         SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
9329         SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
9330         SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
9331         SND_PCI_QUIRK_VENDOR(0x19e5, "Huawei Matebook", ALC255_FIXUP_MIC_MUTE_LED),
9332         {}
9333 };
9334
9335 static const struct hda_model_fixup alc269_fixup_models[] = {
9336         {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
9337         {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
9338         {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
9339         {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
9340         {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
9341         {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
9342         {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
9343         {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
9344         {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9345         {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
9346         {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9347         {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
9348         {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
9349         {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
9350         {.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
9351         {.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
9352         {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
9353         {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
9354         {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
9355         {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
9356         {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
9357         {.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
9358         {.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
9359         {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
9360         {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
9361         {.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
9362         {.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
9363         {.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
9364         {.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
9365         {.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
9366         {.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
9367         {.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
9368         {.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
9369         {.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
9370         {.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
9371         {.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
9372         {.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
9373         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
9374         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
9375         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
9376         {.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
9377         {.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
9378         {.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
9379         {.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
9380         {.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
9381         {.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
9382         {.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
9383         {.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
9384         {.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
9385         {.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
9386         {.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
9387         {.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
9388         {.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
9389         {.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
9390         {.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
9391         {.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
9392         {.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
9393         {.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
9394         {.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
9395         {.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
9396         {.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
9397         {.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
9398         {.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
9399         {.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
9400         {.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
9401         {.id = ALC255_FIXUP_MIC_MUTE_LED, .name = "alc255-dell-mute"},
9402         {.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
9403         {.id = ALC269VB_FIXUP_ASPIRE_E1_COEF, .name = "aspire-e1-coef"},
9404         {.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
9405         {.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9406         {.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
9407         {.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
9408         {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
9409         {.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
9410         {.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
9411         {.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
9412         {.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
9413         {.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
9414         {.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
9415         {.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
9416         {.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
9417         {.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
9418         {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
9419         {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
9420         {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
9421         {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
9422         {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
9423         {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
9424         {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
9425         {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
9426         {.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
9427         {.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
9428         {.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
9429         {.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
9430         {.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
9431         {.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
9432         {.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
9433         {.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
9434         {.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
9435         {.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
9436         {.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
9437         {.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
9438         {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
9439         {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
9440         {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
9441         {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
9442         {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
9443         {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
9444         {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
9445         {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
9446         {.id = ALC298_FIXUP_SAMSUNG_AMP, .name = "alc298-samsung-amp"},
9447         {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
9448         {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
9449         {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
9450         {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
9451         {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
9452         {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
9453         {.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"},
9454         {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
9455         {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
9456         {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
9457         {.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"},
9458         {}
9459 };
9460 #define ALC225_STANDARD_PINS \
9461         {0x21, 0x04211020}
9462
9463 #define ALC256_STANDARD_PINS \
9464         {0x12, 0x90a60140}, \
9465         {0x14, 0x90170110}, \
9466         {0x21, 0x02211020}
9467
9468 #define ALC282_STANDARD_PINS \
9469         {0x14, 0x90170110}
9470
9471 #define ALC290_STANDARD_PINS \
9472         {0x12, 0x99a30130}
9473
9474 #define ALC292_STANDARD_PINS \
9475         {0x14, 0x90170110}, \
9476         {0x15, 0x0221401f}
9477
9478 #define ALC295_STANDARD_PINS \
9479         {0x12, 0xb7a60130}, \
9480         {0x14, 0x90170110}, \
9481         {0x21, 0x04211020}
9482
9483 #define ALC298_STANDARD_PINS \
9484         {0x12, 0x90a60130}, \
9485         {0x21, 0x03211020}
9486
9487 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
9488         SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
9489                 {0x14, 0x01014020},
9490                 {0x17, 0x90170110},
9491                 {0x18, 0x02a11030},
9492                 {0x19, 0x0181303F},
9493                 {0x21, 0x0221102f}),
9494         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
9495                 {0x12, 0x90a601c0},
9496                 {0x14, 0x90171120},
9497                 {0x21, 0x02211030}),
9498         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9499                 {0x14, 0x90170110},
9500                 {0x1b, 0x90a70130},
9501                 {0x21, 0x03211020}),
9502         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9503                 {0x1a, 0x90a70130},
9504                 {0x1b, 0x90170110},
9505                 {0x21, 0x03211020}),
9506         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9507                 ALC225_STANDARD_PINS,
9508                 {0x12, 0xb7a60130},
9509                 {0x14, 0x901701a0}),
9510         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9511                 ALC225_STANDARD_PINS,
9512                 {0x12, 0xb7a60130},
9513                 {0x14, 0x901701b0}),
9514         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9515                 ALC225_STANDARD_PINS,
9516                 {0x12, 0xb7a60150},
9517                 {0x14, 0x901701a0}),
9518         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9519                 ALC225_STANDARD_PINS,
9520                 {0x12, 0xb7a60150},
9521                 {0x14, 0x901701b0}),
9522         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9523                 ALC225_STANDARD_PINS,
9524                 {0x12, 0xb7a60130},
9525                 {0x1b, 0x90170110}),
9526         SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9527                 {0x1b, 0x01111010},
9528                 {0x1e, 0x01451130},
9529                 {0x21, 0x02211020}),
9530         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
9531                 {0x12, 0x90a60140},
9532                 {0x14, 0x90170110},
9533                 {0x19, 0x02a11030},
9534                 {0x21, 0x02211020}),
9535         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9536                 {0x14, 0x90170110},
9537                 {0x19, 0x02a11030},
9538                 {0x1a, 0x02a11040},
9539                 {0x1b, 0x01014020},
9540                 {0x21, 0x0221101f}),
9541         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9542                 {0x14, 0x90170110},
9543                 {0x19, 0x02a11030},
9544                 {0x1a, 0x02a11040},
9545                 {0x1b, 0x01011020},
9546                 {0x21, 0x0221101f}),
9547         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9548                 {0x14, 0x90170110},
9549                 {0x19, 0x02a11020},
9550                 {0x1a, 0x02a11030},
9551                 {0x21, 0x0221101f}),
9552         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
9553                 {0x21, 0x02211010}),
9554         SND_HDA_PIN_QUIRK(0x10ec0236, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9555                 {0x14, 0x90170110},
9556                 {0x19, 0x02a11020},
9557                 {0x21, 0x02211030}),
9558         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9559                 {0x14, 0x90170110},
9560                 {0x21, 0x02211020}),
9561         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9562                 {0x14, 0x90170130},
9563                 {0x21, 0x02211040}),
9564         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9565                 {0x12, 0x90a60140},
9566                 {0x14, 0x90170110},
9567                 {0x21, 0x02211020}),
9568         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9569                 {0x12, 0x90a60160},
9570                 {0x14, 0x90170120},
9571                 {0x21, 0x02211030}),
9572         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9573                 {0x14, 0x90170110},
9574                 {0x1b, 0x02011020},
9575                 {0x21, 0x0221101f}),
9576         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9577                 {0x14, 0x90170110},
9578                 {0x1b, 0x01011020},
9579                 {0x21, 0x0221101f}),
9580         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9581                 {0x14, 0x90170130},
9582                 {0x1b, 0x01014020},
9583                 {0x21, 0x0221103f}),
9584         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9585                 {0x14, 0x90170130},
9586                 {0x1b, 0x01011020},
9587                 {0x21, 0x0221103f}),
9588         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9589                 {0x14, 0x90170130},
9590                 {0x1b, 0x02011020},
9591                 {0x21, 0x0221103f}),
9592         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9593                 {0x14, 0x90170150},
9594                 {0x1b, 0x02011020},
9595                 {0x21, 0x0221105f}),
9596         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9597                 {0x14, 0x90170110},
9598                 {0x1b, 0x01014020},
9599                 {0x21, 0x0221101f}),
9600         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9601                 {0x12, 0x90a60160},
9602                 {0x14, 0x90170120},
9603                 {0x17, 0x90170140},
9604                 {0x21, 0x0321102f}),
9605         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9606                 {0x12, 0x90a60160},
9607                 {0x14, 0x90170130},
9608                 {0x21, 0x02211040}),
9609         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9610                 {0x12, 0x90a60160},
9611                 {0x14, 0x90170140},
9612                 {0x21, 0x02211050}),
9613         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9614                 {0x12, 0x90a60170},
9615                 {0x14, 0x90170120},
9616                 {0x21, 0x02211030}),
9617         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9618                 {0x12, 0x90a60170},
9619                 {0x14, 0x90170130},
9620                 {0x21, 0x02211040}),
9621         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9622                 {0x12, 0x90a60170},
9623                 {0x14, 0x90171130},
9624                 {0x21, 0x02211040}),
9625         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9626                 {0x12, 0x90a60170},
9627                 {0x14, 0x90170140},
9628                 {0x21, 0x02211050}),
9629         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9630                 {0x12, 0x90a60180},
9631                 {0x14, 0x90170130},
9632                 {0x21, 0x02211040}),
9633         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9634                 {0x12, 0x90a60180},
9635                 {0x14, 0x90170120},
9636                 {0x21, 0x02211030}),
9637         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9638                 {0x1b, 0x01011020},
9639                 {0x21, 0x02211010}),
9640         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9641                 {0x14, 0x90170110},
9642                 {0x1b, 0x90a70130},
9643                 {0x21, 0x04211020}),
9644         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9645                 {0x14, 0x90170110},
9646                 {0x1b, 0x90a70130},
9647                 {0x21, 0x03211020}),
9648         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9649                 {0x12, 0x90a60130},
9650                 {0x14, 0x90170110},
9651                 {0x21, 0x03211020}),
9652         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9653                 {0x12, 0x90a60130},
9654                 {0x14, 0x90170110},
9655                 {0x21, 0x04211020}),
9656         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9657                 {0x1a, 0x90a70130},
9658                 {0x1b, 0x90170110},
9659                 {0x21, 0x03211020}),
9660        SND_HDA_PIN_QUIRK(0x10ec0256, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9661                 {0x14, 0x90170110},
9662                 {0x19, 0x02a11020},
9663                 {0x21, 0x0221101f}),
9664        SND_HDA_PIN_QUIRK(0x10ec0274, 0x103c, "HP", ALC274_FIXUP_HP_HEADSET_MIC,
9665                 {0x17, 0x90170110},
9666                 {0x19, 0x03a11030},
9667                 {0x21, 0x03211020}),
9668         SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
9669                 {0x12, 0x90a60130},
9670                 {0x14, 0x90170110},
9671                 {0x15, 0x0421101f},
9672                 {0x1a, 0x04a11020}),
9673         SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
9674                 {0x12, 0x90a60140},
9675                 {0x14, 0x90170110},
9676                 {0x15, 0x0421101f},
9677                 {0x18, 0x02811030},
9678                 {0x1a, 0x04a1103f},
9679                 {0x1b, 0x02011020}),
9680         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9681                 ALC282_STANDARD_PINS,
9682                 {0x12, 0x99a30130},
9683                 {0x19, 0x03a11020},
9684                 {0x21, 0x0321101f}),
9685         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9686                 ALC282_STANDARD_PINS,
9687                 {0x12, 0x99a30130},
9688                 {0x19, 0x03a11020},
9689                 {0x21, 0x03211040}),
9690         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9691                 ALC282_STANDARD_PINS,
9692                 {0x12, 0x99a30130},
9693                 {0x19, 0x03a11030},
9694                 {0x21, 0x03211020}),
9695         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9696                 ALC282_STANDARD_PINS,
9697                 {0x12, 0x99a30130},
9698                 {0x19, 0x04a11020},
9699                 {0x21, 0x0421101f}),
9700         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
9701                 ALC282_STANDARD_PINS,
9702                 {0x12, 0x90a60140},
9703                 {0x19, 0x04a11030},
9704                 {0x21, 0x04211020}),
9705         SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9706                 ALC282_STANDARD_PINS,
9707                 {0x12, 0x90a609c0},
9708                 {0x18, 0x03a11830},
9709                 {0x19, 0x04a19831},
9710                 {0x1a, 0x0481303f},
9711                 {0x1b, 0x04211020},
9712                 {0x21, 0x0321101f}),
9713         SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9714                 ALC282_STANDARD_PINS,
9715                 {0x12, 0x90a60940},
9716                 {0x18, 0x03a11830},
9717                 {0x19, 0x04a19831},
9718                 {0x1a, 0x0481303f},
9719                 {0x1b, 0x04211020},
9720                 {0x21, 0x0321101f}),
9721         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9722                 ALC282_STANDARD_PINS,
9723                 {0x12, 0x90a60130},
9724                 {0x21, 0x0321101f}),
9725         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9726                 {0x12, 0x90a60160},
9727                 {0x14, 0x90170120},
9728                 {0x21, 0x02211030}),
9729         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9730                 ALC282_STANDARD_PINS,
9731                 {0x12, 0x90a60130},
9732                 {0x19, 0x03a11020},
9733                 {0x21, 0x0321101f}),
9734         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
9735                 {0x12, 0x90a60130},
9736                 {0x14, 0x90170110},
9737                 {0x19, 0x04a11040},
9738                 {0x21, 0x04211020}),
9739         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
9740                 {0x14, 0x90170110},
9741                 {0x19, 0x04a11040},
9742                 {0x1d, 0x40600001},
9743                 {0x21, 0x04211020}),
9744         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
9745                 {0x14, 0x90170110},
9746                 {0x19, 0x04a11040},
9747                 {0x21, 0x04211020}),
9748         SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_HEADSET_JACK,
9749                 {0x14, 0x90170110},
9750                 {0x17, 0x90170111},
9751                 {0x19, 0x03a11030},
9752                 {0x21, 0x03211020}),
9753         SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
9754                 {0x12, 0x90a60130},
9755                 {0x17, 0x90170110},
9756                 {0x21, 0x02211020}),
9757         SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
9758                 {0x12, 0x90a60120},
9759                 {0x14, 0x90170110},
9760                 {0x21, 0x0321101f}),
9761         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9762                 ALC290_STANDARD_PINS,
9763                 {0x15, 0x04211040},
9764                 {0x18, 0x90170112},
9765                 {0x1a, 0x04a11020}),
9766         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9767                 ALC290_STANDARD_PINS,
9768                 {0x15, 0x04211040},
9769                 {0x18, 0x90170110},
9770                 {0x1a, 0x04a11020}),
9771         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9772                 ALC290_STANDARD_PINS,
9773                 {0x15, 0x0421101f},
9774                 {0x1a, 0x04a11020}),
9775         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9776                 ALC290_STANDARD_PINS,
9777                 {0x15, 0x04211020},
9778                 {0x1a, 0x04a11040}),
9779         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9780                 ALC290_STANDARD_PINS,
9781                 {0x14, 0x90170110},
9782                 {0x15, 0x04211020},
9783                 {0x1a, 0x04a11040}),
9784         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9785                 ALC290_STANDARD_PINS,
9786                 {0x14, 0x90170110},
9787                 {0x15, 0x04211020},
9788                 {0x1a, 0x04a11020}),
9789         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9790                 ALC290_STANDARD_PINS,
9791                 {0x14, 0x90170110},
9792                 {0x15, 0x0421101f},
9793                 {0x1a, 0x04a11020}),
9794         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9795                 ALC292_STANDARD_PINS,
9796                 {0x12, 0x90a60140},
9797                 {0x16, 0x01014020},
9798                 {0x19, 0x01a19030}),
9799         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9800                 ALC292_STANDARD_PINS,
9801                 {0x12, 0x90a60140},
9802                 {0x16, 0x01014020},
9803                 {0x18, 0x02a19031},
9804                 {0x19, 0x01a1903e}),
9805         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
9806                 ALC292_STANDARD_PINS,
9807                 {0x12, 0x90a60140}),
9808         SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9809                 ALC292_STANDARD_PINS,
9810                 {0x13, 0x90a60140},
9811                 {0x16, 0x21014020},
9812                 {0x19, 0x21a19030}),
9813         SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9814                 ALC292_STANDARD_PINS,
9815                 {0x13, 0x90a60140}),
9816         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_HPE,
9817                 {0x17, 0x90170110},
9818                 {0x21, 0x04211020}),
9819         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
9820                 {0x14, 0x90170110},
9821                 {0x1b, 0x90a70130},
9822                 {0x21, 0x04211020}),
9823         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9824                 {0x12, 0x90a60130},
9825                 {0x17, 0x90170110},
9826                 {0x21, 0x03211020}),
9827         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9828                 {0x12, 0x90a60130},
9829                 {0x17, 0x90170110},
9830                 {0x21, 0x04211020}),
9831         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9832                 {0x12, 0x90a60130},
9833                 {0x17, 0x90170110},
9834                 {0x21, 0x03211020}),
9835         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9836                 {0x12, 0x90a60120},
9837                 {0x17, 0x90170110},
9838                 {0x21, 0x04211030}),
9839         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9840                 {0x12, 0x90a60130},
9841                 {0x17, 0x90170110},
9842                 {0x21, 0x03211020}),
9843         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9844                 {0x12, 0x90a60130},
9845                 {0x17, 0x90170110},
9846                 {0x21, 0x03211020}),
9847         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9848                 {0x14, 0x90170110},
9849                 {0x21, 0x04211020}),
9850         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9851                 {0x14, 0x90170110},
9852                 {0x21, 0x04211030}),
9853         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9854                 ALC295_STANDARD_PINS,
9855                 {0x17, 0x21014020},
9856                 {0x18, 0x21a19030}),
9857         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9858                 ALC295_STANDARD_PINS,
9859                 {0x17, 0x21014040},
9860                 {0x18, 0x21a19050}),
9861         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9862                 ALC295_STANDARD_PINS),
9863         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9864                 ALC298_STANDARD_PINS,
9865                 {0x17, 0x90170110}),
9866         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9867                 ALC298_STANDARD_PINS,
9868                 {0x17, 0x90170140}),
9869         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9870                 ALC298_STANDARD_PINS,
9871                 {0x17, 0x90170150}),
9872         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
9873                 {0x12, 0xb7a60140},
9874                 {0x13, 0xb7a60150},
9875                 {0x17, 0x90170110},
9876                 {0x1a, 0x03011020},
9877                 {0x21, 0x03211030}),
9878         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
9879                 {0x12, 0xb7a60140},
9880                 {0x17, 0x90170110},
9881                 {0x1a, 0x03a11030},
9882                 {0x21, 0x03211020}),
9883         SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9884                 ALC225_STANDARD_PINS,
9885                 {0x12, 0xb7a60130},
9886                 {0x17, 0x90170110}),
9887         SND_HDA_PIN_QUIRK(0x10ec0623, 0x17aa, "Lenovo", ALC283_FIXUP_HEADSET_MIC,
9888                 {0x14, 0x01014010},
9889                 {0x17, 0x90170120},
9890                 {0x18, 0x02a11030},
9891                 {0x19, 0x02a1103f},
9892                 {0x21, 0x0221101f}),
9893         {}
9894 };
9895
9896 /* This is the fallback pin_fixup_tbl for alc269 family, to make the tbl match
9897  * more machines, don't need to match all valid pins, just need to match
9898  * all the pins defined in the tbl. Just because of this reason, it is possible
9899  * that a single machine matches multiple tbls, so there is one limitation:
9900  *   at most one tbl is allowed to define for the same vendor and same codec
9901  */
9902 static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
9903         SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9904                 {0x19, 0x40000000},
9905                 {0x1b, 0x40000000}),
9906         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9907                 {0x19, 0x40000000},
9908                 {0x1a, 0x40000000}),
9909         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9910                 {0x19, 0x40000000},
9911                 {0x1a, 0x40000000}),
9912         SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
9913                 {0x19, 0x40000000},
9914                 {0x1a, 0x40000000}),
9915         {}
9916 };
9917
9918 static void alc269_fill_coef(struct hda_codec *codec)
9919 {
9920         struct alc_spec *spec = codec->spec;
9921         int val;
9922
9923         if (spec->codec_variant != ALC269_TYPE_ALC269VB)
9924                 return;
9925
9926         if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
9927                 alc_write_coef_idx(codec, 0xf, 0x960b);
9928                 alc_write_coef_idx(codec, 0xe, 0x8817);
9929         }
9930
9931         if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
9932                 alc_write_coef_idx(codec, 0xf, 0x960b);
9933                 alc_write_coef_idx(codec, 0xe, 0x8814);
9934         }
9935
9936         if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
9937                 /* Power up output pin */
9938                 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
9939         }
9940
9941         if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
9942                 val = alc_read_coef_idx(codec, 0xd);
9943                 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
9944                         /* Capless ramp up clock control */
9945                         alc_write_coef_idx(codec, 0xd, val | (1<<10));
9946                 }
9947                 val = alc_read_coef_idx(codec, 0x17);
9948                 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
9949                         /* Class D power on reset */
9950                         alc_write_coef_idx(codec, 0x17, val | (1<<7));
9951                 }
9952         }
9953
9954         /* HP */
9955         alc_update_coef_idx(codec, 0x4, 0, 1<<11);
9956 }
9957
9958 /*
9959  */
9960 static int patch_alc269(struct hda_codec *codec)
9961 {
9962         struct alc_spec *spec;
9963         int err;
9964
9965         err = alc_alloc_spec(codec, 0x0b);
9966         if (err < 0)
9967                 return err;
9968
9969         spec = codec->spec;
9970         spec->gen.shared_mic_vref_pin = 0x18;
9971         codec->power_save_node = 0;
9972
9973 #ifdef CONFIG_PM
9974         codec->patch_ops.suspend = alc269_suspend;
9975         codec->patch_ops.resume = alc269_resume;
9976 #endif
9977         spec->shutup = alc_default_shutup;
9978         spec->init_hook = alc_default_init;
9979
9980         switch (codec->core.vendor_id) {
9981         case 0x10ec0269:
9982                 spec->codec_variant = ALC269_TYPE_ALC269VA;
9983                 switch (alc_get_coef0(codec) & 0x00f0) {
9984                 case 0x0010:
9985                         if (codec->bus->pci &&
9986                             codec->bus->pci->subsystem_vendor == 0x1025 &&
9987                             spec->cdefine.platform_type == 1)
9988                                 err = alc_codec_rename(codec, "ALC271X");
9989                         spec->codec_variant = ALC269_TYPE_ALC269VB;
9990                         break;
9991                 case 0x0020:
9992                         if (codec->bus->pci &&
9993                             codec->bus->pci->subsystem_vendor == 0x17aa &&
9994                             codec->bus->pci->subsystem_device == 0x21f3)
9995                                 err = alc_codec_rename(codec, "ALC3202");
9996                         spec->codec_variant = ALC269_TYPE_ALC269VC;
9997                         break;
9998                 case 0x0030:
9999                         spec->codec_variant = ALC269_TYPE_ALC269VD;
10000                         break;
10001                 default:
10002                         alc_fix_pll_init(codec, 0x20, 0x04, 15);
10003                 }
10004                 if (err < 0)
10005                         goto error;
10006                 spec->shutup = alc269_shutup;
10007                 spec->init_hook = alc269_fill_coef;
10008                 alc269_fill_coef(codec);
10009                 break;
10010
10011         case 0x10ec0280:
10012         case 0x10ec0290:
10013                 spec->codec_variant = ALC269_TYPE_ALC280;
10014                 break;
10015         case 0x10ec0282:
10016                 spec->codec_variant = ALC269_TYPE_ALC282;
10017                 spec->shutup = alc282_shutup;
10018                 spec->init_hook = alc282_init;
10019                 break;
10020         case 0x10ec0233:
10021         case 0x10ec0283:
10022                 spec->codec_variant = ALC269_TYPE_ALC283;
10023                 spec->shutup = alc283_shutup;
10024                 spec->init_hook = alc283_init;
10025                 break;
10026         case 0x10ec0284:
10027         case 0x10ec0292:
10028                 spec->codec_variant = ALC269_TYPE_ALC284;
10029                 break;
10030         case 0x10ec0293:
10031                 spec->codec_variant = ALC269_TYPE_ALC293;
10032                 break;
10033         case 0x10ec0286:
10034         case 0x10ec0288:
10035                 spec->codec_variant = ALC269_TYPE_ALC286;
10036                 break;
10037         case 0x10ec0298:
10038                 spec->codec_variant = ALC269_TYPE_ALC298;
10039                 break;
10040         case 0x10ec0235:
10041         case 0x10ec0255:
10042                 spec->codec_variant = ALC269_TYPE_ALC255;
10043                 spec->shutup = alc256_shutup;
10044                 spec->init_hook = alc256_init;
10045                 break;
10046         case 0x10ec0230:
10047         case 0x10ec0236:
10048         case 0x10ec0256:
10049         case 0x19e58326:
10050                 spec->codec_variant = ALC269_TYPE_ALC256;
10051                 spec->shutup = alc256_shutup;
10052                 spec->init_hook = alc256_init;
10053                 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
10054                 break;
10055         case 0x10ec0257:
10056                 spec->codec_variant = ALC269_TYPE_ALC257;
10057                 spec->shutup = alc256_shutup;
10058                 spec->init_hook = alc256_init;
10059                 spec->gen.mixer_nid = 0;
10060                 break;
10061         case 0x10ec0215:
10062         case 0x10ec0245:
10063         case 0x10ec0285:
10064         case 0x10ec0289:
10065                 if (alc_get_coef0(codec) & 0x0010)
10066                         spec->codec_variant = ALC269_TYPE_ALC245;
10067                 else
10068                         spec->codec_variant = ALC269_TYPE_ALC215;
10069                 spec->shutup = alc225_shutup;
10070                 spec->init_hook = alc225_init;
10071                 spec->gen.mixer_nid = 0;
10072                 break;
10073         case 0x10ec0225:
10074         case 0x10ec0295:
10075         case 0x10ec0299:
10076                 spec->codec_variant = ALC269_TYPE_ALC225;
10077                 spec->shutup = alc225_shutup;
10078                 spec->init_hook = alc225_init;
10079                 spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
10080                 break;
10081         case 0x10ec0287:
10082                 spec->codec_variant = ALC269_TYPE_ALC287;
10083                 spec->shutup = alc225_shutup;
10084                 spec->init_hook = alc225_init;
10085                 spec->gen.mixer_nid = 0; /* no loopback on ALC287 */
10086                 break;
10087         case 0x10ec0234:
10088         case 0x10ec0274:
10089         case 0x10ec0294:
10090                 spec->codec_variant = ALC269_TYPE_ALC294;
10091                 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
10092                 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
10093                 spec->init_hook = alc294_init;
10094                 break;
10095         case 0x10ec0300:
10096                 spec->codec_variant = ALC269_TYPE_ALC300;
10097                 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
10098                 break;
10099         case 0x10ec0623:
10100                 spec->codec_variant = ALC269_TYPE_ALC623;
10101                 break;
10102         case 0x10ec0700:
10103         case 0x10ec0701:
10104         case 0x10ec0703:
10105         case 0x10ec0711:
10106                 spec->codec_variant = ALC269_TYPE_ALC700;
10107                 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
10108                 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
10109                 spec->init_hook = alc294_init;
10110                 break;
10111
10112         }
10113
10114         if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
10115                 spec->has_alc5505_dsp = 1;
10116                 spec->init_hook = alc5505_dsp_init;
10117         }
10118
10119         alc_pre_init(codec);
10120
10121         snd_hda_pick_fixup(codec, alc269_fixup_models,
10122                        alc269_fixup_tbl, alc269_fixups);
10123         /* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
10124          * the quirk breaks the latter (bko#214101).
10125          * Clear the wrong entry.
10126          */
10127         if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
10128             codec->core.vendor_id == 0x10ec0294) {
10129                 codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
10130                 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
10131         }
10132
10133         snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
10134         snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
10135         snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
10136                            alc269_fixups);
10137         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10138
10139         alc_auto_parse_customize_define(codec);
10140
10141         if (has_cdefine_beep(codec))
10142                 spec->gen.beep_nid = 0x01;
10143
10144         /* automatic parse from the BIOS config */
10145         err = alc269_parse_auto_config(codec);
10146         if (err < 0)
10147                 goto error;
10148
10149         if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
10150                 err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
10151                 if (err < 0)
10152                         goto error;
10153         }
10154
10155         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10156
10157         return 0;
10158
10159  error:
10160         alc_free(codec);
10161         return err;
10162 }
10163
10164 /*
10165  * ALC861
10166  */
10167
10168 static int alc861_parse_auto_config(struct hda_codec *codec)
10169 {
10170         static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10171         static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
10172         return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
10173 }
10174
10175 /* Pin config fixes */
10176 enum {
10177         ALC861_FIXUP_FSC_AMILO_PI1505,
10178         ALC861_FIXUP_AMP_VREF_0F,
10179         ALC861_FIXUP_NO_JACK_DETECT,
10180         ALC861_FIXUP_ASUS_A6RP,
10181         ALC660_FIXUP_ASUS_W7J,
10182 };
10183
10184 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
10185 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
10186                         const struct hda_fixup *fix, int action)
10187 {
10188         struct alc_spec *spec = codec->spec;
10189         unsigned int val;
10190
10191         if (action != HDA_FIXUP_ACT_INIT)
10192                 return;
10193         val = snd_hda_codec_get_pin_target(codec, 0x0f);
10194         if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
10195                 val |= AC_PINCTL_IN_EN;
10196         val |= AC_PINCTL_VREF_50;
10197         snd_hda_set_pin_ctl(codec, 0x0f, val);
10198         spec->gen.keep_vref_in_automute = 1;
10199 }
10200
10201 /* suppress the jack-detection */
10202 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
10203                                      const struct hda_fixup *fix, int action)
10204 {
10205         if (action == HDA_FIXUP_ACT_PRE_PROBE)
10206                 codec->no_jack_detect = 1;
10207 }
10208
10209 static const struct hda_fixup alc861_fixups[] = {
10210         [ALC861_FIXUP_FSC_AMILO_PI1505] = {
10211                 .type = HDA_FIXUP_PINS,
10212                 .v.pins = (const struct hda_pintbl[]) {
10213                         { 0x0b, 0x0221101f }, /* HP */
10214                         { 0x0f, 0x90170310 }, /* speaker */
10215                         { }
10216                 }
10217         },
10218         [ALC861_FIXUP_AMP_VREF_0F] = {
10219                 .type = HDA_FIXUP_FUNC,
10220                 .v.func = alc861_fixup_asus_amp_vref_0f,
10221         },
10222         [ALC861_FIXUP_NO_JACK_DETECT] = {
10223                 .type = HDA_FIXUP_FUNC,
10224                 .v.func = alc_fixup_no_jack_detect,
10225         },
10226         [ALC861_FIXUP_ASUS_A6RP] = {
10227                 .type = HDA_FIXUP_FUNC,
10228                 .v.func = alc861_fixup_asus_amp_vref_0f,
10229                 .chained = true,
10230                 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
10231         },
10232         [ALC660_FIXUP_ASUS_W7J] = {
10233                 .type = HDA_FIXUP_VERBS,
10234                 .v.verbs = (const struct hda_verb[]) {
10235                         /* ASUS W7J needs a magic pin setup on unused NID 0x10
10236                          * for enabling outputs
10237                          */
10238                         {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10239                         { }
10240                 },
10241         }
10242 };
10243
10244 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
10245         SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
10246         SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
10247         SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
10248         SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
10249         SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
10250         SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
10251         SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
10252         {}
10253 };
10254
10255 /*
10256  */
10257 static int patch_alc861(struct hda_codec *codec)
10258 {
10259         struct alc_spec *spec;
10260         int err;
10261
10262         err = alc_alloc_spec(codec, 0x15);
10263         if (err < 0)
10264                 return err;
10265
10266         spec = codec->spec;
10267         if (has_cdefine_beep(codec))
10268                 spec->gen.beep_nid = 0x23;
10269
10270 #ifdef CONFIG_PM
10271         spec->power_hook = alc_power_eapd;
10272 #endif
10273
10274         alc_pre_init(codec);
10275
10276         snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
10277         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10278
10279         /* automatic parse from the BIOS config */
10280         err = alc861_parse_auto_config(codec);
10281         if (err < 0)
10282                 goto error;
10283
10284         if (!spec->gen.no_analog) {
10285                 err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
10286                 if (err < 0)
10287                         goto error;
10288         }
10289
10290         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10291
10292         return 0;
10293
10294  error:
10295         alc_free(codec);
10296         return err;
10297 }
10298
10299 /*
10300  * ALC861-VD support
10301  *
10302  * Based on ALC882
10303  *
10304  * In addition, an independent DAC
10305  */
10306 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10307 {
10308         static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10309         static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10310         return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
10311 }
10312
10313 enum {
10314         ALC660VD_FIX_ASUS_GPIO1,
10315         ALC861VD_FIX_DALLAS,
10316 };
10317
10318 /* exclude VREF80 */
10319 static void alc861vd_fixup_dallas(struct hda_codec *codec,
10320                                   const struct hda_fixup *fix, int action)
10321 {
10322         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10323                 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
10324                 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
10325         }
10326 }
10327
10328 /* reset GPIO1 */
10329 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
10330                                       const struct hda_fixup *fix, int action)
10331 {
10332         struct alc_spec *spec = codec->spec;
10333
10334         if (action == HDA_FIXUP_ACT_PRE_PROBE)
10335                 spec->gpio_mask |= 0x02;
10336         alc_fixup_gpio(codec, action, 0x01);
10337 }
10338
10339 static const struct hda_fixup alc861vd_fixups[] = {
10340         [ALC660VD_FIX_ASUS_GPIO1] = {
10341                 .type = HDA_FIXUP_FUNC,
10342                 .v.func = alc660vd_fixup_asus_gpio1,
10343         },
10344         [ALC861VD_FIX_DALLAS] = {
10345                 .type = HDA_FIXUP_FUNC,
10346                 .v.func = alc861vd_fixup_dallas,
10347         },
10348 };
10349
10350 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
10351         SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
10352         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
10353         SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
10354         {}
10355 };
10356
10357 /*
10358  */
10359 static int patch_alc861vd(struct hda_codec *codec)
10360 {
10361         struct alc_spec *spec;
10362         int err;
10363
10364         err = alc_alloc_spec(codec, 0x0b);
10365         if (err < 0)
10366                 return err;
10367
10368         spec = codec->spec;
10369         if (has_cdefine_beep(codec))
10370                 spec->gen.beep_nid = 0x23;
10371
10372         spec->shutup = alc_eapd_shutup;
10373
10374         alc_pre_init(codec);
10375
10376         snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
10377         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10378
10379         /* automatic parse from the BIOS config */
10380         err = alc861vd_parse_auto_config(codec);
10381         if (err < 0)
10382                 goto error;
10383
10384         if (!spec->gen.no_analog) {
10385                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10386                 if (err < 0)
10387                         goto error;
10388         }
10389
10390         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10391
10392         return 0;
10393
10394  error:
10395         alc_free(codec);
10396         return err;
10397 }
10398
10399 /*
10400  * ALC662 support
10401  *
10402  * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10403  * configuration.  Each pin widget can choose any input DACs and a mixer.
10404  * Each ADC is connected from a mixer of all inputs.  This makes possible
10405  * 6-channel independent captures.
10406  *
10407  * In addition, an independent DAC for the multi-playback (not used in this
10408  * driver yet).
10409  */
10410
10411 /*
10412  * BIOS auto configuration
10413  */
10414
10415 static int alc662_parse_auto_config(struct hda_codec *codec)
10416 {
10417         static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10418         static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
10419         static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10420         const hda_nid_t *ssids;
10421
10422         if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
10423             codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
10424             codec->core.vendor_id == 0x10ec0671)
10425                 ssids = alc663_ssids;
10426         else
10427                 ssids = alc662_ssids;
10428         return alc_parse_auto_config(codec, alc662_ignore, ssids);
10429 }
10430
10431 static void alc272_fixup_mario(struct hda_codec *codec,
10432                                const struct hda_fixup *fix, int action)
10433 {
10434         if (action != HDA_FIXUP_ACT_PRE_PROBE)
10435                 return;
10436         if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
10437                                       (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
10438                                       (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
10439                                       (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10440                                       (0 << AC_AMPCAP_MUTE_SHIFT)))
10441                 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
10442 }
10443
10444 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
10445         { .channels = 2,
10446           .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
10447         { .channels = 4,
10448           .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
10449                    SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
10450         { }
10451 };
10452
10453 /* override the 2.1 chmap */
10454 static void alc_fixup_bass_chmap(struct hda_codec *codec,
10455                                     const struct hda_fixup *fix, int action)
10456 {
10457         if (action == HDA_FIXUP_ACT_BUILD) {
10458                 struct alc_spec *spec = codec->spec;
10459                 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
10460         }
10461 }
10462
10463 /* avoid D3 for keeping GPIO up */
10464 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
10465                                           hda_nid_t nid,
10466                                           unsigned int power_state)
10467 {
10468         struct alc_spec *spec = codec->spec;
10469         if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
10470                 return AC_PWRST_D0;
10471         return power_state;
10472 }
10473
10474 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
10475                                    const struct hda_fixup *fix, int action)
10476 {
10477         struct alc_spec *spec = codec->spec;
10478
10479         alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
10480         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10481                 spec->mute_led_polarity = 1;
10482                 codec->power_filter = gpio_led_power_filter;
10483         }
10484 }
10485
10486 static void alc662_usi_automute_hook(struct hda_codec *codec,
10487                                          struct hda_jack_callback *jack)
10488 {
10489         struct alc_spec *spec = codec->spec;
10490         int vref;
10491         msleep(200);
10492         snd_hda_gen_hp_automute(codec, jack);
10493
10494         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
10495         msleep(100);
10496         snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10497                             vref);
10498 }
10499
10500 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
10501                                      const struct hda_fixup *fix, int action)
10502 {
10503         struct alc_spec *spec = codec->spec;
10504         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10505                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10506                 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
10507         }
10508 }
10509
10510 static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
10511                                         struct hda_jack_callback *cb)
10512 {
10513         /* surround speakers at 0x1b already get muted automatically when
10514          * headphones are plugged in, but we have to mute/unmute the remaining
10515          * channels manually:
10516          * 0x15 - front left/front right
10517          * 0x18 - front center/ LFE
10518          */
10519         if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
10520                 snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
10521                 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
10522         } else {
10523                 snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
10524                 snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
10525         }
10526 }
10527
10528 static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
10529                                         const struct hda_fixup *fix, int action)
10530 {
10531     /* Pin 0x1b: shared headphones jack and surround speakers */
10532         if (!is_jack_detectable(codec, 0x1b))
10533                 return;
10534
10535         switch (action) {
10536         case HDA_FIXUP_ACT_PRE_PROBE:
10537                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
10538                                 alc662_aspire_ethos_mute_speakers);
10539                 /* subwoofer needs an extra GPIO setting to become audible */
10540                 alc_setup_gpio(codec, 0x02);
10541                 break;
10542         case HDA_FIXUP_ACT_INIT:
10543                 /* Make sure to start in a correct state, i.e. if
10544                  * headphones have been plugged in before powering up the system
10545                  */
10546                 alc662_aspire_ethos_mute_speakers(codec, NULL);
10547                 break;
10548         }
10549 }
10550
10551 static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
10552                                              const struct hda_fixup *fix, int action)
10553 {
10554         struct alc_spec *spec = codec->spec;
10555
10556         static const struct hda_pintbl pincfgs[] = {
10557                 { 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */
10558                 { 0x1b, 0x0181304f },
10559                 { }
10560         };
10561
10562         switch (action) {
10563         case HDA_FIXUP_ACT_PRE_PROBE:
10564                 spec->gen.mixer_nid = 0;
10565                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10566                 snd_hda_apply_pincfgs(codec, pincfgs);
10567                 break;
10568         case HDA_FIXUP_ACT_INIT:
10569                 alc_write_coef_idx(codec, 0x19, 0xa054);
10570                 break;
10571         }
10572 }
10573
10574 static void alc897_hp_automute_hook(struct hda_codec *codec,
10575                                          struct hda_jack_callback *jack)
10576 {
10577         struct alc_spec *spec = codec->spec;
10578         int vref;
10579
10580         snd_hda_gen_hp_automute(codec, jack);
10581         vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP;
10582         snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10583                             vref);
10584 }
10585
10586 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
10587                                      const struct hda_fixup *fix, int action)
10588 {
10589         struct alc_spec *spec = codec->spec;
10590         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10591                 spec->gen.hp_automute_hook = alc897_hp_automute_hook;
10592         }
10593 }
10594
10595 static const struct coef_fw alc668_coefs[] = {
10596         WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
10597         WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
10598         WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
10599         WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
10600         WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
10601         WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
10602         WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
10603         WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
10604         WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
10605         WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
10606         WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
10607         WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
10608         WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
10609         WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
10610         WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
10611         WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
10612         WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
10613         WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
10614         WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
10615         WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
10616         {}
10617 };
10618
10619 static void alc668_restore_default_value(struct hda_codec *codec)
10620 {
10621         alc_process_coef_fw(codec, alc668_coefs);
10622 }
10623
10624 enum {
10625         ALC662_FIXUP_ASPIRE,
10626         ALC662_FIXUP_LED_GPIO1,
10627         ALC662_FIXUP_IDEAPAD,
10628         ALC272_FIXUP_MARIO,
10629         ALC662_FIXUP_CZC_ET26,
10630         ALC662_FIXUP_CZC_P10T,
10631         ALC662_FIXUP_SKU_IGNORE,
10632         ALC662_FIXUP_HP_RP5800,
10633         ALC662_FIXUP_ASUS_MODE1,
10634         ALC662_FIXUP_ASUS_MODE2,
10635         ALC662_FIXUP_ASUS_MODE3,
10636         ALC662_FIXUP_ASUS_MODE4,
10637         ALC662_FIXUP_ASUS_MODE5,
10638         ALC662_FIXUP_ASUS_MODE6,
10639         ALC662_FIXUP_ASUS_MODE7,
10640         ALC662_FIXUP_ASUS_MODE8,
10641         ALC662_FIXUP_NO_JACK_DETECT,
10642         ALC662_FIXUP_ZOTAC_Z68,
10643         ALC662_FIXUP_INV_DMIC,
10644         ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
10645         ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
10646         ALC662_FIXUP_HEADSET_MODE,
10647         ALC668_FIXUP_HEADSET_MODE,
10648         ALC662_FIXUP_BASS_MODE4_CHMAP,
10649         ALC662_FIXUP_BASS_16,
10650         ALC662_FIXUP_BASS_1A,
10651         ALC662_FIXUP_BASS_CHMAP,
10652         ALC668_FIXUP_AUTO_MUTE,
10653         ALC668_FIXUP_DELL_DISABLE_AAMIX,
10654         ALC668_FIXUP_DELL_XPS13,
10655         ALC662_FIXUP_ASUS_Nx50,
10656         ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10657         ALC668_FIXUP_ASUS_Nx51,
10658         ALC668_FIXUP_MIC_COEF,
10659         ALC668_FIXUP_ASUS_G751,
10660         ALC891_FIXUP_HEADSET_MODE,
10661         ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10662         ALC662_FIXUP_ACER_VERITON,
10663         ALC892_FIXUP_ASROCK_MOBO,
10664         ALC662_FIXUP_USI_FUNC,
10665         ALC662_FIXUP_USI_HEADSET_MODE,
10666         ALC662_FIXUP_LENOVO_MULTI_CODECS,
10667         ALC669_FIXUP_ACER_ASPIRE_ETHOS,
10668         ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET,
10669         ALC671_FIXUP_HP_HEADSET_MIC2,
10670         ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
10671         ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
10672         ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
10673         ALC668_FIXUP_HEADSET_MIC,
10674         ALC668_FIXUP_MIC_DET_COEF,
10675         ALC897_FIXUP_LENOVO_HEADSET_MIC,
10676         ALC897_FIXUP_HEADSET_MIC_PIN,
10677         ALC897_FIXUP_HP_HSMIC_VERB,
10678 };
10679
10680 static const struct hda_fixup alc662_fixups[] = {
10681         [ALC662_FIXUP_ASPIRE] = {
10682                 .type = HDA_FIXUP_PINS,
10683                 .v.pins = (const struct hda_pintbl[]) {
10684                         { 0x15, 0x99130112 }, /* subwoofer */
10685                         { }
10686                 }
10687         },
10688         [ALC662_FIXUP_LED_GPIO1] = {
10689                 .type = HDA_FIXUP_FUNC,
10690                 .v.func = alc662_fixup_led_gpio1,
10691         },
10692         [ALC662_FIXUP_IDEAPAD] = {
10693                 .type = HDA_FIXUP_PINS,
10694                 .v.pins = (const struct hda_pintbl[]) {
10695                         { 0x17, 0x99130112 }, /* subwoofer */
10696                         { }
10697                 },
10698                 .chained = true,
10699                 .chain_id = ALC662_FIXUP_LED_GPIO1,
10700         },
10701         [ALC272_FIXUP_MARIO] = {
10702                 .type = HDA_FIXUP_FUNC,
10703                 .v.func = alc272_fixup_mario,
10704         },
10705         [ALC662_FIXUP_CZC_ET26] = {
10706                 .type = HDA_FIXUP_PINS,
10707                 .v.pins = (const struct hda_pintbl[]) {
10708                         {0x12, 0x403cc000},
10709                         {0x14, 0x90170110}, /* speaker */
10710                         {0x15, 0x411111f0},
10711                         {0x16, 0x411111f0},
10712                         {0x18, 0x01a19030}, /* mic */
10713                         {0x19, 0x90a7013f}, /* int-mic */
10714                         {0x1a, 0x01014020},
10715                         {0x1b, 0x0121401f},
10716                         {0x1c, 0x411111f0},
10717                         {0x1d, 0x411111f0},
10718                         {0x1e, 0x40478e35},
10719                         {}
10720                 },
10721                 .chained = true,
10722                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10723         },
10724         [ALC662_FIXUP_CZC_P10T] = {
10725                 .type = HDA_FIXUP_VERBS,
10726                 .v.verbs = (const struct hda_verb[]) {
10727                         {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
10728                         {}
10729                 }
10730         },
10731         [ALC662_FIXUP_SKU_IGNORE] = {
10732                 .type = HDA_FIXUP_FUNC,
10733                 .v.func = alc_fixup_sku_ignore,
10734         },
10735         [ALC662_FIXUP_HP_RP5800] = {
10736                 .type = HDA_FIXUP_PINS,
10737                 .v.pins = (const struct hda_pintbl[]) {
10738                         { 0x14, 0x0221201f }, /* HP out */
10739                         { }
10740                 },
10741                 .chained = true,
10742                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10743         },
10744         [ALC662_FIXUP_ASUS_MODE1] = {
10745                 .type = HDA_FIXUP_PINS,
10746                 .v.pins = (const struct hda_pintbl[]) {
10747                         { 0x14, 0x99130110 }, /* speaker */
10748                         { 0x18, 0x01a19c20 }, /* mic */
10749                         { 0x19, 0x99a3092f }, /* int-mic */
10750                         { 0x21, 0x0121401f }, /* HP out */
10751                         { }
10752                 },
10753                 .chained = true,
10754                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10755         },
10756         [ALC662_FIXUP_ASUS_MODE2] = {
10757                 .type = HDA_FIXUP_PINS,
10758                 .v.pins = (const struct hda_pintbl[]) {
10759                         { 0x14, 0x99130110 }, /* speaker */
10760                         { 0x18, 0x01a19820 }, /* mic */
10761                         { 0x19, 0x99a3092f }, /* int-mic */
10762                         { 0x1b, 0x0121401f }, /* HP out */
10763                         { }
10764                 },
10765                 .chained = true,
10766                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10767         },
10768         [ALC662_FIXUP_ASUS_MODE3] = {
10769                 .type = HDA_FIXUP_PINS,
10770                 .v.pins = (const struct hda_pintbl[]) {
10771                         { 0x14, 0x99130110 }, /* speaker */
10772                         { 0x15, 0x0121441f }, /* HP */
10773                         { 0x18, 0x01a19840 }, /* mic */
10774                         { 0x19, 0x99a3094f }, /* int-mic */
10775                         { 0x21, 0x01211420 }, /* HP2 */
10776                         { }
10777                 },
10778                 .chained = true,
10779                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10780         },
10781         [ALC662_FIXUP_ASUS_MODE4] = {
10782                 .type = HDA_FIXUP_PINS,
10783                 .v.pins = (const struct hda_pintbl[]) {
10784                         { 0x14, 0x99130110 }, /* speaker */
10785                         { 0x16, 0x99130111 }, /* speaker */
10786                         { 0x18, 0x01a19840 }, /* mic */
10787                         { 0x19, 0x99a3094f }, /* int-mic */
10788                         { 0x21, 0x0121441f }, /* HP */
10789                         { }
10790                 },
10791                 .chained = true,
10792                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10793         },
10794         [ALC662_FIXUP_ASUS_MODE5] = {
10795                 .type = HDA_FIXUP_PINS,
10796                 .v.pins = (const struct hda_pintbl[]) {
10797                         { 0x14, 0x99130110 }, /* speaker */
10798                         { 0x15, 0x0121441f }, /* HP */
10799                         { 0x16, 0x99130111 }, /* speaker */
10800                         { 0x18, 0x01a19840 }, /* mic */
10801                         { 0x19, 0x99a3094f }, /* int-mic */
10802                         { }
10803                 },
10804                 .chained = true,
10805                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10806         },
10807         [ALC662_FIXUP_ASUS_MODE6] = {
10808                 .type = HDA_FIXUP_PINS,
10809                 .v.pins = (const struct hda_pintbl[]) {
10810                         { 0x14, 0x99130110 }, /* speaker */
10811                         { 0x15, 0x01211420 }, /* HP2 */
10812                         { 0x18, 0x01a19840 }, /* mic */
10813                         { 0x19, 0x99a3094f }, /* int-mic */
10814                         { 0x1b, 0x0121441f }, /* HP */
10815                         { }
10816                 },
10817                 .chained = true,
10818                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10819         },
10820         [ALC662_FIXUP_ASUS_MODE7] = {
10821                 .type = HDA_FIXUP_PINS,
10822                 .v.pins = (const struct hda_pintbl[]) {
10823                         { 0x14, 0x99130110 }, /* speaker */
10824                         { 0x17, 0x99130111 }, /* speaker */
10825                         { 0x18, 0x01a19840 }, /* mic */
10826                         { 0x19, 0x99a3094f }, /* int-mic */
10827                         { 0x1b, 0x01214020 }, /* HP */
10828                         { 0x21, 0x0121401f }, /* HP */
10829                         { }
10830                 },
10831                 .chained = true,
10832                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10833         },
10834         [ALC662_FIXUP_ASUS_MODE8] = {
10835                 .type = HDA_FIXUP_PINS,
10836                 .v.pins = (const struct hda_pintbl[]) {
10837                         { 0x14, 0x99130110 }, /* speaker */
10838                         { 0x12, 0x99a30970 }, /* int-mic */
10839                         { 0x15, 0x01214020 }, /* HP */
10840                         { 0x17, 0x99130111 }, /* speaker */
10841                         { 0x18, 0x01a19840 }, /* mic */
10842                         { 0x21, 0x0121401f }, /* HP */
10843                         { }
10844                 },
10845                 .chained = true,
10846                 .chain_id = ALC662_FIXUP_SKU_IGNORE
10847         },
10848         [ALC662_FIXUP_NO_JACK_DETECT] = {
10849                 .type = HDA_FIXUP_FUNC,
10850                 .v.func = alc_fixup_no_jack_detect,
10851         },
10852         [ALC662_FIXUP_ZOTAC_Z68] = {
10853                 .type = HDA_FIXUP_PINS,
10854                 .v.pins = (const struct hda_pintbl[]) {
10855                         { 0x1b, 0x02214020 }, /* Front HP */
10856                         { }
10857                 }
10858         },
10859         [ALC662_FIXUP_INV_DMIC] = {
10860                 .type = HDA_FIXUP_FUNC,
10861                 .v.func = alc_fixup_inv_dmic,
10862         },
10863         [ALC668_FIXUP_DELL_XPS13] = {
10864                 .type = HDA_FIXUP_FUNC,
10865                 .v.func = alc_fixup_dell_xps13,
10866                 .chained = true,
10867                 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
10868         },
10869         [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
10870                 .type = HDA_FIXUP_FUNC,
10871                 .v.func = alc_fixup_disable_aamix,
10872                 .chained = true,
10873                 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
10874         },
10875         [ALC668_FIXUP_AUTO_MUTE] = {
10876                 .type = HDA_FIXUP_FUNC,
10877                 .v.func = alc_fixup_auto_mute_via_amp,
10878                 .chained = true,
10879                 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
10880         },
10881         [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
10882                 .type = HDA_FIXUP_PINS,
10883                 .v.pins = (const struct hda_pintbl[]) {
10884                         { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10885                         /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
10886                         { }
10887                 },
10888                 .chained = true,
10889                 .chain_id = ALC662_FIXUP_HEADSET_MODE
10890         },
10891         [ALC662_FIXUP_HEADSET_MODE] = {
10892                 .type = HDA_FIXUP_FUNC,
10893                 .v.func = alc_fixup_headset_mode_alc662,
10894         },
10895         [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
10896                 .type = HDA_FIXUP_PINS,
10897                 .v.pins = (const struct hda_pintbl[]) {
10898                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10899                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10900                         { }
10901                 },
10902                 .chained = true,
10903                 .chain_id = ALC668_FIXUP_HEADSET_MODE
10904         },
10905         [ALC668_FIXUP_HEADSET_MODE] = {
10906                 .type = HDA_FIXUP_FUNC,
10907                 .v.func = alc_fixup_headset_mode_alc668,
10908         },
10909         [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
10910                 .type = HDA_FIXUP_FUNC,
10911                 .v.func = alc_fixup_bass_chmap,
10912                 .chained = true,
10913                 .chain_id = ALC662_FIXUP_ASUS_MODE4
10914         },
10915         [ALC662_FIXUP_BASS_16] = {
10916                 .type = HDA_FIXUP_PINS,
10917                 .v.pins = (const struct hda_pintbl[]) {
10918                         {0x16, 0x80106111}, /* bass speaker */
10919                         {}
10920                 },
10921                 .chained = true,
10922                 .chain_id = ALC662_FIXUP_BASS_CHMAP,
10923         },
10924         [ALC662_FIXUP_BASS_1A] = {
10925                 .type = HDA_FIXUP_PINS,
10926                 .v.pins = (const struct hda_pintbl[]) {
10927                         {0x1a, 0x80106111}, /* bass speaker */
10928                         {}
10929                 },
10930                 .chained = true,
10931                 .chain_id = ALC662_FIXUP_BASS_CHMAP,
10932         },
10933         [ALC662_FIXUP_BASS_CHMAP] = {
10934                 .type = HDA_FIXUP_FUNC,
10935                 .v.func = alc_fixup_bass_chmap,
10936         },
10937         [ALC662_FIXUP_ASUS_Nx50] = {
10938                 .type = HDA_FIXUP_FUNC,
10939                 .v.func = alc_fixup_auto_mute_via_amp,
10940                 .chained = true,
10941                 .chain_id = ALC662_FIXUP_BASS_1A
10942         },
10943         [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
10944                 .type = HDA_FIXUP_FUNC,
10945                 .v.func = alc_fixup_headset_mode_alc668,
10946                 .chain_id = ALC662_FIXUP_BASS_CHMAP
10947         },
10948         [ALC668_FIXUP_ASUS_Nx51] = {
10949                 .type = HDA_FIXUP_PINS,
10950                 .v.pins = (const struct hda_pintbl[]) {
10951                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10952                         { 0x1a, 0x90170151 }, /* bass speaker */
10953                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10954                         {}
10955                 },
10956                 .chained = true,
10957                 .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10958         },
10959         [ALC668_FIXUP_MIC_COEF] = {
10960                 .type = HDA_FIXUP_VERBS,
10961                 .v.verbs = (const struct hda_verb[]) {
10962                         { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
10963                         { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
10964                         {}
10965                 },
10966         },
10967         [ALC668_FIXUP_ASUS_G751] = {
10968                 .type = HDA_FIXUP_PINS,
10969                 .v.pins = (const struct hda_pintbl[]) {
10970                         { 0x16, 0x0421101f }, /* HP */
10971                         {}
10972                 },
10973                 .chained = true,
10974                 .chain_id = ALC668_FIXUP_MIC_COEF
10975         },
10976         [ALC891_FIXUP_HEADSET_MODE] = {
10977                 .type = HDA_FIXUP_FUNC,
10978                 .v.func = alc_fixup_headset_mode,
10979         },
10980         [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
10981                 .type = HDA_FIXUP_PINS,
10982                 .v.pins = (const struct hda_pintbl[]) {
10983                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10984                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10985                         { }
10986                 },
10987                 .chained = true,
10988                 .chain_id = ALC891_FIXUP_HEADSET_MODE
10989         },
10990         [ALC662_FIXUP_ACER_VERITON] = {
10991                 .type = HDA_FIXUP_PINS,
10992                 .v.pins = (const struct hda_pintbl[]) {
10993                         { 0x15, 0x50170120 }, /* no internal speaker */
10994                         { }
10995                 }
10996         },
10997         [ALC892_FIXUP_ASROCK_MOBO] = {
10998                 .type = HDA_FIXUP_PINS,
10999                 .v.pins = (const struct hda_pintbl[]) {
11000                         { 0x15, 0x40f000f0 }, /* disabled */
11001                         { 0x16, 0x40f000f0 }, /* disabled */
11002                         { }
11003                 }
11004         },
11005         [ALC662_FIXUP_USI_FUNC] = {
11006                 .type = HDA_FIXUP_FUNC,
11007                 .v.func = alc662_fixup_usi_headset_mic,
11008         },
11009         [ALC662_FIXUP_USI_HEADSET_MODE] = {
11010                 .type = HDA_FIXUP_PINS,
11011                 .v.pins = (const struct hda_pintbl[]) {
11012                         { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
11013                         { 0x18, 0x01a1903d },
11014                         { }
11015                 },
11016                 .chained = true,
11017                 .chain_id = ALC662_FIXUP_USI_FUNC
11018         },
11019         [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
11020                 .type = HDA_FIXUP_FUNC,
11021                 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
11022         },
11023         [ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET] = {
11024                 .type = HDA_FIXUP_FUNC,
11025                 .v.func = alc662_fixup_aspire_ethos_hp,
11026         },
11027         [ALC669_FIXUP_ACER_ASPIRE_ETHOS] = {
11028                 .type = HDA_FIXUP_PINS,
11029                 .v.pins = (const struct hda_pintbl[]) {
11030                         { 0x15, 0x92130110 }, /* front speakers */
11031                         { 0x18, 0x99130111 }, /* center/subwoofer */
11032                         { 0x1b, 0x11130012 }, /* surround plus jack for HP */
11033                         { }
11034                 },
11035                 .chained = true,
11036                 .chain_id = ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET
11037         },
11038         [ALC671_FIXUP_HP_HEADSET_MIC2] = {
11039                 .type = HDA_FIXUP_FUNC,
11040                 .v.func = alc671_fixup_hp_headset_mic2,
11041         },
11042         [ALC662_FIXUP_ACER_X2660G_HEADSET_MODE] = {
11043                 .type = HDA_FIXUP_PINS,
11044                 .v.pins = (const struct hda_pintbl[]) {
11045                         { 0x1a, 0x02a1113c }, /* use as headset mic, without its own jack detect */
11046                         { }
11047                 },
11048                 .chained = true,
11049                 .chain_id = ALC662_FIXUP_USI_FUNC
11050         },
11051         [ALC662_FIXUP_ACER_NITRO_HEADSET_MODE] = {
11052                 .type = HDA_FIXUP_PINS,
11053                 .v.pins = (const struct hda_pintbl[]) {
11054                         { 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
11055                         { 0x1b, 0x0221144f },
11056                         { }
11057                 },
11058                 .chained = true,
11059                 .chain_id = ALC662_FIXUP_USI_FUNC
11060         },
11061         [ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
11062                 .type = HDA_FIXUP_PINS,
11063                 .v.pins = (const struct hda_pintbl[]) {
11064                         { 0x1b, 0x04a1112c },
11065                         { }
11066                 },
11067                 .chained = true,
11068                 .chain_id = ALC668_FIXUP_HEADSET_MIC
11069         },
11070         [ALC668_FIXUP_HEADSET_MIC] = {
11071                 .type = HDA_FIXUP_FUNC,
11072                 .v.func = alc269_fixup_headset_mic,
11073                 .chained = true,
11074                 .chain_id = ALC668_FIXUP_MIC_DET_COEF
11075         },
11076         [ALC668_FIXUP_MIC_DET_COEF] = {
11077                 .type = HDA_FIXUP_VERBS,
11078                 .v.verbs = (const struct hda_verb[]) {
11079                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
11080                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
11081                         {}
11082                 },
11083         },
11084         [ALC897_FIXUP_LENOVO_HEADSET_MIC] = {
11085                 .type = HDA_FIXUP_FUNC,
11086                 .v.func = alc897_fixup_lenovo_headset_mic,
11087         },
11088         [ALC897_FIXUP_HEADSET_MIC_PIN] = {
11089                 .type = HDA_FIXUP_PINS,
11090                 .v.pins = (const struct hda_pintbl[]) {
11091                         { 0x1a, 0x03a11050 },
11092                         { }
11093                 },
11094                 .chained = true,
11095                 .chain_id = ALC897_FIXUP_LENOVO_HEADSET_MIC
11096         },
11097         [ALC897_FIXUP_HP_HSMIC_VERB] = {
11098                 .type = HDA_FIXUP_PINS,
11099                 .v.pins = (const struct hda_pintbl[]) {
11100                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
11101                         { }
11102                 },
11103         },
11104 };
11105
11106 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
11107         SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
11108         SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
11109         SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
11110         SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
11111         SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
11112         SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
11113         SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
11114         SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
11115         SND_PCI_QUIRK(0x1025, 0x0566, "Acer Aspire Ethos 8951G", ALC669_FIXUP_ACER_ASPIRE_ETHOS),
11116         SND_PCI_QUIRK(0x1025, 0x123c, "Acer Nitro N50-600", ALC662_FIXUP_ACER_NITRO_HEADSET_MODE),
11117         SND_PCI_QUIRK(0x1025, 0x124e, "Acer 2660G", ALC662_FIXUP_ACER_X2660G_HEADSET_MODE),
11118         SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11119         SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11120         SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
11121         SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
11122         SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
11123         SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11124         SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11125         SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11126         SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11127         SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
11128         SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
11129         SND_PCI_QUIRK(0x103c, 0x8719, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
11130         SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
11131         SND_PCI_QUIRK(0x103c, 0x877e, "HP 288 Pro G6", ALC671_FIXUP_HP_HEADSET_MIC2),
11132         SND_PCI_QUIRK(0x103c, 0x885f, "HP 288 Pro G8", ALC671_FIXUP_HP_HEADSET_MIC2),
11133         SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
11134         SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
11135         SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
11136         SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
11137         SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
11138         SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
11139         SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
11140         SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
11141         SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
11142         SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
11143         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
11144         SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
11145         SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
11146         SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
11147         SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
11148         SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
11149         SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
11150         SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
11151         SND_PCI_QUIRK(0x17aa, 0x1057, "Lenovo P360", ALC897_FIXUP_HEADSET_MIC_PIN),
11152         SND_PCI_QUIRK(0x17aa, 0x32ca, "Lenovo ThinkCentre M80", ALC897_FIXUP_HEADSET_MIC_PIN),
11153         SND_PCI_QUIRK(0x17aa, 0x32cb, "Lenovo ThinkCentre M70", ALC897_FIXUP_HEADSET_MIC_PIN),
11154         SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN),
11155         SND_PCI_QUIRK(0x17aa, 0x32f7, "Lenovo ThinkCentre M90", ALC897_FIXUP_HEADSET_MIC_PIN),
11156         SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
11157         SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
11158         SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
11159         SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
11160         SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
11161         SND_PCI_QUIRK(0x1b35, 0x1234, "CZC ET26", ALC662_FIXUP_CZC_ET26),
11162         SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
11163
11164 #if 0
11165         /* Below is a quirk table taken from the old code.
11166          * Basically the device should work as is without the fixup table.
11167          * If BIOS doesn't give a proper info, enable the corresponding
11168          * fixup entry.
11169          */
11170         SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
11171         SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
11172         SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
11173         SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
11174         SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11175         SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11176         SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11177         SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
11178         SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
11179         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11180         SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
11181         SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
11182         SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
11183         SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
11184         SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
11185         SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11186         SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
11187         SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
11188         SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11189         SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11190         SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11191         SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11192         SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
11193         SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
11194         SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
11195         SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11196         SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
11197         SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
11198         SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11199         SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
11200         SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11201         SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11202         SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
11203         SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
11204         SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
11205         SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
11206         SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
11207         SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
11208         SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
11209         SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
11210         SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
11211         SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
11212         SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11213         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
11214         SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
11215         SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
11216         SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
11217         SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
11218         SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
11219         SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
11220 #endif
11221         {}
11222 };
11223
11224 static const struct hda_model_fixup alc662_fixup_models[] = {
11225         {.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
11226         {.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
11227         {.id = ALC272_FIXUP_MARIO, .name = "mario"},
11228         {.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
11229         {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
11230         {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
11231         {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
11232         {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
11233         {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
11234         {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
11235         {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
11236         {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
11237         {.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
11238         {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
11239         {.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
11240         {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
11241         {.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
11242         {.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
11243         {.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
11244         {.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
11245         {.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
11246         {.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
11247         {.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
11248         {.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
11249         {.id = ALC668_FIXUP_ASUS_G751, .name = "asus-g751"},
11250         {.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
11251         {.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
11252         {.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
11253         {.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
11254         {.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
11255         {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
11256         {.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
11257         {}
11258 };
11259
11260 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
11261         SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
11262                 {0x17, 0x02211010},
11263                 {0x18, 0x01a19030},
11264                 {0x1a, 0x01813040},
11265                 {0x21, 0x01014020}),
11266         SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
11267                 {0x16, 0x01813030},
11268                 {0x17, 0x02211010},
11269                 {0x18, 0x01a19040},
11270                 {0x21, 0x01014020}),
11271         SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
11272                 {0x14, 0x01014010},
11273                 {0x18, 0x01a19020},
11274                 {0x1a, 0x0181302f},
11275                 {0x1b, 0x0221401f}),
11276         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11277                 {0x12, 0x99a30130},
11278                 {0x14, 0x90170110},
11279                 {0x15, 0x0321101f},
11280                 {0x16, 0x03011020}),
11281         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11282                 {0x12, 0x99a30140},
11283                 {0x14, 0x90170110},
11284                 {0x15, 0x0321101f},
11285                 {0x16, 0x03011020}),
11286         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11287                 {0x12, 0x99a30150},
11288                 {0x14, 0x90170110},
11289                 {0x15, 0x0321101f},
11290                 {0x16, 0x03011020}),
11291         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
11292                 {0x14, 0x90170110},
11293                 {0x15, 0x0321101f},
11294                 {0x16, 0x03011020}),
11295         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
11296                 {0x12, 0x90a60130},
11297                 {0x14, 0x90170110},
11298                 {0x15, 0x0321101f}),
11299         SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11300                 {0x14, 0x01014010},
11301                 {0x17, 0x90170150},
11302                 {0x19, 0x02a11060},
11303                 {0x1b, 0x01813030},
11304                 {0x21, 0x02211020}),
11305         SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11306                 {0x14, 0x01014010},
11307                 {0x18, 0x01a19040},
11308                 {0x1b, 0x01813030},
11309                 {0x21, 0x02211020}),
11310         SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
11311                 {0x14, 0x01014020},
11312                 {0x17, 0x90170110},
11313                 {0x18, 0x01a19050},
11314                 {0x1b, 0x01813040},
11315                 {0x21, 0x02211030}),
11316         {}
11317 };
11318
11319 /*
11320  */
11321 static int patch_alc662(struct hda_codec *codec)
11322 {
11323         struct alc_spec *spec;
11324         int err;
11325
11326         err = alc_alloc_spec(codec, 0x0b);
11327         if (err < 0)
11328                 return err;
11329
11330         spec = codec->spec;
11331
11332         spec->shutup = alc_eapd_shutup;
11333
11334         /* handle multiple HPs as is */
11335         spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
11336
11337         alc_fix_pll_init(codec, 0x20, 0x04, 15);
11338
11339         switch (codec->core.vendor_id) {
11340         case 0x10ec0668:
11341                 spec->init_hook = alc668_restore_default_value;
11342                 break;
11343         }
11344
11345         alc_pre_init(codec);
11346
11347         snd_hda_pick_fixup(codec, alc662_fixup_models,
11348                        alc662_fixup_tbl, alc662_fixups);
11349         snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
11350         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11351
11352         alc_auto_parse_customize_define(codec);
11353
11354         if (has_cdefine_beep(codec))
11355                 spec->gen.beep_nid = 0x01;
11356
11357         if ((alc_get_coef0(codec) & (1 << 14)) &&
11358             codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
11359             spec->cdefine.platform_type == 1) {
11360                 err = alc_codec_rename(codec, "ALC272X");
11361                 if (err < 0)
11362                         goto error;
11363         }
11364
11365         /* automatic parse from the BIOS config */
11366         err = alc662_parse_auto_config(codec);
11367         if (err < 0)
11368                 goto error;
11369
11370         if (!spec->gen.no_analog && spec->gen.beep_nid) {
11371                 switch (codec->core.vendor_id) {
11372                 case 0x10ec0662:
11373                         err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11374                         break;
11375                 case 0x10ec0272:
11376                 case 0x10ec0663:
11377                 case 0x10ec0665:
11378                 case 0x10ec0668:
11379                         err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
11380                         break;
11381                 case 0x10ec0273:
11382                         err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
11383                         break;
11384                 }
11385                 if (err < 0)
11386                         goto error;
11387         }
11388
11389         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11390
11391         return 0;
11392
11393  error:
11394         alc_free(codec);
11395         return err;
11396 }
11397
11398 /*
11399  * ALC680 support
11400  */
11401
11402 static int alc680_parse_auto_config(struct hda_codec *codec)
11403 {
11404         return alc_parse_auto_config(codec, NULL, NULL);
11405 }
11406
11407 /*
11408  */
11409 static int patch_alc680(struct hda_codec *codec)
11410 {
11411         int err;
11412
11413         /* ALC680 has no aa-loopback mixer */
11414         err = alc_alloc_spec(codec, 0);
11415         if (err < 0)
11416                 return err;
11417
11418         /* automatic parse from the BIOS config */
11419         err = alc680_parse_auto_config(codec);
11420         if (err < 0) {
11421                 alc_free(codec);
11422                 return err;
11423         }
11424
11425         return 0;
11426 }
11427
11428 /*
11429  * patch entries
11430  */
11431 static const struct hda_device_id snd_hda_id_realtek[] = {
11432         HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
11433         HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
11434         HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
11435         HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
11436         HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
11437         HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
11438         HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
11439         HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
11440         HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
11441         HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
11442         HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
11443         HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
11444         HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
11445         HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
11446         HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
11447         HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
11448         HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
11449         HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
11450         HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
11451         HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
11452         HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
11453         HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
11454         HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
11455         HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
11456         HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
11457         HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
11458         HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
11459         HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
11460         HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
11461         HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
11462         HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
11463         HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
11464         HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
11465         HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
11466         HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
11467         HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
11468         HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
11469         HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
11470         HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
11471         HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
11472         HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
11473         HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
11474         HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
11475         HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
11476         HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
11477         HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
11478         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
11479         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
11480         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
11481         HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
11482         HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
11483         HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
11484         HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
11485         HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
11486         HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
11487         HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
11488         HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
11489         HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
11490         HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
11491         HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
11492         HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
11493         HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
11494         HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
11495         HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
11496         HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
11497         HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
11498         HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
11499         HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
11500         HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
11501         HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
11502         HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
11503         HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
11504         HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
11505         HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
11506         HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
11507         HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
11508         HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
11509         HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
11510         HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269),
11511         {} /* terminator */
11512 };
11513 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
11514
11515 MODULE_LICENSE("GPL");
11516 MODULE_DESCRIPTION("Realtek HD-audio codec");
11517
11518 static struct hda_codec_driver realtek_driver = {
11519         .id = snd_hda_id_realtek,
11520 };
11521
11522 module_hda_codec_driver(realtek_driver);