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