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