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