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