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