GNU Linux-libre 4.19.242-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, 0x03);
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 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 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 };
1920
1921 static void alc889_fixup_coef(struct hda_codec *codec,
1922                               const struct hda_fixup *fix, int action)
1923 {
1924         if (action != HDA_FIXUP_ACT_INIT)
1925                 return;
1926         alc_update_coef_idx(codec, 7, 0, 0x2030);
1927 }
1928
1929 /* set up GPIO at initialization */
1930 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1931                                      const struct hda_fixup *fix, int action)
1932 {
1933         struct alc_spec *spec = codec->spec;
1934
1935         spec->gpio_write_delay = true;
1936         alc_fixup_gpio3(codec, fix, action);
1937 }
1938
1939 /* Fix the connection of some pins for ALC889:
1940  * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1941  * work correctly (bko#42740)
1942  */
1943 static void alc889_fixup_dac_route(struct hda_codec *codec,
1944                                    const struct hda_fixup *fix, int action)
1945 {
1946         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1947                 /* fake the connections during parsing the tree */
1948                 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1949                 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1950                 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1951                 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1952                 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1953                 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1954         } else if (action == HDA_FIXUP_ACT_PROBE) {
1955                 /* restore the connections */
1956                 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1957                 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1958                 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1959                 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1960                 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
1961         }
1962 }
1963
1964 /* Set VREF on HP pin */
1965 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1966                                   const struct hda_fixup *fix, int action)
1967 {
1968         struct alc_spec *spec = codec->spec;
1969         static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 };
1970         int i;
1971
1972         if (action != HDA_FIXUP_ACT_INIT)
1973                 return;
1974         for (i = 0; i < ARRAY_SIZE(nids); i++) {
1975                 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1976                 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1977                         continue;
1978                 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1979                 val |= AC_PINCTL_VREF_80;
1980                 snd_hda_set_pin_ctl(codec, nids[i], val);
1981                 spec->gen.keep_vref_in_automute = 1;
1982                 break;
1983         }
1984 }
1985
1986 static void alc889_fixup_mac_pins(struct hda_codec *codec,
1987                                   const hda_nid_t *nids, int num_nids)
1988 {
1989         struct alc_spec *spec = codec->spec;
1990         int i;
1991
1992         for (i = 0; i < num_nids; i++) {
1993                 unsigned int val;
1994                 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1995                 val |= AC_PINCTL_VREF_50;
1996                 snd_hda_set_pin_ctl(codec, nids[i], val);
1997         }
1998         spec->gen.keep_vref_in_automute = 1;
1999 }
2000
2001 /* Set VREF on speaker pins on imac91 */
2002 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2003                                      const struct hda_fixup *fix, int action)
2004 {
2005         static hda_nid_t nids[2] = { 0x18, 0x1a };
2006
2007         if (action == HDA_FIXUP_ACT_INIT)
2008                 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2009 }
2010
2011 /* Set VREF on speaker pins on mba11 */
2012 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2013                                     const struct hda_fixup *fix, int action)
2014 {
2015         static hda_nid_t nids[1] = { 0x18 };
2016
2017         if (action == HDA_FIXUP_ACT_INIT)
2018                 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2019 }
2020
2021 /* Set VREF on speaker pins on mba21 */
2022 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2023                                     const struct hda_fixup *fix, int action)
2024 {
2025         static hda_nid_t nids[2] = { 0x18, 0x19 };
2026
2027         if (action == HDA_FIXUP_ACT_INIT)
2028                 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2029 }
2030
2031 /* Don't take HP output as primary
2032  * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
2033  * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2034  */
2035 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2036                                        const struct hda_fixup *fix, int action)
2037 {
2038         struct alc_spec *spec = codec->spec;
2039         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2040                 spec->gen.no_primary_hp = 1;
2041                 spec->gen.no_multi_io = 1;
2042         }
2043 }
2044
2045 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2046                                  const struct hda_fixup *fix, int action);
2047
2048 /* For dual-codec configuration, we need to disable some features to avoid
2049  * conflicts of kctls and PCM streams
2050  */
2051 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2052                                   const struct hda_fixup *fix, int action)
2053 {
2054         struct alc_spec *spec = codec->spec;
2055
2056         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2057                 return;
2058         /* disable vmaster */
2059         spec->gen.suppress_vmaster = 1;
2060         /* auto-mute and auto-mic switch don't work with multiple codecs */
2061         spec->gen.suppress_auto_mute = 1;
2062         spec->gen.suppress_auto_mic = 1;
2063         /* disable aamix as well */
2064         spec->gen.mixer_nid = 0;
2065         /* add location prefix to avoid conflicts */
2066         codec->force_pin_prefix = 1;
2067 }
2068
2069 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2070                        const char *newname)
2071 {
2072         struct snd_kcontrol *kctl;
2073
2074         kctl = snd_hda_find_mixer_ctl(codec, oldname);
2075         if (kctl)
2076                 strcpy(kctl->id.name, newname);
2077 }
2078
2079 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2080                                          const struct hda_fixup *fix,
2081                                          int action)
2082 {
2083         alc_fixup_dual_codecs(codec, fix, action);
2084         switch (action) {
2085         case HDA_FIXUP_ACT_PRE_PROBE:
2086                 /* override card longname to provide a unique UCM profile */
2087                 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2088                 break;
2089         case HDA_FIXUP_ACT_BUILD:
2090                 /* rename Capture controls depending on the codec */
2091                 rename_ctl(codec, "Capture Volume",
2092                            codec->addr == 0 ?
2093                            "Rear-Panel Capture Volume" :
2094                            "Front-Panel Capture Volume");
2095                 rename_ctl(codec, "Capture Switch",
2096                            codec->addr == 0 ?
2097                            "Rear-Panel Capture Switch" :
2098                            "Front-Panel Capture Switch");
2099                 break;
2100         }
2101 }
2102
2103 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
2104                                      const struct hda_fixup *fix,
2105                                      int action)
2106 {
2107         static const hda_nid_t conn1[] = { 0x0c };
2108         static const struct coef_fw gb_x570_coefs[] = {
2109                 WRITE_COEF(0x07, 0x03c0),
2110                 WRITE_COEF(0x1a, 0x01c1),
2111                 WRITE_COEF(0x1b, 0x0202),
2112                 WRITE_COEF(0x43, 0x3005),
2113                 {}
2114         };
2115
2116         switch (action) {
2117         case HDA_FIXUP_ACT_PRE_PROBE:
2118                 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2119                 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2120                 break;
2121         case HDA_FIXUP_ACT_INIT:
2122                 alc_process_coef_fw(codec, gb_x570_coefs);
2123                 break;
2124         }
2125 }
2126
2127 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2128                                      const struct hda_fixup *fix,
2129                                      int action)
2130 {
2131         hda_nid_t conn1[1] = { 0x0c };
2132
2133         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2134                 return;
2135
2136         alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2137         /* We therefore want to make sure 0x14 (front headphone) and
2138          * 0x1b (speakers) use the stereo DAC 0x02
2139          */
2140         snd_hda_override_conn_list(codec, 0x14, 1, conn1);
2141         snd_hda_override_conn_list(codec, 0x1b, 1, conn1);
2142 }
2143
2144 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2145                                 const struct hda_fixup *fix, int action);
2146
2147 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2148                                      const struct hda_fixup *fix,
2149                                      int action)
2150 {
2151         alc1220_fixup_clevo_p950(codec, fix, action);
2152         alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2153 }
2154
2155 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2156                                          struct hda_jack_callback *jack)
2157 {
2158         struct alc_spec *spec = codec->spec;
2159         unsigned int vref;
2160
2161         snd_hda_gen_hp_automute(codec, jack);
2162
2163         if (spec->gen.hp_jack_present)
2164                 vref = AC_PINCTL_VREF_80;
2165         else
2166                 vref = AC_PINCTL_VREF_HIZ;
2167         snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2168 }
2169
2170 static void alc887_fixup_asus_jack(struct hda_codec *codec,
2171                                      const struct hda_fixup *fix, int action)
2172 {
2173         struct alc_spec *spec = codec->spec;
2174         if (action != HDA_FIXUP_ACT_PROBE)
2175                 return;
2176         snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2177         spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
2178 }
2179
2180 static const struct hda_fixup alc882_fixups[] = {
2181         [ALC882_FIXUP_ABIT_AW9D_MAX] = {
2182                 .type = HDA_FIXUP_PINS,
2183                 .v.pins = (const struct hda_pintbl[]) {
2184                         { 0x15, 0x01080104 }, /* side */
2185                         { 0x16, 0x01011012 }, /* rear */
2186                         { 0x17, 0x01016011 }, /* clfe */
2187                         { }
2188                 }
2189         },
2190         [ALC882_FIXUP_LENOVO_Y530] = {
2191                 .type = HDA_FIXUP_PINS,
2192                 .v.pins = (const struct hda_pintbl[]) {
2193                         { 0x15, 0x99130112 }, /* rear int speakers */
2194                         { 0x16, 0x99130111 }, /* subwoofer */
2195                         { }
2196                 }
2197         },
2198         [ALC882_FIXUP_PB_M5210] = {
2199                 .type = HDA_FIXUP_PINCTLS,
2200                 .v.pins = (const struct hda_pintbl[]) {
2201                         { 0x19, PIN_VREF50 },
2202                         {}
2203                 }
2204         },
2205         [ALC882_FIXUP_ACER_ASPIRE_7736] = {
2206                 .type = HDA_FIXUP_FUNC,
2207                 .v.func = alc_fixup_sku_ignore,
2208         },
2209         [ALC882_FIXUP_ASUS_W90V] = {
2210                 .type = HDA_FIXUP_PINS,
2211                 .v.pins = (const struct hda_pintbl[]) {
2212                         { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2213                         { }
2214                 }
2215         },
2216         [ALC889_FIXUP_CD] = {
2217                 .type = HDA_FIXUP_PINS,
2218                 .v.pins = (const struct hda_pintbl[]) {
2219                         { 0x1c, 0x993301f0 }, /* CD */
2220                         { }
2221                 }
2222         },
2223         [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2224                 .type = HDA_FIXUP_PINS,
2225                 .v.pins = (const struct hda_pintbl[]) {
2226                         { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2227                         { }
2228                 },
2229                 .chained = true,
2230                 .chain_id = ALC889_FIXUP_CD,
2231         },
2232         [ALC889_FIXUP_VAIO_TT] = {
2233                 .type = HDA_FIXUP_PINS,
2234                 .v.pins = (const struct hda_pintbl[]) {
2235                         { 0x17, 0x90170111 }, /* hidden surround speaker */
2236                         { }
2237                 }
2238         },
2239         [ALC888_FIXUP_EEE1601] = {
2240                 .type = HDA_FIXUP_VERBS,
2241                 .v.verbs = (const struct hda_verb[]) {
2242                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2243                         { 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
2244                         { }
2245                 }
2246         },
2247         [ALC886_FIXUP_EAPD] = {
2248                 .type = HDA_FIXUP_VERBS,
2249                 .v.verbs = (const struct hda_verb[]) {
2250                         /* change to EAPD mode */
2251                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2252                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0068 },
2253                         { }
2254                 }
2255         },
2256         [ALC882_FIXUP_EAPD] = {
2257                 .type = HDA_FIXUP_VERBS,
2258                 .v.verbs = (const struct hda_verb[]) {
2259                         /* change to EAPD mode */
2260                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2261                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2262                         { }
2263                 }
2264         },
2265         [ALC883_FIXUP_EAPD] = {
2266                 .type = HDA_FIXUP_VERBS,
2267                 .v.verbs = (const struct hda_verb[]) {
2268                         /* change to EAPD mode */
2269                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2270                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2271                         { }
2272                 }
2273         },
2274         [ALC883_FIXUP_ACER_EAPD] = {
2275                 .type = HDA_FIXUP_VERBS,
2276                 .v.verbs = (const struct hda_verb[]) {
2277                         /* eanable EAPD on Acer laptops */
2278                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2279                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2280                         { }
2281                 }
2282         },
2283         [ALC882_FIXUP_GPIO1] = {
2284                 .type = HDA_FIXUP_FUNC,
2285                 .v.func = alc_fixup_gpio1,
2286         },
2287         [ALC882_FIXUP_GPIO2] = {
2288                 .type = HDA_FIXUP_FUNC,
2289                 .v.func = alc_fixup_gpio2,
2290         },
2291         [ALC882_FIXUP_GPIO3] = {
2292                 .type = HDA_FIXUP_FUNC,
2293                 .v.func = alc_fixup_gpio3,
2294         },
2295         [ALC882_FIXUP_ASUS_W2JC] = {
2296                 .type = HDA_FIXUP_FUNC,
2297                 .v.func = alc_fixup_gpio1,
2298                 .chained = true,
2299                 .chain_id = ALC882_FIXUP_EAPD,
2300         },
2301         [ALC889_FIXUP_COEF] = {
2302                 .type = HDA_FIXUP_FUNC,
2303                 .v.func = alc889_fixup_coef,
2304         },
2305         [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2306                 .type = HDA_FIXUP_PINS,
2307                 .v.pins = (const struct hda_pintbl[]) {
2308                         { 0x16, 0x99130111 }, /* CLFE speaker */
2309                         { 0x17, 0x99130112 }, /* surround speaker */
2310                         { }
2311                 },
2312                 .chained = true,
2313                 .chain_id = ALC882_FIXUP_GPIO1,
2314         },
2315         [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2316                 .type = HDA_FIXUP_PINS,
2317                 .v.pins = (const struct hda_pintbl[]) {
2318                         { 0x16, 0x99130111 }, /* CLFE speaker */
2319                         { 0x1b, 0x99130112 }, /* surround speaker */
2320                         { }
2321                 },
2322                 .chained = true,
2323                 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2324         },
2325         [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2326                 /* additional init verbs for Acer Aspire 8930G */
2327                 .type = HDA_FIXUP_VERBS,
2328                 .v.verbs = (const struct hda_verb[]) {
2329                         /* Enable all DACs */
2330                         /* DAC DISABLE/MUTE 1? */
2331                         /*  setting bits 1-5 disables DAC nids 0x02-0x06
2332                          *  apparently. Init=0x38 */
2333                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2334                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2335                         /* DAC DISABLE/MUTE 2? */
2336                         /*  some bit here disables the other DACs.
2337                          *  Init=0x4900 */
2338                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2339                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2340                         /* DMIC fix
2341                          * This laptop has a stereo digital microphone.
2342                          * The mics are only 1cm apart which makes the stereo
2343                          * useless. However, either the mic or the ALC889
2344                          * makes the signal become a difference/sum signal
2345                          * instead of standard stereo, which is annoying.
2346                          * So instead we flip this bit which makes the
2347                          * codec replicate the sum signal to both channels,
2348                          * turning it into a normal mono mic.
2349                          */
2350                         /* DMIC_CONTROL? Init value = 0x0001 */
2351                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2352                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2353                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2354                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2355                         { }
2356                 },
2357                 .chained = true,
2358                 .chain_id = ALC882_FIXUP_GPIO1,
2359         },
2360         [ALC885_FIXUP_MACPRO_GPIO] = {
2361                 .type = HDA_FIXUP_FUNC,
2362                 .v.func = alc885_fixup_macpro_gpio,
2363         },
2364         [ALC889_FIXUP_DAC_ROUTE] = {
2365                 .type = HDA_FIXUP_FUNC,
2366                 .v.func = alc889_fixup_dac_route,
2367         },
2368         [ALC889_FIXUP_MBP_VREF] = {
2369                 .type = HDA_FIXUP_FUNC,
2370                 .v.func = alc889_fixup_mbp_vref,
2371                 .chained = true,
2372                 .chain_id = ALC882_FIXUP_GPIO1,
2373         },
2374         [ALC889_FIXUP_IMAC91_VREF] = {
2375                 .type = HDA_FIXUP_FUNC,
2376                 .v.func = alc889_fixup_imac91_vref,
2377                 .chained = true,
2378                 .chain_id = ALC882_FIXUP_GPIO1,
2379         },
2380         [ALC889_FIXUP_MBA11_VREF] = {
2381                 .type = HDA_FIXUP_FUNC,
2382                 .v.func = alc889_fixup_mba11_vref,
2383                 .chained = true,
2384                 .chain_id = ALC889_FIXUP_MBP_VREF,
2385         },
2386         [ALC889_FIXUP_MBA21_VREF] = {
2387                 .type = HDA_FIXUP_FUNC,
2388                 .v.func = alc889_fixup_mba21_vref,
2389                 .chained = true,
2390                 .chain_id = ALC889_FIXUP_MBP_VREF,
2391         },
2392         [ALC889_FIXUP_MP11_VREF] = {
2393                 .type = HDA_FIXUP_FUNC,
2394                 .v.func = alc889_fixup_mba11_vref,
2395                 .chained = true,
2396                 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2397         },
2398         [ALC889_FIXUP_MP41_VREF] = {
2399                 .type = HDA_FIXUP_FUNC,
2400                 .v.func = alc889_fixup_mbp_vref,
2401                 .chained = true,
2402                 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2403         },
2404         [ALC882_FIXUP_INV_DMIC] = {
2405                 .type = HDA_FIXUP_FUNC,
2406                 .v.func = alc_fixup_inv_dmic,
2407         },
2408         [ALC882_FIXUP_NO_PRIMARY_HP] = {
2409                 .type = HDA_FIXUP_FUNC,
2410                 .v.func = alc882_fixup_no_primary_hp,
2411         },
2412         [ALC887_FIXUP_ASUS_BASS] = {
2413                 .type = HDA_FIXUP_PINS,
2414                 .v.pins = (const struct hda_pintbl[]) {
2415                         {0x16, 0x99130130}, /* bass speaker */
2416                         {}
2417                 },
2418                 .chained = true,
2419                 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2420         },
2421         [ALC887_FIXUP_BASS_CHMAP] = {
2422                 .type = HDA_FIXUP_FUNC,
2423                 .v.func = alc_fixup_bass_chmap,
2424         },
2425         [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2426                 .type = HDA_FIXUP_FUNC,
2427                 .v.func = alc1220_fixup_gb_dual_codecs,
2428         },
2429         [ALC1220_FIXUP_GB_X570] = {
2430                 .type = HDA_FIXUP_FUNC,
2431                 .v.func = alc1220_fixup_gb_x570,
2432         },
2433         [ALC1220_FIXUP_CLEVO_P950] = {
2434                 .type = HDA_FIXUP_FUNC,
2435                 .v.func = alc1220_fixup_clevo_p950,
2436         },
2437         [ALC1220_FIXUP_CLEVO_PB51ED] = {
2438                 .type = HDA_FIXUP_FUNC,
2439                 .v.func = alc1220_fixup_clevo_pb51ed,
2440         },
2441         [ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
2442                 .type = HDA_FIXUP_PINS,
2443                 .v.pins = (const struct hda_pintbl[]) {
2444                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2445                         {}
2446                 },
2447                 .chained = true,
2448                 .chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
2449         },
2450         [ALC887_FIXUP_ASUS_AUDIO] = {
2451                 .type = HDA_FIXUP_PINS,
2452                 .v.pins = (const struct hda_pintbl[]) {
2453                         { 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
2454                         { 0x19, 0x22219420 },
2455                         {}
2456                 },
2457         },
2458         [ALC887_FIXUP_ASUS_HMIC] = {
2459                 .type = HDA_FIXUP_FUNC,
2460                 .v.func = alc887_fixup_asus_jack,
2461                 .chained = true,
2462                 .chain_id = ALC887_FIXUP_ASUS_AUDIO,
2463         },
2464 };
2465
2466 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2467         SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2468         SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2469         SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2470         SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2471         SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2472         SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2473         SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2474         SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2475                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2476         SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2477                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2478         SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2479                       ALC882_FIXUP_ACER_ASPIRE_8930G),
2480         SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2481                       ALC882_FIXUP_ACER_ASPIRE_8930G),
2482         SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2483                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2484         SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2485         SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2486                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2487         SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2488                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2489         SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2490                       ALC882_FIXUP_ACER_ASPIRE_4930G),
2491         SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2492         SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2493         SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2494         SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2495         SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2496         SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2497         SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
2498         SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2499         SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2500         SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2501         SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2502         SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2503         SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2504         SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2505         SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2506
2507         /* All Apple entries are in codec SSIDs */
2508         SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2509         SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2510         SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2511         SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2512         SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2513         SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2514         SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2515         SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2516         SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2517         SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2518         SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2519         SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2520         SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2521         SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2522         SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2523         SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2524         SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2525         SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2526         SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2527         SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2528         SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2529         SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2530
2531         SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2532         SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
2533         SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2534         SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2535         SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570),
2536         SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570),
2537         SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570),
2538         SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
2539         SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
2540         SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
2541         SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
2542         SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
2543         SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
2544         SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2545         SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS),
2546         SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2547         SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2548         SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2549         SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2550         SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2551         SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2552         SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2553         SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2554         SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2555         SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2556         SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2557         SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2558         SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2559         SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2560         SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2561         SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2562         SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
2563         SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2564         SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
2565         SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
2566         SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2567         SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2568         SND_PCI_QUIRK(0x1558, 0x95e3, "Clevo P955[ER]T", ALC1220_FIXUP_CLEVO_P950),
2569         SND_PCI_QUIRK(0x1558, 0x95e4, "Clevo P955ER", ALC1220_FIXUP_CLEVO_P950),
2570         SND_PCI_QUIRK(0x1558, 0x95e5, "Clevo P955EE6", ALC1220_FIXUP_CLEVO_P950),
2571         SND_PCI_QUIRK(0x1558, 0x95e6, "Clevo P950R[CDF]", ALC1220_FIXUP_CLEVO_P950),
2572         SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2573         SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2574         SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
2575         SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2576         SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2577         SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2578         SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2579         {}
2580 };
2581
2582 static const struct hda_model_fixup alc882_fixup_models[] = {
2583         {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2584         {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2585         {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2586         {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2587         {.id = ALC889_FIXUP_CD, .name = "cd"},
2588         {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2589         {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2590         {.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2591         {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2592         {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2593         {.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2594         {.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2595         {.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2596         {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2597         {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2598         {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2599         {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2600         {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2601         {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2602         {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2603         {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2604         {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2605         {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2606         {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2607         {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2608         {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2609         {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2610         {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2611         {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2612         {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2613         {.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
2614         {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2615         {}
2616 };
2617
2618 /*
2619  * BIOS auto configuration
2620  */
2621 /* almost identical with ALC880 parser... */
2622 static int alc882_parse_auto_config(struct hda_codec *codec)
2623 {
2624         static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2625         static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2626         return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2627 }
2628
2629 /*
2630  */
2631 static int patch_alc882(struct hda_codec *codec)
2632 {
2633         struct alc_spec *spec;
2634         int err;
2635
2636         err = alc_alloc_spec(codec, 0x0b);
2637         if (err < 0)
2638                 return err;
2639
2640         spec = codec->spec;
2641
2642         switch (codec->core.vendor_id) {
2643         case 0x10ec0882:
2644         case 0x10ec0885:
2645         case 0x10ec0900:
2646         case 0x10ec0b00:
2647         case 0x10ec1220:
2648                 break;
2649         default:
2650                 /* ALC883 and variants */
2651                 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2652                 break;
2653         }
2654
2655         snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2656                        alc882_fixups);
2657         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2658
2659         alc_auto_parse_customize_define(codec);
2660
2661         if (has_cdefine_beep(codec))
2662                 spec->gen.beep_nid = 0x01;
2663
2664         /* automatic parse from the BIOS config */
2665         err = alc882_parse_auto_config(codec);
2666         if (err < 0)
2667                 goto error;
2668
2669         if (!spec->gen.no_analog && spec->gen.beep_nid) {
2670                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2671                 if (err < 0)
2672                         goto error;
2673         }
2674
2675         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2676
2677         return 0;
2678
2679  error:
2680         alc_free(codec);
2681         return err;
2682 }
2683
2684
2685 /*
2686  * ALC262 support
2687  */
2688 static int alc262_parse_auto_config(struct hda_codec *codec)
2689 {
2690         static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2691         static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2692         return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2693 }
2694
2695 /*
2696  * Pin config fixes
2697  */
2698 enum {
2699         ALC262_FIXUP_FSC_H270,
2700         ALC262_FIXUP_FSC_S7110,
2701         ALC262_FIXUP_HP_Z200,
2702         ALC262_FIXUP_TYAN,
2703         ALC262_FIXUP_LENOVO_3000,
2704         ALC262_FIXUP_BENQ,
2705         ALC262_FIXUP_BENQ_T31,
2706         ALC262_FIXUP_INV_DMIC,
2707         ALC262_FIXUP_INTEL_BAYLEYBAY,
2708 };
2709
2710 static const struct hda_fixup alc262_fixups[] = {
2711         [ALC262_FIXUP_FSC_H270] = {
2712                 .type = HDA_FIXUP_PINS,
2713                 .v.pins = (const struct hda_pintbl[]) {
2714                         { 0x14, 0x99130110 }, /* speaker */
2715                         { 0x15, 0x0221142f }, /* front HP */
2716                         { 0x1b, 0x0121141f }, /* rear HP */
2717                         { }
2718                 }
2719         },
2720         [ALC262_FIXUP_FSC_S7110] = {
2721                 .type = HDA_FIXUP_PINS,
2722                 .v.pins = (const struct hda_pintbl[]) {
2723                         { 0x15, 0x90170110 }, /* speaker */
2724                         { }
2725                 },
2726                 .chained = true,
2727                 .chain_id = ALC262_FIXUP_BENQ,
2728         },
2729         [ALC262_FIXUP_HP_Z200] = {
2730                 .type = HDA_FIXUP_PINS,
2731                 .v.pins = (const struct hda_pintbl[]) {
2732                         { 0x16, 0x99130120 }, /* internal speaker */
2733                         { }
2734                 }
2735         },
2736         [ALC262_FIXUP_TYAN] = {
2737                 .type = HDA_FIXUP_PINS,
2738                 .v.pins = (const struct hda_pintbl[]) {
2739                         { 0x14, 0x1993e1f0 }, /* int AUX */
2740                         { }
2741                 }
2742         },
2743         [ALC262_FIXUP_LENOVO_3000] = {
2744                 .type = HDA_FIXUP_PINCTLS,
2745                 .v.pins = (const struct hda_pintbl[]) {
2746                         { 0x19, PIN_VREF50 },
2747                         {}
2748                 },
2749                 .chained = true,
2750                 .chain_id = ALC262_FIXUP_BENQ,
2751         },
2752         [ALC262_FIXUP_BENQ] = {
2753                 .type = HDA_FIXUP_VERBS,
2754                 .v.verbs = (const struct hda_verb[]) {
2755                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2756                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2757                         {}
2758                 }
2759         },
2760         [ALC262_FIXUP_BENQ_T31] = {
2761                 .type = HDA_FIXUP_VERBS,
2762                 .v.verbs = (const struct hda_verb[]) {
2763                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2764                         { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2765                         {}
2766                 }
2767         },
2768         [ALC262_FIXUP_INV_DMIC] = {
2769                 .type = HDA_FIXUP_FUNC,
2770                 .v.func = alc_fixup_inv_dmic,
2771         },
2772         [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2773                 .type = HDA_FIXUP_FUNC,
2774                 .v.func = alc_fixup_no_depop_delay,
2775         },
2776 };
2777
2778 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2779         SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2780         SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2781         SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2782         SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2783         SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2784         SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2785         SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2786         SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2787         SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2788         SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2789         {}
2790 };
2791
2792 static const struct hda_model_fixup alc262_fixup_models[] = {
2793         {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2794         {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2795         {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2796         {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2797         {.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2798         {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2799         {.id = ALC262_FIXUP_BENQ, .name = "benq"},
2800         {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2801         {.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2802         {}
2803 };
2804
2805 /*
2806  */
2807 static int patch_alc262(struct hda_codec *codec)
2808 {
2809         struct alc_spec *spec;
2810         int err;
2811
2812         err = alc_alloc_spec(codec, 0x0b);
2813         if (err < 0)
2814                 return err;
2815
2816         spec = codec->spec;
2817         spec->gen.shared_mic_vref_pin = 0x18;
2818
2819         spec->shutup = alc_eapd_shutup;
2820
2821 #if 0
2822         /* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is
2823          * under-run
2824          */
2825         alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2826 #endif
2827         alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2828
2829         snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2830                        alc262_fixups);
2831         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2832
2833         alc_auto_parse_customize_define(codec);
2834
2835         if (has_cdefine_beep(codec))
2836                 spec->gen.beep_nid = 0x01;
2837
2838         /* automatic parse from the BIOS config */
2839         err = alc262_parse_auto_config(codec);
2840         if (err < 0)
2841                 goto error;
2842
2843         if (!spec->gen.no_analog && spec->gen.beep_nid) {
2844                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2845                 if (err < 0)
2846                         goto error;
2847         }
2848
2849         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2850
2851         return 0;
2852
2853  error:
2854         alc_free(codec);
2855         return err;
2856 }
2857
2858 /*
2859  *  ALC268
2860  */
2861 /* bind Beep switches of both NID 0x0f and 0x10 */
2862 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2863                                   struct snd_ctl_elem_value *ucontrol)
2864 {
2865         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2866         unsigned long pval;
2867         int err;
2868
2869         mutex_lock(&codec->control_mutex);
2870         pval = kcontrol->private_value;
2871         kcontrol->private_value = (pval & ~0xff) | 0x0f;
2872         err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2873         if (err >= 0) {
2874                 kcontrol->private_value = (pval & ~0xff) | 0x10;
2875                 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2876         }
2877         kcontrol->private_value = pval;
2878         mutex_unlock(&codec->control_mutex);
2879         return err;
2880 }
2881
2882 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2883         HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2884         {
2885                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2886                 .name = "Beep Playback Switch",
2887                 .subdevice = HDA_SUBDEV_AMP_FLAG,
2888                 .info = snd_hda_mixer_amp_switch_info,
2889                 .get = snd_hda_mixer_amp_switch_get,
2890                 .put = alc268_beep_switch_put,
2891                 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2892         },
2893 };
2894
2895 /* set PCBEEP vol = 0, mute connections */
2896 static const struct hda_verb alc268_beep_init_verbs[] = {
2897         {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2898         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2899         {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2900         { }
2901 };
2902
2903 enum {
2904         ALC268_FIXUP_INV_DMIC,
2905         ALC268_FIXUP_HP_EAPD,
2906         ALC268_FIXUP_SPDIF,
2907 };
2908
2909 static const struct hda_fixup alc268_fixups[] = {
2910         [ALC268_FIXUP_INV_DMIC] = {
2911                 .type = HDA_FIXUP_FUNC,
2912                 .v.func = alc_fixup_inv_dmic,
2913         },
2914         [ALC268_FIXUP_HP_EAPD] = {
2915                 .type = HDA_FIXUP_VERBS,
2916                 .v.verbs = (const struct hda_verb[]) {
2917                         {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2918                         {}
2919                 }
2920         },
2921         [ALC268_FIXUP_SPDIF] = {
2922                 .type = HDA_FIXUP_PINS,
2923                 .v.pins = (const struct hda_pintbl[]) {
2924                         { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2925                         {}
2926                 }
2927         },
2928 };
2929
2930 static const struct hda_model_fixup alc268_fixup_models[] = {
2931         {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2932         {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2933         {.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2934         {}
2935 };
2936
2937 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2938         SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2939         SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2940         /* below is codec SSID since multiple Toshiba laptops have the
2941          * same PCI SSID 1179:ff00
2942          */
2943         SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2944         {}
2945 };
2946
2947 /*
2948  * BIOS auto configuration
2949  */
2950 static int alc268_parse_auto_config(struct hda_codec *codec)
2951 {
2952         static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2953         return alc_parse_auto_config(codec, NULL, alc268_ssids);
2954 }
2955
2956 /*
2957  */
2958 static int patch_alc268(struct hda_codec *codec)
2959 {
2960         struct alc_spec *spec;
2961         int i, err;
2962
2963         /* ALC268 has no aa-loopback mixer */
2964         err = alc_alloc_spec(codec, 0);
2965         if (err < 0)
2966                 return err;
2967
2968         spec = codec->spec;
2969         spec->gen.beep_nid = 0x01;
2970
2971         spec->shutup = alc_eapd_shutup;
2972
2973         snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2974         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2975
2976         /* automatic parse from the BIOS config */
2977         err = alc268_parse_auto_config(codec);
2978         if (err < 0)
2979                 goto error;
2980
2981         if (err > 0 && !spec->gen.no_analog &&
2982             spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2983                 for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
2984                         if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
2985                                                   &alc268_beep_mixer[i])) {
2986                                 err = -ENOMEM;
2987                                 goto error;
2988                         }
2989                 }
2990                 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2991                 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2992                         /* override the amp caps for beep generator */
2993                         snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2994                                           (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2995                                           (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2996                                           (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2997                                           (0 << AC_AMPCAP_MUTE_SHIFT));
2998         }
2999
3000         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3001
3002         return 0;
3003
3004  error:
3005         alc_free(codec);
3006         return err;
3007 }
3008
3009 /*
3010  * ALC269
3011  */
3012
3013 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
3014         .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3015 };
3016
3017 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
3018         .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3019 };
3020
3021 /* different alc269-variants */
3022 enum {
3023         ALC269_TYPE_ALC269VA,
3024         ALC269_TYPE_ALC269VB,
3025         ALC269_TYPE_ALC269VC,
3026         ALC269_TYPE_ALC269VD,
3027         ALC269_TYPE_ALC280,
3028         ALC269_TYPE_ALC282,
3029         ALC269_TYPE_ALC283,
3030         ALC269_TYPE_ALC284,
3031         ALC269_TYPE_ALC293,
3032         ALC269_TYPE_ALC286,
3033         ALC269_TYPE_ALC298,
3034         ALC269_TYPE_ALC255,
3035         ALC269_TYPE_ALC256,
3036         ALC269_TYPE_ALC257,
3037         ALC269_TYPE_ALC215,
3038         ALC269_TYPE_ALC225,
3039         ALC269_TYPE_ALC294,
3040         ALC269_TYPE_ALC300,
3041         ALC269_TYPE_ALC623,
3042         ALC269_TYPE_ALC700,
3043 };
3044
3045 /*
3046  * BIOS auto configuration
3047  */
3048 static int alc269_parse_auto_config(struct hda_codec *codec)
3049 {
3050         static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3051         static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
3052         static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3053         struct alc_spec *spec = codec->spec;
3054         const hda_nid_t *ssids;
3055
3056         switch (spec->codec_variant) {
3057         case ALC269_TYPE_ALC269VA:
3058         case ALC269_TYPE_ALC269VC:
3059         case ALC269_TYPE_ALC280:
3060         case ALC269_TYPE_ALC284:
3061         case ALC269_TYPE_ALC293:
3062                 ssids = alc269va_ssids;
3063                 break;
3064         case ALC269_TYPE_ALC269VB:
3065         case ALC269_TYPE_ALC269VD:
3066         case ALC269_TYPE_ALC282:
3067         case ALC269_TYPE_ALC283:
3068         case ALC269_TYPE_ALC286:
3069         case ALC269_TYPE_ALC298:
3070         case ALC269_TYPE_ALC255:
3071         case ALC269_TYPE_ALC256:
3072         case ALC269_TYPE_ALC257:
3073         case ALC269_TYPE_ALC215:
3074         case ALC269_TYPE_ALC225:
3075         case ALC269_TYPE_ALC294:
3076         case ALC269_TYPE_ALC300:
3077         case ALC269_TYPE_ALC623:
3078         case ALC269_TYPE_ALC700:
3079                 ssids = alc269_ssids;
3080                 break;
3081         default:
3082                 ssids = alc269_ssids;
3083                 break;
3084         }
3085
3086         return alc_parse_auto_config(codec, alc269_ignore, ssids);
3087 }
3088
3089 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3090 {
3091         alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3092 }
3093
3094 static void alc269_shutup(struct hda_codec *codec)
3095 {
3096         struct alc_spec *spec = codec->spec;
3097
3098         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3099                 alc269vb_toggle_power_output(codec, 0);
3100         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3101                         (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3102                 msleep(150);
3103         }
3104         alc_shutup_pins(codec);
3105 }
3106
3107 static struct coef_fw alc282_coefs[] = {
3108         WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3109         UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3110         WRITE_COEF(0x07, 0x0200), /* DMIC control */
3111         UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3112         UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3113         WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3114         WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3115         WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
3116         UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3117         UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3118         WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
3119         UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
3120         WRITE_COEF(0x34, 0xa0c0), /* ANC */
3121         UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
3122         UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3123         UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3124         WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3125         WRITE_COEF(0x63, 0x2902), /* PLL */
3126         WRITE_COEF(0x68, 0xa080), /* capless control 2 */
3127         WRITE_COEF(0x69, 0x3400), /* capless control 3 */
3128         WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
3129         WRITE_COEF(0x6b, 0x0), /* capless control 5 */
3130         UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
3131         WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
3132         UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
3133         WRITE_COEF(0x71, 0x0014), /* class D test 6 */
3134         WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
3135         UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
3136         WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
3137         {}
3138 };
3139
3140 static void alc282_restore_default_value(struct hda_codec *codec)
3141 {
3142         alc_process_coef_fw(codec, alc282_coefs);
3143 }
3144
3145 static void alc282_init(struct hda_codec *codec)
3146 {
3147         struct alc_spec *spec = codec->spec;
3148         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3149         bool hp_pin_sense;
3150         int coef78;
3151
3152         alc282_restore_default_value(codec);
3153
3154         if (!hp_pin)
3155                 return;
3156         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3157         coef78 = alc_read_coef_idx(codec, 0x78);
3158
3159         /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3160         /* Headphone capless set to high power mode */
3161         alc_write_coef_idx(codec, 0x78, 0x9004);
3162
3163         if (hp_pin_sense)
3164                 msleep(2);
3165
3166         snd_hda_codec_write(codec, hp_pin, 0,
3167                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3168
3169         if (hp_pin_sense)
3170                 msleep(85);
3171
3172         snd_hda_codec_write(codec, hp_pin, 0,
3173                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3174
3175         if (hp_pin_sense)
3176                 msleep(100);
3177
3178         /* Headphone capless set to normal mode */
3179         alc_write_coef_idx(codec, 0x78, coef78);
3180 }
3181
3182 static void alc282_shutup(struct hda_codec *codec)
3183 {
3184         struct alc_spec *spec = codec->spec;
3185         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3186         bool hp_pin_sense;
3187         int coef78;
3188
3189         if (!hp_pin) {
3190                 alc269_shutup(codec);
3191                 return;
3192         }
3193
3194         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3195         coef78 = alc_read_coef_idx(codec, 0x78);
3196         alc_write_coef_idx(codec, 0x78, 0x9004);
3197
3198         if (hp_pin_sense)
3199                 msleep(2);
3200
3201         snd_hda_codec_write(codec, hp_pin, 0,
3202                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3203
3204         if (hp_pin_sense)
3205                 msleep(85);
3206
3207         if (!spec->no_shutup_pins)
3208                 snd_hda_codec_write(codec, hp_pin, 0,
3209                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3210
3211         if (hp_pin_sense)
3212                 msleep(100);
3213
3214         alc_auto_setup_eapd(codec, false);
3215         alc_shutup_pins(codec);
3216         alc_write_coef_idx(codec, 0x78, coef78);
3217 }
3218
3219 static struct coef_fw alc283_coefs[] = {
3220         WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3221         UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3222         WRITE_COEF(0x07, 0x0200), /* DMIC control */
3223         UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3224         UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3225         WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3226         WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3227         WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3228         UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3229         UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3230         WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3231         UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3232         WRITE_COEF(0x22, 0xa0c0), /* ANC */
3233         UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3234         UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3235         UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3236         WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3237         WRITE_COEF(0x2e, 0x2902), /* PLL */
3238         WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3239         WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3240         WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3241         WRITE_COEF(0x36, 0x0), /* capless control 5 */
3242         UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3243         WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3244         UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3245         WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3246         WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3247         UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3248         WRITE_COEF(0x49, 0x0), /* test mode */
3249         UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3250         UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3251         WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3252         UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3253         {}
3254 };
3255
3256 static void alc283_restore_default_value(struct hda_codec *codec)
3257 {
3258         alc_process_coef_fw(codec, alc283_coefs);
3259 }
3260
3261 static void alc283_init(struct hda_codec *codec)
3262 {
3263         struct alc_spec *spec = codec->spec;
3264         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3265         bool hp_pin_sense;
3266
3267         alc283_restore_default_value(codec);
3268
3269         if (!hp_pin)
3270                 return;
3271
3272         msleep(30);
3273         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3274
3275         /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3276         /* Headphone capless set to high power mode */
3277         alc_write_coef_idx(codec, 0x43, 0x9004);
3278
3279         snd_hda_codec_write(codec, hp_pin, 0,
3280                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3281
3282         if (hp_pin_sense)
3283                 msleep(85);
3284
3285         snd_hda_codec_write(codec, hp_pin, 0,
3286                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3287
3288         if (hp_pin_sense)
3289                 msleep(85);
3290         /* Index 0x46 Combo jack auto switch control 2 */
3291         /* 3k pull low control for Headset jack. */
3292         alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3293         /* Headphone capless set to normal mode */
3294         alc_write_coef_idx(codec, 0x43, 0x9614);
3295 }
3296
3297 static void alc283_shutup(struct hda_codec *codec)
3298 {
3299         struct alc_spec *spec = codec->spec;
3300         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3301         bool hp_pin_sense;
3302
3303         if (!hp_pin) {
3304                 alc269_shutup(codec);
3305                 return;
3306         }
3307
3308         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3309
3310         alc_write_coef_idx(codec, 0x43, 0x9004);
3311
3312         /*depop hp during suspend*/
3313         alc_write_coef_idx(codec, 0x06, 0x2100);
3314
3315         snd_hda_codec_write(codec, hp_pin, 0,
3316                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3317
3318         if (hp_pin_sense)
3319                 msleep(100);
3320
3321         if (!spec->no_shutup_pins)
3322                 snd_hda_codec_write(codec, hp_pin, 0,
3323                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3324
3325         alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3326
3327         if (hp_pin_sense)
3328                 msleep(100);
3329         alc_auto_setup_eapd(codec, false);
3330         alc_shutup_pins(codec);
3331         alc_write_coef_idx(codec, 0x43, 0x9614);
3332 }
3333
3334 static void alc256_init(struct hda_codec *codec)
3335 {
3336         struct alc_spec *spec = codec->spec;
3337         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3338         bool hp_pin_sense;
3339
3340         if (!hp_pin)
3341                 return;
3342
3343         msleep(30);
3344
3345         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3346
3347         if (hp_pin_sense)
3348                 msleep(2);
3349
3350         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3351
3352         snd_hda_codec_write(codec, hp_pin, 0,
3353                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3354
3355         if (hp_pin_sense)
3356                 msleep(85);
3357
3358         snd_hda_codec_write(codec, hp_pin, 0,
3359                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3360
3361         if (hp_pin_sense)
3362                 msleep(100);
3363
3364         alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3365         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3366         alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3367         alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3368         /*
3369          * Expose headphone mic (or possibly Line In on some machines) instead
3370          * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3371          * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3372          * this register.
3373          */
3374         alc_write_coef_idx(codec, 0x36, 0x5757);
3375 }
3376
3377 static void alc256_shutup(struct hda_codec *codec)
3378 {
3379         struct alc_spec *spec = codec->spec;
3380         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3381         bool hp_pin_sense;
3382
3383         if (!hp_pin) {
3384                 alc269_shutup(codec);
3385                 return;
3386         }
3387
3388         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3389
3390         if (hp_pin_sense)
3391                 msleep(2);
3392
3393         snd_hda_codec_write(codec, hp_pin, 0,
3394                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3395
3396         if (hp_pin_sense)
3397                 msleep(85);
3398
3399         /* 3k pull low control for Headset jack. */
3400         /* NOTE: call this before clearing the pin, otherwise codec stalls */
3401         /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
3402          * when booting with headset plugged. So skip setting it for the codec alc257
3403          */
3404         if (codec->core.vendor_id != 0x10ec0236 &&
3405             codec->core.vendor_id != 0x10ec0257)
3406                 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3407
3408         if (!spec->no_shutup_pins)
3409                 snd_hda_codec_write(codec, hp_pin, 0,
3410                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3411
3412         if (hp_pin_sense)
3413                 msleep(100);
3414
3415         alc_auto_setup_eapd(codec, false);
3416         alc_shutup_pins(codec);
3417 }
3418
3419 static void alc225_init(struct hda_codec *codec)
3420 {
3421         struct alc_spec *spec = codec->spec;
3422         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3423         bool hp1_pin_sense, hp2_pin_sense;
3424
3425         if (!hp_pin)
3426                 return;
3427
3428         msleep(30);
3429
3430         hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3431         hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3432
3433         if (hp1_pin_sense || hp2_pin_sense)
3434                 msleep(2);
3435
3436         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3437
3438         if (hp1_pin_sense)
3439                 snd_hda_codec_write(codec, hp_pin, 0,
3440                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3441         if (hp2_pin_sense)
3442                 snd_hda_codec_write(codec, 0x16, 0,
3443                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3444
3445         if (hp1_pin_sense || hp2_pin_sense)
3446                 msleep(85);
3447
3448         if (hp1_pin_sense)
3449                 snd_hda_codec_write(codec, hp_pin, 0,
3450                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3451         if (hp2_pin_sense)
3452                 snd_hda_codec_write(codec, 0x16, 0,
3453                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3454
3455         if (hp1_pin_sense || hp2_pin_sense)
3456                 msleep(100);
3457
3458         alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3459         alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3460 }
3461
3462 static void alc225_shutup(struct hda_codec *codec)
3463 {
3464         struct alc_spec *spec = codec->spec;
3465         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3466         bool hp1_pin_sense, hp2_pin_sense;
3467
3468         if (!hp_pin) {
3469                 alc269_shutup(codec);
3470                 return;
3471         }
3472
3473         /* 3k pull low control for Headset jack. */
3474         alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3475
3476         hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3477         hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3478
3479         if (hp1_pin_sense || hp2_pin_sense)
3480                 msleep(2);
3481
3482         if (hp1_pin_sense)
3483                 snd_hda_codec_write(codec, hp_pin, 0,
3484                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3485         if (hp2_pin_sense)
3486                 snd_hda_codec_write(codec, 0x16, 0,
3487                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3488
3489         if (hp1_pin_sense || hp2_pin_sense)
3490                 msleep(85);
3491
3492         if (hp1_pin_sense)
3493                 snd_hda_codec_write(codec, hp_pin, 0,
3494                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3495         if (hp2_pin_sense)
3496                 snd_hda_codec_write(codec, 0x16, 0,
3497                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3498
3499         if (hp1_pin_sense || hp2_pin_sense)
3500                 msleep(100);
3501
3502         alc_auto_setup_eapd(codec, false);
3503         alc_shutup_pins(codec);
3504 }
3505
3506 static void alc_default_init(struct hda_codec *codec)
3507 {
3508         struct alc_spec *spec = codec->spec;
3509         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3510         bool hp_pin_sense;
3511
3512         if (!hp_pin)
3513                 return;
3514
3515         msleep(30);
3516
3517         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3518
3519         if (hp_pin_sense)
3520                 msleep(2);
3521
3522         snd_hda_codec_write(codec, hp_pin, 0,
3523                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3524
3525         if (hp_pin_sense)
3526                 msleep(85);
3527
3528         snd_hda_codec_write(codec, hp_pin, 0,
3529                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3530
3531         if (hp_pin_sense)
3532                 msleep(100);
3533 }
3534
3535 static void alc_default_shutup(struct hda_codec *codec)
3536 {
3537         struct alc_spec *spec = codec->spec;
3538         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3539         bool hp_pin_sense;
3540
3541         if (!hp_pin) {
3542                 alc269_shutup(codec);
3543                 return;
3544         }
3545
3546         hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3547
3548         if (hp_pin_sense)
3549                 msleep(2);
3550
3551         snd_hda_codec_write(codec, hp_pin, 0,
3552                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3553
3554         if (hp_pin_sense)
3555                 msleep(85);
3556
3557         if (!spec->no_shutup_pins)
3558                 snd_hda_codec_write(codec, hp_pin, 0,
3559                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3560
3561         if (hp_pin_sense)
3562                 msleep(100);
3563
3564         alc_auto_setup_eapd(codec, false);
3565         alc_shutup_pins(codec);
3566 }
3567
3568 static void alc294_hp_init(struct hda_codec *codec)
3569 {
3570         struct alc_spec *spec = codec->spec;
3571         hda_nid_t hp_pin = alc_get_hp_pin(spec);
3572         int i, val;
3573
3574         if (!hp_pin)
3575                 return;
3576
3577         snd_hda_codec_write(codec, hp_pin, 0,
3578                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3579
3580         msleep(100);
3581
3582         if (!spec->no_shutup_pins)
3583                 snd_hda_codec_write(codec, hp_pin, 0,
3584                                     AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3585
3586         alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3587         alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3588
3589         /* Wait for depop procedure finish  */
3590         val = alc_read_coefex_idx(codec, 0x58, 0x01);
3591         for (i = 0; i < 20 && val & 0x0080; i++) {
3592                 msleep(50);
3593                 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3594         }
3595         /* Set HP depop to auto mode */
3596         alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3597         msleep(50);
3598 }
3599
3600 static void alc294_init(struct hda_codec *codec)
3601 {
3602         struct alc_spec *spec = codec->spec;
3603
3604         /* required only at boot or S4 resume time */
3605         if (!spec->done_hp_init ||
3606             codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3607                 alc294_hp_init(codec);
3608                 spec->done_hp_init = true;
3609         }
3610         alc_default_init(codec);
3611 }
3612
3613 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3614                              unsigned int val)
3615 {
3616         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3617         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3618         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3619 }
3620
3621 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3622 {
3623         unsigned int val;
3624
3625         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3626         val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3627                 & 0xffff;
3628         val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3629                 << 16;
3630         return val;
3631 }
3632
3633 static void alc5505_dsp_halt(struct hda_codec *codec)
3634 {
3635         unsigned int val;
3636
3637         alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3638         alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3639         alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3640         alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3641         alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3642         alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3643         alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3644         val = alc5505_coef_get(codec, 0x6220);
3645         alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3646 }
3647
3648 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3649 {
3650         alc5505_coef_set(codec, 0x61b8, 0x04133302);
3651         alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3652         alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3653         alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3654         alc5505_coef_set(codec, 0x6220, 0x2002010f);
3655         alc5505_coef_set(codec, 0x880c, 0x00000004);
3656 }
3657
3658 static void alc5505_dsp_init(struct hda_codec *codec)
3659 {
3660         unsigned int val;
3661
3662         alc5505_dsp_halt(codec);
3663         alc5505_dsp_back_from_halt(codec);
3664         alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3665         alc5505_coef_set(codec, 0x61b0, 0x5b16);
3666         alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3667         alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3668         alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3669         alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3670         snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3671         alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3672         alc5505_coef_set(codec, 0x61b8, 0x04173302);
3673         alc5505_coef_set(codec, 0x61b8, 0x04163302);
3674         alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3675         alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3676         alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3677
3678         val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3679         if (val <= 3)
3680                 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3681         else
3682                 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3683
3684         alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3685         alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3686         alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3687         alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3688         alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3689         alc5505_coef_set(codec, 0x880c, 0x00000003);
3690         alc5505_coef_set(codec, 0x880c, 0x00000010);
3691
3692 #ifdef HALT_REALTEK_ALC5505
3693         alc5505_dsp_halt(codec);
3694 #endif
3695 }
3696
3697 #ifdef HALT_REALTEK_ALC5505
3698 #define alc5505_dsp_suspend(codec)      /* NOP */
3699 #define alc5505_dsp_resume(codec)       /* NOP */
3700 #else
3701 #define alc5505_dsp_suspend(codec)      alc5505_dsp_halt(codec)
3702 #define alc5505_dsp_resume(codec)       alc5505_dsp_back_from_halt(codec)
3703 #endif
3704
3705 #ifdef CONFIG_PM
3706 static int alc269_suspend(struct hda_codec *codec)
3707 {
3708         struct alc_spec *spec = codec->spec;
3709
3710         if (spec->has_alc5505_dsp)
3711                 alc5505_dsp_suspend(codec);
3712         return alc_suspend(codec);
3713 }
3714
3715 static int alc269_resume(struct hda_codec *codec)
3716 {
3717         struct alc_spec *spec = codec->spec;
3718
3719         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3720                 alc269vb_toggle_power_output(codec, 0);
3721         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3722                         (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3723                 msleep(150);
3724         }
3725
3726         codec->patch_ops.init(codec);
3727
3728         if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3729                 alc269vb_toggle_power_output(codec, 1);
3730         if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3731                         (alc_get_coef0(codec) & 0x00ff) == 0x017) {
3732                 msleep(200);
3733         }
3734
3735         regcache_sync(codec->core.regmap);
3736         hda_call_check_power_status(codec, 0x01);
3737
3738         /* on some machine, the BIOS will clear the codec gpio data when enter
3739          * suspend, and won't restore the data after resume, so we restore it
3740          * in the driver.
3741          */
3742         if (spec->gpio_data)
3743                 alc_write_gpio_data(codec);
3744
3745         if (spec->has_alc5505_dsp)
3746                 alc5505_dsp_resume(codec);
3747
3748         return 0;
3749 }
3750 #endif /* CONFIG_PM */
3751
3752 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
3753                                                  const struct hda_fixup *fix, int action)
3754 {
3755         struct alc_spec *spec = codec->spec;
3756
3757         if (action == HDA_FIXUP_ACT_PRE_PROBE)
3758                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3759 }
3760
3761 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3762                                                  const struct hda_fixup *fix,
3763                                                  int action)
3764 {
3765         unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3766         unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3767
3768         if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3769                 snd_hda_codec_set_pincfg(codec, 0x19,
3770                         (cfg_headphone & ~AC_DEFCFG_DEVICE) |
3771                         (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3772 }
3773
3774 static void alc269_fixup_hweq(struct hda_codec *codec,
3775                                const struct hda_fixup *fix, int action)
3776 {
3777         if (action == HDA_FIXUP_ACT_INIT)
3778                 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
3779 }
3780
3781 static void alc269_fixup_headset_mic(struct hda_codec *codec,
3782                                        const struct hda_fixup *fix, int action)
3783 {
3784         struct alc_spec *spec = codec->spec;
3785
3786         if (action == HDA_FIXUP_ACT_PRE_PROBE)
3787                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3788 }
3789
3790 static void alc271_fixup_dmic(struct hda_codec *codec,
3791                               const struct hda_fixup *fix, int action)
3792 {
3793         static const struct hda_verb verbs[] = {
3794                 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3795                 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3796                 {}
3797         };
3798         unsigned int cfg;
3799
3800         if (strcmp(codec->core.chip_name, "ALC271X") &&
3801             strcmp(codec->core.chip_name, "ALC269VB"))
3802                 return;
3803         cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3804         if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3805                 snd_hda_sequence_write(codec, verbs);
3806 }
3807
3808 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
3809                                  const struct hda_fixup *fix, int action)
3810 {
3811         struct alc_spec *spec = codec->spec;
3812
3813         if (action != HDA_FIXUP_ACT_PROBE)
3814                 return;
3815
3816         /* Due to a hardware problem on Lenovo Ideadpad, we need to
3817          * fix the sample rate of analog I/O to 44.1kHz
3818          */
3819         spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3820         spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
3821 }
3822
3823 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
3824                                      const struct hda_fixup *fix, int action)
3825 {
3826         /* The digital-mic unit sends PDM (differential signal) instead of
3827          * the standard PCM, thus you can't record a valid mono stream as is.
3828          * Below is a workaround specific to ALC269 to control the dmic
3829          * signal source as mono.
3830          */
3831         if (action == HDA_FIXUP_ACT_INIT)
3832                 alc_update_coef_idx(codec, 0x07, 0, 0x80);
3833 }
3834
3835 static void alc269_quanta_automute(struct hda_codec *codec)
3836 {
3837         snd_hda_gen_update_outputs(codec);
3838
3839         alc_write_coef_idx(codec, 0x0c, 0x680);
3840         alc_write_coef_idx(codec, 0x0c, 0x480);
3841 }
3842
3843 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
3844                                      const struct hda_fixup *fix, int action)
3845 {
3846         struct alc_spec *spec = codec->spec;
3847         if (action != HDA_FIXUP_ACT_PROBE)
3848                 return;
3849         spec->gen.automute_hook = alc269_quanta_automute;
3850 }
3851
3852 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3853                                          struct hda_jack_callback *jack)
3854 {
3855         struct alc_spec *spec = codec->spec;
3856         int vref;
3857         msleep(200);
3858         snd_hda_gen_hp_automute(codec, jack);
3859
3860         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3861         msleep(100);
3862         snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3863                             vref);
3864         msleep(500);
3865         snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3866                             vref);
3867 }
3868
3869 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3870                                      const struct hda_fixup *fix, int action)
3871 {
3872         struct alc_spec *spec = codec->spec;
3873         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3874                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3875                 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3876         }
3877 }
3878
3879
3880 /* update mute-LED according to the speaker mute state via mic VREF pin */
3881 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
3882 {
3883         struct hda_codec *codec = private_data;
3884         struct alc_spec *spec = codec->spec;
3885         unsigned int pinval;
3886
3887         if (spec->mute_led_polarity)
3888                 enabled = !enabled;
3889         pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3890         pinval &= ~AC_PINCTL_VREFEN;
3891         pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
3892         if (spec->mute_led_nid) {
3893                 /* temporarily power up/down for setting VREF */
3894                 snd_hda_power_up_pm(codec);
3895                 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
3896                 snd_hda_power_down_pm(codec);
3897         }
3898 }
3899
3900 /* Make sure the led works even in runtime suspend */
3901 static unsigned int led_power_filter(struct hda_codec *codec,
3902                                                   hda_nid_t nid,
3903                                                   unsigned int power_state)
3904 {
3905         struct alc_spec *spec = codec->spec;
3906
3907         if (power_state != AC_PWRST_D3 || nid == 0 ||
3908             (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
3909                 return power_state;
3910
3911         /* Set pin ctl again, it might have just been set to 0 */
3912         snd_hda_set_pin_ctl(codec, nid,
3913                             snd_hda_codec_get_pin_target(codec, nid));
3914
3915         return snd_hda_gen_path_power_filter(codec, nid, power_state);
3916 }
3917
3918 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3919                                      const struct hda_fixup *fix, int action)
3920 {
3921         struct alc_spec *spec = codec->spec;
3922         const struct dmi_device *dev = NULL;
3923
3924         if (action != HDA_FIXUP_ACT_PRE_PROBE)
3925                 return;
3926
3927         while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3928                 int pol, pin;
3929                 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3930                         continue;
3931                 if (pin < 0x0a || pin >= 0x10)
3932                         break;
3933                 spec->mute_led_polarity = pol;
3934                 spec->mute_led_nid = pin - 0x0a + 0x18;
3935                 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3936                 spec->gen.vmaster_mute_enum = 1;
3937                 codec->power_filter = led_power_filter;
3938                 codec_dbg(codec,
3939                           "Detected mute LED for %x:%d\n", spec->mute_led_nid,
3940                            spec->mute_led_polarity);
3941                 break;
3942         }
3943 }
3944
3945 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
3946                                           const struct hda_fixup *fix,
3947                                           int action, hda_nid_t pin)
3948 {
3949         struct alc_spec *spec = codec->spec;
3950
3951         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3952                 spec->mute_led_polarity = 0;
3953                 spec->mute_led_nid = pin;
3954                 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3955                 spec->gen.vmaster_mute_enum = 1;
3956                 codec->power_filter = led_power_filter;
3957         }
3958 }
3959
3960 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3961                                 const struct hda_fixup *fix, int action)
3962 {
3963         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
3964 }
3965
3966 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3967                                 const struct hda_fixup *fix, int action)
3968 {
3969         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
3970 }
3971
3972 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
3973                                 const struct hda_fixup *fix, int action)
3974 {
3975         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
3976 }
3977
3978 /* update LED status via GPIO */
3979 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
3980                                 int polarity, bool enabled)
3981 {
3982         if (polarity)
3983                 enabled = !enabled;
3984         alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
3985 }
3986
3987 /* turn on/off mute LED via GPIO per vmaster hook */
3988 static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
3989 {
3990         struct hda_codec *codec = private_data;
3991         struct alc_spec *spec = codec->spec;
3992
3993         alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
3994                             spec->mute_led_polarity, enabled);
3995 }
3996
3997 /* turn on/off mic-mute LED via GPIO per capture hook */
3998 static void alc_gpio_micmute_update(struct hda_codec *codec)
3999 {
4000         struct alc_spec *spec = codec->spec;
4001
4002         alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4003                             spec->micmute_led_polarity,
4004                             spec->gen.micmute_led.led_value);
4005 }
4006
4007 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
4008 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4009                                   int action,
4010                                   unsigned int mute_mask,
4011                                   unsigned int micmute_mask)
4012 {
4013         struct alc_spec *spec = codec->spec;
4014
4015         alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4016
4017         if (action != HDA_FIXUP_ACT_PRE_PROBE)
4018                 return;
4019         if (mute_mask) {
4020                 spec->gpio_mute_led_mask = mute_mask;
4021                 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
4022         }
4023         if (micmute_mask) {
4024                 spec->gpio_mic_led_mask = micmute_mask;
4025                 snd_hda_gen_add_micmute_led(codec, alc_gpio_micmute_update);
4026         }
4027 }
4028
4029 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4030                                 const struct hda_fixup *fix, int action)
4031 {
4032         alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4033 }
4034
4035 static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4036                                 const struct hda_fixup *fix, int action)
4037 {
4038         struct alc_spec *spec = codec->spec;
4039
4040         spec->micmute_led_polarity = 1;
4041
4042         alc_fixup_hp_gpio_led(codec, action, 0x04, 0x01);
4043 }
4044
4045 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4046                                 const struct hda_fixup *fix, int action)
4047 {
4048         alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4049 }
4050
4051 /* turn on/off mic-mute LED per capture hook */
4052 static void alc_cap_micmute_update(struct hda_codec *codec)
4053 {
4054         struct alc_spec *spec = codec->spec;
4055         unsigned int pinval;
4056
4057         if (!spec->cap_mute_led_nid)
4058                 return;
4059         pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
4060         pinval &= ~AC_PINCTL_VREFEN;
4061         if (spec->gen.micmute_led.led_value)
4062                 pinval |= AC_PINCTL_VREF_80;
4063         else
4064                 pinval |= AC_PINCTL_VREF_HIZ;
4065         snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
4066 }
4067
4068 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4069                                 const struct hda_fixup *fix, int action)
4070 {
4071         struct alc_spec *spec = codec->spec;
4072
4073         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4074         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4075                 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to
4076                  * enable headphone amp
4077                  */
4078                 spec->gpio_mask |= 0x10;
4079                 spec->gpio_dir |= 0x10;
4080                 spec->cap_mute_led_nid = 0x18;
4081                 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
4082                 codec->power_filter = led_power_filter;
4083         }
4084 }
4085
4086 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4087                                    const struct hda_fixup *fix, int action)
4088 {
4089         struct alc_spec *spec = codec->spec;
4090
4091         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4092         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4093                 spec->cap_mute_led_nid = 0x18;
4094                 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
4095                 codec->power_filter = led_power_filter;
4096         }
4097 }
4098
4099 #if IS_REACHABLE(CONFIG_INPUT)
4100 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4101                                    struct hda_jack_callback *event)
4102 {
4103         struct alc_spec *spec = codec->spec;
4104
4105         /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4106            send both key on and key off event for every interrupt. */
4107         input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4108         input_sync(spec->kb_dev);
4109         input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4110         input_sync(spec->kb_dev);
4111 }
4112
4113 static int alc_register_micmute_input_device(struct hda_codec *codec)
4114 {
4115         struct alc_spec *spec = codec->spec;
4116         int i;
4117
4118         spec->kb_dev = input_allocate_device();
4119         if (!spec->kb_dev) {
4120                 codec_err(codec, "Out of memory (input_allocate_device)\n");
4121                 return -ENOMEM;
4122         }
4123
4124         spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4125
4126         spec->kb_dev->name = "Microphone Mute Button";
4127         spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4128         spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4129         spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4130         spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4131         for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4132                 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4133
4134         if (input_register_device(spec->kb_dev)) {
4135                 codec_err(codec, "input_register_device failed\n");
4136                 input_free_device(spec->kb_dev);
4137                 spec->kb_dev = NULL;
4138                 return -ENOMEM;
4139         }
4140
4141         return 0;
4142 }
4143
4144 /* GPIO1 = set according to SKU external amp
4145  * GPIO2 = mic mute hotkey
4146  * GPIO3 = mute LED
4147  * GPIO4 = mic mute LED
4148  */
4149 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4150                                              const struct hda_fixup *fix, int action)
4151 {
4152         struct alc_spec *spec = codec->spec;
4153
4154         alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4155         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4156                 spec->init_amp = ALC_INIT_DEFAULT;
4157                 if (alc_register_micmute_input_device(codec) != 0)
4158                         return;
4159
4160                 spec->gpio_mask |= 0x06;
4161                 spec->gpio_dir |= 0x02;
4162                 spec->gpio_data |= 0x02;
4163                 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4164                                           AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
4165                 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4166                                                     gpio2_mic_hotkey_event);
4167                 return;
4168         }
4169
4170         if (!spec->kb_dev)
4171                 return;
4172
4173         switch (action) {
4174         case HDA_FIXUP_ACT_FREE:
4175                 input_unregister_device(spec->kb_dev);
4176                 spec->kb_dev = NULL;
4177         }
4178 }
4179
4180 /* Line2 = mic mute hotkey
4181  * GPIO2 = mic mute LED
4182  */
4183 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4184                                              const struct hda_fixup *fix, int action)
4185 {
4186         struct alc_spec *spec = codec->spec;
4187
4188         spec->micmute_led_polarity = 1;
4189         alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4190         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4191                 spec->init_amp = ALC_INIT_DEFAULT;
4192                 if (alc_register_micmute_input_device(codec) != 0)
4193                         return;
4194
4195                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4196                                                     gpio2_mic_hotkey_event);
4197                 return;
4198         }
4199
4200         if (!spec->kb_dev)
4201                 return;
4202
4203         switch (action) {
4204         case HDA_FIXUP_ACT_FREE:
4205                 input_unregister_device(spec->kb_dev);
4206                 spec->kb_dev = NULL;
4207         }
4208 }
4209 #else /* INPUT */
4210 #define alc280_fixup_hp_gpio2_mic_hotkey        NULL
4211 #define alc233_fixup_lenovo_line2_mic_hotkey    NULL
4212 #endif /* INPUT */
4213
4214 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4215                                 const struct hda_fixup *fix, int action)
4216 {
4217         struct alc_spec *spec = codec->spec;
4218
4219         alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4220         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4221                 spec->cap_mute_led_nid = 0x18;
4222                 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
4223         }
4224 }
4225
4226 static struct coef_fw alc225_pre_hsmode[] = {
4227         UPDATE_COEF(0x4a, 1<<8, 0),
4228         UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4229         UPDATE_COEF(0x63, 3<<14, 3<<14),
4230         UPDATE_COEF(0x4a, 3<<4, 2<<4),
4231         UPDATE_COEF(0x4a, 3<<10, 3<<10),
4232         UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4233         UPDATE_COEF(0x4a, 3<<10, 0),
4234         {}
4235 };
4236
4237 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4238 {
4239         static struct coef_fw coef0255[] = {
4240                 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4241                 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4242                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4243                 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4244                 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4245                 {}
4246         };
4247         static struct coef_fw coef0256[] = {
4248                 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4249                 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4250                 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4251                 WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4252                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4253                 {}
4254         };
4255         static struct coef_fw coef0233[] = {
4256                 WRITE_COEF(0x1b, 0x0c0b),
4257                 WRITE_COEF(0x45, 0xc429),
4258                 UPDATE_COEF(0x35, 0x4000, 0),
4259                 WRITE_COEF(0x06, 0x2104),
4260                 WRITE_COEF(0x1a, 0x0001),
4261                 WRITE_COEF(0x26, 0x0004),
4262                 WRITE_COEF(0x32, 0x42a3),
4263                 {}
4264         };
4265         static struct coef_fw coef0288[] = {
4266                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4267                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4268                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4269                 UPDATE_COEF(0x66, 0x0008, 0),
4270                 UPDATE_COEF(0x67, 0x2000, 0),
4271                 {}
4272         };
4273         static struct coef_fw coef0298[] = {
4274                 UPDATE_COEF(0x19, 0x1300, 0x0300),
4275                 {}
4276         };
4277         static struct coef_fw coef0292[] = {
4278                 WRITE_COEF(0x76, 0x000e),
4279                 WRITE_COEF(0x6c, 0x2400),
4280                 WRITE_COEF(0x18, 0x7308),
4281                 WRITE_COEF(0x6b, 0xc429),
4282                 {}
4283         };
4284         static struct coef_fw coef0293[] = {
4285                 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4286                 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4287                 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4288                 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4289                 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4290                 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4291                 {}
4292         };
4293         static struct coef_fw coef0668[] = {
4294                 WRITE_COEF(0x15, 0x0d40),
4295                 WRITE_COEF(0xb7, 0x802b),
4296                 {}
4297         };
4298         static struct coef_fw coef0225[] = {
4299                 UPDATE_COEF(0x63, 3<<14, 0),
4300                 {}
4301         };
4302         static struct coef_fw coef0274[] = {
4303                 UPDATE_COEF(0x4a, 0x0100, 0),
4304                 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4305                 UPDATE_COEF(0x6b, 0xf000, 0x5000),
4306                 UPDATE_COEF(0x4a, 0x0010, 0),
4307                 UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4308                 WRITE_COEF(0x45, 0x5289),
4309                 UPDATE_COEF(0x4a, 0x0c00, 0),
4310                 {}
4311         };
4312
4313         switch (codec->core.vendor_id) {
4314         case 0x10ec0255:
4315                 alc_process_coef_fw(codec, coef0255);
4316                 break;
4317         case 0x10ec0236:
4318         case 0x10ec0256:
4319                 alc_process_coef_fw(codec, coef0256);
4320                 break;
4321         case 0x10ec0234:
4322         case 0x10ec0274:
4323         case 0x10ec0294:
4324                 alc_process_coef_fw(codec, coef0274);
4325                 break;
4326         case 0x10ec0233:
4327         case 0x10ec0283:
4328                 alc_process_coef_fw(codec, coef0233);
4329                 break;
4330         case 0x10ec0286:
4331         case 0x10ec0288:
4332                 alc_process_coef_fw(codec, coef0288);
4333                 break;
4334         case 0x10ec0298:
4335                 alc_process_coef_fw(codec, coef0298);
4336                 alc_process_coef_fw(codec, coef0288);
4337                 break;
4338         case 0x10ec0292:
4339                 alc_process_coef_fw(codec, coef0292);
4340                 break;
4341         case 0x10ec0293:
4342                 alc_process_coef_fw(codec, coef0293);
4343                 break;
4344         case 0x10ec0668:
4345                 alc_process_coef_fw(codec, coef0668);
4346                 break;
4347         case 0x10ec0215:
4348         case 0x10ec0225:
4349         case 0x10ec0285:
4350         case 0x10ec0295:
4351         case 0x10ec0289:
4352         case 0x10ec0299:
4353                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4354                 alc_process_coef_fw(codec, coef0225);
4355                 break;
4356         case 0x10ec0867:
4357                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4358                 break;
4359         }
4360         codec_dbg(codec, "Headset jack set to unplugged mode.\n");
4361 }
4362
4363
4364 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4365                                     hda_nid_t mic_pin)
4366 {
4367         static struct coef_fw coef0255[] = {
4368                 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4369                 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4370                 {}
4371         };
4372         static struct coef_fw coef0256[] = {
4373                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
4374                 WRITE_COEFEX(0x57, 0x03, 0x09a3),
4375                 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4376                 {}
4377         };
4378         static struct coef_fw coef0233[] = {
4379                 UPDATE_COEF(0x35, 0, 1<<14),
4380                 WRITE_COEF(0x06, 0x2100),
4381                 WRITE_COEF(0x1a, 0x0021),
4382                 WRITE_COEF(0x26, 0x008c),
4383                 {}
4384         };
4385         static struct coef_fw coef0288[] = {
4386                 UPDATE_COEF(0x4f, 0x00c0, 0),
4387                 UPDATE_COEF(0x50, 0x2000, 0),
4388                 UPDATE_COEF(0x56, 0x0006, 0),
4389                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4390                 UPDATE_COEF(0x66, 0x0008, 0x0008),
4391                 UPDATE_COEF(0x67, 0x2000, 0x2000),
4392                 {}
4393         };
4394         static struct coef_fw coef0292[] = {
4395                 WRITE_COEF(0x19, 0xa208),
4396                 WRITE_COEF(0x2e, 0xacf0),
4397                 {}
4398         };
4399         static struct coef_fw coef0293[] = {
4400                 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4401                 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4402                 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4403                 {}
4404         };
4405         static struct coef_fw coef0688[] = {
4406                 WRITE_COEF(0xb7, 0x802b),
4407                 WRITE_COEF(0xb5, 0x1040),
4408                 UPDATE_COEF(0xc3, 0, 1<<12),
4409                 {}
4410         };
4411         static struct coef_fw coef0225[] = {
4412                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4413                 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4414                 UPDATE_COEF(0x63, 3<<14, 0),
4415                 {}
4416         };
4417         static struct coef_fw coef0274[] = {
4418                 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4419                 UPDATE_COEF(0x4a, 0x0010, 0),
4420                 UPDATE_COEF(0x6b, 0xf000, 0),
4421                 {}
4422         };
4423
4424         switch (codec->core.vendor_id) {
4425         case 0x10ec0255:
4426                 alc_write_coef_idx(codec, 0x45, 0xc489);
4427                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4428                 alc_process_coef_fw(codec, coef0255);
4429                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4430                 break;
4431         case 0x10ec0236:
4432         case 0x10ec0256:
4433                 alc_write_coef_idx(codec, 0x45, 0xc489);
4434                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4435                 alc_process_coef_fw(codec, coef0256);
4436                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4437                 break;
4438         case 0x10ec0234:
4439         case 0x10ec0274:
4440         case 0x10ec0294:
4441                 alc_write_coef_idx(codec, 0x45, 0x4689);
4442                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4443                 alc_process_coef_fw(codec, coef0274);
4444                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4445                 break;
4446         case 0x10ec0233:
4447         case 0x10ec0283:
4448                 alc_write_coef_idx(codec, 0x45, 0xc429);
4449                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4450                 alc_process_coef_fw(codec, coef0233);
4451                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4452                 break;
4453         case 0x10ec0286:
4454         case 0x10ec0288:
4455         case 0x10ec0298:
4456                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4457                 alc_process_coef_fw(codec, coef0288);
4458                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4459                 break;
4460         case 0x10ec0292:
4461                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4462                 alc_process_coef_fw(codec, coef0292);
4463                 break;
4464         case 0x10ec0293:
4465                 /* Set to TRS mode */
4466                 alc_write_coef_idx(codec, 0x45, 0xc429);
4467                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4468                 alc_process_coef_fw(codec, coef0293);
4469                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4470                 break;
4471         case 0x10ec0867:
4472                 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4473                 /* fallthru */
4474         case 0x10ec0221:
4475         case 0x10ec0662:
4476                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4477                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4478                 break;
4479         case 0x10ec0668:
4480                 alc_write_coef_idx(codec, 0x11, 0x0001);
4481                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4482                 alc_process_coef_fw(codec, coef0688);
4483                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4484                 break;
4485         case 0x10ec0215:
4486         case 0x10ec0225:
4487         case 0x10ec0285:
4488         case 0x10ec0295:
4489         case 0x10ec0289:
4490         case 0x10ec0299:
4491                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4492                 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4493                 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4494                 alc_process_coef_fw(codec, coef0225);
4495                 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4496                 break;
4497         }
4498         codec_dbg(codec, "Headset jack set to mic-in mode.\n");
4499 }
4500
4501 static void alc_headset_mode_default(struct hda_codec *codec)
4502 {
4503         static struct coef_fw coef0225[] = {
4504                 UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4505                 UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4506                 UPDATE_COEF(0x49, 3<<8, 0<<8),
4507                 UPDATE_COEF(0x4a, 3<<4, 3<<4),
4508                 UPDATE_COEF(0x63, 3<<14, 0),
4509                 UPDATE_COEF(0x67, 0xf000, 0x3000),
4510                 {}
4511         };
4512         static struct coef_fw coef0255[] = {
4513                 WRITE_COEF(0x45, 0xc089),
4514                 WRITE_COEF(0x45, 0xc489),
4515                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4516                 WRITE_COEF(0x49, 0x0049),
4517                 {}
4518         };
4519         static struct coef_fw coef0256[] = {
4520                 WRITE_COEF(0x45, 0xc489),
4521                 WRITE_COEFEX(0x57, 0x03, 0x0da3),
4522                 WRITE_COEF(0x49, 0x0049),
4523                 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4524                 WRITE_COEF(0x06, 0x6100),
4525                 {}
4526         };
4527         static struct coef_fw coef0233[] = {
4528                 WRITE_COEF(0x06, 0x2100),
4529                 WRITE_COEF(0x32, 0x4ea3),
4530                 {}
4531         };
4532         static struct coef_fw coef0288[] = {
4533                 UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
4534                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4535                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4536                 UPDATE_COEF(0x66, 0x0008, 0),
4537                 UPDATE_COEF(0x67, 0x2000, 0),
4538                 {}
4539         };
4540         static struct coef_fw coef0292[] = {
4541                 WRITE_COEF(0x76, 0x000e),
4542                 WRITE_COEF(0x6c, 0x2400),
4543                 WRITE_COEF(0x6b, 0xc429),
4544                 WRITE_COEF(0x18, 0x7308),
4545                 {}
4546         };
4547         static struct coef_fw coef0293[] = {
4548                 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4549                 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
4550                 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4551                 {}
4552         };
4553         static struct coef_fw coef0688[] = {
4554                 WRITE_COEF(0x11, 0x0041),
4555                 WRITE_COEF(0x15, 0x0d40),
4556                 WRITE_COEF(0xb7, 0x802b),
4557                 {}
4558         };
4559         static struct coef_fw coef0274[] = {
4560                 WRITE_COEF(0x45, 0x4289),
4561                 UPDATE_COEF(0x4a, 0x0010, 0x0010),
4562                 UPDATE_COEF(0x6b, 0x0f00, 0),
4563                 UPDATE_COEF(0x49, 0x0300, 0x0300),
4564                 {}
4565         };
4566
4567         switch (codec->core.vendor_id) {
4568         case 0x10ec0215:
4569         case 0x10ec0225:
4570         case 0x10ec0285:
4571         case 0x10ec0295:
4572         case 0x10ec0289:
4573         case 0x10ec0299:
4574                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4575                 alc_process_coef_fw(codec, coef0225);
4576                 break;
4577         case 0x10ec0255:
4578                 alc_process_coef_fw(codec, coef0255);
4579                 break;
4580         case 0x10ec0236:
4581         case 0x10ec0256:
4582                 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4583                 alc_write_coef_idx(codec, 0x45, 0xc089);
4584                 msleep(50);
4585                 alc_process_coef_fw(codec, coef0256);
4586                 break;
4587         case 0x10ec0234:
4588         case 0x10ec0274:
4589         case 0x10ec0294:
4590                 alc_process_coef_fw(codec, coef0274);
4591                 break;
4592         case 0x10ec0233:
4593         case 0x10ec0283:
4594                 alc_process_coef_fw(codec, coef0233);
4595                 break;
4596         case 0x10ec0286:
4597         case 0x10ec0288:
4598         case 0x10ec0298:
4599                 alc_process_coef_fw(codec, coef0288);
4600                 break;
4601         case 0x10ec0292:
4602                 alc_process_coef_fw(codec, coef0292);
4603                 break;
4604         case 0x10ec0293:
4605                 alc_process_coef_fw(codec, coef0293);
4606                 break;
4607         case 0x10ec0668:
4608                 alc_process_coef_fw(codec, coef0688);
4609                 break;
4610         case 0x10ec0867:
4611                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4612                 break;
4613         }
4614         codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
4615 }
4616
4617 /* Iphone type */
4618 static void alc_headset_mode_ctia(struct hda_codec *codec)
4619 {
4620         int val;
4621
4622         static struct coef_fw coef0255[] = {
4623                 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4624                 WRITE_COEF(0x1b, 0x0c2b),
4625                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4626                 {}
4627         };
4628         static struct coef_fw coef0256[] = {
4629                 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4630                 WRITE_COEF(0x1b, 0x0e6b),
4631                 {}
4632         };
4633         static struct coef_fw coef0233[] = {
4634                 WRITE_COEF(0x45, 0xd429),
4635                 WRITE_COEF(0x1b, 0x0c2b),
4636                 WRITE_COEF(0x32, 0x4ea3),
4637                 {}
4638         };
4639         static struct coef_fw coef0288[] = {
4640                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4641                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4642                 UPDATE_COEF(0x66, 0x0008, 0),
4643                 UPDATE_COEF(0x67, 0x2000, 0),
4644                 {}
4645         };
4646         static struct coef_fw coef0292[] = {
4647                 WRITE_COEF(0x6b, 0xd429),
4648                 WRITE_COEF(0x76, 0x0008),
4649                 WRITE_COEF(0x18, 0x7388),
4650                 {}
4651         };
4652         static struct coef_fw coef0293[] = {
4653                 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
4654                 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4655                 {}
4656         };
4657         static struct coef_fw coef0688[] = {
4658                 WRITE_COEF(0x11, 0x0001),
4659                 WRITE_COEF(0x15, 0x0d60),
4660                 WRITE_COEF(0xc3, 0x0000),
4661                 {}
4662         };
4663         static struct coef_fw coef0225_1[] = {
4664                 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4665                 UPDATE_COEF(0x63, 3<<14, 2<<14),
4666                 {}
4667         };
4668         static struct coef_fw coef0225_2[] = {
4669                 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4670                 UPDATE_COEF(0x63, 3<<14, 1<<14),
4671                 {}
4672         };
4673
4674         switch (codec->core.vendor_id) {
4675         case 0x10ec0255:
4676                 alc_process_coef_fw(codec, coef0255);
4677                 break;
4678         case 0x10ec0236:
4679         case 0x10ec0256:
4680                 alc_process_coef_fw(codec, coef0256);
4681                 break;
4682         case 0x10ec0234:
4683         case 0x10ec0274:
4684         case 0x10ec0294:
4685                 alc_write_coef_idx(codec, 0x45, 0xd689);
4686                 break;
4687         case 0x10ec0233:
4688         case 0x10ec0283:
4689                 alc_process_coef_fw(codec, coef0233);
4690                 break;
4691         case 0x10ec0298:
4692                 val = alc_read_coef_idx(codec, 0x50);
4693                 if (val & (1 << 12)) {
4694                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4695                         alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4696                         msleep(300);
4697                 } else {
4698                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4699                         alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4700                         msleep(300);
4701                 }
4702                 break;
4703         case 0x10ec0286:
4704         case 0x10ec0288:
4705                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4706                 msleep(300);
4707                 alc_process_coef_fw(codec, coef0288);
4708                 break;
4709         case 0x10ec0292:
4710                 alc_process_coef_fw(codec, coef0292);
4711                 break;
4712         case 0x10ec0293:
4713                 alc_process_coef_fw(codec, coef0293);
4714                 break;
4715         case 0x10ec0668:
4716                 alc_process_coef_fw(codec, coef0688);
4717                 break;
4718         case 0x10ec0215:
4719         case 0x10ec0225:
4720         case 0x10ec0285:
4721         case 0x10ec0295:
4722         case 0x10ec0289:
4723         case 0x10ec0299:
4724                 val = alc_read_coef_idx(codec, 0x45);
4725                 if (val & (1 << 9))
4726                         alc_process_coef_fw(codec, coef0225_2);
4727                 else
4728                         alc_process_coef_fw(codec, coef0225_1);
4729                 break;
4730         case 0x10ec0867:
4731                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4732                 break;
4733         }
4734         codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
4735 }
4736
4737 /* Nokia type */
4738 static void alc_headset_mode_omtp(struct hda_codec *codec)
4739 {
4740         static struct coef_fw coef0255[] = {
4741                 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4742                 WRITE_COEF(0x1b, 0x0c2b),
4743                 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4744                 {}
4745         };
4746         static struct coef_fw coef0256[] = {
4747                 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4748                 WRITE_COEF(0x1b, 0x0e6b),
4749                 {}
4750         };
4751         static struct coef_fw coef0233[] = {
4752                 WRITE_COEF(0x45, 0xe429),
4753                 WRITE_COEF(0x1b, 0x0c2b),
4754                 WRITE_COEF(0x32, 0x4ea3),
4755                 {}
4756         };
4757         static struct coef_fw coef0288[] = {
4758                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4759                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4760                 UPDATE_COEF(0x66, 0x0008, 0),
4761                 UPDATE_COEF(0x67, 0x2000, 0),
4762                 {}
4763         };
4764         static struct coef_fw coef0292[] = {
4765                 WRITE_COEF(0x6b, 0xe429),
4766                 WRITE_COEF(0x76, 0x0008),
4767                 WRITE_COEF(0x18, 0x7388),
4768                 {}
4769         };
4770         static struct coef_fw coef0293[] = {
4771                 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
4772                 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4773                 {}
4774         };
4775         static struct coef_fw coef0688[] = {
4776                 WRITE_COEF(0x11, 0x0001),
4777                 WRITE_COEF(0x15, 0x0d50),
4778                 WRITE_COEF(0xc3, 0x0000),
4779                 {}
4780         };
4781         static struct coef_fw coef0225[] = {
4782                 UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
4783                 UPDATE_COEF(0x63, 3<<14, 2<<14),
4784                 {}
4785         };
4786
4787         switch (codec->core.vendor_id) {
4788         case 0x10ec0255:
4789                 alc_process_coef_fw(codec, coef0255);
4790                 break;
4791         case 0x10ec0236:
4792         case 0x10ec0256:
4793                 alc_process_coef_fw(codec, coef0256);
4794                 break;
4795         case 0x10ec0234:
4796         case 0x10ec0274:
4797         case 0x10ec0294:
4798                 alc_write_coef_idx(codec, 0x45, 0xe689);
4799                 break;
4800         case 0x10ec0233:
4801         case 0x10ec0283:
4802                 alc_process_coef_fw(codec, coef0233);
4803                 break;
4804         case 0x10ec0298:
4805                 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
4806                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4807                 msleep(300);
4808                 break;
4809         case 0x10ec0286:
4810         case 0x10ec0288:
4811                 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4812                 msleep(300);
4813                 alc_process_coef_fw(codec, coef0288);
4814                 break;
4815         case 0x10ec0292:
4816                 alc_process_coef_fw(codec, coef0292);
4817                 break;
4818         case 0x10ec0293:
4819                 alc_process_coef_fw(codec, coef0293);
4820                 break;
4821         case 0x10ec0668:
4822                 alc_process_coef_fw(codec, coef0688);
4823                 break;
4824         case 0x10ec0215:
4825         case 0x10ec0225:
4826         case 0x10ec0285:
4827         case 0x10ec0295:
4828         case 0x10ec0289:
4829         case 0x10ec0299:
4830                 alc_process_coef_fw(codec, coef0225);
4831                 break;
4832         }
4833         codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
4834 }
4835
4836 static void alc_determine_headset_type(struct hda_codec *codec)
4837 {
4838         int val;
4839         bool is_ctia = false;
4840         struct alc_spec *spec = codec->spec;
4841         static struct coef_fw coef0255[] = {
4842                 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
4843                 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
4844  conteol) */
4845                 {}
4846         };
4847         static struct coef_fw coef0288[] = {
4848                 UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
4849                 {}
4850         };
4851         static struct coef_fw coef0298[] = {
4852                 UPDATE_COEF(0x50, 0x2000, 0x2000),
4853                 UPDATE_COEF(0x56, 0x0006, 0x0006),
4854                 UPDATE_COEF(0x66, 0x0008, 0),
4855                 UPDATE_COEF(0x67, 0x2000, 0),
4856                 UPDATE_COEF(0x19, 0x1300, 0x1300),
4857                 {}
4858         };
4859         static struct coef_fw coef0293[] = {
4860                 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
4861                 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
4862                 {}
4863         };
4864         static struct coef_fw coef0688[] = {
4865                 WRITE_COEF(0x11, 0x0001),
4866                 WRITE_COEF(0xb7, 0x802b),
4867                 WRITE_COEF(0x15, 0x0d60),
4868                 WRITE_COEF(0xc3, 0x0c00),
4869                 {}
4870         };
4871         static struct coef_fw coef0274[] = {
4872                 UPDATE_COEF(0x4a, 0x0010, 0),
4873                 UPDATE_COEF(0x4a, 0x8000, 0),
4874                 WRITE_COEF(0x45, 0xd289),
4875                 UPDATE_COEF(0x49, 0x0300, 0x0300),
4876                 {}
4877         };
4878
4879         switch (codec->core.vendor_id) {
4880         case 0x10ec0255:
4881                 alc_process_coef_fw(codec, coef0255);
4882                 msleep(300);
4883                 val = alc_read_coef_idx(codec, 0x46);
4884                 is_ctia = (val & 0x0070) == 0x0070;
4885                 break;
4886         case 0x10ec0236:
4887         case 0x10ec0256:
4888                 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4889                 alc_write_coef_idx(codec, 0x06, 0x6104);
4890                 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
4891
4892                 snd_hda_codec_write(codec, 0x21, 0,
4893                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4894                 msleep(80);
4895                 snd_hda_codec_write(codec, 0x21, 0,
4896                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4897
4898                 alc_process_coef_fw(codec, coef0255);
4899                 msleep(300);
4900                 val = alc_read_coef_idx(codec, 0x46);
4901                 is_ctia = (val & 0x0070) == 0x0070;
4902
4903                 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
4904                 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4905
4906                 snd_hda_codec_write(codec, 0x21, 0,
4907                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4908                 msleep(80);
4909                 snd_hda_codec_write(codec, 0x21, 0,
4910                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4911                 break;
4912         case 0x10ec0234:
4913         case 0x10ec0274:
4914         case 0x10ec0294:
4915                 alc_process_coef_fw(codec, coef0274);
4916                 msleep(850);
4917                 val = alc_read_coef_idx(codec, 0x46);
4918                 is_ctia = (val & 0x00f0) == 0x00f0;
4919                 break;
4920         case 0x10ec0233:
4921         case 0x10ec0283:
4922                 alc_write_coef_idx(codec, 0x45, 0xd029);
4923                 msleep(300);
4924                 val = alc_read_coef_idx(codec, 0x46);
4925                 is_ctia = (val & 0x0070) == 0x0070;
4926                 break;
4927         case 0x10ec0298:
4928                 snd_hda_codec_write(codec, 0x21, 0,
4929                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4930                 msleep(100);
4931                 snd_hda_codec_write(codec, 0x21, 0,
4932                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4933                 msleep(200);
4934
4935                 val = alc_read_coef_idx(codec, 0x50);
4936                 if (val & (1 << 12)) {
4937                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4938                         alc_process_coef_fw(codec, coef0288);
4939                         msleep(350);
4940                         val = alc_read_coef_idx(codec, 0x50);
4941                         is_ctia = (val & 0x0070) == 0x0070;
4942                 } else {
4943                         alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4944                         alc_process_coef_fw(codec, coef0288);
4945                         msleep(350);
4946                         val = alc_read_coef_idx(codec, 0x50);
4947                         is_ctia = (val & 0x0070) == 0x0070;
4948                 }
4949                 alc_process_coef_fw(codec, coef0298);
4950                 snd_hda_codec_write(codec, 0x21, 0,
4951                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4952                 msleep(75);
4953                 snd_hda_codec_write(codec, 0x21, 0,
4954                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4955                 break;
4956         case 0x10ec0286:
4957         case 0x10ec0288:
4958                 alc_process_coef_fw(codec, coef0288);
4959                 msleep(350);
4960                 val = alc_read_coef_idx(codec, 0x50);
4961                 is_ctia = (val & 0x0070) == 0x0070;
4962                 break;
4963         case 0x10ec0292:
4964                 alc_write_coef_idx(codec, 0x6b, 0xd429);
4965                 msleep(300);
4966                 val = alc_read_coef_idx(codec, 0x6c);
4967                 is_ctia = (val & 0x001c) == 0x001c;
4968                 break;
4969         case 0x10ec0293:
4970                 alc_process_coef_fw(codec, coef0293);
4971                 msleep(300);
4972                 val = alc_read_coef_idx(codec, 0x46);
4973                 is_ctia = (val & 0x0070) == 0x0070;
4974                 break;
4975         case 0x10ec0668:
4976                 alc_process_coef_fw(codec, coef0688);
4977                 msleep(300);
4978                 val = alc_read_coef_idx(codec, 0xbe);
4979                 is_ctia = (val & 0x1c02) == 0x1c02;
4980                 break;
4981         case 0x10ec0215:
4982         case 0x10ec0225:
4983         case 0x10ec0285:
4984         case 0x10ec0295:
4985         case 0x10ec0289:
4986         case 0x10ec0299:
4987                 snd_hda_codec_write(codec, 0x21, 0,
4988                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4989                 msleep(80);
4990                 snd_hda_codec_write(codec, 0x21, 0,
4991                             AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4992
4993                 alc_process_coef_fw(codec, alc225_pre_hsmode);
4994                 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
4995                 val = alc_read_coef_idx(codec, 0x45);
4996                 if (val & (1 << 9)) {
4997                         alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4998                         alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
4999                         msleep(800);
5000                         val = alc_read_coef_idx(codec, 0x46);
5001                         is_ctia = (val & 0x00f0) == 0x00f0;
5002                 } else {
5003                         alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5004                         alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5005                         msleep(800);
5006                         val = alc_read_coef_idx(codec, 0x46);
5007                         is_ctia = (val & 0x00f0) == 0x00f0;
5008                 }
5009                 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5010                 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5011                 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5012
5013                 snd_hda_codec_write(codec, 0x21, 0,
5014                             AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5015                 msleep(80);
5016                 snd_hda_codec_write(codec, 0x21, 0,
5017                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5018                 break;
5019         case 0x10ec0867:
5020                 is_ctia = true;
5021                 break;
5022         }
5023
5024         codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5025                     is_ctia ? "yes" : "no");
5026         spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5027 }
5028
5029 static void alc_update_headset_mode(struct hda_codec *codec)
5030 {
5031         struct alc_spec *spec = codec->spec;
5032
5033         hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5034         hda_nid_t hp_pin = alc_get_hp_pin(spec);
5035
5036         int new_headset_mode;
5037
5038         if (!snd_hda_jack_detect(codec, hp_pin))
5039                 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
5040         else if (mux_pin == spec->headset_mic_pin)
5041                 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
5042         else if (mux_pin == spec->headphone_mic_pin)
5043                 new_headset_mode = ALC_HEADSET_MODE_MIC;
5044         else
5045                 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
5046
5047         if (new_headset_mode == spec->current_headset_mode) {
5048                 snd_hda_gen_update_outputs(codec);
5049                 return;
5050         }
5051
5052         switch (new_headset_mode) {
5053         case ALC_HEADSET_MODE_UNPLUGGED:
5054                 alc_headset_mode_unplugged(codec);
5055                 spec->gen.hp_jack_present = false;
5056                 break;
5057         case ALC_HEADSET_MODE_HEADSET:
5058                 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5059                         alc_determine_headset_type(codec);
5060                 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5061                         alc_headset_mode_ctia(codec);
5062                 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5063                         alc_headset_mode_omtp(codec);
5064                 spec->gen.hp_jack_present = true;
5065                 break;
5066         case ALC_HEADSET_MODE_MIC:
5067                 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5068                 spec->gen.hp_jack_present = false;
5069                 break;
5070         case ALC_HEADSET_MODE_HEADPHONE:
5071                 alc_headset_mode_default(codec);
5072                 spec->gen.hp_jack_present = true;
5073                 break;
5074         }
5075         if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5076                 snd_hda_set_pin_ctl_cache(codec, hp_pin,
5077                                           AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5078                 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5079                         snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5080                                                   PIN_VREFHIZ);
5081         }
5082         spec->current_headset_mode = new_headset_mode;
5083
5084         snd_hda_gen_update_outputs(codec);
5085 }
5086
5087 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5088                                          struct snd_kcontrol *kcontrol,
5089                                          struct snd_ctl_elem_value *ucontrol)
5090 {
5091         alc_update_headset_mode(codec);
5092 }
5093
5094 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5095                                        struct hda_jack_callback *jack)
5096 {
5097         struct alc_spec *spec = codec->spec;
5098         spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5099         snd_hda_gen_hp_automute(codec, jack);
5100         alc_update_headset_mode(codec);
5101 }
5102
5103 static void alc_probe_headset_mode(struct hda_codec *codec)
5104 {
5105         int i;
5106         struct alc_spec *spec = codec->spec;
5107         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5108
5109         /* Find mic pins */
5110         for (i = 0; i < cfg->num_inputs; i++) {
5111                 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5112                         spec->headset_mic_pin = cfg->inputs[i].pin;
5113                 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5114                         spec->headphone_mic_pin = cfg->inputs[i].pin;
5115         }
5116
5117         WARN_ON(spec->gen.cap_sync_hook);
5118         spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5119         spec->gen.automute_hook = alc_update_headset_mode;
5120         spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5121 }
5122
5123 static void alc_fixup_headset_mode(struct hda_codec *codec,
5124                                 const struct hda_fixup *fix, int action)
5125 {
5126         struct alc_spec *spec = codec->spec;
5127
5128         switch (action) {
5129         case HDA_FIXUP_ACT_PRE_PROBE:
5130                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5131                 break;
5132         case HDA_FIXUP_ACT_PROBE:
5133                 alc_probe_headset_mode(codec);
5134                 break;
5135         case HDA_FIXUP_ACT_INIT:
5136                 spec->current_headset_mode = 0;
5137                 alc_update_headset_mode(codec);
5138                 break;
5139         }
5140 }
5141
5142 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5143                                 const struct hda_fixup *fix, int action)
5144 {
5145         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5146                 struct alc_spec *spec = codec->spec;
5147                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5148         }
5149         else
5150                 alc_fixup_headset_mode(codec, fix, action);
5151 }
5152
5153 static void alc255_set_default_jack_type(struct hda_codec *codec)
5154 {
5155         /* Set to iphone type */
5156         static struct coef_fw alc255fw[] = {
5157                 WRITE_COEF(0x1b, 0x880b),
5158                 WRITE_COEF(0x45, 0xd089),
5159                 WRITE_COEF(0x1b, 0x080b),
5160                 WRITE_COEF(0x46, 0x0004),
5161                 WRITE_COEF(0x1b, 0x0c0b),
5162                 {}
5163         };
5164         static struct coef_fw alc256fw[] = {
5165                 WRITE_COEF(0x1b, 0x884b),
5166                 WRITE_COEF(0x45, 0xd089),
5167                 WRITE_COEF(0x1b, 0x084b),
5168                 WRITE_COEF(0x46, 0x0004),
5169                 WRITE_COEF(0x1b, 0x0c4b),
5170                 {}
5171         };
5172         switch (codec->core.vendor_id) {
5173         case 0x10ec0255:
5174                 alc_process_coef_fw(codec, alc255fw);
5175                 break;
5176         case 0x10ec0236:
5177         case 0x10ec0256:
5178                 alc_process_coef_fw(codec, alc256fw);
5179                 break;
5180         }
5181         msleep(30);
5182 }
5183
5184 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5185                                 const struct hda_fixup *fix, int action)
5186 {
5187         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5188                 alc255_set_default_jack_type(codec);
5189         }
5190         alc_fixup_headset_mode(codec, fix, action);
5191 }
5192
5193 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5194                                 const struct hda_fixup *fix, int action)
5195 {
5196         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5197                 struct alc_spec *spec = codec->spec;
5198                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5199                 alc255_set_default_jack_type(codec);
5200         } 
5201         else
5202                 alc_fixup_headset_mode(codec, fix, action);
5203 }
5204
5205 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5206                                        struct hda_jack_callback *jack)
5207 {
5208         struct alc_spec *spec = codec->spec;
5209
5210         alc_update_headset_jack_cb(codec, jack);
5211         /* Headset Mic enable or disable, only for Dell Dino */
5212         alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5213 }
5214
5215 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5216                                 const struct hda_fixup *fix, int action)
5217 {
5218         alc_fixup_headset_mode(codec, fix, action);
5219         if (action == HDA_FIXUP_ACT_PROBE) {
5220                 struct alc_spec *spec = codec->spec;
5221                 /* toggled via hp_automute_hook */
5222                 spec->gpio_mask |= 0x40;
5223                 spec->gpio_dir |= 0x40;
5224                 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5225         }
5226 }
5227
5228 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5229                                         const struct hda_fixup *fix, int action)
5230 {
5231         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5232                 struct alc_spec *spec = codec->spec;
5233                 spec->gen.auto_mute_via_amp = 1;
5234         }
5235 }
5236
5237 static void alc_fixup_no_shutup(struct hda_codec *codec,
5238                                 const struct hda_fixup *fix, int action)
5239 {
5240         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5241                 struct alc_spec *spec = codec->spec;
5242                 spec->no_shutup_pins = 1;
5243         }
5244 }
5245
5246 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5247                                     const struct hda_fixup *fix, int action)
5248 {
5249         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5250                 struct alc_spec *spec = codec->spec;
5251                 /* Disable AA-loopback as it causes white noise */
5252                 spec->gen.mixer_nid = 0;
5253         }
5254 }
5255
5256 /* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
5257 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5258                                   const struct hda_fixup *fix, int action)
5259 {
5260         static const struct hda_pintbl pincfgs[] = {
5261                 { 0x16, 0x21211010 }, /* dock headphone */
5262                 { 0x19, 0x21a11010 }, /* dock mic */
5263                 { }
5264         };
5265         struct alc_spec *spec = codec->spec;
5266
5267         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5268                 spec->reboot_notify = snd_hda_gen_reboot_notify; /* reduce noise */
5269                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5270                 codec->power_save_node = 0; /* avoid click noises */
5271                 snd_hda_apply_pincfgs(codec, pincfgs);
5272         }
5273 }
5274
5275 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5276                                   const struct hda_fixup *fix, int action)
5277 {
5278         static const struct hda_pintbl pincfgs[] = {
5279                 { 0x17, 0x21211010 }, /* dock headphone */
5280                 { 0x19, 0x21a11010 }, /* dock mic */
5281                 { }
5282         };
5283         struct alc_spec *spec = codec->spec;
5284
5285         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5286                 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5287                 snd_hda_apply_pincfgs(codec, pincfgs);
5288         } else if (action == HDA_FIXUP_ACT_INIT) {
5289                 /* Enable DOCK device */
5290                 snd_hda_codec_write(codec, 0x17, 0,
5291                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5292                 /* Enable DOCK device */
5293                 snd_hda_codec_write(codec, 0x19, 0,
5294                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5295         }
5296 }
5297
5298 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
5299                                   const struct hda_fixup *fix, int action)
5300 {
5301         /* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5302          * the speaker output becomes too low by some reason on Thinkpads with
5303          * ALC298 codec
5304          */
5305         static hda_nid_t preferred_pairs[] = {
5306                 0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5307                 0
5308         };
5309         struct alc_spec *spec = codec->spec;
5310
5311         if (action == HDA_FIXUP_ACT_PRE_PROBE)
5312                 spec->gen.preferred_dacs = preferred_pairs;
5313 }
5314
5315 static void alc_shutup_dell_xps13(struct hda_codec *codec)
5316 {
5317         struct alc_spec *spec = codec->spec;
5318         int hp_pin = alc_get_hp_pin(spec);
5319
5320         /* Prevent pop noises when headphones are plugged in */
5321         snd_hda_codec_write(codec, hp_pin, 0,
5322                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5323         msleep(20);
5324 }
5325
5326 static void alc_fixup_dell_xps13(struct hda_codec *codec,
5327                                 const struct hda_fixup *fix, int action)
5328 {
5329         struct alc_spec *spec = codec->spec;
5330         struct hda_input_mux *imux = &spec->gen.input_mux;
5331         int i;
5332
5333         switch (action) {
5334         case HDA_FIXUP_ACT_PRE_PROBE:
5335                 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
5336                  * it causes a click noise at start up
5337                  */
5338                 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5339                 spec->shutup = alc_shutup_dell_xps13;
5340                 break;
5341         case HDA_FIXUP_ACT_PROBE:
5342                 /* Make the internal mic the default input source. */
5343                 for (i = 0; i < imux->num_items; i++) {
5344                         if (spec->gen.imux_pins[i] == 0x12) {
5345                                 spec->gen.cur_mux[0] = i;
5346                                 break;
5347                         }
5348                 }
5349                 break;
5350         }
5351 }
5352
5353 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5354                                 const struct hda_fixup *fix, int action)
5355 {
5356         struct alc_spec *spec = codec->spec;
5357
5358         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5359                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5360                 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
5361
5362                 /* Disable boost for mic-in permanently. (This code is only called
5363                    from quirks that guarantee that the headphone is at NID 0x1b.) */
5364                 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5365                 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
5366         } else
5367                 alc_fixup_headset_mode(codec, fix, action);
5368 }
5369
5370 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5371                                 const struct hda_fixup *fix, int action)
5372 {
5373         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5374                 alc_write_coef_idx(codec, 0xc4, 0x8000);
5375                 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
5376                 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
5377         }
5378         alc_fixup_headset_mode(codec, fix, action);
5379 }
5380
5381 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
5382 static int find_ext_mic_pin(struct hda_codec *codec)
5383 {
5384         struct alc_spec *spec = codec->spec;
5385         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5386         hda_nid_t nid;
5387         unsigned int defcfg;
5388         int i;
5389
5390         for (i = 0; i < cfg->num_inputs; i++) {
5391                 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5392                         continue;
5393                 nid = cfg->inputs[i].pin;
5394                 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5395                 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
5396                         continue;
5397                 return nid;
5398         }
5399
5400         return 0;
5401 }
5402
5403 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
5404                                     const struct hda_fixup *fix,
5405                                     int action)
5406 {
5407         struct alc_spec *spec = codec->spec;
5408
5409         if (action == HDA_FIXUP_ACT_PROBE) {
5410                 int mic_pin = find_ext_mic_pin(codec);
5411                 int hp_pin = alc_get_hp_pin(spec);
5412
5413                 if (snd_BUG_ON(!mic_pin || !hp_pin))
5414                         return;
5415                 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
5416         }
5417 }
5418
5419 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
5420                                              const struct hda_fixup *fix,
5421                                              int action)
5422 {
5423         struct alc_spec *spec = codec->spec;
5424         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5425         int i;
5426
5427         /* The mic boosts on level 2 and 3 are too noisy
5428            on the internal mic input.
5429            Therefore limit the boost to 0 or 1. */
5430
5431         if (action != HDA_FIXUP_ACT_PROBE)
5432                 return;
5433
5434         for (i = 0; i < cfg->num_inputs; i++) {
5435                 hda_nid_t nid = cfg->inputs[i].pin;
5436                 unsigned int defcfg;
5437                 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5438                         continue;
5439                 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5440                 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
5441                         continue;
5442
5443                 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
5444                                           (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
5445                                           (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5446                                           (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
5447                                           (0 << AC_AMPCAP_MUTE_SHIFT));
5448         }
5449 }
5450
5451 static void alc283_hp_automute_hook(struct hda_codec *codec,
5452                                     struct hda_jack_callback *jack)
5453 {
5454         struct alc_spec *spec = codec->spec;
5455         int vref;
5456
5457         msleep(200);
5458         snd_hda_gen_hp_automute(codec, jack);
5459
5460         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
5461
5462         msleep(600);
5463         snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5464                             vref);
5465 }
5466
5467 static void alc283_fixup_chromebook(struct hda_codec *codec,
5468                                     const struct hda_fixup *fix, int action)
5469 {
5470         struct alc_spec *spec = codec->spec;
5471
5472         switch (action) {
5473         case HDA_FIXUP_ACT_PRE_PROBE:
5474                 snd_hda_override_wcaps(codec, 0x03, 0);
5475                 /* Disable AA-loopback as it causes white noise */
5476                 spec->gen.mixer_nid = 0;
5477                 break;
5478         case HDA_FIXUP_ACT_INIT:
5479                 /* MIC2-VREF control */
5480                 /* Set to manual mode */
5481                 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5482                 /* Enable Line1 input control by verb */
5483                 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
5484                 break;
5485         }
5486 }
5487
5488 static void alc283_fixup_sense_combo_jack(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                 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
5496                 break;
5497         case HDA_FIXUP_ACT_INIT:
5498                 /* MIC2-VREF control */
5499                 /* Set to manual mode */
5500                 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5501                 break;
5502         }
5503 }
5504
5505 /* mute tablet speaker pin (0x14) via dock plugging in addition */
5506 static void asus_tx300_automute(struct hda_codec *codec)
5507 {
5508         struct alc_spec *spec = codec->spec;
5509         snd_hda_gen_update_outputs(codec);
5510         if (snd_hda_jack_detect(codec, 0x1b))
5511                 spec->gen.mute_bits |= (1ULL << 0x14);
5512 }
5513
5514 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
5515                                     const struct hda_fixup *fix, int action)
5516 {
5517         struct alc_spec *spec = codec->spec;
5518         static const struct hda_pintbl dock_pins[] = {
5519                 { 0x1b, 0x21114000 }, /* dock speaker pin */
5520                 {}
5521         };
5522
5523         switch (action) {
5524         case HDA_FIXUP_ACT_PRE_PROBE:
5525                 spec->init_amp = ALC_INIT_DEFAULT;
5526                 /* TX300 needs to set up GPIO2 for the speaker amp */
5527                 alc_setup_gpio(codec, 0x04);
5528                 snd_hda_apply_pincfgs(codec, dock_pins);
5529                 spec->gen.auto_mute_via_amp = 1;
5530                 spec->gen.automute_hook = asus_tx300_automute;
5531                 snd_hda_jack_detect_enable_callback(codec, 0x1b,
5532                                                     snd_hda_gen_hp_automute);
5533                 break;
5534         case HDA_FIXUP_ACT_PROBE:
5535                 spec->init_amp = ALC_INIT_DEFAULT;
5536                 break;
5537         case HDA_FIXUP_ACT_BUILD:
5538                 /* this is a bit tricky; give more sane names for the main
5539                  * (tablet) speaker and the dock speaker, respectively
5540                  */
5541                 rename_ctl(codec, "Speaker Playback Switch",
5542                            "Dock Speaker Playback Switch");
5543                 rename_ctl(codec, "Bass Speaker Playback Switch",
5544                            "Speaker Playback Switch");
5545                 break;
5546         }
5547 }
5548
5549 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
5550                                        const struct hda_fixup *fix, int action)
5551 {
5552         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5553                 /* DAC node 0x03 is giving mono output. We therefore want to
5554                    make sure 0x14 (front speaker) and 0x15 (headphones) use the
5555                    stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
5556                 hda_nid_t conn1[2] = { 0x0c };
5557                 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
5558                 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
5559         }
5560 }
5561
5562 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
5563                                         const struct hda_fixup *fix, int action)
5564 {
5565         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5566                 /* The speaker is routed to the Node 0x06 by a mistake, as a result
5567                    we can't adjust the speaker's volume since this node does not has
5568                    Amp-out capability. we change the speaker's route to:
5569                    Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
5570                    Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
5571                    speaker's volume now. */
5572
5573                 hda_nid_t conn1[1] = { 0x0c };
5574                 snd_hda_override_conn_list(codec, 0x17, 1, conn1);
5575         }
5576 }
5577
5578 /* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
5579 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
5580                                       const struct hda_fixup *fix, int action)
5581 {
5582         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5583                 hda_nid_t conn[2] = { 0x02, 0x03 };
5584                 snd_hda_override_conn_list(codec, 0x17, 2, conn);
5585         }
5586 }
5587
5588 /* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
5589 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
5590                                           const struct hda_fixup *fix, int action)
5591 {
5592         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5593                 hda_nid_t conn[1] = { 0x02 };
5594                 snd_hda_override_conn_list(codec, 0x17, 1, conn);
5595         }
5596 }
5597
5598 /* Hook to update amp GPIO4 for automute */
5599 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
5600                                           struct hda_jack_callback *jack)
5601 {
5602         struct alc_spec *spec = codec->spec;
5603
5604         snd_hda_gen_hp_automute(codec, jack);
5605         /* mute_led_polarity is set to 0, so we pass inverted value here */
5606         alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
5607                             !spec->gen.hp_jack_present);
5608 }
5609
5610 /* Manage GPIOs for HP EliteBook Folio 9480m.
5611  *
5612  * GPIO4 is the headphone amplifier power control
5613  * GPIO3 is the audio output mute indicator LED
5614  */
5615
5616 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
5617                                   const struct hda_fixup *fix,
5618                                   int action)
5619 {
5620         struct alc_spec *spec = codec->spec;
5621
5622         alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
5623         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5624                 /* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
5625                 spec->gpio_mask |= 0x10;
5626                 spec->gpio_dir |= 0x10;
5627                 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
5628         }
5629 }
5630
5631 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
5632                                    const struct hda_fixup *fix,
5633                                    int action)
5634 {
5635         struct alc_spec *spec = codec->spec;
5636
5637         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5638                 spec->gpio_mask |= 0x04;
5639                 spec->gpio_dir |= 0x04;
5640                 /* set data bit low */
5641         }
5642 }
5643
5644 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
5645                                          const struct hda_fixup *fix,
5646                                          int action)
5647 {
5648         alc_fixup_dual_codecs(codec, fix, action);
5649         switch (action) {
5650         case HDA_FIXUP_ACT_PRE_PROBE:
5651                 /* override card longname to provide a unique UCM profile */
5652                 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
5653                 break;
5654         case HDA_FIXUP_ACT_BUILD:
5655                 /* rename Capture controls depending on the codec */
5656                 rename_ctl(codec, "Capture Volume",
5657                            codec->addr == 0 ?
5658                            "Rear-Panel Capture Volume" :
5659                            "Front-Panel Capture Volume");
5660                 rename_ctl(codec, "Capture Switch",
5661                            codec->addr == 0 ?
5662                            "Rear-Panel Capture Switch" :
5663                            "Front-Panel Capture Switch");
5664                 break;
5665         }
5666 }
5667
5668 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
5669                                       const struct hda_fixup *fix, int action)
5670 {
5671         if (action != HDA_FIXUP_ACT_PRE_PROBE)
5672                 return;
5673
5674         codec->power_save_node = 1;
5675 }
5676
5677 /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
5678 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
5679                                     const struct hda_fixup *fix, int action)
5680 {
5681         struct alc_spec *spec = codec->spec;
5682         static hda_nid_t preferred_pairs[] = {
5683                 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
5684                 0
5685         };
5686
5687         if (action != HDA_FIXUP_ACT_PRE_PROBE)
5688                 return;
5689
5690         spec->gen.preferred_dacs = preferred_pairs;
5691         spec->gen.auto_mute_via_amp = 1;
5692         codec->power_save_node = 0;
5693 }
5694
5695 /* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
5696 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
5697                               const struct hda_fixup *fix, int action)
5698 {
5699         if (action != HDA_FIXUP_ACT_PRE_PROBE)
5700                 return;
5701
5702         snd_hda_override_wcaps(codec, 0x03, 0);
5703 }
5704
5705 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
5706                                   const struct hda_fixup *fix, int action)
5707 {
5708         if (action == HDA_FIXUP_ACT_PRE_PROBE)
5709                 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5710 }
5711
5712 /* for hda_fixup_thinkpad_acpi() */
5713 #include "thinkpad_helper.c"
5714
5715 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
5716                                     const struct hda_fixup *fix, int action)
5717 {
5718         alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
5719         hda_fixup_thinkpad_acpi(codec, fix, action);
5720 }
5721
5722 /* for dell wmi mic mute led */
5723 #include "dell_wmi_helper.c"
5724
5725 /* for alc295_fixup_hp_top_speakers */
5726 #include "hp_x360_helper.c"
5727
5728 enum {
5729         ALC269_FIXUP_GPIO2,
5730         ALC269_FIXUP_SONY_VAIO,
5731         ALC275_FIXUP_SONY_VAIO_GPIO2,
5732         ALC269_FIXUP_DELL_M101Z,
5733         ALC269_FIXUP_SKU_IGNORE,
5734         ALC269_FIXUP_ASUS_G73JW,
5735         ALC269_FIXUP_LENOVO_EAPD,
5736         ALC275_FIXUP_SONY_HWEQ,
5737         ALC275_FIXUP_SONY_DISABLE_AAMIX,
5738         ALC271_FIXUP_DMIC,
5739         ALC269_FIXUP_PCM_44K,
5740         ALC269_FIXUP_STEREO_DMIC,
5741         ALC269_FIXUP_HEADSET_MIC,
5742         ALC269_FIXUP_QUANTA_MUTE,
5743         ALC269_FIXUP_LIFEBOOK,
5744         ALC269_FIXUP_LIFEBOOK_EXTMIC,
5745         ALC269_FIXUP_LIFEBOOK_HP_PIN,
5746         ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
5747         ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
5748         ALC269_FIXUP_AMIC,
5749         ALC269_FIXUP_DMIC,
5750         ALC269VB_FIXUP_AMIC,
5751         ALC269VB_FIXUP_DMIC,
5752         ALC269_FIXUP_HP_MUTE_LED,
5753         ALC269_FIXUP_HP_MUTE_LED_MIC1,
5754         ALC269_FIXUP_HP_MUTE_LED_MIC2,
5755         ALC269_FIXUP_HP_MUTE_LED_MIC3,
5756         ALC269_FIXUP_HP_GPIO_LED,
5757         ALC269_FIXUP_HP_GPIO_MIC1_LED,
5758         ALC269_FIXUP_HP_LINE1_MIC1_LED,
5759         ALC269_FIXUP_INV_DMIC,
5760         ALC269_FIXUP_LENOVO_DOCK,
5761         ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
5762         ALC269_FIXUP_NO_SHUTUP,
5763         ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
5764         ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
5765         ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5766         ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
5767         ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5768         ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
5769         ALC269_FIXUP_HEADSET_MODE,
5770         ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
5771         ALC269_FIXUP_ASPIRE_HEADSET_MIC,
5772         ALC269_FIXUP_ASUS_X101_FUNC,
5773         ALC269_FIXUP_ASUS_X101_VERB,
5774         ALC269_FIXUP_ASUS_X101,
5775         ALC271_FIXUP_AMIC_MIC2,
5776         ALC271_FIXUP_HP_GATE_MIC_JACK,
5777         ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
5778         ALC269_FIXUP_ACER_AC700,
5779         ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
5780         ALC269VB_FIXUP_ASUS_ZENBOOK,
5781         ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
5782         ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
5783         ALC269VB_FIXUP_ORDISSIMO_EVE2,
5784         ALC283_FIXUP_CHROME_BOOK,
5785         ALC283_FIXUP_SENSE_COMBO_JACK,
5786         ALC282_FIXUP_ASUS_TX300,
5787         ALC283_FIXUP_INT_MIC,
5788         ALC290_FIXUP_MONO_SPEAKERS,
5789         ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5790         ALC290_FIXUP_SUBWOOFER,
5791         ALC290_FIXUP_SUBWOOFER_HSJACK,
5792         ALC269_FIXUP_THINKPAD_ACPI,
5793         ALC269_FIXUP_DMIC_THINKPAD_ACPI,
5794         ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
5795         ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
5796         ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5797         ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
5798         ALC255_FIXUP_HEADSET_MODE,
5799         ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
5800         ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5801         ALC292_FIXUP_TPT440_DOCK,
5802         ALC292_FIXUP_TPT440,
5803         ALC283_FIXUP_HEADSET_MIC,
5804         ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
5805         ALC282_FIXUP_ASPIRE_V5_PINS,
5806         ALC280_FIXUP_HP_GPIO4,
5807         ALC286_FIXUP_HP_GPIO_LED,
5808         ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
5809         ALC280_FIXUP_HP_DOCK_PINS,
5810         ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
5811         ALC280_FIXUP_HP_9480M,
5812         ALC288_FIXUP_DELL_HEADSET_MODE,
5813         ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
5814         ALC288_FIXUP_DELL_XPS_13,
5815         ALC288_FIXUP_DISABLE_AAMIX,
5816         ALC292_FIXUP_DELL_E7X,
5817         ALC292_FIXUP_DISABLE_AAMIX,
5818         ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
5819         ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
5820         ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
5821         ALC275_FIXUP_DELL_XPS,
5822         ALC293_FIXUP_LENOVO_SPK_NOISE,
5823         ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
5824         ALC255_FIXUP_DELL_SPK_NOISE,
5825         ALC225_FIXUP_DISABLE_MIC_VREF,
5826         ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
5827         ALC295_FIXUP_DISABLE_DAC3,
5828         ALC285_FIXUP_SPEAKER2_TO_DAC1,
5829         ALC280_FIXUP_HP_HEADSET_MIC,
5830         ALC221_FIXUP_HP_FRONT_MIC,
5831         ALC292_FIXUP_TPT460,
5832         ALC298_FIXUP_SPK_VOLUME,
5833         ALC298_FIXUP_LENOVO_SPK_VOLUME,
5834         ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
5835         ALC269_FIXUP_ATIV_BOOK_8,
5836         ALC221_FIXUP_HP_MIC_NO_PRESENCE,
5837         ALC256_FIXUP_ASUS_HEADSET_MODE,
5838         ALC256_FIXUP_ASUS_MIC,
5839         ALC256_FIXUP_ASUS_AIO_GPIO2,
5840         ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
5841         ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
5842         ALC233_FIXUP_LENOVO_MULTI_CODECS,
5843         ALC233_FIXUP_ACER_HEADSET_MIC,
5844         ALC294_FIXUP_LENOVO_MIC_LOCATION,
5845         ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
5846         ALC225_FIXUP_S3_POP_NOISE,
5847         ALC700_FIXUP_INTEL_REFERENCE,
5848         ALC274_FIXUP_DELL_BIND_DACS,
5849         ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
5850         ALC298_FIXUP_TPT470_DOCK_FIX,
5851         ALC298_FIXUP_TPT470_DOCK,
5852         ALC255_FIXUP_DUMMY_LINEOUT_VERB,
5853         ALC255_FIXUP_DELL_HEADSET_MIC,
5854         ALC256_FIXUP_HUAWEI_MBXP_PINS,
5855         ALC295_FIXUP_HP_X360,
5856         ALC221_FIXUP_HP_HEADSET_MIC,
5857         ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
5858         ALC295_FIXUP_HP_AUTO_MUTE,
5859         ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
5860         ALC294_FIXUP_ASUS_MIC,
5861         ALC294_FIXUP_ASUS_HEADSET_MIC,
5862         ALC294_FIXUP_ASUS_SPK,
5863         ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
5864         ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
5865         ALC255_FIXUP_ACER_HEADSET_MIC,
5866         ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
5867         ALC225_FIXUP_WYSE_AUTO_MUTE,
5868         ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
5869         ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
5870         ALC256_FIXUP_ASUS_HEADSET_MIC,
5871         ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
5872         ALC299_FIXUP_PREDATOR_SPK,
5873         ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
5874         ALC289_FIXUP_DELL_SPK2,
5875         ALC289_FIXUP_DUAL_SPK,
5876         ALC294_FIXUP_SPK2_TO_DAC1,
5877         ALC294_FIXUP_ASUS_DUAL_SPK,
5878         ALC294_FIXUP_ASUS_HPE,
5879         ALC285_FIXUP_HP_GPIO_LED,
5880 };
5881
5882 static const struct hda_fixup alc269_fixups[] = {
5883         [ALC269_FIXUP_GPIO2] = {
5884                 .type = HDA_FIXUP_FUNC,
5885                 .v.func = alc_fixup_gpio2,
5886         },
5887         [ALC269_FIXUP_SONY_VAIO] = {
5888                 .type = HDA_FIXUP_PINCTLS,
5889                 .v.pins = (const struct hda_pintbl[]) {
5890                         {0x19, PIN_VREFGRD},
5891                         {}
5892                 }
5893         },
5894         [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
5895                 .type = HDA_FIXUP_FUNC,
5896                 .v.func = alc275_fixup_gpio4_off,
5897                 .chained = true,
5898                 .chain_id = ALC269_FIXUP_SONY_VAIO
5899         },
5900         [ALC269_FIXUP_DELL_M101Z] = {
5901                 .type = HDA_FIXUP_VERBS,
5902                 .v.verbs = (const struct hda_verb[]) {
5903                         /* Enables internal speaker */
5904                         {0x20, AC_VERB_SET_COEF_INDEX, 13},
5905                         {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5906                         {}
5907                 }
5908         },
5909         [ALC269_FIXUP_SKU_IGNORE] = {
5910                 .type = HDA_FIXUP_FUNC,
5911                 .v.func = alc_fixup_sku_ignore,
5912         },
5913         [ALC269_FIXUP_ASUS_G73JW] = {
5914                 .type = HDA_FIXUP_PINS,
5915                 .v.pins = (const struct hda_pintbl[]) {
5916                         { 0x17, 0x99130111 }, /* subwoofer */
5917                         { }
5918                 }
5919         },
5920         [ALC269_FIXUP_LENOVO_EAPD] = {
5921                 .type = HDA_FIXUP_VERBS,
5922                 .v.verbs = (const struct hda_verb[]) {
5923                         {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5924                         {}
5925                 }
5926         },
5927         [ALC275_FIXUP_SONY_HWEQ] = {
5928                 .type = HDA_FIXUP_FUNC,
5929                 .v.func = alc269_fixup_hweq,
5930                 .chained = true,
5931                 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5932         },
5933         [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
5934                 .type = HDA_FIXUP_FUNC,
5935                 .v.func = alc_fixup_disable_aamix,
5936                 .chained = true,
5937                 .chain_id = ALC269_FIXUP_SONY_VAIO
5938         },
5939         [ALC271_FIXUP_DMIC] = {
5940                 .type = HDA_FIXUP_FUNC,
5941                 .v.func = alc271_fixup_dmic,
5942         },
5943         [ALC269_FIXUP_PCM_44K] = {
5944                 .type = HDA_FIXUP_FUNC,
5945                 .v.func = alc269_fixup_pcm_44k,
5946                 .chained = true,
5947                 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5948         },
5949         [ALC269_FIXUP_STEREO_DMIC] = {
5950                 .type = HDA_FIXUP_FUNC,
5951                 .v.func = alc269_fixup_stereo_dmic,
5952         },
5953         [ALC269_FIXUP_HEADSET_MIC] = {
5954                 .type = HDA_FIXUP_FUNC,
5955                 .v.func = alc269_fixup_headset_mic,
5956         },
5957         [ALC269_FIXUP_QUANTA_MUTE] = {
5958                 .type = HDA_FIXUP_FUNC,
5959                 .v.func = alc269_fixup_quanta_mute,
5960         },
5961         [ALC269_FIXUP_LIFEBOOK] = {
5962                 .type = HDA_FIXUP_PINS,
5963                 .v.pins = (const struct hda_pintbl[]) {
5964                         { 0x1a, 0x2101103f }, /* dock line-out */
5965                         { 0x1b, 0x23a11040 }, /* dock mic-in */
5966                         { }
5967                 },
5968                 .chained = true,
5969                 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5970         },
5971         [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
5972                 .type = HDA_FIXUP_PINS,
5973                 .v.pins = (const struct hda_pintbl[]) {
5974                         { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
5975                         { }
5976                 },
5977         },
5978         [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
5979                 .type = HDA_FIXUP_PINS,
5980                 .v.pins = (const struct hda_pintbl[]) {
5981                         { 0x21, 0x0221102f }, /* HP out */
5982                         { }
5983                 },
5984         },
5985         [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
5986                 .type = HDA_FIXUP_FUNC,
5987                 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
5988         },
5989         [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
5990                 .type = HDA_FIXUP_FUNC,
5991                 .v.func = alc269_fixup_pincfg_U7x7_headset_mic,
5992         },
5993         [ALC269_FIXUP_AMIC] = {
5994                 .type = HDA_FIXUP_PINS,
5995                 .v.pins = (const struct hda_pintbl[]) {
5996                         { 0x14, 0x99130110 }, /* speaker */
5997                         { 0x15, 0x0121401f }, /* HP out */
5998                         { 0x18, 0x01a19c20 }, /* mic */
5999                         { 0x19, 0x99a3092f }, /* int-mic */
6000                         { }
6001                 },
6002         },
6003         [ALC269_FIXUP_DMIC] = {
6004                 .type = HDA_FIXUP_PINS,
6005                 .v.pins = (const struct hda_pintbl[]) {
6006                         { 0x12, 0x99a3092f }, /* int-mic */
6007                         { 0x14, 0x99130110 }, /* speaker */
6008                         { 0x15, 0x0121401f }, /* HP out */
6009                         { 0x18, 0x01a19c20 }, /* mic */
6010                         { }
6011                 },
6012         },
6013         [ALC269VB_FIXUP_AMIC] = {
6014                 .type = HDA_FIXUP_PINS,
6015                 .v.pins = (const struct hda_pintbl[]) {
6016                         { 0x14, 0x99130110 }, /* speaker */
6017                         { 0x18, 0x01a19c20 }, /* mic */
6018                         { 0x19, 0x99a3092f }, /* int-mic */
6019                         { 0x21, 0x0121401f }, /* HP out */
6020                         { }
6021                 },
6022         },
6023         [ALC269VB_FIXUP_DMIC] = {
6024                 .type = HDA_FIXUP_PINS,
6025                 .v.pins = (const struct hda_pintbl[]) {
6026                         { 0x12, 0x99a3092f }, /* int-mic */
6027                         { 0x14, 0x99130110 }, /* speaker */
6028                         { 0x18, 0x01a19c20 }, /* mic */
6029                         { 0x21, 0x0121401f }, /* HP out */
6030                         { }
6031                 },
6032         },
6033         [ALC269_FIXUP_HP_MUTE_LED] = {
6034                 .type = HDA_FIXUP_FUNC,
6035                 .v.func = alc269_fixup_hp_mute_led,
6036         },
6037         [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
6038                 .type = HDA_FIXUP_FUNC,
6039                 .v.func = alc269_fixup_hp_mute_led_mic1,
6040         },
6041         [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
6042                 .type = HDA_FIXUP_FUNC,
6043                 .v.func = alc269_fixup_hp_mute_led_mic2,
6044         },
6045         [ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
6046                 .type = HDA_FIXUP_FUNC,
6047                 .v.func = alc269_fixup_hp_mute_led_mic3,
6048                 .chained = true,
6049                 .chain_id = ALC295_FIXUP_HP_AUTO_MUTE
6050         },
6051         [ALC269_FIXUP_HP_GPIO_LED] = {
6052                 .type = HDA_FIXUP_FUNC,
6053                 .v.func = alc269_fixup_hp_gpio_led,
6054         },
6055         [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
6056                 .type = HDA_FIXUP_FUNC,
6057                 .v.func = alc269_fixup_hp_gpio_mic1_led,
6058         },
6059         [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
6060                 .type = HDA_FIXUP_FUNC,
6061                 .v.func = alc269_fixup_hp_line1_mic1_led,
6062         },
6063         [ALC269_FIXUP_INV_DMIC] = {
6064                 .type = HDA_FIXUP_FUNC,
6065                 .v.func = alc_fixup_inv_dmic,
6066         },
6067         [ALC269_FIXUP_NO_SHUTUP] = {
6068                 .type = HDA_FIXUP_FUNC,
6069                 .v.func = alc_fixup_no_shutup,
6070         },
6071         [ALC269_FIXUP_LENOVO_DOCK] = {
6072                 .type = HDA_FIXUP_PINS,
6073                 .v.pins = (const struct hda_pintbl[]) {
6074                         { 0x19, 0x23a11040 }, /* dock mic */
6075                         { 0x1b, 0x2121103f }, /* dock headphone */
6076                         { }
6077                 },
6078                 .chained = true,
6079                 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
6080         },
6081         [ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
6082                 .type = HDA_FIXUP_FUNC,
6083                 .v.func = alc269_fixup_limit_int_mic_boost,
6084                 .chained = true,
6085                 .chain_id = ALC269_FIXUP_LENOVO_DOCK,
6086         },
6087         [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
6088                 .type = HDA_FIXUP_FUNC,
6089                 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
6090                 .chained = true,
6091                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6092         },
6093         [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6094                 .type = HDA_FIXUP_PINS,
6095                 .v.pins = (const struct hda_pintbl[]) {
6096                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6097                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6098                         { }
6099                 },
6100                 .chained = true,
6101                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6102         },
6103         [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6104                 .type = HDA_FIXUP_PINS,
6105                 .v.pins = (const struct hda_pintbl[]) {
6106                         { 0x16, 0x21014020 }, /* dock line out */
6107                         { 0x19, 0x21a19030 }, /* dock mic */
6108                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6109                         { }
6110                 },
6111                 .chained = true,
6112                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6113         },
6114         [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
6115                 .type = HDA_FIXUP_PINS,
6116                 .v.pins = (const struct hda_pintbl[]) {
6117                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6118                         { }
6119                 },
6120                 .chained = true,
6121                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6122         },
6123         [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
6124                 .type = HDA_FIXUP_PINS,
6125                 .v.pins = (const struct hda_pintbl[]) {
6126                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6127                         { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6128                         { }
6129                 },
6130                 .chained = true,
6131                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6132         },
6133         [ALC269_FIXUP_HEADSET_MODE] = {
6134                 .type = HDA_FIXUP_FUNC,
6135                 .v.func = alc_fixup_headset_mode,
6136                 .chained = true,
6137                 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
6138         },
6139         [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6140                 .type = HDA_FIXUP_FUNC,
6141                 .v.func = alc_fixup_headset_mode_no_hp_mic,
6142         },
6143         [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
6144                 .type = HDA_FIXUP_PINS,
6145                 .v.pins = (const struct hda_pintbl[]) {
6146                         { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
6147                         { }
6148                 },
6149                 .chained = true,
6150                 .chain_id = ALC269_FIXUP_HEADSET_MODE,
6151         },
6152         [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
6153                 .type = HDA_FIXUP_PINS,
6154                 .v.pins = (const struct hda_pintbl[]) {
6155                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6156                         { }
6157                 },
6158                 .chained = true,
6159                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6160         },
6161         [ALC256_FIXUP_HUAWEI_MBXP_PINS] = {
6162                 .type = HDA_FIXUP_PINS,
6163                 .v.pins = (const struct hda_pintbl[]) {
6164                         {0x12, 0x90a60130},
6165                         {0x13, 0x40000000},
6166                         {0x14, 0x90170110},
6167                         {0x18, 0x411111f0},
6168                         {0x19, 0x04a11040},
6169                         {0x1a, 0x411111f0},
6170                         {0x1b, 0x90170112},
6171                         {0x1d, 0x40759a05},
6172                         {0x1e, 0x411111f0},
6173                         {0x21, 0x04211020},
6174                         { }
6175                 },
6176         },
6177         [ALC269_FIXUP_ASUS_X101_FUNC] = {
6178                 .type = HDA_FIXUP_FUNC,
6179                 .v.func = alc269_fixup_x101_headset_mic,
6180         },
6181         [ALC269_FIXUP_ASUS_X101_VERB] = {
6182                 .type = HDA_FIXUP_VERBS,
6183                 .v.verbs = (const struct hda_verb[]) {
6184                         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6185                         {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
6186                         {0x20, AC_VERB_SET_PROC_COEF,  0x0310},
6187                         { }
6188                 },
6189                 .chained = true,
6190                 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
6191         },
6192         [ALC269_FIXUP_ASUS_X101] = {
6193                 .type = HDA_FIXUP_PINS,
6194                 .v.pins = (const struct hda_pintbl[]) {
6195                         { 0x18, 0x04a1182c }, /* Headset mic */
6196                         { }
6197                 },
6198                 .chained = true,
6199                 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
6200         },
6201         [ALC271_FIXUP_AMIC_MIC2] = {
6202                 .type = HDA_FIXUP_PINS,
6203                 .v.pins = (const struct hda_pintbl[]) {
6204                         { 0x14, 0x99130110 }, /* speaker */
6205                         { 0x19, 0x01a19c20 }, /* mic */
6206                         { 0x1b, 0x99a7012f }, /* int-mic */
6207                         { 0x21, 0x0121401f }, /* HP out */
6208                         { }
6209                 },
6210         },
6211         [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
6212                 .type = HDA_FIXUP_FUNC,
6213                 .v.func = alc271_hp_gate_mic_jack,
6214                 .chained = true,
6215                 .chain_id = ALC271_FIXUP_AMIC_MIC2,
6216         },
6217         [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
6218                 .type = HDA_FIXUP_FUNC,
6219                 .v.func = alc269_fixup_limit_int_mic_boost,
6220                 .chained = true,
6221                 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
6222         },
6223         [ALC269_FIXUP_ACER_AC700] = {
6224                 .type = HDA_FIXUP_PINS,
6225                 .v.pins = (const struct hda_pintbl[]) {
6226                         { 0x12, 0x99a3092f }, /* int-mic */
6227                         { 0x14, 0x99130110 }, /* speaker */
6228                         { 0x18, 0x03a11c20 }, /* mic */
6229                         { 0x1e, 0x0346101e }, /* SPDIF1 */
6230                         { 0x21, 0x0321101f }, /* HP out */
6231                         { }
6232                 },
6233                 .chained = true,
6234                 .chain_id = ALC271_FIXUP_DMIC,
6235         },
6236         [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
6237                 .type = HDA_FIXUP_FUNC,
6238                 .v.func = alc269_fixup_limit_int_mic_boost,
6239                 .chained = true,
6240                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6241         },
6242         [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
6243                 .type = HDA_FIXUP_FUNC,
6244                 .v.func = alc269_fixup_limit_int_mic_boost,
6245                 .chained = true,
6246                 .chain_id = ALC269VB_FIXUP_DMIC,
6247         },
6248         [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
6249                 .type = HDA_FIXUP_VERBS,
6250                 .v.verbs = (const struct hda_verb[]) {
6251                         /* class-D output amp +5dB */
6252                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
6253                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
6254                         {}
6255                 },
6256                 .chained = true,
6257                 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
6258         },
6259         [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
6260                 .type = HDA_FIXUP_FUNC,
6261                 .v.func = alc269_fixup_limit_int_mic_boost,
6262                 .chained = true,
6263                 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
6264         },
6265         [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
6266                 .type = HDA_FIXUP_PINS,
6267                 .v.pins = (const struct hda_pintbl[]) {
6268                         { 0x12, 0x99a3092f }, /* int-mic */
6269                         { 0x18, 0x03a11d20 }, /* mic */
6270                         { 0x19, 0x411111f0 }, /* Unused bogus pin */
6271                         { }
6272                 },
6273         },
6274         [ALC283_FIXUP_CHROME_BOOK] = {
6275                 .type = HDA_FIXUP_FUNC,
6276                 .v.func = alc283_fixup_chromebook,
6277         },
6278         [ALC283_FIXUP_SENSE_COMBO_JACK] = {
6279                 .type = HDA_FIXUP_FUNC,
6280                 .v.func = alc283_fixup_sense_combo_jack,
6281                 .chained = true,
6282                 .chain_id = ALC283_FIXUP_CHROME_BOOK,
6283         },
6284         [ALC282_FIXUP_ASUS_TX300] = {
6285                 .type = HDA_FIXUP_FUNC,
6286                 .v.func = alc282_fixup_asus_tx300,
6287         },
6288         [ALC283_FIXUP_INT_MIC] = {
6289                 .type = HDA_FIXUP_VERBS,
6290                 .v.verbs = (const struct hda_verb[]) {
6291                         {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
6292                         {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
6293                         { }
6294                 },
6295                 .chained = true,
6296                 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6297         },
6298         [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
6299                 .type = HDA_FIXUP_PINS,
6300                 .v.pins = (const struct hda_pintbl[]) {
6301                         { 0x17, 0x90170112 }, /* subwoofer */
6302                         { }
6303                 },
6304                 .chained = true,
6305                 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6306         },
6307         [ALC290_FIXUP_SUBWOOFER] = {
6308                 .type = HDA_FIXUP_PINS,
6309                 .v.pins = (const struct hda_pintbl[]) {
6310                         { 0x17, 0x90170112 }, /* subwoofer */
6311                         { }
6312                 },
6313                 .chained = true,
6314                 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
6315         },
6316         [ALC290_FIXUP_MONO_SPEAKERS] = {
6317                 .type = HDA_FIXUP_FUNC,
6318                 .v.func = alc290_fixup_mono_speakers,
6319         },
6320         [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
6321                 .type = HDA_FIXUP_FUNC,
6322                 .v.func = alc290_fixup_mono_speakers,
6323                 .chained = true,
6324                 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6325         },
6326         [ALC269_FIXUP_THINKPAD_ACPI] = {
6327                 .type = HDA_FIXUP_FUNC,
6328                 .v.func = alc_fixup_thinkpad_acpi,
6329                 .chained = true,
6330                 .chain_id = ALC269_FIXUP_SKU_IGNORE,
6331         },
6332         [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
6333                 .type = HDA_FIXUP_FUNC,
6334                 .v.func = alc_fixup_inv_dmic,
6335                 .chained = true,
6336                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6337         },
6338         [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
6339                 .type = HDA_FIXUP_PINS,
6340                 .v.pins = (const struct hda_pintbl[]) {
6341                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6342                         { }
6343                 },
6344                 .chained = true,
6345                 .chain_id = ALC255_FIXUP_HEADSET_MODE
6346         },
6347         [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6348                 .type = HDA_FIXUP_PINS,
6349                 .v.pins = (const struct hda_pintbl[]) {
6350                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6351                         { }
6352                 },
6353                 .chained = true,
6354                 .chain_id = ALC255_FIXUP_HEADSET_MODE
6355         },
6356         [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6357                 .type = HDA_FIXUP_PINS,
6358                 .v.pins = (const struct hda_pintbl[]) {
6359                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6360                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6361                         { }
6362                 },
6363                 .chained = true,
6364                 .chain_id = ALC255_FIXUP_HEADSET_MODE
6365         },
6366         [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6367                 .type = HDA_FIXUP_PINS,
6368                 .v.pins = (const struct hda_pintbl[]) {
6369                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6370                         { }
6371                 },
6372                 .chained = true,
6373                 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
6374         },
6375         [ALC255_FIXUP_HEADSET_MODE] = {
6376                 .type = HDA_FIXUP_FUNC,
6377                 .v.func = alc_fixup_headset_mode_alc255,
6378                 .chained = true,
6379                 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
6380         },
6381         [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6382                 .type = HDA_FIXUP_FUNC,
6383                 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
6384         },
6385         [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6386                 .type = HDA_FIXUP_PINS,
6387                 .v.pins = (const struct hda_pintbl[]) {
6388                         { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6389                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6390                         { }
6391                 },
6392                 .chained = true,
6393                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6394         },
6395         [ALC292_FIXUP_TPT440_DOCK] = {
6396                 .type = HDA_FIXUP_FUNC,
6397                 .v.func = alc_fixup_tpt440_dock,
6398                 .chained = true,
6399                 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6400         },
6401         [ALC292_FIXUP_TPT440] = {
6402                 .type = HDA_FIXUP_FUNC,
6403                 .v.func = alc_fixup_disable_aamix,
6404                 .chained = true,
6405                 .chain_id = ALC292_FIXUP_TPT440_DOCK,
6406         },
6407         [ALC283_FIXUP_HEADSET_MIC] = {
6408                 .type = HDA_FIXUP_PINS,
6409                 .v.pins = (const struct hda_pintbl[]) {
6410                         { 0x19, 0x04a110f0 },
6411                         { },
6412                 },
6413         },
6414         [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
6415                 .type = HDA_FIXUP_FUNC,
6416                 .v.func = alc_fixup_dell_wmi,
6417         },
6418         [ALC282_FIXUP_ASPIRE_V5_PINS] = {
6419                 .type = HDA_FIXUP_PINS,
6420                 .v.pins = (const struct hda_pintbl[]) {
6421                         { 0x12, 0x90a60130 },
6422                         { 0x14, 0x90170110 },
6423                         { 0x17, 0x40000008 },
6424                         { 0x18, 0x411111f0 },
6425                         { 0x19, 0x01a1913c },
6426                         { 0x1a, 0x411111f0 },
6427                         { 0x1b, 0x411111f0 },
6428                         { 0x1d, 0x40f89b2d },
6429                         { 0x1e, 0x411111f0 },
6430                         { 0x21, 0x0321101f },
6431                         { },
6432                 },
6433         },
6434         [ALC280_FIXUP_HP_GPIO4] = {
6435                 .type = HDA_FIXUP_FUNC,
6436                 .v.func = alc280_fixup_hp_gpio4,
6437         },
6438         [ALC286_FIXUP_HP_GPIO_LED] = {
6439                 .type = HDA_FIXUP_FUNC,
6440                 .v.func = alc286_fixup_hp_gpio_led,
6441         },
6442         [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
6443                 .type = HDA_FIXUP_FUNC,
6444                 .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
6445         },
6446         [ALC280_FIXUP_HP_DOCK_PINS] = {
6447                 .type = HDA_FIXUP_PINS,
6448                 .v.pins = (const struct hda_pintbl[]) {
6449                         { 0x1b, 0x21011020 }, /* line-out */
6450                         { 0x1a, 0x01a1903c }, /* headset mic */
6451                         { 0x18, 0x2181103f }, /* line-in */
6452                         { },
6453                 },
6454                 .chained = true,
6455                 .chain_id = ALC280_FIXUP_HP_GPIO4
6456         },
6457         [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
6458                 .type = HDA_FIXUP_PINS,
6459                 .v.pins = (const struct hda_pintbl[]) {
6460                         { 0x1b, 0x21011020 }, /* line-out */
6461                         { 0x18, 0x2181103f }, /* line-in */
6462                         { },
6463                 },
6464                 .chained = true,
6465                 .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
6466         },
6467         [ALC280_FIXUP_HP_9480M] = {
6468                 .type = HDA_FIXUP_FUNC,
6469                 .v.func = alc280_fixup_hp_9480m,
6470         },
6471         [ALC288_FIXUP_DELL_HEADSET_MODE] = {
6472                 .type = HDA_FIXUP_FUNC,
6473                 .v.func = alc_fixup_headset_mode_dell_alc288,
6474                 .chained = true,
6475                 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
6476         },
6477         [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6478                 .type = HDA_FIXUP_PINS,
6479                 .v.pins = (const struct hda_pintbl[]) {
6480                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6481                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6482                         { }
6483                 },
6484                 .chained = true,
6485                 .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
6486         },
6487         [ALC288_FIXUP_DISABLE_AAMIX] = {
6488                 .type = HDA_FIXUP_FUNC,
6489                 .v.func = alc_fixup_disable_aamix,
6490                 .chained = true,
6491                 .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
6492         },
6493         [ALC288_FIXUP_DELL_XPS_13] = {
6494                 .type = HDA_FIXUP_FUNC,
6495                 .v.func = alc_fixup_dell_xps13,
6496                 .chained = true,
6497                 .chain_id = ALC288_FIXUP_DISABLE_AAMIX
6498         },
6499         [ALC292_FIXUP_DISABLE_AAMIX] = {
6500                 .type = HDA_FIXUP_FUNC,
6501                 .v.func = alc_fixup_disable_aamix,
6502                 .chained = true,
6503                 .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
6504         },
6505         [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
6506                 .type = HDA_FIXUP_FUNC,
6507                 .v.func = alc_fixup_disable_aamix,
6508                 .chained = true,
6509                 .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
6510         },
6511         [ALC292_FIXUP_DELL_E7X] = {
6512                 .type = HDA_FIXUP_FUNC,
6513                 .v.func = alc_fixup_dell_xps13,
6514                 .chained = true,
6515                 .chain_id = ALC292_FIXUP_DISABLE_AAMIX
6516         },
6517         [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6518                 .type = HDA_FIXUP_PINS,
6519                 .v.pins = (const struct hda_pintbl[]) {
6520                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6521                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6522                         { }
6523                 },
6524                 .chained = true,
6525                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6526         },
6527         [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
6528                 .type = HDA_FIXUP_PINS,
6529                 .v.pins = (const struct hda_pintbl[]) {
6530                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6531                         { }
6532                 },
6533                 .chained = true,
6534                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6535         },
6536         [ALC275_FIXUP_DELL_XPS] = {
6537                 .type = HDA_FIXUP_VERBS,
6538                 .v.verbs = (const struct hda_verb[]) {
6539                         /* Enables internal speaker */
6540                         {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
6541                         {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
6542                         {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
6543                         {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
6544                         {}
6545                 }
6546         },
6547         [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
6548                 .type = HDA_FIXUP_FUNC,
6549                 .v.func = alc_fixup_disable_aamix,
6550                 .chained = true,
6551                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
6552         },
6553         [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
6554                 .type = HDA_FIXUP_FUNC,
6555                 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
6556         },
6557         [ALC255_FIXUP_DELL_SPK_NOISE] = {
6558                 .type = HDA_FIXUP_FUNC,
6559                 .v.func = alc_fixup_disable_aamix,
6560                 .chained = true,
6561                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6562         },
6563         [ALC225_FIXUP_DISABLE_MIC_VREF] = {
6564                 .type = HDA_FIXUP_FUNC,
6565                 .v.func = alc_fixup_disable_mic_vref,
6566                 .chained = true,
6567                 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6568         },
6569         [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6570                 .type = HDA_FIXUP_VERBS,
6571                 .v.verbs = (const struct hda_verb[]) {
6572                         /* Disable pass-through path for FRONT 14h */
6573                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6574                         { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6575                         {}
6576                 },
6577                 .chained = true,
6578                 .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
6579         },
6580         [ALC280_FIXUP_HP_HEADSET_MIC] = {
6581                 .type = HDA_FIXUP_FUNC,
6582                 .v.func = alc_fixup_disable_aamix,
6583                 .chained = true,
6584                 .chain_id = ALC269_FIXUP_HEADSET_MIC,
6585         },
6586         [ALC221_FIXUP_HP_FRONT_MIC] = {
6587                 .type = HDA_FIXUP_PINS,
6588                 .v.pins = (const struct hda_pintbl[]) {
6589                         { 0x19, 0x02a19020 }, /* Front Mic */
6590                         { }
6591                 },
6592         },
6593         [ALC292_FIXUP_TPT460] = {
6594                 .type = HDA_FIXUP_FUNC,
6595                 .v.func = alc_fixup_tpt440_dock,
6596                 .chained = true,
6597                 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
6598         },
6599         [ALC298_FIXUP_SPK_VOLUME] = {
6600                 .type = HDA_FIXUP_FUNC,
6601                 .v.func = alc298_fixup_speaker_volume,
6602                 .chained = true,
6603                 .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6604         },
6605         [ALC298_FIXUP_LENOVO_SPK_VOLUME] = {
6606                 .type = HDA_FIXUP_FUNC,
6607                 .v.func = alc298_fixup_speaker_volume,
6608         },
6609         [ALC295_FIXUP_DISABLE_DAC3] = {
6610                 .type = HDA_FIXUP_FUNC,
6611                 .v.func = alc295_fixup_disable_dac3,
6612         },
6613         [ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
6614                 .type = HDA_FIXUP_FUNC,
6615                 .v.func = alc285_fixup_speaker2_to_dac1,
6616                 .chained = true,
6617                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
6618         },
6619         [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
6620                 .type = HDA_FIXUP_PINS,
6621                 .v.pins = (const struct hda_pintbl[]) {
6622                         { 0x1b, 0x90170151 },
6623                         { }
6624                 },
6625                 .chained = true,
6626                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6627         },
6628         [ALC269_FIXUP_ATIV_BOOK_8] = {
6629                 .type = HDA_FIXUP_FUNC,
6630                 .v.func = alc_fixup_auto_mute_via_amp,
6631                 .chained = true,
6632                 .chain_id = ALC269_FIXUP_NO_SHUTUP
6633         },
6634         [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
6635                 .type = HDA_FIXUP_PINS,
6636                 .v.pins = (const struct hda_pintbl[]) {
6637                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6638                         { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6639                         { }
6640                 },
6641                 .chained = true,
6642                 .chain_id = ALC269_FIXUP_HEADSET_MODE
6643         },
6644         [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
6645                 .type = HDA_FIXUP_FUNC,
6646                 .v.func = alc_fixup_headset_mode,
6647         },
6648         [ALC256_FIXUP_ASUS_MIC] = {
6649                 .type = HDA_FIXUP_PINS,
6650                 .v.pins = (const struct hda_pintbl[]) {
6651                         { 0x13, 0x90a60160 }, /* use as internal mic */
6652                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6653                         { }
6654                 },
6655                 .chained = true,
6656                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6657         },
6658         [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
6659                 .type = HDA_FIXUP_FUNC,
6660                 /* Set up GPIO2 for the speaker amp */
6661                 .v.func = alc_fixup_gpio4,
6662         },
6663         [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6664                 .type = HDA_FIXUP_PINS,
6665                 .v.pins = (const struct hda_pintbl[]) {
6666                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6667                         { }
6668                 },
6669                 .chained = true,
6670                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6671         },
6672         [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
6673                 .type = HDA_FIXUP_VERBS,
6674                 .v.verbs = (const struct hda_verb[]) {
6675                         /* Enables internal speaker */
6676                         {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
6677                         {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
6678                         {}
6679                 },
6680                 .chained = true,
6681                 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6682         },
6683         [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
6684                 .type = HDA_FIXUP_FUNC,
6685                 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
6686                 .chained = true,
6687                 .chain_id = ALC269_FIXUP_GPIO2
6688         },
6689         [ALC233_FIXUP_ACER_HEADSET_MIC] = {
6690                 .type = HDA_FIXUP_VERBS,
6691                 .v.verbs = (const struct hda_verb[]) {
6692                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
6693                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
6694                         { }
6695                 },
6696                 .chained = true,
6697                 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6698         },
6699         [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
6700                 .type = HDA_FIXUP_PINS,
6701                 .v.pins = (const struct hda_pintbl[]) {
6702                         /* Change the mic location from front to right, otherwise there are
6703                            two front mics with the same name, pulseaudio can't handle them.
6704                            This is just a temporary workaround, after applying this fixup,
6705                            there will be one "Front Mic" and one "Mic" in this machine.
6706                          */
6707                         { 0x1a, 0x04a19040 },
6708                         { }
6709                 },
6710         },
6711         [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
6712                 .type = HDA_FIXUP_PINS,
6713                 .v.pins = (const struct hda_pintbl[]) {
6714                         { 0x16, 0x0101102f }, /* Rear Headset HP */
6715                         { 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
6716                         { 0x1a, 0x01a19030 }, /* Rear Headset MIC */
6717                         { 0x1b, 0x02011020 },
6718                         { }
6719                 },
6720                 .chained = true,
6721                 .chain_id = ALC225_FIXUP_S3_POP_NOISE
6722         },
6723         [ALC225_FIXUP_S3_POP_NOISE] = {
6724                 .type = HDA_FIXUP_FUNC,
6725                 .v.func = alc225_fixup_s3_pop_noise,
6726                 .chained = true,
6727                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6728         },
6729         [ALC700_FIXUP_INTEL_REFERENCE] = {
6730                 .type = HDA_FIXUP_VERBS,
6731                 .v.verbs = (const struct hda_verb[]) {
6732                         /* Enables internal speaker */
6733                         {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
6734                         {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
6735                         {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
6736                         {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
6737                         {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
6738                         {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
6739                         {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
6740                         {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
6741                         {}
6742                 }
6743         },
6744         [ALC274_FIXUP_DELL_BIND_DACS] = {
6745                 .type = HDA_FIXUP_FUNC,
6746                 .v.func = alc274_fixup_bind_dacs,
6747                 .chained = true,
6748                 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6749         },
6750         [ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
6751                 .type = HDA_FIXUP_PINS,
6752                 .v.pins = (const struct hda_pintbl[]) {
6753                         { 0x1b, 0x0401102f },
6754                         { }
6755                 },
6756                 .chained = true,
6757                 .chain_id = ALC274_FIXUP_DELL_BIND_DACS
6758         },
6759         [ALC298_FIXUP_TPT470_DOCK_FIX] = {
6760                 .type = HDA_FIXUP_FUNC,
6761                 .v.func = alc_fixup_tpt470_dock,
6762                 .chained = true,
6763                 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
6764         },
6765         [ALC298_FIXUP_TPT470_DOCK] = {
6766                 .type = HDA_FIXUP_FUNC,
6767                 .v.func = alc_fixup_tpt470_dacs,
6768                 .chained = true,
6769                 .chain_id = ALC298_FIXUP_TPT470_DOCK_FIX
6770         },
6771         [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
6772                 .type = HDA_FIXUP_PINS,
6773                 .v.pins = (const struct hda_pintbl[]) {
6774                         { 0x14, 0x0201101f },
6775                         { }
6776                 },
6777                 .chained = true,
6778                 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6779         },
6780         [ALC255_FIXUP_DELL_HEADSET_MIC] = {
6781                 .type = HDA_FIXUP_PINS,
6782                 .v.pins = (const struct hda_pintbl[]) {
6783                         { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6784                         { }
6785                 },
6786                 .chained = true,
6787                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6788         },
6789         [ALC295_FIXUP_HP_X360] = {
6790                 .type = HDA_FIXUP_FUNC,
6791                 .v.func = alc295_fixup_hp_top_speakers,
6792                 .chained = true,
6793                 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
6794         },
6795         [ALC221_FIXUP_HP_HEADSET_MIC] = {
6796                 .type = HDA_FIXUP_PINS,
6797                 .v.pins = (const struct hda_pintbl[]) {
6798                         { 0x19, 0x0181313f},
6799                         { }
6800                 },
6801                 .chained = true,
6802                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6803         },
6804         [ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
6805                 .type = HDA_FIXUP_FUNC,
6806                 .v.func = alc285_fixup_invalidate_dacs,
6807                 .chained = true,
6808                 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
6809         },
6810         [ALC295_FIXUP_HP_AUTO_MUTE] = {
6811                 .type = HDA_FIXUP_FUNC,
6812                 .v.func = alc_fixup_auto_mute_via_amp,
6813         },
6814         [ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
6815                 .type = HDA_FIXUP_PINS,
6816                 .v.pins = (const struct hda_pintbl[]) {
6817                         { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6818                         { }
6819                 },
6820                 .chained = true,
6821                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6822         },
6823         [ALC294_FIXUP_ASUS_MIC] = {
6824                 .type = HDA_FIXUP_PINS,
6825                 .v.pins = (const struct hda_pintbl[]) {
6826                         { 0x13, 0x90a60160 }, /* use as internal mic */
6827                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6828                         { }
6829                 },
6830                 .chained = true,
6831                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6832         },
6833         [ALC294_FIXUP_ASUS_HEADSET_MIC] = {
6834                 .type = HDA_FIXUP_PINS,
6835                 .v.pins = (const struct hda_pintbl[]) {
6836                         { 0x19, 0x01a1103c }, /* use as headset mic */
6837                         { }
6838                 },
6839                 .chained = true,
6840                 .chain_id = ALC269_FIXUP_HEADSET_MIC
6841         },
6842         [ALC294_FIXUP_ASUS_SPK] = {
6843                 .type = HDA_FIXUP_VERBS,
6844                 .v.verbs = (const struct hda_verb[]) {
6845                         /* Set EAPD high */
6846                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
6847                         { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
6848                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
6849                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
6850                         { }
6851                 },
6852                 .chained = true,
6853                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
6854         },
6855         [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
6856                 .type = HDA_FIXUP_PINS,
6857                 .v.pins = (const struct hda_pintbl[]) {
6858                         { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6859                         { }
6860                 },
6861                 .chained = true,
6862                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6863         },
6864         [ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
6865                 .type = HDA_FIXUP_VERBS,
6866                 .v.verbs = (const struct hda_verb[]) {
6867                         /* Disable PCBEEP-IN passthrough */
6868                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6869                         { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6870                         { }
6871                 },
6872                 .chained = true,
6873                 .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
6874         },
6875         [ALC255_FIXUP_ACER_HEADSET_MIC] = {
6876                 .type = HDA_FIXUP_PINS,
6877                 .v.pins = (const struct hda_pintbl[]) {
6878                         { 0x19, 0x03a11130 },
6879                         { 0x1a, 0x90a60140 }, /* use as internal mic */
6880                         { }
6881                 },
6882                 .chained = true,
6883                 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
6884         },
6885         [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
6886                 .type = HDA_FIXUP_PINS,
6887                 .v.pins = (const struct hda_pintbl[]) {
6888                         { 0x16, 0x01011020 }, /* Rear Line out */
6889                         { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
6890                         { }
6891                 },
6892                 .chained = true,
6893                 .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
6894         },
6895         [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
6896                 .type = HDA_FIXUP_FUNC,
6897                 .v.func = alc_fixup_auto_mute_via_amp,
6898                 .chained = true,
6899                 .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
6900         },
6901         [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
6902                 .type = HDA_FIXUP_FUNC,
6903                 .v.func = alc_fixup_disable_mic_vref,
6904                 .chained = true,
6905                 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6906         },
6907         [ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
6908                 .type = HDA_FIXUP_VERBS,
6909                 .v.verbs = (const struct hda_verb[]) {
6910                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
6911                         { 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
6912                         { }
6913                 },
6914                 .chained = true,
6915                 .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
6916         },
6917         [ALC256_FIXUP_ASUS_HEADSET_MIC] = {
6918                 .type = HDA_FIXUP_PINS,
6919                 .v.pins = (const struct hda_pintbl[]) {
6920                         { 0x19, 0x03a11020 }, /* headset mic with jack detect */
6921                         { }
6922                 },
6923                 .chained = true,
6924                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6925         },
6926         [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6927                 .type = HDA_FIXUP_PINS,
6928                 .v.pins = (const struct hda_pintbl[]) {
6929                         { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6930                         { }
6931                 },
6932                 .chained = true,
6933                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6934         },
6935         [ALC299_FIXUP_PREDATOR_SPK] = {
6936                 .type = HDA_FIXUP_PINS,
6937                 .v.pins = (const struct hda_pintbl[]) {
6938                         { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
6939                         { }
6940                 }
6941         },
6942         [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
6943                 .type = HDA_FIXUP_PINS,
6944                 .v.pins = (const struct hda_pintbl[]) {
6945                         { 0x19, 0x04a11040 },
6946                         { 0x21, 0x04211020 },
6947                         { }
6948                 },
6949                 .chained = true,
6950                 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6951         },
6952         [ALC289_FIXUP_DELL_SPK2] = {
6953                 .type = HDA_FIXUP_PINS,
6954                 .v.pins = (const struct hda_pintbl[]) {
6955                         { 0x17, 0x90170130 }, /* bass spk */
6956                         { }
6957                 },
6958                 .chained = true,
6959                 .chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
6960         },
6961         [ALC289_FIXUP_DUAL_SPK] = {
6962                 .type = HDA_FIXUP_FUNC,
6963                 .v.func = alc285_fixup_speaker2_to_dac1,
6964                 .chained = true,
6965                 .chain_id = ALC289_FIXUP_DELL_SPK2
6966         },
6967         [ALC294_FIXUP_SPK2_TO_DAC1] = {
6968                 .type = HDA_FIXUP_FUNC,
6969                 .v.func = alc285_fixup_speaker2_to_dac1,
6970                 .chained = true,
6971                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
6972         },
6973         [ALC294_FIXUP_ASUS_DUAL_SPK] = {
6974                 .type = HDA_FIXUP_FUNC,
6975                 /* The GPIO must be pulled to initialize the AMP */
6976                 .v.func = alc_fixup_gpio4,
6977                 .chained = true,
6978                 .chain_id = ALC294_FIXUP_SPK2_TO_DAC1
6979         },
6980         [ALC294_FIXUP_ASUS_HPE] = {
6981                 .type = HDA_FIXUP_VERBS,
6982                 .v.verbs = (const struct hda_verb[]) {
6983                         /* Set EAPD high */
6984                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
6985                         { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
6986                         { }
6987                 },
6988                 .chained = true,
6989                 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
6990         },
6991         [ALC285_FIXUP_HP_GPIO_LED] = {
6992                 .type = HDA_FIXUP_FUNC,
6993                 .v.func = alc285_fixup_hp_gpio_led,
6994         },
6995 };
6996
6997 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6998         SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
6999         SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
7000         SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
7001         SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
7002         SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
7003         SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
7004         SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
7005         SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
7006         SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
7007         SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
7008         SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
7009         SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
7010         SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
7011         SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
7012         SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
7013         SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
7014         SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
7015         SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
7016         SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
7017         SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
7018         SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
7019         SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
7020         SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
7021         SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
7022         SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
7023         SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
7024         SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
7025         SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
7026         SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
7027         SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7028         SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7029         SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7030         SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
7031         SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
7032         SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
7033         SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
7034         SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
7035         SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7036         SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7037         SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
7038         SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
7039         SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
7040         SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
7041         SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7042         SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7043         SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
7044         SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
7045         SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
7046         SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
7047         SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
7048         SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
7049         SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
7050         SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
7051         SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
7052         SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
7053         SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
7054         SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
7055         SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
7056         SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
7057         SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
7058         SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
7059         SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
7060         SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
7061         SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
7062         SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
7063         SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
7064         SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
7065         SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
7066         SND_PCI_QUIRK(0x1028, 0x098d, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
7067         SND_PCI_QUIRK(0x1028, 0x09bf, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
7068         SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7069         SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7070         SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
7071         SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
7072         SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
7073         SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7074         SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7075         SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7076         SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7077         SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
7078         SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7079         SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7080         SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
7081         SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
7082         SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
7083         SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
7084         SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
7085         SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7086         SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7087         SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7088         SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7089         SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7090         SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7091         SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
7092         SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
7093         SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7094         SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7095         SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7096         SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7097         SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7098         SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7099         SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7100         SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7101         SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
7102         SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7103         SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
7104         SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7105         SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
7106         SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7107         SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7108         SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7109         SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7110         SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7111         SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7112         SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7113         SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7114         SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7115         SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7116         SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7117         SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7118         SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7119         SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7120         SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
7121         SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7122         SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
7123         SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7124         SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7125         SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7126         SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7127         SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
7128         SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
7129         SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
7130         SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
7131         SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
7132         SND_PCI_QUIRK(0x103c, 0x827f, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
7133         SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
7134         SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
7135         SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
7136         SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
7137         SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
7138         SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
7139         SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_LED),
7140         SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
7141         SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
7142         SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7143         SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
7144         SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
7145         SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
7146         SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7147         SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
7148         SND_PCI_QUIRK(0x1043, 0x1271, "ASUS X430UN", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
7149         SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
7150         SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
7151         SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
7152         SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
7153         SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
7154         SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
7155         SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
7156         SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
7157         SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
7158         SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
7159         SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
7160         SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
7161         SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
7162         SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
7163         SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
7164         SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7165         SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
7166         SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
7167         SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
7168         SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
7169         SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
7170         SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
7171         SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
7172         SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
7173         SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
7174         SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
7175         SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
7176         SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
7177         SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
7178         SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
7179         SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
7180         SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
7181         SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
7182         SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
7183         SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
7184         SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
7185         SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
7186         SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
7187         SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
7188         SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
7189         SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
7190         SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
7191         SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
7192         SND_PCI_QUIRK(0x152d, 0x1082, "Quanta NL3", ALC269_FIXUP_LIFEBOOK),
7193         SND_PCI_QUIRK(0x1558, 0x1323, "Clevo N130ZU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7194         SND_PCI_QUIRK(0x1558, 0x1325, "System76 Darter Pro (darp5)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7195         SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7196         SND_PCI_QUIRK(0x1558, 0x1403, "Clevo N140CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7197         SND_PCI_QUIRK(0x1558, 0x1404, "Clevo N150CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7198         SND_PCI_QUIRK(0x1558, 0x14a1, "Clevo L141MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7199         SND_PCI_QUIRK(0x1558, 0x4018, "Clevo NV40M[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7200         SND_PCI_QUIRK(0x1558, 0x4019, "Clevo NV40MZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7201         SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7202         SND_PCI_QUIRK(0x1558, 0x40a1, "Clevo NL40GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7203         SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7204         SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7205         SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7206         SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7207         SND_PCI_QUIRK(0x1558, 0x50b6, "Clevo NK50S5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7208         SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7209         SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7210         SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7211         SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7212         SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7213         SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7214         SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7215         SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7216         SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7217         SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7218         SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7219         SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7220         SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7221         SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7222         SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7223         SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7224         SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7225         SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7226         SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7227         SND_PCI_QUIRK(0x1558, 0x8535, "Clevo NH50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7228         SND_PCI_QUIRK(0x1558, 0x8536, "Clevo NH79D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7229         SND_PCI_QUIRK(0x1558, 0x8550, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7230         SND_PCI_QUIRK(0x1558, 0x8551, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7231         SND_PCI_QUIRK(0x1558, 0x8560, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
7232         SND_PCI_QUIRK(0x1558, 0x8561, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
7233         SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[5|7][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
7234         SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7235         SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7236         SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7237         SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7238         SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7239         SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7240         SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7241         SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7242         SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7243         SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7244         SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL53RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7245         SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL5XNU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7246         SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7247         SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7248         SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7249         SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7250         SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7251         SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7252         SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
7253         SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7254         SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
7255         SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
7256         SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
7257         SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
7258         SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
7259         SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
7260         SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
7261         SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
7262         SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
7263         SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
7264         SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
7265         SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
7266         SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
7267         SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
7268         SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
7269         SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
7270         SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
7271         SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7272         SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
7273         SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
7274         SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
7275         SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7276         SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7277         SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
7278         SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
7279         SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
7280         SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7281         SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7282         SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
7283         SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7284         SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7285         SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7286         SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7287         SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Yoga 7th", ALC285_FIXUP_SPEAKER2_TO_DAC1),
7288         SND_PCI_QUIRK(0x17aa, 0x2293, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_SPEAKER2_TO_DAC1),
7289         SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
7290         SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
7291         SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7292         SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7293         SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7294         SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7295         SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7296         SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7297         SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7298         SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7299         SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
7300         SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
7301         SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
7302         SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
7303         SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
7304         SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7305         SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
7306         SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
7307         SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7308         SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
7309         SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
7310         SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
7311         SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
7312         SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
7313         SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
7314         SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
7315         SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
7316         SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7317         SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7318         SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7319         SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7320         SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7321         SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7322         SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
7323         SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MBXP", ALC256_FIXUP_HUAWEI_MBXP_PINS),
7324         SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
7325         SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
7326         SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
7327
7328 #if 0
7329         /* Below is a quirk table taken from the old code.
7330          * Basically the device should work as is without the fixup table.
7331          * If BIOS doesn't give a proper info, enable the corresponding
7332          * fixup entry.
7333          */
7334         SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
7335                       ALC269_FIXUP_AMIC),
7336         SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
7337         SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
7338         SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
7339         SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
7340         SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
7341         SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
7342         SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
7343         SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
7344         SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
7345         SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
7346         SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
7347         SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
7348         SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
7349         SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
7350         SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
7351         SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
7352         SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
7353         SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
7354         SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
7355         SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
7356         SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
7357         SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
7358         SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
7359         SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
7360         SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
7361         SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
7362         SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
7363         SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
7364         SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
7365         SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
7366         SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
7367         SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
7368         SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
7369         SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
7370         SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
7371         SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
7372         SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
7373         SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
7374         SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
7375 #endif
7376         {}
7377 };
7378
7379 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
7380         SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
7381         SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
7382         SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
7383         SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
7384         {}
7385 };
7386
7387 static const struct hda_model_fixup alc269_fixup_models[] = {
7388         {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
7389         {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
7390         {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
7391         {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
7392         {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
7393         {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
7394         {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
7395         {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
7396         {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
7397         {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
7398         {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
7399         {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
7400         {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
7401         {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
7402         {.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
7403         {.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
7404         {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
7405         {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
7406         {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
7407         {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
7408         {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
7409         {.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
7410         {.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
7411         {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
7412         {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
7413         {.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
7414         {.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
7415         {.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
7416         {.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
7417         {.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
7418         {.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
7419         {.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
7420         {.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
7421         {.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
7422         {.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
7423         {.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
7424         {.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
7425         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
7426         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
7427         {.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
7428         {.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
7429         {.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
7430         {.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
7431         {.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
7432         {.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
7433         {.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
7434         {.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
7435         {.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
7436         {.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
7437         {.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
7438         {.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
7439         {.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
7440         {.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
7441         {.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
7442         {.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
7443         {.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
7444         {.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
7445         {.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
7446         {.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
7447         {.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
7448         {.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
7449         {.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
7450         {.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
7451         {.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
7452         {.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
7453         {.id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, .name = "alc255-dell-mute"},
7454         {.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
7455         {.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
7456         {.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
7457         {.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
7458         {.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
7459         {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
7460         {.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
7461         {.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
7462         {.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
7463         {.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
7464         {.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
7465         {.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
7466         {.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
7467         {.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
7468         {.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
7469         {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
7470         {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
7471         {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
7472         {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
7473         {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
7474         {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
7475         {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
7476         {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
7477         {.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
7478         {.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
7479         {.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
7480         {.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
7481         {.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
7482         {.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
7483         {.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
7484         {.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
7485         {.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
7486         {.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
7487         {.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
7488         {.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
7489         {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
7490         {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
7491         {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
7492         {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
7493         {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
7494         {}
7495 };
7496 #define ALC225_STANDARD_PINS \
7497         {0x21, 0x04211020}
7498
7499 #define ALC256_STANDARD_PINS \
7500         {0x12, 0x90a60140}, \
7501         {0x14, 0x90170110}, \
7502         {0x21, 0x02211020}
7503
7504 #define ALC282_STANDARD_PINS \
7505         {0x14, 0x90170110}
7506
7507 #define ALC290_STANDARD_PINS \
7508         {0x12, 0x99a30130}
7509
7510 #define ALC292_STANDARD_PINS \
7511         {0x14, 0x90170110}, \
7512         {0x15, 0x0221401f}
7513
7514 #define ALC295_STANDARD_PINS \
7515         {0x12, 0xb7a60130}, \
7516         {0x14, 0x90170110}, \
7517         {0x21, 0x04211020}
7518
7519 #define ALC298_STANDARD_PINS \
7520         {0x12, 0x90a60130}, \
7521         {0x21, 0x03211020}
7522
7523 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
7524         SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
7525                 {0x14, 0x01014020},
7526                 {0x17, 0x90170110},
7527                 {0x18, 0x02a11030},
7528                 {0x19, 0x0181303F},
7529                 {0x21, 0x0221102f}),
7530         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
7531                 {0x12, 0x90a601c0},
7532                 {0x14, 0x90171120},
7533                 {0x21, 0x02211030}),
7534         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
7535                 {0x14, 0x90170110},
7536                 {0x1b, 0x90a70130},
7537                 {0x21, 0x03211020}),
7538         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
7539                 {0x1a, 0x90a70130},
7540                 {0x1b, 0x90170110},
7541                 {0x21, 0x03211020}),
7542         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7543                 ALC225_STANDARD_PINS,
7544                 {0x12, 0xb7a60130},
7545                 {0x14, 0x901701a0}),
7546         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7547                 ALC225_STANDARD_PINS,
7548                 {0x12, 0xb7a60130},
7549                 {0x14, 0x901701b0}),
7550         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7551                 ALC225_STANDARD_PINS,
7552                 {0x12, 0xb7a60150},
7553                 {0x14, 0x901701a0}),
7554         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7555                 ALC225_STANDARD_PINS,
7556                 {0x12, 0xb7a60150},
7557                 {0x14, 0x901701b0}),
7558         SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7559                 ALC225_STANDARD_PINS,
7560                 {0x12, 0xb7a60130},
7561                 {0x1b, 0x90170110}),
7562         SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7563                 {0x1b, 0x01111010},
7564                 {0x1e, 0x01451130},
7565                 {0x21, 0x02211020}),
7566         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
7567                 {0x12, 0x90a60140},
7568                 {0x14, 0x90170110},
7569                 {0x19, 0x02a11030},
7570                 {0x21, 0x02211020}),
7571         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7572                 {0x14, 0x90170110},
7573                 {0x19, 0x02a11030},
7574                 {0x1a, 0x02a11040},
7575                 {0x1b, 0x01014020},
7576                 {0x21, 0x0221101f}),
7577         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7578                 {0x14, 0x90170110},
7579                 {0x19, 0x02a11030},
7580                 {0x1a, 0x02a11040},
7581                 {0x1b, 0x01011020},
7582                 {0x21, 0x0221101f}),
7583         SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7584                 {0x14, 0x90170110},
7585                 {0x19, 0x02a11020},
7586                 {0x1a, 0x02a11030},
7587                 {0x21, 0x0221101f}),
7588         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7589                 {0x12, 0x90a60140},
7590                 {0x14, 0x90170110},
7591                 {0x21, 0x02211020}),
7592         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7593                 {0x12, 0x90a60140},
7594                 {0x14, 0x90170150},
7595                 {0x21, 0x02211020}),
7596         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7597                 {0x21, 0x02211020}),
7598         SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7599                 {0x12, 0x40000000},
7600                 {0x14, 0x90170110},
7601                 {0x21, 0x02211020}),
7602         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
7603                 {0x14, 0x90170110},
7604                 {0x21, 0x02211020}),
7605         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7606                 {0x14, 0x90170130},
7607                 {0x21, 0x02211040}),
7608         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7609                 {0x12, 0x90a60140},
7610                 {0x14, 0x90170110},
7611                 {0x21, 0x02211020}),
7612         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7613                 {0x12, 0x90a60160},
7614                 {0x14, 0x90170120},
7615                 {0x21, 0x02211030}),
7616         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7617                 {0x14, 0x90170110},
7618                 {0x1b, 0x02011020},
7619                 {0x21, 0x0221101f}),
7620         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7621                 {0x14, 0x90170110},
7622                 {0x1b, 0x01011020},
7623                 {0x21, 0x0221101f}),
7624         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7625                 {0x14, 0x90170130},
7626                 {0x1b, 0x01014020},
7627                 {0x21, 0x0221103f}),
7628         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7629                 {0x14, 0x90170130},
7630                 {0x1b, 0x01011020},
7631                 {0x21, 0x0221103f}),
7632         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7633                 {0x14, 0x90170130},
7634                 {0x1b, 0x02011020},
7635                 {0x21, 0x0221103f}),
7636         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7637                 {0x14, 0x90170150},
7638                 {0x1b, 0x02011020},
7639                 {0x21, 0x0221105f}),
7640         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7641                 {0x14, 0x90170110},
7642                 {0x1b, 0x01014020},
7643                 {0x21, 0x0221101f}),
7644         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7645                 {0x12, 0x90a60160},
7646                 {0x14, 0x90170120},
7647                 {0x17, 0x90170140},
7648                 {0x21, 0x0321102f}),
7649         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7650                 {0x12, 0x90a60160},
7651                 {0x14, 0x90170130},
7652                 {0x21, 0x02211040}),
7653         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7654                 {0x12, 0x90a60160},
7655                 {0x14, 0x90170140},
7656                 {0x21, 0x02211050}),
7657         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7658                 {0x12, 0x90a60170},
7659                 {0x14, 0x90170120},
7660                 {0x21, 0x02211030}),
7661         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7662                 {0x12, 0x90a60170},
7663                 {0x14, 0x90170130},
7664                 {0x21, 0x02211040}),
7665         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7666                 {0x12, 0x90a60170},
7667                 {0x14, 0x90171130},
7668                 {0x21, 0x02211040}),
7669         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7670                 {0x12, 0x90a60170},
7671                 {0x14, 0x90170140},
7672                 {0x21, 0x02211050}),
7673         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7674                 {0x12, 0x90a60180},
7675                 {0x14, 0x90170130},
7676                 {0x21, 0x02211040}),
7677         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7678                 {0x12, 0x90a60180},
7679                 {0x14, 0x90170120},
7680                 {0x21, 0x02211030}),
7681         SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7682                 {0x1b, 0x01011020},
7683                 {0x21, 0x02211010}),
7684         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7685                 {0x12, 0x90a60130},
7686                 {0x14, 0x90170110},
7687                 {0x1b, 0x01011020},
7688                 {0x21, 0x0221101f}),
7689         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7690                 {0x12, 0x90a60160},
7691                 {0x14, 0x90170120},
7692                 {0x21, 0x02211030}),
7693         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7694                 {0x12, 0x90a60170},
7695                 {0x14, 0x90170120},
7696                 {0x21, 0x02211030}),
7697         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7698                 {0x12, 0x90a60180},
7699                 {0x14, 0x90170120},
7700                 {0x21, 0x02211030}),
7701         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7702                 {0x12, 0xb7a60130},
7703                 {0x14, 0x90170110},
7704                 {0x21, 0x02211020}),
7705         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7706                 {0x12, 0x90a60130},
7707                 {0x14, 0x90170110},
7708                 {0x14, 0x01011020},
7709                 {0x21, 0x0221101f}),
7710         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7711                 ALC256_STANDARD_PINS),
7712         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7713                 {0x14, 0x90170110},
7714                 {0x1b, 0x01011020},
7715                 {0x21, 0x0221101f}),
7716         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
7717                 {0x14, 0x90170110},
7718                 {0x1b, 0x90a70130},
7719                 {0x21, 0x04211020}),
7720         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
7721                 {0x14, 0x90170110},
7722                 {0x1b, 0x90a70130},
7723                 {0x21, 0x03211020}),
7724         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7725                 {0x12, 0x90a60130},
7726                 {0x14, 0x90170110},
7727                 {0x21, 0x03211020}),
7728         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7729                 {0x12, 0x90a60130},
7730                 {0x14, 0x90170110},
7731                 {0x21, 0x04211020}),
7732         SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7733                 {0x1a, 0x90a70130},
7734                 {0x1b, 0x90170110},
7735                 {0x21, 0x03211020}),
7736         SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
7737                 {0x12, 0xb7a60130},
7738                 {0x13, 0xb8a61140},
7739                 {0x16, 0x90170110},
7740                 {0x21, 0x04211020}),
7741         SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
7742                 {0x12, 0x90a60130},
7743                 {0x14, 0x90170110},
7744                 {0x15, 0x0421101f},
7745                 {0x1a, 0x04a11020}),
7746         SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
7747                 {0x12, 0x90a60140},
7748                 {0x14, 0x90170110},
7749                 {0x15, 0x0421101f},
7750                 {0x18, 0x02811030},
7751                 {0x1a, 0x04a1103f},
7752                 {0x1b, 0x02011020}),
7753         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7754                 ALC282_STANDARD_PINS,
7755                 {0x12, 0x99a30130},
7756                 {0x19, 0x03a11020},
7757                 {0x21, 0x0321101f}),
7758         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7759                 ALC282_STANDARD_PINS,
7760                 {0x12, 0x99a30130},
7761                 {0x19, 0x03a11020},
7762                 {0x21, 0x03211040}),
7763         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7764                 ALC282_STANDARD_PINS,
7765                 {0x12, 0x99a30130},
7766                 {0x19, 0x03a11030},
7767                 {0x21, 0x03211020}),
7768         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7769                 ALC282_STANDARD_PINS,
7770                 {0x12, 0x99a30130},
7771                 {0x19, 0x04a11020},
7772                 {0x21, 0x0421101f}),
7773         SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
7774                 ALC282_STANDARD_PINS,
7775                 {0x12, 0x90a60140},
7776                 {0x19, 0x04a11030},
7777                 {0x21, 0x04211020}),
7778         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7779                 ALC282_STANDARD_PINS,
7780                 {0x12, 0x90a60130},
7781                 {0x21, 0x0321101f}),
7782         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7783                 {0x12, 0x90a60160},
7784                 {0x14, 0x90170120},
7785                 {0x21, 0x02211030}),
7786         SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7787                 ALC282_STANDARD_PINS,
7788                 {0x12, 0x90a60130},
7789                 {0x19, 0x03a11020},
7790                 {0x21, 0x0321101f}),
7791         SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
7792                 {0x12, 0x90a60130},
7793                 {0x14, 0x90170110},
7794                 {0x19, 0x04a11040},
7795                 {0x21, 0x04211020}),
7796         SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
7797                 {0x12, 0x90a60130},
7798                 {0x17, 0x90170110},
7799                 {0x21, 0x02211020}),
7800         SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
7801                 {0x12, 0x90a60120},
7802                 {0x14, 0x90170110},
7803                 {0x21, 0x0321101f}),
7804         SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7805                 {0x12, 0xb7a60130},
7806                 {0x14, 0x90170110},
7807                 {0x21, 0x04211020}),
7808         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7809                 ALC290_STANDARD_PINS,
7810                 {0x15, 0x04211040},
7811                 {0x18, 0x90170112},
7812                 {0x1a, 0x04a11020}),
7813         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7814                 ALC290_STANDARD_PINS,
7815                 {0x15, 0x04211040},
7816                 {0x18, 0x90170110},
7817                 {0x1a, 0x04a11020}),
7818         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7819                 ALC290_STANDARD_PINS,
7820                 {0x15, 0x0421101f},
7821                 {0x1a, 0x04a11020}),
7822         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7823                 ALC290_STANDARD_PINS,
7824                 {0x15, 0x04211020},
7825                 {0x1a, 0x04a11040}),
7826         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7827                 ALC290_STANDARD_PINS,
7828                 {0x14, 0x90170110},
7829                 {0x15, 0x04211020},
7830                 {0x1a, 0x04a11040}),
7831         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7832                 ALC290_STANDARD_PINS,
7833                 {0x14, 0x90170110},
7834                 {0x15, 0x04211020},
7835                 {0x1a, 0x04a11020}),
7836         SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
7837                 ALC290_STANDARD_PINS,
7838                 {0x14, 0x90170110},
7839                 {0x15, 0x0421101f},
7840                 {0x1a, 0x04a11020}),
7841         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
7842                 ALC292_STANDARD_PINS,
7843                 {0x12, 0x90a60140},
7844                 {0x16, 0x01014020},
7845                 {0x19, 0x01a19030}),
7846         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
7847                 ALC292_STANDARD_PINS,
7848                 {0x12, 0x90a60140},
7849                 {0x16, 0x01014020},
7850                 {0x18, 0x02a19031},
7851                 {0x19, 0x01a1903e}),
7852         SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
7853                 ALC292_STANDARD_PINS,
7854                 {0x12, 0x90a60140}),
7855         SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
7856                 ALC292_STANDARD_PINS,
7857                 {0x13, 0x90a60140},
7858                 {0x16, 0x21014020},
7859                 {0x19, 0x21a19030}),
7860         SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
7861                 ALC292_STANDARD_PINS,
7862                 {0x13, 0x90a60140}),
7863         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_HPE,
7864                 {0x17, 0x90170110},
7865                 {0x21, 0x04211020}),
7866         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
7867                 {0x14, 0x90170110},
7868                 {0x1b, 0x90a70130},
7869                 {0x21, 0x04211020}),
7870         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7871                 {0x12, 0x90a60130},
7872                 {0x17, 0x90170110},
7873                 {0x21, 0x03211020}),
7874         SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7875                 {0x12, 0x90a60130},
7876                 {0x17, 0x90170110},
7877                 {0x21, 0x04211020}),
7878         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7879                 {0x12, 0x90a60130},
7880                 {0x17, 0x90170110},
7881                 {0x21, 0x03211020}),
7882         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7883                 {0x14, 0x90170110},
7884                 {0x21, 0x04211020}),
7885         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7886                 {0x14, 0x90170110},
7887                 {0x21, 0x04211030}),
7888         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7889                 ALC295_STANDARD_PINS,
7890                 {0x17, 0x21014020},
7891                 {0x18, 0x21a19030}),
7892         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7893                 ALC295_STANDARD_PINS,
7894                 {0x17, 0x21014040},
7895                 {0x18, 0x21a19050}),
7896         SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7897                 ALC295_STANDARD_PINS),
7898         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7899                 ALC298_STANDARD_PINS,
7900                 {0x17, 0x90170110}),
7901         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7902                 ALC298_STANDARD_PINS,
7903                 {0x17, 0x90170140}),
7904         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7905                 ALC298_STANDARD_PINS,
7906                 {0x17, 0x90170150}),
7907         SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
7908                 {0x12, 0xb7a60140},
7909                 {0x13, 0xb7a60150},
7910                 {0x17, 0x90170110},
7911                 {0x1a, 0x03011020},
7912                 {0x21, 0x03211030}),
7913         SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7914                 ALC225_STANDARD_PINS,
7915                 {0x12, 0xb7a60130},
7916                 {0x17, 0x90170110}),
7917         SND_HDA_PIN_QUIRK(0x10ec0623, 0x17aa, "Lenovo", ALC283_FIXUP_HEADSET_MIC,
7918                 {0x14, 0x01014010},
7919                 {0x17, 0x90170120},
7920                 {0x18, 0x02a11030},
7921                 {0x19, 0x02a1103f},
7922                 {0x21, 0x0221101f}),
7923         {}
7924 };
7925
7926 static void alc269_fill_coef(struct hda_codec *codec)
7927 {
7928         struct alc_spec *spec = codec->spec;
7929         int val;
7930
7931         if (spec->codec_variant != ALC269_TYPE_ALC269VB)
7932                 return;
7933
7934         if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
7935                 alc_write_coef_idx(codec, 0xf, 0x960b);
7936                 alc_write_coef_idx(codec, 0xe, 0x8817);
7937         }
7938
7939         if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
7940                 alc_write_coef_idx(codec, 0xf, 0x960b);
7941                 alc_write_coef_idx(codec, 0xe, 0x8814);
7942         }
7943
7944         if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
7945                 /* Power up output pin */
7946                 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
7947         }
7948
7949         if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
7950                 val = alc_read_coef_idx(codec, 0xd);
7951                 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
7952                         /* Capless ramp up clock control */
7953                         alc_write_coef_idx(codec, 0xd, val | (1<<10));
7954                 }
7955                 val = alc_read_coef_idx(codec, 0x17);
7956                 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
7957                         /* Class D power on reset */
7958                         alc_write_coef_idx(codec, 0x17, val | (1<<7));
7959                 }
7960         }
7961
7962         /* HP */
7963         alc_update_coef_idx(codec, 0x4, 0, 1<<11);
7964 }
7965
7966 /*
7967  */
7968 static int patch_alc269(struct hda_codec *codec)
7969 {
7970         struct alc_spec *spec;
7971         int err;
7972
7973         err = alc_alloc_spec(codec, 0x0b);
7974         if (err < 0)
7975                 return err;
7976
7977         spec = codec->spec;
7978         spec->gen.shared_mic_vref_pin = 0x18;
7979         codec->power_save_node = 0;
7980
7981 #ifdef CONFIG_PM
7982         codec->patch_ops.suspend = alc269_suspend;
7983         codec->patch_ops.resume = alc269_resume;
7984 #endif
7985         spec->shutup = alc_default_shutup;
7986         spec->init_hook = alc_default_init;
7987
7988         switch (codec->core.vendor_id) {
7989         case 0x10ec0269:
7990                 spec->codec_variant = ALC269_TYPE_ALC269VA;
7991                 switch (alc_get_coef0(codec) & 0x00f0) {
7992                 case 0x0010:
7993                         if (codec->bus->pci &&
7994                             codec->bus->pci->subsystem_vendor == 0x1025 &&
7995                             spec->cdefine.platform_type == 1)
7996                                 err = alc_codec_rename(codec, "ALC271X");
7997                         spec->codec_variant = ALC269_TYPE_ALC269VB;
7998                         break;
7999                 case 0x0020:
8000                         if (codec->bus->pci &&
8001                             codec->bus->pci->subsystem_vendor == 0x17aa &&
8002                             codec->bus->pci->subsystem_device == 0x21f3)
8003                                 err = alc_codec_rename(codec, "ALC3202");
8004                         spec->codec_variant = ALC269_TYPE_ALC269VC;
8005                         break;
8006                 case 0x0030:
8007                         spec->codec_variant = ALC269_TYPE_ALC269VD;
8008                         break;
8009                 default:
8010                         alc_fix_pll_init(codec, 0x20, 0x04, 15);
8011                 }
8012                 if (err < 0)
8013                         goto error;
8014                 spec->shutup = alc269_shutup;
8015                 spec->init_hook = alc269_fill_coef;
8016                 alc269_fill_coef(codec);
8017                 break;
8018
8019         case 0x10ec0280:
8020         case 0x10ec0290:
8021                 spec->codec_variant = ALC269_TYPE_ALC280;
8022                 break;
8023         case 0x10ec0282:
8024                 spec->codec_variant = ALC269_TYPE_ALC282;
8025                 spec->shutup = alc282_shutup;
8026                 spec->init_hook = alc282_init;
8027                 break;
8028         case 0x10ec0233:
8029         case 0x10ec0283:
8030                 spec->codec_variant = ALC269_TYPE_ALC283;
8031                 spec->shutup = alc283_shutup;
8032                 spec->init_hook = alc283_init;
8033                 break;
8034         case 0x10ec0284:
8035         case 0x10ec0292:
8036                 spec->codec_variant = ALC269_TYPE_ALC284;
8037                 break;
8038         case 0x10ec0293:
8039                 spec->codec_variant = ALC269_TYPE_ALC293;
8040                 break;
8041         case 0x10ec0286:
8042         case 0x10ec0288:
8043                 spec->codec_variant = ALC269_TYPE_ALC286;
8044                 break;
8045         case 0x10ec0298:
8046                 spec->codec_variant = ALC269_TYPE_ALC298;
8047                 break;
8048         case 0x10ec0235:
8049         case 0x10ec0255:
8050                 spec->codec_variant = ALC269_TYPE_ALC255;
8051                 spec->shutup = alc256_shutup;
8052                 spec->init_hook = alc256_init;
8053                 break;
8054         case 0x10ec0236:
8055         case 0x10ec0256:
8056                 spec->codec_variant = ALC269_TYPE_ALC256;
8057                 spec->shutup = alc256_shutup;
8058                 spec->init_hook = alc256_init;
8059                 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
8060                 break;
8061         case 0x10ec0257:
8062                 spec->codec_variant = ALC269_TYPE_ALC257;
8063                 spec->shutup = alc256_shutup;
8064                 spec->init_hook = alc256_init;
8065                 spec->gen.mixer_nid = 0;
8066                 break;
8067         case 0x10ec0215:
8068         case 0x10ec0245:
8069         case 0x10ec0285:
8070         case 0x10ec0287:
8071         case 0x10ec0289:
8072                 spec->codec_variant = ALC269_TYPE_ALC215;
8073                 spec->shutup = alc225_shutup;
8074                 spec->init_hook = alc225_init;
8075                 spec->gen.mixer_nid = 0;
8076                 break;
8077         case 0x10ec0225:
8078         case 0x10ec0295:
8079         case 0x10ec0299:
8080                 spec->codec_variant = ALC269_TYPE_ALC225;
8081                 spec->shutup = alc225_shutup;
8082                 spec->init_hook = alc225_init;
8083                 spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
8084                 break;
8085         case 0x10ec0234:
8086         case 0x10ec0274:
8087         case 0x10ec0294:
8088                 spec->codec_variant = ALC269_TYPE_ALC294;
8089                 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
8090                 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
8091                 spec->init_hook = alc294_init;
8092                 break;
8093         case 0x10ec0300:
8094                 spec->codec_variant = ALC269_TYPE_ALC300;
8095                 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
8096                 break;
8097         case 0x10ec0623:
8098                 spec->codec_variant = ALC269_TYPE_ALC623;
8099                 break;
8100         case 0x10ec0700:
8101         case 0x10ec0701:
8102         case 0x10ec0703:
8103         case 0x10ec0711:
8104                 spec->codec_variant = ALC269_TYPE_ALC700;
8105                 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
8106                 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
8107                 spec->init_hook = alc294_init;
8108                 break;
8109
8110         }
8111
8112         if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
8113                 spec->has_alc5505_dsp = 1;
8114                 spec->init_hook = alc5505_dsp_init;
8115         }
8116
8117         snd_hda_pick_fixup(codec, alc269_fixup_models,
8118                        alc269_fixup_tbl, alc269_fixups);
8119         snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
8120         snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
8121                            alc269_fixups);
8122         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8123
8124         alc_auto_parse_customize_define(codec);
8125
8126         if (has_cdefine_beep(codec))
8127                 spec->gen.beep_nid = 0x01;
8128
8129         /* automatic parse from the BIOS config */
8130         err = alc269_parse_auto_config(codec);
8131         if (err < 0)
8132                 goto error;
8133
8134         if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
8135                 err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
8136                 if (err < 0)
8137                         goto error;
8138         }
8139
8140         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
8141
8142         return 0;
8143
8144  error:
8145         alc_free(codec);
8146         return err;
8147 }
8148
8149 /*
8150  * ALC861
8151  */
8152
8153 static int alc861_parse_auto_config(struct hda_codec *codec)
8154 {
8155         static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
8156         static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
8157         return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
8158 }
8159
8160 /* Pin config fixes */
8161 enum {
8162         ALC861_FIXUP_FSC_AMILO_PI1505,
8163         ALC861_FIXUP_AMP_VREF_0F,
8164         ALC861_FIXUP_NO_JACK_DETECT,
8165         ALC861_FIXUP_ASUS_A6RP,
8166         ALC660_FIXUP_ASUS_W7J,
8167 };
8168
8169 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
8170 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
8171                         const struct hda_fixup *fix, int action)
8172 {
8173         struct alc_spec *spec = codec->spec;
8174         unsigned int val;
8175
8176         if (action != HDA_FIXUP_ACT_INIT)
8177                 return;
8178         val = snd_hda_codec_get_pin_target(codec, 0x0f);
8179         if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
8180                 val |= AC_PINCTL_IN_EN;
8181         val |= AC_PINCTL_VREF_50;
8182         snd_hda_set_pin_ctl(codec, 0x0f, val);
8183         spec->gen.keep_vref_in_automute = 1;
8184 }
8185
8186 /* suppress the jack-detection */
8187 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
8188                                      const struct hda_fixup *fix, int action)
8189 {
8190         if (action == HDA_FIXUP_ACT_PRE_PROBE)
8191                 codec->no_jack_detect = 1;
8192 }
8193
8194 static const struct hda_fixup alc861_fixups[] = {
8195         [ALC861_FIXUP_FSC_AMILO_PI1505] = {
8196                 .type = HDA_FIXUP_PINS,
8197                 .v.pins = (const struct hda_pintbl[]) {
8198                         { 0x0b, 0x0221101f }, /* HP */
8199                         { 0x0f, 0x90170310 }, /* speaker */
8200                         { }
8201                 }
8202         },
8203         [ALC861_FIXUP_AMP_VREF_0F] = {
8204                 .type = HDA_FIXUP_FUNC,
8205                 .v.func = alc861_fixup_asus_amp_vref_0f,
8206         },
8207         [ALC861_FIXUP_NO_JACK_DETECT] = {
8208                 .type = HDA_FIXUP_FUNC,
8209                 .v.func = alc_fixup_no_jack_detect,
8210         },
8211         [ALC861_FIXUP_ASUS_A6RP] = {
8212                 .type = HDA_FIXUP_FUNC,
8213                 .v.func = alc861_fixup_asus_amp_vref_0f,
8214                 .chained = true,
8215                 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
8216         },
8217         [ALC660_FIXUP_ASUS_W7J] = {
8218                 .type = HDA_FIXUP_VERBS,
8219                 .v.verbs = (const struct hda_verb[]) {
8220                         /* ASUS W7J needs a magic pin setup on unused NID 0x10
8221                          * for enabling outputs
8222                          */
8223                         {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8224                         { }
8225                 },
8226         }
8227 };
8228
8229 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
8230         SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
8231         SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
8232         SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
8233         SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
8234         SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
8235         SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
8236         SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
8237         {}
8238 };
8239
8240 /*
8241  */
8242 static int patch_alc861(struct hda_codec *codec)
8243 {
8244         struct alc_spec *spec;
8245         int err;
8246
8247         err = alc_alloc_spec(codec, 0x15);
8248         if (err < 0)
8249                 return err;
8250
8251         spec = codec->spec;
8252         spec->gen.beep_nid = 0x23;
8253
8254 #ifdef CONFIG_PM
8255         spec->power_hook = alc_power_eapd;
8256 #endif
8257
8258         snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
8259         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8260
8261         /* automatic parse from the BIOS config */
8262         err = alc861_parse_auto_config(codec);
8263         if (err < 0)
8264                 goto error;
8265
8266         if (!spec->gen.no_analog) {
8267                 err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
8268                 if (err < 0)
8269                         goto error;
8270         }
8271
8272         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
8273
8274         return 0;
8275
8276  error:
8277         alc_free(codec);
8278         return err;
8279 }
8280
8281 /*
8282  * ALC861-VD support
8283  *
8284  * Based on ALC882
8285  *
8286  * In addition, an independent DAC
8287  */
8288 static int alc861vd_parse_auto_config(struct hda_codec *codec)
8289 {
8290         static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8291         static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
8292         return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
8293 }
8294
8295 enum {
8296         ALC660VD_FIX_ASUS_GPIO1,
8297         ALC861VD_FIX_DALLAS,
8298 };
8299
8300 /* exclude VREF80 */
8301 static void alc861vd_fixup_dallas(struct hda_codec *codec,
8302                                   const struct hda_fixup *fix, int action)
8303 {
8304         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
8305                 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
8306                 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8307         }
8308 }
8309
8310 /* reset GPIO1 */
8311 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
8312                                       const struct hda_fixup *fix, int action)
8313 {
8314         struct alc_spec *spec = codec->spec;
8315
8316         if (action == HDA_FIXUP_ACT_PRE_PROBE)
8317                 spec->gpio_mask |= 0x02;
8318         alc_fixup_gpio(codec, action, 0x01);
8319 }
8320
8321 static const struct hda_fixup alc861vd_fixups[] = {
8322         [ALC660VD_FIX_ASUS_GPIO1] = {
8323                 .type = HDA_FIXUP_FUNC,
8324                 .v.func = alc660vd_fixup_asus_gpio1,
8325         },
8326         [ALC861VD_FIX_DALLAS] = {
8327                 .type = HDA_FIXUP_FUNC,
8328                 .v.func = alc861vd_fixup_dallas,
8329         },
8330 };
8331
8332 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8333         SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
8334         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8335         SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
8336         {}
8337 };
8338
8339 /*
8340  */
8341 static int patch_alc861vd(struct hda_codec *codec)
8342 {
8343         struct alc_spec *spec;
8344         int err;
8345
8346         err = alc_alloc_spec(codec, 0x0b);
8347         if (err < 0)
8348                 return err;
8349
8350         spec = codec->spec;
8351         spec->gen.beep_nid = 0x23;
8352
8353         spec->shutup = alc_eapd_shutup;
8354
8355         snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
8356         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8357
8358         /* automatic parse from the BIOS config */
8359         err = alc861vd_parse_auto_config(codec);
8360         if (err < 0)
8361                 goto error;
8362
8363         if (!spec->gen.no_analog) {
8364                 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
8365                 if (err < 0)
8366                         goto error;
8367         }
8368
8369         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
8370
8371         return 0;
8372
8373  error:
8374         alc_free(codec);
8375         return err;
8376 }
8377
8378 /*
8379  * ALC662 support
8380  *
8381  * ALC662 is almost identical with ALC880 but has cleaner and more flexible
8382  * configuration.  Each pin widget can choose any input DACs and a mixer.
8383  * Each ADC is connected from a mixer of all inputs.  This makes possible
8384  * 6-channel independent captures.
8385  *
8386  * In addition, an independent DAC for the multi-playback (not used in this
8387  * driver yet).
8388  */
8389
8390 /*
8391  * BIOS auto configuration
8392  */
8393
8394 static int alc662_parse_auto_config(struct hda_codec *codec)
8395 {
8396         static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
8397         static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
8398         static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
8399         const hda_nid_t *ssids;
8400
8401         if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
8402             codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
8403             codec->core.vendor_id == 0x10ec0671)
8404                 ssids = alc663_ssids;
8405         else
8406                 ssids = alc662_ssids;
8407         return alc_parse_auto_config(codec, alc662_ignore, ssids);
8408 }
8409
8410 static void alc272_fixup_mario(struct hda_codec *codec,
8411                                const struct hda_fixup *fix, int action)
8412 {
8413         if (action != HDA_FIXUP_ACT_PRE_PROBE)
8414                 return;
8415         if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
8416                                       (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
8417                                       (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
8418                                       (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
8419                                       (0 << AC_AMPCAP_MUTE_SHIFT)))
8420                 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
8421 }
8422
8423 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
8424         { .channels = 2,
8425           .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
8426         { .channels = 4,
8427           .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
8428                    SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
8429         { }
8430 };
8431
8432 /* override the 2.1 chmap */
8433 static void alc_fixup_bass_chmap(struct hda_codec *codec,
8434                                     const struct hda_fixup *fix, int action)
8435 {
8436         if (action == HDA_FIXUP_ACT_BUILD) {
8437                 struct alc_spec *spec = codec->spec;
8438                 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
8439         }
8440 }
8441
8442 /* avoid D3 for keeping GPIO up */
8443 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
8444                                           hda_nid_t nid,
8445                                           unsigned int power_state)
8446 {
8447         struct alc_spec *spec = codec->spec;
8448         if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
8449                 return AC_PWRST_D0;
8450         return power_state;
8451 }
8452
8453 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
8454                                    const struct hda_fixup *fix, int action)
8455 {
8456         struct alc_spec *spec = codec->spec;
8457
8458         alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
8459         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
8460                 spec->mute_led_polarity = 1;
8461                 codec->power_filter = gpio_led_power_filter;
8462         }
8463 }
8464
8465 static void alc662_usi_automute_hook(struct hda_codec *codec,
8466                                          struct hda_jack_callback *jack)
8467 {
8468         struct alc_spec *spec = codec->spec;
8469         int vref;
8470         msleep(200);
8471         snd_hda_gen_hp_automute(codec, jack);
8472
8473         vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
8474         msleep(100);
8475         snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8476                             vref);
8477 }
8478
8479 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
8480                                      const struct hda_fixup *fix, int action)
8481 {
8482         struct alc_spec *spec = codec->spec;
8483         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
8484                 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
8485                 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
8486         }
8487 }
8488
8489 static struct coef_fw alc668_coefs[] = {
8490         WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
8491         WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
8492         WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
8493         WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
8494         WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
8495         WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
8496         WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
8497         WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
8498         WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
8499         WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
8500         WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
8501         WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
8502         WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
8503         WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
8504         WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
8505         WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
8506         WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
8507         WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
8508         WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
8509         WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
8510         {}
8511 };
8512
8513 static void alc668_restore_default_value(struct hda_codec *codec)
8514 {
8515         alc_process_coef_fw(codec, alc668_coefs);
8516 }
8517
8518 enum {
8519         ALC662_FIXUP_ASPIRE,
8520         ALC662_FIXUP_LED_GPIO1,
8521         ALC662_FIXUP_IDEAPAD,
8522         ALC272_FIXUP_MARIO,
8523         ALC662_FIXUP_CZC_P10T,
8524         ALC662_FIXUP_SKU_IGNORE,
8525         ALC662_FIXUP_HP_RP5800,
8526         ALC662_FIXUP_ASUS_MODE1,
8527         ALC662_FIXUP_ASUS_MODE2,
8528         ALC662_FIXUP_ASUS_MODE3,
8529         ALC662_FIXUP_ASUS_MODE4,
8530         ALC662_FIXUP_ASUS_MODE5,
8531         ALC662_FIXUP_ASUS_MODE6,
8532         ALC662_FIXUP_ASUS_MODE7,
8533         ALC662_FIXUP_ASUS_MODE8,
8534         ALC662_FIXUP_NO_JACK_DETECT,
8535         ALC662_FIXUP_ZOTAC_Z68,
8536         ALC662_FIXUP_INV_DMIC,
8537         ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
8538         ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
8539         ALC662_FIXUP_HEADSET_MODE,
8540         ALC668_FIXUP_HEADSET_MODE,
8541         ALC662_FIXUP_BASS_MODE4_CHMAP,
8542         ALC662_FIXUP_BASS_16,
8543         ALC662_FIXUP_BASS_1A,
8544         ALC662_FIXUP_BASS_CHMAP,
8545         ALC668_FIXUP_AUTO_MUTE,
8546         ALC668_FIXUP_DELL_DISABLE_AAMIX,
8547         ALC668_FIXUP_DELL_XPS13,
8548         ALC662_FIXUP_ASUS_Nx50,
8549         ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
8550         ALC668_FIXUP_ASUS_Nx51,
8551         ALC668_FIXUP_MIC_COEF,
8552         ALC668_FIXUP_ASUS_G751,
8553         ALC891_FIXUP_HEADSET_MODE,
8554         ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
8555         ALC662_FIXUP_ACER_VERITON,
8556         ALC892_FIXUP_ASROCK_MOBO,
8557         ALC662_FIXUP_USI_FUNC,
8558         ALC662_FIXUP_USI_HEADSET_MODE,
8559         ALC662_FIXUP_LENOVO_MULTI_CODECS,
8560 };
8561
8562 static const struct hda_fixup alc662_fixups[] = {
8563         [ALC662_FIXUP_ASPIRE] = {
8564                 .type = HDA_FIXUP_PINS,
8565                 .v.pins = (const struct hda_pintbl[]) {
8566                         { 0x15, 0x99130112 }, /* subwoofer */
8567                         { }
8568                 }
8569         },
8570         [ALC662_FIXUP_LED_GPIO1] = {
8571                 .type = HDA_FIXUP_FUNC,
8572                 .v.func = alc662_fixup_led_gpio1,
8573         },
8574         [ALC662_FIXUP_IDEAPAD] = {
8575                 .type = HDA_FIXUP_PINS,
8576                 .v.pins = (const struct hda_pintbl[]) {
8577                         { 0x17, 0x99130112 }, /* subwoofer */
8578                         { }
8579                 },
8580                 .chained = true,
8581                 .chain_id = ALC662_FIXUP_LED_GPIO1,
8582         },
8583         [ALC272_FIXUP_MARIO] = {
8584                 .type = HDA_FIXUP_FUNC,
8585                 .v.func = alc272_fixup_mario,
8586         },
8587         [ALC662_FIXUP_CZC_P10T] = {
8588                 .type = HDA_FIXUP_VERBS,
8589                 .v.verbs = (const struct hda_verb[]) {
8590                         {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
8591                         {}
8592                 }
8593         },
8594         [ALC662_FIXUP_SKU_IGNORE] = {
8595                 .type = HDA_FIXUP_FUNC,
8596                 .v.func = alc_fixup_sku_ignore,
8597         },
8598         [ALC662_FIXUP_HP_RP5800] = {
8599                 .type = HDA_FIXUP_PINS,
8600                 .v.pins = (const struct hda_pintbl[]) {
8601                         { 0x14, 0x0221201f }, /* HP out */
8602                         { }
8603                 },
8604                 .chained = true,
8605                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8606         },
8607         [ALC662_FIXUP_ASUS_MODE1] = {
8608                 .type = HDA_FIXUP_PINS,
8609                 .v.pins = (const struct hda_pintbl[]) {
8610                         { 0x14, 0x99130110 }, /* speaker */
8611                         { 0x18, 0x01a19c20 }, /* mic */
8612                         { 0x19, 0x99a3092f }, /* int-mic */
8613                         { 0x21, 0x0121401f }, /* HP out */
8614                         { }
8615                 },
8616                 .chained = true,
8617                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8618         },
8619         [ALC662_FIXUP_ASUS_MODE2] = {
8620                 .type = HDA_FIXUP_PINS,
8621                 .v.pins = (const struct hda_pintbl[]) {
8622                         { 0x14, 0x99130110 }, /* speaker */
8623                         { 0x18, 0x01a19820 }, /* mic */
8624                         { 0x19, 0x99a3092f }, /* int-mic */
8625                         { 0x1b, 0x0121401f }, /* HP out */
8626                         { }
8627                 },
8628                 .chained = true,
8629                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8630         },
8631         [ALC662_FIXUP_ASUS_MODE3] = {
8632                 .type = HDA_FIXUP_PINS,
8633                 .v.pins = (const struct hda_pintbl[]) {
8634                         { 0x14, 0x99130110 }, /* speaker */
8635                         { 0x15, 0x0121441f }, /* HP */
8636                         { 0x18, 0x01a19840 }, /* mic */
8637                         { 0x19, 0x99a3094f }, /* int-mic */
8638                         { 0x21, 0x01211420 }, /* HP2 */
8639                         { }
8640                 },
8641                 .chained = true,
8642                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8643         },
8644         [ALC662_FIXUP_ASUS_MODE4] = {
8645                 .type = HDA_FIXUP_PINS,
8646                 .v.pins = (const struct hda_pintbl[]) {
8647                         { 0x14, 0x99130110 }, /* speaker */
8648                         { 0x16, 0x99130111 }, /* speaker */
8649                         { 0x18, 0x01a19840 }, /* mic */
8650                         { 0x19, 0x99a3094f }, /* int-mic */
8651                         { 0x21, 0x0121441f }, /* HP */
8652                         { }
8653                 },
8654                 .chained = true,
8655                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8656         },
8657         [ALC662_FIXUP_ASUS_MODE5] = {
8658                 .type = HDA_FIXUP_PINS,
8659                 .v.pins = (const struct hda_pintbl[]) {
8660                         { 0x14, 0x99130110 }, /* speaker */
8661                         { 0x15, 0x0121441f }, /* HP */
8662                         { 0x16, 0x99130111 }, /* speaker */
8663                         { 0x18, 0x01a19840 }, /* mic */
8664                         { 0x19, 0x99a3094f }, /* int-mic */
8665                         { }
8666                 },
8667                 .chained = true,
8668                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8669         },
8670         [ALC662_FIXUP_ASUS_MODE6] = {
8671                 .type = HDA_FIXUP_PINS,
8672                 .v.pins = (const struct hda_pintbl[]) {
8673                         { 0x14, 0x99130110 }, /* speaker */
8674                         { 0x15, 0x01211420 }, /* HP2 */
8675                         { 0x18, 0x01a19840 }, /* mic */
8676                         { 0x19, 0x99a3094f }, /* int-mic */
8677                         { 0x1b, 0x0121441f }, /* HP */
8678                         { }
8679                 },
8680                 .chained = true,
8681                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8682         },
8683         [ALC662_FIXUP_ASUS_MODE7] = {
8684                 .type = HDA_FIXUP_PINS,
8685                 .v.pins = (const struct hda_pintbl[]) {
8686                         { 0x14, 0x99130110 }, /* speaker */
8687                         { 0x17, 0x99130111 }, /* speaker */
8688                         { 0x18, 0x01a19840 }, /* mic */
8689                         { 0x19, 0x99a3094f }, /* int-mic */
8690                         { 0x1b, 0x01214020 }, /* HP */
8691                         { 0x21, 0x0121401f }, /* HP */
8692                         { }
8693                 },
8694                 .chained = true,
8695                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8696         },
8697         [ALC662_FIXUP_ASUS_MODE8] = {
8698                 .type = HDA_FIXUP_PINS,
8699                 .v.pins = (const struct hda_pintbl[]) {
8700                         { 0x14, 0x99130110 }, /* speaker */
8701                         { 0x12, 0x99a30970 }, /* int-mic */
8702                         { 0x15, 0x01214020 }, /* HP */
8703                         { 0x17, 0x99130111 }, /* speaker */
8704                         { 0x18, 0x01a19840 }, /* mic */
8705                         { 0x21, 0x0121401f }, /* HP */
8706                         { }
8707                 },
8708                 .chained = true,
8709                 .chain_id = ALC662_FIXUP_SKU_IGNORE
8710         },
8711         [ALC662_FIXUP_NO_JACK_DETECT] = {
8712                 .type = HDA_FIXUP_FUNC,
8713                 .v.func = alc_fixup_no_jack_detect,
8714         },
8715         [ALC662_FIXUP_ZOTAC_Z68] = {
8716                 .type = HDA_FIXUP_PINS,
8717                 .v.pins = (const struct hda_pintbl[]) {
8718                         { 0x1b, 0x02214020 }, /* Front HP */
8719                         { }
8720                 }
8721         },
8722         [ALC662_FIXUP_INV_DMIC] = {
8723                 .type = HDA_FIXUP_FUNC,
8724                 .v.func = alc_fixup_inv_dmic,
8725         },
8726         [ALC668_FIXUP_DELL_XPS13] = {
8727                 .type = HDA_FIXUP_FUNC,
8728                 .v.func = alc_fixup_dell_xps13,
8729                 .chained = true,
8730                 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
8731         },
8732         [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
8733                 .type = HDA_FIXUP_FUNC,
8734                 .v.func = alc_fixup_disable_aamix,
8735                 .chained = true,
8736                 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
8737         },
8738         [ALC668_FIXUP_AUTO_MUTE] = {
8739                 .type = HDA_FIXUP_FUNC,
8740                 .v.func = alc_fixup_auto_mute_via_amp,
8741                 .chained = true,
8742                 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
8743         },
8744         [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
8745                 .type = HDA_FIXUP_PINS,
8746                 .v.pins = (const struct hda_pintbl[]) {
8747                         { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8748                         /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
8749                         { }
8750                 },
8751                 .chained = true,
8752                 .chain_id = ALC662_FIXUP_HEADSET_MODE
8753         },
8754         [ALC662_FIXUP_HEADSET_MODE] = {
8755                 .type = HDA_FIXUP_FUNC,
8756                 .v.func = alc_fixup_headset_mode_alc662,
8757         },
8758         [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
8759                 .type = HDA_FIXUP_PINS,
8760                 .v.pins = (const struct hda_pintbl[]) {
8761                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8762                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8763                         { }
8764                 },
8765                 .chained = true,
8766                 .chain_id = ALC668_FIXUP_HEADSET_MODE
8767         },
8768         [ALC668_FIXUP_HEADSET_MODE] = {
8769                 .type = HDA_FIXUP_FUNC,
8770                 .v.func = alc_fixup_headset_mode_alc668,
8771         },
8772         [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
8773                 .type = HDA_FIXUP_FUNC,
8774                 .v.func = alc_fixup_bass_chmap,
8775                 .chained = true,
8776                 .chain_id = ALC662_FIXUP_ASUS_MODE4
8777         },
8778         [ALC662_FIXUP_BASS_16] = {
8779                 .type = HDA_FIXUP_PINS,
8780                 .v.pins = (const struct hda_pintbl[]) {
8781                         {0x16, 0x80106111}, /* bass speaker */
8782                         {}
8783                 },
8784                 .chained = true,
8785                 .chain_id = ALC662_FIXUP_BASS_CHMAP,
8786         },
8787         [ALC662_FIXUP_BASS_1A] = {
8788                 .type = HDA_FIXUP_PINS,
8789                 .v.pins = (const struct hda_pintbl[]) {
8790                         {0x1a, 0x80106111}, /* bass speaker */
8791                         {}
8792                 },
8793                 .chained = true,
8794                 .chain_id = ALC662_FIXUP_BASS_CHMAP,
8795         },
8796         [ALC662_FIXUP_BASS_CHMAP] = {
8797                 .type = HDA_FIXUP_FUNC,
8798                 .v.func = alc_fixup_bass_chmap,
8799         },
8800         [ALC662_FIXUP_ASUS_Nx50] = {
8801                 .type = HDA_FIXUP_FUNC,
8802                 .v.func = alc_fixup_auto_mute_via_amp,
8803                 .chained = true,
8804                 .chain_id = ALC662_FIXUP_BASS_1A
8805         },
8806         [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
8807                 .type = HDA_FIXUP_FUNC,
8808                 .v.func = alc_fixup_headset_mode_alc668,
8809                 .chain_id = ALC662_FIXUP_BASS_CHMAP
8810         },
8811         [ALC668_FIXUP_ASUS_Nx51] = {
8812                 .type = HDA_FIXUP_PINS,
8813                 .v.pins = (const struct hda_pintbl[]) {
8814                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8815                         { 0x1a, 0x90170151 }, /* bass speaker */
8816                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8817                         {}
8818                 },
8819                 .chained = true,
8820                 .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
8821         },
8822         [ALC668_FIXUP_MIC_COEF] = {
8823                 .type = HDA_FIXUP_VERBS,
8824                 .v.verbs = (const struct hda_verb[]) {
8825                         { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
8826                         { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
8827                         {}
8828                 },
8829         },
8830         [ALC668_FIXUP_ASUS_G751] = {
8831                 .type = HDA_FIXUP_PINS,
8832                 .v.pins = (const struct hda_pintbl[]) {
8833                         { 0x16, 0x0421101f }, /* HP */
8834                         {}
8835                 },
8836                 .chained = true,
8837                 .chain_id = ALC668_FIXUP_MIC_COEF
8838         },
8839         [ALC891_FIXUP_HEADSET_MODE] = {
8840                 .type = HDA_FIXUP_FUNC,
8841                 .v.func = alc_fixup_headset_mode,
8842         },
8843         [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
8844                 .type = HDA_FIXUP_PINS,
8845                 .v.pins = (const struct hda_pintbl[]) {
8846                         { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8847                         { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8848                         { }
8849                 },
8850                 .chained = true,
8851                 .chain_id = ALC891_FIXUP_HEADSET_MODE
8852         },
8853         [ALC662_FIXUP_ACER_VERITON] = {
8854                 .type = HDA_FIXUP_PINS,
8855                 .v.pins = (const struct hda_pintbl[]) {
8856                         { 0x15, 0x50170120 }, /* no internal speaker */
8857                         { }
8858                 }
8859         },
8860         [ALC892_FIXUP_ASROCK_MOBO] = {
8861                 .type = HDA_FIXUP_PINS,
8862                 .v.pins = (const struct hda_pintbl[]) {
8863                         { 0x15, 0x40f000f0 }, /* disabled */
8864                         { 0x16, 0x40f000f0 }, /* disabled */
8865                         { }
8866                 }
8867         },
8868         [ALC662_FIXUP_USI_FUNC] = {
8869                 .type = HDA_FIXUP_FUNC,
8870                 .v.func = alc662_fixup_usi_headset_mic,
8871         },
8872         [ALC662_FIXUP_USI_HEADSET_MODE] = {
8873                 .type = HDA_FIXUP_PINS,
8874                 .v.pins = (const struct hda_pintbl[]) {
8875                         { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
8876                         { 0x18, 0x01a1903d },
8877                         { }
8878                 },
8879                 .chained = true,
8880                 .chain_id = ALC662_FIXUP_USI_FUNC
8881         },
8882         [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
8883                 .type = HDA_FIXUP_FUNC,
8884                 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
8885         },
8886 };
8887
8888 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
8889         SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
8890         SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
8891         SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
8892         SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
8893         SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
8894         SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
8895         SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
8896         SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
8897         SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8898         SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8899         SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
8900         SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
8901         SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
8902         SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8903         SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8904         SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8905         SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8906         SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8907         SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
8908         SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
8909         SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
8910         SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
8911         SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
8912         SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
8913         SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
8914         SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
8915         SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
8916         SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
8917         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
8918         SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8919         SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
8920         SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
8921         SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
8922         SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
8923         SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
8924         SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
8925         SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
8926         SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
8927         SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
8928         SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
8929         SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
8930         SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
8931
8932 #if 0
8933         /* Below is a quirk table taken from the old code.
8934          * Basically the device should work as is without the fixup table.
8935          * If BIOS doesn't give a proper info, enable the corresponding
8936          * fixup entry.
8937          */
8938         SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
8939         SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
8940         SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
8941         SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
8942         SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8943         SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8944         SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8945         SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
8946         SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
8947         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8948         SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
8949         SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
8950         SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
8951         SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
8952         SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
8953         SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8954         SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
8955         SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
8956         SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8957         SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8958         SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8959         SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8960         SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
8961         SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
8962         SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
8963         SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8964         SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
8965         SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8966         SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8967         SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
8968         SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8969         SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8970         SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
8971         SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
8972         SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
8973         SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
8974         SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
8975         SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
8976         SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
8977         SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8978         SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
8979         SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
8980         SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8981         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
8982         SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
8983         SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
8984         SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
8985         SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
8986         SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8987         SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
8988 #endif
8989         {}
8990 };
8991
8992 static const struct hda_model_fixup alc662_fixup_models[] = {
8993         {.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
8994         {.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
8995         {.id = ALC272_FIXUP_MARIO, .name = "mario"},
8996         {.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
8997         {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
8998         {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
8999         {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
9000         {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
9001         {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
9002         {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
9003         {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
9004         {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
9005         {.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
9006         {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
9007         {.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
9008         {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
9009         {.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
9010         {.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
9011         {.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
9012         {.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
9013         {.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
9014         {.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
9015         {.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
9016         {.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
9017         {.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
9018         {.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
9019         {.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
9020         {.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
9021         {.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
9022         {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
9023         {}
9024 };
9025
9026 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
9027         SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
9028                 {0x17, 0x02211010},
9029                 {0x18, 0x01a19030},
9030                 {0x1a, 0x01813040},
9031                 {0x21, 0x01014020}),
9032         SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
9033                 {0x16, 0x01813030},
9034                 {0x17, 0x02211010},
9035                 {0x18, 0x01a19040},
9036                 {0x21, 0x01014020}),
9037         SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
9038                 {0x14, 0x01014010},
9039                 {0x18, 0x01a19020},
9040                 {0x1a, 0x0181302f},
9041                 {0x1b, 0x0221401f}),
9042         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
9043                 {0x12, 0x99a30130},
9044                 {0x14, 0x90170110},
9045                 {0x15, 0x0321101f},
9046                 {0x16, 0x03011020}),
9047         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
9048                 {0x12, 0x99a30140},
9049                 {0x14, 0x90170110},
9050                 {0x15, 0x0321101f},
9051                 {0x16, 0x03011020}),
9052         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
9053                 {0x12, 0x99a30150},
9054                 {0x14, 0x90170110},
9055                 {0x15, 0x0321101f},
9056                 {0x16, 0x03011020}),
9057         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
9058                 {0x14, 0x90170110},
9059                 {0x15, 0x0321101f},
9060                 {0x16, 0x03011020}),
9061         SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
9062                 {0x12, 0x90a60130},
9063                 {0x14, 0x90170110},
9064                 {0x15, 0x0321101f}),
9065         {}
9066 };
9067
9068 /*
9069  */
9070 static int patch_alc662(struct hda_codec *codec)
9071 {
9072         struct alc_spec *spec;
9073         int err;
9074
9075         err = alc_alloc_spec(codec, 0x0b);
9076         if (err < 0)
9077                 return err;
9078
9079         spec = codec->spec;
9080
9081         spec->shutup = alc_eapd_shutup;
9082
9083         /* handle multiple HPs as is */
9084         spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
9085
9086         alc_fix_pll_init(codec, 0x20, 0x04, 15);
9087
9088         switch (codec->core.vendor_id) {
9089         case 0x10ec0668:
9090                 spec->init_hook = alc668_restore_default_value;
9091                 break;
9092         }
9093
9094         snd_hda_pick_fixup(codec, alc662_fixup_models,
9095                        alc662_fixup_tbl, alc662_fixups);
9096         snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
9097         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9098
9099         alc_auto_parse_customize_define(codec);
9100
9101         if (has_cdefine_beep(codec))
9102                 spec->gen.beep_nid = 0x01;
9103
9104         if ((alc_get_coef0(codec) & (1 << 14)) &&
9105             codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
9106             spec->cdefine.platform_type == 1) {
9107                 err = alc_codec_rename(codec, "ALC272X");
9108                 if (err < 0)
9109                         goto error;
9110         }
9111
9112         /* automatic parse from the BIOS config */
9113         err = alc662_parse_auto_config(codec);
9114         if (err < 0)
9115                 goto error;
9116
9117         if (!spec->gen.no_analog && spec->gen.beep_nid) {
9118                 switch (codec->core.vendor_id) {
9119                 case 0x10ec0662:
9120                         err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9121                         break;
9122                 case 0x10ec0272:
9123                 case 0x10ec0663:
9124                 case 0x10ec0665:
9125                 case 0x10ec0668:
9126                         err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
9127                         break;
9128                 case 0x10ec0273:
9129                         err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
9130                         break;
9131                 }
9132                 if (err < 0)
9133                         goto error;
9134         }
9135
9136         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9137
9138         return 0;
9139
9140  error:
9141         alc_free(codec);
9142         return err;
9143 }
9144
9145 /*
9146  * ALC680 support
9147  */
9148
9149 static int alc680_parse_auto_config(struct hda_codec *codec)
9150 {
9151         return alc_parse_auto_config(codec, NULL, NULL);
9152 }
9153
9154 /*
9155  */
9156 static int patch_alc680(struct hda_codec *codec)
9157 {
9158         int err;
9159
9160         /* ALC680 has no aa-loopback mixer */
9161         err = alc_alloc_spec(codec, 0);
9162         if (err < 0)
9163                 return err;
9164
9165         /* automatic parse from the BIOS config */
9166         err = alc680_parse_auto_config(codec);
9167         if (err < 0) {
9168                 alc_free(codec);
9169                 return err;
9170         }
9171
9172         return 0;
9173 }
9174
9175 /*
9176  * patch entries
9177  */
9178 static const struct hda_device_id snd_hda_id_realtek[] = {
9179         HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
9180         HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
9181         HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
9182         HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
9183         HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
9184         HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
9185         HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
9186         HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
9187         HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
9188         HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
9189         HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
9190         HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
9191         HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
9192         HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
9193         HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
9194         HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
9195         HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
9196         HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
9197         HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
9198         HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
9199         HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
9200         HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
9201         HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
9202         HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
9203         HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
9204         HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
9205         HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
9206         HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
9207         HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
9208         HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
9209         HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
9210         HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
9211         HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
9212         HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
9213         HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
9214         HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
9215         HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
9216         HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
9217         HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
9218         HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
9219         HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
9220         HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
9221         HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
9222         HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
9223         HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
9224         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
9225         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
9226         HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
9227         HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
9228         HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
9229         HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
9230         HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
9231         HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
9232         HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
9233         HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
9234         HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
9235         HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
9236         HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
9237         HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
9238         HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
9239         HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
9240         HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
9241         HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
9242         HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
9243         HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
9244         HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
9245         HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
9246         HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
9247         HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
9248         HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
9249         HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
9250         HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
9251         HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
9252         HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
9253         HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
9254         HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
9255         HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
9256         {} /* terminator */
9257 };
9258 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
9259
9260 MODULE_LICENSE("GPL");
9261 MODULE_DESCRIPTION("Realtek HD-audio codec");
9262
9263 static struct hda_codec_driver realtek_driver = {
9264         .id = snd_hda_id_realtek,
9265 };
9266
9267 module_hda_codec_driver(realtek_driver);