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