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