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