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