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