~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/pci/hda/patch_realtek.c

Version: ~ [ linux-5.0-rc6 ] ~ [ linux-4.20.10 ] ~ [ linux-4.19.23 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.101 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.158 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.174 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.134 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.63 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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