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