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