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