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