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