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