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