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