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