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