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