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