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