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