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