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