]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - sound/pci/hda/patch_realtek.c
xfs: Fix tail rounding in xfs_alloc_file_space()
[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),
d2c3b14e 2444 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
63691587 2445 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
d2c3b14e 2446 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
5c0ebfbe 2447 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
0202f5cd 2448 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
4d10d972 2449 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
69366066 2450 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
f1d8dfbd
RS
2451 SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2452 SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2453 SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2454 SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
7a6069bf
TI
2455 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2456 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
ac9b1cdd 2457 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
68ef0561 2458 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
ff818c24
TI
2459 {}
2460};
2461
1727a771 2462static const struct hda_model_fixup alc882_fixup_models[] = {
912093bc
TI
2463 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2464 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2465 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
6e72aa5f 2466 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
e427c237 2467 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
ba90d6a6 2468 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
912093bc
TI
2469 {}
2470};
2471
f6a92248 2472/*
1d045db9 2473 * BIOS auto configuration
f6a92248 2474 */
1d045db9
TI
2475/* almost identical with ALC880 parser... */
2476static int alc882_parse_auto_config(struct hda_codec *codec)
2477{
1d045db9 2478 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2479 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2480 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
1d045db9 2481}
b896b4eb 2482
1d045db9
TI
2483/*
2484 */
1d045db9 2485static int patch_alc882(struct hda_codec *codec)
f6a92248
KY
2486{
2487 struct alc_spec *spec;
1a97b7f2 2488 int err;
f6a92248 2489
3de95173
TI
2490 err = alc_alloc_spec(codec, 0x0b);
2491 if (err < 0)
2492 return err;
f6a92248 2493
3de95173 2494 spec = codec->spec;
1f0f4b80 2495
7639a06c 2496 switch (codec->core.vendor_id) {
1d045db9
TI
2497 case 0x10ec0882:
2498 case 0x10ec0885:
acf08081 2499 case 0x10ec0900:
b312cc3e 2500 case 0x10ec0b00:
a535ad57 2501 case 0x10ec1220:
1d045db9
TI
2502 break;
2503 default:
2504 /* ALC883 and variants */
2505 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2506 break;
c793bec5 2507 }
977ddd6b 2508
1727a771 2509 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
912093bc 2510 alc882_fixups);
1727a771 2511 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ff818c24 2512
1d045db9
TI
2513 alc_auto_parse_customize_define(codec);
2514
7504b6cd
TI
2515 if (has_cdefine_beep(codec))
2516 spec->gen.beep_nid = 0x01;
2517
1a97b7f2
TI
2518 /* automatic parse from the BIOS config */
2519 err = alc882_parse_auto_config(codec);
2520 if (err < 0)
2521 goto error;
f6a92248 2522
7504b6cd 2523 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2524 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f6a92248 2525
1727a771 2526 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2527
f6a92248 2528 return 0;
e16fb6d1
TI
2529
2530 error:
2531 alc_free(codec);
2532 return err;
f6a92248
KY
2533}
2534
df694daa 2535
df694daa 2536/*
1d045db9 2537 * ALC262 support
df694daa 2538 */
1d045db9 2539static int alc262_parse_auto_config(struct hda_codec *codec)
df694daa 2540{
1d045db9 2541 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2542 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2543 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
df694daa
KY
2544}
2545
df694daa 2546/*
1d045db9 2547 * Pin config fixes
df694daa 2548 */
cfc9b06f 2549enum {
ea4e7af1 2550 ALC262_FIXUP_FSC_H270,
7513e6da 2551 ALC262_FIXUP_FSC_S7110,
ea4e7af1
TI
2552 ALC262_FIXUP_HP_Z200,
2553 ALC262_FIXUP_TYAN,
c470150c 2554 ALC262_FIXUP_LENOVO_3000,
b42590b8
TI
2555 ALC262_FIXUP_BENQ,
2556 ALC262_FIXUP_BENQ_T31,
6e72aa5f 2557 ALC262_FIXUP_INV_DMIC,
b5c6611f 2558 ALC262_FIXUP_INTEL_BAYLEYBAY,
cfc9b06f
TI
2559};
2560
1727a771 2561static const struct hda_fixup alc262_fixups[] = {
ea4e7af1 2562 [ALC262_FIXUP_FSC_H270] = {
1727a771
TI
2563 .type = HDA_FIXUP_PINS,
2564 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2565 { 0x14, 0x99130110 }, /* speaker */
2566 { 0x15, 0x0221142f }, /* front HP */
2567 { 0x1b, 0x0121141f }, /* rear HP */
2568 { }
2569 }
2570 },
7513e6da
TI
2571 [ALC262_FIXUP_FSC_S7110] = {
2572 .type = HDA_FIXUP_PINS,
2573 .v.pins = (const struct hda_pintbl[]) {
2574 { 0x15, 0x90170110 }, /* speaker */
2575 { }
2576 },
2577 .chained = true,
2578 .chain_id = ALC262_FIXUP_BENQ,
2579 },
ea4e7af1 2580 [ALC262_FIXUP_HP_Z200] = {
1727a771
TI
2581 .type = HDA_FIXUP_PINS,
2582 .v.pins = (const struct hda_pintbl[]) {
1d045db9 2583 { 0x16, 0x99130120 }, /* internal speaker */
73413b12
TI
2584 { }
2585 }
cfc9b06f 2586 },
ea4e7af1 2587 [ALC262_FIXUP_TYAN] = {
1727a771
TI
2588 .type = HDA_FIXUP_PINS,
2589 .v.pins = (const struct hda_pintbl[]) {
ea4e7af1
TI
2590 { 0x14, 0x1993e1f0 }, /* int AUX */
2591 { }
2592 }
2593 },
c470150c 2594 [ALC262_FIXUP_LENOVO_3000] = {
fd108215
TI
2595 .type = HDA_FIXUP_PINCTLS,
2596 .v.pins = (const struct hda_pintbl[]) {
2597 { 0x19, PIN_VREF50 },
b42590b8
TI
2598 {}
2599 },
2600 .chained = true,
2601 .chain_id = ALC262_FIXUP_BENQ,
2602 },
2603 [ALC262_FIXUP_BENQ] = {
1727a771 2604 .type = HDA_FIXUP_VERBS,
b42590b8 2605 .v.verbs = (const struct hda_verb[]) {
c470150c
TI
2606 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2607 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2608 {}
2609 }
2610 },
b42590b8 2611 [ALC262_FIXUP_BENQ_T31] = {
1727a771 2612 .type = HDA_FIXUP_VERBS,
b42590b8
TI
2613 .v.verbs = (const struct hda_verb[]) {
2614 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2615 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2616 {}
2617 }
2618 },
6e72aa5f 2619 [ALC262_FIXUP_INV_DMIC] = {
1727a771 2620 .type = HDA_FIXUP_FUNC,
9d36a7dc 2621 .v.func = alc_fixup_inv_dmic,
6e72aa5f 2622 },
b5c6611f
ML
2623 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2624 .type = HDA_FIXUP_FUNC,
2625 .v.func = alc_fixup_no_depop_delay,
2626 },
cfc9b06f
TI
2627};
2628
1d045db9 2629static const struct snd_pci_quirk alc262_fixup_tbl[] = {
ea4e7af1 2630 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
7513e6da 2631 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
3dcd3be3 2632 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
ea4e7af1 2633 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
4bf1bd42 2634 SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
ea4e7af1 2635 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
c470150c 2636 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
b42590b8
TI
2637 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2638 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
b5c6611f 2639 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
cfc9b06f
TI
2640 {}
2641};
df694daa 2642
1727a771 2643static const struct hda_model_fixup alc262_fixup_models[] = {
6e72aa5f
TI
2644 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2645 {}
2646};
1d045db9 2647
1d045db9
TI
2648/*
2649 */
1d045db9 2650static int patch_alc262(struct hda_codec *codec)
df694daa
KY
2651{
2652 struct alc_spec *spec;
df694daa
KY
2653 int err;
2654
3de95173
TI
2655 err = alc_alloc_spec(codec, 0x0b);
2656 if (err < 0)
2657 return err;
df694daa 2658
3de95173 2659 spec = codec->spec;
08c189f2 2660 spec->gen.shared_mic_vref_pin = 0x18;
1d045db9 2661
225068ab
TI
2662 spec->shutup = alc_eapd_shutup;
2663
1d045db9
TI
2664#if 0
2665 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2666 * under-run
2667 */
98b24883 2668 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
1d045db9 2669#endif
1d045db9
TI
2670 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2671
1727a771 2672 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
6e72aa5f 2673 alc262_fixups);
1727a771 2674 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9c7f852e 2675
af741c15
TI
2676 alc_auto_parse_customize_define(codec);
2677
7504b6cd
TI
2678 if (has_cdefine_beep(codec))
2679 spec->gen.beep_nid = 0x01;
2680
42399f7a
TI
2681 /* automatic parse from the BIOS config */
2682 err = alc262_parse_auto_config(codec);
2683 if (err < 0)
2684 goto error;
df694daa 2685
7504b6cd 2686 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2687 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2134ea4f 2688
1727a771 2689 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2690
1da177e4 2691 return 0;
e16fb6d1
TI
2692
2693 error:
2694 alc_free(codec);
2695 return err;
1da177e4
LT
2696}
2697
f32610ed 2698/*
1d045db9 2699 * ALC268
f32610ed 2700 */
1d045db9 2701/* bind Beep switches of both NID 0x0f and 0x10 */
a717777d
TI
2702static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2703 struct snd_ctl_elem_value *ucontrol)
2704{
2705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2706 unsigned long pval;
2707 int err;
2708
2709 mutex_lock(&codec->control_mutex);
2710 pval = kcontrol->private_value;
2711 kcontrol->private_value = (pval & ~0xff) | 0x0f;
2712 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2713 if (err >= 0) {
2714 kcontrol->private_value = (pval & ~0xff) | 0x10;
2715 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2716 }
2717 kcontrol->private_value = pval;
2718 mutex_unlock(&codec->control_mutex);
2719 return err;
2720}
f32610ed 2721
1d045db9
TI
2722static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2723 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
a717777d
TI
2724 {
2725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2726 .name = "Beep Playback Switch",
2727 .subdevice = HDA_SUBDEV_AMP_FLAG,
2728 .info = snd_hda_mixer_amp_switch_info,
2729 .get = snd_hda_mixer_amp_switch_get,
2730 .put = alc268_beep_switch_put,
2731 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2732 },
1d045db9 2733 { }
f32610ed
JS
2734};
2735
1d045db9
TI
2736/* set PCBEEP vol = 0, mute connections */
2737static const struct hda_verb alc268_beep_init_verbs[] = {
2738 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2739 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2740 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2741 { }
f32610ed
JS
2742};
2743
6e72aa5f
TI
2744enum {
2745 ALC268_FIXUP_INV_DMIC,
cb766404 2746 ALC268_FIXUP_HP_EAPD,
24eff328 2747 ALC268_FIXUP_SPDIF,
6e72aa5f
TI
2748};
2749
1727a771 2750static const struct hda_fixup alc268_fixups[] = {
6e72aa5f 2751 [ALC268_FIXUP_INV_DMIC] = {
1727a771 2752 .type = HDA_FIXUP_FUNC,
9d36a7dc 2753 .v.func = alc_fixup_inv_dmic,
6e72aa5f 2754 },
cb766404 2755 [ALC268_FIXUP_HP_EAPD] = {
1727a771 2756 .type = HDA_FIXUP_VERBS,
cb766404
TI
2757 .v.verbs = (const struct hda_verb[]) {
2758 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2759 {}
2760 }
2761 },
24eff328
TI
2762 [ALC268_FIXUP_SPDIF] = {
2763 .type = HDA_FIXUP_PINS,
2764 .v.pins = (const struct hda_pintbl[]) {
2765 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2766 {}
2767 }
2768 },
6e72aa5f
TI
2769};
2770
1727a771 2771static const struct hda_model_fixup alc268_fixup_models[] = {
6e72aa5f 2772 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
cb766404
TI
2773 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2774 {}
2775};
2776
2777static const struct snd_pci_quirk alc268_fixup_tbl[] = {
24eff328 2778 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
fcd8f3b1 2779 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
cb766404
TI
2780 /* below is codec SSID since multiple Toshiba laptops have the
2781 * same PCI SSID 1179:ff00
2782 */
2783 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
6e72aa5f
TI
2784 {}
2785};
2786
f32610ed
JS
2787/*
2788 * BIOS auto configuration
2789 */
1d045db9 2790static int alc268_parse_auto_config(struct hda_codec *codec)
f32610ed 2791{
3e6179b8 2792 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7504b6cd 2793 return alc_parse_auto_config(codec, NULL, alc268_ssids);
f32610ed
JS
2794}
2795
1d045db9
TI
2796/*
2797 */
1d045db9 2798static int patch_alc268(struct hda_codec *codec)
f32610ed
JS
2799{
2800 struct alc_spec *spec;
7504b6cd 2801 int err;
f32610ed 2802
1d045db9 2803 /* ALC268 has no aa-loopback mixer */
3de95173
TI
2804 err = alc_alloc_spec(codec, 0);
2805 if (err < 0)
2806 return err;
2807
2808 spec = codec->spec;
7504b6cd 2809 spec->gen.beep_nid = 0x01;
1f0f4b80 2810
225068ab
TI
2811 spec->shutup = alc_eapd_shutup;
2812
1727a771
TI
2813 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2814 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6e72aa5f 2815
6ebb8053
TI
2816 /* automatic parse from the BIOS config */
2817 err = alc268_parse_auto_config(codec);
e16fb6d1
TI
2818 if (err < 0)
2819 goto error;
f32610ed 2820
7504b6cd
TI
2821 if (err > 0 && !spec->gen.no_analog &&
2822 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2823 add_mixer(spec, alc268_beep_mixer);
2824 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
1d045db9
TI
2825 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2826 /* override the amp caps for beep generator */
2827 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2828 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2829 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2830 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2831 (0 << AC_AMPCAP_MUTE_SHIFT));
2f893286
KY
2832 }
2833
1727a771 2834 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6e72aa5f 2835
f32610ed 2836 return 0;
e16fb6d1
TI
2837
2838 error:
2839 alc_free(codec);
2840 return err;
f32610ed
JS
2841}
2842
bc9f98a9 2843/*
1d045db9 2844 * ALC269
bc9f98a9 2845 */
08c189f2 2846
1d045db9 2847static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
1d045db9 2848 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
bc9f98a9
KY
2849};
2850
1d045db9 2851static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
1d045db9 2852 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
bc9f98a9 2853};
291702f0 2854
1d045db9
TI
2855/* different alc269-variants */
2856enum {
2857 ALC269_TYPE_ALC269VA,
2858 ALC269_TYPE_ALC269VB,
2859 ALC269_TYPE_ALC269VC,
adcc70b2 2860 ALC269_TYPE_ALC269VD,
065380f0
KY
2861 ALC269_TYPE_ALC280,
2862 ALC269_TYPE_ALC282,
2af02be7 2863 ALC269_TYPE_ALC283,
065380f0 2864 ALC269_TYPE_ALC284,
4731d5de 2865 ALC269_TYPE_ALC293,
7fc7d047 2866 ALC269_TYPE_ALC286,
506b62c3 2867 ALC269_TYPE_ALC298,
1d04c9de 2868 ALC269_TYPE_ALC255,
4344aec8 2869 ALC269_TYPE_ALC256,
f429e7e4 2870 ALC269_TYPE_ALC257,
0a6f0600 2871 ALC269_TYPE_ALC215,
4231430d 2872 ALC269_TYPE_ALC225,
dcd4f0db 2873 ALC269_TYPE_ALC294,
9887cf53 2874 ALC269_TYPE_ALC300,
8666616e 2875 ALC269_TYPE_ALC623,
6fbae35a 2876 ALC269_TYPE_ALC700,
bc9f98a9
KY
2877};
2878
2879/*
1d045db9 2880 * BIOS auto configuration
bc9f98a9 2881 */
1d045db9
TI
2882static int alc269_parse_auto_config(struct hda_codec *codec)
2883{
1d045db9 2884 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2885 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2886 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2887 struct alc_spec *spec = codec->spec;
adcc70b2
KY
2888 const hda_nid_t *ssids;
2889
2890 switch (spec->codec_variant) {
2891 case ALC269_TYPE_ALC269VA:
2892 case ALC269_TYPE_ALC269VC:
065380f0
KY
2893 case ALC269_TYPE_ALC280:
2894 case ALC269_TYPE_ALC284:
4731d5de 2895 case ALC269_TYPE_ALC293:
adcc70b2
KY
2896 ssids = alc269va_ssids;
2897 break;
2898 case ALC269_TYPE_ALC269VB:
2899 case ALC269_TYPE_ALC269VD:
065380f0 2900 case ALC269_TYPE_ALC282:
2af02be7 2901 case ALC269_TYPE_ALC283:
7fc7d047 2902 case ALC269_TYPE_ALC286:
506b62c3 2903 case ALC269_TYPE_ALC298:
1d04c9de 2904 case ALC269_TYPE_ALC255:
4344aec8 2905 case ALC269_TYPE_ALC256:
f429e7e4 2906 case ALC269_TYPE_ALC257:
0a6f0600 2907 case ALC269_TYPE_ALC215:
4231430d 2908 case ALC269_TYPE_ALC225:
dcd4f0db 2909 case ALC269_TYPE_ALC294:
9887cf53 2910 case ALC269_TYPE_ALC300:
8666616e 2911 case ALC269_TYPE_ALC623:
6fbae35a 2912 case ALC269_TYPE_ALC700:
adcc70b2
KY
2913 ssids = alc269_ssids;
2914 break;
2915 default:
2916 ssids = alc269_ssids;
2917 break;
2918 }
bc9f98a9 2919
3e6179b8 2920 return alc_parse_auto_config(codec, alc269_ignore, ssids);
1d045db9 2921}
bc9f98a9 2922
1387e2d1 2923static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
1d045db9 2924{
98b24883 2925 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
1d045db9 2926}
291702f0 2927
1d045db9
TI
2928static void alc269_shutup(struct hda_codec *codec)
2929{
adcc70b2
KY
2930 struct alc_spec *spec = codec->spec;
2931
1387e2d1
KY
2932 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2933 alc269vb_toggle_power_output(codec, 0);
2934 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2935 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
2936 msleep(150);
2937 }
b001f661 2938 alc_shutup_pins(codec);
1d045db9 2939}
291702f0 2940
54db6c39
TI
2941static struct coef_fw alc282_coefs[] = {
2942 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
32fa7e49 2943 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
54db6c39
TI
2944 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2945 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2946 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2947 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2948 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2949 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2950 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2951 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2952 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2953 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2954 WRITE_COEF(0x34, 0xa0c0), /* ANC */
2955 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2956 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2957 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2958 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2959 WRITE_COEF(0x63, 0x2902), /* PLL */
2960 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2961 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2962 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2963 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2964 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2965 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2966 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2967 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2968 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2969 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2970 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2971 {}
2972};
2973
cb149cb3
KY
2974static void alc282_restore_default_value(struct hda_codec *codec)
2975{
54db6c39 2976 alc_process_coef_fw(codec, alc282_coefs);
cb149cb3
KY
2977}
2978
7b5c7a02
KY
2979static void alc282_init(struct hda_codec *codec)
2980{
2981 struct alc_spec *spec = codec->spec;
80f10932 2982 hda_nid_t hp_pin = alc_get_hp_pin(spec);
7b5c7a02
KY
2983 bool hp_pin_sense;
2984 int coef78;
2985
435e2bb2
KY
2986 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
2987 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
2988 hp_pin = spec->gen.autocfg.line_out_pins[0];
2989 }
2990
cb149cb3
KY
2991 alc282_restore_default_value(codec);
2992
7b5c7a02
KY
2993 if (!hp_pin)
2994 return;
2995 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2996 coef78 = alc_read_coef_idx(codec, 0x78);
2997
2998 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2999 /* Headphone capless set to high power mode */
3000 alc_write_coef_idx(codec, 0x78, 0x9004);
3001
3002 if (hp_pin_sense)
3003 msleep(2);
3004
3005 snd_hda_codec_write(codec, hp_pin, 0,
3006 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3007
3008 if (hp_pin_sense)
3009 msleep(85);
3010
3011 snd_hda_codec_write(codec, hp_pin, 0,
3012 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3013
3014 if (hp_pin_sense)
3015 msleep(100);
3016
3017 /* Headphone capless set to normal mode */
3018 alc_write_coef_idx(codec, 0x78, coef78);
3019}
3020
3021static void alc282_shutup(struct hda_codec *codec)
3022{
3023 struct alc_spec *spec = codec->spec;
80f10932 3024 hda_nid_t hp_pin = alc_get_hp_pin(spec);
7b5c7a02
KY
3025 bool hp_pin_sense;
3026 int coef78;
3027
435e2bb2
KY
3028 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3029 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3030 hp_pin = spec->gen.autocfg.line_out_pins[0];
3031 }
3032
7b5c7a02
KY
3033 if (!hp_pin) {
3034 alc269_shutup(codec);
3035 return;
3036 }
3037
3038 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3039 coef78 = alc_read_coef_idx(codec, 0x78);
3040 alc_write_coef_idx(codec, 0x78, 0x9004);
3041
3042 if (hp_pin_sense)
3043 msleep(2);
3044
3045 snd_hda_codec_write(codec, hp_pin, 0,
3046 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3047
3048 if (hp_pin_sense)
3049 msleep(85);
3050
b001f661
TI
3051 if (!spec->no_shutup_pins)
3052 snd_hda_codec_write(codec, hp_pin, 0,
3053 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
7b5c7a02
KY
3054
3055 if (hp_pin_sense)
3056 msleep(100);
3057
3058 alc_auto_setup_eapd(codec, false);
b001f661 3059 alc_shutup_pins(codec);
7b5c7a02
KY
3060 alc_write_coef_idx(codec, 0x78, coef78);
3061}
3062
54db6c39
TI
3063static struct coef_fw alc283_coefs[] = {
3064 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
56779864 3065 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
54db6c39
TI
3066 WRITE_COEF(0x07, 0x0200), /* DMIC control */
3067 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3068 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3069 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3070 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3071 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3072 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3073 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3074 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3075 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3076 WRITE_COEF(0x22, 0xa0c0), /* ANC */
3077 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3078 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3079 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3080 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3081 WRITE_COEF(0x2e, 0x2902), /* PLL */
3082 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3083 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3084 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3085 WRITE_COEF(0x36, 0x0), /* capless control 5 */
3086 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3087 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3088 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3089 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3090 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3091 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3092 WRITE_COEF(0x49, 0x0), /* test mode */
3093 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3094 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3095 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
56779864 3096 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
54db6c39
TI
3097 {}
3098};
3099
6bd55b04
KY
3100static void alc283_restore_default_value(struct hda_codec *codec)
3101{
54db6c39 3102 alc_process_coef_fw(codec, alc283_coefs);
6bd55b04
KY
3103}
3104
2af02be7
KY
3105static void alc283_init(struct hda_codec *codec)
3106{
3107 struct alc_spec *spec = codec->spec;
80f10932 3108 hda_nid_t hp_pin = alc_get_hp_pin(spec);
2af02be7 3109 bool hp_pin_sense;
2af02be7 3110
6bd55b04
KY
3111 alc283_restore_default_value(codec);
3112
2af02be7
KY
3113 if (!hp_pin)
3114 return;
a59d7199
KY
3115
3116 msleep(30);
2af02be7
KY
3117 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3118
3119 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3120 /* Headphone capless set to high power mode */
3121 alc_write_coef_idx(codec, 0x43, 0x9004);
3122
3123 snd_hda_codec_write(codec, hp_pin, 0,
3124 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3125
3126 if (hp_pin_sense)
3127 msleep(85);
3128
3129 snd_hda_codec_write(codec, hp_pin, 0,
3130 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3131
3132 if (hp_pin_sense)
3133 msleep(85);
3134 /* Index 0x46 Combo jack auto switch control 2 */
3135 /* 3k pull low control for Headset jack. */
98b24883 3136 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
2af02be7
KY
3137 /* Headphone capless set to normal mode */
3138 alc_write_coef_idx(codec, 0x43, 0x9614);
3139}
3140
3141static void alc283_shutup(struct hda_codec *codec)
3142{
3143 struct alc_spec *spec = codec->spec;
80f10932 3144 hda_nid_t hp_pin = alc_get_hp_pin(spec);
2af02be7 3145 bool hp_pin_sense;
2af02be7
KY
3146
3147 if (!hp_pin) {
3148 alc269_shutup(codec);
3149 return;
3150 }
3151
3152 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3153
3154 alc_write_coef_idx(codec, 0x43, 0x9004);
3155
b450b17c
HP
3156 /*depop hp during suspend*/
3157 alc_write_coef_idx(codec, 0x06, 0x2100);
3158
2af02be7
KY
3159 snd_hda_codec_write(codec, hp_pin, 0,
3160 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3161
3162 if (hp_pin_sense)
88011c09 3163 msleep(100);
2af02be7 3164
b001f661
TI
3165 if (!spec->no_shutup_pins)
3166 snd_hda_codec_write(codec, hp_pin, 0,
3167 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2af02be7 3168
98b24883 3169 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
2af02be7
KY
3170
3171 if (hp_pin_sense)
88011c09 3172 msleep(100);
0435b3ff 3173 alc_auto_setup_eapd(codec, false);
b001f661 3174 alc_shutup_pins(codec);
2af02be7
KY
3175 alc_write_coef_idx(codec, 0x43, 0x9614);
3176}
3177
4a219ef8
KY
3178static void alc256_init(struct hda_codec *codec)
3179{
3180 struct alc_spec *spec = codec->spec;
80f10932 3181 hda_nid_t hp_pin = alc_get_hp_pin(spec);
4a219ef8
KY
3182 bool hp_pin_sense;
3183
435e2bb2
KY
3184 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3185 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3186 hp_pin = spec->gen.autocfg.line_out_pins[0];
3187 }
3188
4a219ef8
KY
3189 if (!hp_pin)
3190 return;
3191
3192 msleep(30);
3193
3194 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3195
3196 if (hp_pin_sense)
3197 msleep(2);
3198
3199 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3200
3201 snd_hda_codec_write(codec, hp_pin, 0,
3202 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3203
3204 if (hp_pin_sense)
3205 msleep(85);
3206
3207 snd_hda_codec_write(codec, hp_pin, 0,
3208 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3209
3210 if (hp_pin_sense)
3211 msleep(100);
3212
3213 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3214 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
fc434f5a
KY
3215 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3216 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
a03bb0ae 3217 alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
4a219ef8
KY
3218}
3219
3220static void alc256_shutup(struct hda_codec *codec)
3221{
3222 struct alc_spec *spec = codec->spec;
80f10932 3223 hda_nid_t hp_pin = alc_get_hp_pin(spec);
4a219ef8
KY
3224 bool hp_pin_sense;
3225
435e2bb2
KY
3226 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3227 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3228 hp_pin = spec->gen.autocfg.line_out_pins[0];
3229 }
3230
4a219ef8
KY
3231 if (!hp_pin) {
3232 alc269_shutup(codec);
3233 return;
3234 }
3235
3236 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3237
3238 if (hp_pin_sense)
3239 msleep(2);
3240
3241 snd_hda_codec_write(codec, hp_pin, 0,
3242 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3243
3244 if (hp_pin_sense)
3245 msleep(85);
3246
e9d7786a
TI
3247 /* 3k pull low control for Headset jack. */
3248 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3249 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3250
b001f661
TI
3251 if (!spec->no_shutup_pins)
3252 snd_hda_codec_write(codec, hp_pin, 0,
3253 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4a219ef8 3254
4a219ef8
KY
3255 if (hp_pin_sense)
3256 msleep(100);
3257
3258 alc_auto_setup_eapd(codec, false);
b001f661 3259 alc_shutup_pins(codec);
4a219ef8
KY
3260}
3261
0b4d8f55
KY
3262static void alc225_init(struct hda_codec *codec)
3263{
3264 struct alc_spec *spec = codec->spec;
80f10932 3265 hda_nid_t hp_pin = alc_get_hp_pin(spec);
0b4d8f55
KY
3266 bool hp1_pin_sense, hp2_pin_sense;
3267
435e2bb2
KY
3268 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3269 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3270 hp_pin = spec->gen.autocfg.line_out_pins[0];
3271 }
3272
0b4d8f55
KY
3273 if (!hp_pin)
3274 return;
3275
3276 msleep(30);
3277
3278 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3279 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3280
3281 if (hp1_pin_sense || hp2_pin_sense)
3282 msleep(2);
3283
3284 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3285
3286 if (hp1_pin_sense)
3287 snd_hda_codec_write(codec, hp_pin, 0,
3288 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3289 if (hp2_pin_sense)
3290 snd_hda_codec_write(codec, 0x16, 0,
3291 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3292
3293 if (hp1_pin_sense || hp2_pin_sense)
3294 msleep(85);
3295
3296 if (hp1_pin_sense)
3297 snd_hda_codec_write(codec, hp_pin, 0,
3298 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3299 if (hp2_pin_sense)
3300 snd_hda_codec_write(codec, 0x16, 0,
3301 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3302
3303 if (hp1_pin_sense || hp2_pin_sense)
3304 msleep(100);
3305
3306 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3307 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3308}
3309
3310static void alc225_shutup(struct hda_codec *codec)
3311{
3312 struct alc_spec *spec = codec->spec;
80f10932 3313 hda_nid_t hp_pin = alc_get_hp_pin(spec);
0b4d8f55
KY
3314 bool hp1_pin_sense, hp2_pin_sense;
3315
435e2bb2
KY
3316 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3317 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3318 hp_pin = spec->gen.autocfg.line_out_pins[0];
3319 }
3320
0b4d8f55
KY
3321 if (!hp_pin) {
3322 alc269_shutup(codec);
3323 return;
3324 }
3325
3326 /* 3k pull low control for Headset jack. */
3327 alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3328
3329 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3330 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3331
3332 if (hp1_pin_sense || hp2_pin_sense)
3333 msleep(2);
3334
3335 if (hp1_pin_sense)
3336 snd_hda_codec_write(codec, hp_pin, 0,
3337 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3338 if (hp2_pin_sense)
3339 snd_hda_codec_write(codec, 0x16, 0,
3340 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3341
3342 if (hp1_pin_sense || hp2_pin_sense)
3343 msleep(85);
3344
3345 if (hp1_pin_sense)
3346 snd_hda_codec_write(codec, hp_pin, 0,
3347 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3348 if (hp2_pin_sense)
3349 snd_hda_codec_write(codec, 0x16, 0,
3350 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3351
3352 if (hp1_pin_sense || hp2_pin_sense)
3353 msleep(100);
3354
3355 alc_auto_setup_eapd(codec, false);
b001f661 3356 alc_shutup_pins(codec);
0b4d8f55
KY
3357}
3358
c2d6af53
KY
3359static void alc_default_init(struct hda_codec *codec)
3360{
3361 struct alc_spec *spec = codec->spec;
80f10932 3362 hda_nid_t hp_pin = alc_get_hp_pin(spec);
c2d6af53
KY
3363 bool hp_pin_sense;
3364
435e2bb2
KY
3365 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3366 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3367 hp_pin = spec->gen.autocfg.line_out_pins[0];
3368 }
3369
c2d6af53
KY
3370 if (!hp_pin)
3371 return;
3372
3373 msleep(30);
3374
3375 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3376
3377 if (hp_pin_sense)
3378 msleep(2);
3379
3380 snd_hda_codec_write(codec, hp_pin, 0,
3381 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3382
3383 if (hp_pin_sense)
3384 msleep(85);
3385
3386 snd_hda_codec_write(codec, hp_pin, 0,
3387 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3388
3389 if (hp_pin_sense)
3390 msleep(100);
3391}
3392
3393static void alc_default_shutup(struct hda_codec *codec)
3394{
3395 struct alc_spec *spec = codec->spec;
80f10932 3396 hda_nid_t hp_pin = alc_get_hp_pin(spec);
c2d6af53
KY
3397 bool hp_pin_sense;
3398
435e2bb2
KY
3399 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3400 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3401 hp_pin = spec->gen.autocfg.line_out_pins[0];
3402 }
3403
c2d6af53
KY
3404 if (!hp_pin) {
3405 alc269_shutup(codec);
3406 return;
3407 }
3408
3409 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3410
3411 if (hp_pin_sense)
3412 msleep(2);
3413
3414 snd_hda_codec_write(codec, hp_pin, 0,
3415 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3416
3417 if (hp_pin_sense)
3418 msleep(85);
3419
b001f661
TI
3420 if (!spec->no_shutup_pins)
3421 snd_hda_codec_write(codec, hp_pin, 0,
3422 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
c2d6af53
KY
3423
3424 if (hp_pin_sense)
3425 msleep(100);
3426
3427 alc_auto_setup_eapd(codec, false);
b001f661 3428 alc_shutup_pins(codec);
c2d6af53
KY
3429}
3430
6e25f0c7
KY
3431static void alc294_hp_init(struct hda_codec *codec)
3432{
3433 struct alc_spec *spec = codec->spec;
80f10932 3434 hda_nid_t hp_pin = alc_get_hp_pin(spec);
6e25f0c7
KY
3435 int i, val;
3436
435e2bb2
KY
3437 if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
3438 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3439 hp_pin = spec->gen.autocfg.line_out_pins[0];
3440 }
3441
6e25f0c7
KY
3442 if (!hp_pin)
3443 return;
3444
3445 snd_hda_codec_write(codec, hp_pin, 0,
3446 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3447
3448 msleep(100);
3449
3450 snd_hda_codec_write(codec, hp_pin, 0,
3451 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3452
3453 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3454 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3455
3456 /* Wait for depop procedure finish */
3457 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3458 for (i = 0; i < 20 && val & 0x0080; i++) {
3459 msleep(50);
3460 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3461 }
3462 /* Set HP depop to auto mode */
3463 alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3464 msleep(50);
3465}
3466
3467static void alc294_init(struct hda_codec *codec)
3468{
3469 struct alc_spec *spec = codec->spec;
3470
e6649bbc
TI
3471 /* required only at boot or S4 resume time */
3472 if (!spec->done_hp_init ||
3473 codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
6e25f0c7
KY
3474 alc294_hp_init(codec);
3475 spec->done_hp_init = true;
3476 }
3477 alc_default_init(codec);
3478}
3479
ad60d502
KY
3480static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3481 unsigned int val)
3482{
3483 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3484 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3485 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3486}
3487
3488static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3489{
3490 unsigned int val;
3491
3492 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3493 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3494 & 0xffff;
3495 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3496 << 16;
3497 return val;
3498}
3499
3500static void alc5505_dsp_halt(struct hda_codec *codec)
3501{
3502 unsigned int val;
3503
3504 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3505 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3506 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3507 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3508 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3509 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3510 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3511 val = alc5505_coef_get(codec, 0x6220);
3512 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3513}
3514
3515static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3516{
3517 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3518 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3519 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3520 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3521 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3522 alc5505_coef_set(codec, 0x880c, 0x00000004);
3523}
3524
3525static void alc5505_dsp_init(struct hda_codec *codec)
3526{
3527 unsigned int val;
3528
3529 alc5505_dsp_halt(codec);
3530 alc5505_dsp_back_from_halt(codec);
3531 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3532 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3533 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3534 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3535 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3536 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3537 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3538 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3539 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3540 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3541 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3542 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3543 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3544
3545 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3546 if (val <= 3)
3547 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3548 else
3549 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3550
3551 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3552 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3553 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3554 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3555 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3556 alc5505_coef_set(codec, 0x880c, 0x00000003);
3557 alc5505_coef_set(codec, 0x880c, 0x00000010);
cd63a5ff
TI
3558
3559#ifdef HALT_REALTEK_ALC5505
3560 alc5505_dsp_halt(codec);
3561#endif
ad60d502
KY
3562}
3563
cd63a5ff
TI
3564#ifdef HALT_REALTEK_ALC5505
3565#define alc5505_dsp_suspend(codec) /* NOP */
3566#define alc5505_dsp_resume(codec) /* NOP */
3567#else
3568#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3569#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3570#endif
3571
2a43952a 3572#ifdef CONFIG_PM
ad60d502
KY
3573static int alc269_suspend(struct hda_codec *codec)
3574{
3575 struct alc_spec *spec = codec->spec;
3576
3577 if (spec->has_alc5505_dsp)
cd63a5ff 3578 alc5505_dsp_suspend(codec);
ad60d502
KY
3579 return alc_suspend(codec);
3580}
3581
1d045db9
TI
3582static int alc269_resume(struct hda_codec *codec)
3583{
adcc70b2
KY
3584 struct alc_spec *spec = codec->spec;
3585
1387e2d1
KY
3586 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3587 alc269vb_toggle_power_output(codec, 0);
3588 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3589 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
3590 msleep(150);
3591 }
8c427226 3592
1d045db9 3593 codec->patch_ops.init(codec);
f1d4e28b 3594
1387e2d1
KY
3595 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3596 alc269vb_toggle_power_output(codec, 1);
3597 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3598 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
3599 msleep(200);
3600 }
f1d4e28b 3601
eeecd9d1 3602 regcache_sync(codec->core.regmap);
1d045db9 3603 hda_call_check_power_status(codec, 0x01);
f475371a
HW
3604
3605 /* on some machine, the BIOS will clear the codec gpio data when enter
3606 * suspend, and won't restore the data after resume, so we restore it
3607 * in the driver.
3608 */
3609 if (spec->gpio_led)
7639a06c 3610 snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DATA,
f475371a
HW
3611 spec->gpio_led);
3612
ad60d502 3613 if (spec->has_alc5505_dsp)
cd63a5ff 3614 alc5505_dsp_resume(codec);
c5177c86 3615
1d045db9
TI
3616 return 0;
3617}
2a43952a 3618#endif /* CONFIG_PM */
f1d4e28b 3619
108cc108 3620static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
1727a771 3621 const struct hda_fixup *fix, int action)
108cc108
DH
3622{
3623 struct alc_spec *spec = codec->spec;
3624
1727a771 3625 if (action == HDA_FIXUP_ACT_PRE_PROBE)
108cc108
DH
3626 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3627}
3628
0dcd451c
JMG
3629static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3630 const struct hda_fixup *fix,
3631 int action)
3632{
3633 unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3634 unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3635
3636 if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3637 snd_hda_codec_set_pincfg(codec, 0x19,
3638 (cfg_headphone & ~AC_DEFCFG_DEVICE) |
3639 (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3640}
3641
1d045db9 3642static void alc269_fixup_hweq(struct hda_codec *codec,
1727a771 3643 const struct hda_fixup *fix, int action)
1d045db9 3644{
98b24883
TI
3645 if (action == HDA_FIXUP_ACT_INIT)
3646 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
1d045db9 3647}
f1d4e28b 3648
7c478f03
DH
3649static void alc269_fixup_headset_mic(struct hda_codec *codec,
3650 const struct hda_fixup *fix, int action)
3651{
3652 struct alc_spec *spec = codec->spec;
3653
3654 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3655 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3656}
3657
1d045db9 3658static void alc271_fixup_dmic(struct hda_codec *codec,
1727a771 3659 const struct hda_fixup *fix, int action)
1d045db9
TI
3660{
3661 static const struct hda_verb verbs[] = {
3662 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3663 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3664 {}
3665 };
3666 unsigned int cfg;
f1d4e28b 3667
7639a06c
TI
3668 if (strcmp(codec->core.chip_name, "ALC271X") &&
3669 strcmp(codec->core.chip_name, "ALC269VB"))
1d045db9
TI
3670 return;
3671 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3672 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3673 snd_hda_sequence_write(codec, verbs);
3674}
f1d4e28b 3675
017f2a10 3676static void alc269_fixup_pcm_44k(struct hda_codec *codec,
1727a771 3677 const struct hda_fixup *fix, int action)
017f2a10
TI
3678{
3679 struct alc_spec *spec = codec->spec;
3680
1727a771 3681 if (action != HDA_FIXUP_ACT_PROBE)
017f2a10
TI
3682 return;
3683
3684 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3685 * fix the sample rate of analog I/O to 44.1kHz
3686 */
08c189f2
TI
3687 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3688 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
017f2a10
TI
3689}
3690
adabb3ec 3691static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
1727a771 3692 const struct hda_fixup *fix, int action)
adabb3ec 3693{
adabb3ec
TI
3694 /* The digital-mic unit sends PDM (differential signal) instead of
3695 * the standard PCM, thus you can't record a valid mono stream as is.
3696 * Below is a workaround specific to ALC269 to control the dmic
3697 * signal source as mono.
3698 */
98b24883
TI
3699 if (action == HDA_FIXUP_ACT_INIT)
3700 alc_update_coef_idx(codec, 0x07, 0, 0x80);
adabb3ec
TI
3701}
3702
24519911
TI
3703static void alc269_quanta_automute(struct hda_codec *codec)
3704{
08c189f2 3705 snd_hda_gen_update_outputs(codec);
24519911 3706
1687ccc8
TI
3707 alc_write_coef_idx(codec, 0x0c, 0x680);
3708 alc_write_coef_idx(codec, 0x0c, 0x480);
24519911
TI
3709}
3710
3711static void alc269_fixup_quanta_mute(struct hda_codec *codec,
1727a771 3712 const struct hda_fixup *fix, int action)
24519911
TI
3713{
3714 struct alc_spec *spec = codec->spec;
1727a771 3715 if (action != HDA_FIXUP_ACT_PROBE)
24519911 3716 return;
08c189f2 3717 spec->gen.automute_hook = alc269_quanta_automute;
24519911
TI
3718}
3719
d240d1dc 3720static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
1a4f69d5 3721 struct hda_jack_callback *jack)
d240d1dc
DH
3722{
3723 struct alc_spec *spec = codec->spec;
3724 int vref;
3725 msleep(200);
3726 snd_hda_gen_hp_automute(codec, jack);
3727
3728 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3729 msleep(100);
3730 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3731 vref);
3732 msleep(500);
3733 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3734 vref);
3735}
3736
3737static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3738 const struct hda_fixup *fix, int action)
3739{
3740 struct alc_spec *spec = codec->spec;
3741 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3742 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3743 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3744 }
3745}
3746
3747
08fb0d0e
TI
3748/* update mute-LED according to the speaker mute state via mic VREF pin */
3749static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
6d3cd5d4
DH
3750{
3751 struct hda_codec *codec = private_data;
08fb0d0e
TI
3752 struct alc_spec *spec = codec->spec;
3753 unsigned int pinval;
3754
3755 if (spec->mute_led_polarity)
3756 enabled = !enabled;
415d555e
TI
3757 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3758 pinval &= ~AC_PINCTL_VREFEN;
3759 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
52401e2a
TI
3760 if (spec->mute_led_nid) {
3761 /* temporarily power up/down for setting VREF */
3762 snd_hda_power_up_pm(codec);
08fb0d0e 3763 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
52401e2a
TI
3764 snd_hda_power_down_pm(codec);
3765 }
6d3cd5d4
DH
3766}
3767
d5b6b65e
DH
3768/* Make sure the led works even in runtime suspend */
3769static unsigned int led_power_filter(struct hda_codec *codec,
3770 hda_nid_t nid,
3771 unsigned int power_state)
3772{
3773 struct alc_spec *spec = codec->spec;
3774
50dd9050
HW
3775 if (power_state != AC_PWRST_D3 || nid == 0 ||
3776 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
d5b6b65e
DH
3777 return power_state;
3778
3779 /* Set pin ctl again, it might have just been set to 0 */
3780 snd_hda_set_pin_ctl(codec, nid,
3781 snd_hda_codec_get_pin_target(codec, nid));
3782
cffd3966 3783 return snd_hda_gen_path_power_filter(codec, nid, power_state);
d5b6b65e
DH
3784}
3785
08fb0d0e
TI
3786static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3787 const struct hda_fixup *fix, int action)
6d3cd5d4
DH
3788{
3789 struct alc_spec *spec = codec->spec;
08fb0d0e
TI
3790 const struct dmi_device *dev = NULL;
3791
3792 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3793 return;
3794
3795 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3796 int pol, pin;
3797 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3798 continue;
3799 if (pin < 0x0a || pin >= 0x10)
3800 break;
3801 spec->mute_led_polarity = pol;
3802 spec->mute_led_nid = pin - 0x0a + 0x18;
3803 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3804 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3805 codec->power_filter = led_power_filter;
4e76a883
TI
3806 codec_dbg(codec,
3807 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
08fb0d0e 3808 spec->mute_led_polarity);
6d3cd5d4
DH
3809 break;
3810 }
3811}
3812
d06ac143
DH
3813static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3814 const struct hda_fixup *fix, int action)
3815{
3816 struct alc_spec *spec = codec->spec;
3817 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3818 spec->mute_led_polarity = 0;
3819 spec->mute_led_nid = 0x18;
3820 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3821 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3822 codec->power_filter = led_power_filter;
d06ac143
DH
3823 }
3824}
3825
08fb0d0e
TI
3826static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3827 const struct hda_fixup *fix, int action)
420b0feb
TI
3828{
3829 struct alc_spec *spec = codec->spec;
9bb1f06f 3830 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08fb0d0e
TI
3831 spec->mute_led_polarity = 0;
3832 spec->mute_led_nid = 0x19;
3833 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3834 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3835 codec->power_filter = led_power_filter;
420b0feb
TI
3836 }
3837}
3838
8062159a
TB
3839static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
3840 const struct hda_fixup *fix, int action)
3841{
3842 struct alc_spec *spec = codec->spec;
3843 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3844 spec->mute_led_polarity = 0;
3845 spec->mute_led_nid = 0x1b;
3846 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3847 spec->gen.vmaster_mute_enum = 1;
3848 codec->power_filter = led_power_filter;
3849 }
3850}
3851
0f32fd19
TI
3852/* update LED status via GPIO */
3853static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
3854 bool enabled)
9f5c6faf 3855{
9f5c6faf
TI
3856 struct alc_spec *spec = codec->spec;
3857 unsigned int oldval = spec->gpio_led;
3858
0f32fd19
TI
3859 if (spec->mute_led_polarity)
3860 enabled = !enabled;
3861
9f5c6faf 3862 if (enabled)
0f32fd19 3863 spec->gpio_led &= ~mask;
9f5c6faf 3864 else
0f32fd19 3865 spec->gpio_led |= mask;
9f5c6faf
TI
3866 if (spec->gpio_led != oldval)
3867 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3868 spec->gpio_led);
3869}
3870
0f32fd19
TI
3871/* turn on/off mute LED via GPIO per vmaster hook */
3872static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
9f5c6faf 3873{
0f32fd19 3874 struct hda_codec *codec = private_data;
9f5c6faf 3875 struct alc_spec *spec = codec->spec;
9f5c6faf 3876
0f32fd19
TI
3877 alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
3878}
9f5c6faf 3879
0f32fd19
TI
3880/* turn on/off mic-mute LED via GPIO per capture hook */
3881static void alc_fixup_gpio_mic_mute_hook(struct hda_codec *codec,
3882 struct snd_kcontrol *kcontrol,
3883 struct snd_ctl_elem_value *ucontrol)
3884{
3885 struct alc_spec *spec = codec->spec;
3886
3887 if (ucontrol)
3888 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
3889 ucontrol->value.integer.value[0] ||
3890 ucontrol->value.integer.value[1]);
9f5c6faf
TI
3891}
3892
3893static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3894 const struct hda_fixup *fix, int action)
3895{
3896 struct alc_spec *spec = codec->spec;
3897 static const struct hda_verb gpio_init[] = {
3898 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3899 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3900 {}
3901 };
3902
3903 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19
TI
3904 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3905 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
9f5c6faf 3906 spec->gpio_led = 0;
0f32fd19
TI
3907 spec->mute_led_polarity = 0;
3908 spec->gpio_mute_led_mask = 0x08;
3909 spec->gpio_mic_led_mask = 0x10;
9f5c6faf
TI
3910 snd_hda_add_verbs(codec, gpio_init);
3911 }
3912}
3913
eaa8e5ef
KY
3914static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
3915 const struct hda_fixup *fix, int action)
3916{
3917 struct alc_spec *spec = codec->spec;
3918 static const struct hda_verb gpio_init[] = {
3919 { 0x01, AC_VERB_SET_GPIO_MASK, 0x22 },
3920 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x22 },
3921 {}
3922 };
3923
3924 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3925 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3926 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
9f5c6faf 3927 spec->gpio_led = 0;
eaa8e5ef
KY
3928 spec->mute_led_polarity = 0;
3929 spec->gpio_mute_led_mask = 0x02;
3930 spec->gpio_mic_led_mask = 0x20;
9f5c6faf
TI
3931 snd_hda_add_verbs(codec, gpio_init);
3932 }
3933}
3934
9c5dc3bf
KY
3935/* turn on/off mic-mute LED per capture hook */
3936static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3937 struct snd_kcontrol *kcontrol,
3938 struct snd_ctl_elem_value *ucontrol)
3939{
3940 struct alc_spec *spec = codec->spec;
3941 unsigned int pinval, enable, disable;
3942
fc1fad93 3943 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
9c5dc3bf
KY
3944 pinval &= ~AC_PINCTL_VREFEN;
3945 enable = pinval | AC_PINCTL_VREF_80;
3946 disable = pinval | AC_PINCTL_VREF_HIZ;
3947
3948 if (!ucontrol)
3949 return;
3950
3951 if (ucontrol->value.integer.value[0] ||
3952 ucontrol->value.integer.value[1])
3953 pinval = disable;
3954 else
3955 pinval = enable;
3956
3957 if (spec->cap_mute_led_nid)
3958 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3959}
3960
3961static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3962 const struct hda_fixup *fix, int action)
3963{
3964 struct alc_spec *spec = codec->spec;
3965 static const struct hda_verb gpio_init[] = {
3966 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3967 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3968 {}
3969 };
3970
3971 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 3972 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
9c5dc3bf
KY
3973 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3974 spec->gpio_led = 0;
0f32fd19
TI
3975 spec->mute_led_polarity = 0;
3976 spec->gpio_mute_led_mask = 0x08;
9c5dc3bf
KY
3977 spec->cap_mute_led_nid = 0x18;
3978 snd_hda_add_verbs(codec, gpio_init);
50dd9050 3979 codec->power_filter = led_power_filter;
9c5dc3bf
KY
3980 }
3981}
3982
7a5255f1
DH
3983static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3984 const struct hda_fixup *fix, int action)
3985{
3986 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to enable headphone amp */
3987 struct alc_spec *spec = codec->spec;
3988 static const struct hda_verb gpio_init[] = {
3989 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3990 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3991 {}
3992 };
3993
3994 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 3995 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
7a5255f1
DH
3996 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3997 spec->gpio_led = 0;
0f32fd19
TI
3998 spec->mute_led_polarity = 0;
3999 spec->gpio_mute_led_mask = 0x08;
7a5255f1
DH
4000 spec->cap_mute_led_nid = 0x18;
4001 snd_hda_add_verbs(codec, gpio_init);
4002 codec->power_filter = led_power_filter;
4003 }
4004}
4005
b12263b7 4006#if IS_REACHABLE(CONFIG_INPUT)
33f4acd3
DH
4007static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4008 struct hda_jack_callback *event)
4009{
4010 struct alc_spec *spec = codec->spec;
4011
4012 /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4013 send both key on and key off event for every interrupt. */
c7b60a89 4014 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
33f4acd3 4015 input_sync(spec->kb_dev);
c7b60a89 4016 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
33f4acd3
DH
4017 input_sync(spec->kb_dev);
4018}
33f4acd3 4019
3694cb29
K
4020static int alc_register_micmute_input_device(struct hda_codec *codec)
4021{
4022 struct alc_spec *spec = codec->spec;
c7b60a89 4023 int i;
3694cb29
K
4024
4025 spec->kb_dev = input_allocate_device();
4026 if (!spec->kb_dev) {
4027 codec_err(codec, "Out of memory (input_allocate_device)\n");
4028 return -ENOMEM;
4029 }
c7b60a89
HW
4030
4031 spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4032
3694cb29
K
4033 spec->kb_dev->name = "Microphone Mute Button";
4034 spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
c7b60a89
HW
4035 spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4036 spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4037 spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4038 for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4039 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
3694cb29
K
4040
4041 if (input_register_device(spec->kb_dev)) {
4042 codec_err(codec, "input_register_device failed\n");
4043 input_free_device(spec->kb_dev);
4044 spec->kb_dev = NULL;
4045 return -ENOMEM;
4046 }
4047
4048 return 0;
4049}
4050
33f4acd3
DH
4051static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4052 const struct hda_fixup *fix, int action)
4053{
33f4acd3
DH
4054 /* GPIO1 = set according to SKU external amp
4055 GPIO2 = mic mute hotkey
4056 GPIO3 = mute LED
4057 GPIO4 = mic mute LED */
4058 static const struct hda_verb gpio_init[] = {
4059 { 0x01, AC_VERB_SET_GPIO_MASK, 0x1e },
4060 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x1a },
4061 { 0x01, AC_VERB_SET_GPIO_DATA, 0x02 },
4062 {}
4063 };
4064
4065 struct alc_spec *spec = codec->spec;
4066
4067 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3694cb29 4068 if (alc_register_micmute_input_device(codec) != 0)
33f4acd3 4069 return;
33f4acd3
DH
4070
4071 snd_hda_add_verbs(codec, gpio_init);
7639a06c 4072 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
33f4acd3 4073 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
7639a06c 4074 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
33f4acd3
DH
4075 gpio2_mic_hotkey_event);
4076
4077 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
4078 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
4079 spec->gpio_led = 0;
4080 spec->mute_led_polarity = 0;
4081 spec->gpio_mute_led_mask = 0x08;
4082 spec->gpio_mic_led_mask = 0x10;
4083 return;
4084 }
4085
4086 if (!spec->kb_dev)
4087 return;
4088
4089 switch (action) {
4090 case HDA_FIXUP_ACT_PROBE:
4091 spec->init_amp = ALC_INIT_DEFAULT;
4092 break;
4093 case HDA_FIXUP_ACT_FREE:
4094 input_unregister_device(spec->kb_dev);
33f4acd3
DH
4095 spec->kb_dev = NULL;
4096 }
33f4acd3
DH
4097}
4098
3694cb29
K
4099static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4100 const struct hda_fixup *fix, int action)
4101{
4102 /* Line2 = mic mute hotkey
4103 GPIO2 = mic mute LED */
4104 static const struct hda_verb gpio_init[] = {
4105 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4106 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4107 {}
4108 };
4109
4110 struct alc_spec *spec = codec->spec;
4111
4112 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4113 if (alc_register_micmute_input_device(codec) != 0)
4114 return;
4115
4116 snd_hda_add_verbs(codec, gpio_init);
4117 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4118 gpio2_mic_hotkey_event);
4119
4120 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
4121 spec->gpio_led = 0;
4122 spec->mute_led_polarity = 0;
4123 spec->gpio_mic_led_mask = 0x04;
4124 return;
4125 }
4126
4127 if (!spec->kb_dev)
4128 return;
4129
4130 switch (action) {
4131 case HDA_FIXUP_ACT_PROBE:
4132 spec->init_amp = ALC_INIT_DEFAULT;
4133 break;
4134 case HDA_FIXUP_ACT_FREE:
4135 input_unregister_device(spec->kb_dev);
4136 spec->kb_dev = NULL;
4137 }
4138}
63c4da64
TI
4139#else /* INPUT */
4140#define alc280_fixup_hp_gpio2_mic_hotkey NULL
4141#define alc233_fixup_lenovo_line2_mic_hotkey NULL
4142#endif /* INPUT */
3694cb29 4143
9c5dc3bf
KY
4144static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4145 const struct hda_fixup *fix, int action)
4146{
4147 struct alc_spec *spec = codec->spec;
4148
4149 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4150 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
4151 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
4152 spec->mute_led_polarity = 0;
4153 spec->mute_led_nid = 0x1a;
4154 spec->cap_mute_led_nid = 0x18;
4155 spec->gen.vmaster_mute_enum = 1;
4156 codec->power_filter = led_power_filter;
4157 }
4158}
4159
5a36767a
KY
4160static struct coef_fw alc225_pre_hsmode[] = {
4161 UPDATE_COEF(0x4a, 1<<8, 0),
4162 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4163 UPDATE_COEF(0x63, 3<<14, 3<<14),
4164 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4165 UPDATE_COEF(0x4a, 3<<10, 3<<10),
4166 UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4167 UPDATE_COEF(0x4a, 3<<10, 0),
4168 {}
4169};
4170
73bdd597
DH
4171static void alc_headset_mode_unplugged(struct hda_codec *codec)
4172{
54db6c39 4173 static struct coef_fw coef0255[] = {
e9ff70ab 4174 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
54db6c39
TI
4175 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4176 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4177 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4178 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4179 {}
4180 };
e69e7e03
KY
4181 static struct coef_fw coef0256[] = {
4182 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
e9ff70ab
KY
4183 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4184 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4185 WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4186 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
e69e7e03
KY
4187 {}
4188 };
54db6c39
TI
4189 static struct coef_fw coef0233[] = {
4190 WRITE_COEF(0x1b, 0x0c0b),
4191 WRITE_COEF(0x45, 0xc429),
4192 UPDATE_COEF(0x35, 0x4000, 0),
4193 WRITE_COEF(0x06, 0x2104),
4194 WRITE_COEF(0x1a, 0x0001),
4195 WRITE_COEF(0x26, 0x0004),
4196 WRITE_COEF(0x32, 0x42a3),
4197 {}
4198 };
f3b70332
KY
4199 static struct coef_fw coef0288[] = {
4200 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4201 UPDATE_COEF(0x50, 0x2000, 0x2000),
4202 UPDATE_COEF(0x56, 0x0006, 0x0006),
4203 UPDATE_COEF(0x66, 0x0008, 0),
4204 UPDATE_COEF(0x67, 0x2000, 0),
4205 {}
4206 };
89542936
KY
4207 static struct coef_fw coef0298[] = {
4208 UPDATE_COEF(0x19, 0x1300, 0x0300),
4209 {}
4210 };
54db6c39
TI
4211 static struct coef_fw coef0292[] = {
4212 WRITE_COEF(0x76, 0x000e),
4213 WRITE_COEF(0x6c, 0x2400),
4214 WRITE_COEF(0x18, 0x7308),
4215 WRITE_COEF(0x6b, 0xc429),
4216 {}
4217 };
4218 static struct coef_fw coef0293[] = {
4219 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4220 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4221 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4222 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4223 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4224 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4225 {}
4226 };
4227 static struct coef_fw coef0668[] = {
4228 WRITE_COEF(0x15, 0x0d40),
4229 WRITE_COEF(0xb7, 0x802b),
4230 {}
4231 };
4cc9b9d6 4232 static struct coef_fw coef0225[] = {
5a36767a 4233 UPDATE_COEF(0x63, 3<<14, 0),
4cc9b9d6
KY
4234 {}
4235 };
71683c32
KY
4236 static struct coef_fw coef0274[] = {
4237 UPDATE_COEF(0x4a, 0x0100, 0),
4238 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4239 UPDATE_COEF(0x6b, 0xf000, 0x5000),
4240 UPDATE_COEF(0x4a, 0x0010, 0),
4241 UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4242 WRITE_COEF(0x45, 0x5289),
4243 UPDATE_COEF(0x4a, 0x0c00, 0),
4244 {}
4245 };
54db6c39 4246
7639a06c 4247 switch (codec->core.vendor_id) {
9a22a8f5 4248 case 0x10ec0255:
e69e7e03
KY
4249 alc_process_coef_fw(codec, coef0255);
4250 break;
736f20a7 4251 case 0x10ec0236:
7081adf3 4252 case 0x10ec0256:
e69e7e03 4253 alc_process_coef_fw(codec, coef0256);
9a22a8f5 4254 break;
71683c32
KY
4255 case 0x10ec0234:
4256 case 0x10ec0274:
4257 case 0x10ec0294:
4258 alc_process_coef_fw(codec, coef0274);
4259 break;
13fd08a3 4260 case 0x10ec0233:
73bdd597 4261 case 0x10ec0283:
54db6c39 4262 alc_process_coef_fw(codec, coef0233);
73bdd597 4263 break;
f3b70332
KY
4264 case 0x10ec0286:
4265 case 0x10ec0288:
89542936
KY
4266 alc_process_coef_fw(codec, coef0288);
4267 break;
1a5bc8d9 4268 case 0x10ec0298:
89542936 4269 alc_process_coef_fw(codec, coef0298);
f3b70332
KY
4270 alc_process_coef_fw(codec, coef0288);
4271 break;
73bdd597 4272 case 0x10ec0292:
54db6c39 4273 alc_process_coef_fw(codec, coef0292);
73bdd597 4274 break;
a22aa26f 4275 case 0x10ec0293:
54db6c39 4276 alc_process_coef_fw(codec, coef0293);
a22aa26f 4277 break;
73bdd597 4278 case 0x10ec0668:
54db6c39 4279 alc_process_coef_fw(codec, coef0668);
73bdd597 4280 break;
638aad63 4281 case 0x10ec0215:
4cc9b9d6 4282 case 0x10ec0225:
638aad63 4283 case 0x10ec0285:
7d727869 4284 case 0x10ec0295:
638aad63 4285 case 0x10ec0289:
28f1f9b2 4286 case 0x10ec0299:
ba6d77fa 4287 alc_process_coef_fw(codec, alc225_pre_hsmode);
4cc9b9d6
KY
4288 alc_process_coef_fw(codec, coef0225);
4289 break;
78f4f7c2
KY
4290 case 0x10ec0867:
4291 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4292 break;
73bdd597 4293 }
4e76a883 4294 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
73bdd597
DH
4295}
4296
4297
4298static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4299 hda_nid_t mic_pin)
4300{
54db6c39
TI
4301 static struct coef_fw coef0255[] = {
4302 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4303 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4304 {}
4305 };
e9ff70ab
KY
4306 static struct coef_fw coef0256[] = {
4307 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
4308 WRITE_COEFEX(0x57, 0x03, 0x09a3),
4309 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4310 {}
4311 };
54db6c39
TI
4312 static struct coef_fw coef0233[] = {
4313 UPDATE_COEF(0x35, 0, 1<<14),
4314 WRITE_COEF(0x06, 0x2100),
4315 WRITE_COEF(0x1a, 0x0021),
4316 WRITE_COEF(0x26, 0x008c),
4317 {}
4318 };
f3b70332 4319 static struct coef_fw coef0288[] = {
89542936 4320 UPDATE_COEF(0x4f, 0x00c0, 0),
f3b70332
KY
4321 UPDATE_COEF(0x50, 0x2000, 0),
4322 UPDATE_COEF(0x56, 0x0006, 0),
4323 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4324 UPDATE_COEF(0x66, 0x0008, 0x0008),
4325 UPDATE_COEF(0x67, 0x2000, 0x2000),
4326 {}
4327 };
54db6c39
TI
4328 static struct coef_fw coef0292[] = {
4329 WRITE_COEF(0x19, 0xa208),
4330 WRITE_COEF(0x2e, 0xacf0),
4331 {}
4332 };
4333 static struct coef_fw coef0293[] = {
4334 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4335 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4336 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4337 {}
4338 };
4339 static struct coef_fw coef0688[] = {
4340 WRITE_COEF(0xb7, 0x802b),
4341 WRITE_COEF(0xb5, 0x1040),
4342 UPDATE_COEF(0xc3, 0, 1<<12),
4343 {}
4344 };
4cc9b9d6
KY
4345 static struct coef_fw coef0225[] = {
4346 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4347 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4348 UPDATE_COEF(0x63, 3<<14, 0),
4349 {}
4350 };
71683c32
KY
4351 static struct coef_fw coef0274[] = {
4352 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4353 UPDATE_COEF(0x4a, 0x0010, 0),
4354 UPDATE_COEF(0x6b, 0xf000, 0),
4355 {}
4356 };
54db6c39 4357
7639a06c 4358 switch (codec->core.vendor_id) {
9a22a8f5
KY
4359 case 0x10ec0255:
4360 alc_write_coef_idx(codec, 0x45, 0xc489);
4361 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4362 alc_process_coef_fw(codec, coef0255);
9a22a8f5
KY
4363 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4364 break;
e9ff70ab
KY
4365 case 0x10ec0236:
4366 case 0x10ec0256:
4367 alc_write_coef_idx(codec, 0x45, 0xc489);
4368 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4369 alc_process_coef_fw(codec, coef0256);
4370 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4371 break;
71683c32
KY
4372 case 0x10ec0234:
4373 case 0x10ec0274:
4374 case 0x10ec0294:
4375 alc_write_coef_idx(codec, 0x45, 0x4689);
4376 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4377 alc_process_coef_fw(codec, coef0274);
4378 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4379 break;
13fd08a3 4380 case 0x10ec0233:
73bdd597
DH
4381 case 0x10ec0283:
4382 alc_write_coef_idx(codec, 0x45, 0xc429);
4383 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4384 alc_process_coef_fw(codec, coef0233);
73bdd597
DH
4385 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4386 break;
f3b70332
KY
4387 case 0x10ec0286:
4388 case 0x10ec0288:
1a5bc8d9 4389 case 0x10ec0298:
f3b70332
KY
4390 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4391 alc_process_coef_fw(codec, coef0288);
4392 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4393 break;
73bdd597
DH
4394 case 0x10ec0292:
4395 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4396 alc_process_coef_fw(codec, coef0292);
73bdd597 4397 break;
a22aa26f
KY
4398 case 0x10ec0293:
4399 /* Set to TRS mode */
4400 alc_write_coef_idx(codec, 0x45, 0xc429);
4401 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4402 alc_process_coef_fw(codec, coef0293);
a22aa26f
KY
4403 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4404 break;
78f4f7c2
KY
4405 case 0x10ec0867:
4406 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4407 /* fallthru */
9eb5d0e6 4408 case 0x10ec0221:
1f8b46cd
DH
4409 case 0x10ec0662:
4410 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4411 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4412 break;
73bdd597
DH
4413 case 0x10ec0668:
4414 alc_write_coef_idx(codec, 0x11, 0x0001);
4415 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4416 alc_process_coef_fw(codec, coef0688);
73bdd597
DH
4417 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4418 break;
638aad63 4419 case 0x10ec0215:
4cc9b9d6 4420 case 0x10ec0225:
638aad63 4421 case 0x10ec0285:
7d727869 4422 case 0x10ec0295:
638aad63 4423 case 0x10ec0289:
28f1f9b2 4424 case 0x10ec0299:
5a36767a 4425 alc_process_coef_fw(codec, alc225_pre_hsmode);
4cc9b9d6
KY
4426 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4427 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4428 alc_process_coef_fw(codec, coef0225);
4429 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4430 break;
73bdd597 4431 }
4e76a883 4432 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
73bdd597
DH
4433}
4434
4435static void alc_headset_mode_default(struct hda_codec *codec)
4436{
2ae95577 4437 static struct coef_fw coef0225[] = {
5a36767a
KY
4438 UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4439 UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4440 UPDATE_COEF(0x49, 3<<8, 0<<8),
4441 UPDATE_COEF(0x4a, 3<<4, 3<<4),
4442 UPDATE_COEF(0x63, 3<<14, 0),
4443 UPDATE_COEF(0x67, 0xf000, 0x3000),
2ae95577
DH
4444 {}
4445 };
54db6c39
TI
4446 static struct coef_fw coef0255[] = {
4447 WRITE_COEF(0x45, 0xc089),
4448 WRITE_COEF(0x45, 0xc489),
4449 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4450 WRITE_COEF(0x49, 0x0049),
4451 {}
4452 };
e9ff70ab
KY
4453 static struct coef_fw coef0256[] = {
4454 WRITE_COEF(0x45, 0xc489),
4455 WRITE_COEFEX(0x57, 0x03, 0x0da3),
4456 WRITE_COEF(0x49, 0x0049),
4457 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4458 WRITE_COEF(0x06, 0x6100),
4459 {}
4460 };
54db6c39
TI
4461 static struct coef_fw coef0233[] = {
4462 WRITE_COEF(0x06, 0x2100),
4463 WRITE_COEF(0x32, 0x4ea3),
4464 {}
4465 };
f3b70332
KY
4466 static struct coef_fw coef0288[] = {
4467 UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
4468 UPDATE_COEF(0x50, 0x2000, 0x2000),
4469 UPDATE_COEF(0x56, 0x0006, 0x0006),
4470 UPDATE_COEF(0x66, 0x0008, 0),
4471 UPDATE_COEF(0x67, 0x2000, 0),
4472 {}
4473 };
54db6c39
TI
4474 static struct coef_fw coef0292[] = {
4475 WRITE_COEF(0x76, 0x000e),
4476 WRITE_COEF(0x6c, 0x2400),
4477 WRITE_COEF(0x6b, 0xc429),
4478 WRITE_COEF(0x18, 0x7308),
4479 {}
4480 };
4481 static struct coef_fw coef0293[] = {
4482 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4483 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
4484 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4485 {}
4486 };
4487 static struct coef_fw coef0688[] = {
4488 WRITE_COEF(0x11, 0x0041),
4489 WRITE_COEF(0x15, 0x0d40),
4490 WRITE_COEF(0xb7, 0x802b),
4491 {}
4492 };
71683c32
KY
4493 static struct coef_fw coef0274[] = {
4494 WRITE_COEF(0x45, 0x4289),
4495 UPDATE_COEF(0x4a, 0x0010, 0x0010),
4496 UPDATE_COEF(0x6b, 0x0f00, 0),
4497 UPDATE_COEF(0x49, 0x0300, 0x0300),
4498 {}
4499 };
54db6c39 4500
7639a06c 4501 switch (codec->core.vendor_id) {
638aad63 4502 case 0x10ec0215:
2ae95577 4503 case 0x10ec0225:
638aad63 4504 case 0x10ec0285:
7d727869 4505 case 0x10ec0295:
638aad63 4506 case 0x10ec0289:
28f1f9b2 4507 case 0x10ec0299:
5a36767a 4508 alc_process_coef_fw(codec, alc225_pre_hsmode);
2ae95577
DH
4509 alc_process_coef_fw(codec, coef0225);
4510 break;
9a22a8f5 4511 case 0x10ec0255:
54db6c39 4512 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4513 break;
e9ff70ab
KY
4514 case 0x10ec0236:
4515 case 0x10ec0256:
4516 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4517 alc_write_coef_idx(codec, 0x45, 0xc089);
4518 msleep(50);
4519 alc_process_coef_fw(codec, coef0256);
4520 break;
71683c32
KY
4521 case 0x10ec0234:
4522 case 0x10ec0274:
4523 case 0x10ec0294:
4524 alc_process_coef_fw(codec, coef0274);
4525 break;
13fd08a3 4526 case 0x10ec0233:
73bdd597 4527 case 0x10ec0283:
54db6c39 4528 alc_process_coef_fw(codec, coef0233);
73bdd597 4529 break;
f3b70332
KY
4530 case 0x10ec0286:
4531 case 0x10ec0288:
1a5bc8d9 4532 case 0x10ec0298:
f3b70332
KY
4533 alc_process_coef_fw(codec, coef0288);
4534 break;
73bdd597 4535 case 0x10ec0292:
54db6c39 4536 alc_process_coef_fw(codec, coef0292);
73bdd597 4537 break;
a22aa26f 4538 case 0x10ec0293:
54db6c39 4539 alc_process_coef_fw(codec, coef0293);
a22aa26f 4540 break;
73bdd597 4541 case 0x10ec0668:
54db6c39 4542 alc_process_coef_fw(codec, coef0688);
73bdd597 4543 break;
78f4f7c2
KY
4544 case 0x10ec0867:
4545 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4546 break;
73bdd597 4547 }
4e76a883 4548 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
73bdd597
DH
4549}
4550
4551/* Iphone type */
4552static void alc_headset_mode_ctia(struct hda_codec *codec)
4553{
89542936
KY
4554 int val;
4555
54db6c39
TI
4556 static struct coef_fw coef0255[] = {
4557 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4558 WRITE_COEF(0x1b, 0x0c2b),
4559 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4560 {}
4561 };
e69e7e03
KY
4562 static struct coef_fw coef0256[] = {
4563 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
e9ff70ab 4564 WRITE_COEF(0x1b, 0x0e6b),
e69e7e03
KY
4565 {}
4566 };
54db6c39
TI
4567 static struct coef_fw coef0233[] = {
4568 WRITE_COEF(0x45, 0xd429),
4569 WRITE_COEF(0x1b, 0x0c2b),
4570 WRITE_COEF(0x32, 0x4ea3),
4571 {}
4572 };
f3b70332
KY
4573 static struct coef_fw coef0288[] = {
4574 UPDATE_COEF(0x50, 0x2000, 0x2000),
4575 UPDATE_COEF(0x56, 0x0006, 0x0006),
4576 UPDATE_COEF(0x66, 0x0008, 0),
4577 UPDATE_COEF(0x67, 0x2000, 0),
4578 {}
4579 };
54db6c39
TI
4580 static struct coef_fw coef0292[] = {
4581 WRITE_COEF(0x6b, 0xd429),
4582 WRITE_COEF(0x76, 0x0008),
4583 WRITE_COEF(0x18, 0x7388),
4584 {}
4585 };
4586 static struct coef_fw coef0293[] = {
4587 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
4588 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4589 {}
4590 };
4591 static struct coef_fw coef0688[] = {
4592 WRITE_COEF(0x11, 0x0001),
4593 WRITE_COEF(0x15, 0x0d60),
4594 WRITE_COEF(0xc3, 0x0000),
4595 {}
4596 };
5a36767a 4597 static struct coef_fw coef0225_1[] = {
4cc9b9d6 4598 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5a36767a
KY
4599 UPDATE_COEF(0x63, 3<<14, 2<<14),
4600 {}
4601 };
4602 static struct coef_fw coef0225_2[] = {
4603 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4604 UPDATE_COEF(0x63, 3<<14, 1<<14),
4cc9b9d6
KY
4605 {}
4606 };
54db6c39 4607
7639a06c 4608 switch (codec->core.vendor_id) {
9a22a8f5 4609 case 0x10ec0255:
54db6c39 4610 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4611 break;
736f20a7 4612 case 0x10ec0236:
e69e7e03
KY
4613 case 0x10ec0256:
4614 alc_process_coef_fw(codec, coef0256);
4615 break;
71683c32
KY
4616 case 0x10ec0234:
4617 case 0x10ec0274:
4618 case 0x10ec0294:
4619 alc_write_coef_idx(codec, 0x45, 0xd689);
4620 break;
13fd08a3 4621 case 0x10ec0233:
73bdd597 4622 case 0x10ec0283:
54db6c39 4623 alc_process_coef_fw(codec, coef0233);
73bdd597 4624 break;
1a5bc8d9 4625 case 0x10ec0298:
89542936
KY
4626 val = alc_read_coef_idx(codec, 0x50);
4627 if (val & (1 << 12)) {
4628 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4629 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4630 msleep(300);
4631 } else {
4632 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4633 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4634 msleep(300);
4635 }
4636 break;
f3b70332
KY
4637 case 0x10ec0286:
4638 case 0x10ec0288:
4639 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4640 msleep(300);
4641 alc_process_coef_fw(codec, coef0288);
4642 break;
73bdd597 4643 case 0x10ec0292:
54db6c39 4644 alc_process_coef_fw(codec, coef0292);
73bdd597 4645 break;
a22aa26f 4646 case 0x10ec0293:
54db6c39 4647 alc_process_coef_fw(codec, coef0293);
a22aa26f 4648 break;
73bdd597 4649 case 0x10ec0668:
54db6c39 4650 alc_process_coef_fw(codec, coef0688);
73bdd597 4651 break;
638aad63 4652 case 0x10ec0215:
4cc9b9d6 4653 case 0x10ec0225:
638aad63 4654 case 0x10ec0285:
7d727869 4655 case 0x10ec0295:
638aad63 4656 case 0x10ec0289:
28f1f9b2 4657 case 0x10ec0299:
5a36767a
KY
4658 val = alc_read_coef_idx(codec, 0x45);
4659 if (val & (1 << 9))
4660 alc_process_coef_fw(codec, coef0225_2);
4661 else
4662 alc_process_coef_fw(codec, coef0225_1);
4cc9b9d6 4663 break;
78f4f7c2
KY
4664 case 0x10ec0867:
4665 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4666 break;
73bdd597 4667 }
4e76a883 4668 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
73bdd597
DH
4669}
4670
4671/* Nokia type */
4672static void alc_headset_mode_omtp(struct hda_codec *codec)
4673{
54db6c39
TI
4674 static struct coef_fw coef0255[] = {
4675 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4676 WRITE_COEF(0x1b, 0x0c2b),
4677 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4678 {}
4679 };
e69e7e03
KY
4680 static struct coef_fw coef0256[] = {
4681 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
e9ff70ab 4682 WRITE_COEF(0x1b, 0x0e6b),
e69e7e03
KY
4683 {}
4684 };
54db6c39
TI
4685 static struct coef_fw coef0233[] = {
4686 WRITE_COEF(0x45, 0xe429),
4687 WRITE_COEF(0x1b, 0x0c2b),
4688 WRITE_COEF(0x32, 0x4ea3),
4689 {}
4690 };
f3b70332
KY
4691 static struct coef_fw coef0288[] = {
4692 UPDATE_COEF(0x50, 0x2000, 0x2000),
4693 UPDATE_COEF(0x56, 0x0006, 0x0006),
4694 UPDATE_COEF(0x66, 0x0008, 0),
4695 UPDATE_COEF(0x67, 0x2000, 0),
4696 {}
4697 };
54db6c39
TI
4698 static struct coef_fw coef0292[] = {
4699 WRITE_COEF(0x6b, 0xe429),
4700 WRITE_COEF(0x76, 0x0008),
4701 WRITE_COEF(0x18, 0x7388),
4702 {}
4703 };
4704 static struct coef_fw coef0293[] = {
4705 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
4706 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4707 {}
4708 };
4709 static struct coef_fw coef0688[] = {
4710 WRITE_COEF(0x11, 0x0001),
4711 WRITE_COEF(0x15, 0x0d50),
4712 WRITE_COEF(0xc3, 0x0000),
4713 {}
4714 };
4cc9b9d6
KY
4715 static struct coef_fw coef0225[] = {
4716 UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5a36767a 4717 UPDATE_COEF(0x63, 3<<14, 2<<14),
4cc9b9d6
KY
4718 {}
4719 };
54db6c39 4720
7639a06c 4721 switch (codec->core.vendor_id) {
9a22a8f5 4722 case 0x10ec0255:
54db6c39 4723 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4724 break;
736f20a7 4725 case 0x10ec0236:
e69e7e03
KY
4726 case 0x10ec0256:
4727 alc_process_coef_fw(codec, coef0256);
4728 break;
71683c32
KY
4729 case 0x10ec0234:
4730 case 0x10ec0274:
4731 case 0x10ec0294:
4732 alc_write_coef_idx(codec, 0x45, 0xe689);
4733 break;
13fd08a3 4734 case 0x10ec0233:
73bdd597 4735 case 0x10ec0283:
54db6c39 4736 alc_process_coef_fw(codec, coef0233);
73bdd597 4737 break;
1a5bc8d9
KY
4738 case 0x10ec0298:
4739 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
89542936
KY
4740 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4741 msleep(300);
4742 break;
f3b70332
KY
4743 case 0x10ec0286:
4744 case 0x10ec0288:
4745 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4746 msleep(300);
4747 alc_process_coef_fw(codec, coef0288);
4748 break;
73bdd597 4749 case 0x10ec0292:
54db6c39 4750 alc_process_coef_fw(codec, coef0292);
73bdd597 4751 break;
a22aa26f 4752 case 0x10ec0293:
54db6c39 4753 alc_process_coef_fw(codec, coef0293);
a22aa26f 4754 break;
73bdd597 4755 case 0x10ec0668:
54db6c39 4756 alc_process_coef_fw(codec, coef0688);
73bdd597 4757 break;
638aad63 4758 case 0x10ec0215:
4cc9b9d6 4759 case 0x10ec0225:
638aad63 4760 case 0x10ec0285:
7d727869 4761 case 0x10ec0295:
638aad63 4762 case 0x10ec0289:
28f1f9b2 4763 case 0x10ec0299:
4cc9b9d6
KY
4764 alc_process_coef_fw(codec, coef0225);
4765 break;
73bdd597 4766 }
4e76a883 4767 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
73bdd597
DH
4768}
4769
4770static void alc_determine_headset_type(struct hda_codec *codec)
4771{
4772 int val;
4773 bool is_ctia = false;
4774 struct alc_spec *spec = codec->spec;
54db6c39
TI
4775 static struct coef_fw coef0255[] = {
4776 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
4777 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
4778 conteol) */
4779 {}
4780 };
f3b70332
KY
4781 static struct coef_fw coef0288[] = {
4782 UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
4783 {}
4784 };
89542936
KY
4785 static struct coef_fw coef0298[] = {
4786 UPDATE_COEF(0x50, 0x2000, 0x2000),
4787 UPDATE_COEF(0x56, 0x0006, 0x0006),
4788 UPDATE_COEF(0x66, 0x0008, 0),
4789 UPDATE_COEF(0x67, 0x2000, 0),
4790 UPDATE_COEF(0x19, 0x1300, 0x1300),
4791 {}
4792 };
54db6c39
TI
4793 static struct coef_fw coef0293[] = {
4794 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
4795 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
4796 {}
4797 };
4798 static struct coef_fw coef0688[] = {
4799 WRITE_COEF(0x11, 0x0001),
4800 WRITE_COEF(0xb7, 0x802b),
4801 WRITE_COEF(0x15, 0x0d60),
4802 WRITE_COEF(0xc3, 0x0c00),
4803 {}
4804 };
71683c32
KY
4805 static struct coef_fw coef0274[] = {
4806 UPDATE_COEF(0x4a, 0x0010, 0),
4807 UPDATE_COEF(0x4a, 0x8000, 0),
4808 WRITE_COEF(0x45, 0xd289),
4809 UPDATE_COEF(0x49, 0x0300, 0x0300),
4810 {}
4811 };
73bdd597 4812
7639a06c 4813 switch (codec->core.vendor_id) {
9a22a8f5 4814 case 0x10ec0255:
e9ff70ab
KY
4815 alc_process_coef_fw(codec, coef0255);
4816 msleep(300);
4817 val = alc_read_coef_idx(codec, 0x46);
4818 is_ctia = (val & 0x0070) == 0x0070;
4819 break;
4820 case 0x10ec0236:
7081adf3 4821 case 0x10ec0256:
e9ff70ab
KY
4822 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4823 alc_write_coef_idx(codec, 0x06, 0x6104);
4824 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
4825
4826 snd_hda_codec_write(codec, 0x21, 0,
4827 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4828 msleep(80);
4829 snd_hda_codec_write(codec, 0x21, 0,
4830 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4831
54db6c39 4832 alc_process_coef_fw(codec, coef0255);
9a22a8f5
KY
4833 msleep(300);
4834 val = alc_read_coef_idx(codec, 0x46);
4835 is_ctia = (val & 0x0070) == 0x0070;
e9ff70ab
KY
4836
4837 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
4838 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4839
4840 snd_hda_codec_write(codec, 0x21, 0,
4841 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4842 msleep(80);
4843 snd_hda_codec_write(codec, 0x21, 0,
4844 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
9a22a8f5 4845 break;
71683c32
KY
4846 case 0x10ec0234:
4847 case 0x10ec0274:
4848 case 0x10ec0294:
4849 alc_process_coef_fw(codec, coef0274);
4850 msleep(80);
4851 val = alc_read_coef_idx(codec, 0x46);
4852 is_ctia = (val & 0x00f0) == 0x00f0;
4853 break;
13fd08a3 4854 case 0x10ec0233:
73bdd597
DH
4855 case 0x10ec0283:
4856 alc_write_coef_idx(codec, 0x45, 0xd029);
4857 msleep(300);
4858 val = alc_read_coef_idx(codec, 0x46);
4859 is_ctia = (val & 0x0070) == 0x0070;
4860 break;
1a5bc8d9 4861 case 0x10ec0298:
89542936
KY
4862 snd_hda_codec_write(codec, 0x21, 0,
4863 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4864 msleep(100);
4865 snd_hda_codec_write(codec, 0x21, 0,
4866 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4867 msleep(200);
4868
4869 val = alc_read_coef_idx(codec, 0x50);
4870 if (val & (1 << 12)) {
4871 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4872 alc_process_coef_fw(codec, coef0288);
4873 msleep(350);
4874 val = alc_read_coef_idx(codec, 0x50);
4875 is_ctia = (val & 0x0070) == 0x0070;
4876 } else {
4877 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4878 alc_process_coef_fw(codec, coef0288);
4879 msleep(350);
4880 val = alc_read_coef_idx(codec, 0x50);
4881 is_ctia = (val & 0x0070) == 0x0070;
4882 }
4883 alc_process_coef_fw(codec, coef0298);
4884 snd_hda_codec_write(codec, 0x21, 0,
4885 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4886 msleep(75);
4887 snd_hda_codec_write(codec, 0x21, 0,
4888 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4889 break;
f3b70332
KY
4890 case 0x10ec0286:
4891 case 0x10ec0288:
4892 alc_process_coef_fw(codec, coef0288);
4893 msleep(350);
4894 val = alc_read_coef_idx(codec, 0x50);
4895 is_ctia = (val & 0x0070) == 0x0070;
4896 break;
73bdd597
DH
4897 case 0x10ec0292:
4898 alc_write_coef_idx(codec, 0x6b, 0xd429);
4899 msleep(300);
4900 val = alc_read_coef_idx(codec, 0x6c);
4901 is_ctia = (val & 0x001c) == 0x001c;
4902 break;
a22aa26f 4903 case 0x10ec0293:
54db6c39 4904 alc_process_coef_fw(codec, coef0293);
a22aa26f
KY
4905 msleep(300);
4906 val = alc_read_coef_idx(codec, 0x46);
4907 is_ctia = (val & 0x0070) == 0x0070;
4908 break;
73bdd597 4909 case 0x10ec0668:
54db6c39 4910 alc_process_coef_fw(codec, coef0688);
73bdd597
DH
4911 msleep(300);
4912 val = alc_read_coef_idx(codec, 0xbe);
4913 is_ctia = (val & 0x1c02) == 0x1c02;
4914 break;
638aad63 4915 case 0x10ec0215:
4cc9b9d6 4916 case 0x10ec0225:
638aad63 4917 case 0x10ec0285:
7d727869 4918 case 0x10ec0295:
638aad63 4919 case 0x10ec0289:
28f1f9b2 4920 case 0x10ec0299:
0b4d8f55
KY
4921 snd_hda_codec_write(codec, 0x21, 0,
4922 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4923 msleep(80);
4924 snd_hda_codec_write(codec, 0x21, 0,
4925 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4926
5a36767a
KY
4927 alc_process_coef_fw(codec, alc225_pre_hsmode);
4928 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
4929 val = alc_read_coef_idx(codec, 0x45);
4930 if (val & (1 << 9)) {
4931 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4932 alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
4933 msleep(800);
4934 val = alc_read_coef_idx(codec, 0x46);
4935 is_ctia = (val & 0x00f0) == 0x00f0;
4936 } else {
4937 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4938 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
4939 msleep(800);
4940 val = alc_read_coef_idx(codec, 0x46);
4941 is_ctia = (val & 0x00f0) == 0x00f0;
4942 }
4943 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
4944 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
4945 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
0b4d8f55
KY
4946
4947 snd_hda_codec_write(codec, 0x21, 0,
4948 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4949 msleep(80);
4950 snd_hda_codec_write(codec, 0x21, 0,
4951 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4cc9b9d6 4952 break;
78f4f7c2
KY
4953 case 0x10ec0867:
4954 is_ctia = true;
4955 break;
73bdd597
DH
4956 }
4957
4e76a883 4958 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
73bdd597
DH
4959 is_ctia ? "yes" : "no");
4960 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
4961}
4962
4963static void alc_update_headset_mode(struct hda_codec *codec)
4964{
4965 struct alc_spec *spec = codec->spec;
4966
4967 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
80f10932 4968 hda_nid_t hp_pin = alc_get_hp_pin(spec);
73bdd597
DH
4969
4970 int new_headset_mode;
4971
4972 if (!snd_hda_jack_detect(codec, hp_pin))
4973 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
4974 else if (mux_pin == spec->headset_mic_pin)
4975 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
4976 else if (mux_pin == spec->headphone_mic_pin)
4977 new_headset_mode = ALC_HEADSET_MODE_MIC;
4978 else
4979 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
4980
5959a6bc
DH
4981 if (new_headset_mode == spec->current_headset_mode) {
4982 snd_hda_gen_update_outputs(codec);
73bdd597 4983 return;
5959a6bc 4984 }
73bdd597
DH
4985
4986 switch (new_headset_mode) {
4987 case ALC_HEADSET_MODE_UNPLUGGED:
4988 alc_headset_mode_unplugged(codec);
4989 spec->gen.hp_jack_present = false;
4990 break;
4991 case ALC_HEADSET_MODE_HEADSET:
4992 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
4993 alc_determine_headset_type(codec);
4994 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
4995 alc_headset_mode_ctia(codec);
4996 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
4997 alc_headset_mode_omtp(codec);
4998 spec->gen.hp_jack_present = true;
4999 break;
5000 case ALC_HEADSET_MODE_MIC:
5001 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5002 spec->gen.hp_jack_present = false;
5003 break;
5004 case ALC_HEADSET_MODE_HEADPHONE:
5005 alc_headset_mode_default(codec);
5006 spec->gen.hp_jack_present = true;
5007 break;
5008 }
5009 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5010 snd_hda_set_pin_ctl_cache(codec, hp_pin,
5011 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1f8b46cd 5012 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
73bdd597
DH
5013 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5014 PIN_VREFHIZ);
5015 }
5016 spec->current_headset_mode = new_headset_mode;
5017
5018 snd_hda_gen_update_outputs(codec);
5019}
5020
5021static void alc_update_headset_mode_hook(struct hda_codec *codec,
7fe30711
TI
5022 struct snd_kcontrol *kcontrol,
5023 struct snd_ctl_elem_value *ucontrol)
73bdd597
DH
5024{
5025 alc_update_headset_mode(codec);
5026}
5027
1a4f69d5
TI
5028static void alc_update_headset_jack_cb(struct hda_codec *codec,
5029 struct hda_jack_callback *jack)
73bdd597
DH
5030{
5031 struct alc_spec *spec = codec->spec;
5db4d34b 5032 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
73bdd597
DH
5033 snd_hda_gen_hp_automute(codec, jack);
5034}
5035
5036static void alc_probe_headset_mode(struct hda_codec *codec)
5037{
5038 int i;
5039 struct alc_spec *spec = codec->spec;
5040 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5041
5042 /* Find mic pins */
5043 for (i = 0; i < cfg->num_inputs; i++) {
5044 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5045 spec->headset_mic_pin = cfg->inputs[i].pin;
5046 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5047 spec->headphone_mic_pin = cfg->inputs[i].pin;
5048 }
5049
5050 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5051 spec->gen.automute_hook = alc_update_headset_mode;
5052 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5053}
5054
5055static void alc_fixup_headset_mode(struct hda_codec *codec,
5056 const struct hda_fixup *fix, int action)
5057{
5058 struct alc_spec *spec = codec->spec;
5059
5060 switch (action) {
5061 case HDA_FIXUP_ACT_PRE_PROBE:
5062 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5063 break;
5064 case HDA_FIXUP_ACT_PROBE:
5065 alc_probe_headset_mode(codec);
5066 break;
5067 case HDA_FIXUP_ACT_INIT:
5068 spec->current_headset_mode = 0;
5069 alc_update_headset_mode(codec);
5070 break;
5071 }
5072}
5073
5074static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5075 const struct hda_fixup *fix, int action)
5076{
5077 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5078 struct alc_spec *spec = codec->spec;
5079 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5080 }
5081 else
5082 alc_fixup_headset_mode(codec, fix, action);
5083}
5084
31278997
KY
5085static void alc255_set_default_jack_type(struct hda_codec *codec)
5086{
5087 /* Set to iphone type */
e69e7e03 5088 static struct coef_fw alc255fw[] = {
54db6c39
TI
5089 WRITE_COEF(0x1b, 0x880b),
5090 WRITE_COEF(0x45, 0xd089),
5091 WRITE_COEF(0x1b, 0x080b),
5092 WRITE_COEF(0x46, 0x0004),
5093 WRITE_COEF(0x1b, 0x0c0b),
5094 {}
5095 };
e69e7e03
KY
5096 static struct coef_fw alc256fw[] = {
5097 WRITE_COEF(0x1b, 0x884b),
5098 WRITE_COEF(0x45, 0xd089),
5099 WRITE_COEF(0x1b, 0x084b),
5100 WRITE_COEF(0x46, 0x0004),
5101 WRITE_COEF(0x1b, 0x0c4b),
5102 {}
5103 };
5104 switch (codec->core.vendor_id) {
5105 case 0x10ec0255:
5106 alc_process_coef_fw(codec, alc255fw);
5107 break;
736f20a7 5108 case 0x10ec0236:
e69e7e03
KY
5109 case 0x10ec0256:
5110 alc_process_coef_fw(codec, alc256fw);
5111 break;
5112 }
31278997
KY
5113 msleep(30);
5114}
5115
9a22a8f5
KY
5116static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5117 const struct hda_fixup *fix, int action)
5118{
5119 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
31278997 5120 alc255_set_default_jack_type(codec);
9a22a8f5
KY
5121 }
5122 alc_fixup_headset_mode(codec, fix, action);
5123}
5124
31278997
KY
5125static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5126 const struct hda_fixup *fix, int action)
5127{
5128 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5129 struct alc_spec *spec = codec->spec;
5130 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5131 alc255_set_default_jack_type(codec);
5132 }
5133 else
5134 alc_fixup_headset_mode(codec, fix, action);
5135}
5136
e1e62b98
KY
5137static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5138 struct hda_jack_callback *jack)
5139{
5140 struct alc_spec *spec = codec->spec;
5141 int present;
5142
5143 alc_update_headset_jack_cb(codec, jack);
5144 /* Headset Mic enable or disable, only for Dell Dino */
5145 present = spec->gen.hp_jack_present ? 0x40 : 0;
5146 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5147 present);
5148}
5149
5150static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5151 const struct hda_fixup *fix, int action)
5152{
5153 alc_fixup_headset_mode(codec, fix, action);
5154 if (action == HDA_FIXUP_ACT_PROBE) {
5155 struct alc_spec *spec = codec->spec;
5156 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5157 }
5158}
5159
493a52a9
HW
5160static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5161 const struct hda_fixup *fix, int action)
5162{
5163 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5164 struct alc_spec *spec = codec->spec;
5165 spec->gen.auto_mute_via_amp = 1;
5166 }
5167}
5168
9b745ab8
TI
5169static void alc_fixup_no_shutup(struct hda_codec *codec,
5170 const struct hda_fixup *fix, int action)
5171{
972aa2c7 5172 if (action == HDA_FIXUP_ACT_PROBE) {
9b745ab8 5173 struct alc_spec *spec = codec->spec;
b001f661 5174 spec->no_shutup_pins = 1;
9b745ab8
TI
5175 }
5176}
5177
5e6db669
GM
5178static void alc_fixup_disable_aamix(struct hda_codec *codec,
5179 const struct hda_fixup *fix, int action)
5180{
5181 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5182 struct alc_spec *spec = codec->spec;
5183 /* Disable AA-loopback as it causes white noise */
5184 spec->gen.mixer_nid = 0;
5185 }
5186}
5187
7f57d803
TI
5188/* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
5189static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5190 const struct hda_fixup *fix, int action)
5191{
5192 static const struct hda_pintbl pincfgs[] = {
5193 { 0x16, 0x21211010 }, /* dock headphone */
5194 { 0x19, 0x21a11010 }, /* dock mic */
5195 { }
5196 };
5197 struct alc_spec *spec = codec->spec;
5198
5199 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
422689a7 5200 spec->reboot_notify = snd_hda_gen_reboot_notify; /* reduce noise */
7f57d803
TI
5201 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5202 codec->power_save_node = 0; /* avoid click noises */
5203 snd_hda_apply_pincfgs(codec, pincfgs);
5204 }
5205}
5206
114745cd
KY
5207static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5208 const struct hda_fixup *fix, int action)
5209{
5210 static const struct hda_pintbl pincfgs[] = {
5211 { 0x17, 0x21211010 }, /* dock headphone */
5212 { 0x19, 0x21a11010 }, /* dock mic */
5213 { }
5214 };
595263d2
TI
5215 /* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5216 * the speaker output becomes too low by some reason on Thinkpads with
5217 * ALC298 codec
5218 */
5219 static hda_nid_t preferred_pairs[] = {
5220 0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5221 0
5222 };
114745cd
KY
5223 struct alc_spec *spec = codec->spec;
5224
5225 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
595263d2 5226 spec->gen.preferred_dacs = preferred_pairs;
114745cd 5227 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
35bc709a
TI
5228 snd_hda_apply_pincfgs(codec, pincfgs);
5229 } else if (action == HDA_FIXUP_ACT_INIT) {
114745cd
KY
5230 /* Enable DOCK device */
5231 snd_hda_codec_write(codec, 0x17, 0,
5232 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5233 /* Enable DOCK device */
5234 snd_hda_codec_write(codec, 0x19, 0,
5235 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
114745cd
KY
5236 }
5237}
5238
9476d369 5239static void alc_shutup_dell_xps13(struct hda_codec *codec)
033b0a7c
GM
5240{
5241 struct alc_spec *spec = codec->spec;
80f10932 5242 int hp_pin = alc_get_hp_pin(spec);
033b0a7c 5243
9476d369
GM
5244 /* Prevent pop noises when headphones are plugged in */
5245 snd_hda_codec_write(codec, hp_pin, 0,
5246 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5247 msleep(20);
033b0a7c
GM
5248}
5249
5250static void alc_fixup_dell_xps13(struct hda_codec *codec,
5251 const struct hda_fixup *fix, int action)
5252{
3e1b0c4a
TI
5253 struct alc_spec *spec = codec->spec;
5254 struct hda_input_mux *imux = &spec->gen.input_mux;
5255 int i;
f38663ab 5256
3e1b0c4a
TI
5257 switch (action) {
5258 case HDA_FIXUP_ACT_PRE_PROBE:
5259 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
5260 * it causes a click noise at start up
5261 */
5262 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5263 break;
5264 case HDA_FIXUP_ACT_PROBE:
9476d369 5265 spec->shutup = alc_shutup_dell_xps13;
f38663ab
GM
5266
5267 /* Make the internal mic the default input source. */
5268 for (i = 0; i < imux->num_items; i++) {
5269 if (spec->gen.imux_pins[i] == 0x12) {
5270 spec->gen.cur_mux[0] = i;
5271 break;
5272 }
5273 }
3e1b0c4a 5274 break;
033b0a7c
GM
5275 }
5276}
5277
1f8b46cd
DH
5278static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5279 const struct hda_fixup *fix, int action)
5280{
5281 struct alc_spec *spec = codec->spec;
5282
5283 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5284 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5285 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
b40eda64
DH
5286
5287 /* Disable boost for mic-in permanently. (This code is only called
5288 from quirks that guarantee that the headphone is at NID 0x1b.) */
5289 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5290 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
1f8b46cd
DH
5291 } else
5292 alc_fixup_headset_mode(codec, fix, action);
5293}
5294
73bdd597
DH
5295static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5296 const struct hda_fixup *fix, int action)
5297{
5298 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
73bdd597 5299 alc_write_coef_idx(codec, 0xc4, 0x8000);
98b24883 5300 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
73bdd597
DH
5301 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
5302 }
5303 alc_fixup_headset_mode(codec, fix, action);
5304}
5305
bde7bc60
CCC
5306/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
5307static int find_ext_mic_pin(struct hda_codec *codec)
5308{
5309 struct alc_spec *spec = codec->spec;
5310 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5311 hda_nid_t nid;
5312 unsigned int defcfg;
5313 int i;
5314
5315 for (i = 0; i < cfg->num_inputs; i++) {
5316 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5317 continue;
5318 nid = cfg->inputs[i].pin;
5319 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5320 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
5321 continue;
5322 return nid;
5323 }
5324
5325 return 0;
5326}
5327
08a978db 5328static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
1727a771 5329 const struct hda_fixup *fix,
08a978db
DR
5330 int action)
5331{
5332 struct alc_spec *spec = codec->spec;
5333
0db75790 5334 if (action == HDA_FIXUP_ACT_PROBE) {
bde7bc60 5335 int mic_pin = find_ext_mic_pin(codec);
80f10932 5336 int hp_pin = alc_get_hp_pin(spec);
bde7bc60
CCC
5337
5338 if (snd_BUG_ON(!mic_pin || !hp_pin))
0db75790 5339 return;
bde7bc60 5340 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
0db75790 5341 }
08a978db 5342}
693b613d 5343
a2fe1dc7
KHF
5344static void alc256_fixup_dell_xps_13_headphone_noise2(struct hda_codec *codec,
5345 const struct hda_fixup *fix,
5346 int action)
5347{
5348 if (action != HDA_FIXUP_ACT_PRE_PROBE)
5349 return;
5350
5351 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 0, HDA_AMP_VOLMASK, 1);
5352 snd_hda_override_wcaps(codec, 0x1a, get_wcaps(codec, 0x1a) & ~AC_WCAP_IN_AMP);
5353}
5354
3e0d611b
DH
5355static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
5356 const struct hda_fixup *fix,
5357 int action)
5358{
5359 struct alc_spec *spec = codec->spec;
5360 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5361 int i;
5362
5363 /* The mic boosts on level 2 and 3 are too noisy
5364 on the internal mic input.
5365 Therefore limit the boost to 0 or 1. */
5366
5367 if (action != HDA_FIXUP_ACT_PROBE)
5368 return;
5369
5370 for (i = 0; i < cfg->num_inputs; i++) {
5371 hda_nid_t nid = cfg->inputs[i].pin;
5372 unsigned int defcfg;
5373 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5374 continue;
5375 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5376 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
5377 continue;
5378
5379 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
5380 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
5381 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5382 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
5383 (0 << AC_AMPCAP_MUTE_SHIFT));
5384 }
5385}
5386
cd217a63 5387static void alc283_hp_automute_hook(struct hda_codec *codec,
1a4f69d5 5388 struct hda_jack_callback *jack)
cd217a63
KY
5389{
5390 struct alc_spec *spec = codec->spec;
5391 int vref;
5392
5393 msleep(200);
5394 snd_hda_gen_hp_automute(codec, jack);
5395
5396 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
5397
5398 msleep(600);
5399 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5400 vref);
5401}
5402
cd217a63
KY
5403static void alc283_fixup_chromebook(struct hda_codec *codec,
5404 const struct hda_fixup *fix, int action)
5405{
5406 struct alc_spec *spec = codec->spec;
cd217a63
KY
5407
5408 switch (action) {
5409 case HDA_FIXUP_ACT_PRE_PROBE:
0202e99c 5410 snd_hda_override_wcaps(codec, 0x03, 0);
d2e92709
TI
5411 /* Disable AA-loopback as it causes white noise */
5412 spec->gen.mixer_nid = 0;
38070219 5413 break;
0202e99c 5414 case HDA_FIXUP_ACT_INIT:
de9481cb
KY
5415 /* MIC2-VREF control */
5416 /* Set to manual mode */
98b24883 5417 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
0202e99c 5418 /* Enable Line1 input control by verb */
98b24883 5419 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
0202e99c
KY
5420 break;
5421 }
5422}
5423
5424static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
5425 const struct hda_fixup *fix, int action)
5426{
5427 struct alc_spec *spec = codec->spec;
0202e99c
KY
5428
5429 switch (action) {
5430 case HDA_FIXUP_ACT_PRE_PROBE:
cd217a63 5431 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
38070219
KY
5432 break;
5433 case HDA_FIXUP_ACT_INIT:
cd217a63
KY
5434 /* MIC2-VREF control */
5435 /* Set to manual mode */
98b24883 5436 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
cd217a63
KY
5437 break;
5438 }
5439}
5440
7bba2157
TI
5441/* mute tablet speaker pin (0x14) via dock plugging in addition */
5442static void asus_tx300_automute(struct hda_codec *codec)
5443{
5444 struct alc_spec *spec = codec->spec;
5445 snd_hda_gen_update_outputs(codec);
5446 if (snd_hda_jack_detect(codec, 0x1b))
5447 spec->gen.mute_bits |= (1ULL << 0x14);
5448}
5449
5450static void alc282_fixup_asus_tx300(struct hda_codec *codec,
5451 const struct hda_fixup *fix, int action)
5452{
5453 struct alc_spec *spec = codec->spec;
5454 /* TX300 needs to set up GPIO2 for the speaker amp */
5455 static const struct hda_verb gpio2_verbs[] = {
5456 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
5457 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
5458 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
5459 {}
5460 };
5461 static const struct hda_pintbl dock_pins[] = {
5462 { 0x1b, 0x21114000 }, /* dock speaker pin */
5463 {}
5464 };
7bba2157
TI
5465
5466 switch (action) {
5467 case HDA_FIXUP_ACT_PRE_PROBE:
5468 snd_hda_add_verbs(codec, gpio2_verbs);
5469 snd_hda_apply_pincfgs(codec, dock_pins);
5470 spec->gen.auto_mute_via_amp = 1;
5471 spec->gen.automute_hook = asus_tx300_automute;
5472 snd_hda_jack_detect_enable_callback(codec, 0x1b,
7bba2157
TI
5473 snd_hda_gen_hp_automute);
5474 break;
5475 case HDA_FIXUP_ACT_BUILD:
5476 /* this is a bit tricky; give more sane names for the main
5477 * (tablet) speaker and the dock speaker, respectively
5478 */
56798e6b
TI
5479 rename_ctl(codec, "Speaker Playback Switch",
5480 "Dock Speaker Playback Switch");
5481 rename_ctl(codec, "Bass Speaker Playback Switch",
5482 "Speaker Playback Switch");
7bba2157
TI
5483 break;
5484 }
5485}
5486
338cae56
DH
5487static void alc290_fixup_mono_speakers(struct hda_codec *codec,
5488 const struct hda_fixup *fix, int action)
5489{
0f4881dc
DH
5490 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5491 /* DAC node 0x03 is giving mono output. We therefore want to
5492 make sure 0x14 (front speaker) and 0x15 (headphones) use the
5493 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
5494 hda_nid_t conn1[2] = { 0x0c };
5495 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
5496 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
5497 }
338cae56
DH
5498}
5499
dd9aa335
HW
5500static void alc298_fixup_speaker_volume(struct hda_codec *codec,
5501 const struct hda_fixup *fix, int action)
5502{
5503 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5504 /* The speaker is routed to the Node 0x06 by a mistake, as a result
5505 we can't adjust the speaker's volume since this node does not has
5506 Amp-out capability. we change the speaker's route to:
5507 Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
5508 Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
5509 speaker's volume now. */
5510
5511 hda_nid_t conn1[1] = { 0x0c };
5512 snd_hda_override_conn_list(codec, 0x17, 1, conn1);
5513 }
5514}
5515
214839a8
TI
5516/* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
5517static void alc295_fixup_disable_dac3(struct hda_codec *codec,
5518 const struct hda_fixup *fix, int action)
5519{
5520 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5521 hda_nid_t conn[2] = { 0x02, 0x03 };
5522 snd_hda_override_conn_list(codec, 0x17, 2, conn);
5523 }
5524}
5525
294f6c04
JK
5526/* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
5527static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
5528 const struct hda_fixup *fix, int action)
5529{
5530 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5531 hda_nid_t conn[1] = { 0x02 };
5532 snd_hda_override_conn_list(codec, 0x17, 1, conn);
5533 }
5534}
5535
98973f2f
KP
5536/* Hook to update amp GPIO4 for automute */
5537static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
5538 struct hda_jack_callback *jack)
5539{
5540 struct alc_spec *spec = codec->spec;
5541
5542 snd_hda_gen_hp_automute(codec, jack);
5543 /* mute_led_polarity is set to 0, so we pass inverted value here */
5544 alc_update_gpio_led(codec, 0x10, !spec->gen.hp_jack_present);
5545}
5546
5547/* Manage GPIOs for HP EliteBook Folio 9480m.
5548 *
5549 * GPIO4 is the headphone amplifier power control
5550 * GPIO3 is the audio output mute indicator LED
5551 */
5552
5553static void alc280_fixup_hp_9480m(struct hda_codec *codec,
5554 const struct hda_fixup *fix,
5555 int action)
5556{
5557 struct alc_spec *spec = codec->spec;
5558 static const struct hda_verb gpio_init[] = {
5559 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
5560 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
5561 {}
5562 };
5563
5564 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5565 /* Set the hooks to turn the headphone amp on/off
5566 * as needed
5567 */
5568 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
5569 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
5570
5571 /* The GPIOs are currently off */
5572 spec->gpio_led = 0;
5573
5574 /* GPIO3 is connected to the output mute LED,
5575 * high is on, low is off
5576 */
5577 spec->mute_led_polarity = 0;
5578 spec->gpio_mute_led_mask = 0x08;
5579
5580 /* Initialize GPIO configuration */
5581 snd_hda_add_verbs(codec, gpio_init);
5582 }
5583}
5584
ca169cc2
KY
5585static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
5586 const struct hda_fixup *fix,
5587 int action)
5588{
5589 alc_fixup_dual_codecs(codec, fix, action);
5590 switch (action) {
5591 case HDA_FIXUP_ACT_PRE_PROBE:
5592 /* override card longname to provide a unique UCM profile */
5593 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
5594 break;
5595 case HDA_FIXUP_ACT_BUILD:
5596 /* rename Capture controls depending on the codec */
5597 rename_ctl(codec, "Capture Volume",
5598 codec->addr == 0 ?
5599 "Rear-Panel Capture Volume" :
5600 "Front-Panel Capture Volume");
5601 rename_ctl(codec, "Capture Switch",
5602 codec->addr == 0 ?
5603 "Rear-Panel Capture Switch" :
5604 "Front-Panel Capture Switch");
5605 break;
5606 }
5607}
5608
92266651
KY
5609/* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
5610static void alc274_fixup_bind_dacs(struct hda_codec *codec,
5611 const struct hda_fixup *fix, int action)
5612{
5613 struct alc_spec *spec = codec->spec;
5614 static hda_nid_t preferred_pairs[] = {
5615 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
5616 0
5617 };
5618
5619 if (action != HDA_FIXUP_ACT_PRE_PROBE)
5620 return;
5621
5622 spec->gen.preferred_dacs = preferred_pairs;
fde563b0
KY
5623 spec->gen.auto_mute_via_amp = 1;
5624 codec->power_save_node = 0;
92266651
KY
5625}
5626
ea7118da
HW
5627/* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
5628static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
5629 const struct hda_fixup *fix, int action)
5630{
5631 if (action != HDA_FIXUP_ACT_PRE_PROBE)
5632 return;
5633
5634 snd_hda_override_wcaps(codec, 0x03, 0);
5635}
5636
f4ccb37c
KY
5637static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
5638 const struct hda_fixup *fix, int action)
5639{
5640 if (action == HDA_FIXUP_ACT_PRE_PROBE)
5641 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5642}
5643
b317b032
TI
5644/* for hda_fixup_thinkpad_acpi() */
5645#include "thinkpad_helper.c"
b67ae3f1 5646
2ae22638
TI
5647static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
5648 const struct hda_fixup *fix, int action)
5649{
5650 alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
5651 hda_fixup_thinkpad_acpi(codec, fix, action);
5652}
5653
00ef9940
HW
5654/* for dell wmi mic mute led */
5655#include "dell_wmi_helper.c"
5656
1d045db9
TI
5657enum {
5658 ALC269_FIXUP_SONY_VAIO,
5659 ALC275_FIXUP_SONY_VAIO_GPIO2,
5660 ALC269_FIXUP_DELL_M101Z,
5661 ALC269_FIXUP_SKU_IGNORE,
5662 ALC269_FIXUP_ASUS_G73JW,
5663 ALC269_FIXUP_LENOVO_EAPD,
5664 ALC275_FIXUP_SONY_HWEQ,
e9bd7d5c 5665 ALC275_FIXUP_SONY_DISABLE_AAMIX,
1d045db9 5666 ALC271_FIXUP_DMIC,
017f2a10 5667 ALC269_FIXUP_PCM_44K,
adabb3ec 5668 ALC269_FIXUP_STEREO_DMIC,
7c478f03 5669 ALC269_FIXUP_HEADSET_MIC,
24519911
TI
5670 ALC269_FIXUP_QUANTA_MUTE,
5671 ALC269_FIXUP_LIFEBOOK,
2041d564 5672 ALC269_FIXUP_LIFEBOOK_EXTMIC,
cc7016ab 5673 ALC269_FIXUP_LIFEBOOK_HP_PIN,
4df3fd17 5674 ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
0dcd451c 5675 ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
a4297b5d
TI
5676 ALC269_FIXUP_AMIC,
5677 ALC269_FIXUP_DMIC,
5678 ALC269VB_FIXUP_AMIC,
5679 ALC269VB_FIXUP_DMIC,
08fb0d0e 5680 ALC269_FIXUP_HP_MUTE_LED,
d06ac143 5681 ALC269_FIXUP_HP_MUTE_LED_MIC1,
08fb0d0e 5682 ALC269_FIXUP_HP_MUTE_LED_MIC2,
8062159a 5683 ALC269_FIXUP_HP_MUTE_LED_MIC3,
9f5c6faf 5684 ALC269_FIXUP_HP_GPIO_LED,
9c5dc3bf
KY
5685 ALC269_FIXUP_HP_GPIO_MIC1_LED,
5686 ALC269_FIXUP_HP_LINE1_MIC1_LED,
693b613d 5687 ALC269_FIXUP_INV_DMIC,
108cc108 5688 ALC269_FIXUP_LENOVO_DOCK,
9b745ab8 5689 ALC269_FIXUP_NO_SHUTUP,
88cfcf86 5690 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
108cc108 5691 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
73bdd597
DH
5692 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5693 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
338cae56 5694 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
fcc6c877 5695 ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
73bdd597
DH
5696 ALC269_FIXUP_HEADSET_MODE,
5697 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
7819717b 5698 ALC269_FIXUP_ASPIRE_HEADSET_MIC,
d240d1dc
DH
5699 ALC269_FIXUP_ASUS_X101_FUNC,
5700 ALC269_FIXUP_ASUS_X101_VERB,
5701 ALC269_FIXUP_ASUS_X101,
08a978db
DR
5702 ALC271_FIXUP_AMIC_MIC2,
5703 ALC271_FIXUP_HP_GATE_MIC_JACK,
b1e8972e 5704 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
42397004 5705 ALC269_FIXUP_ACER_AC700,
3e0d611b 5706 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
2cede303 5707 ALC269VB_FIXUP_ASUS_ZENBOOK,
23870831 5708 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
8e35cd4a 5709 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
02b504d9 5710 ALC269VB_FIXUP_ORDISSIMO_EVE2,
cd217a63 5711 ALC283_FIXUP_CHROME_BOOK,
0202e99c 5712 ALC283_FIXUP_SENSE_COMBO_JACK,
7bba2157 5713 ALC282_FIXUP_ASUS_TX300,
1bb3e062 5714 ALC283_FIXUP_INT_MIC,
338cae56 5715 ALC290_FIXUP_MONO_SPEAKERS,
0f4881dc
DH
5716 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5717 ALC290_FIXUP_SUBWOOFER,
5718 ALC290_FIXUP_SUBWOOFER_HSJACK,
b67ae3f1 5719 ALC269_FIXUP_THINKPAD_ACPI,
56f27013 5720 ALC269_FIXUP_DMIC_THINKPAD_ACPI,
5824ce8d 5721 ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
615966ad 5722 ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9a22a8f5 5723 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
31278997 5724 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9a22a8f5 5725 ALC255_FIXUP_HEADSET_MODE,
31278997 5726 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
a22aa26f 5727 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
1c37c223 5728 ALC292_FIXUP_TPT440_DOCK,
9a811230 5729 ALC292_FIXUP_TPT440,
abaa2274 5730 ALC283_FIXUP_HEADSET_MIC,
00ef9940 5731 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
1a22e775 5732 ALC282_FIXUP_ASPIRE_V5_PINS,
7a5255f1 5733 ALC280_FIXUP_HP_GPIO4,
eaa8e5ef 5734 ALC286_FIXUP_HP_GPIO_LED,
33f4acd3 5735 ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
b4b33f9d 5736 ALC280_FIXUP_HP_DOCK_PINS,
04d5466a 5737 ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
98973f2f 5738 ALC280_FIXUP_HP_9480M,
e1e62b98
KY
5739 ALC288_FIXUP_DELL_HEADSET_MODE,
5740 ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
5741 ALC288_FIXUP_DELL_XPS_13_GPIO6,
831bfdf9
HW
5742 ALC288_FIXUP_DELL_XPS_13,
5743 ALC288_FIXUP_DISABLE_AAMIX,
8b99aba7
TI
5744 ALC292_FIXUP_DELL_E7X,
5745 ALC292_FIXUP_DISABLE_AAMIX,
c04017ea 5746 ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
977e6276 5747 ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
2f726aec 5748 ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6ed1131f 5749 ALC275_FIXUP_DELL_XPS,
8c69729b 5750 ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE,
a2fe1dc7 5751 ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2,
23adc192 5752 ALC293_FIXUP_LENOVO_SPK_NOISE,
3694cb29 5753 ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
3b43b71f 5754 ALC255_FIXUP_DELL_SPK_NOISE,
f4ccb37c 5755 ALC225_FIXUP_DISABLE_MIC_VREF,
2ae95577 5756 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
214839a8 5757 ALC295_FIXUP_DISABLE_DAC3,
294f6c04 5758 ALC285_FIXUP_SPEAKER2_TO_DAC1,
f883982d 5759 ALC280_FIXUP_HP_HEADSET_MIC,
e549d190 5760 ALC221_FIXUP_HP_FRONT_MIC,
c636b95e 5761 ALC292_FIXUP_TPT460,
dd9aa335 5762 ALC298_FIXUP_SPK_VOLUME,
fd06c77e 5763 ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
823ff161 5764 ALC269_FIXUP_ATIV_BOOK_8,
9eb5d0e6 5765 ALC221_FIXUP_HP_MIC_NO_PRESENCE,
c1732ede
CC
5766 ALC256_FIXUP_ASUS_HEADSET_MODE,
5767 ALC256_FIXUP_ASUS_MIC,
eeed4cd1 5768 ALC256_FIXUP_ASUS_AIO_GPIO2,
216d7aeb
CC
5769 ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
5770 ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
ca169cc2 5771 ALC233_FIXUP_LENOVO_MULTI_CODECS,
f33f79f3 5772 ALC294_FIXUP_LENOVO_MIC_LOCATION,
9423a273 5773 ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
b84e8436 5774 ALC700_FIXUP_INTEL_REFERENCE,
92266651
KY
5775 ALC274_FIXUP_DELL_BIND_DACS,
5776 ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
114745cd 5777 ALC298_FIXUP_TPT470_DOCK,
9cfdabca 5778 ALC255_FIXUP_DUMMY_LINEOUT_VERB,
4c574ad4 5779 ALC255_FIXUP_DELL_HEADSET_MIC,
531802e2 5780 ALC256_FIXUP_HUAWEI_MBXP_PINS,
32e2ee86 5781 ALC221_FIXUP_HP_HEADSET_MIC,
ea7118da 5782 ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
9c54c712 5783 ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
0a60c116 5784 ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
09416ef0 5785 ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
dad6c4f4 5786 ALC294_FIXUP_ASUS_MIC,
7398055e
JHP
5787 ALC294_FIXUP_ASUS_HEADSET_MIC,
5788 ALC294_FIXUP_ASUS_SPK,
20616fb0
KY
5789 ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
5790 ALC225_FIXUP_WYSE_AUTO_MUTE,
5791 ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
1a1fcf1f 5792 ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
6454939d 5793 ALC256_FIXUP_ASUS_HEADSET_MIC,
4f7f74da 5794 ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
128a4c8d 5795 ALC299_FIXUP_PREDATOR_SPK,
e77aee2f 5796 ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC,
f52b4dcf 5797 ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
f1d4e28b
KY
5798};
5799
1727a771 5800static const struct hda_fixup alc269_fixups[] = {
1d045db9 5801 [ALC269_FIXUP_SONY_VAIO] = {
fd108215
TI
5802 .type = HDA_FIXUP_PINCTLS,
5803 .v.pins = (const struct hda_pintbl[]) {
5804 {0x19, PIN_VREFGRD},
1d045db9
TI
5805 {}
5806 }
f1d4e28b 5807 },
1d045db9 5808 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
1727a771 5809 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5810 .v.verbs = (const struct hda_verb[]) {
5811 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
5812 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
5813 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5814 { }
5815 },
5816 .chained = true,
5817 .chain_id = ALC269_FIXUP_SONY_VAIO
5818 },
5819 [ALC269_FIXUP_DELL_M101Z] = {
1727a771 5820 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5821 .v.verbs = (const struct hda_verb[]) {
5822 /* Enables internal speaker */
5823 {0x20, AC_VERB_SET_COEF_INDEX, 13},
5824 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5825 {}
5826 }
5827 },
5828 [ALC269_FIXUP_SKU_IGNORE] = {
1727a771 5829 .type = HDA_FIXUP_FUNC,
23d30f28 5830 .v.func = alc_fixup_sku_ignore,
1d045db9
TI
5831 },
5832 [ALC269_FIXUP_ASUS_G73JW] = {
1727a771
TI
5833 .type = HDA_FIXUP_PINS,
5834 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
5835 { 0x17, 0x99130111 }, /* subwoofer */
5836 { }
5837 }
5838 },
5839 [ALC269_FIXUP_LENOVO_EAPD] = {
1727a771 5840 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5841 .v.verbs = (const struct hda_verb[]) {
5842 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5843 {}
5844 }
5845 },
5846 [ALC275_FIXUP_SONY_HWEQ] = {
1727a771 5847 .type = HDA_FIXUP_FUNC,
1d045db9
TI
5848 .v.func = alc269_fixup_hweq,
5849 .chained = true,
5850 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5851 },
e9bd7d5c
TI
5852 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
5853 .type = HDA_FIXUP_FUNC,
5854 .v.func = alc_fixup_disable_aamix,
5855 .chained = true,
5856 .chain_id = ALC269_FIXUP_SONY_VAIO
5857 },
1d045db9 5858 [ALC271_FIXUP_DMIC] = {
1727a771 5859 .type = HDA_FIXUP_FUNC,
1d045db9 5860 .v.func = alc271_fixup_dmic,
f1d4e28b 5861 },
017f2a10 5862 [ALC269_FIXUP_PCM_44K] = {
1727a771 5863 .type = HDA_FIXUP_FUNC,
017f2a10 5864 .v.func = alc269_fixup_pcm_44k,
012e7eb1
DH
5865 .chained = true,
5866 .chain_id = ALC269_FIXUP_QUANTA_MUTE
017f2a10 5867 },
adabb3ec 5868 [ALC269_FIXUP_STEREO_DMIC] = {
1727a771 5869 .type = HDA_FIXUP_FUNC,
adabb3ec
TI
5870 .v.func = alc269_fixup_stereo_dmic,
5871 },
7c478f03
DH
5872 [ALC269_FIXUP_HEADSET_MIC] = {
5873 .type = HDA_FIXUP_FUNC,
5874 .v.func = alc269_fixup_headset_mic,
5875 },
24519911 5876 [ALC269_FIXUP_QUANTA_MUTE] = {
1727a771 5877 .type = HDA_FIXUP_FUNC,
24519911
TI
5878 .v.func = alc269_fixup_quanta_mute,
5879 },
5880 [ALC269_FIXUP_LIFEBOOK] = {
1727a771
TI
5881 .type = HDA_FIXUP_PINS,
5882 .v.pins = (const struct hda_pintbl[]) {
24519911
TI
5883 { 0x1a, 0x2101103f }, /* dock line-out */
5884 { 0x1b, 0x23a11040 }, /* dock mic-in */
5885 { }
5886 },
5887 .chained = true,
5888 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5889 },
2041d564
DH
5890 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
5891 .type = HDA_FIXUP_PINS,
5892 .v.pins = (const struct hda_pintbl[]) {
5893 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
5894 { }
5895 },
5896 },
cc7016ab
TI
5897 [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
5898 .type = HDA_FIXUP_PINS,
5899 .v.pins = (const struct hda_pintbl[]) {
5900 { 0x21, 0x0221102f }, /* HP out */
5901 { }
5902 },
5903 },
4df3fd17
TI
5904 [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
5905 .type = HDA_FIXUP_FUNC,
5906 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
5907 },
0dcd451c
JMG
5908 [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
5909 .type = HDA_FIXUP_FUNC,
5910 .v.func = alc269_fixup_pincfg_U7x7_headset_mic,
5911 },
a4297b5d 5912 [ALC269_FIXUP_AMIC] = {
1727a771
TI
5913 .type = HDA_FIXUP_PINS,
5914 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5915 { 0x14, 0x99130110 }, /* speaker */
5916 { 0x15, 0x0121401f }, /* HP out */
5917 { 0x18, 0x01a19c20 }, /* mic */
5918 { 0x19, 0x99a3092f }, /* int-mic */
5919 { }
5920 },
5921 },
5922 [ALC269_FIXUP_DMIC] = {
1727a771
TI
5923 .type = HDA_FIXUP_PINS,
5924 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5925 { 0x12, 0x99a3092f }, /* int-mic */
5926 { 0x14, 0x99130110 }, /* speaker */
5927 { 0x15, 0x0121401f }, /* HP out */
5928 { 0x18, 0x01a19c20 }, /* mic */
5929 { }
5930 },
5931 },
5932 [ALC269VB_FIXUP_AMIC] = {
1727a771
TI
5933 .type = HDA_FIXUP_PINS,
5934 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5935 { 0x14, 0x99130110 }, /* speaker */
5936 { 0x18, 0x01a19c20 }, /* mic */
5937 { 0x19, 0x99a3092f }, /* int-mic */
5938 { 0x21, 0x0121401f }, /* HP out */
5939 { }
5940 },
5941 },
2267ea97 5942 [ALC269VB_FIXUP_DMIC] = {
1727a771
TI
5943 .type = HDA_FIXUP_PINS,
5944 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5945 { 0x12, 0x99a3092f }, /* int-mic */
5946 { 0x14, 0x99130110 }, /* speaker */
5947 { 0x18, 0x01a19c20 }, /* mic */
5948 { 0x21, 0x0121401f }, /* HP out */
5949 { }
5950 },
5951 },
08fb0d0e 5952 [ALC269_FIXUP_HP_MUTE_LED] = {
1727a771 5953 .type = HDA_FIXUP_FUNC,
08fb0d0e 5954 .v.func = alc269_fixup_hp_mute_led,
6d3cd5d4 5955 },
d06ac143
DH
5956 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
5957 .type = HDA_FIXUP_FUNC,
5958 .v.func = alc269_fixup_hp_mute_led_mic1,
5959 },
08fb0d0e 5960 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
1727a771 5961 .type = HDA_FIXUP_FUNC,
08fb0d0e 5962 .v.func = alc269_fixup_hp_mute_led_mic2,
420b0feb 5963 },
8062159a
TB
5964 [ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
5965 .type = HDA_FIXUP_FUNC,
5966 .v.func = alc269_fixup_hp_mute_led_mic3,
5967 },
9f5c6faf
TI
5968 [ALC269_FIXUP_HP_GPIO_LED] = {
5969 .type = HDA_FIXUP_FUNC,
5970 .v.func = alc269_fixup_hp_gpio_led,
5971 },
9c5dc3bf
KY
5972 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
5973 .type = HDA_FIXUP_FUNC,
5974 .v.func = alc269_fixup_hp_gpio_mic1_led,
5975 },
5976 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
5977 .type = HDA_FIXUP_FUNC,
5978 .v.func = alc269_fixup_hp_line1_mic1_led,
5979 },
693b613d 5980 [ALC269_FIXUP_INV_DMIC] = {
1727a771 5981 .type = HDA_FIXUP_FUNC,
9d36a7dc 5982 .v.func = alc_fixup_inv_dmic,
693b613d 5983 },
9b745ab8
TI
5984 [ALC269_FIXUP_NO_SHUTUP] = {
5985 .type = HDA_FIXUP_FUNC,
5986 .v.func = alc_fixup_no_shutup,
5987 },
108cc108 5988 [ALC269_FIXUP_LENOVO_DOCK] = {
1727a771
TI
5989 .type = HDA_FIXUP_PINS,
5990 .v.pins = (const struct hda_pintbl[]) {
108cc108
DH
5991 { 0x19, 0x23a11040 }, /* dock mic */
5992 { 0x1b, 0x2121103f }, /* dock headphone */
5993 { }
5994 },
5995 .chained = true,
5996 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
5997 },
5998 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
1727a771 5999 .type = HDA_FIXUP_FUNC,
108cc108 6000 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
52129000
DH
6001 .chained = true,
6002 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
108cc108 6003 },
73bdd597
DH
6004 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6005 .type = HDA_FIXUP_PINS,
6006 .v.pins = (const struct hda_pintbl[]) {
6007 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6008 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6009 { }
6010 },
6011 .chained = true,
6012 .chain_id = ALC269_FIXUP_HEADSET_MODE
6013 },
6014 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6015 .type = HDA_FIXUP_PINS,
6016 .v.pins = (const struct hda_pintbl[]) {
6017 { 0x16, 0x21014020 }, /* dock line out */
6018 { 0x19, 0x21a19030 }, /* dock mic */
6019 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6020 { }
6021 },
6022 .chained = true,
6023 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6024 },
338cae56
DH
6025 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
6026 .type = HDA_FIXUP_PINS,
6027 .v.pins = (const struct hda_pintbl[]) {
6028 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6029 { }
6030 },
6031 .chained = true,
6032 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6033 },
fcc6c877
KY
6034 [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
6035 .type = HDA_FIXUP_PINS,
6036 .v.pins = (const struct hda_pintbl[]) {
6037 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6038 { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6039 { }
6040 },
6041 .chained = true,
6042 .chain_id = ALC269_FIXUP_HEADSET_MODE
6043 },
73bdd597
DH
6044 [ALC269_FIXUP_HEADSET_MODE] = {
6045 .type = HDA_FIXUP_FUNC,
6046 .v.func = alc_fixup_headset_mode,
6676f308
HW
6047 .chained = true,
6048 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
73bdd597
DH
6049 },
6050 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6051 .type = HDA_FIXUP_FUNC,
6052 .v.func = alc_fixup_headset_mode_no_hp_mic,
6053 },
7819717b
TI
6054 [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
6055 .type = HDA_FIXUP_PINS,
6056 .v.pins = (const struct hda_pintbl[]) {
6057 { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
6058 { }
6059 },
6060 .chained = true,
6061 .chain_id = ALC269_FIXUP_HEADSET_MODE,
6062 },
88cfcf86
DH
6063 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
6064 .type = HDA_FIXUP_PINS,
6065 .v.pins = (const struct hda_pintbl[]) {
6066 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6067 { }
6068 },
fbc78ad6
DH
6069 .chained = true,
6070 .chain_id = ALC269_FIXUP_HEADSET_MIC
88cfcf86 6071 },
531802e2
AB
6072 [ALC256_FIXUP_HUAWEI_MBXP_PINS] = {
6073 .type = HDA_FIXUP_PINS,
6074 .v.pins = (const struct hda_pintbl[]) {
6075 {0x12, 0x90a60130},
6076 {0x13, 0x40000000},
6077 {0x14, 0x90170110},
6078 {0x18, 0x411111f0},
6079 {0x19, 0x04a11040},
6080 {0x1a, 0x411111f0},
6081 {0x1b, 0x90170112},
6082 {0x1d, 0x40759a05},
6083 {0x1e, 0x411111f0},
6084 {0x21, 0x04211020},
6085 { }
6086 },
6087 },
d240d1dc
DH
6088 [ALC269_FIXUP_ASUS_X101_FUNC] = {
6089 .type = HDA_FIXUP_FUNC,
6090 .v.func = alc269_fixup_x101_headset_mic,
6091 },
6092 [ALC269_FIXUP_ASUS_X101_VERB] = {
6093 .type = HDA_FIXUP_VERBS,
6094 .v.verbs = (const struct hda_verb[]) {
6095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6096 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
6097 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
6098 { }
6099 },
6100 .chained = true,
6101 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
6102 },
6103 [ALC269_FIXUP_ASUS_X101] = {
6104 .type = HDA_FIXUP_PINS,
6105 .v.pins = (const struct hda_pintbl[]) {
6106 { 0x18, 0x04a1182c }, /* Headset mic */
6107 { }
6108 },
6109 .chained = true,
6110 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
6111 },
08a978db 6112 [ALC271_FIXUP_AMIC_MIC2] = {
1727a771
TI
6113 .type = HDA_FIXUP_PINS,
6114 .v.pins = (const struct hda_pintbl[]) {
08a978db
DR
6115 { 0x14, 0x99130110 }, /* speaker */
6116 { 0x19, 0x01a19c20 }, /* mic */
6117 { 0x1b, 0x99a7012f }, /* int-mic */
6118 { 0x21, 0x0121401f }, /* HP out */
6119 { }
6120 },
6121 },
6122 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
1727a771 6123 .type = HDA_FIXUP_FUNC,
08a978db
DR
6124 .v.func = alc271_hp_gate_mic_jack,
6125 .chained = true,
6126 .chain_id = ALC271_FIXUP_AMIC_MIC2,
6127 },
b1e8972e
OR
6128 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
6129 .type = HDA_FIXUP_FUNC,
6130 .v.func = alc269_fixup_limit_int_mic_boost,
6131 .chained = true,
6132 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
6133 },
42397004
DR
6134 [ALC269_FIXUP_ACER_AC700] = {
6135 .type = HDA_FIXUP_PINS,
6136 .v.pins = (const struct hda_pintbl[]) {
6137 { 0x12, 0x99a3092f }, /* int-mic */
6138 { 0x14, 0x99130110 }, /* speaker */
6139 { 0x18, 0x03a11c20 }, /* mic */
6140 { 0x1e, 0x0346101e }, /* SPDIF1 */
6141 { 0x21, 0x0321101f }, /* HP out */
6142 { }
6143 },
6144 .chained = true,
6145 .chain_id = ALC271_FIXUP_DMIC,
6146 },
3e0d611b
DH
6147 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
6148 .type = HDA_FIXUP_FUNC,
6149 .v.func = alc269_fixup_limit_int_mic_boost,
2793769f
DH
6150 .chained = true,
6151 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
3e0d611b 6152 },
2cede303
OR
6153 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
6154 .type = HDA_FIXUP_FUNC,
6155 .v.func = alc269_fixup_limit_int_mic_boost,
6156 .chained = true,
6157 .chain_id = ALC269VB_FIXUP_DMIC,
6158 },
23870831
TI
6159 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
6160 .type = HDA_FIXUP_VERBS,
6161 .v.verbs = (const struct hda_verb[]) {
6162 /* class-D output amp +5dB */
6163 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
6164 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
6165 {}
6166 },
6167 .chained = true,
6168 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
6169 },
8e35cd4a
DH
6170 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
6171 .type = HDA_FIXUP_FUNC,
6172 .v.func = alc269_fixup_limit_int_mic_boost,
6173 .chained = true,
6174 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
6175 },
02b504d9
AA
6176 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
6177 .type = HDA_FIXUP_PINS,
6178 .v.pins = (const struct hda_pintbl[]) {
6179 { 0x12, 0x99a3092f }, /* int-mic */
6180 { 0x18, 0x03a11d20 }, /* mic */
6181 { 0x19, 0x411111f0 }, /* Unused bogus pin */
6182 { }
6183 },
6184 },
cd217a63
KY
6185 [ALC283_FIXUP_CHROME_BOOK] = {
6186 .type = HDA_FIXUP_FUNC,
6187 .v.func = alc283_fixup_chromebook,
6188 },
0202e99c
KY
6189 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
6190 .type = HDA_FIXUP_FUNC,
6191 .v.func = alc283_fixup_sense_combo_jack,
6192 .chained = true,
6193 .chain_id = ALC283_FIXUP_CHROME_BOOK,
6194 },
7bba2157
TI
6195 [ALC282_FIXUP_ASUS_TX300] = {
6196 .type = HDA_FIXUP_FUNC,
6197 .v.func = alc282_fixup_asus_tx300,
6198 },
1bb3e062
KY
6199 [ALC283_FIXUP_INT_MIC] = {
6200 .type = HDA_FIXUP_VERBS,
6201 .v.verbs = (const struct hda_verb[]) {
6202 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
6203 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
6204 { }
6205 },
6206 .chained = true,
6207 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6208 },
0f4881dc
DH
6209 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
6210 .type = HDA_FIXUP_PINS,
6211 .v.pins = (const struct hda_pintbl[]) {
6212 { 0x17, 0x90170112 }, /* subwoofer */
6213 { }
6214 },
6215 .chained = true,
6216 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6217 },
6218 [ALC290_FIXUP_SUBWOOFER] = {
6219 .type = HDA_FIXUP_PINS,
6220 .v.pins = (const struct hda_pintbl[]) {
6221 { 0x17, 0x90170112 }, /* subwoofer */
6222 { }
6223 },
6224 .chained = true,
6225 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
6226 },
338cae56
DH
6227 [ALC290_FIXUP_MONO_SPEAKERS] = {
6228 .type = HDA_FIXUP_FUNC,
6229 .v.func = alc290_fixup_mono_speakers,
0f4881dc
DH
6230 },
6231 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
6232 .type = HDA_FIXUP_FUNC,
6233 .v.func = alc290_fixup_mono_speakers,
338cae56
DH
6234 .chained = true,
6235 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6236 },
b67ae3f1
DH
6237 [ALC269_FIXUP_THINKPAD_ACPI] = {
6238 .type = HDA_FIXUP_FUNC,
2ae22638 6239 .v.func = alc_fixup_thinkpad_acpi,
09da111a
TI
6240 .chained = true,
6241 .chain_id = ALC269_FIXUP_SKU_IGNORE,
b67ae3f1 6242 },
56f27013
DH
6243 [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
6244 .type = HDA_FIXUP_FUNC,
6245 .v.func = alc_fixup_inv_dmic,
6246 .chained = true,
6247 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6248 },
5824ce8d
CC
6249 [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
6250 .type = HDA_FIXUP_PINS,
6251 .v.pins = (const struct hda_pintbl[]) {
6252 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6253 { }
6254 },
6255 .chained = true,
6256 .chain_id = ALC255_FIXUP_HEADSET_MODE
6257 },
615966ad
CC
6258 [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6259 .type = HDA_FIXUP_PINS,
6260 .v.pins = (const struct hda_pintbl[]) {
6261 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6262 { }
6263 },
6264 .chained = true,
6265 .chain_id = ALC255_FIXUP_HEADSET_MODE
6266 },
9a22a8f5
KY
6267 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6268 .type = HDA_FIXUP_PINS,
6269 .v.pins = (const struct hda_pintbl[]) {
6270 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6271 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6272 { }
6273 },
6274 .chained = true,
6275 .chain_id = ALC255_FIXUP_HEADSET_MODE
6276 },
31278997
KY
6277 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6278 .type = HDA_FIXUP_PINS,
6279 .v.pins = (const struct hda_pintbl[]) {
6280 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6281 { }
6282 },
6283 .chained = true,
6284 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
6285 },
9a22a8f5
KY
6286 [ALC255_FIXUP_HEADSET_MODE] = {
6287 .type = HDA_FIXUP_FUNC,
6288 .v.func = alc_fixup_headset_mode_alc255,
4a83d42a
HW
6289 .chained = true,
6290 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
9a22a8f5 6291 },
31278997
KY
6292 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6293 .type = HDA_FIXUP_FUNC,
6294 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
6295 },
a22aa26f
KY
6296 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6297 .type = HDA_FIXUP_PINS,
6298 .v.pins = (const struct hda_pintbl[]) {
6299 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6300 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6301 { }
6302 },
6303 .chained = true,
6304 .chain_id = ALC269_FIXUP_HEADSET_MODE
6305 },
1c37c223 6306 [ALC292_FIXUP_TPT440_DOCK] = {
ec56af67 6307 .type = HDA_FIXUP_FUNC,
7f57d803 6308 .v.func = alc_fixup_tpt440_dock,
1c37c223
TI
6309 .chained = true,
6310 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6311 },
9a811230
TI
6312 [ALC292_FIXUP_TPT440] = {
6313 .type = HDA_FIXUP_FUNC,
157f0b7f 6314 .v.func = alc_fixup_disable_aamix,
9a811230
TI
6315 .chained = true,
6316 .chain_id = ALC292_FIXUP_TPT440_DOCK,
6317 },
abaa2274 6318 [ALC283_FIXUP_HEADSET_MIC] = {
9dc12862
DD
6319 .type = HDA_FIXUP_PINS,
6320 .v.pins = (const struct hda_pintbl[]) {
6321 { 0x19, 0x04a110f0 },
6322 { },
6323 },
6324 },
00ef9940
HW
6325 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
6326 .type = HDA_FIXUP_FUNC,
6327 .v.func = alc_fixup_dell_wmi,
00ef9940 6328 },
1a22e775
TI
6329 [ALC282_FIXUP_ASPIRE_V5_PINS] = {
6330 .type = HDA_FIXUP_PINS,
6331 .v.pins = (const struct hda_pintbl[]) {
6332 { 0x12, 0x90a60130 },
6333 { 0x14, 0x90170110 },
6334 { 0x17, 0x40000008 },
6335 { 0x18, 0x411111f0 },
0420694d 6336 { 0x19, 0x01a1913c },
1a22e775
TI
6337 { 0x1a, 0x411111f0 },
6338 { 0x1b, 0x411111f0 },
6339 { 0x1d, 0x40f89b2d },
6340 { 0x1e, 0x411111f0 },
6341 { 0x21, 0x0321101f },
6342 { },
6343 },
6344 },
7a5255f1
DH
6345 [ALC280_FIXUP_HP_GPIO4] = {
6346 .type = HDA_FIXUP_FUNC,
6347 .v.func = alc280_fixup_hp_gpio4,
6348 },
eaa8e5ef
KY
6349 [ALC286_FIXUP_HP_GPIO_LED] = {
6350 .type = HDA_FIXUP_FUNC,
6351 .v.func = alc286_fixup_hp_gpio_led,
6352 },
33f4acd3
DH
6353 [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
6354 .type = HDA_FIXUP_FUNC,
6355 .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
6356 },
b4b33f9d
TC
6357 [ALC280_FIXUP_HP_DOCK_PINS] = {
6358 .type = HDA_FIXUP_PINS,
6359 .v.pins = (const struct hda_pintbl[]) {
6360 { 0x1b, 0x21011020 }, /* line-out */
6361 { 0x1a, 0x01a1903c }, /* headset mic */
6362 { 0x18, 0x2181103f }, /* line-in */
6363 { },
6364 },
6365 .chained = true,
6366 .chain_id = ALC280_FIXUP_HP_GPIO4
6367 },
04d5466a
JK
6368 [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
6369 .type = HDA_FIXUP_PINS,
6370 .v.pins = (const struct hda_pintbl[]) {
6371 { 0x1b, 0x21011020 }, /* line-out */
6372 { 0x18, 0x2181103f }, /* line-in */
6373 { },
6374 },
6375 .chained = true,
6376 .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
6377 },
98973f2f
KP
6378 [ALC280_FIXUP_HP_9480M] = {
6379 .type = HDA_FIXUP_FUNC,
6380 .v.func = alc280_fixup_hp_9480m,
6381 },
e1e62b98
KY
6382 [ALC288_FIXUP_DELL_HEADSET_MODE] = {
6383 .type = HDA_FIXUP_FUNC,
6384 .v.func = alc_fixup_headset_mode_dell_alc288,
6385 .chained = true,
6386 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
6387 },
6388 [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6389 .type = HDA_FIXUP_PINS,
6390 .v.pins = (const struct hda_pintbl[]) {
6391 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6392 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6393 { }
6394 },
6395 .chained = true,
6396 .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
6397 },
6398 [ALC288_FIXUP_DELL_XPS_13_GPIO6] = {
6399 .type = HDA_FIXUP_VERBS,
6400 .v.verbs = (const struct hda_verb[]) {
6401 {0x01, AC_VERB_SET_GPIO_MASK, 0x40},
6402 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x40},
6403 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6404 { }
6405 },
6406 .chained = true,
6407 .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
6408 },
831bfdf9
HW
6409 [ALC288_FIXUP_DISABLE_AAMIX] = {
6410 .type = HDA_FIXUP_FUNC,
6411 .v.func = alc_fixup_disable_aamix,
6412 .chained = true,
6413 .chain_id = ALC288_FIXUP_DELL_XPS_13_GPIO6
6414 },
6415 [ALC288_FIXUP_DELL_XPS_13] = {
6416 .type = HDA_FIXUP_FUNC,
6417 .v.func = alc_fixup_dell_xps13,
6418 .chained = true,
6419 .chain_id = ALC288_FIXUP_DISABLE_AAMIX
6420 },
8b99aba7
TI
6421 [ALC292_FIXUP_DISABLE_AAMIX] = {
6422 .type = HDA_FIXUP_FUNC,
6423 .v.func = alc_fixup_disable_aamix,
831bfdf9
HW
6424 .chained = true,
6425 .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
8b99aba7 6426 },
c04017ea
DH
6427 [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
6428 .type = HDA_FIXUP_FUNC,
6429 .v.func = alc_fixup_disable_aamix,
6430 .chained = true,
6431 .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
6432 },
8b99aba7
TI
6433 [ALC292_FIXUP_DELL_E7X] = {
6434 .type = HDA_FIXUP_FUNC,
6435 .v.func = alc_fixup_dell_xps13,
6436 .chained = true,
6437 .chain_id = ALC292_FIXUP_DISABLE_AAMIX
6438 },
977e6276
KY
6439 [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6440 .type = HDA_FIXUP_PINS,
6441 .v.pins = (const struct hda_pintbl[]) {
6442 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6443 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6444 { }
6445 },
6446 .chained = true,
6447 .chain_id = ALC269_FIXUP_HEADSET_MODE
6448 },
2f726aec
HW
6449 [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
6450 .type = HDA_FIXUP_PINS,
6451 .v.pins = (const struct hda_pintbl[]) {
6452 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6453 { }
6454 },
6455 .chained = true,
6456 .chain_id = ALC269_FIXUP_HEADSET_MODE
6457 },
6ed1131f
KY
6458 [ALC275_FIXUP_DELL_XPS] = {
6459 .type = HDA_FIXUP_VERBS,
6460 .v.verbs = (const struct hda_verb[]) {
6461 /* Enables internal speaker */
6462 {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
6463 {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
6464 {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
6465 {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
6466 {}
6467 }
6468 },
8c69729b
HW
6469 [ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE] = {
6470 .type = HDA_FIXUP_VERBS,
6471 .v.verbs = (const struct hda_verb[]) {
6472 /* Disable pass-through path for FRONT 14h */
6473 {0x20, AC_VERB_SET_COEF_INDEX, 0x36},
6474 {0x20, AC_VERB_SET_PROC_COEF, 0x1737},
6475 {}
6476 },
6477 .chained = true,
6478 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6479 },
a2fe1dc7
KHF
6480 [ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2] = {
6481 .type = HDA_FIXUP_FUNC,
6482 .v.func = alc256_fixup_dell_xps_13_headphone_noise2,
6483 .chained = true,
6484 .chain_id = ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE
6485 },
23adc192
HW
6486 [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
6487 .type = HDA_FIXUP_FUNC,
6488 .v.func = alc_fixup_disable_aamix,
6489 .chained = true,
6490 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
6491 },
3694cb29
K
6492 [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
6493 .type = HDA_FIXUP_FUNC,
6494 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
6495 },
3b43b71f
KHF
6496 [ALC255_FIXUP_DELL_SPK_NOISE] = {
6497 .type = HDA_FIXUP_FUNC,
6498 .v.func = alc_fixup_disable_aamix,
6499 .chained = true,
6500 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6501 },
f4ccb37c
KY
6502 [ALC225_FIXUP_DISABLE_MIC_VREF] = {
6503 .type = HDA_FIXUP_FUNC,
6504 .v.func = alc_fixup_disable_mic_vref,
6505 .chained = true,
6506 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6507 },
2ae95577
DH
6508 [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6509 .type = HDA_FIXUP_VERBS,
6510 .v.verbs = (const struct hda_verb[]) {
6511 /* Disable pass-through path for FRONT 14h */
6512 { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6513 { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6514 {}
6515 },
6516 .chained = true,
f4ccb37c 6517 .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
2ae95577 6518 },
f883982d
TI
6519 [ALC280_FIXUP_HP_HEADSET_MIC] = {
6520 .type = HDA_FIXUP_FUNC,
6521 .v.func = alc_fixup_disable_aamix,
6522 .chained = true,
6523 .chain_id = ALC269_FIXUP_HEADSET_MIC,
6524 },
e549d190
HW
6525 [ALC221_FIXUP_HP_FRONT_MIC] = {
6526 .type = HDA_FIXUP_PINS,
6527 .v.pins = (const struct hda_pintbl[]) {
6528 { 0x19, 0x02a19020 }, /* Front Mic */
6529 { }
6530 },
6531 },
c636b95e
SE
6532 [ALC292_FIXUP_TPT460] = {
6533 .type = HDA_FIXUP_FUNC,
6534 .v.func = alc_fixup_tpt440_dock,
6535 .chained = true,
6536 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
6537 },
dd9aa335
HW
6538 [ALC298_FIXUP_SPK_VOLUME] = {
6539 .type = HDA_FIXUP_FUNC,
6540 .v.func = alc298_fixup_speaker_volume,
59ec4b57 6541 .chained = true,
2f726aec 6542 .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
dd9aa335 6543 },
214839a8
TI
6544 [ALC295_FIXUP_DISABLE_DAC3] = {
6545 .type = HDA_FIXUP_FUNC,
6546 .v.func = alc295_fixup_disable_dac3,
6547 },
294f6c04
JK
6548 [ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
6549 .type = HDA_FIXUP_FUNC,
6550 .v.func = alc285_fixup_speaker2_to_dac1,
debf2e4b
HW
6551 .chained = true,
6552 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
294f6c04 6553 },
fd06c77e
KHF
6554 [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
6555 .type = HDA_FIXUP_PINS,
6556 .v.pins = (const struct hda_pintbl[]) {
6557 { 0x1b, 0x90170151 },
6558 { }
6559 },
6560 .chained = true,
6561 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6562 },
823ff161
GM
6563 [ALC269_FIXUP_ATIV_BOOK_8] = {
6564 .type = HDA_FIXUP_FUNC,
6565 .v.func = alc_fixup_auto_mute_via_amp,
6566 .chained = true,
6567 .chain_id = ALC269_FIXUP_NO_SHUTUP
6568 },
9eb5d0e6
KY
6569 [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
6570 .type = HDA_FIXUP_PINS,
6571 .v.pins = (const struct hda_pintbl[]) {
6572 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6573 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6574 { }
6575 },
6576 .chained = true,
6577 .chain_id = ALC269_FIXUP_HEADSET_MODE
6578 },
c1732ede
CC
6579 [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
6580 .type = HDA_FIXUP_FUNC,
6581 .v.func = alc_fixup_headset_mode,
6582 },
6583 [ALC256_FIXUP_ASUS_MIC] = {
6584 .type = HDA_FIXUP_PINS,
6585 .v.pins = (const struct hda_pintbl[]) {
6586 { 0x13, 0x90a60160 }, /* use as internal mic */
6587 { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6588 { }
6589 },
6590 .chained = true,
6591 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6592 },
eeed4cd1
CC
6593 [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
6594 .type = HDA_FIXUP_VERBS,
6595 .v.verbs = (const struct hda_verb[]) {
6596 /* Set up GPIO2 for the speaker amp */
6597 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
6598 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
6599 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
6600 {}
6601 },
6602 },
216d7aeb
CC
6603 [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6604 .type = HDA_FIXUP_PINS,
6605 .v.pins = (const struct hda_pintbl[]) {
6606 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6607 { }
6608 },
6609 .chained = true,
6610 .chain_id = ALC269_FIXUP_HEADSET_MIC
6611 },
6612 [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
6613 .type = HDA_FIXUP_VERBS,
6614 .v.verbs = (const struct hda_verb[]) {
6615 /* Enables internal speaker */
6616 {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
6617 {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
6618 {}
6619 },
6620 .chained = true,
6621 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6622 },
ca169cc2
KY
6623 [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
6624 .type = HDA_FIXUP_FUNC,
6625 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
6626 },
f33f79f3
HW
6627 [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
6628 .type = HDA_FIXUP_PINS,
6629 .v.pins = (const struct hda_pintbl[]) {
6630 /* Change the mic location from front to right, otherwise there are
6631 two front mics with the same name, pulseaudio can't handle them.
6632 This is just a temporary workaround, after applying this fixup,
6633 there will be one "Front Mic" and one "Mic" in this machine.
6634 */
6635 { 0x1a, 0x04a19040 },
6636 { }
6637 },
6638 },
9423a273
KY
6639 [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
6640 .type = HDA_FIXUP_PINS,
6641 .v.pins = (const struct hda_pintbl[]) {
6642 { 0x16, 0x0101102f }, /* Rear Headset HP */
6643 { 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
6644 { 0x1a, 0x01a19030 }, /* Rear Headset MIC */
6645 { 0x1b, 0x02011020 },
6646 { }
6647 },
6648 .chained = true,
6649 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6650 },
b84e8436
PH
6651 [ALC700_FIXUP_INTEL_REFERENCE] = {
6652 .type = HDA_FIXUP_VERBS,
6653 .v.verbs = (const struct hda_verb[]) {
6654 /* Enables internal speaker */
6655 {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
6656 {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
6657 {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
6658 {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
6659 {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
6660 {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
6661 {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
6662 {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
6663 {}
6664 }
6665 },
92266651
KY
6666 [ALC274_FIXUP_DELL_BIND_DACS] = {
6667 .type = HDA_FIXUP_FUNC,
6668 .v.func = alc274_fixup_bind_dacs,
6669 .chained = true,
6670 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6671 },
6672 [ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
6673 .type = HDA_FIXUP_PINS,
6674 .v.pins = (const struct hda_pintbl[]) {
6675 { 0x1b, 0x0401102f },
6676 { }
6677 },
6678 .chained = true,
6679 .chain_id = ALC274_FIXUP_DELL_BIND_DACS
6680 },
114745cd
KY
6681 [ALC298_FIXUP_TPT470_DOCK] = {
6682 .type = HDA_FIXUP_FUNC,
6683 .v.func = alc_fixup_tpt470_dock,
6684 .chained = true,
6685 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
6686 },
9cfdabca
KY
6687 [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
6688 .type = HDA_FIXUP_PINS,
6689 .v.pins = (const struct hda_pintbl[]) {
6690 { 0x14, 0x0201101f },
6691 { }
6692 },
6693 .chained = true,
6694 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6695 },
4c574ad4
KY
6696 [ALC255_FIXUP_DELL_HEADSET_MIC] = {
6697 .type = HDA_FIXUP_PINS,
6698 .v.pins = (const struct hda_pintbl[]) {
6699 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6700 { }
6701 },
431b427b
HW
6702 .chained = true,
6703 .chain_id = ALC269_FIXUP_HEADSET_MIC
4c574ad4 6704 },
32e2ee86
KY
6705 [ALC221_FIXUP_HP_HEADSET_MIC] = {
6706 .type = HDA_FIXUP_PINS,
6707 .v.pins = (const struct hda_pintbl[]) {
6708 { 0x19, 0x0181313f},
6709 { }
6710 },
6711 .chained = true,
6712 .chain_id = ALC269_FIXUP_HEADSET_MIC
6713 },
ea7118da
HW
6714 [ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
6715 .type = HDA_FIXUP_FUNC,
6716 .v.func = alc285_fixup_invalidate_dacs,
3b01ea18
HW
6717 .chained = true,
6718 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
ea7118da 6719 },
0a60c116
HW
6720 [ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
6721 .type = HDA_FIXUP_VERBS,
6722 .v.verbs = (const struct hda_verb[]) {
6723 /* Disable PCBEEP-IN passthrough */
6724 { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6725 { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6726 { }
6727 },
6728 .chained = true,
6729 .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
6730 },
09416ef0
JS
6731 [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
6732 .type = HDA_FIXUP_PINS,
6733 .v.pins = (const struct hda_pintbl[]) {
6734 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6735 { }
6736 },
6737 .chained = true,
6738 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6739 },
20616fb0
KY
6740 [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
6741 .type = HDA_FIXUP_PINS,
6742 .v.pins = (const struct hda_pintbl[]) {
6743 { 0x16, 0x01011020 }, /* Rear Line out */
6744 { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
6745 { }
6746 },
6747 .chained = true,
6748 .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
6749 },
6750 [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
6751 .type = HDA_FIXUP_FUNC,
6752 .v.func = alc_fixup_auto_mute_via_amp,
6753 .chained = true,
6754 .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
6755 },
6756 [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
6757 .type = HDA_FIXUP_FUNC,
6758 .v.func = alc_fixup_disable_mic_vref,
6759 .chained = true,
6760 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6761 },
9c54c712
CC
6762 [ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
6763 .type = HDA_FIXUP_PINS,
6764 .v.pins = (const struct hda_pintbl[]) {
6765 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6766 { }
6767 },
6768 .chained = true,
6769 .chain_id = ALC269_FIXUP_HEADSET_MIC
6770 },
dad6c4f4
CC
6771 [ALC294_FIXUP_ASUS_MIC] = {
6772 .type = HDA_FIXUP_PINS,
6773 .v.pins = (const struct hda_pintbl[]) {
6774 { 0x13, 0x90a60160 }, /* use as internal mic */
6775 { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6776 { }
6777 },
6778 .chained = true,
6779 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6780 },
7398055e
JHP
6781 [ALC294_FIXUP_ASUS_HEADSET_MIC] = {
6782 .type = HDA_FIXUP_PINS,
6783 .v.pins = (const struct hda_pintbl[]) {
8f5982cc 6784 { 0x19, 0x01a1103c }, /* use as headset mic */
7398055e
JHP
6785 { }
6786 },
6787 .chained = true,
6788 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6789 },
6790 [ALC294_FIXUP_ASUS_SPK] = {
6791 .type = HDA_FIXUP_VERBS,
6792 .v.verbs = (const struct hda_verb[]) {
6793 /* Set EAPD high */
6794 { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
6795 { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
6796 { }
6797 },
6798 .chained = true,
6799 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
6800 },
1a1fcf1f
JHP
6801 [ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
6802 .type = HDA_FIXUP_VERBS,
6803 .v.verbs = (const struct hda_verb[]) {
6804 { 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
6805 { 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
6806 { }
6807 },
6808 .chained = true,
6809 .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
6810 },
6454939d
DD
6811 [ALC256_FIXUP_ASUS_HEADSET_MIC] = {
6812 .type = HDA_FIXUP_PINS,
6813 .v.pins = (const struct hda_pintbl[]) {
6814 { 0x19, 0x03a11020 }, /* headset mic with jack detect */
6815 { }
6816 },
6817 .chained = true,
6818 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6819 },
4f7f74da
JHP
6820 [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6821 .type = HDA_FIXUP_PINS,
6822 .v.pins = (const struct hda_pintbl[]) {
6823 { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6824 { }
6825 },
6826 .chained = true,
6827 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6828 },
128a4c8d
BR
6829 [ALC299_FIXUP_PREDATOR_SPK] = {
6830 .type = HDA_FIXUP_PINS,
6831 .v.pins = (const struct hda_pintbl[]) {
6832 { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
6833 { }
6834 }
6835 },
e77aee2f
JHP
6836 [ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC] = {
6837 .type = HDA_FIXUP_PINS,
6838 .v.pins = (const struct hda_pintbl[]) {
6839 { 0x14, 0x411111f0 }, /* disable confusing internal speaker */
6840 { 0x19, 0x04a11150 }, /* use as headset mic, without its own jack detect */
6841 { }
6842 },
6843 .chained = true,
6844 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6845 },
f52b4dcf
JMG
6846 [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
6847 .type = HDA_FIXUP_PINS,
6848 .v.pins = (const struct hda_pintbl[]) {
6849 { 0x19, 0x04a11040 },
6850 { 0x21, 0x04211020 },
6851 { }
6852 },
6853 .chained = true,
6854 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6855 },
f1d4e28b
KY
6856};
6857
1d045db9 6858static const struct snd_pci_quirk alc269_fixup_tbl[] = {
a6b92b66 6859 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
693b613d
DH
6860 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
6861 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
aaedfb47 6862 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
7819717b
TI
6863 SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
6864 SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
aaedfb47
DH
6865 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
6866 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
02322ac9 6867 SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
b1e8972e 6868 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
1a22e775 6869 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
b085c988 6870 SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
b9c2fa52 6871 SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
4b1784ee
CC
6872 SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
6873 SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
128a4c8d 6874 SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
1a1fcf1f
JHP
6875 SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
6876 SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
6877 SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
b5ed743b 6878 SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
aaedfb47 6879 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
6ed1131f 6880 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
86f799b8 6881 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
cf52103a 6882 SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8b99aba7
TI
6883 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
6884 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
0f4881dc 6885 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
73bdd597
DH
6886 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6887 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6888 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
0f4881dc
DH
6889 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
6890 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
98070576 6891 SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
4275554d 6892 SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
0f4881dc 6893 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
a22aa26f
KY
6894 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6895 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
831bfdf9 6896 SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
afecb146 6897 SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
3a05d12f 6898 SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8b72415d 6899 SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
b734304f
KY
6900 SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6901 SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
c04017ea
DH
6902 SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6903 SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6904 SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6905 SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6906 SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
a2fe1dc7 6907 SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2),
fd06c77e 6908 SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
3b43b71f 6909 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
b001f661 6910 SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
a2fe1dc7 6911 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2),
feda862c 6912 SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
dd9aa335 6913 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
214839a8 6914 SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
493de342 6915 SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
9423a273 6916 SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
a2fe1dc7 6917 SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2),
a98cf497
KY
6918 SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
6919 SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
4c574ad4
KY
6920 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
6921 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
9cfdabca 6922 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
20616fb0 6923 SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
1fddba4b 6924 SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
1b48c755 6925 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
a22aa26f
KY
6926 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6927 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
08fb0d0e 6928 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9f5c6faf 6929 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8e35cd4a 6930 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
33f4acd3 6931 SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
c60666bd 6932 /* ALC282 */
7976eb49 6933 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6934 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6935 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
6936 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6937 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6938 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6939 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9c5dc3bf 6940 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
c60666bd 6941 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6942 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6943 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6944 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
eaa8e5ef 6945 SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
b4b33f9d 6946 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
3271cb22 6947 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
c60666bd 6948 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6949 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6950 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6951 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6952 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
98973f2f 6953 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
9c5dc3bf
KY
6954 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6955 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 6956 /* ALC290 */
9c5dc3bf 6957 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6958 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6959 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf
KY
6960 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6961 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6962 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6963 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6964 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6965 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
04d5466a 6966 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
c60666bd 6967 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6968 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6969 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6970 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
6971 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6972 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6973 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 6974 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6975 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6976 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6977 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6978 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6979 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6980 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6981 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
6982 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6983 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6984 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6985 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
f883982d 6986 SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
b0759c99
JK
6987 SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
6988 SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
e549d190 6989 SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
8062159a 6990 SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
b0759c99
JK
6991 SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
6992 SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
c1732ede 6993 SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
7bba2157 6994 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
3e0d611b 6995 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
ff0e5460 6996 SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
c1732ede 6997 SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
4eab0ea1 6998 SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
3e0d611b 6999 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4eab0ea1
TI
7000 SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
7001 SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
7002 SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
c1732ede
CC
7003 SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
7004 SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
7005 SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
2cede303 7006 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
23870831 7007 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
3e0d611b 7008 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
e77aee2f 7009 SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC),
6454939d 7010 SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
017f2a10 7011 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
28e8af8a 7012 SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
693b613d 7013 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
615966ad 7014 SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
4eab0ea1 7015 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
c1732ede 7016 SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
eeed4cd1 7017 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
adabb3ec
TI
7018 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
7019 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
7020 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
7021 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
d240d1dc 7022 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
f88abaa0 7023 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
88cfcf86 7024 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
1d045db9
TI
7025 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
7026 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
7027 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
e9bd7d5c 7028 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
24519911 7029 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
4df3fd17 7030 SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
cc7016ab 7031 SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
88776f36 7032 SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
0dcd451c 7033 SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
2041d564 7034 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
b84e8436 7035 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
f4900a15 7036 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
a33cc48d 7037 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
823ff161 7038 SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
abaa2274
AA
7039 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
7040 SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
dbfe90df 7041 SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
09416ef0 7042 SND_PCI_QUIRK(0x1558, 0x1325, "System76 Darter Pro (darp5)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8ece3055 7043 SND_PCI_QUIRK(0x1558, 0x8550, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
6f616691
JS
7044 SND_PCI_QUIRK(0x1558, 0x8551, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
7045 SND_PCI_QUIRK(0x1558, 0x8560, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
7046 SND_PCI_QUIRK(0x1558, 0x8561, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
ca169cc2 7047 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
1d045db9
TI
7048 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
7049 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
7050 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
7051 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
7052 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
707fba3f 7053 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
c8415a48 7054 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
84f98fdf 7055 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
4407be6b 7056 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
108cc108 7057 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
aaedfb47 7058 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
9a811230 7059 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
1c37c223 7060 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
a12137e7 7061 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
59a51a6b 7062 SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
6d16941a 7063 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
7c21539c 7064 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
a4a9e082 7065 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
b6903c0e 7066 SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
d05ea7da 7067 SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
c0278669 7068 SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
114745cd
KY
7069 SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7070 SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
dab38e43 7071 SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
c636b95e 7072 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
114745cd
KY
7073 SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
7074 SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7075 SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
3051e378 7076 SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
114745cd
KY
7077 SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7078 SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7079 SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8c85df50 7080 SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
3530e143 7081 SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Yoga 7th", ALC285_FIXUP_SPEAKER2_TO_DAC1),
294f6c04 7082 SND_PCI_QUIRK(0x17aa, 0x2293, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_SPEAKER2_TO_DAC1),
3694cb29 7083 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6ef2f68f 7084 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
f33f79f3 7085 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
82fcb1bd 7086 SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
b4ceb446 7087 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
74ef8b43 7088 SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8da5bbfc 7089 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
369b3f52 7090 SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
0bb1e002
AM
7091 SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7092 SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
56f27013 7093 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
fedb2245 7094 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
e2e7a9f7 7095 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
a4a9e082 7096 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
1bb3e062 7097 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
c497d9f9 7098 SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
cd5302c0 7099 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
f2aa1110 7100 SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
80b311d3 7101 SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
09ea9976 7102 SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
037e1197 7103 SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
23adc192 7104 SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
0f087ee3 7105 SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
9cd25743 7106 SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
0f087ee3 7107 SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
114745cd
KY
7108 SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7109 SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7110 SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
cd5302c0 7111 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
114745cd
KY
7112 SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7113 SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
012e7eb1 7114 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
1d045db9 7115 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
531802e2 7116 SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MBXP", ALC256_FIXUP_HUAWEI_MBXP_PINS),
02b504d9 7117 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
90733a10 7118 SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
f52b4dcf 7119 SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
a4297b5d 7120
a7f3eedc 7121#if 0
a4297b5d
TI
7122 /* Below is a quirk table taken from the old code.
7123 * Basically the device should work as is without the fixup table.
7124 * If BIOS doesn't give a proper info, enable the corresponding
7125 * fixup entry.
7d7eb9ea 7126 */
a4297b5d
TI
7127 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
7128 ALC269_FIXUP_AMIC),
7129 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
a4297b5d
TI
7130 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
7131 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
7132 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
7133 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
7134 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
7135 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
7136 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
7137 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
7138 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
7139 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
7140 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
7141 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
7142 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
7143 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
7144 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
7145 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
7146 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
7147 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
7148 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
7149 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
7150 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
7151 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
7152 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
7153 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
7154 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
7155 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
7156 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
7157 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
7158 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
7159 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
7160 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
7161 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
7162 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
7163 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
7164 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
7165 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
7166 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
7167 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
7168#endif
7169 {}
7170};
7171
214eef76
DH
7172static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
7173 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
7174 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
7175 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
7176 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
7177 {}
7178};
7179
1727a771 7180static const struct hda_model_fixup alc269_fixup_models[] = {
a4297b5d
TI
7181 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
7182 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6e72aa5f
TI
7183 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
7184 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
7185 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
7c478f03 7186 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
b016951e
TI
7187 {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
7188 {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
108cc108 7189 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9f5c6faf 7190 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
04d5466a 7191 {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
e32aa85a
DH
7192 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
7193 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
128a4c8d 7194 {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
294f6c04 7195 {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
f52b4dcf 7196 {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
be8ef16a 7197 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
0202e99c 7198 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
1c37c223 7199 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
9a811230 7200 {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
c636b95e 7201 {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
ba90d6a6 7202 {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
28d1d6d2 7203 {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
1d045db9 7204 {}
6dda9f4a 7205};
cfc5a845 7206#define ALC225_STANDARD_PINS \
cfc5a845 7207 {0x21, 0x04211020}
6dda9f4a 7208
e8191a8e
HW
7209#define ALC256_STANDARD_PINS \
7210 {0x12, 0x90a60140}, \
7211 {0x14, 0x90170110}, \
e8191a8e
HW
7212 {0x21, 0x02211020}
7213
fea185e2 7214#define ALC282_STANDARD_PINS \
11580297 7215 {0x14, 0x90170110}
e1e62b98 7216
fea185e2 7217#define ALC290_STANDARD_PINS \
11580297 7218 {0x12, 0x99a30130}
fea185e2
DH
7219
7220#define ALC292_STANDARD_PINS \
7221 {0x14, 0x90170110}, \
11580297 7222 {0x15, 0x0221401f}
977e6276 7223
3f640970
HW
7224#define ALC295_STANDARD_PINS \
7225 {0x12, 0xb7a60130}, \
7226 {0x14, 0x90170110}, \
3f640970
HW
7227 {0x21, 0x04211020}
7228
703867e2
WS
7229#define ALC298_STANDARD_PINS \
7230 {0x12, 0x90a60130}, \
7231 {0x21, 0x03211020}
7232
e1918938 7233static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
32e2ee86
KY
7234 SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
7235 {0x14, 0x01014020},
7236 {0x17, 0x90170110},
7237 {0x18, 0x02a11030},
7238 {0x19, 0x0181303F},
7239 {0x21, 0x0221102f}),
5824ce8d
CC
7240 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
7241 {0x12, 0x90a601c0},
7242 {0x14, 0x90171120},
7243 {0x21, 0x02211030}),
615966ad
CC
7244 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
7245 {0x14, 0x90170110},
7246 {0x1b, 0x90a70130},
7247 {0x21, 0x03211020}),
7248 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
7249 {0x1a, 0x90a70130},
7250 {0x1b, 0x90170110},
7251 {0x21, 0x03211020}),
2ae95577 7252 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
cfc5a845 7253 ALC225_STANDARD_PINS,
8a132099 7254 {0x12, 0xb7a60130},
cfc5a845 7255 {0x14, 0x901701a0}),
2ae95577 7256 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
cfc5a845 7257 ALC225_STANDARD_PINS,
8a132099 7258 {0x12, 0xb7a60130},
cfc5a845 7259 {0x14, 0x901701b0}),
8a132099
HW
7260 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7261 ALC225_STANDARD_PINS,
7262 {0x12, 0xb7a60150},
7263 {0x14, 0x901701a0}),
7264 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7265 ALC225_STANDARD_PINS,
7266 {0x12, 0xb7a60150},
7267 {0x14, 0x901701b0}),
7268 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7269 ALC225_STANDARD_PINS,
7270 {0x12, 0xb7a60130},
7271 {0x1b, 0x90170110}),
0ce48e17
KHF
7272 SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7273 {0x1b, 0x01111010},
7274 {0x1e, 0x01451130},
7275 {0x21, 0x02211020}),
56d3b887
HW
7276 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
7277 {0x12, 0x90a60140},
7278 {0x14, 0x90170110},
7279 {0x19, 0x02a11030},
7280 {0x21, 0x02211020}),
74ef8b43
HW
7281 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7282 {0x14, 0x90170110},
7283 {0x19, 0x02a11030},
7284 {0x1a, 0x02a11040},
7285 {0x1b, 0x01014020},
7286 {0x21, 0x0221101f}),
66a0e1cc
HW
7287 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7288 {0x14, 0x90170110},
7289 {0x19, 0x02a11030},
7290 {0x1a, 0x02a11040},
7291 {0x1b, 0x01011020},
7292 {0x21, 0x0221101f}),
3374ea95
HW
7293 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7294 {0x14, 0x90170110},
7295 {0x19, 0x02a11020},
7296 {0x1a, 0x02a11030},
7297 {0x21, 0x0221101f}),
19412c71
TI
7298 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
7299 {0x12, 0x90a60140},
7300 {0x14, 0x90170110},
7301 {0x19, 0x02a11030},
7302 {0x21, 0x02211020}),
c77900e6 7303 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
c77900e6 7304 {0x14, 0x90170110},
c77900e6 7305 {0x21, 0x02211020}),
86c72d1c
HW
7306 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7307 {0x14, 0x90170130},
7308 {0x21, 0x02211040}),
76c2132e
DH
7309 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7310 {0x12, 0x90a60140},
7311 {0x14, 0x90170110},
76c2132e
DH
7312 {0x21, 0x02211020}),
7313 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7314 {0x12, 0x90a60160},
7315 {0x14, 0x90170120},
76c2132e 7316 {0x21, 0x02211030}),
392c9da2
HW
7317 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7318 {0x14, 0x90170110},
7319 {0x1b, 0x02011020},
7320 {0x21, 0x0221101f}),
6aecd871
HW
7321 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7322 {0x14, 0x90170110},
7323 {0x1b, 0x01011020},
7324 {0x21, 0x0221101f}),
cba59972 7325 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
cba59972 7326 {0x14, 0x90170130},
cba59972 7327 {0x1b, 0x01014020},
cba59972 7328 {0x21, 0x0221103f}),
6aecd871
HW
7329 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7330 {0x14, 0x90170130},
7331 {0x1b, 0x01011020},
7332 {0x21, 0x0221103f}),
59ec4b57
HW
7333 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7334 {0x14, 0x90170130},
7335 {0x1b, 0x02011020},
7336 {0x21, 0x0221103f}),
e9c28e16 7337 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
e9c28e16 7338 {0x14, 0x90170150},
e9c28e16 7339 {0x1b, 0x02011020},
e9c28e16
WS
7340 {0x21, 0x0221105f}),
7341 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
e9c28e16 7342 {0x14, 0x90170110},
e9c28e16 7343 {0x1b, 0x01014020},
e9c28e16 7344 {0x21, 0x0221101f}),
76c2132e
DH
7345 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7346 {0x12, 0x90a60160},
7347 {0x14, 0x90170120},
7348 {0x17, 0x90170140},
76c2132e
DH
7349 {0x21, 0x0321102f}),
7350 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7351 {0x12, 0x90a60160},
7352 {0x14, 0x90170130},
76c2132e
DH
7353 {0x21, 0x02211040}),
7354 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7355 {0x12, 0x90a60160},
7356 {0x14, 0x90170140},
76c2132e
DH
7357 {0x21, 0x02211050}),
7358 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7359 {0x12, 0x90a60170},
7360 {0x14, 0x90170120},
76c2132e
DH
7361 {0x21, 0x02211030}),
7362 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7363 {0x12, 0x90a60170},
7364 {0x14, 0x90170130},
76c2132e 7365 {0x21, 0x02211040}),
0a1f90a9
HW
7366 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7367 {0x12, 0x90a60170},
7368 {0x14, 0x90171130},
7369 {0x21, 0x02211040}),
70658b99 7370 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
70658b99
HW
7371 {0x12, 0x90a60170},
7372 {0x14, 0x90170140},
70658b99 7373 {0x21, 0x02211050}),
9b5a4e39 7374 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9b5a4e39
DH
7375 {0x12, 0x90a60180},
7376 {0x14, 0x90170130},
9b5a4e39 7377 {0x21, 0x02211040}),
f90d83b3
AK
7378 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7379 {0x12, 0x90a60180},
7380 {0x14, 0x90170120},
7381 {0x21, 0x02211030}),
989dbe4a
HW
7382 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7383 {0x1b, 0x01011020},
7384 {0x21, 0x02211010}),
c1732ede
CC
7385 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
7386 {0x14, 0x90170110},
7387 {0x1b, 0x90a70130},
7388 {0x21, 0x04211020}),
7389 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
7390 {0x14, 0x90170110},
7391 {0x1b, 0x90a70130},
7392 {0x21, 0x03211020}),
0c17ee73
CC
7393 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7394 {0x12, 0x90a60130},
7395 {0x14, 0x90170110},
7396 {0x21, 0x03211020}),
8c63db5b
JHP
7397 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7398 {0x12, 0x90a60130},
7399 {0x14, 0x90170110},
7400 {0x21, 0x04211020}),
4f7f74da
JHP
7401 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7402 {0x1a, 0x90a70130},
7403 {0x1b, 0x90170110},
7404 {0x21, 0x03211020}),
cf51eb9d
DH
7405 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
7406 {0x12, 0x90a60130},
cf51eb9d
DH
7407 {0x14, 0x90170110},
7408 {0x15, 0x0421101f},
11580297 7409 {0x1a, 0x04a11020}),
0279661b
HW
7410 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
7411 {0x12, 0x90a60140},
0279661b
HW
7412 {0x14, 0x90170110},
7413 {0x15, 0x0421101f},
0279661b 7414 {0x18, 0x02811030},
0279661b 7415 {0x1a, 0x04a1103f},
11580297 7416 {0x1b, 0x02011020}),
42304474 7417 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7418 ALC282_STANDARD_PINS,
42304474 7419 {0x12, 0x99a30130},
42304474 7420 {0x19, 0x03a11020},
42304474 7421 {0x21, 0x0321101f}),
2c609999 7422 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7423 ALC282_STANDARD_PINS,
2c609999 7424 {0x12, 0x99a30130},
2c609999 7425 {0x19, 0x03a11020},
2c609999
HW
7426 {0x21, 0x03211040}),
7427 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7428 ALC282_STANDARD_PINS,
2c609999 7429 {0x12, 0x99a30130},
2c609999 7430 {0x19, 0x03a11030},
2c609999
HW
7431 {0x21, 0x03211020}),
7432 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7433 ALC282_STANDARD_PINS,
2c609999 7434 {0x12, 0x99a30130},
2c609999 7435 {0x19, 0x04a11020},
2c609999 7436 {0x21, 0x0421101f}),
200afc09 7437 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
aec856d0 7438 ALC282_STANDARD_PINS,
200afc09 7439 {0x12, 0x90a60140},
200afc09 7440 {0x19, 0x04a11030},
200afc09 7441 {0x21, 0x04211020}),
76c2132e 7442 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7443 ALC282_STANDARD_PINS,
76c2132e 7444 {0x12, 0x90a60130},
76c2132e
DH
7445 {0x21, 0x0321101f}),
7446 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7447 {0x12, 0x90a60160},
7448 {0x14, 0x90170120},
76c2132e 7449 {0x21, 0x02211030}),
bc262179 7450 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7451 ALC282_STANDARD_PINS,
bc262179 7452 {0x12, 0x90a60130},
bc262179 7453 {0x19, 0x03a11020},
bc262179 7454 {0x21, 0x0321101f}),
0a60c116 7455 SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
ea7118da
HW
7456 {0x12, 0x90a60130},
7457 {0x14, 0x90170110},
7458 {0x19, 0x04a11040},
7459 {0x21, 0x04211020}),
e1e62b98 7460 SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL_XPS_13_GPIO6,
e1e62b98 7461 {0x12, 0x90a60120},
e1e62b98 7462 {0x14, 0x90170110},
e1e62b98 7463 {0x21, 0x0321101f}),
e4442bcf 7464 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7465 ALC290_STANDARD_PINS,
e4442bcf 7466 {0x15, 0x04211040},
e4442bcf 7467 {0x18, 0x90170112},
11580297 7468 {0x1a, 0x04a11020}),
e4442bcf 7469 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7470 ALC290_STANDARD_PINS,
e4442bcf 7471 {0x15, 0x04211040},
e4442bcf 7472 {0x18, 0x90170110},
11580297 7473 {0x1a, 0x04a11020}),
e4442bcf 7474 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7475 ALC290_STANDARD_PINS,
e4442bcf 7476 {0x15, 0x0421101f},
11580297 7477 {0x1a, 0x04a11020}),
e4442bcf 7478 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7479 ALC290_STANDARD_PINS,
e4442bcf 7480 {0x15, 0x04211020},
11580297 7481 {0x1a, 0x04a11040}),
e4442bcf 7482 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7483 ALC290_STANDARD_PINS,
e4442bcf
HW
7484 {0x14, 0x90170110},
7485 {0x15, 0x04211020},
11580297 7486 {0x1a, 0x04a11040}),
e4442bcf 7487 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7488 ALC290_STANDARD_PINS,
e4442bcf
HW
7489 {0x14, 0x90170110},
7490 {0x15, 0x04211020},
11580297 7491 {0x1a, 0x04a11020}),
e4442bcf 7492 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7493 ALC290_STANDARD_PINS,
e4442bcf
HW
7494 {0x14, 0x90170110},
7495 {0x15, 0x0421101f},
11580297 7496 {0x1a, 0x04a11020}),
e8818fa8 7497 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
aec856d0 7498 ALC292_STANDARD_PINS,
e8818fa8 7499 {0x12, 0x90a60140},
e8818fa8 7500 {0x16, 0x01014020},
11580297 7501 {0x19, 0x01a19030}),
e8818fa8 7502 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
aec856d0 7503 ALC292_STANDARD_PINS,
e8818fa8 7504 {0x12, 0x90a60140},
e8818fa8
HW
7505 {0x16, 0x01014020},
7506 {0x18, 0x02a19031},
11580297 7507 {0x19, 0x01a1903e}),
76c2132e 7508 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
aec856d0 7509 ALC292_STANDARD_PINS,
11580297 7510 {0x12, 0x90a60140}),
76c2132e 7511 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7512 ALC292_STANDARD_PINS,
76c2132e 7513 {0x13, 0x90a60140},
76c2132e 7514 {0x16, 0x21014020},
11580297 7515 {0x19, 0x21a19030}),
e03fdbde 7516 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7517 ALC292_STANDARD_PINS,
11580297 7518 {0x13, 0x90a60140}),
dad6c4f4
CC
7519 SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
7520 {0x14, 0x90170110},
7521 {0x1b, 0x90a70130},
7522 {0x21, 0x04211020}),
32557ebe
JHP
7523 SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7524 {0x12, 0x90a60130},
7525 {0x17, 0x90170110},
7526 {0x21, 0x03211020}),
3794a5cd
JHP
7527 SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7528 {0x12, 0x90a60130},
7529 {0x17, 0x90170110},
7530 {0x21, 0x04211020}),
6bcdd584
TI
7531 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7532 {0x12, 0x90a60130},
7533 {0x17, 0x90170110},
7534 {0x21, 0x03211020}),
b491fd79 7535 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
14603be1
KY
7536 {0x14, 0x90170110},
7537 {0x21, 0x04211020}),
b491fd79
KY
7538 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7539 {0x14, 0x90170110},
7540 {0x21, 0x04211030}),
3f640970 7541 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
f771d5bb
HW
7542 ALC295_STANDARD_PINS,
7543 {0x17, 0x21014020},
7544 {0x18, 0x21a19030}),
7545 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7546 ALC295_STANDARD_PINS,
7547 {0x17, 0x21014040},
7548 {0x18, 0x21a19050}),
3f307834
HW
7549 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7550 ALC295_STANDARD_PINS),
9f502ff5
TI
7551 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7552 ALC298_STANDARD_PINS,
7553 {0x17, 0x90170110}),
977e6276 7554 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
703867e2
WS
7555 ALC298_STANDARD_PINS,
7556 {0x17, 0x90170140}),
7557 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7558 ALC298_STANDARD_PINS,
9f502ff5 7559 {0x17, 0x90170150}),
9f1bc2c4
KHF
7560 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
7561 {0x12, 0xb7a60140},
7562 {0x13, 0xb7a60150},
7563 {0x17, 0x90170110},
7564 {0x1a, 0x03011020},
7565 {0x21, 0x03211030}),
fcc6c877
KY
7566 SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7567 ALC225_STANDARD_PINS,
7568 {0x12, 0xb7a60130},
fcc6c877 7569 {0x17, 0x90170110}),
9c54c712
CC
7570 SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
7571 {0x12, 0x90a60130},
7572 {0x17, 0x90170110},
7573 {0x21, 0x02211020}),
e1918938
HW
7574 {}
7575};
6dda9f4a 7576
ad0b7b84
HW
7577/* This is the fallback pin_fixup_tbl for alc269 family, to make the tbl match
7578 * more machines, don't need to match all valid pins, just need to match
7579 * all the pins defined in the tbl. Just because of this reason, it is possible
7580 * that a single machine matches multiple tbls, so there is one limitation:
7581 * at most one tbl is allowed to define for the same vendor and same codec
7582 */
7583static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
7584 SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7585 {0x19, 0x40000000},
7586 {0x1b, 0x40000000}),
e43478cb
HW
7587 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7588 {0x19, 0x40000000},
7589 {0x1a, 0x40000000}),
e3155463
HW
7590 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7591 {0x19, 0x40000000},
7592 {0x1a, 0x40000000}),
73d0d548
HW
7593 SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
7594 {0x19, 0x40000000},
7595 {0x1a, 0x40000000}),
ad0b7b84
HW
7596 {}
7597};
7598
546bb678 7599static void alc269_fill_coef(struct hda_codec *codec)
1d045db9 7600{
526af6eb 7601 struct alc_spec *spec = codec->spec;
1d045db9 7602 int val;
ebb83eeb 7603
526af6eb 7604 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
546bb678 7605 return;
526af6eb 7606
1bb7e43e 7607 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
1d045db9
TI
7608 alc_write_coef_idx(codec, 0xf, 0x960b);
7609 alc_write_coef_idx(codec, 0xe, 0x8817);
7610 }
ebb83eeb 7611
1bb7e43e 7612 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
1d045db9
TI
7613 alc_write_coef_idx(codec, 0xf, 0x960b);
7614 alc_write_coef_idx(codec, 0xe, 0x8814);
7615 }
ebb83eeb 7616
1bb7e43e 7617 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9 7618 /* Power up output pin */
98b24883 7619 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
1d045db9 7620 }
ebb83eeb 7621
1bb7e43e 7622 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9 7623 val = alc_read_coef_idx(codec, 0xd);
f3ee07d8 7624 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
1d045db9
TI
7625 /* Capless ramp up clock control */
7626 alc_write_coef_idx(codec, 0xd, val | (1<<10));
7627 }
7628 val = alc_read_coef_idx(codec, 0x17);
f3ee07d8 7629 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
1d045db9
TI
7630 /* Class D power on reset */
7631 alc_write_coef_idx(codec, 0x17, val | (1<<7));
7632 }
7633 }
ebb83eeb 7634
98b24883
TI
7635 /* HP */
7636 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
1d045db9 7637}
a7f2371f 7638
1d045db9
TI
7639/*
7640 */
1d045db9
TI
7641static int patch_alc269(struct hda_codec *codec)
7642{
7643 struct alc_spec *spec;
3de95173 7644 int err;
f1d4e28b 7645
3de95173 7646 err = alc_alloc_spec(codec, 0x0b);
e16fb6d1 7647 if (err < 0)
3de95173
TI
7648 return err;
7649
7650 spec = codec->spec;
08c189f2 7651 spec->gen.shared_mic_vref_pin = 0x18;
762c2538 7652 codec->power_save_node = 0;
e16fb6d1 7653
225068ab
TI
7654#ifdef CONFIG_PM
7655 codec->patch_ops.suspend = alc269_suspend;
7656 codec->patch_ops.resume = alc269_resume;
7657#endif
c2d6af53
KY
7658 spec->shutup = alc_default_shutup;
7659 spec->init_hook = alc_default_init;
225068ab 7660
1727a771 7661 snd_hda_pick_fixup(codec, alc269_fixup_models,
9f720bb9 7662 alc269_fixup_tbl, alc269_fixups);
31d7a6e3 7663 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
ad0b7b84 7664 snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
214eef76
DH
7665 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
7666 alc269_fixups);
1727a771 7667 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9f720bb9
HRK
7668
7669 alc_auto_parse_customize_define(codec);
7670
7504b6cd
TI
7671 if (has_cdefine_beep(codec))
7672 spec->gen.beep_nid = 0x01;
7673
7639a06c 7674 switch (codec->core.vendor_id) {
065380f0 7675 case 0x10ec0269:
1d045db9 7676 spec->codec_variant = ALC269_TYPE_ALC269VA;
1bb7e43e
TI
7677 switch (alc_get_coef0(codec) & 0x00f0) {
7678 case 0x0010:
5100cd07
TI
7679 if (codec->bus->pci &&
7680 codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 7681 spec->cdefine.platform_type == 1)
20ca0c35 7682 err = alc_codec_rename(codec, "ALC271X");
1d045db9 7683 spec->codec_variant = ALC269_TYPE_ALC269VB;
1bb7e43e
TI
7684 break;
7685 case 0x0020:
5100cd07
TI
7686 if (codec->bus->pci &&
7687 codec->bus->pci->subsystem_vendor == 0x17aa &&
e16fb6d1 7688 codec->bus->pci->subsystem_device == 0x21f3)
20ca0c35 7689 err = alc_codec_rename(codec, "ALC3202");
1d045db9 7690 spec->codec_variant = ALC269_TYPE_ALC269VC;
1bb7e43e 7691 break;
adcc70b2
KY
7692 case 0x0030:
7693 spec->codec_variant = ALC269_TYPE_ALC269VD;
7694 break;
1bb7e43e 7695 default:
1d045db9 7696 alc_fix_pll_init(codec, 0x20, 0x04, 15);
1bb7e43e 7697 }
e16fb6d1
TI
7698 if (err < 0)
7699 goto error;
c2d6af53 7700 spec->shutup = alc269_shutup;
546bb678 7701 spec->init_hook = alc269_fill_coef;
1d045db9 7702 alc269_fill_coef(codec);
065380f0
KY
7703 break;
7704
7705 case 0x10ec0280:
7706 case 0x10ec0290:
7707 spec->codec_variant = ALC269_TYPE_ALC280;
7708 break;
7709 case 0x10ec0282:
065380f0 7710 spec->codec_variant = ALC269_TYPE_ALC282;
7b5c7a02
KY
7711 spec->shutup = alc282_shutup;
7712 spec->init_hook = alc282_init;
065380f0 7713 break;
2af02be7
KY
7714 case 0x10ec0233:
7715 case 0x10ec0283:
7716 spec->codec_variant = ALC269_TYPE_ALC283;
7717 spec->shutup = alc283_shutup;
7718 spec->init_hook = alc283_init;
7719 break;
065380f0
KY
7720 case 0x10ec0284:
7721 case 0x10ec0292:
7722 spec->codec_variant = ALC269_TYPE_ALC284;
7723 break;
161ebf29 7724 case 0x10ec0293:
4731d5de 7725 spec->codec_variant = ALC269_TYPE_ALC293;
161ebf29 7726 break;
7fc7d047 7727 case 0x10ec0286:
7c665932 7728 case 0x10ec0288:
7fc7d047
KY
7729 spec->codec_variant = ALC269_TYPE_ALC286;
7730 break;
506b62c3
KY
7731 case 0x10ec0298:
7732 spec->codec_variant = ALC269_TYPE_ALC298;
7733 break;
583142ca 7734 case 0x10ec0235:
1d04c9de
KY
7735 case 0x10ec0255:
7736 spec->codec_variant = ALC269_TYPE_ALC255;
016c6fdd
KY
7737 spec->shutup = alc256_shutup;
7738 spec->init_hook = alc256_init;
1d04c9de 7739 break;
736f20a7 7740 case 0x10ec0236:
4344aec8
KY
7741 case 0x10ec0256:
7742 spec->codec_variant = ALC269_TYPE_ALC256;
4a219ef8
KY
7743 spec->shutup = alc256_shutup;
7744 spec->init_hook = alc256_init;
7d1b6e29 7745 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
4344aec8 7746 break;
f429e7e4
KY
7747 case 0x10ec0257:
7748 spec->codec_variant = ALC269_TYPE_ALC257;
fc434f5a
KY
7749 spec->shutup = alc256_shutup;
7750 spec->init_hook = alc256_init;
f429e7e4
KY
7751 spec->gen.mixer_nid = 0;
7752 break;
0a6f0600
KY
7753 case 0x10ec0215:
7754 case 0x10ec0285:
7755 case 0x10ec0289:
7756 spec->codec_variant = ALC269_TYPE_ALC215;
7757 spec->gen.mixer_nid = 0;
7758 break;
4231430d 7759 case 0x10ec0225:
7d727869 7760 case 0x10ec0295:
fa16b69f 7761 spec->codec_variant = ALC269_TYPE_ALC225;
e674ac9a 7762 spec->gen.mixer_nid = 0; /* no loopback on ALC225 ALC295 */
fa16b69f 7763 break;
28f1f9b2 7764 case 0x10ec0299:
4231430d 7765 spec->codec_variant = ALC269_TYPE_ALC225;
0b4d8f55
KY
7766 spec->shutup = alc225_shutup;
7767 spec->init_hook = alc225_init;
7768 spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
4231430d 7769 break;
dcd4f0db
KY
7770 case 0x10ec0234:
7771 case 0x10ec0274:
7772 case 0x10ec0294:
7773 spec->codec_variant = ALC269_TYPE_ALC294;
532a7784 7774 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
71683c32 7775 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
6e25f0c7 7776 spec->init_hook = alc294_init;
dcd4f0db 7777 break;
9887cf53
KY
7778 case 0x10ec0300:
7779 spec->codec_variant = ALC269_TYPE_ALC300;
7780 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
7781 break;
8666616e
KY
7782 case 0x10ec0623:
7783 spec->codec_variant = ALC269_TYPE_ALC623;
7784 break;
6fbae35a
KY
7785 case 0x10ec0700:
7786 case 0x10ec0701:
7787 case 0x10ec0703:
0b2d4d6c 7788 case 0x10ec0711:
6fbae35a
KY
7789 spec->codec_variant = ALC269_TYPE_ALC700;
7790 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
2d7fe618 7791 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
6e25f0c7 7792 spec->init_hook = alc294_init;
6fbae35a
KY
7793 break;
7794
1d045db9 7795 }
6dda9f4a 7796
ad60d502 7797 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
97a26570 7798 spec->has_alc5505_dsp = 1;
ad60d502
KY
7799 spec->init_hook = alc5505_dsp_init;
7800 }
7801
a4297b5d
TI
7802 /* automatic parse from the BIOS config */
7803 err = alc269_parse_auto_config(codec);
e16fb6d1
TI
7804 if (err < 0)
7805 goto error;
6dda9f4a 7806
7d1b6e29
DH
7807 if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid)
7808 set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
f1d4e28b 7809
1727a771 7810 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7811
1d045db9 7812 return 0;
e16fb6d1
TI
7813
7814 error:
7815 alc_free(codec);
7816 return err;
1d045db9 7817}
f1d4e28b 7818
1d045db9
TI
7819/*
7820 * ALC861
7821 */
622e84cd 7822
1d045db9 7823static int alc861_parse_auto_config(struct hda_codec *codec)
6dda9f4a 7824{
1d045db9 7825 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7826 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
7827 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
604401a9
TI
7828}
7829
1d045db9
TI
7830/* Pin config fixes */
7831enum {
e652f4c8
TI
7832 ALC861_FIXUP_FSC_AMILO_PI1505,
7833 ALC861_FIXUP_AMP_VREF_0F,
7834 ALC861_FIXUP_NO_JACK_DETECT,
7835 ALC861_FIXUP_ASUS_A6RP,
6ddf0fd1 7836 ALC660_FIXUP_ASUS_W7J,
1d045db9 7837};
7085ec12 7838
31150f23
TI
7839/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
7840static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
1727a771 7841 const struct hda_fixup *fix, int action)
31150f23
TI
7842{
7843 struct alc_spec *spec = codec->spec;
7844 unsigned int val;
7845
1727a771 7846 if (action != HDA_FIXUP_ACT_INIT)
31150f23 7847 return;
d3f02d60 7848 val = snd_hda_codec_get_pin_target(codec, 0x0f);
31150f23
TI
7849 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
7850 val |= AC_PINCTL_IN_EN;
7851 val |= AC_PINCTL_VREF_50;
cdd03ced 7852 snd_hda_set_pin_ctl(codec, 0x0f, val);
08c189f2 7853 spec->gen.keep_vref_in_automute = 1;
31150f23
TI
7854}
7855
e652f4c8
TI
7856/* suppress the jack-detection */
7857static void alc_fixup_no_jack_detect(struct hda_codec *codec,
1727a771 7858 const struct hda_fixup *fix, int action)
e652f4c8 7859{
1727a771 7860 if (action == HDA_FIXUP_ACT_PRE_PROBE)
e652f4c8 7861 codec->no_jack_detect = 1;
7d7eb9ea 7862}
e652f4c8 7863
1727a771 7864static const struct hda_fixup alc861_fixups[] = {
e652f4c8 7865 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
1727a771
TI
7866 .type = HDA_FIXUP_PINS,
7867 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
7868 { 0x0b, 0x0221101f }, /* HP */
7869 { 0x0f, 0x90170310 }, /* speaker */
7870 { }
7871 }
7872 },
e652f4c8 7873 [ALC861_FIXUP_AMP_VREF_0F] = {
1727a771 7874 .type = HDA_FIXUP_FUNC,
31150f23 7875 .v.func = alc861_fixup_asus_amp_vref_0f,
3b25eb69 7876 },
e652f4c8 7877 [ALC861_FIXUP_NO_JACK_DETECT] = {
1727a771 7878 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
7879 .v.func = alc_fixup_no_jack_detect,
7880 },
7881 [ALC861_FIXUP_ASUS_A6RP] = {
1727a771 7882 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
7883 .v.func = alc861_fixup_asus_amp_vref_0f,
7884 .chained = true,
7885 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
6ddf0fd1
TI
7886 },
7887 [ALC660_FIXUP_ASUS_W7J] = {
7888 .type = HDA_FIXUP_VERBS,
7889 .v.verbs = (const struct hda_verb[]) {
7890 /* ASUS W7J needs a magic pin setup on unused NID 0x10
7891 * for enabling outputs
7892 */
7893 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7894 { }
7895 },
e652f4c8 7896 }
1d045db9 7897};
7085ec12 7898
1d045db9 7899static const struct snd_pci_quirk alc861_fixup_tbl[] = {
6ddf0fd1 7900 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
e7ca237b 7901 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
e652f4c8
TI
7902 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
7903 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
7904 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
7905 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
7906 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
7907 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
1d045db9
TI
7908 {}
7909};
3af9ee6b 7910
1d045db9
TI
7911/*
7912 */
1d045db9 7913static int patch_alc861(struct hda_codec *codec)
7085ec12 7914{
1d045db9 7915 struct alc_spec *spec;
1d045db9 7916 int err;
7085ec12 7917
3de95173
TI
7918 err = alc_alloc_spec(codec, 0x15);
7919 if (err < 0)
7920 return err;
1d045db9 7921
3de95173 7922 spec = codec->spec;
7504b6cd 7923 spec->gen.beep_nid = 0x23;
1d045db9 7924
225068ab
TI
7925#ifdef CONFIG_PM
7926 spec->power_hook = alc_power_eapd;
7927#endif
7928
1727a771
TI
7929 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
7930 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3af9ee6b 7931
cb4e4824
TI
7932 /* automatic parse from the BIOS config */
7933 err = alc861_parse_auto_config(codec);
e16fb6d1
TI
7934 if (err < 0)
7935 goto error;
3af9ee6b 7936
7504b6cd 7937 if (!spec->gen.no_analog)
3e6179b8 7938 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7085ec12 7939
1727a771 7940 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7941
1d045db9 7942 return 0;
e16fb6d1
TI
7943
7944 error:
7945 alc_free(codec);
7946 return err;
7085ec12
TI
7947}
7948
1d045db9
TI
7949/*
7950 * ALC861-VD support
7951 *
7952 * Based on ALC882
7953 *
7954 * In addition, an independent DAC
7955 */
1d045db9 7956static int alc861vd_parse_auto_config(struct hda_codec *codec)
bc9f98a9 7957{
1d045db9 7958 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7959 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7960 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
ce764ab2
TI
7961}
7962
1d045db9 7963enum {
8fdcb6fe
TI
7964 ALC660VD_FIX_ASUS_GPIO1,
7965 ALC861VD_FIX_DALLAS,
1d045db9 7966};
ce764ab2 7967
8fdcb6fe
TI
7968/* exclude VREF80 */
7969static void alc861vd_fixup_dallas(struct hda_codec *codec,
1727a771 7970 const struct hda_fixup *fix, int action)
8fdcb6fe 7971{
1727a771 7972 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
b78562b1
TI
7973 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
7974 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8fdcb6fe
TI
7975 }
7976}
7977
1727a771 7978static const struct hda_fixup alc861vd_fixups[] = {
1d045db9 7979 [ALC660VD_FIX_ASUS_GPIO1] = {
1727a771 7980 .type = HDA_FIXUP_VERBS,
1d045db9 7981 .v.verbs = (const struct hda_verb[]) {
8fdcb6fe 7982 /* reset GPIO1 */
1d045db9
TI
7983 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
7985 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
7986 { }
7987 }
7988 },
8fdcb6fe 7989 [ALC861VD_FIX_DALLAS] = {
1727a771 7990 .type = HDA_FIXUP_FUNC,
8fdcb6fe
TI
7991 .v.func = alc861vd_fixup_dallas,
7992 },
1d045db9 7993};
ce764ab2 7994
1d045db9 7995static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8fdcb6fe 7996 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
1d045db9 7997 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8fdcb6fe 7998 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
1d045db9
TI
7999 {}
8000};
ce764ab2 8001
1d045db9
TI
8002/*
8003 */
1d045db9 8004static int patch_alc861vd(struct hda_codec *codec)
ce764ab2 8005{
1d045db9 8006 struct alc_spec *spec;
cb4e4824 8007 int err;
ce764ab2 8008
3de95173
TI
8009 err = alc_alloc_spec(codec, 0x0b);
8010 if (err < 0)
8011 return err;
1d045db9 8012
3de95173 8013 spec = codec->spec;
7504b6cd 8014 spec->gen.beep_nid = 0x23;
1d045db9 8015
225068ab
TI
8016 spec->shutup = alc_eapd_shutup;
8017
1727a771
TI
8018 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
8019 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1d045db9 8020
cb4e4824
TI
8021 /* automatic parse from the BIOS config */
8022 err = alc861vd_parse_auto_config(codec);
e16fb6d1
TI
8023 if (err < 0)
8024 goto error;
ce764ab2 8025
7504b6cd 8026 if (!spec->gen.no_analog)
3e6179b8 8027 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1d045db9 8028
1727a771 8029 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 8030
ce764ab2 8031 return 0;
e16fb6d1
TI
8032
8033 error:
8034 alc_free(codec);
8035 return err;
ce764ab2
TI
8036}
8037
1d045db9
TI
8038/*
8039 * ALC662 support
8040 *
8041 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
8042 * configuration. Each pin widget can choose any input DACs and a mixer.
8043 * Each ADC is connected from a mixer of all inputs. This makes possible
8044 * 6-channel independent captures.
8045 *
8046 * In addition, an independent DAC for the multi-playback (not used in this
8047 * driver yet).
8048 */
1d045db9
TI
8049
8050/*
8051 * BIOS auto configuration
8052 */
8053
bc9f98a9
KY
8054static int alc662_parse_auto_config(struct hda_codec *codec)
8055{
4c6d72d1 8056 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3e6179b8
TI
8057 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
8058 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
8059 const hda_nid_t *ssids;
ee979a14 8060
7639a06c
TI
8061 if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
8062 codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
8063 codec->core.vendor_id == 0x10ec0671)
3e6179b8 8064 ssids = alc663_ssids;
6227cdce 8065 else
3e6179b8
TI
8066 ssids = alc662_ssids;
8067 return alc_parse_auto_config(codec, alc662_ignore, ssids);
bc9f98a9
KY
8068}
8069
6be7948f 8070static void alc272_fixup_mario(struct hda_codec *codec,
1727a771 8071 const struct hda_fixup *fix, int action)
6fc398cb 8072{
9bb1f06f 8073 if (action != HDA_FIXUP_ACT_PRE_PROBE)
6fc398cb 8074 return;
6be7948f
TB
8075 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
8076 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
8077 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
8078 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
8079 (0 << AC_AMPCAP_MUTE_SHIFT)))
4e76a883 8080 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
6be7948f
TB
8081}
8082
8e383953
TI
8083static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
8084 { .channels = 2,
8085 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
8086 { .channels = 4,
8087 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
8088 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
8089 { }
8090};
8091
8092/* override the 2.1 chmap */
eb9ca3ab 8093static void alc_fixup_bass_chmap(struct hda_codec *codec,
8e383953
TI
8094 const struct hda_fixup *fix, int action)
8095{
8096 if (action == HDA_FIXUP_ACT_BUILD) {
8097 struct alc_spec *spec = codec->spec;
bbbc7e85 8098 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
8e383953
TI
8099 }
8100}
8101
bf68665d
TI
8102/* avoid D3 for keeping GPIO up */
8103static unsigned int gpio_led_power_filter(struct hda_codec *codec,
8104 hda_nid_t nid,
8105 unsigned int power_state)
8106{
8107 struct alc_spec *spec = codec->spec;
7639a06c 8108 if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_led)
bf68665d
TI
8109 return AC_PWRST_D0;
8110 return power_state;
8111}
8112
3e887f37
TI
8113static void alc662_fixup_led_gpio1(struct hda_codec *codec,
8114 const struct hda_fixup *fix, int action)
8115{
8116 struct alc_spec *spec = codec->spec;
8117 static const struct hda_verb gpio_init[] = {
8118 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
8119 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
8120 {}
8121 };
8122
8123 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 8124 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3e887f37 8125 spec->gpio_led = 0;
0f32fd19
TI
8126 spec->mute_led_polarity = 1;
8127 spec->gpio_mute_led_mask = 0x01;
3e887f37 8128 snd_hda_add_verbs(codec, gpio_init);
bf68665d 8129 codec->power_filter = gpio_led_power_filter;
3e887f37
TI
8130 }
8131}
8132
c6790c8e
KY
8133static void alc662_usi_automute_hook(struct hda_codec *codec,
8134 struct hda_jack_callback *jack)
8135{
8136 struct alc_spec *spec = codec->spec;
8137 int vref;
8138 msleep(200);
8139 snd_hda_gen_hp_automute(codec, jack);
8140
8141 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
8142 msleep(100);
8143 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8144 vref);
8145}
8146
8147static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
8148 const struct hda_fixup *fix, int action)
8149{
8150 struct alc_spec *spec = codec->spec;
8151 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
8152 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
8153 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
8154 }
8155}
8156
f3f9185f
KY
8157static struct coef_fw alc668_coefs[] = {
8158 WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0),
8159 WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80),
8160 WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b, 0x0),
8161 WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
8162 WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
8163 WRITE_COEF(0x13, 0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
8164 WRITE_COEF(0x19, 0x0), WRITE_COEF(0x1a, 0x0), WRITE_COEF(0x1b, 0x0),
8165 WRITE_COEF(0x1c, 0x0), WRITE_COEF(0x1d, 0x0), WRITE_COEF(0x1e, 0x7418),
8166 WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
8167 WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
8168 WRITE_COEF(0x27, 0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
8169 WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
8170 WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac, 0x0),
8171 WRITE_COEF(0xad, 0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
8172 WRITE_COEF(0xb0, 0x0), WRITE_COEF(0xb1, 0x0), WRITE_COEF(0xb2, 0x0),
8173 WRITE_COEF(0xb3, 0x0), WRITE_COEF(0xb4, 0x0), WRITE_COEF(0xb5, 0x1040),
8174 WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
8175 WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
8176 WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
8177 WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
8178 {}
8179};
8180
8181static void alc668_restore_default_value(struct hda_codec *codec)
8182{
8183 alc_process_coef_fw(codec, alc668_coefs);
8184}
8185
6cb3b707 8186enum {
2df03514 8187 ALC662_FIXUP_ASPIRE,
3e887f37 8188 ALC662_FIXUP_LED_GPIO1,
6cb3b707 8189 ALC662_FIXUP_IDEAPAD,
6be7948f 8190 ALC272_FIXUP_MARIO,
d2ebd479 8191 ALC662_FIXUP_CZC_P10T,
94024cd1 8192 ALC662_FIXUP_SKU_IGNORE,
e59ea3ed 8193 ALC662_FIXUP_HP_RP5800,
53c334ad
TI
8194 ALC662_FIXUP_ASUS_MODE1,
8195 ALC662_FIXUP_ASUS_MODE2,
8196 ALC662_FIXUP_ASUS_MODE3,
8197 ALC662_FIXUP_ASUS_MODE4,
8198 ALC662_FIXUP_ASUS_MODE5,
8199 ALC662_FIXUP_ASUS_MODE6,
8200 ALC662_FIXUP_ASUS_MODE7,
8201 ALC662_FIXUP_ASUS_MODE8,
1565cc35 8202 ALC662_FIXUP_NO_JACK_DETECT,
edfe3bfc 8203 ALC662_FIXUP_ZOTAC_Z68,
125821ae 8204 ALC662_FIXUP_INV_DMIC,
1f8b46cd 8205 ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
73bdd597 8206 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
1f8b46cd 8207 ALC662_FIXUP_HEADSET_MODE,
73bdd597 8208 ALC668_FIXUP_HEADSET_MODE,
8e54b4ac 8209 ALC662_FIXUP_BASS_MODE4_CHMAP,
61a75f13 8210 ALC662_FIXUP_BASS_16,
a30c9aaa 8211 ALC662_FIXUP_BASS_1A,
8e54b4ac 8212 ALC662_FIXUP_BASS_CHMAP,
493a52a9 8213 ALC668_FIXUP_AUTO_MUTE,
5e6db669 8214 ALC668_FIXUP_DELL_DISABLE_AAMIX,
033b0a7c 8215 ALC668_FIXUP_DELL_XPS13,
9d4dc584 8216 ALC662_FIXUP_ASUS_Nx50,
fc7438b1 8217 ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3231e205 8218 ALC668_FIXUP_ASUS_Nx51,
73d9844f 8219 ALC668_FIXUP_MIC_COEF,
495b327b 8220 ALC668_FIXUP_ASUS_G751,
78f4f7c2
KY
8221 ALC891_FIXUP_HEADSET_MODE,
8222 ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
9b51fe3e 8223 ALC662_FIXUP_ACER_VERITON,
1a3f0991 8224 ALC892_FIXUP_ASROCK_MOBO,
c6790c8e
KY
8225 ALC662_FIXUP_USI_FUNC,
8226 ALC662_FIXUP_USI_HEADSET_MODE,
ca169cc2 8227 ALC662_FIXUP_LENOVO_MULTI_CODECS,
6cb3b707
DH
8228};
8229
1727a771 8230static const struct hda_fixup alc662_fixups[] = {
2df03514 8231 [ALC662_FIXUP_ASPIRE] = {
1727a771
TI
8232 .type = HDA_FIXUP_PINS,
8233 .v.pins = (const struct hda_pintbl[]) {
2df03514
DC
8234 { 0x15, 0x99130112 }, /* subwoofer */
8235 { }
8236 }
8237 },
3e887f37
TI
8238 [ALC662_FIXUP_LED_GPIO1] = {
8239 .type = HDA_FIXUP_FUNC,
8240 .v.func = alc662_fixup_led_gpio1,
8241 },
6cb3b707 8242 [ALC662_FIXUP_IDEAPAD] = {
1727a771
TI
8243 .type = HDA_FIXUP_PINS,
8244 .v.pins = (const struct hda_pintbl[]) {
6cb3b707
DH
8245 { 0x17, 0x99130112 }, /* subwoofer */
8246 { }
3e887f37
TI
8247 },
8248 .chained = true,
8249 .chain_id = ALC662_FIXUP_LED_GPIO1,
6cb3b707 8250 },
6be7948f 8251 [ALC272_FIXUP_MARIO] = {
1727a771 8252 .type = HDA_FIXUP_FUNC,
b5bfbc67 8253 .v.func = alc272_fixup_mario,
d2ebd479
AA
8254 },
8255 [ALC662_FIXUP_CZC_P10T] = {
1727a771 8256 .type = HDA_FIXUP_VERBS,
d2ebd479
AA
8257 .v.verbs = (const struct hda_verb[]) {
8258 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
8259 {}
8260 }
8261 },
94024cd1 8262 [ALC662_FIXUP_SKU_IGNORE] = {
1727a771 8263 .type = HDA_FIXUP_FUNC,
23d30f28 8264 .v.func = alc_fixup_sku_ignore,
c6b35874 8265 },
e59ea3ed 8266 [ALC662_FIXUP_HP_RP5800] = {
1727a771
TI
8267 .type = HDA_FIXUP_PINS,
8268 .v.pins = (const struct hda_pintbl[]) {
e59ea3ed
TI
8269 { 0x14, 0x0221201f }, /* HP out */
8270 { }
8271 },
8272 .chained = true,
8273 .chain_id = ALC662_FIXUP_SKU_IGNORE
8274 },
53c334ad 8275 [ALC662_FIXUP_ASUS_MODE1] = {
1727a771
TI
8276 .type = HDA_FIXUP_PINS,
8277 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8278 { 0x14, 0x99130110 }, /* speaker */
8279 { 0x18, 0x01a19c20 }, /* mic */
8280 { 0x19, 0x99a3092f }, /* int-mic */
8281 { 0x21, 0x0121401f }, /* HP out */
8282 { }
8283 },
8284 .chained = true,
8285 .chain_id = ALC662_FIXUP_SKU_IGNORE
8286 },
8287 [ALC662_FIXUP_ASUS_MODE2] = {
1727a771
TI
8288 .type = HDA_FIXUP_PINS,
8289 .v.pins = (const struct hda_pintbl[]) {
2996bdba
TI
8290 { 0x14, 0x99130110 }, /* speaker */
8291 { 0x18, 0x01a19820 }, /* mic */
8292 { 0x19, 0x99a3092f }, /* int-mic */
8293 { 0x1b, 0x0121401f }, /* HP out */
8294 { }
8295 },
53c334ad
TI
8296 .chained = true,
8297 .chain_id = ALC662_FIXUP_SKU_IGNORE
8298 },
8299 [ALC662_FIXUP_ASUS_MODE3] = {
1727a771
TI
8300 .type = HDA_FIXUP_PINS,
8301 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8302 { 0x14, 0x99130110 }, /* speaker */
8303 { 0x15, 0x0121441f }, /* HP */
8304 { 0x18, 0x01a19840 }, /* mic */
8305 { 0x19, 0x99a3094f }, /* int-mic */
8306 { 0x21, 0x01211420 }, /* HP2 */
8307 { }
8308 },
8309 .chained = true,
8310 .chain_id = ALC662_FIXUP_SKU_IGNORE
8311 },
8312 [ALC662_FIXUP_ASUS_MODE4] = {
1727a771
TI
8313 .type = HDA_FIXUP_PINS,
8314 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8315 { 0x14, 0x99130110 }, /* speaker */
8316 { 0x16, 0x99130111 }, /* speaker */
8317 { 0x18, 0x01a19840 }, /* mic */
8318 { 0x19, 0x99a3094f }, /* int-mic */
8319 { 0x21, 0x0121441f }, /* HP */
8320 { }
8321 },
8322 .chained = true,
8323 .chain_id = ALC662_FIXUP_SKU_IGNORE
8324 },
8325 [ALC662_FIXUP_ASUS_MODE5] = {
1727a771
TI
8326 .type = HDA_FIXUP_PINS,
8327 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8328 { 0x14, 0x99130110 }, /* speaker */
8329 { 0x15, 0x0121441f }, /* HP */
8330 { 0x16, 0x99130111 }, /* speaker */
8331 { 0x18, 0x01a19840 }, /* mic */
8332 { 0x19, 0x99a3094f }, /* int-mic */
8333 { }
8334 },
8335 .chained = true,
8336 .chain_id = ALC662_FIXUP_SKU_IGNORE
8337 },
8338 [ALC662_FIXUP_ASUS_MODE6] = {
1727a771
TI
8339 .type = HDA_FIXUP_PINS,
8340 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8341 { 0x14, 0x99130110 }, /* speaker */
8342 { 0x15, 0x01211420 }, /* HP2 */
8343 { 0x18, 0x01a19840 }, /* mic */
8344 { 0x19, 0x99a3094f }, /* int-mic */
8345 { 0x1b, 0x0121441f }, /* HP */
8346 { }
8347 },
8348 .chained = true,
8349 .chain_id = ALC662_FIXUP_SKU_IGNORE
8350 },
8351 [ALC662_FIXUP_ASUS_MODE7] = {
1727a771
TI
8352 .type = HDA_FIXUP_PINS,
8353 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8354 { 0x14, 0x99130110 }, /* speaker */
8355 { 0x17, 0x99130111 }, /* speaker */
8356 { 0x18, 0x01a19840 }, /* mic */
8357 { 0x19, 0x99a3094f }, /* int-mic */
8358 { 0x1b, 0x01214020 }, /* HP */
8359 { 0x21, 0x0121401f }, /* HP */
8360 { }
8361 },
8362 .chained = true,
8363 .chain_id = ALC662_FIXUP_SKU_IGNORE
8364 },
8365 [ALC662_FIXUP_ASUS_MODE8] = {
1727a771
TI
8366 .type = HDA_FIXUP_PINS,
8367 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8368 { 0x14, 0x99130110 }, /* speaker */
8369 { 0x12, 0x99a30970 }, /* int-mic */
8370 { 0x15, 0x01214020 }, /* HP */
8371 { 0x17, 0x99130111 }, /* speaker */
8372 { 0x18, 0x01a19840 }, /* mic */
8373 { 0x21, 0x0121401f }, /* HP */
8374 { }
8375 },
8376 .chained = true,
8377 .chain_id = ALC662_FIXUP_SKU_IGNORE
2996bdba 8378 },
1565cc35 8379 [ALC662_FIXUP_NO_JACK_DETECT] = {
1727a771 8380 .type = HDA_FIXUP_FUNC,
1565cc35
TI
8381 .v.func = alc_fixup_no_jack_detect,
8382 },
edfe3bfc 8383 [ALC662_FIXUP_ZOTAC_Z68] = {
1727a771
TI
8384 .type = HDA_FIXUP_PINS,
8385 .v.pins = (const struct hda_pintbl[]) {
edfe3bfc
DH
8386 { 0x1b, 0x02214020 }, /* Front HP */
8387 { }
8388 }
8389 },
125821ae 8390 [ALC662_FIXUP_INV_DMIC] = {
1727a771 8391 .type = HDA_FIXUP_FUNC,
9d36a7dc 8392 .v.func = alc_fixup_inv_dmic,
125821ae 8393 },
033b0a7c
GM
8394 [ALC668_FIXUP_DELL_XPS13] = {
8395 .type = HDA_FIXUP_FUNC,
8396 .v.func = alc_fixup_dell_xps13,
8397 .chained = true,
8398 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
8399 },
5e6db669
GM
8400 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
8401 .type = HDA_FIXUP_FUNC,
8402 .v.func = alc_fixup_disable_aamix,
8403 .chained = true,
8404 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
8405 },
493a52a9
HW
8406 [ALC668_FIXUP_AUTO_MUTE] = {
8407 .type = HDA_FIXUP_FUNC,
8408 .v.func = alc_fixup_auto_mute_via_amp,
8409 .chained = true,
8410 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
8411 },
1f8b46cd
DH
8412 [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
8413 .type = HDA_FIXUP_PINS,
8414 .v.pins = (const struct hda_pintbl[]) {
8415 { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8416 /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
8417 { }
8418 },
8419 .chained = true,
8420 .chain_id = ALC662_FIXUP_HEADSET_MODE
8421 },
8422 [ALC662_FIXUP_HEADSET_MODE] = {
8423 .type = HDA_FIXUP_FUNC,
8424 .v.func = alc_fixup_headset_mode_alc662,
8425 },
73bdd597
DH
8426 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
8427 .type = HDA_FIXUP_PINS,
8428 .v.pins = (const struct hda_pintbl[]) {
8429 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8430 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8431 { }
8432 },
8433 .chained = true,
8434 .chain_id = ALC668_FIXUP_HEADSET_MODE
8435 },
8436 [ALC668_FIXUP_HEADSET_MODE] = {
8437 .type = HDA_FIXUP_FUNC,
8438 .v.func = alc_fixup_headset_mode_alc668,
8439 },
8e54b4ac 8440 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
8e383953 8441 .type = HDA_FIXUP_FUNC,
eb9ca3ab 8442 .v.func = alc_fixup_bass_chmap,
8e383953
TI
8443 .chained = true,
8444 .chain_id = ALC662_FIXUP_ASUS_MODE4
8445 },
61a75f13
DH
8446 [ALC662_FIXUP_BASS_16] = {
8447 .type = HDA_FIXUP_PINS,
8448 .v.pins = (const struct hda_pintbl[]) {
8449 {0x16, 0x80106111}, /* bass speaker */
8450 {}
8451 },
8452 .chained = true,
8453 .chain_id = ALC662_FIXUP_BASS_CHMAP,
8454 },
a30c9aaa
TI
8455 [ALC662_FIXUP_BASS_1A] = {
8456 .type = HDA_FIXUP_PINS,
8457 .v.pins = (const struct hda_pintbl[]) {
8458 {0x1a, 0x80106111}, /* bass speaker */
8459 {}
8460 },
8e54b4ac
DH
8461 .chained = true,
8462 .chain_id = ALC662_FIXUP_BASS_CHMAP,
a30c9aaa 8463 },
8e54b4ac 8464 [ALC662_FIXUP_BASS_CHMAP] = {
a30c9aaa 8465 .type = HDA_FIXUP_FUNC,
eb9ca3ab 8466 .v.func = alc_fixup_bass_chmap,
a30c9aaa 8467 },
9d4dc584
BM
8468 [ALC662_FIXUP_ASUS_Nx50] = {
8469 .type = HDA_FIXUP_FUNC,
8470 .v.func = alc_fixup_auto_mute_via_amp,
8471 .chained = true,
8472 .chain_id = ALC662_FIXUP_BASS_1A
8473 },
fc7438b1
MP
8474 [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
8475 .type = HDA_FIXUP_FUNC,
8476 .v.func = alc_fixup_headset_mode_alc668,
8477 .chain_id = ALC662_FIXUP_BASS_CHMAP
8478 },
3231e205
YP
8479 [ALC668_FIXUP_ASUS_Nx51] = {
8480 .type = HDA_FIXUP_PINS,
8481 .v.pins = (const struct hda_pintbl[]) {
fc7438b1
MP
8482 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8483 { 0x1a, 0x90170151 }, /* bass speaker */
8484 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
3231e205
YP
8485 {}
8486 },
8487 .chained = true,
fc7438b1 8488 .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3231e205 8489 },
73d9844f 8490 [ALC668_FIXUP_MIC_COEF] = {
495b327b
TI
8491 .type = HDA_FIXUP_VERBS,
8492 .v.verbs = (const struct hda_verb[]) {
8493 { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
8494 { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
8495 {}
8496 },
8497 },
73d9844f
TI
8498 [ALC668_FIXUP_ASUS_G751] = {
8499 .type = HDA_FIXUP_PINS,
8500 .v.pins = (const struct hda_pintbl[]) {
8501 { 0x16, 0x0421101f }, /* HP */
8502 {}
8503 },
8504 .chained = true,
8505 .chain_id = ALC668_FIXUP_MIC_COEF
8506 },
78f4f7c2
KY
8507 [ALC891_FIXUP_HEADSET_MODE] = {
8508 .type = HDA_FIXUP_FUNC,
8509 .v.func = alc_fixup_headset_mode,
8510 },
8511 [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
8512 .type = HDA_FIXUP_PINS,
8513 .v.pins = (const struct hda_pintbl[]) {
8514 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8515 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8516 { }
8517 },
8518 .chained = true,
8519 .chain_id = ALC891_FIXUP_HEADSET_MODE
8520 },
9b51fe3e
SB
8521 [ALC662_FIXUP_ACER_VERITON] = {
8522 .type = HDA_FIXUP_PINS,
8523 .v.pins = (const struct hda_pintbl[]) {
8524 { 0x15, 0x50170120 }, /* no internal speaker */
8525 { }
8526 }
8527 },
1a3f0991
TI
8528 [ALC892_FIXUP_ASROCK_MOBO] = {
8529 .type = HDA_FIXUP_PINS,
8530 .v.pins = (const struct hda_pintbl[]) {
8531 { 0x15, 0x40f000f0 }, /* disabled */
8532 { 0x16, 0x40f000f0 }, /* disabled */
1a3f0991
TI
8533 { }
8534 }
8535 },
c6790c8e
KY
8536 [ALC662_FIXUP_USI_FUNC] = {
8537 .type = HDA_FIXUP_FUNC,
8538 .v.func = alc662_fixup_usi_headset_mic,
8539 },
8540 [ALC662_FIXUP_USI_HEADSET_MODE] = {
8541 .type = HDA_FIXUP_PINS,
8542 .v.pins = (const struct hda_pintbl[]) {
8543 { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
8544 { 0x18, 0x01a1903d },
8545 { }
8546 },
8547 .chained = true,
8548 .chain_id = ALC662_FIXUP_USI_FUNC
8549 },
ca169cc2
KY
8550 [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
8551 .type = HDA_FIXUP_FUNC,
8552 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
8553 },
6cb3b707
DH
8554};
8555
a9111321 8556static const struct snd_pci_quirk alc662_fixup_tbl[] = {
53c334ad 8557 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
d3d3835c 8558 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
02f6ff90 8559 SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
a6c47a85 8560 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
94024cd1 8561 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
125821ae 8562 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
1801928e 8563 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
2df03514 8564 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
73bdd597
DH
8565 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8566 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
c5d019c3 8567 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
033b0a7c 8568 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
467e1436 8569 SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
09d2014f 8570 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
ad8ff99e 8571 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8dc9abb9
KY
8572 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8573 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6a98e34b 8574 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
e59ea3ed 8575 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
2da2dc9e 8576 SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
83a9efb5 8577 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
db8948e6 8578 SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
9d4dc584 8579 SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
495b327b 8580 SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
8e54b4ac 8581 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
61a75f13 8582 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
3231e205
YP
8583 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
8584 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
c7efff92 8585 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
61a75f13 8586 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8e54b4ac 8587 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
1565cc35 8588 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
53c334ad 8589 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
a0e90acc 8590 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
c6790c8e 8591 SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
ca169cc2 8592 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
d4118588 8593 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6cb3b707 8594 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
1a3f0991 8595 SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
edfe3bfc 8596 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
9b51fe3e 8597 SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
d2ebd479 8598 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
53c334ad
TI
8599
8600#if 0
8601 /* Below is a quirk table taken from the old code.
8602 * Basically the device should work as is without the fixup table.
8603 * If BIOS doesn't give a proper info, enable the corresponding
8604 * fixup entry.
7d7eb9ea 8605 */
53c334ad
TI
8606 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
8607 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
8608 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
8609 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
8610 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8611 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8612 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8613 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
8614 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
8615 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8616 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
8617 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
8618 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
8619 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
8620 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
8621 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8622 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
8623 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
8624 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8625 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8626 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8627 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8628 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
8629 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
8630 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
8631 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8632 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
8633 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8634 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8635 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
8636 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8637 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8638 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
8639 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
8640 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
8641 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
8642 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
8643 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
8644 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
8645 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8646 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
8647 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
8648 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8649 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
8650 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
8651 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
8652 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
8653 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
8654 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8655 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
8656#endif
6cb3b707
DH
8657 {}
8658};
8659
1727a771 8660static const struct hda_model_fixup alc662_fixup_models[] = {
6be7948f 8661 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
53c334ad
TI
8662 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
8663 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
8664 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
8665 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
8666 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
8667 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
8668 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
8669 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6e72aa5f 8670 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
e32aa85a 8671 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
ba90d6a6 8672 {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
6be7948f
TB
8673 {}
8674};
6cb3b707 8675
532895c5 8676static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
78f4f7c2
KY
8677 SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
8678 {0x17, 0x02211010},
8679 {0x18, 0x01a19030},
8680 {0x1a, 0x01813040},
8681 {0x21, 0x01014020}),
0b6758d3
HW
8682 SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
8683 {0x16, 0x01813030},
8684 {0x17, 0x02211010},
8685 {0x18, 0x01a19040},
8686 {0x21, 0x01014020}),
1f8b46cd 8687 SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
1f8b46cd 8688 {0x14, 0x01014010},
1f8b46cd 8689 {0x18, 0x01a19020},
1f8b46cd 8690 {0x1a, 0x0181302f},
11580297 8691 {0x1b, 0x0221401f}),
76c2132e
DH
8692 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8693 {0x12, 0x99a30130},
8694 {0x14, 0x90170110},
8695 {0x15, 0x0321101f},
11580297 8696 {0x16, 0x03011020}),
76c2132e
DH
8697 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8698 {0x12, 0x99a30140},
8699 {0x14, 0x90170110},
8700 {0x15, 0x0321101f},
11580297 8701 {0x16, 0x03011020}),
76c2132e
DH
8702 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8703 {0x12, 0x99a30150},
8704 {0x14, 0x90170110},
8705 {0x15, 0x0321101f},
11580297 8706 {0x16, 0x03011020}),
76c2132e 8707 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
76c2132e
DH
8708 {0x14, 0x90170110},
8709 {0x15, 0x0321101f},
11580297 8710 {0x16, 0x03011020}),
76c2132e
DH
8711 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
8712 {0x12, 0x90a60130},
8713 {0x14, 0x90170110},
11580297 8714 {0x15, 0x0321101f}),
532895c5
HW
8715 {}
8716};
8717
1d045db9
TI
8718/*
8719 */
bc9f98a9
KY
8720static int patch_alc662(struct hda_codec *codec)
8721{
8722 struct alc_spec *spec;
3de95173 8723 int err;
bc9f98a9 8724
3de95173
TI
8725 err = alc_alloc_spec(codec, 0x0b);
8726 if (err < 0)
8727 return err;
bc9f98a9 8728
3de95173 8729 spec = codec->spec;
1f0f4b80 8730
225068ab
TI
8731 spec->shutup = alc_eapd_shutup;
8732
53c334ad
TI
8733 /* handle multiple HPs as is */
8734 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
8735
2c3bf9ab
TI
8736 alc_fix_pll_init(codec, 0x20, 0x04, 15);
8737
7639a06c 8738 switch (codec->core.vendor_id) {
f3f9185f
KY
8739 case 0x10ec0668:
8740 spec->init_hook = alc668_restore_default_value;
8741 break;
f3f9185f 8742 }
8663ff75 8743
1727a771 8744 snd_hda_pick_fixup(codec, alc662_fixup_models,
8e5a0509 8745 alc662_fixup_tbl, alc662_fixups);
31d7a6e3 8746 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
1727a771 8747 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8e5a0509
TI
8748
8749 alc_auto_parse_customize_define(codec);
8750
7504b6cd
TI
8751 if (has_cdefine_beep(codec))
8752 spec->gen.beep_nid = 0x01;
8753
1bb7e43e 8754 if ((alc_get_coef0(codec) & (1 << 14)) &&
5100cd07 8755 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 8756 spec->cdefine.platform_type == 1) {
6134b1a2
WY
8757 err = alc_codec_rename(codec, "ALC272X");
8758 if (err < 0)
e16fb6d1 8759 goto error;
20ca0c35 8760 }
274693f3 8761
b9c5106c
TI
8762 /* automatic parse from the BIOS config */
8763 err = alc662_parse_auto_config(codec);
e16fb6d1
TI
8764 if (err < 0)
8765 goto error;
bc9f98a9 8766
7504b6cd 8767 if (!spec->gen.no_analog && spec->gen.beep_nid) {
7639a06c 8768 switch (codec->core.vendor_id) {
da00c244
KY
8769 case 0x10ec0662:
8770 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
8771 break;
8772 case 0x10ec0272:
8773 case 0x10ec0663:
8774 case 0x10ec0665:
9ad54547 8775 case 0x10ec0668:
da00c244
KY
8776 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
8777 break;
8778 case 0x10ec0273:
8779 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
8780 break;
8781 }
cec27c89 8782 }
2134ea4f 8783
1727a771 8784 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 8785
bc9f98a9 8786 return 0;
801f49d3 8787
e16fb6d1
TI
8788 error:
8789 alc_free(codec);
8790 return err;
b478b998
KY
8791}
8792
d1eb57f4
KY
8793/*
8794 * ALC680 support
8795 */
d1eb57f4 8796
d1eb57f4
KY
8797static int alc680_parse_auto_config(struct hda_codec *codec)
8798{
3e6179b8 8799 return alc_parse_auto_config(codec, NULL, NULL);
d1eb57f4
KY
8800}
8801
d1eb57f4 8802/*
d1eb57f4 8803 */
d1eb57f4
KY
8804static int patch_alc680(struct hda_codec *codec)
8805{
d1eb57f4
KY
8806 int err;
8807
1f0f4b80 8808 /* ALC680 has no aa-loopback mixer */
3de95173
TI
8809 err = alc_alloc_spec(codec, 0);
8810 if (err < 0)
8811 return err;
1f0f4b80 8812
1ebec5f2
TI
8813 /* automatic parse from the BIOS config */
8814 err = alc680_parse_auto_config(codec);
8815 if (err < 0) {
8816 alc_free(codec);
8817 return err;
d1eb57f4
KY
8818 }
8819
d1eb57f4
KY
8820 return 0;
8821}
8822
1da177e4
LT
8823/*
8824 * patch entries
8825 */
b9a94a9c 8826static const struct hda_device_id snd_hda_id_realtek[] = {
0a6f0600 8827 HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
b9a94a9c 8828 HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
369b3f52 8829 HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
4231430d 8830 HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
b9a94a9c
TI
8831 HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
8832 HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
dcd4f0db 8833 HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
b9a94a9c 8834 HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
736f20a7 8835 HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
b9a94a9c
TI
8836 HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
8837 HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
f429e7e4 8838 HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
b9a94a9c
TI
8839 HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
8840 HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
8841 HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
8842 HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
8843 HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
8844 HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
8845 HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
dcd4f0db 8846 HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
b9a94a9c
TI
8847 HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
8848 HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
8849 HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
8850 HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
8851 HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
8852 HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
0a6f0600 8853 HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
b9a94a9c
TI
8854 HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
8855 HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
0a6f0600 8856 HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
b9a94a9c
TI
8857 HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
8858 HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
8859 HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
dcd4f0db 8860 HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
7d727869 8861 HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
b9a94a9c 8862 HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
28f1f9b2 8863 HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
9887cf53 8864 HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
8666616e 8865 HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
b9a94a9c
TI
8866 HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
8867 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
8868 HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
8869 HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
8870 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
8871 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
8872 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
8873 HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
8874 HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
8875 HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
8876 HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
8877 HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
8878 HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
8879 HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
6fbae35a
KY
8880 HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
8881 HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
8882 HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
0b2d4d6c 8883 HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
78f4f7c2 8884 HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
b9a94a9c
TI
8885 HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
8886 HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
8887 HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
8888 HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
8889 HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
8890 HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
8891 HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
8892 HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
8893 HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
8894 HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
8895 HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
8896 HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
8897 HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
b312cc3e 8898 HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
65553b12 8899 HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
a535ad57 8900 HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
1da177e4
LT
8901 {} /* terminator */
8902};
b9a94a9c 8903MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
1289e9e8
TI
8904
8905MODULE_LICENSE("GPL");
8906MODULE_DESCRIPTION("Realtek HD-audio codec");
8907
d8a766a1 8908static struct hda_codec_driver realtek_driver = {
b9a94a9c 8909 .id = snd_hda_id_realtek,
1289e9e8
TI
8910};
8911
d8a766a1 8912module_hda_codec_driver(realtek_driver);