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