OSDN Git Service

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