]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - sound/pci/hda/patch_realtek.c
Revert "net: phy: marvell: avoid pause mode on SGMII-to-Copper for 88e151x"
[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
cb149cb3
KY
2976 alc282_restore_default_value(codec);
2977
7b5c7a02
KY
2978 if (!hp_pin)
2979 return;
2980 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2981 coef78 = alc_read_coef_idx(codec, 0x78);
2982
2983 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2984 /* Headphone capless set to high power mode */
2985 alc_write_coef_idx(codec, 0x78, 0x9004);
2986
2987 if (hp_pin_sense)
2988 msleep(2);
2989
2990 snd_hda_codec_write(codec, hp_pin, 0,
2991 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2992
2993 if (hp_pin_sense)
2994 msleep(85);
2995
2996 snd_hda_codec_write(codec, hp_pin, 0,
2997 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2998
2999 if (hp_pin_sense)
3000 msleep(100);
3001
3002 /* Headphone capless set to normal mode */
3003 alc_write_coef_idx(codec, 0x78, coef78);
3004}
3005
3006static void alc282_shutup(struct hda_codec *codec)
3007{
3008 struct alc_spec *spec = codec->spec;
80f10932 3009 hda_nid_t hp_pin = alc_get_hp_pin(spec);
7b5c7a02
KY
3010 bool hp_pin_sense;
3011 int coef78;
3012
3013 if (!hp_pin) {
3014 alc269_shutup(codec);
3015 return;
3016 }
3017
3018 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3019 coef78 = alc_read_coef_idx(codec, 0x78);
3020 alc_write_coef_idx(codec, 0x78, 0x9004);
3021
3022 if (hp_pin_sense)
3023 msleep(2);
3024
3025 snd_hda_codec_write(codec, hp_pin, 0,
3026 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3027
3028 if (hp_pin_sense)
3029 msleep(85);
3030
b001f661
TI
3031 if (!spec->no_shutup_pins)
3032 snd_hda_codec_write(codec, hp_pin, 0,
3033 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
7b5c7a02
KY
3034
3035 if (hp_pin_sense)
3036 msleep(100);
3037
3038 alc_auto_setup_eapd(codec, false);
b001f661 3039 alc_shutup_pins(codec);
7b5c7a02
KY
3040 alc_write_coef_idx(codec, 0x78, coef78);
3041}
3042
54db6c39
TI
3043static struct coef_fw alc283_coefs[] = {
3044 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
56779864 3045 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
54db6c39
TI
3046 WRITE_COEF(0x07, 0x0200), /* DMIC control */
3047 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3048 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3049 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3050 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3051 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3052 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3053 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3054 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3055 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3056 WRITE_COEF(0x22, 0xa0c0), /* ANC */
3057 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3058 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3059 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3060 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3061 WRITE_COEF(0x2e, 0x2902), /* PLL */
3062 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3063 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3064 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3065 WRITE_COEF(0x36, 0x0), /* capless control 5 */
3066 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3067 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3068 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3069 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3070 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3071 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3072 WRITE_COEF(0x49, 0x0), /* test mode */
3073 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3074 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3075 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
56779864 3076 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
54db6c39
TI
3077 {}
3078};
3079
6bd55b04
KY
3080static void alc283_restore_default_value(struct hda_codec *codec)
3081{
54db6c39 3082 alc_process_coef_fw(codec, alc283_coefs);
6bd55b04
KY
3083}
3084
2af02be7
KY
3085static void alc283_init(struct hda_codec *codec)
3086{
3087 struct alc_spec *spec = codec->spec;
80f10932 3088 hda_nid_t hp_pin = alc_get_hp_pin(spec);
2af02be7 3089 bool hp_pin_sense;
2af02be7 3090
6bd55b04
KY
3091 alc283_restore_default_value(codec);
3092
2af02be7
KY
3093 if (!hp_pin)
3094 return;
a59d7199
KY
3095
3096 msleep(30);
2af02be7
KY
3097 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3098
3099 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3100 /* Headphone capless set to high power mode */
3101 alc_write_coef_idx(codec, 0x43, 0x9004);
3102
3103 snd_hda_codec_write(codec, hp_pin, 0,
3104 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3105
3106 if (hp_pin_sense)
3107 msleep(85);
3108
3109 snd_hda_codec_write(codec, hp_pin, 0,
3110 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3111
3112 if (hp_pin_sense)
3113 msleep(85);
3114 /* Index 0x46 Combo jack auto switch control 2 */
3115 /* 3k pull low control for Headset jack. */
98b24883 3116 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
2af02be7
KY
3117 /* Headphone capless set to normal mode */
3118 alc_write_coef_idx(codec, 0x43, 0x9614);
3119}
3120
3121static void alc283_shutup(struct hda_codec *codec)
3122{
3123 struct alc_spec *spec = codec->spec;
80f10932 3124 hda_nid_t hp_pin = alc_get_hp_pin(spec);
2af02be7 3125 bool hp_pin_sense;
2af02be7
KY
3126
3127 if (!hp_pin) {
3128 alc269_shutup(codec);
3129 return;
3130 }
3131
3132 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3133
3134 alc_write_coef_idx(codec, 0x43, 0x9004);
3135
b450b17c
HP
3136 /*depop hp during suspend*/
3137 alc_write_coef_idx(codec, 0x06, 0x2100);
3138
2af02be7
KY
3139 snd_hda_codec_write(codec, hp_pin, 0,
3140 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3141
3142 if (hp_pin_sense)
88011c09 3143 msleep(100);
2af02be7 3144
b001f661
TI
3145 if (!spec->no_shutup_pins)
3146 snd_hda_codec_write(codec, hp_pin, 0,
3147 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2af02be7 3148
98b24883 3149 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
2af02be7
KY
3150
3151 if (hp_pin_sense)
88011c09 3152 msleep(100);
0435b3ff 3153 alc_auto_setup_eapd(codec, false);
b001f661 3154 alc_shutup_pins(codec);
2af02be7
KY
3155 alc_write_coef_idx(codec, 0x43, 0x9614);
3156}
3157
4a219ef8
KY
3158static void alc256_init(struct hda_codec *codec)
3159{
3160 struct alc_spec *spec = codec->spec;
80f10932 3161 hda_nid_t hp_pin = alc_get_hp_pin(spec);
4a219ef8
KY
3162 bool hp_pin_sense;
3163
3164 if (!hp_pin)
3165 return;
3166
3167 msleep(30);
3168
3169 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3170
3171 if (hp_pin_sense)
3172 msleep(2);
3173
3174 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3175
3176 snd_hda_codec_write(codec, hp_pin, 0,
3177 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3178
3179 if (hp_pin_sense)
3180 msleep(85);
3181
3182 snd_hda_codec_write(codec, hp_pin, 0,
3183 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3184
3185 if (hp_pin_sense)
3186 msleep(100);
3187
3188 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3189 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
fc434f5a
KY
3190 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3191 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
4a219ef8
KY
3192}
3193
3194static void alc256_shutup(struct hda_codec *codec)
3195{
3196 struct alc_spec *spec = codec->spec;
80f10932 3197 hda_nid_t hp_pin = alc_get_hp_pin(spec);
4a219ef8
KY
3198 bool hp_pin_sense;
3199
3200 if (!hp_pin) {
3201 alc269_shutup(codec);
3202 return;
3203 }
3204
3205 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3206
3207 if (hp_pin_sense)
3208 msleep(2);
3209
3210 snd_hda_codec_write(codec, hp_pin, 0,
3211 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3212
3213 if (hp_pin_sense)
3214 msleep(85);
3215
e9d7786a
TI
3216 /* 3k pull low control for Headset jack. */
3217 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3218 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3219
b001f661
TI
3220 if (!spec->no_shutup_pins)
3221 snd_hda_codec_write(codec, hp_pin, 0,
3222 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4a219ef8 3223
4a219ef8
KY
3224 if (hp_pin_sense)
3225 msleep(100);
3226
3227 alc_auto_setup_eapd(codec, false);
b001f661 3228 alc_shutup_pins(codec);
4a219ef8
KY
3229}
3230
0b4d8f55
KY
3231static void alc225_init(struct hda_codec *codec)
3232{
3233 struct alc_spec *spec = codec->spec;
80f10932 3234 hda_nid_t hp_pin = alc_get_hp_pin(spec);
0b4d8f55
KY
3235 bool hp1_pin_sense, hp2_pin_sense;
3236
3237 if (!hp_pin)
3238 return;
3239
3240 msleep(30);
3241
3242 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3243 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3244
3245 if (hp1_pin_sense || hp2_pin_sense)
3246 msleep(2);
3247
3248 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3249
3250 if (hp1_pin_sense)
3251 snd_hda_codec_write(codec, hp_pin, 0,
3252 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3253 if (hp2_pin_sense)
3254 snd_hda_codec_write(codec, 0x16, 0,
3255 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3256
3257 if (hp1_pin_sense || hp2_pin_sense)
3258 msleep(85);
3259
3260 if (hp1_pin_sense)
3261 snd_hda_codec_write(codec, hp_pin, 0,
3262 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3263 if (hp2_pin_sense)
3264 snd_hda_codec_write(codec, 0x16, 0,
3265 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3266
3267 if (hp1_pin_sense || hp2_pin_sense)
3268 msleep(100);
3269
3270 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3271 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3272}
3273
3274static void alc225_shutup(struct hda_codec *codec)
3275{
3276 struct alc_spec *spec = codec->spec;
80f10932 3277 hda_nid_t hp_pin = alc_get_hp_pin(spec);
0b4d8f55
KY
3278 bool hp1_pin_sense, hp2_pin_sense;
3279
3280 if (!hp_pin) {
3281 alc269_shutup(codec);
3282 return;
3283 }
3284
3285 /* 3k pull low control for Headset jack. */
3286 alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3287
3288 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3289 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3290
3291 if (hp1_pin_sense || hp2_pin_sense)
3292 msleep(2);
3293
3294 if (hp1_pin_sense)
3295 snd_hda_codec_write(codec, hp_pin, 0,
3296 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3297 if (hp2_pin_sense)
3298 snd_hda_codec_write(codec, 0x16, 0,
3299 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3300
3301 if (hp1_pin_sense || hp2_pin_sense)
3302 msleep(85);
3303
3304 if (hp1_pin_sense)
3305 snd_hda_codec_write(codec, hp_pin, 0,
3306 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3307 if (hp2_pin_sense)
3308 snd_hda_codec_write(codec, 0x16, 0,
3309 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3310
3311 if (hp1_pin_sense || hp2_pin_sense)
3312 msleep(100);
3313
3314 alc_auto_setup_eapd(codec, false);
b001f661 3315 alc_shutup_pins(codec);
0b4d8f55
KY
3316}
3317
c2d6af53
KY
3318static void alc_default_init(struct hda_codec *codec)
3319{
3320 struct alc_spec *spec = codec->spec;
80f10932 3321 hda_nid_t hp_pin = alc_get_hp_pin(spec);
c2d6af53
KY
3322 bool hp_pin_sense;
3323
3324 if (!hp_pin)
3325 return;
3326
3327 msleep(30);
3328
3329 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3330
3331 if (hp_pin_sense)
3332 msleep(2);
3333
3334 snd_hda_codec_write(codec, hp_pin, 0,
3335 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3336
3337 if (hp_pin_sense)
3338 msleep(85);
3339
3340 snd_hda_codec_write(codec, hp_pin, 0,
3341 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3342
3343 if (hp_pin_sense)
3344 msleep(100);
3345}
3346
3347static void alc_default_shutup(struct hda_codec *codec)
3348{
3349 struct alc_spec *spec = codec->spec;
80f10932 3350 hda_nid_t hp_pin = alc_get_hp_pin(spec);
c2d6af53
KY
3351 bool hp_pin_sense;
3352
3353 if (!hp_pin) {
3354 alc269_shutup(codec);
3355 return;
3356 }
3357
3358 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3359
3360 if (hp_pin_sense)
3361 msleep(2);
3362
3363 snd_hda_codec_write(codec, hp_pin, 0,
3364 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3365
3366 if (hp_pin_sense)
3367 msleep(85);
3368
b001f661
TI
3369 if (!spec->no_shutup_pins)
3370 snd_hda_codec_write(codec, hp_pin, 0,
3371 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
c2d6af53
KY
3372
3373 if (hp_pin_sense)
3374 msleep(100);
3375
3376 alc_auto_setup_eapd(codec, false);
b001f661 3377 alc_shutup_pins(codec);
c2d6af53
KY
3378}
3379
6e25f0c7
KY
3380static void alc294_hp_init(struct hda_codec *codec)
3381{
3382 struct alc_spec *spec = codec->spec;
80f10932 3383 hda_nid_t hp_pin = alc_get_hp_pin(spec);
6e25f0c7
KY
3384 int i, val;
3385
3386 if (!hp_pin)
3387 return;
3388
3389 snd_hda_codec_write(codec, hp_pin, 0,
3390 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3391
3392 msleep(100);
3393
3394 snd_hda_codec_write(codec, hp_pin, 0,
3395 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3396
3397 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3398 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3399
3400 /* Wait for depop procedure finish */
3401 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3402 for (i = 0; i < 20 && val & 0x0080; i++) {
3403 msleep(50);
3404 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3405 }
3406 /* Set HP depop to auto mode */
3407 alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3408 msleep(50);
3409}
3410
3411static void alc294_init(struct hda_codec *codec)
3412{
3413 struct alc_spec *spec = codec->spec;
3414
3415 if (!spec->done_hp_init) {
3416 alc294_hp_init(codec);
3417 spec->done_hp_init = true;
3418 }
3419 alc_default_init(codec);
3420}
3421
ad60d502
KY
3422static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3423 unsigned int val)
3424{
3425 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3426 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3427 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3428}
3429
3430static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3431{
3432 unsigned int val;
3433
3434 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3435 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3436 & 0xffff;
3437 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3438 << 16;
3439 return val;
3440}
3441
3442static void alc5505_dsp_halt(struct hda_codec *codec)
3443{
3444 unsigned int val;
3445
3446 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3447 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3448 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3449 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3450 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3451 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3452 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3453 val = alc5505_coef_get(codec, 0x6220);
3454 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3455}
3456
3457static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3458{
3459 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3460 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3461 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3462 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3463 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3464 alc5505_coef_set(codec, 0x880c, 0x00000004);
3465}
3466
3467static void alc5505_dsp_init(struct hda_codec *codec)
3468{
3469 unsigned int val;
3470
3471 alc5505_dsp_halt(codec);
3472 alc5505_dsp_back_from_halt(codec);
3473 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3474 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3475 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3476 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3477 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3478 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3479 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3480 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3481 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3482 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3483 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3484 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3485 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3486
3487 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3488 if (val <= 3)
3489 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3490 else
3491 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3492
3493 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3494 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3495 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3496 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3497 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3498 alc5505_coef_set(codec, 0x880c, 0x00000003);
3499 alc5505_coef_set(codec, 0x880c, 0x00000010);
cd63a5ff
TI
3500
3501#ifdef HALT_REALTEK_ALC5505
3502 alc5505_dsp_halt(codec);
3503#endif
ad60d502
KY
3504}
3505
cd63a5ff
TI
3506#ifdef HALT_REALTEK_ALC5505
3507#define alc5505_dsp_suspend(codec) /* NOP */
3508#define alc5505_dsp_resume(codec) /* NOP */
3509#else
3510#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3511#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3512#endif
3513
2a43952a 3514#ifdef CONFIG_PM
ad60d502
KY
3515static int alc269_suspend(struct hda_codec *codec)
3516{
3517 struct alc_spec *spec = codec->spec;
3518
3519 if (spec->has_alc5505_dsp)
cd63a5ff 3520 alc5505_dsp_suspend(codec);
ad60d502
KY
3521 return alc_suspend(codec);
3522}
3523
1d045db9
TI
3524static int alc269_resume(struct hda_codec *codec)
3525{
adcc70b2
KY
3526 struct alc_spec *spec = codec->spec;
3527
1387e2d1
KY
3528 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3529 alc269vb_toggle_power_output(codec, 0);
3530 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3531 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
3532 msleep(150);
3533 }
8c427226 3534
1d045db9 3535 codec->patch_ops.init(codec);
f1d4e28b 3536
1387e2d1
KY
3537 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3538 alc269vb_toggle_power_output(codec, 1);
3539 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3540 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
3541 msleep(200);
3542 }
f1d4e28b 3543
eeecd9d1 3544 regcache_sync(codec->core.regmap);
1d045db9 3545 hda_call_check_power_status(codec, 0x01);
f475371a
HW
3546
3547 /* on some machine, the BIOS will clear the codec gpio data when enter
3548 * suspend, and won't restore the data after resume, so we restore it
3549 * in the driver.
3550 */
3551 if (spec->gpio_led)
7639a06c 3552 snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DATA,
f475371a
HW
3553 spec->gpio_led);
3554
ad60d502 3555 if (spec->has_alc5505_dsp)
cd63a5ff 3556 alc5505_dsp_resume(codec);
c5177c86 3557
1d045db9
TI
3558 return 0;
3559}
2a43952a 3560#endif /* CONFIG_PM */
f1d4e28b 3561
108cc108 3562static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
1727a771 3563 const struct hda_fixup *fix, int action)
108cc108
DH
3564{
3565 struct alc_spec *spec = codec->spec;
3566
1727a771 3567 if (action == HDA_FIXUP_ACT_PRE_PROBE)
108cc108
DH
3568 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3569}
3570
0dcd451c
JMG
3571static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3572 const struct hda_fixup *fix,
3573 int action)
3574{
3575 unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3576 unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3577
3578 if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3579 snd_hda_codec_set_pincfg(codec, 0x19,
3580 (cfg_headphone & ~AC_DEFCFG_DEVICE) |
3581 (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3582}
3583
1d045db9 3584static void alc269_fixup_hweq(struct hda_codec *codec,
1727a771 3585 const struct hda_fixup *fix, int action)
1d045db9 3586{
98b24883
TI
3587 if (action == HDA_FIXUP_ACT_INIT)
3588 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
1d045db9 3589}
f1d4e28b 3590
7c478f03
DH
3591static void alc269_fixup_headset_mic(struct hda_codec *codec,
3592 const struct hda_fixup *fix, int action)
3593{
3594 struct alc_spec *spec = codec->spec;
3595
3596 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3597 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3598}
3599
1d045db9 3600static void alc271_fixup_dmic(struct hda_codec *codec,
1727a771 3601 const struct hda_fixup *fix, int action)
1d045db9
TI
3602{
3603 static const struct hda_verb verbs[] = {
3604 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3605 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3606 {}
3607 };
3608 unsigned int cfg;
f1d4e28b 3609
7639a06c
TI
3610 if (strcmp(codec->core.chip_name, "ALC271X") &&
3611 strcmp(codec->core.chip_name, "ALC269VB"))
1d045db9
TI
3612 return;
3613 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3614 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3615 snd_hda_sequence_write(codec, verbs);
3616}
f1d4e28b 3617
017f2a10 3618static void alc269_fixup_pcm_44k(struct hda_codec *codec,
1727a771 3619 const struct hda_fixup *fix, int action)
017f2a10
TI
3620{
3621 struct alc_spec *spec = codec->spec;
3622
1727a771 3623 if (action != HDA_FIXUP_ACT_PROBE)
017f2a10
TI
3624 return;
3625
3626 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3627 * fix the sample rate of analog I/O to 44.1kHz
3628 */
08c189f2
TI
3629 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3630 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
017f2a10
TI
3631}
3632
adabb3ec 3633static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
1727a771 3634 const struct hda_fixup *fix, int action)
adabb3ec 3635{
adabb3ec
TI
3636 /* The digital-mic unit sends PDM (differential signal) instead of
3637 * the standard PCM, thus you can't record a valid mono stream as is.
3638 * Below is a workaround specific to ALC269 to control the dmic
3639 * signal source as mono.
3640 */
98b24883
TI
3641 if (action == HDA_FIXUP_ACT_INIT)
3642 alc_update_coef_idx(codec, 0x07, 0, 0x80);
adabb3ec
TI
3643}
3644
24519911
TI
3645static void alc269_quanta_automute(struct hda_codec *codec)
3646{
08c189f2 3647 snd_hda_gen_update_outputs(codec);
24519911 3648
1687ccc8
TI
3649 alc_write_coef_idx(codec, 0x0c, 0x680);
3650 alc_write_coef_idx(codec, 0x0c, 0x480);
24519911
TI
3651}
3652
3653static void alc269_fixup_quanta_mute(struct hda_codec *codec,
1727a771 3654 const struct hda_fixup *fix, int action)
24519911
TI
3655{
3656 struct alc_spec *spec = codec->spec;
1727a771 3657 if (action != HDA_FIXUP_ACT_PROBE)
24519911 3658 return;
08c189f2 3659 spec->gen.automute_hook = alc269_quanta_automute;
24519911
TI
3660}
3661
d240d1dc 3662static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
1a4f69d5 3663 struct hda_jack_callback *jack)
d240d1dc
DH
3664{
3665 struct alc_spec *spec = codec->spec;
3666 int vref;
3667 msleep(200);
3668 snd_hda_gen_hp_automute(codec, jack);
3669
3670 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3671 msleep(100);
3672 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3673 vref);
3674 msleep(500);
3675 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3676 vref);
3677}
3678
3679static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3680 const struct hda_fixup *fix, int action)
3681{
3682 struct alc_spec *spec = codec->spec;
3683 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3684 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3685 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3686 }
3687}
3688
3689
08fb0d0e
TI
3690/* update mute-LED according to the speaker mute state via mic VREF pin */
3691static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
6d3cd5d4
DH
3692{
3693 struct hda_codec *codec = private_data;
08fb0d0e
TI
3694 struct alc_spec *spec = codec->spec;
3695 unsigned int pinval;
3696
3697 if (spec->mute_led_polarity)
3698 enabled = !enabled;
415d555e
TI
3699 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3700 pinval &= ~AC_PINCTL_VREFEN;
3701 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
52401e2a
TI
3702 if (spec->mute_led_nid) {
3703 /* temporarily power up/down for setting VREF */
3704 snd_hda_power_up_pm(codec);
08fb0d0e 3705 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
52401e2a
TI
3706 snd_hda_power_down_pm(codec);
3707 }
6d3cd5d4
DH
3708}
3709
d5b6b65e
DH
3710/* Make sure the led works even in runtime suspend */
3711static unsigned int led_power_filter(struct hda_codec *codec,
3712 hda_nid_t nid,
3713 unsigned int power_state)
3714{
3715 struct alc_spec *spec = codec->spec;
3716
50dd9050
HW
3717 if (power_state != AC_PWRST_D3 || nid == 0 ||
3718 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
d5b6b65e
DH
3719 return power_state;
3720
3721 /* Set pin ctl again, it might have just been set to 0 */
3722 snd_hda_set_pin_ctl(codec, nid,
3723 snd_hda_codec_get_pin_target(codec, nid));
3724
cffd3966 3725 return snd_hda_gen_path_power_filter(codec, nid, power_state);
d5b6b65e
DH
3726}
3727
08fb0d0e
TI
3728static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3729 const struct hda_fixup *fix, int action)
6d3cd5d4
DH
3730{
3731 struct alc_spec *spec = codec->spec;
08fb0d0e
TI
3732 const struct dmi_device *dev = NULL;
3733
3734 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3735 return;
3736
3737 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3738 int pol, pin;
3739 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3740 continue;
3741 if (pin < 0x0a || pin >= 0x10)
3742 break;
3743 spec->mute_led_polarity = pol;
3744 spec->mute_led_nid = pin - 0x0a + 0x18;
3745 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3746 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3747 codec->power_filter = led_power_filter;
4e76a883
TI
3748 codec_dbg(codec,
3749 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
08fb0d0e 3750 spec->mute_led_polarity);
6d3cd5d4
DH
3751 break;
3752 }
3753}
3754
d06ac143
DH
3755static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3756 const struct hda_fixup *fix, int action)
3757{
3758 struct alc_spec *spec = codec->spec;
3759 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3760 spec->mute_led_polarity = 0;
3761 spec->mute_led_nid = 0x18;
3762 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3763 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3764 codec->power_filter = led_power_filter;
d06ac143
DH
3765 }
3766}
3767
08fb0d0e
TI
3768static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3769 const struct hda_fixup *fix, int action)
420b0feb
TI
3770{
3771 struct alc_spec *spec = codec->spec;
9bb1f06f 3772 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08fb0d0e
TI
3773 spec->mute_led_polarity = 0;
3774 spec->mute_led_nid = 0x19;
3775 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3776 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3777 codec->power_filter = led_power_filter;
420b0feb
TI
3778 }
3779}
3780
0f32fd19
TI
3781/* update LED status via GPIO */
3782static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
3783 bool enabled)
9f5c6faf 3784{
9f5c6faf
TI
3785 struct alc_spec *spec = codec->spec;
3786 unsigned int oldval = spec->gpio_led;
3787
0f32fd19
TI
3788 if (spec->mute_led_polarity)
3789 enabled = !enabled;
3790
9f5c6faf 3791 if (enabled)
0f32fd19 3792 spec->gpio_led &= ~mask;
9f5c6faf 3793 else
0f32fd19 3794 spec->gpio_led |= mask;
9f5c6faf
TI
3795 if (spec->gpio_led != oldval)
3796 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3797 spec->gpio_led);
3798}
3799
0f32fd19
TI
3800/* turn on/off mute LED via GPIO per vmaster hook */
3801static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
9f5c6faf 3802{
0f32fd19 3803 struct hda_codec *codec = private_data;
9f5c6faf 3804 struct alc_spec *spec = codec->spec;
9f5c6faf 3805
0f32fd19
TI
3806 alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
3807}
9f5c6faf 3808
0f32fd19
TI
3809/* turn on/off mic-mute LED via GPIO per capture hook */
3810static void alc_fixup_gpio_mic_mute_hook(struct hda_codec *codec,
3811 struct snd_kcontrol *kcontrol,
3812 struct snd_ctl_elem_value *ucontrol)
3813{
3814 struct alc_spec *spec = codec->spec;
3815
3816 if (ucontrol)
3817 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
3818 ucontrol->value.integer.value[0] ||
3819 ucontrol->value.integer.value[1]);
9f5c6faf
TI
3820}
3821
3822static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3823 const struct hda_fixup *fix, int action)
3824{
3825 struct alc_spec *spec = codec->spec;
3826 static const struct hda_verb gpio_init[] = {
3827 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3828 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3829 {}
3830 };
3831
3832 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19
TI
3833 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3834 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
9f5c6faf 3835 spec->gpio_led = 0;
0f32fd19
TI
3836 spec->mute_led_polarity = 0;
3837 spec->gpio_mute_led_mask = 0x08;
3838 spec->gpio_mic_led_mask = 0x10;
9f5c6faf
TI
3839 snd_hda_add_verbs(codec, gpio_init);
3840 }
3841}
3842
eaa8e5ef
KY
3843static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
3844 const struct hda_fixup *fix, int action)
3845{
3846 struct alc_spec *spec = codec->spec;
3847 static const struct hda_verb gpio_init[] = {
3848 { 0x01, AC_VERB_SET_GPIO_MASK, 0x22 },
3849 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x22 },
3850 {}
3851 };
3852
3853 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3854 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3855 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
9f5c6faf 3856 spec->gpio_led = 0;
eaa8e5ef
KY
3857 spec->mute_led_polarity = 0;
3858 spec->gpio_mute_led_mask = 0x02;
3859 spec->gpio_mic_led_mask = 0x20;
9f5c6faf
TI
3860 snd_hda_add_verbs(codec, gpio_init);
3861 }
3862}
3863
9c5dc3bf
KY
3864/* turn on/off mic-mute LED per capture hook */
3865static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3866 struct snd_kcontrol *kcontrol,
3867 struct snd_ctl_elem_value *ucontrol)
3868{
3869 struct alc_spec *spec = codec->spec;
3870 unsigned int pinval, enable, disable;
3871
fc1fad93 3872 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
9c5dc3bf
KY
3873 pinval &= ~AC_PINCTL_VREFEN;
3874 enable = pinval | AC_PINCTL_VREF_80;
3875 disable = pinval | AC_PINCTL_VREF_HIZ;
3876
3877 if (!ucontrol)
3878 return;
3879
3880 if (ucontrol->value.integer.value[0] ||
3881 ucontrol->value.integer.value[1])
3882 pinval = disable;
3883 else
3884 pinval = enable;
3885
3886 if (spec->cap_mute_led_nid)
3887 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3888}
3889
3890static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3891 const struct hda_fixup *fix, int action)
3892{
3893 struct alc_spec *spec = codec->spec;
3894 static const struct hda_verb gpio_init[] = {
3895 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3896 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3897 {}
3898 };
3899
3900 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 3901 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
9c5dc3bf
KY
3902 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3903 spec->gpio_led = 0;
0f32fd19
TI
3904 spec->mute_led_polarity = 0;
3905 spec->gpio_mute_led_mask = 0x08;
9c5dc3bf
KY
3906 spec->cap_mute_led_nid = 0x18;
3907 snd_hda_add_verbs(codec, gpio_init);
50dd9050 3908 codec->power_filter = led_power_filter;
9c5dc3bf
KY
3909 }
3910}
3911
7a5255f1
DH
3912static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3913 const struct hda_fixup *fix, int action)
3914{
3915 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to enable headphone amp */
3916 struct alc_spec *spec = codec->spec;
3917 static const struct hda_verb gpio_init[] = {
3918 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3919 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3920 {}
3921 };
3922
3923 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 3924 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
7a5255f1
DH
3925 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3926 spec->gpio_led = 0;
0f32fd19
TI
3927 spec->mute_led_polarity = 0;
3928 spec->gpio_mute_led_mask = 0x08;
7a5255f1
DH
3929 spec->cap_mute_led_nid = 0x18;
3930 snd_hda_add_verbs(codec, gpio_init);
3931 codec->power_filter = led_power_filter;
3932 }
3933}
3934
b12263b7 3935#if IS_REACHABLE(CONFIG_INPUT)
33f4acd3
DH
3936static void gpio2_mic_hotkey_event(struct hda_codec *codec,
3937 struct hda_jack_callback *event)
3938{
3939 struct alc_spec *spec = codec->spec;
3940
3941 /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
3942 send both key on and key off event for every interrupt. */
c7b60a89 3943 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
33f4acd3 3944 input_sync(spec->kb_dev);
c7b60a89 3945 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
33f4acd3
DH
3946 input_sync(spec->kb_dev);
3947}
33f4acd3 3948
3694cb29
K
3949static int alc_register_micmute_input_device(struct hda_codec *codec)
3950{
3951 struct alc_spec *spec = codec->spec;
c7b60a89 3952 int i;
3694cb29
K
3953
3954 spec->kb_dev = input_allocate_device();
3955 if (!spec->kb_dev) {
3956 codec_err(codec, "Out of memory (input_allocate_device)\n");
3957 return -ENOMEM;
3958 }
c7b60a89
HW
3959
3960 spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
3961
3694cb29
K
3962 spec->kb_dev->name = "Microphone Mute Button";
3963 spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
c7b60a89
HW
3964 spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
3965 spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
3966 spec->kb_dev->keycode = spec->alc_mute_keycode_map;
3967 for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
3968 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
3694cb29
K
3969
3970 if (input_register_device(spec->kb_dev)) {
3971 codec_err(codec, "input_register_device failed\n");
3972 input_free_device(spec->kb_dev);
3973 spec->kb_dev = NULL;
3974 return -ENOMEM;
3975 }
3976
3977 return 0;
3978}
3979
33f4acd3
DH
3980static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
3981 const struct hda_fixup *fix, int action)
3982{
33f4acd3
DH
3983 /* GPIO1 = set according to SKU external amp
3984 GPIO2 = mic mute hotkey
3985 GPIO3 = mute LED
3986 GPIO4 = mic mute LED */
3987 static const struct hda_verb gpio_init[] = {
3988 { 0x01, AC_VERB_SET_GPIO_MASK, 0x1e },
3989 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x1a },
3990 { 0x01, AC_VERB_SET_GPIO_DATA, 0x02 },
3991 {}
3992 };
3993
3994 struct alc_spec *spec = codec->spec;
3995
3996 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3694cb29 3997 if (alc_register_micmute_input_device(codec) != 0)
33f4acd3 3998 return;
33f4acd3
DH
3999
4000 snd_hda_add_verbs(codec, gpio_init);
7639a06c 4001 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
33f4acd3 4002 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
7639a06c 4003 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
33f4acd3
DH
4004 gpio2_mic_hotkey_event);
4005
4006 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
4007 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
4008 spec->gpio_led = 0;
4009 spec->mute_led_polarity = 0;
4010 spec->gpio_mute_led_mask = 0x08;
4011 spec->gpio_mic_led_mask = 0x10;
4012 return;
4013 }
4014
4015 if (!spec->kb_dev)
4016 return;
4017
4018 switch (action) {
4019 case HDA_FIXUP_ACT_PROBE:
4020 spec->init_amp = ALC_INIT_DEFAULT;
4021 break;
4022 case HDA_FIXUP_ACT_FREE:
4023 input_unregister_device(spec->kb_dev);
33f4acd3
DH
4024 spec->kb_dev = NULL;
4025 }
33f4acd3
DH
4026}
4027
3694cb29
K
4028static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4029 const struct hda_fixup *fix, int action)
4030{
4031 /* Line2 = mic mute hotkey
4032 GPIO2 = mic mute LED */
4033 static const struct hda_verb gpio_init[] = {
4034 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4035 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4036 {}
4037 };
4038
4039 struct alc_spec *spec = codec->spec;
4040
4041 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4042 if (alc_register_micmute_input_device(codec) != 0)
4043 return;
4044
4045 snd_hda_add_verbs(codec, gpio_init);
4046 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4047 gpio2_mic_hotkey_event);
4048
4049 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
4050 spec->gpio_led = 0;
4051 spec->mute_led_polarity = 0;
4052 spec->gpio_mic_led_mask = 0x04;
4053 return;
4054 }
4055
4056 if (!spec->kb_dev)
4057 return;
4058
4059 switch (action) {
4060 case HDA_FIXUP_ACT_PROBE:
4061 spec->init_amp = ALC_INIT_DEFAULT;
4062 break;
4063 case HDA_FIXUP_ACT_FREE:
4064 input_unregister_device(spec->kb_dev);
4065 spec->kb_dev = NULL;
4066 }
4067}
63c4da64
TI
4068#else /* INPUT */
4069#define alc280_fixup_hp_gpio2_mic_hotkey NULL
4070#define alc233_fixup_lenovo_line2_mic_hotkey NULL
4071#endif /* INPUT */
3694cb29 4072
9c5dc3bf
KY
4073static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4074 const struct hda_fixup *fix, int action)
4075{
4076 struct alc_spec *spec = codec->spec;
4077
4078 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4079 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
4080 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
4081 spec->mute_led_polarity = 0;
4082 spec->mute_led_nid = 0x1a;
4083 spec->cap_mute_led_nid = 0x18;
4084 spec->gen.vmaster_mute_enum = 1;
4085 codec->power_filter = led_power_filter;
4086 }
4087}
4088
5a36767a
KY
4089static struct coef_fw alc225_pre_hsmode[] = {
4090 UPDATE_COEF(0x4a, 1<<8, 0),
4091 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4092 UPDATE_COEF(0x63, 3<<14, 3<<14),
4093 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4094 UPDATE_COEF(0x4a, 3<<10, 3<<10),
4095 UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4096 UPDATE_COEF(0x4a, 3<<10, 0),
4097 {}
4098};
4099
73bdd597
DH
4100static void alc_headset_mode_unplugged(struct hda_codec *codec)
4101{
54db6c39 4102 static struct coef_fw coef0255[] = {
54db6c39
TI
4103 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4104 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4105 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4106 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4107 {}
4108 };
e69e7e03
KY
4109 static struct coef_fw coef0255_1[] = {
4110 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4111 {}
4112 };
4113 static struct coef_fw coef0256[] = {
4114 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4115 {}
4116 };
54db6c39
TI
4117 static struct coef_fw coef0233[] = {
4118 WRITE_COEF(0x1b, 0x0c0b),
4119 WRITE_COEF(0x45, 0xc429),
4120 UPDATE_COEF(0x35, 0x4000, 0),
4121 WRITE_COEF(0x06, 0x2104),
4122 WRITE_COEF(0x1a, 0x0001),
4123 WRITE_COEF(0x26, 0x0004),
4124 WRITE_COEF(0x32, 0x42a3),
4125 {}
4126 };
f3b70332
KY
4127 static struct coef_fw coef0288[] = {
4128 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4129 UPDATE_COEF(0x50, 0x2000, 0x2000),
4130 UPDATE_COEF(0x56, 0x0006, 0x0006),
4131 UPDATE_COEF(0x66, 0x0008, 0),
4132 UPDATE_COEF(0x67, 0x2000, 0),
4133 {}
4134 };
89542936
KY
4135 static struct coef_fw coef0298[] = {
4136 UPDATE_COEF(0x19, 0x1300, 0x0300),
4137 {}
4138 };
54db6c39
TI
4139 static struct coef_fw coef0292[] = {
4140 WRITE_COEF(0x76, 0x000e),
4141 WRITE_COEF(0x6c, 0x2400),
4142 WRITE_COEF(0x18, 0x7308),
4143 WRITE_COEF(0x6b, 0xc429),
4144 {}
4145 };
4146 static struct coef_fw coef0293[] = {
4147 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4148 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4149 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4150 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4151 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4152 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4153 {}
4154 };
4155 static struct coef_fw coef0668[] = {
4156 WRITE_COEF(0x15, 0x0d40),
4157 WRITE_COEF(0xb7, 0x802b),
4158 {}
4159 };
4cc9b9d6 4160 static struct coef_fw coef0225[] = {
5a36767a 4161 UPDATE_COEF(0x63, 3<<14, 0),
4cc9b9d6
KY
4162 {}
4163 };
71683c32
KY
4164 static struct coef_fw coef0274[] = {
4165 UPDATE_COEF(0x4a, 0x0100, 0),
4166 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4167 UPDATE_COEF(0x6b, 0xf000, 0x5000),
4168 UPDATE_COEF(0x4a, 0x0010, 0),
4169 UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4170 WRITE_COEF(0x45, 0x5289),
4171 UPDATE_COEF(0x4a, 0x0c00, 0),
4172 {}
4173 };
54db6c39 4174
7639a06c 4175 switch (codec->core.vendor_id) {
9a22a8f5 4176 case 0x10ec0255:
e69e7e03
KY
4177 alc_process_coef_fw(codec, coef0255_1);
4178 alc_process_coef_fw(codec, coef0255);
4179 break;
736f20a7 4180 case 0x10ec0236:
7081adf3 4181 case 0x10ec0256:
e69e7e03 4182 alc_process_coef_fw(codec, coef0256);
54db6c39 4183 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4184 break;
71683c32
KY
4185 case 0x10ec0234:
4186 case 0x10ec0274:
4187 case 0x10ec0294:
4188 alc_process_coef_fw(codec, coef0274);
4189 break;
13fd08a3 4190 case 0x10ec0233:
73bdd597 4191 case 0x10ec0283:
54db6c39 4192 alc_process_coef_fw(codec, coef0233);
73bdd597 4193 break;
f3b70332
KY
4194 case 0x10ec0286:
4195 case 0x10ec0288:
89542936
KY
4196 alc_process_coef_fw(codec, coef0288);
4197 break;
1a5bc8d9 4198 case 0x10ec0298:
89542936 4199 alc_process_coef_fw(codec, coef0298);
f3b70332
KY
4200 alc_process_coef_fw(codec, coef0288);
4201 break;
73bdd597 4202 case 0x10ec0292:
54db6c39 4203 alc_process_coef_fw(codec, coef0292);
73bdd597 4204 break;
a22aa26f 4205 case 0x10ec0293:
54db6c39 4206 alc_process_coef_fw(codec, coef0293);
a22aa26f 4207 break;
73bdd597 4208 case 0x10ec0668:
54db6c39 4209 alc_process_coef_fw(codec, coef0668);
73bdd597 4210 break;
638aad63 4211 case 0x10ec0215:
4cc9b9d6 4212 case 0x10ec0225:
638aad63 4213 case 0x10ec0285:
7d727869 4214 case 0x10ec0295:
638aad63 4215 case 0x10ec0289:
28f1f9b2 4216 case 0x10ec0299:
ba6d77fa 4217 alc_process_coef_fw(codec, alc225_pre_hsmode);
4cc9b9d6
KY
4218 alc_process_coef_fw(codec, coef0225);
4219 break;
78f4f7c2
KY
4220 case 0x10ec0867:
4221 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4222 break;
73bdd597 4223 }
4e76a883 4224 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
73bdd597
DH
4225}
4226
4227
4228static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4229 hda_nid_t mic_pin)
4230{
54db6c39
TI
4231 static struct coef_fw coef0255[] = {
4232 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4233 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4234 {}
4235 };
4236 static struct coef_fw coef0233[] = {
4237 UPDATE_COEF(0x35, 0, 1<<14),
4238 WRITE_COEF(0x06, 0x2100),
4239 WRITE_COEF(0x1a, 0x0021),
4240 WRITE_COEF(0x26, 0x008c),
4241 {}
4242 };
f3b70332 4243 static struct coef_fw coef0288[] = {
89542936 4244 UPDATE_COEF(0x4f, 0x00c0, 0),
f3b70332
KY
4245 UPDATE_COEF(0x50, 0x2000, 0),
4246 UPDATE_COEF(0x56, 0x0006, 0),
4247 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4248 UPDATE_COEF(0x66, 0x0008, 0x0008),
4249 UPDATE_COEF(0x67, 0x2000, 0x2000),
4250 {}
4251 };
54db6c39
TI
4252 static struct coef_fw coef0292[] = {
4253 WRITE_COEF(0x19, 0xa208),
4254 WRITE_COEF(0x2e, 0xacf0),
4255 {}
4256 };
4257 static struct coef_fw coef0293[] = {
4258 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4259 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4260 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4261 {}
4262 };
4263 static struct coef_fw coef0688[] = {
4264 WRITE_COEF(0xb7, 0x802b),
4265 WRITE_COEF(0xb5, 0x1040),
4266 UPDATE_COEF(0xc3, 0, 1<<12),
4267 {}
4268 };
4cc9b9d6
KY
4269 static struct coef_fw coef0225[] = {
4270 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4271 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4272 UPDATE_COEF(0x63, 3<<14, 0),
4273 {}
4274 };
71683c32
KY
4275 static struct coef_fw coef0274[] = {
4276 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4277 UPDATE_COEF(0x4a, 0x0010, 0),
4278 UPDATE_COEF(0x6b, 0xf000, 0),
4279 {}
4280 };
54db6c39 4281
7639a06c 4282 switch (codec->core.vendor_id) {
736f20a7 4283 case 0x10ec0236:
9a22a8f5 4284 case 0x10ec0255:
7081adf3 4285 case 0x10ec0256:
9a22a8f5
KY
4286 alc_write_coef_idx(codec, 0x45, 0xc489);
4287 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4288 alc_process_coef_fw(codec, coef0255);
9a22a8f5
KY
4289 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4290 break;
71683c32
KY
4291 case 0x10ec0234:
4292 case 0x10ec0274:
4293 case 0x10ec0294:
4294 alc_write_coef_idx(codec, 0x45, 0x4689);
4295 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4296 alc_process_coef_fw(codec, coef0274);
4297 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4298 break;
13fd08a3 4299 case 0x10ec0233:
73bdd597
DH
4300 case 0x10ec0283:
4301 alc_write_coef_idx(codec, 0x45, 0xc429);
4302 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4303 alc_process_coef_fw(codec, coef0233);
73bdd597
DH
4304 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4305 break;
f3b70332
KY
4306 case 0x10ec0286:
4307 case 0x10ec0288:
1a5bc8d9 4308 case 0x10ec0298:
f3b70332
KY
4309 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4310 alc_process_coef_fw(codec, coef0288);
4311 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4312 break;
73bdd597
DH
4313 case 0x10ec0292:
4314 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4315 alc_process_coef_fw(codec, coef0292);
73bdd597 4316 break;
a22aa26f
KY
4317 case 0x10ec0293:
4318 /* Set to TRS mode */
4319 alc_write_coef_idx(codec, 0x45, 0xc429);
4320 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4321 alc_process_coef_fw(codec, coef0293);
a22aa26f
KY
4322 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4323 break;
78f4f7c2
KY
4324 case 0x10ec0867:
4325 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4326 /* fallthru */
9eb5d0e6 4327 case 0x10ec0221:
1f8b46cd
DH
4328 case 0x10ec0662:
4329 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4330 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4331 break;
73bdd597
DH
4332 case 0x10ec0668:
4333 alc_write_coef_idx(codec, 0x11, 0x0001);
4334 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4335 alc_process_coef_fw(codec, coef0688);
73bdd597
DH
4336 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4337 break;
638aad63 4338 case 0x10ec0215:
4cc9b9d6 4339 case 0x10ec0225:
638aad63 4340 case 0x10ec0285:
7d727869 4341 case 0x10ec0295:
638aad63 4342 case 0x10ec0289:
28f1f9b2 4343 case 0x10ec0299:
5a36767a 4344 alc_process_coef_fw(codec, alc225_pre_hsmode);
4cc9b9d6
KY
4345 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4346 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4347 alc_process_coef_fw(codec, coef0225);
4348 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4349 break;
73bdd597 4350 }
4e76a883 4351 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
73bdd597
DH
4352}
4353
4354static void alc_headset_mode_default(struct hda_codec *codec)
4355{
2ae95577 4356 static struct coef_fw coef0225[] = {
5a36767a
KY
4357 UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4358 UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4359 UPDATE_COEF(0x49, 3<<8, 0<<8),
4360 UPDATE_COEF(0x4a, 3<<4, 3<<4),
4361 UPDATE_COEF(0x63, 3<<14, 0),
4362 UPDATE_COEF(0x67, 0xf000, 0x3000),
2ae95577
DH
4363 {}
4364 };
54db6c39
TI
4365 static struct coef_fw coef0255[] = {
4366 WRITE_COEF(0x45, 0xc089),
4367 WRITE_COEF(0x45, 0xc489),
4368 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4369 WRITE_COEF(0x49, 0x0049),
4370 {}
4371 };
4372 static struct coef_fw coef0233[] = {
4373 WRITE_COEF(0x06, 0x2100),
4374 WRITE_COEF(0x32, 0x4ea3),
4375 {}
4376 };
f3b70332
KY
4377 static struct coef_fw coef0288[] = {
4378 UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
4379 UPDATE_COEF(0x50, 0x2000, 0x2000),
4380 UPDATE_COEF(0x56, 0x0006, 0x0006),
4381 UPDATE_COEF(0x66, 0x0008, 0),
4382 UPDATE_COEF(0x67, 0x2000, 0),
4383 {}
4384 };
54db6c39
TI
4385 static struct coef_fw coef0292[] = {
4386 WRITE_COEF(0x76, 0x000e),
4387 WRITE_COEF(0x6c, 0x2400),
4388 WRITE_COEF(0x6b, 0xc429),
4389 WRITE_COEF(0x18, 0x7308),
4390 {}
4391 };
4392 static struct coef_fw coef0293[] = {
4393 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4394 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
4395 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4396 {}
4397 };
4398 static struct coef_fw coef0688[] = {
4399 WRITE_COEF(0x11, 0x0041),
4400 WRITE_COEF(0x15, 0x0d40),
4401 WRITE_COEF(0xb7, 0x802b),
4402 {}
4403 };
71683c32
KY
4404 static struct coef_fw coef0274[] = {
4405 WRITE_COEF(0x45, 0x4289),
4406 UPDATE_COEF(0x4a, 0x0010, 0x0010),
4407 UPDATE_COEF(0x6b, 0x0f00, 0),
4408 UPDATE_COEF(0x49, 0x0300, 0x0300),
4409 {}
4410 };
54db6c39 4411
7639a06c 4412 switch (codec->core.vendor_id) {
638aad63 4413 case 0x10ec0215:
2ae95577 4414 case 0x10ec0225:
638aad63 4415 case 0x10ec0285:
7d727869 4416 case 0x10ec0295:
638aad63 4417 case 0x10ec0289:
28f1f9b2 4418 case 0x10ec0299:
5a36767a 4419 alc_process_coef_fw(codec, alc225_pre_hsmode);
2ae95577
DH
4420 alc_process_coef_fw(codec, coef0225);
4421 break;
736f20a7 4422 case 0x10ec0236:
9a22a8f5 4423 case 0x10ec0255:
7081adf3 4424 case 0x10ec0256:
54db6c39 4425 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4426 break;
71683c32
KY
4427 case 0x10ec0234:
4428 case 0x10ec0274:
4429 case 0x10ec0294:
4430 alc_process_coef_fw(codec, coef0274);
4431 break;
13fd08a3 4432 case 0x10ec0233:
73bdd597 4433 case 0x10ec0283:
54db6c39 4434 alc_process_coef_fw(codec, coef0233);
73bdd597 4435 break;
f3b70332
KY
4436 case 0x10ec0286:
4437 case 0x10ec0288:
1a5bc8d9 4438 case 0x10ec0298:
f3b70332
KY
4439 alc_process_coef_fw(codec, coef0288);
4440 break;
73bdd597 4441 case 0x10ec0292:
54db6c39 4442 alc_process_coef_fw(codec, coef0292);
73bdd597 4443 break;
a22aa26f 4444 case 0x10ec0293:
54db6c39 4445 alc_process_coef_fw(codec, coef0293);
a22aa26f 4446 break;
73bdd597 4447 case 0x10ec0668:
54db6c39 4448 alc_process_coef_fw(codec, coef0688);
73bdd597 4449 break;
78f4f7c2
KY
4450 case 0x10ec0867:
4451 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4452 break;
73bdd597 4453 }
4e76a883 4454 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
73bdd597
DH
4455}
4456
4457/* Iphone type */
4458static void alc_headset_mode_ctia(struct hda_codec *codec)
4459{
89542936
KY
4460 int val;
4461
54db6c39
TI
4462 static struct coef_fw coef0255[] = {
4463 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4464 WRITE_COEF(0x1b, 0x0c2b),
4465 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4466 {}
4467 };
e69e7e03
KY
4468 static struct coef_fw coef0256[] = {
4469 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4470 WRITE_COEF(0x1b, 0x0c6b),
4471 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4472 {}
4473 };
54db6c39
TI
4474 static struct coef_fw coef0233[] = {
4475 WRITE_COEF(0x45, 0xd429),
4476 WRITE_COEF(0x1b, 0x0c2b),
4477 WRITE_COEF(0x32, 0x4ea3),
4478 {}
4479 };
f3b70332
KY
4480 static struct coef_fw coef0288[] = {
4481 UPDATE_COEF(0x50, 0x2000, 0x2000),
4482 UPDATE_COEF(0x56, 0x0006, 0x0006),
4483 UPDATE_COEF(0x66, 0x0008, 0),
4484 UPDATE_COEF(0x67, 0x2000, 0),
4485 {}
4486 };
54db6c39
TI
4487 static struct coef_fw coef0292[] = {
4488 WRITE_COEF(0x6b, 0xd429),
4489 WRITE_COEF(0x76, 0x0008),
4490 WRITE_COEF(0x18, 0x7388),
4491 {}
4492 };
4493 static struct coef_fw coef0293[] = {
4494 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
4495 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4496 {}
4497 };
4498 static struct coef_fw coef0688[] = {
4499 WRITE_COEF(0x11, 0x0001),
4500 WRITE_COEF(0x15, 0x0d60),
4501 WRITE_COEF(0xc3, 0x0000),
4502 {}
4503 };
5a36767a 4504 static struct coef_fw coef0225_1[] = {
4cc9b9d6 4505 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5a36767a
KY
4506 UPDATE_COEF(0x63, 3<<14, 2<<14),
4507 {}
4508 };
4509 static struct coef_fw coef0225_2[] = {
4510 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4511 UPDATE_COEF(0x63, 3<<14, 1<<14),
4cc9b9d6
KY
4512 {}
4513 };
54db6c39 4514
7639a06c 4515 switch (codec->core.vendor_id) {
9a22a8f5 4516 case 0x10ec0255:
54db6c39 4517 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4518 break;
736f20a7 4519 case 0x10ec0236:
e69e7e03
KY
4520 case 0x10ec0256:
4521 alc_process_coef_fw(codec, coef0256);
4522 break;
71683c32
KY
4523 case 0x10ec0234:
4524 case 0x10ec0274:
4525 case 0x10ec0294:
4526 alc_write_coef_idx(codec, 0x45, 0xd689);
4527 break;
13fd08a3 4528 case 0x10ec0233:
73bdd597 4529 case 0x10ec0283:
54db6c39 4530 alc_process_coef_fw(codec, coef0233);
73bdd597 4531 break;
1a5bc8d9 4532 case 0x10ec0298:
89542936
KY
4533 val = alc_read_coef_idx(codec, 0x50);
4534 if (val & (1 << 12)) {
4535 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4536 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4537 msleep(300);
4538 } else {
4539 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4540 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4541 msleep(300);
4542 }
4543 break;
f3b70332
KY
4544 case 0x10ec0286:
4545 case 0x10ec0288:
4546 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4547 msleep(300);
4548 alc_process_coef_fw(codec, coef0288);
4549 break;
73bdd597 4550 case 0x10ec0292:
54db6c39 4551 alc_process_coef_fw(codec, coef0292);
73bdd597 4552 break;
a22aa26f 4553 case 0x10ec0293:
54db6c39 4554 alc_process_coef_fw(codec, coef0293);
a22aa26f 4555 break;
73bdd597 4556 case 0x10ec0668:
54db6c39 4557 alc_process_coef_fw(codec, coef0688);
73bdd597 4558 break;
638aad63 4559 case 0x10ec0215:
4cc9b9d6 4560 case 0x10ec0225:
638aad63 4561 case 0x10ec0285:
7d727869 4562 case 0x10ec0295:
638aad63 4563 case 0x10ec0289:
28f1f9b2 4564 case 0x10ec0299:
5a36767a
KY
4565 val = alc_read_coef_idx(codec, 0x45);
4566 if (val & (1 << 9))
4567 alc_process_coef_fw(codec, coef0225_2);
4568 else
4569 alc_process_coef_fw(codec, coef0225_1);
4cc9b9d6 4570 break;
78f4f7c2
KY
4571 case 0x10ec0867:
4572 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4573 break;
73bdd597 4574 }
4e76a883 4575 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
73bdd597
DH
4576}
4577
4578/* Nokia type */
4579static void alc_headset_mode_omtp(struct hda_codec *codec)
4580{
54db6c39
TI
4581 static struct coef_fw coef0255[] = {
4582 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4583 WRITE_COEF(0x1b, 0x0c2b),
4584 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4585 {}
4586 };
e69e7e03
KY
4587 static struct coef_fw coef0256[] = {
4588 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4589 WRITE_COEF(0x1b, 0x0c6b),
4590 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4591 {}
4592 };
54db6c39
TI
4593 static struct coef_fw coef0233[] = {
4594 WRITE_COEF(0x45, 0xe429),
4595 WRITE_COEF(0x1b, 0x0c2b),
4596 WRITE_COEF(0x32, 0x4ea3),
4597 {}
4598 };
f3b70332
KY
4599 static struct coef_fw coef0288[] = {
4600 UPDATE_COEF(0x50, 0x2000, 0x2000),
4601 UPDATE_COEF(0x56, 0x0006, 0x0006),
4602 UPDATE_COEF(0x66, 0x0008, 0),
4603 UPDATE_COEF(0x67, 0x2000, 0),
4604 {}
4605 };
54db6c39
TI
4606 static struct coef_fw coef0292[] = {
4607 WRITE_COEF(0x6b, 0xe429),
4608 WRITE_COEF(0x76, 0x0008),
4609 WRITE_COEF(0x18, 0x7388),
4610 {}
4611 };
4612 static struct coef_fw coef0293[] = {
4613 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
4614 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4615 {}
4616 };
4617 static struct coef_fw coef0688[] = {
4618 WRITE_COEF(0x11, 0x0001),
4619 WRITE_COEF(0x15, 0x0d50),
4620 WRITE_COEF(0xc3, 0x0000),
4621 {}
4622 };
4cc9b9d6
KY
4623 static struct coef_fw coef0225[] = {
4624 UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5a36767a 4625 UPDATE_COEF(0x63, 3<<14, 2<<14),
4cc9b9d6
KY
4626 {}
4627 };
54db6c39 4628
7639a06c 4629 switch (codec->core.vendor_id) {
9a22a8f5 4630 case 0x10ec0255:
54db6c39 4631 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4632 break;
736f20a7 4633 case 0x10ec0236:
e69e7e03
KY
4634 case 0x10ec0256:
4635 alc_process_coef_fw(codec, coef0256);
4636 break;
71683c32
KY
4637 case 0x10ec0234:
4638 case 0x10ec0274:
4639 case 0x10ec0294:
4640 alc_write_coef_idx(codec, 0x45, 0xe689);
4641 break;
13fd08a3 4642 case 0x10ec0233:
73bdd597 4643 case 0x10ec0283:
54db6c39 4644 alc_process_coef_fw(codec, coef0233);
73bdd597 4645 break;
1a5bc8d9
KY
4646 case 0x10ec0298:
4647 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
89542936
KY
4648 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4649 msleep(300);
4650 break;
f3b70332
KY
4651 case 0x10ec0286:
4652 case 0x10ec0288:
4653 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4654 msleep(300);
4655 alc_process_coef_fw(codec, coef0288);
4656 break;
73bdd597 4657 case 0x10ec0292:
54db6c39 4658 alc_process_coef_fw(codec, coef0292);
73bdd597 4659 break;
a22aa26f 4660 case 0x10ec0293:
54db6c39 4661 alc_process_coef_fw(codec, coef0293);
a22aa26f 4662 break;
73bdd597 4663 case 0x10ec0668:
54db6c39 4664 alc_process_coef_fw(codec, coef0688);
73bdd597 4665 break;
638aad63 4666 case 0x10ec0215:
4cc9b9d6 4667 case 0x10ec0225:
638aad63 4668 case 0x10ec0285:
7d727869 4669 case 0x10ec0295:
638aad63 4670 case 0x10ec0289:
28f1f9b2 4671 case 0x10ec0299:
4cc9b9d6
KY
4672 alc_process_coef_fw(codec, coef0225);
4673 break;
73bdd597 4674 }
4e76a883 4675 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
73bdd597
DH
4676}
4677
4678static void alc_determine_headset_type(struct hda_codec *codec)
4679{
4680 int val;
4681 bool is_ctia = false;
4682 struct alc_spec *spec = codec->spec;
54db6c39
TI
4683 static struct coef_fw coef0255[] = {
4684 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
4685 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
4686 conteol) */
4687 {}
4688 };
f3b70332
KY
4689 static struct coef_fw coef0288[] = {
4690 UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
4691 {}
4692 };
89542936
KY
4693 static struct coef_fw coef0298[] = {
4694 UPDATE_COEF(0x50, 0x2000, 0x2000),
4695 UPDATE_COEF(0x56, 0x0006, 0x0006),
4696 UPDATE_COEF(0x66, 0x0008, 0),
4697 UPDATE_COEF(0x67, 0x2000, 0),
4698 UPDATE_COEF(0x19, 0x1300, 0x1300),
4699 {}
4700 };
54db6c39
TI
4701 static struct coef_fw coef0293[] = {
4702 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
4703 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
4704 {}
4705 };
4706 static struct coef_fw coef0688[] = {
4707 WRITE_COEF(0x11, 0x0001),
4708 WRITE_COEF(0xb7, 0x802b),
4709 WRITE_COEF(0x15, 0x0d60),
4710 WRITE_COEF(0xc3, 0x0c00),
4711 {}
4712 };
71683c32
KY
4713 static struct coef_fw coef0274[] = {
4714 UPDATE_COEF(0x4a, 0x0010, 0),
4715 UPDATE_COEF(0x4a, 0x8000, 0),
4716 WRITE_COEF(0x45, 0xd289),
4717 UPDATE_COEF(0x49, 0x0300, 0x0300),
4718 {}
4719 };
73bdd597 4720
7639a06c 4721 switch (codec->core.vendor_id) {
736f20a7 4722 case 0x10ec0236:
9a22a8f5 4723 case 0x10ec0255:
7081adf3 4724 case 0x10ec0256:
54db6c39 4725 alc_process_coef_fw(codec, coef0255);
9a22a8f5
KY
4726 msleep(300);
4727 val = alc_read_coef_idx(codec, 0x46);
4728 is_ctia = (val & 0x0070) == 0x0070;
4729 break;
71683c32
KY
4730 case 0x10ec0234:
4731 case 0x10ec0274:
4732 case 0x10ec0294:
4733 alc_process_coef_fw(codec, coef0274);
4734 msleep(80);
4735 val = alc_read_coef_idx(codec, 0x46);
4736 is_ctia = (val & 0x00f0) == 0x00f0;
4737 break;
13fd08a3 4738 case 0x10ec0233:
73bdd597
DH
4739 case 0x10ec0283:
4740 alc_write_coef_idx(codec, 0x45, 0xd029);
4741 msleep(300);
4742 val = alc_read_coef_idx(codec, 0x46);
4743 is_ctia = (val & 0x0070) == 0x0070;
4744 break;
1a5bc8d9 4745 case 0x10ec0298:
89542936
KY
4746 snd_hda_codec_write(codec, 0x21, 0,
4747 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4748 msleep(100);
4749 snd_hda_codec_write(codec, 0x21, 0,
4750 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4751 msleep(200);
4752
4753 val = alc_read_coef_idx(codec, 0x50);
4754 if (val & (1 << 12)) {
4755 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4756 alc_process_coef_fw(codec, coef0288);
4757 msleep(350);
4758 val = alc_read_coef_idx(codec, 0x50);
4759 is_ctia = (val & 0x0070) == 0x0070;
4760 } else {
4761 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4762 alc_process_coef_fw(codec, coef0288);
4763 msleep(350);
4764 val = alc_read_coef_idx(codec, 0x50);
4765 is_ctia = (val & 0x0070) == 0x0070;
4766 }
4767 alc_process_coef_fw(codec, coef0298);
4768 snd_hda_codec_write(codec, 0x21, 0,
4769 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4770 msleep(75);
4771 snd_hda_codec_write(codec, 0x21, 0,
4772 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4773 break;
f3b70332
KY
4774 case 0x10ec0286:
4775 case 0x10ec0288:
4776 alc_process_coef_fw(codec, coef0288);
4777 msleep(350);
4778 val = alc_read_coef_idx(codec, 0x50);
4779 is_ctia = (val & 0x0070) == 0x0070;
4780 break;
73bdd597
DH
4781 case 0x10ec0292:
4782 alc_write_coef_idx(codec, 0x6b, 0xd429);
4783 msleep(300);
4784 val = alc_read_coef_idx(codec, 0x6c);
4785 is_ctia = (val & 0x001c) == 0x001c;
4786 break;
a22aa26f 4787 case 0x10ec0293:
54db6c39 4788 alc_process_coef_fw(codec, coef0293);
a22aa26f
KY
4789 msleep(300);
4790 val = alc_read_coef_idx(codec, 0x46);
4791 is_ctia = (val & 0x0070) == 0x0070;
4792 break;
73bdd597 4793 case 0x10ec0668:
54db6c39 4794 alc_process_coef_fw(codec, coef0688);
73bdd597
DH
4795 msleep(300);
4796 val = alc_read_coef_idx(codec, 0xbe);
4797 is_ctia = (val & 0x1c02) == 0x1c02;
4798 break;
638aad63 4799 case 0x10ec0215:
4cc9b9d6 4800 case 0x10ec0225:
638aad63 4801 case 0x10ec0285:
7d727869 4802 case 0x10ec0295:
638aad63 4803 case 0x10ec0289:
28f1f9b2 4804 case 0x10ec0299:
0b4d8f55
KY
4805 snd_hda_codec_write(codec, 0x21, 0,
4806 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4807 msleep(80);
4808 snd_hda_codec_write(codec, 0x21, 0,
4809 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4810
5a36767a
KY
4811 alc_process_coef_fw(codec, alc225_pre_hsmode);
4812 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
4813 val = alc_read_coef_idx(codec, 0x45);
4814 if (val & (1 << 9)) {
4815 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4816 alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
4817 msleep(800);
4818 val = alc_read_coef_idx(codec, 0x46);
4819 is_ctia = (val & 0x00f0) == 0x00f0;
4820 } else {
4821 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4822 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
4823 msleep(800);
4824 val = alc_read_coef_idx(codec, 0x46);
4825 is_ctia = (val & 0x00f0) == 0x00f0;
4826 }
4827 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
4828 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
4829 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
0b4d8f55
KY
4830
4831 snd_hda_codec_write(codec, 0x21, 0,
4832 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4833 msleep(80);
4834 snd_hda_codec_write(codec, 0x21, 0,
4835 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4cc9b9d6 4836 break;
78f4f7c2
KY
4837 case 0x10ec0867:
4838 is_ctia = true;
4839 break;
73bdd597
DH
4840 }
4841
4e76a883 4842 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
73bdd597
DH
4843 is_ctia ? "yes" : "no");
4844 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
4845}
4846
4847static void alc_update_headset_mode(struct hda_codec *codec)
4848{
4849 struct alc_spec *spec = codec->spec;
4850
4851 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
80f10932 4852 hda_nid_t hp_pin = alc_get_hp_pin(spec);
73bdd597
DH
4853
4854 int new_headset_mode;
4855
4856 if (!snd_hda_jack_detect(codec, hp_pin))
4857 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
4858 else if (mux_pin == spec->headset_mic_pin)
4859 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
4860 else if (mux_pin == spec->headphone_mic_pin)
4861 new_headset_mode = ALC_HEADSET_MODE_MIC;
4862 else
4863 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
4864
5959a6bc
DH
4865 if (new_headset_mode == spec->current_headset_mode) {
4866 snd_hda_gen_update_outputs(codec);
73bdd597 4867 return;
5959a6bc 4868 }
73bdd597
DH
4869
4870 switch (new_headset_mode) {
4871 case ALC_HEADSET_MODE_UNPLUGGED:
4872 alc_headset_mode_unplugged(codec);
4873 spec->gen.hp_jack_present = false;
4874 break;
4875 case ALC_HEADSET_MODE_HEADSET:
4876 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
4877 alc_determine_headset_type(codec);
4878 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
4879 alc_headset_mode_ctia(codec);
4880 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
4881 alc_headset_mode_omtp(codec);
4882 spec->gen.hp_jack_present = true;
4883 break;
4884 case ALC_HEADSET_MODE_MIC:
4885 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
4886 spec->gen.hp_jack_present = false;
4887 break;
4888 case ALC_HEADSET_MODE_HEADPHONE:
4889 alc_headset_mode_default(codec);
4890 spec->gen.hp_jack_present = true;
4891 break;
4892 }
4893 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
4894 snd_hda_set_pin_ctl_cache(codec, hp_pin,
4895 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1f8b46cd 4896 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
73bdd597
DH
4897 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
4898 PIN_VREFHIZ);
4899 }
4900 spec->current_headset_mode = new_headset_mode;
4901
4902 snd_hda_gen_update_outputs(codec);
4903}
4904
4905static void alc_update_headset_mode_hook(struct hda_codec *codec,
7fe30711
TI
4906 struct snd_kcontrol *kcontrol,
4907 struct snd_ctl_elem_value *ucontrol)
73bdd597
DH
4908{
4909 alc_update_headset_mode(codec);
4910}
4911
1a4f69d5
TI
4912static void alc_update_headset_jack_cb(struct hda_codec *codec,
4913 struct hda_jack_callback *jack)
73bdd597
DH
4914{
4915 struct alc_spec *spec = codec->spec;
5db4d34b 4916 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
73bdd597
DH
4917 snd_hda_gen_hp_automute(codec, jack);
4918}
4919
4920static void alc_probe_headset_mode(struct hda_codec *codec)
4921{
4922 int i;
4923 struct alc_spec *spec = codec->spec;
4924 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4925
4926 /* Find mic pins */
4927 for (i = 0; i < cfg->num_inputs; i++) {
4928 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
4929 spec->headset_mic_pin = cfg->inputs[i].pin;
4930 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
4931 spec->headphone_mic_pin = cfg->inputs[i].pin;
4932 }
4933
4934 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
4935 spec->gen.automute_hook = alc_update_headset_mode;
4936 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
4937}
4938
4939static void alc_fixup_headset_mode(struct hda_codec *codec,
4940 const struct hda_fixup *fix, int action)
4941{
4942 struct alc_spec *spec = codec->spec;
4943
4944 switch (action) {
4945 case HDA_FIXUP_ACT_PRE_PROBE:
4946 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
4947 break;
4948 case HDA_FIXUP_ACT_PROBE:
4949 alc_probe_headset_mode(codec);
4950 break;
4951 case HDA_FIXUP_ACT_INIT:
4952 spec->current_headset_mode = 0;
4953 alc_update_headset_mode(codec);
4954 break;
4955 }
4956}
4957
4958static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
4959 const struct hda_fixup *fix, int action)
4960{
4961 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4962 struct alc_spec *spec = codec->spec;
4963 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4964 }
4965 else
4966 alc_fixup_headset_mode(codec, fix, action);
4967}
4968
31278997
KY
4969static void alc255_set_default_jack_type(struct hda_codec *codec)
4970{
4971 /* Set to iphone type */
e69e7e03 4972 static struct coef_fw alc255fw[] = {
54db6c39
TI
4973 WRITE_COEF(0x1b, 0x880b),
4974 WRITE_COEF(0x45, 0xd089),
4975 WRITE_COEF(0x1b, 0x080b),
4976 WRITE_COEF(0x46, 0x0004),
4977 WRITE_COEF(0x1b, 0x0c0b),
4978 {}
4979 };
e69e7e03
KY
4980 static struct coef_fw alc256fw[] = {
4981 WRITE_COEF(0x1b, 0x884b),
4982 WRITE_COEF(0x45, 0xd089),
4983 WRITE_COEF(0x1b, 0x084b),
4984 WRITE_COEF(0x46, 0x0004),
4985 WRITE_COEF(0x1b, 0x0c4b),
4986 {}
4987 };
4988 switch (codec->core.vendor_id) {
4989 case 0x10ec0255:
4990 alc_process_coef_fw(codec, alc255fw);
4991 break;
736f20a7 4992 case 0x10ec0236:
e69e7e03
KY
4993 case 0x10ec0256:
4994 alc_process_coef_fw(codec, alc256fw);
4995 break;
4996 }
31278997
KY
4997 msleep(30);
4998}
4999
9a22a8f5
KY
5000static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5001 const struct hda_fixup *fix, int action)
5002{
5003 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
31278997 5004 alc255_set_default_jack_type(codec);
9a22a8f5
KY
5005 }
5006 alc_fixup_headset_mode(codec, fix, action);
5007}
5008
31278997
KY
5009static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5010 const struct hda_fixup *fix, int action)
5011{
5012 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5013 struct alc_spec *spec = codec->spec;
5014 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5015 alc255_set_default_jack_type(codec);
5016 }
5017 else
5018 alc_fixup_headset_mode(codec, fix, action);
5019}
5020
e1e62b98
KY
5021static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5022 struct hda_jack_callback *jack)
5023{
5024 struct alc_spec *spec = codec->spec;
5025 int present;
5026
5027 alc_update_headset_jack_cb(codec, jack);
5028 /* Headset Mic enable or disable, only for Dell Dino */
5029 present = spec->gen.hp_jack_present ? 0x40 : 0;
5030 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5031 present);
5032}
5033
5034static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5035 const struct hda_fixup *fix, int action)
5036{
5037 alc_fixup_headset_mode(codec, fix, action);
5038 if (action == HDA_FIXUP_ACT_PROBE) {
5039 struct alc_spec *spec = codec->spec;
5040 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5041 }
5042}
5043
493a52a9
HW
5044static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5045 const struct hda_fixup *fix, int action)
5046{
5047 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5048 struct alc_spec *spec = codec->spec;
5049 spec->gen.auto_mute_via_amp = 1;
5050 }
5051}
5052
9b745ab8
TI
5053static void alc_fixup_no_shutup(struct hda_codec *codec,
5054 const struct hda_fixup *fix, int action)
5055{
972aa2c7 5056 if (action == HDA_FIXUP_ACT_PROBE) {
9b745ab8 5057 struct alc_spec *spec = codec->spec;
b001f661 5058 spec->no_shutup_pins = 1;
9b745ab8
TI
5059 }
5060}
5061
5e6db669
GM
5062static void alc_fixup_disable_aamix(struct hda_codec *codec,
5063 const struct hda_fixup *fix, int action)
5064{
5065 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5066 struct alc_spec *spec = codec->spec;
5067 /* Disable AA-loopback as it causes white noise */
5068 spec->gen.mixer_nid = 0;
5069 }
5070}
5071
7f57d803
TI
5072/* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
5073static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5074 const struct hda_fixup *fix, int action)
5075{
5076 static const struct hda_pintbl pincfgs[] = {
5077 { 0x16, 0x21211010 }, /* dock headphone */
5078 { 0x19, 0x21a11010 }, /* dock mic */
5079 { }
5080 };
5081 struct alc_spec *spec = codec->spec;
5082
5083 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
70a0976b 5084 spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
7f57d803
TI
5085 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5086 codec->power_save_node = 0; /* avoid click noises */
5087 snd_hda_apply_pincfgs(codec, pincfgs);
5088 }
5089}
5090
114745cd
KY
5091static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5092 const struct hda_fixup *fix, int action)
5093{
5094 static const struct hda_pintbl pincfgs[] = {
5095 { 0x17, 0x21211010 }, /* dock headphone */
5096 { 0x19, 0x21a11010 }, /* dock mic */
5097 { }
5098 };
595263d2
TI
5099 /* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5100 * the speaker output becomes too low by some reason on Thinkpads with
5101 * ALC298 codec
5102 */
5103 static hda_nid_t preferred_pairs[] = {
5104 0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5105 0
5106 };
114745cd
KY
5107 struct alc_spec *spec = codec->spec;
5108
5109 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
595263d2 5110 spec->gen.preferred_dacs = preferred_pairs;
114745cd 5111 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
35bc709a
TI
5112 snd_hda_apply_pincfgs(codec, pincfgs);
5113 } else if (action == HDA_FIXUP_ACT_INIT) {
114745cd
KY
5114 /* Enable DOCK device */
5115 snd_hda_codec_write(codec, 0x17, 0,
5116 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5117 /* Enable DOCK device */
5118 snd_hda_codec_write(codec, 0x19, 0,
5119 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
114745cd
KY
5120 }
5121}
5122
9476d369 5123static void alc_shutup_dell_xps13(struct hda_codec *codec)
033b0a7c
GM
5124{
5125 struct alc_spec *spec = codec->spec;
80f10932 5126 int hp_pin = alc_get_hp_pin(spec);
033b0a7c 5127
9476d369
GM
5128 /* Prevent pop noises when headphones are plugged in */
5129 snd_hda_codec_write(codec, hp_pin, 0,
5130 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5131 msleep(20);
033b0a7c
GM
5132}
5133
5134static void alc_fixup_dell_xps13(struct hda_codec *codec,
5135 const struct hda_fixup *fix, int action)
5136{
3e1b0c4a
TI
5137 struct alc_spec *spec = codec->spec;
5138 struct hda_input_mux *imux = &spec->gen.input_mux;
5139 int i;
f38663ab 5140
3e1b0c4a
TI
5141 switch (action) {
5142 case HDA_FIXUP_ACT_PRE_PROBE:
5143 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
5144 * it causes a click noise at start up
5145 */
5146 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5147 break;
5148 case HDA_FIXUP_ACT_PROBE:
9476d369 5149 spec->shutup = alc_shutup_dell_xps13;
f38663ab
GM
5150
5151 /* Make the internal mic the default input source. */
5152 for (i = 0; i < imux->num_items; i++) {
5153 if (spec->gen.imux_pins[i] == 0x12) {
5154 spec->gen.cur_mux[0] = i;
5155 break;
5156 }
5157 }
3e1b0c4a 5158 break;
033b0a7c
GM
5159 }
5160}
5161
1f8b46cd
DH
5162static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5163 const struct hda_fixup *fix, int action)
5164{
5165 struct alc_spec *spec = codec->spec;
5166
5167 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5168 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5169 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
b40eda64
DH
5170
5171 /* Disable boost for mic-in permanently. (This code is only called
5172 from quirks that guarantee that the headphone is at NID 0x1b.) */
5173 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5174 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
1f8b46cd
DH
5175 } else
5176 alc_fixup_headset_mode(codec, fix, action);
5177}
5178
73bdd597
DH
5179static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5180 const struct hda_fixup *fix, int action)
5181{
5182 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
73bdd597 5183 alc_write_coef_idx(codec, 0xc4, 0x8000);
98b24883 5184 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
73bdd597
DH
5185 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
5186 }
5187 alc_fixup_headset_mode(codec, fix, action);
5188}
5189
bde7bc60
CCC
5190/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
5191static int find_ext_mic_pin(struct hda_codec *codec)
5192{
5193 struct alc_spec *spec = codec->spec;
5194 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5195 hda_nid_t nid;
5196 unsigned int defcfg;
5197 int i;
5198
5199 for (i = 0; i < cfg->num_inputs; i++) {
5200 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5201 continue;
5202 nid = cfg->inputs[i].pin;
5203 defcfg = snd_hda_codec_get_pincfg(codec, nid);
5204 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
5205 continue;
5206 return nid;
5207 }
5208
5209 return 0;
5210}
5211
08a978db 5212static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
1727a771 5213 const struct hda_fixup *fix,
08a978db
DR
5214 int action)
5215{
5216 struct alc_spec *spec = codec->spec;
5217
0db75790 5218 if (action == HDA_FIXUP_ACT_PROBE) {
bde7bc60 5219 int mic_pin = find_ext_mic_pin(codec);
80f10932 5220 int hp_pin = alc_get_hp_pin(spec);
bde7bc60
CCC
5221
5222 if (snd_BUG_ON(!mic_pin || !hp_pin))
0db75790 5223 return;
bde7bc60 5224 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
0db75790 5225 }
08a978db 5226}
693b613d 5227
3e0d611b
DH
5228static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
5229 const struct hda_fixup *fix,
5230 int action)
5231{
5232 struct alc_spec *spec = codec->spec;
5233 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5234 int i;
5235
5236 /* The mic boosts on level 2 and 3 are too noisy
5237 on the internal mic input.
5238 Therefore limit the boost to 0 or 1. */
5239
5240 if (action != HDA_FIXUP_ACT_PROBE)
5241 return;
5242
5243 for (i = 0; i < cfg->num_inputs; i++) {
5244 hda_nid_t nid = cfg->inputs[i].pin;
5245 unsigned int defcfg;
5246 if (cfg->inputs[i].type != AUTO_PIN_MIC)
5247 continue;
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
5252 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
5253 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
5254 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5255 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
5256 (0 << AC_AMPCAP_MUTE_SHIFT));
5257 }
5258}
5259
cd217a63 5260static void alc283_hp_automute_hook(struct hda_codec *codec,
1a4f69d5 5261 struct hda_jack_callback *jack)
cd217a63
KY
5262{
5263 struct alc_spec *spec = codec->spec;
5264 int vref;
5265
5266 msleep(200);
5267 snd_hda_gen_hp_automute(codec, jack);
5268
5269 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
5270
5271 msleep(600);
5272 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5273 vref);
5274}
5275
cd217a63
KY
5276static void alc283_fixup_chromebook(struct hda_codec *codec,
5277 const struct hda_fixup *fix, int action)
5278{
5279 struct alc_spec *spec = codec->spec;
cd217a63
KY
5280
5281 switch (action) {
5282 case HDA_FIXUP_ACT_PRE_PROBE:
0202e99c 5283 snd_hda_override_wcaps(codec, 0x03, 0);
d2e92709
TI
5284 /* Disable AA-loopback as it causes white noise */
5285 spec->gen.mixer_nid = 0;
38070219 5286 break;
0202e99c 5287 case HDA_FIXUP_ACT_INIT:
de9481cb
KY
5288 /* MIC2-VREF control */
5289 /* Set to manual mode */
98b24883 5290 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
0202e99c 5291 /* Enable Line1 input control by verb */
98b24883 5292 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
0202e99c
KY
5293 break;
5294 }
5295}
5296
5297static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
5298 const struct hda_fixup *fix, int action)
5299{
5300 struct alc_spec *spec = codec->spec;
0202e99c
KY
5301
5302 switch (action) {
5303 case HDA_FIXUP_ACT_PRE_PROBE:
cd217a63 5304 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
38070219
KY
5305 break;
5306 case HDA_FIXUP_ACT_INIT:
cd217a63
KY
5307 /* MIC2-VREF control */
5308 /* Set to manual mode */
98b24883 5309 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
cd217a63
KY
5310 break;
5311 }
5312}
5313
7bba2157
TI
5314/* mute tablet speaker pin (0x14) via dock plugging in addition */
5315static void asus_tx300_automute(struct hda_codec *codec)
5316{
5317 struct alc_spec *spec = codec->spec;
5318 snd_hda_gen_update_outputs(codec);
5319 if (snd_hda_jack_detect(codec, 0x1b))
5320 spec->gen.mute_bits |= (1ULL << 0x14);
5321}
5322
5323static void alc282_fixup_asus_tx300(struct hda_codec *codec,
5324 const struct hda_fixup *fix, int action)
5325{
5326 struct alc_spec *spec = codec->spec;
5327 /* TX300 needs to set up GPIO2 for the speaker amp */
5328 static const struct hda_verb gpio2_verbs[] = {
5329 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
5330 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
5331 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
5332 {}
5333 };
5334 static const struct hda_pintbl dock_pins[] = {
5335 { 0x1b, 0x21114000 }, /* dock speaker pin */
5336 {}
5337 };
7bba2157
TI
5338
5339 switch (action) {
5340 case HDA_FIXUP_ACT_PRE_PROBE:
5341 snd_hda_add_verbs(codec, gpio2_verbs);
5342 snd_hda_apply_pincfgs(codec, dock_pins);
5343 spec->gen.auto_mute_via_amp = 1;
5344 spec->gen.automute_hook = asus_tx300_automute;
5345 snd_hda_jack_detect_enable_callback(codec, 0x1b,
7bba2157
TI
5346 snd_hda_gen_hp_automute);
5347 break;
5348 case HDA_FIXUP_ACT_BUILD:
5349 /* this is a bit tricky; give more sane names for the main
5350 * (tablet) speaker and the dock speaker, respectively
5351 */
56798e6b
TI
5352 rename_ctl(codec, "Speaker Playback Switch",
5353 "Dock Speaker Playback Switch");
5354 rename_ctl(codec, "Bass Speaker Playback Switch",
5355 "Speaker Playback Switch");
7bba2157
TI
5356 break;
5357 }
5358}
5359
338cae56
DH
5360static void alc290_fixup_mono_speakers(struct hda_codec *codec,
5361 const struct hda_fixup *fix, int action)
5362{
0f4881dc
DH
5363 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5364 /* DAC node 0x03 is giving mono output. We therefore want to
5365 make sure 0x14 (front speaker) and 0x15 (headphones) use the
5366 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
5367 hda_nid_t conn1[2] = { 0x0c };
5368 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
5369 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
5370 }
338cae56
DH
5371}
5372
dd9aa335
HW
5373static void alc298_fixup_speaker_volume(struct hda_codec *codec,
5374 const struct hda_fixup *fix, int action)
5375{
5376 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5377 /* The speaker is routed to the Node 0x06 by a mistake, as a result
5378 we can't adjust the speaker's volume since this node does not has
5379 Amp-out capability. we change the speaker's route to:
5380 Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
5381 Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
5382 speaker's volume now. */
5383
5384 hda_nid_t conn1[1] = { 0x0c };
5385 snd_hda_override_conn_list(codec, 0x17, 1, conn1);
5386 }
5387}
5388
214839a8
TI
5389/* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
5390static void alc295_fixup_disable_dac3(struct hda_codec *codec,
5391 const struct hda_fixup *fix, int action)
5392{
5393 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5394 hda_nid_t conn[2] = { 0x02, 0x03 };
5395 snd_hda_override_conn_list(codec, 0x17, 2, conn);
5396 }
5397}
5398
98973f2f
KP
5399/* Hook to update amp GPIO4 for automute */
5400static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
5401 struct hda_jack_callback *jack)
5402{
5403 struct alc_spec *spec = codec->spec;
5404
5405 snd_hda_gen_hp_automute(codec, jack);
5406 /* mute_led_polarity is set to 0, so we pass inverted value here */
5407 alc_update_gpio_led(codec, 0x10, !spec->gen.hp_jack_present);
5408}
5409
5410/* Manage GPIOs for HP EliteBook Folio 9480m.
5411 *
5412 * GPIO4 is the headphone amplifier power control
5413 * GPIO3 is the audio output mute indicator LED
5414 */
5415
5416static void alc280_fixup_hp_9480m(struct hda_codec *codec,
5417 const struct hda_fixup *fix,
5418 int action)
5419{
5420 struct alc_spec *spec = codec->spec;
5421 static const struct hda_verb gpio_init[] = {
5422 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
5423 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
5424 {}
5425 };
5426
5427 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5428 /* Set the hooks to turn the headphone amp on/off
5429 * as needed
5430 */
5431 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
5432 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
5433
5434 /* The GPIOs are currently off */
5435 spec->gpio_led = 0;
5436
5437 /* GPIO3 is connected to the output mute LED,
5438 * high is on, low is off
5439 */
5440 spec->mute_led_polarity = 0;
5441 spec->gpio_mute_led_mask = 0x08;
5442
5443 /* Initialize GPIO configuration */
5444 snd_hda_add_verbs(codec, gpio_init);
5445 }
5446}
5447
ca169cc2
KY
5448static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
5449 const struct hda_fixup *fix,
5450 int action)
5451{
5452 alc_fixup_dual_codecs(codec, fix, action);
5453 switch (action) {
5454 case HDA_FIXUP_ACT_PRE_PROBE:
5455 /* override card longname to provide a unique UCM profile */
5456 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
5457 break;
5458 case HDA_FIXUP_ACT_BUILD:
5459 /* rename Capture controls depending on the codec */
5460 rename_ctl(codec, "Capture Volume",
5461 codec->addr == 0 ?
5462 "Rear-Panel Capture Volume" :
5463 "Front-Panel Capture Volume");
5464 rename_ctl(codec, "Capture Switch",
5465 codec->addr == 0 ?
5466 "Rear-Panel Capture Switch" :
5467 "Front-Panel Capture Switch");
5468 break;
5469 }
5470}
5471
92266651
KY
5472/* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
5473static void alc274_fixup_bind_dacs(struct hda_codec *codec,
5474 const struct hda_fixup *fix, int action)
5475{
5476 struct alc_spec *spec = codec->spec;
5477 static hda_nid_t preferred_pairs[] = {
5478 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
5479 0
5480 };
5481
5482 if (action != HDA_FIXUP_ACT_PRE_PROBE)
5483 return;
5484
5485 spec->gen.preferred_dacs = preferred_pairs;
fde563b0
KY
5486 spec->gen.auto_mute_via_amp = 1;
5487 codec->power_save_node = 0;
92266651
KY
5488}
5489
ea7118da
HW
5490/* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
5491static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
5492 const struct hda_fixup *fix, int action)
5493{
5494 if (action != HDA_FIXUP_ACT_PRE_PROBE)
5495 return;
5496
5497 snd_hda_override_wcaps(codec, 0x03, 0);
5498}
5499
f4ccb37c
KY
5500static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
5501 const struct hda_fixup *fix, int action)
5502{
5503 if (action == HDA_FIXUP_ACT_PRE_PROBE)
5504 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5505}
5506
b317b032
TI
5507/* for hda_fixup_thinkpad_acpi() */
5508#include "thinkpad_helper.c"
b67ae3f1 5509
2ae22638
TI
5510static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
5511 const struct hda_fixup *fix, int action)
5512{
5513 alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
5514 hda_fixup_thinkpad_acpi(codec, fix, action);
5515}
5516
00ef9940
HW
5517/* for dell wmi mic mute led */
5518#include "dell_wmi_helper.c"
5519
1d045db9
TI
5520enum {
5521 ALC269_FIXUP_SONY_VAIO,
5522 ALC275_FIXUP_SONY_VAIO_GPIO2,
5523 ALC269_FIXUP_DELL_M101Z,
5524 ALC269_FIXUP_SKU_IGNORE,
5525 ALC269_FIXUP_ASUS_G73JW,
5526 ALC269_FIXUP_LENOVO_EAPD,
5527 ALC275_FIXUP_SONY_HWEQ,
e9bd7d5c 5528 ALC275_FIXUP_SONY_DISABLE_AAMIX,
1d045db9 5529 ALC271_FIXUP_DMIC,
017f2a10 5530 ALC269_FIXUP_PCM_44K,
adabb3ec 5531 ALC269_FIXUP_STEREO_DMIC,
7c478f03 5532 ALC269_FIXUP_HEADSET_MIC,
24519911
TI
5533 ALC269_FIXUP_QUANTA_MUTE,
5534 ALC269_FIXUP_LIFEBOOK,
2041d564 5535 ALC269_FIXUP_LIFEBOOK_EXTMIC,
cc7016ab 5536 ALC269_FIXUP_LIFEBOOK_HP_PIN,
4df3fd17 5537 ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
0dcd451c 5538 ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
a4297b5d
TI
5539 ALC269_FIXUP_AMIC,
5540 ALC269_FIXUP_DMIC,
5541 ALC269VB_FIXUP_AMIC,
5542 ALC269VB_FIXUP_DMIC,
08fb0d0e 5543 ALC269_FIXUP_HP_MUTE_LED,
d06ac143 5544 ALC269_FIXUP_HP_MUTE_LED_MIC1,
08fb0d0e 5545 ALC269_FIXUP_HP_MUTE_LED_MIC2,
9f5c6faf 5546 ALC269_FIXUP_HP_GPIO_LED,
9c5dc3bf
KY
5547 ALC269_FIXUP_HP_GPIO_MIC1_LED,
5548 ALC269_FIXUP_HP_LINE1_MIC1_LED,
693b613d 5549 ALC269_FIXUP_INV_DMIC,
108cc108 5550 ALC269_FIXUP_LENOVO_DOCK,
9b745ab8 5551 ALC269_FIXUP_NO_SHUTUP,
88cfcf86 5552 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
108cc108 5553 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
73bdd597
DH
5554 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5555 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
338cae56 5556 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
fcc6c877 5557 ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
73bdd597
DH
5558 ALC269_FIXUP_HEADSET_MODE,
5559 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
7819717b 5560 ALC269_FIXUP_ASPIRE_HEADSET_MIC,
d240d1dc
DH
5561 ALC269_FIXUP_ASUS_X101_FUNC,
5562 ALC269_FIXUP_ASUS_X101_VERB,
5563 ALC269_FIXUP_ASUS_X101,
08a978db
DR
5564 ALC271_FIXUP_AMIC_MIC2,
5565 ALC271_FIXUP_HP_GATE_MIC_JACK,
b1e8972e 5566 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
42397004 5567 ALC269_FIXUP_ACER_AC700,
3e0d611b 5568 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
2cede303 5569 ALC269VB_FIXUP_ASUS_ZENBOOK,
23870831 5570 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
8e35cd4a 5571 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
02b504d9 5572 ALC269VB_FIXUP_ORDISSIMO_EVE2,
cd217a63 5573 ALC283_FIXUP_CHROME_BOOK,
0202e99c 5574 ALC283_FIXUP_SENSE_COMBO_JACK,
7bba2157 5575 ALC282_FIXUP_ASUS_TX300,
1bb3e062 5576 ALC283_FIXUP_INT_MIC,
338cae56 5577 ALC290_FIXUP_MONO_SPEAKERS,
0f4881dc
DH
5578 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5579 ALC290_FIXUP_SUBWOOFER,
5580 ALC290_FIXUP_SUBWOOFER_HSJACK,
b67ae3f1 5581 ALC269_FIXUP_THINKPAD_ACPI,
56f27013 5582 ALC269_FIXUP_DMIC_THINKPAD_ACPI,
5824ce8d 5583 ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
615966ad 5584 ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9a22a8f5 5585 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
31278997 5586 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9a22a8f5 5587 ALC255_FIXUP_HEADSET_MODE,
31278997 5588 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
a22aa26f 5589 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
1c37c223 5590 ALC292_FIXUP_TPT440_DOCK,
9a811230 5591 ALC292_FIXUP_TPT440,
abaa2274 5592 ALC283_FIXUP_HEADSET_MIC,
00ef9940 5593 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
1a22e775 5594 ALC282_FIXUP_ASPIRE_V5_PINS,
7a5255f1 5595 ALC280_FIXUP_HP_GPIO4,
eaa8e5ef 5596 ALC286_FIXUP_HP_GPIO_LED,
33f4acd3 5597 ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
b4b33f9d 5598 ALC280_FIXUP_HP_DOCK_PINS,
04d5466a 5599 ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
98973f2f 5600 ALC280_FIXUP_HP_9480M,
e1e62b98
KY
5601 ALC288_FIXUP_DELL_HEADSET_MODE,
5602 ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
5603 ALC288_FIXUP_DELL_XPS_13_GPIO6,
831bfdf9
HW
5604 ALC288_FIXUP_DELL_XPS_13,
5605 ALC288_FIXUP_DISABLE_AAMIX,
8b99aba7
TI
5606 ALC292_FIXUP_DELL_E7X,
5607 ALC292_FIXUP_DISABLE_AAMIX,
c04017ea 5608 ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
977e6276 5609 ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
2f726aec 5610 ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6ed1131f 5611 ALC275_FIXUP_DELL_XPS,
8c69729b 5612 ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE,
23adc192 5613 ALC293_FIXUP_LENOVO_SPK_NOISE,
3694cb29 5614 ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
3b43b71f 5615 ALC255_FIXUP_DELL_SPK_NOISE,
f4ccb37c 5616 ALC225_FIXUP_DISABLE_MIC_VREF,
2ae95577 5617 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
214839a8 5618 ALC295_FIXUP_DISABLE_DAC3,
f883982d 5619 ALC280_FIXUP_HP_HEADSET_MIC,
e549d190 5620 ALC221_FIXUP_HP_FRONT_MIC,
c636b95e 5621 ALC292_FIXUP_TPT460,
dd9aa335 5622 ALC298_FIXUP_SPK_VOLUME,
fd06c77e 5623 ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
823ff161 5624 ALC269_FIXUP_ATIV_BOOK_8,
9eb5d0e6 5625 ALC221_FIXUP_HP_MIC_NO_PRESENCE,
c1732ede
CC
5626 ALC256_FIXUP_ASUS_HEADSET_MODE,
5627 ALC256_FIXUP_ASUS_MIC,
eeed4cd1 5628 ALC256_FIXUP_ASUS_AIO_GPIO2,
216d7aeb
CC
5629 ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
5630 ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
ca169cc2 5631 ALC233_FIXUP_LENOVO_MULTI_CODECS,
f33f79f3 5632 ALC294_FIXUP_LENOVO_MIC_LOCATION,
9423a273 5633 ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
b84e8436 5634 ALC700_FIXUP_INTEL_REFERENCE,
92266651
KY
5635 ALC274_FIXUP_DELL_BIND_DACS,
5636 ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
114745cd 5637 ALC298_FIXUP_TPT470_DOCK,
9cfdabca 5638 ALC255_FIXUP_DUMMY_LINEOUT_VERB,
4c574ad4 5639 ALC255_FIXUP_DELL_HEADSET_MIC,
32e2ee86 5640 ALC221_FIXUP_HP_HEADSET_MIC,
ea7118da 5641 ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
9c54c712 5642 ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
0a60c116 5643 ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
09416ef0 5644 ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
dad6c4f4 5645 ALC294_FIXUP_ASUS_MIC,
7398055e
JHP
5646 ALC294_FIXUP_ASUS_HEADSET_MIC,
5647 ALC294_FIXUP_ASUS_SPK,
20616fb0
KY
5648 ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
5649 ALC225_FIXUP_WYSE_AUTO_MUTE,
5650 ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
f1d4e28b
KY
5651};
5652
1727a771 5653static const struct hda_fixup alc269_fixups[] = {
1d045db9 5654 [ALC269_FIXUP_SONY_VAIO] = {
fd108215
TI
5655 .type = HDA_FIXUP_PINCTLS,
5656 .v.pins = (const struct hda_pintbl[]) {
5657 {0x19, PIN_VREFGRD},
1d045db9
TI
5658 {}
5659 }
f1d4e28b 5660 },
1d045db9 5661 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
1727a771 5662 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5663 .v.verbs = (const struct hda_verb[]) {
5664 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
5665 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
5666 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5667 { }
5668 },
5669 .chained = true,
5670 .chain_id = ALC269_FIXUP_SONY_VAIO
5671 },
5672 [ALC269_FIXUP_DELL_M101Z] = {
1727a771 5673 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5674 .v.verbs = (const struct hda_verb[]) {
5675 /* Enables internal speaker */
5676 {0x20, AC_VERB_SET_COEF_INDEX, 13},
5677 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5678 {}
5679 }
5680 },
5681 [ALC269_FIXUP_SKU_IGNORE] = {
1727a771 5682 .type = HDA_FIXUP_FUNC,
23d30f28 5683 .v.func = alc_fixup_sku_ignore,
1d045db9
TI
5684 },
5685 [ALC269_FIXUP_ASUS_G73JW] = {
1727a771
TI
5686 .type = HDA_FIXUP_PINS,
5687 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
5688 { 0x17, 0x99130111 }, /* subwoofer */
5689 { }
5690 }
5691 },
5692 [ALC269_FIXUP_LENOVO_EAPD] = {
1727a771 5693 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5694 .v.verbs = (const struct hda_verb[]) {
5695 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5696 {}
5697 }
5698 },
5699 [ALC275_FIXUP_SONY_HWEQ] = {
1727a771 5700 .type = HDA_FIXUP_FUNC,
1d045db9
TI
5701 .v.func = alc269_fixup_hweq,
5702 .chained = true,
5703 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5704 },
e9bd7d5c
TI
5705 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
5706 .type = HDA_FIXUP_FUNC,
5707 .v.func = alc_fixup_disable_aamix,
5708 .chained = true,
5709 .chain_id = ALC269_FIXUP_SONY_VAIO
5710 },
1d045db9 5711 [ALC271_FIXUP_DMIC] = {
1727a771 5712 .type = HDA_FIXUP_FUNC,
1d045db9 5713 .v.func = alc271_fixup_dmic,
f1d4e28b 5714 },
017f2a10 5715 [ALC269_FIXUP_PCM_44K] = {
1727a771 5716 .type = HDA_FIXUP_FUNC,
017f2a10 5717 .v.func = alc269_fixup_pcm_44k,
012e7eb1
DH
5718 .chained = true,
5719 .chain_id = ALC269_FIXUP_QUANTA_MUTE
017f2a10 5720 },
adabb3ec 5721 [ALC269_FIXUP_STEREO_DMIC] = {
1727a771 5722 .type = HDA_FIXUP_FUNC,
adabb3ec
TI
5723 .v.func = alc269_fixup_stereo_dmic,
5724 },
7c478f03
DH
5725 [ALC269_FIXUP_HEADSET_MIC] = {
5726 .type = HDA_FIXUP_FUNC,
5727 .v.func = alc269_fixup_headset_mic,
5728 },
24519911 5729 [ALC269_FIXUP_QUANTA_MUTE] = {
1727a771 5730 .type = HDA_FIXUP_FUNC,
24519911
TI
5731 .v.func = alc269_fixup_quanta_mute,
5732 },
5733 [ALC269_FIXUP_LIFEBOOK] = {
1727a771
TI
5734 .type = HDA_FIXUP_PINS,
5735 .v.pins = (const struct hda_pintbl[]) {
24519911
TI
5736 { 0x1a, 0x2101103f }, /* dock line-out */
5737 { 0x1b, 0x23a11040 }, /* dock mic-in */
5738 { }
5739 },
5740 .chained = true,
5741 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5742 },
2041d564
DH
5743 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
5744 .type = HDA_FIXUP_PINS,
5745 .v.pins = (const struct hda_pintbl[]) {
5746 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
5747 { }
5748 },
5749 },
cc7016ab
TI
5750 [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
5751 .type = HDA_FIXUP_PINS,
5752 .v.pins = (const struct hda_pintbl[]) {
5753 { 0x21, 0x0221102f }, /* HP out */
5754 { }
5755 },
5756 },
4df3fd17
TI
5757 [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
5758 .type = HDA_FIXUP_FUNC,
5759 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
5760 },
0dcd451c
JMG
5761 [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
5762 .type = HDA_FIXUP_FUNC,
5763 .v.func = alc269_fixup_pincfg_U7x7_headset_mic,
5764 },
a4297b5d 5765 [ALC269_FIXUP_AMIC] = {
1727a771
TI
5766 .type = HDA_FIXUP_PINS,
5767 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5768 { 0x14, 0x99130110 }, /* speaker */
5769 { 0x15, 0x0121401f }, /* HP out */
5770 { 0x18, 0x01a19c20 }, /* mic */
5771 { 0x19, 0x99a3092f }, /* int-mic */
5772 { }
5773 },
5774 },
5775 [ALC269_FIXUP_DMIC] = {
1727a771
TI
5776 .type = HDA_FIXUP_PINS,
5777 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5778 { 0x12, 0x99a3092f }, /* int-mic */
5779 { 0x14, 0x99130110 }, /* speaker */
5780 { 0x15, 0x0121401f }, /* HP out */
5781 { 0x18, 0x01a19c20 }, /* mic */
5782 { }
5783 },
5784 },
5785 [ALC269VB_FIXUP_AMIC] = {
1727a771
TI
5786 .type = HDA_FIXUP_PINS,
5787 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5788 { 0x14, 0x99130110 }, /* speaker */
5789 { 0x18, 0x01a19c20 }, /* mic */
5790 { 0x19, 0x99a3092f }, /* int-mic */
5791 { 0x21, 0x0121401f }, /* HP out */
5792 { }
5793 },
5794 },
2267ea97 5795 [ALC269VB_FIXUP_DMIC] = {
1727a771
TI
5796 .type = HDA_FIXUP_PINS,
5797 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5798 { 0x12, 0x99a3092f }, /* int-mic */
5799 { 0x14, 0x99130110 }, /* speaker */
5800 { 0x18, 0x01a19c20 }, /* mic */
5801 { 0x21, 0x0121401f }, /* HP out */
5802 { }
5803 },
5804 },
08fb0d0e 5805 [ALC269_FIXUP_HP_MUTE_LED] = {
1727a771 5806 .type = HDA_FIXUP_FUNC,
08fb0d0e 5807 .v.func = alc269_fixup_hp_mute_led,
6d3cd5d4 5808 },
d06ac143
DH
5809 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
5810 .type = HDA_FIXUP_FUNC,
5811 .v.func = alc269_fixup_hp_mute_led_mic1,
5812 },
08fb0d0e 5813 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
1727a771 5814 .type = HDA_FIXUP_FUNC,
08fb0d0e 5815 .v.func = alc269_fixup_hp_mute_led_mic2,
420b0feb 5816 },
9f5c6faf
TI
5817 [ALC269_FIXUP_HP_GPIO_LED] = {
5818 .type = HDA_FIXUP_FUNC,
5819 .v.func = alc269_fixup_hp_gpio_led,
5820 },
9c5dc3bf
KY
5821 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
5822 .type = HDA_FIXUP_FUNC,
5823 .v.func = alc269_fixup_hp_gpio_mic1_led,
5824 },
5825 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
5826 .type = HDA_FIXUP_FUNC,
5827 .v.func = alc269_fixup_hp_line1_mic1_led,
5828 },
693b613d 5829 [ALC269_FIXUP_INV_DMIC] = {
1727a771 5830 .type = HDA_FIXUP_FUNC,
9d36a7dc 5831 .v.func = alc_fixup_inv_dmic,
693b613d 5832 },
9b745ab8
TI
5833 [ALC269_FIXUP_NO_SHUTUP] = {
5834 .type = HDA_FIXUP_FUNC,
5835 .v.func = alc_fixup_no_shutup,
5836 },
108cc108 5837 [ALC269_FIXUP_LENOVO_DOCK] = {
1727a771
TI
5838 .type = HDA_FIXUP_PINS,
5839 .v.pins = (const struct hda_pintbl[]) {
108cc108
DH
5840 { 0x19, 0x23a11040 }, /* dock mic */
5841 { 0x1b, 0x2121103f }, /* dock headphone */
5842 { }
5843 },
5844 .chained = true,
5845 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
5846 },
5847 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
1727a771 5848 .type = HDA_FIXUP_FUNC,
108cc108 5849 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
52129000
DH
5850 .chained = true,
5851 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
108cc108 5852 },
73bdd597
DH
5853 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5854 .type = HDA_FIXUP_PINS,
5855 .v.pins = (const struct hda_pintbl[]) {
5856 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5857 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5858 { }
5859 },
5860 .chained = true,
5861 .chain_id = ALC269_FIXUP_HEADSET_MODE
5862 },
5863 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
5864 .type = HDA_FIXUP_PINS,
5865 .v.pins = (const struct hda_pintbl[]) {
5866 { 0x16, 0x21014020 }, /* dock line out */
5867 { 0x19, 0x21a19030 }, /* dock mic */
5868 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5869 { }
5870 },
5871 .chained = true,
5872 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
5873 },
338cae56
DH
5874 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
5875 .type = HDA_FIXUP_PINS,
5876 .v.pins = (const struct hda_pintbl[]) {
5877 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5878 { }
5879 },
5880 .chained = true,
5881 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
5882 },
fcc6c877
KY
5883 [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
5884 .type = HDA_FIXUP_PINS,
5885 .v.pins = (const struct hda_pintbl[]) {
5886 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5887 { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5888 { }
5889 },
5890 .chained = true,
5891 .chain_id = ALC269_FIXUP_HEADSET_MODE
5892 },
73bdd597
DH
5893 [ALC269_FIXUP_HEADSET_MODE] = {
5894 .type = HDA_FIXUP_FUNC,
5895 .v.func = alc_fixup_headset_mode,
6676f308
HW
5896 .chained = true,
5897 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
73bdd597
DH
5898 },
5899 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
5900 .type = HDA_FIXUP_FUNC,
5901 .v.func = alc_fixup_headset_mode_no_hp_mic,
5902 },
7819717b
TI
5903 [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
5904 .type = HDA_FIXUP_PINS,
5905 .v.pins = (const struct hda_pintbl[]) {
5906 { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
5907 { }
5908 },
5909 .chained = true,
5910 .chain_id = ALC269_FIXUP_HEADSET_MODE,
5911 },
88cfcf86
DH
5912 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
5913 .type = HDA_FIXUP_PINS,
5914 .v.pins = (const struct hda_pintbl[]) {
5915 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5916 { }
5917 },
fbc78ad6
DH
5918 .chained = true,
5919 .chain_id = ALC269_FIXUP_HEADSET_MIC
88cfcf86 5920 },
d240d1dc
DH
5921 [ALC269_FIXUP_ASUS_X101_FUNC] = {
5922 .type = HDA_FIXUP_FUNC,
5923 .v.func = alc269_fixup_x101_headset_mic,
5924 },
5925 [ALC269_FIXUP_ASUS_X101_VERB] = {
5926 .type = HDA_FIXUP_VERBS,
5927 .v.verbs = (const struct hda_verb[]) {
5928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5929 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
5930 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
5931 { }
5932 },
5933 .chained = true,
5934 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
5935 },
5936 [ALC269_FIXUP_ASUS_X101] = {
5937 .type = HDA_FIXUP_PINS,
5938 .v.pins = (const struct hda_pintbl[]) {
5939 { 0x18, 0x04a1182c }, /* Headset mic */
5940 { }
5941 },
5942 .chained = true,
5943 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
5944 },
08a978db 5945 [ALC271_FIXUP_AMIC_MIC2] = {
1727a771
TI
5946 .type = HDA_FIXUP_PINS,
5947 .v.pins = (const struct hda_pintbl[]) {
08a978db
DR
5948 { 0x14, 0x99130110 }, /* speaker */
5949 { 0x19, 0x01a19c20 }, /* mic */
5950 { 0x1b, 0x99a7012f }, /* int-mic */
5951 { 0x21, 0x0121401f }, /* HP out */
5952 { }
5953 },
5954 },
5955 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
1727a771 5956 .type = HDA_FIXUP_FUNC,
08a978db
DR
5957 .v.func = alc271_hp_gate_mic_jack,
5958 .chained = true,
5959 .chain_id = ALC271_FIXUP_AMIC_MIC2,
5960 },
b1e8972e
OR
5961 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
5962 .type = HDA_FIXUP_FUNC,
5963 .v.func = alc269_fixup_limit_int_mic_boost,
5964 .chained = true,
5965 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
5966 },
42397004
DR
5967 [ALC269_FIXUP_ACER_AC700] = {
5968 .type = HDA_FIXUP_PINS,
5969 .v.pins = (const struct hda_pintbl[]) {
5970 { 0x12, 0x99a3092f }, /* int-mic */
5971 { 0x14, 0x99130110 }, /* speaker */
5972 { 0x18, 0x03a11c20 }, /* mic */
5973 { 0x1e, 0x0346101e }, /* SPDIF1 */
5974 { 0x21, 0x0321101f }, /* HP out */
5975 { }
5976 },
5977 .chained = true,
5978 .chain_id = ALC271_FIXUP_DMIC,
5979 },
3e0d611b
DH
5980 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
5981 .type = HDA_FIXUP_FUNC,
5982 .v.func = alc269_fixup_limit_int_mic_boost,
2793769f
DH
5983 .chained = true,
5984 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
3e0d611b 5985 },
2cede303
OR
5986 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
5987 .type = HDA_FIXUP_FUNC,
5988 .v.func = alc269_fixup_limit_int_mic_boost,
5989 .chained = true,
5990 .chain_id = ALC269VB_FIXUP_DMIC,
5991 },
23870831
TI
5992 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
5993 .type = HDA_FIXUP_VERBS,
5994 .v.verbs = (const struct hda_verb[]) {
5995 /* class-D output amp +5dB */
5996 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
5997 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
5998 {}
5999 },
6000 .chained = true,
6001 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
6002 },
8e35cd4a
DH
6003 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
6004 .type = HDA_FIXUP_FUNC,
6005 .v.func = alc269_fixup_limit_int_mic_boost,
6006 .chained = true,
6007 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
6008 },
02b504d9
AA
6009 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
6010 .type = HDA_FIXUP_PINS,
6011 .v.pins = (const struct hda_pintbl[]) {
6012 { 0x12, 0x99a3092f }, /* int-mic */
6013 { 0x18, 0x03a11d20 }, /* mic */
6014 { 0x19, 0x411111f0 }, /* Unused bogus pin */
6015 { }
6016 },
6017 },
cd217a63
KY
6018 [ALC283_FIXUP_CHROME_BOOK] = {
6019 .type = HDA_FIXUP_FUNC,
6020 .v.func = alc283_fixup_chromebook,
6021 },
0202e99c
KY
6022 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
6023 .type = HDA_FIXUP_FUNC,
6024 .v.func = alc283_fixup_sense_combo_jack,
6025 .chained = true,
6026 .chain_id = ALC283_FIXUP_CHROME_BOOK,
6027 },
7bba2157
TI
6028 [ALC282_FIXUP_ASUS_TX300] = {
6029 .type = HDA_FIXUP_FUNC,
6030 .v.func = alc282_fixup_asus_tx300,
6031 },
1bb3e062
KY
6032 [ALC283_FIXUP_INT_MIC] = {
6033 .type = HDA_FIXUP_VERBS,
6034 .v.verbs = (const struct hda_verb[]) {
6035 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
6036 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
6037 { }
6038 },
6039 .chained = true,
6040 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6041 },
0f4881dc
DH
6042 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
6043 .type = HDA_FIXUP_PINS,
6044 .v.pins = (const struct hda_pintbl[]) {
6045 { 0x17, 0x90170112 }, /* subwoofer */
6046 { }
6047 },
6048 .chained = true,
6049 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6050 },
6051 [ALC290_FIXUP_SUBWOOFER] = {
6052 .type = HDA_FIXUP_PINS,
6053 .v.pins = (const struct hda_pintbl[]) {
6054 { 0x17, 0x90170112 }, /* subwoofer */
6055 { }
6056 },
6057 .chained = true,
6058 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
6059 },
338cae56
DH
6060 [ALC290_FIXUP_MONO_SPEAKERS] = {
6061 .type = HDA_FIXUP_FUNC,
6062 .v.func = alc290_fixup_mono_speakers,
0f4881dc
DH
6063 },
6064 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
6065 .type = HDA_FIXUP_FUNC,
6066 .v.func = alc290_fixup_mono_speakers,
338cae56
DH
6067 .chained = true,
6068 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6069 },
b67ae3f1
DH
6070 [ALC269_FIXUP_THINKPAD_ACPI] = {
6071 .type = HDA_FIXUP_FUNC,
2ae22638 6072 .v.func = alc_fixup_thinkpad_acpi,
09da111a
TI
6073 .chained = true,
6074 .chain_id = ALC269_FIXUP_SKU_IGNORE,
b67ae3f1 6075 },
56f27013
DH
6076 [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
6077 .type = HDA_FIXUP_FUNC,
6078 .v.func = alc_fixup_inv_dmic,
6079 .chained = true,
6080 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6081 },
5824ce8d
CC
6082 [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
6083 .type = HDA_FIXUP_PINS,
6084 .v.pins = (const struct hda_pintbl[]) {
6085 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6086 { }
6087 },
6088 .chained = true,
6089 .chain_id = ALC255_FIXUP_HEADSET_MODE
6090 },
615966ad
CC
6091 [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6092 .type = HDA_FIXUP_PINS,
6093 .v.pins = (const struct hda_pintbl[]) {
6094 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6095 { }
6096 },
6097 .chained = true,
6098 .chain_id = ALC255_FIXUP_HEADSET_MODE
6099 },
9a22a8f5
KY
6100 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6101 .type = HDA_FIXUP_PINS,
6102 .v.pins = (const struct hda_pintbl[]) {
6103 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6104 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6105 { }
6106 },
6107 .chained = true,
6108 .chain_id = ALC255_FIXUP_HEADSET_MODE
6109 },
31278997
KY
6110 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6111 .type = HDA_FIXUP_PINS,
6112 .v.pins = (const struct hda_pintbl[]) {
6113 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6114 { }
6115 },
6116 .chained = true,
6117 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
6118 },
9a22a8f5
KY
6119 [ALC255_FIXUP_HEADSET_MODE] = {
6120 .type = HDA_FIXUP_FUNC,
6121 .v.func = alc_fixup_headset_mode_alc255,
4a83d42a
HW
6122 .chained = true,
6123 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
9a22a8f5 6124 },
31278997
KY
6125 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6126 .type = HDA_FIXUP_FUNC,
6127 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
6128 },
a22aa26f
KY
6129 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6130 .type = HDA_FIXUP_PINS,
6131 .v.pins = (const struct hda_pintbl[]) {
6132 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6133 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6134 { }
6135 },
6136 .chained = true,
6137 .chain_id = ALC269_FIXUP_HEADSET_MODE
6138 },
1c37c223 6139 [ALC292_FIXUP_TPT440_DOCK] = {
ec56af67 6140 .type = HDA_FIXUP_FUNC,
7f57d803 6141 .v.func = alc_fixup_tpt440_dock,
1c37c223
TI
6142 .chained = true,
6143 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
6144 },
9a811230
TI
6145 [ALC292_FIXUP_TPT440] = {
6146 .type = HDA_FIXUP_FUNC,
157f0b7f 6147 .v.func = alc_fixup_disable_aamix,
9a811230
TI
6148 .chained = true,
6149 .chain_id = ALC292_FIXUP_TPT440_DOCK,
6150 },
abaa2274 6151 [ALC283_FIXUP_HEADSET_MIC] = {
9dc12862
DD
6152 .type = HDA_FIXUP_PINS,
6153 .v.pins = (const struct hda_pintbl[]) {
6154 { 0x19, 0x04a110f0 },
6155 { },
6156 },
6157 },
00ef9940
HW
6158 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
6159 .type = HDA_FIXUP_FUNC,
6160 .v.func = alc_fixup_dell_wmi,
00ef9940 6161 },
1a22e775
TI
6162 [ALC282_FIXUP_ASPIRE_V5_PINS] = {
6163 .type = HDA_FIXUP_PINS,
6164 .v.pins = (const struct hda_pintbl[]) {
6165 { 0x12, 0x90a60130 },
6166 { 0x14, 0x90170110 },
6167 { 0x17, 0x40000008 },
6168 { 0x18, 0x411111f0 },
0420694d 6169 { 0x19, 0x01a1913c },
1a22e775
TI
6170 { 0x1a, 0x411111f0 },
6171 { 0x1b, 0x411111f0 },
6172 { 0x1d, 0x40f89b2d },
6173 { 0x1e, 0x411111f0 },
6174 { 0x21, 0x0321101f },
6175 { },
6176 },
6177 },
7a5255f1
DH
6178 [ALC280_FIXUP_HP_GPIO4] = {
6179 .type = HDA_FIXUP_FUNC,
6180 .v.func = alc280_fixup_hp_gpio4,
6181 },
eaa8e5ef
KY
6182 [ALC286_FIXUP_HP_GPIO_LED] = {
6183 .type = HDA_FIXUP_FUNC,
6184 .v.func = alc286_fixup_hp_gpio_led,
6185 },
33f4acd3
DH
6186 [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
6187 .type = HDA_FIXUP_FUNC,
6188 .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
6189 },
b4b33f9d
TC
6190 [ALC280_FIXUP_HP_DOCK_PINS] = {
6191 .type = HDA_FIXUP_PINS,
6192 .v.pins = (const struct hda_pintbl[]) {
6193 { 0x1b, 0x21011020 }, /* line-out */
6194 { 0x1a, 0x01a1903c }, /* headset mic */
6195 { 0x18, 0x2181103f }, /* line-in */
6196 { },
6197 },
6198 .chained = true,
6199 .chain_id = ALC280_FIXUP_HP_GPIO4
6200 },
04d5466a
JK
6201 [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
6202 .type = HDA_FIXUP_PINS,
6203 .v.pins = (const struct hda_pintbl[]) {
6204 { 0x1b, 0x21011020 }, /* line-out */
6205 { 0x18, 0x2181103f }, /* line-in */
6206 { },
6207 },
6208 .chained = true,
6209 .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
6210 },
98973f2f
KP
6211 [ALC280_FIXUP_HP_9480M] = {
6212 .type = HDA_FIXUP_FUNC,
6213 .v.func = alc280_fixup_hp_9480m,
6214 },
e1e62b98
KY
6215 [ALC288_FIXUP_DELL_HEADSET_MODE] = {
6216 .type = HDA_FIXUP_FUNC,
6217 .v.func = alc_fixup_headset_mode_dell_alc288,
6218 .chained = true,
6219 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
6220 },
6221 [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6222 .type = HDA_FIXUP_PINS,
6223 .v.pins = (const struct hda_pintbl[]) {
6224 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6225 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6226 { }
6227 },
6228 .chained = true,
6229 .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
6230 },
6231 [ALC288_FIXUP_DELL_XPS_13_GPIO6] = {
6232 .type = HDA_FIXUP_VERBS,
6233 .v.verbs = (const struct hda_verb[]) {
6234 {0x01, AC_VERB_SET_GPIO_MASK, 0x40},
6235 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x40},
6236 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6237 { }
6238 },
6239 .chained = true,
6240 .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
6241 },
831bfdf9
HW
6242 [ALC288_FIXUP_DISABLE_AAMIX] = {
6243 .type = HDA_FIXUP_FUNC,
6244 .v.func = alc_fixup_disable_aamix,
6245 .chained = true,
6246 .chain_id = ALC288_FIXUP_DELL_XPS_13_GPIO6
6247 },
6248 [ALC288_FIXUP_DELL_XPS_13] = {
6249 .type = HDA_FIXUP_FUNC,
6250 .v.func = alc_fixup_dell_xps13,
6251 .chained = true,
6252 .chain_id = ALC288_FIXUP_DISABLE_AAMIX
6253 },
8b99aba7
TI
6254 [ALC292_FIXUP_DISABLE_AAMIX] = {
6255 .type = HDA_FIXUP_FUNC,
6256 .v.func = alc_fixup_disable_aamix,
831bfdf9
HW
6257 .chained = true,
6258 .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
8b99aba7 6259 },
c04017ea
DH
6260 [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
6261 .type = HDA_FIXUP_FUNC,
6262 .v.func = alc_fixup_disable_aamix,
6263 .chained = true,
6264 .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
6265 },
8b99aba7
TI
6266 [ALC292_FIXUP_DELL_E7X] = {
6267 .type = HDA_FIXUP_FUNC,
6268 .v.func = alc_fixup_dell_xps13,
6269 .chained = true,
6270 .chain_id = ALC292_FIXUP_DISABLE_AAMIX
6271 },
977e6276
KY
6272 [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6273 .type = HDA_FIXUP_PINS,
6274 .v.pins = (const struct hda_pintbl[]) {
6275 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6276 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6277 { }
6278 },
6279 .chained = true,
6280 .chain_id = ALC269_FIXUP_HEADSET_MODE
6281 },
2f726aec
HW
6282 [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
6283 .type = HDA_FIXUP_PINS,
6284 .v.pins = (const struct hda_pintbl[]) {
6285 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6286 { }
6287 },
6288 .chained = true,
6289 .chain_id = ALC269_FIXUP_HEADSET_MODE
6290 },
6ed1131f
KY
6291 [ALC275_FIXUP_DELL_XPS] = {
6292 .type = HDA_FIXUP_VERBS,
6293 .v.verbs = (const struct hda_verb[]) {
6294 /* Enables internal speaker */
6295 {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
6296 {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
6297 {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
6298 {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
6299 {}
6300 }
6301 },
8c69729b
HW
6302 [ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE] = {
6303 .type = HDA_FIXUP_VERBS,
6304 .v.verbs = (const struct hda_verb[]) {
6305 /* Disable pass-through path for FRONT 14h */
6306 {0x20, AC_VERB_SET_COEF_INDEX, 0x36},
6307 {0x20, AC_VERB_SET_PROC_COEF, 0x1737},
6308 {}
6309 },
6310 .chained = true,
6311 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6312 },
23adc192
HW
6313 [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
6314 .type = HDA_FIXUP_FUNC,
6315 .v.func = alc_fixup_disable_aamix,
6316 .chained = true,
6317 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
6318 },
3694cb29
K
6319 [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
6320 .type = HDA_FIXUP_FUNC,
6321 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
6322 },
3b43b71f
KHF
6323 [ALC255_FIXUP_DELL_SPK_NOISE] = {
6324 .type = HDA_FIXUP_FUNC,
6325 .v.func = alc_fixup_disable_aamix,
6326 .chained = true,
6327 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6328 },
f4ccb37c
KY
6329 [ALC225_FIXUP_DISABLE_MIC_VREF] = {
6330 .type = HDA_FIXUP_FUNC,
6331 .v.func = alc_fixup_disable_mic_vref,
6332 .chained = true,
6333 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6334 },
2ae95577
DH
6335 [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6336 .type = HDA_FIXUP_VERBS,
6337 .v.verbs = (const struct hda_verb[]) {
6338 /* Disable pass-through path for FRONT 14h */
6339 { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6340 { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6341 {}
6342 },
6343 .chained = true,
f4ccb37c 6344 .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
2ae95577 6345 },
f883982d
TI
6346 [ALC280_FIXUP_HP_HEADSET_MIC] = {
6347 .type = HDA_FIXUP_FUNC,
6348 .v.func = alc_fixup_disable_aamix,
6349 .chained = true,
6350 .chain_id = ALC269_FIXUP_HEADSET_MIC,
6351 },
e549d190
HW
6352 [ALC221_FIXUP_HP_FRONT_MIC] = {
6353 .type = HDA_FIXUP_PINS,
6354 .v.pins = (const struct hda_pintbl[]) {
6355 { 0x19, 0x02a19020 }, /* Front Mic */
6356 { }
6357 },
6358 },
c636b95e
SE
6359 [ALC292_FIXUP_TPT460] = {
6360 .type = HDA_FIXUP_FUNC,
6361 .v.func = alc_fixup_tpt440_dock,
6362 .chained = true,
6363 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
6364 },
dd9aa335
HW
6365 [ALC298_FIXUP_SPK_VOLUME] = {
6366 .type = HDA_FIXUP_FUNC,
6367 .v.func = alc298_fixup_speaker_volume,
59ec4b57 6368 .chained = true,
2f726aec 6369 .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
dd9aa335 6370 },
214839a8
TI
6371 [ALC295_FIXUP_DISABLE_DAC3] = {
6372 .type = HDA_FIXUP_FUNC,
6373 .v.func = alc295_fixup_disable_dac3,
6374 },
fd06c77e
KHF
6375 [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
6376 .type = HDA_FIXUP_PINS,
6377 .v.pins = (const struct hda_pintbl[]) {
6378 { 0x1b, 0x90170151 },
6379 { }
6380 },
6381 .chained = true,
6382 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6383 },
823ff161
GM
6384 [ALC269_FIXUP_ATIV_BOOK_8] = {
6385 .type = HDA_FIXUP_FUNC,
6386 .v.func = alc_fixup_auto_mute_via_amp,
6387 .chained = true,
6388 .chain_id = ALC269_FIXUP_NO_SHUTUP
6389 },
9eb5d0e6
KY
6390 [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
6391 .type = HDA_FIXUP_PINS,
6392 .v.pins = (const struct hda_pintbl[]) {
6393 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6394 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6395 { }
6396 },
6397 .chained = true,
6398 .chain_id = ALC269_FIXUP_HEADSET_MODE
6399 },
c1732ede
CC
6400 [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
6401 .type = HDA_FIXUP_FUNC,
6402 .v.func = alc_fixup_headset_mode,
6403 },
6404 [ALC256_FIXUP_ASUS_MIC] = {
6405 .type = HDA_FIXUP_PINS,
6406 .v.pins = (const struct hda_pintbl[]) {
6407 { 0x13, 0x90a60160 }, /* use as internal mic */
6408 { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6409 { }
6410 },
6411 .chained = true,
6412 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6413 },
eeed4cd1
CC
6414 [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
6415 .type = HDA_FIXUP_VERBS,
6416 .v.verbs = (const struct hda_verb[]) {
6417 /* Set up GPIO2 for the speaker amp */
6418 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
6419 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
6420 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
6421 {}
6422 },
6423 },
216d7aeb
CC
6424 [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6425 .type = HDA_FIXUP_PINS,
6426 .v.pins = (const struct hda_pintbl[]) {
6427 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6428 { }
6429 },
6430 .chained = true,
6431 .chain_id = ALC269_FIXUP_HEADSET_MIC
6432 },
6433 [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
6434 .type = HDA_FIXUP_VERBS,
6435 .v.verbs = (const struct hda_verb[]) {
6436 /* Enables internal speaker */
6437 {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
6438 {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
6439 {}
6440 },
6441 .chained = true,
6442 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6443 },
ca169cc2
KY
6444 [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
6445 .type = HDA_FIXUP_FUNC,
6446 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
6447 },
f33f79f3
HW
6448 [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
6449 .type = HDA_FIXUP_PINS,
6450 .v.pins = (const struct hda_pintbl[]) {
6451 /* Change the mic location from front to right, otherwise there are
6452 two front mics with the same name, pulseaudio can't handle them.
6453 This is just a temporary workaround, after applying this fixup,
6454 there will be one "Front Mic" and one "Mic" in this machine.
6455 */
6456 { 0x1a, 0x04a19040 },
6457 { }
6458 },
6459 },
9423a273
KY
6460 [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
6461 .type = HDA_FIXUP_PINS,
6462 .v.pins = (const struct hda_pintbl[]) {
6463 { 0x16, 0x0101102f }, /* Rear Headset HP */
6464 { 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
6465 { 0x1a, 0x01a19030 }, /* Rear Headset MIC */
6466 { 0x1b, 0x02011020 },
6467 { }
6468 },
6469 .chained = true,
6470 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6471 },
b84e8436
PH
6472 [ALC700_FIXUP_INTEL_REFERENCE] = {
6473 .type = HDA_FIXUP_VERBS,
6474 .v.verbs = (const struct hda_verb[]) {
6475 /* Enables internal speaker */
6476 {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
6477 {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
6478 {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
6479 {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
6480 {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
6481 {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
6482 {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
6483 {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
6484 {}
6485 }
6486 },
92266651
KY
6487 [ALC274_FIXUP_DELL_BIND_DACS] = {
6488 .type = HDA_FIXUP_FUNC,
6489 .v.func = alc274_fixup_bind_dacs,
6490 .chained = true,
6491 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6492 },
6493 [ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
6494 .type = HDA_FIXUP_PINS,
6495 .v.pins = (const struct hda_pintbl[]) {
6496 { 0x1b, 0x0401102f },
6497 { }
6498 },
6499 .chained = true,
6500 .chain_id = ALC274_FIXUP_DELL_BIND_DACS
6501 },
114745cd
KY
6502 [ALC298_FIXUP_TPT470_DOCK] = {
6503 .type = HDA_FIXUP_FUNC,
6504 .v.func = alc_fixup_tpt470_dock,
6505 .chained = true,
6506 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
6507 },
9cfdabca
KY
6508 [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
6509 .type = HDA_FIXUP_PINS,
6510 .v.pins = (const struct hda_pintbl[]) {
6511 { 0x14, 0x0201101f },
6512 { }
6513 },
6514 .chained = true,
6515 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6516 },
4c574ad4
KY
6517 [ALC255_FIXUP_DELL_HEADSET_MIC] = {
6518 .type = HDA_FIXUP_PINS,
6519 .v.pins = (const struct hda_pintbl[]) {
6520 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6521 { }
6522 },
431b427b
HW
6523 .chained = true,
6524 .chain_id = ALC269_FIXUP_HEADSET_MIC
4c574ad4 6525 },
32e2ee86
KY
6526 [ALC221_FIXUP_HP_HEADSET_MIC] = {
6527 .type = HDA_FIXUP_PINS,
6528 .v.pins = (const struct hda_pintbl[]) {
6529 { 0x19, 0x0181313f},
6530 { }
6531 },
6532 .chained = true,
6533 .chain_id = ALC269_FIXUP_HEADSET_MIC
6534 },
ea7118da
HW
6535 [ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
6536 .type = HDA_FIXUP_FUNC,
6537 .v.func = alc285_fixup_invalidate_dacs,
3b01ea18
HW
6538 .chained = true,
6539 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
ea7118da 6540 },
0a60c116
HW
6541 [ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
6542 .type = HDA_FIXUP_VERBS,
6543 .v.verbs = (const struct hda_verb[]) {
6544 /* Disable PCBEEP-IN passthrough */
6545 { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
6546 { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
6547 { }
6548 },
6549 .chained = true,
6550 .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
6551 },
09416ef0
JS
6552 [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
6553 .type = HDA_FIXUP_PINS,
6554 .v.pins = (const struct hda_pintbl[]) {
6555 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6556 { }
6557 },
6558 .chained = true,
6559 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6560 },
20616fb0
KY
6561 [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
6562 .type = HDA_FIXUP_PINS,
6563 .v.pins = (const struct hda_pintbl[]) {
6564 { 0x16, 0x01011020 }, /* Rear Line out */
6565 { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
6566 { }
6567 },
6568 .chained = true,
6569 .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
6570 },
6571 [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
6572 .type = HDA_FIXUP_FUNC,
6573 .v.func = alc_fixup_auto_mute_via_amp,
6574 .chained = true,
6575 .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
6576 },
6577 [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
6578 .type = HDA_FIXUP_FUNC,
6579 .v.func = alc_fixup_disable_mic_vref,
6580 .chained = true,
6581 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6582 },
9c54c712
CC
6583 [ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
6584 .type = HDA_FIXUP_PINS,
6585 .v.pins = (const struct hda_pintbl[]) {
6586 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6587 { }
6588 },
6589 .chained = true,
6590 .chain_id = ALC269_FIXUP_HEADSET_MIC
6591 },
dad6c4f4
CC
6592 [ALC294_FIXUP_ASUS_MIC] = {
6593 .type = HDA_FIXUP_PINS,
6594 .v.pins = (const struct hda_pintbl[]) {
6595 { 0x13, 0x90a60160 }, /* use as internal mic */
6596 { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6597 { }
6598 },
6599 .chained = true,
6600 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6601 },
7398055e
JHP
6602 [ALC294_FIXUP_ASUS_HEADSET_MIC] = {
6603 .type = HDA_FIXUP_PINS,
6604 .v.pins = (const struct hda_pintbl[]) {
8f5982cc 6605 { 0x19, 0x01a1103c }, /* use as headset mic */
7398055e
JHP
6606 { }
6607 },
6608 .chained = true,
6609 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6610 },
6611 [ALC294_FIXUP_ASUS_SPK] = {
6612 .type = HDA_FIXUP_VERBS,
6613 .v.verbs = (const struct hda_verb[]) {
6614 /* Set EAPD high */
6615 { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
6616 { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
6617 { }
6618 },
6619 .chained = true,
6620 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
6621 },
f1d4e28b
KY
6622};
6623
1d045db9 6624static const struct snd_pci_quirk alc269_fixup_tbl[] = {
a6b92b66 6625 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
693b613d
DH
6626 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
6627 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
aaedfb47 6628 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
7819717b
TI
6629 SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
6630 SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
aaedfb47
DH
6631 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
6632 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
02322ac9 6633 SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
b1e8972e 6634 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
1a22e775 6635 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
b085c988 6636 SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
b9c2fa52 6637 SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
01f5508c
CC
6638 SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
6639 SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
edf57569 6640 SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
aaedfb47 6641 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
6ed1131f 6642 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
86f799b8 6643 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
cf52103a 6644 SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8b99aba7
TI
6645 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
6646 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
0f4881dc 6647 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
73bdd597
DH
6648 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6649 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6650 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
0f4881dc
DH
6651 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
6652 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
98070576 6653 SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
4275554d 6654 SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
0f4881dc 6655 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
a22aa26f
KY
6656 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6657 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
831bfdf9 6658 SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
afecb146 6659 SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
3a05d12f 6660 SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8b72415d 6661 SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
b734304f
KY
6662 SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6663 SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
c04017ea
DH
6664 SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6665 SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6666 SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6667 SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6668 SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
423cd785 6669 SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
fd06c77e 6670 SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
3b43b71f 6671 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
b001f661 6672 SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
423cd785 6673 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
feda862c 6674 SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
dd9aa335 6675 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
214839a8 6676 SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
493de342 6677 SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
9423a273 6678 SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
e4c9fd10 6679 SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
a98cf497
KY
6680 SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
6681 SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
4c574ad4
KY
6682 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
6683 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
9cfdabca 6684 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
20616fb0 6685 SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
1fddba4b 6686 SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
1b48c755 6687 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
a22aa26f
KY
6688 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6689 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
08fb0d0e 6690 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9f5c6faf 6691 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8e35cd4a 6692 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
33f4acd3 6693 SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
c60666bd 6694 /* ALC282 */
7976eb49 6695 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6696 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6697 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
6698 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6699 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6700 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6701 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9c5dc3bf 6702 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
c60666bd 6703 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6704 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6705 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6706 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
eaa8e5ef 6707 SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
b4b33f9d 6708 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
3271cb22 6709 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
c60666bd 6710 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6711 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6712 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6713 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6714 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
98973f2f 6715 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
9c5dc3bf
KY
6716 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6717 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 6718 /* ALC290 */
9c5dc3bf 6719 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6720 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6721 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf
KY
6722 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6723 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6724 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6725 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6726 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6727 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
04d5466a 6728 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
c60666bd 6729 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6730 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6731 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6732 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
6733 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6734 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6735 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 6736 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6737 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6738 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6739 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6740 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6741 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6742 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6743 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
6744 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6745 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6746 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6747 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
f883982d 6748 SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
e549d190 6749 SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
9eb5d0e6
KY
6750 SND_PCI_QUIRK(0x103c, 0x82bf, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
6751 SND_PCI_QUIRK(0x103c, 0x82c0, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
c1732ede 6752 SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
7bba2157 6753 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
3e0d611b 6754 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
ff0e5460 6755 SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
c1732ede 6756 SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
4eab0ea1 6757 SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
3e0d611b 6758 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4eab0ea1
TI
6759 SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
6760 SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
6761 SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
c1732ede
CC
6762 SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
6763 SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
6764 SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
2cede303 6765 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
7398055e 6766 SND_PCI_QUIRK(0x1043, 0x14a1, "ASUS UX533FD", ALC294_FIXUP_ASUS_SPK),
23870831 6767 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
3e0d611b 6768 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
017f2a10 6769 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
28e8af8a 6770 SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
693b613d 6771 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
615966ad 6772 SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
4eab0ea1 6773 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
c1732ede 6774 SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
eeed4cd1 6775 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
adabb3ec
TI
6776 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
6777 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
6778 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
6779 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
d240d1dc 6780 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
f88abaa0 6781 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
88cfcf86 6782 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
1d045db9
TI
6783 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
6784 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
6785 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
e9bd7d5c 6786 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
24519911 6787 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
4df3fd17 6788 SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
cc7016ab 6789 SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
88776f36 6790 SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
0dcd451c 6791 SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
2041d564 6792 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
b84e8436 6793 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
f4900a15 6794 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
a33cc48d 6795 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
823ff161 6796 SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
abaa2274
AA
6797 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
6798 SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
dbfe90df 6799 SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
09416ef0 6800 SND_PCI_QUIRK(0x1558, 0x1325, "System76 Darter Pro (darp5)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8ece3055 6801 SND_PCI_QUIRK(0x1558, 0x8550, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
6f616691
JS
6802 SND_PCI_QUIRK(0x1558, 0x8551, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
6803 SND_PCI_QUIRK(0x1558, 0x8560, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
6804 SND_PCI_QUIRK(0x1558, 0x8561, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC),
ca169cc2 6805 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
1d045db9
TI
6806 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
6807 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
6808 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
6809 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
6810 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
707fba3f 6811 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
c8415a48 6812 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
84f98fdf 6813 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
4407be6b 6814 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
108cc108 6815 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
aaedfb47 6816 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
9a811230 6817 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
1c37c223 6818 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
a12137e7 6819 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
59a51a6b 6820 SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
6d16941a 6821 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
7c21539c 6822 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
a4a9e082 6823 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
b6903c0e 6824 SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
d05ea7da 6825 SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
c0278669 6826 SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
114745cd
KY
6827 SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6828 SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
dab38e43 6829 SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
c636b95e 6830 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
114745cd
KY
6831 SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
6832 SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6833 SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
3051e378 6834 SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
114745cd
KY
6835 SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6836 SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6837 SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8c85df50 6838 SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
3694cb29 6839 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6ef2f68f 6840 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
f33f79f3 6841 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
b4ceb446 6842 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
74ef8b43 6843 SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8da5bbfc 6844 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
56f27013 6845 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
fedb2245 6846 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
9b745ab8 6847 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
a4a9e082 6848 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
1bb3e062 6849 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
c497d9f9 6850 SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
cd5302c0 6851 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
f2aa1110 6852 SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
80b311d3 6853 SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
09ea9976 6854 SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
037e1197 6855 SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
23adc192 6856 SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
0f087ee3 6857 SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
9cd25743 6858 SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
0f087ee3 6859 SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
114745cd
KY
6860 SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6861 SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6862 SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
cd5302c0 6863 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
114745cd
KY
6864 SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6865 SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
012e7eb1 6866 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
1d045db9 6867 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
02b504d9 6868 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
a4297b5d 6869
a7f3eedc 6870#if 0
a4297b5d
TI
6871 /* Below is a quirk table taken from the old code.
6872 * Basically the device should work as is without the fixup table.
6873 * If BIOS doesn't give a proper info, enable the corresponding
6874 * fixup entry.
7d7eb9ea 6875 */
a4297b5d
TI
6876 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6877 ALC269_FIXUP_AMIC),
6878 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
a4297b5d
TI
6879 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
6880 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
6881 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
6882 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
6883 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
6884 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
6885 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
6886 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
6887 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
6888 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
6889 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
6890 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
6891 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
6892 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
6893 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
6894 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
6895 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
6896 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
6897 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
6898 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
6899 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
6900 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
6901 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
6902 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
6903 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
6904 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
6905 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
6906 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
6907 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
6908 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
6909 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
6910 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
6911 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
6912 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
6913 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
6914 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
6915 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
6916 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
6917#endif
6918 {}
6919};
6920
214eef76
DH
6921static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
6922 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
6923 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
6924 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
6925 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
6926 {}
6927};
6928
1727a771 6929static const struct hda_model_fixup alc269_fixup_models[] = {
a4297b5d
TI
6930 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
6931 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6e72aa5f
TI
6932 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
6933 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
6934 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
7c478f03 6935 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
b016951e
TI
6936 {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
6937 {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
108cc108 6938 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9f5c6faf 6939 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
04d5466a 6940 {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
e32aa85a
DH
6941 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
6942 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
be8ef16a 6943 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
0202e99c 6944 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
1c37c223 6945 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
9a811230 6946 {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
c636b95e 6947 {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
ba90d6a6 6948 {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
28d1d6d2 6949 {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
1d045db9 6950 {}
6dda9f4a 6951};
cfc5a845 6952#define ALC225_STANDARD_PINS \
cfc5a845 6953 {0x21, 0x04211020}
6dda9f4a 6954
e8191a8e
HW
6955#define ALC256_STANDARD_PINS \
6956 {0x12, 0x90a60140}, \
6957 {0x14, 0x90170110}, \
e8191a8e
HW
6958 {0x21, 0x02211020}
6959
fea185e2 6960#define ALC282_STANDARD_PINS \
11580297 6961 {0x14, 0x90170110}
e1e62b98 6962
fea185e2 6963#define ALC290_STANDARD_PINS \
11580297 6964 {0x12, 0x99a30130}
fea185e2
DH
6965
6966#define ALC292_STANDARD_PINS \
6967 {0x14, 0x90170110}, \
11580297 6968 {0x15, 0x0221401f}
977e6276 6969
3f640970
HW
6970#define ALC295_STANDARD_PINS \
6971 {0x12, 0xb7a60130}, \
6972 {0x14, 0x90170110}, \
3f640970
HW
6973 {0x21, 0x04211020}
6974
703867e2
WS
6975#define ALC298_STANDARD_PINS \
6976 {0x12, 0x90a60130}, \
6977 {0x21, 0x03211020}
6978
e1918938 6979static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
32e2ee86
KY
6980 SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
6981 {0x14, 0x01014020},
6982 {0x17, 0x90170110},
6983 {0x18, 0x02a11030},
6984 {0x19, 0x0181303F},
6985 {0x21, 0x0221102f}),
5824ce8d
CC
6986 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6987 {0x12, 0x90a601c0},
6988 {0x14, 0x90171120},
6989 {0x21, 0x02211030}),
615966ad
CC
6990 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6991 {0x14, 0x90170110},
6992 {0x1b, 0x90a70130},
6993 {0x21, 0x03211020}),
6994 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6995 {0x1a, 0x90a70130},
6996 {0x1b, 0x90170110},
6997 {0x21, 0x03211020}),
2ae95577 6998 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
cfc5a845 6999 ALC225_STANDARD_PINS,
8a132099 7000 {0x12, 0xb7a60130},
cfc5a845 7001 {0x14, 0x901701a0}),
2ae95577 7002 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
cfc5a845 7003 ALC225_STANDARD_PINS,
8a132099 7004 {0x12, 0xb7a60130},
cfc5a845 7005 {0x14, 0x901701b0}),
8a132099
HW
7006 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7007 ALC225_STANDARD_PINS,
7008 {0x12, 0xb7a60150},
7009 {0x14, 0x901701a0}),
7010 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7011 ALC225_STANDARD_PINS,
7012 {0x12, 0xb7a60150},
7013 {0x14, 0x901701b0}),
7014 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7015 ALC225_STANDARD_PINS,
7016 {0x12, 0xb7a60130},
7017 {0x1b, 0x90170110}),
0ce48e17
KHF
7018 SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7019 {0x1b, 0x01111010},
7020 {0x1e, 0x01451130},
7021 {0x21, 0x02211020}),
56d3b887
HW
7022 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
7023 {0x12, 0x90a60140},
7024 {0x14, 0x90170110},
7025 {0x19, 0x02a11030},
7026 {0x21, 0x02211020}),
74ef8b43
HW
7027 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7028 {0x14, 0x90170110},
7029 {0x19, 0x02a11030},
7030 {0x1a, 0x02a11040},
7031 {0x1b, 0x01014020},
7032 {0x21, 0x0221101f}),
66a0e1cc
HW
7033 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7034 {0x14, 0x90170110},
7035 {0x19, 0x02a11030},
7036 {0x1a, 0x02a11040},
7037 {0x1b, 0x01011020},
7038 {0x21, 0x0221101f}),
3374ea95
HW
7039 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
7040 {0x14, 0x90170110},
7041 {0x19, 0x02a11020},
7042 {0x1a, 0x02a11030},
7043 {0x21, 0x0221101f}),
f265788c
HW
7044 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7045 {0x12, 0x90a60140},
7046 {0x14, 0x90170110},
7047 {0x21, 0x02211020}),
19412c71
TI
7048 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
7049 {0x12, 0x90a60140},
7050 {0x14, 0x90170110},
7051 {0x19, 0x02a11030},
7052 {0x21, 0x02211020}),
f265788c
HW
7053 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7054 {0x12, 0x90a60140},
7055 {0x14, 0x90170150},
7056 {0x21, 0x02211020}),
be620cc7
HW
7057 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7058 {0x21, 0x02211020}),
c77900e6 7059 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
c77900e6 7060 {0x14, 0x90170110},
c77900e6 7061 {0x21, 0x02211020}),
86c72d1c
HW
7062 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7063 {0x14, 0x90170130},
7064 {0x21, 0x02211040}),
76c2132e
DH
7065 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7066 {0x12, 0x90a60140},
7067 {0x14, 0x90170110},
76c2132e
DH
7068 {0x21, 0x02211020}),
7069 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7070 {0x12, 0x90a60160},
7071 {0x14, 0x90170120},
76c2132e 7072 {0x21, 0x02211030}),
392c9da2
HW
7073 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7074 {0x14, 0x90170110},
7075 {0x1b, 0x02011020},
7076 {0x21, 0x0221101f}),
6aecd871
HW
7077 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7078 {0x14, 0x90170110},
7079 {0x1b, 0x01011020},
7080 {0x21, 0x0221101f}),
cba59972 7081 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
cba59972 7082 {0x14, 0x90170130},
cba59972 7083 {0x1b, 0x01014020},
cba59972 7084 {0x21, 0x0221103f}),
6aecd871
HW
7085 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7086 {0x14, 0x90170130},
7087 {0x1b, 0x01011020},
7088 {0x21, 0x0221103f}),
59ec4b57
HW
7089 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7090 {0x14, 0x90170130},
7091 {0x1b, 0x02011020},
7092 {0x21, 0x0221103f}),
e9c28e16 7093 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
e9c28e16 7094 {0x14, 0x90170150},
e9c28e16 7095 {0x1b, 0x02011020},
e9c28e16
WS
7096 {0x21, 0x0221105f}),
7097 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
e9c28e16 7098 {0x14, 0x90170110},
e9c28e16 7099 {0x1b, 0x01014020},
e9c28e16 7100 {0x21, 0x0221101f}),
76c2132e
DH
7101 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7102 {0x12, 0x90a60160},
7103 {0x14, 0x90170120},
7104 {0x17, 0x90170140},
76c2132e
DH
7105 {0x21, 0x0321102f}),
7106 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7107 {0x12, 0x90a60160},
7108 {0x14, 0x90170130},
76c2132e
DH
7109 {0x21, 0x02211040}),
7110 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7111 {0x12, 0x90a60160},
7112 {0x14, 0x90170140},
76c2132e
DH
7113 {0x21, 0x02211050}),
7114 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7115 {0x12, 0x90a60170},
7116 {0x14, 0x90170120},
76c2132e
DH
7117 {0x21, 0x02211030}),
7118 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7119 {0x12, 0x90a60170},
7120 {0x14, 0x90170130},
76c2132e 7121 {0x21, 0x02211040}),
0a1f90a9
HW
7122 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7123 {0x12, 0x90a60170},
7124 {0x14, 0x90171130},
7125 {0x21, 0x02211040}),
70658b99 7126 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
70658b99
HW
7127 {0x12, 0x90a60170},
7128 {0x14, 0x90170140},
70658b99 7129 {0x21, 0x02211050}),
9b5a4e39 7130 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9b5a4e39
DH
7131 {0x12, 0x90a60180},
7132 {0x14, 0x90170130},
9b5a4e39 7133 {0x21, 0x02211040}),
f90d83b3
AK
7134 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7135 {0x12, 0x90a60180},
7136 {0x14, 0x90170120},
7137 {0x21, 0x02211030}),
989dbe4a
HW
7138 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7139 {0x1b, 0x01011020},
7140 {0x21, 0x02211010}),
285d5ddc
HW
7141 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7142 {0x12, 0x90a60130},
7143 {0x14, 0x90170110},
7144 {0x1b, 0x01011020},
7145 {0x21, 0x0221101f}),
81a1231b 7146 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
81a1231b
KY
7147 {0x12, 0x90a60160},
7148 {0x14, 0x90170120},
81a1231b 7149 {0x21, 0x02211030}),
f83c3292
WS
7150 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7151 {0x12, 0x90a60170},
7152 {0x14, 0x90170120},
7153 {0x21, 0x02211030}),
311042d1
SB
7154 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7155 {0x12, 0x90a60180},
7156 {0x14, 0x90170120},
7157 {0x21, 0x02211030}),
3f640970
HW
7158 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7159 {0x12, 0xb7a60130},
7160 {0x14, 0x90170110},
7161 {0x21, 0x02211020}),
b4fd4012
HW
7162 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7163 {0x12, 0x90a60130},
7164 {0x14, 0x90170110},
7165 {0x14, 0x01011020},
7166 {0x21, 0x0221101f}),
7081adf3 7167 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
11580297 7168 ALC256_STANDARD_PINS),
be620cc7
HW
7169 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7170 {0x14, 0x90170110},
7171 {0x1b, 0x01011020},
7172 {0x21, 0x0221101f}),
c1732ede
CC
7173 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
7174 {0x14, 0x90170110},
7175 {0x1b, 0x90a70130},
7176 {0x21, 0x04211020}),
7177 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
7178 {0x14, 0x90170110},
7179 {0x1b, 0x90a70130},
7180 {0x21, 0x03211020}),
92266651 7181 SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
75ee94b2
HW
7182 {0x12, 0xb7a60130},
7183 {0x13, 0xb8a61140},
7184 {0x16, 0x90170110},
7185 {0x21, 0x04211020}),
cf51eb9d
DH
7186 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
7187 {0x12, 0x90a60130},
cf51eb9d
DH
7188 {0x14, 0x90170110},
7189 {0x15, 0x0421101f},
11580297 7190 {0x1a, 0x04a11020}),
0279661b
HW
7191 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
7192 {0x12, 0x90a60140},
0279661b
HW
7193 {0x14, 0x90170110},
7194 {0x15, 0x0421101f},
0279661b 7195 {0x18, 0x02811030},
0279661b 7196 {0x1a, 0x04a1103f},
11580297 7197 {0x1b, 0x02011020}),
42304474 7198 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7199 ALC282_STANDARD_PINS,
42304474 7200 {0x12, 0x99a30130},
42304474 7201 {0x19, 0x03a11020},
42304474 7202 {0x21, 0x0321101f}),
2c609999 7203 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7204 ALC282_STANDARD_PINS,
2c609999 7205 {0x12, 0x99a30130},
2c609999 7206 {0x19, 0x03a11020},
2c609999
HW
7207 {0x21, 0x03211040}),
7208 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7209 ALC282_STANDARD_PINS,
2c609999 7210 {0x12, 0x99a30130},
2c609999 7211 {0x19, 0x03a11030},
2c609999
HW
7212 {0x21, 0x03211020}),
7213 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7214 ALC282_STANDARD_PINS,
2c609999 7215 {0x12, 0x99a30130},
2c609999 7216 {0x19, 0x04a11020},
2c609999 7217 {0x21, 0x0421101f}),
200afc09 7218 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
aec856d0 7219 ALC282_STANDARD_PINS,
200afc09 7220 {0x12, 0x90a60140},
200afc09 7221 {0x19, 0x04a11030},
200afc09 7222 {0x21, 0x04211020}),
76c2132e 7223 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7224 ALC282_STANDARD_PINS,
76c2132e 7225 {0x12, 0x90a60130},
76c2132e
DH
7226 {0x21, 0x0321101f}),
7227 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7228 {0x12, 0x90a60160},
7229 {0x14, 0x90170120},
76c2132e 7230 {0x21, 0x02211030}),
bc262179 7231 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7232 ALC282_STANDARD_PINS,
bc262179 7233 {0x12, 0x90a60130},
bc262179 7234 {0x19, 0x03a11020},
bc262179 7235 {0x21, 0x0321101f}),
0a60c116 7236 SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
ea7118da
HW
7237 {0x12, 0x90a60130},
7238 {0x14, 0x90170110},
7239 {0x19, 0x04a11040},
7240 {0x21, 0x04211020}),
e1e62b98 7241 SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL_XPS_13_GPIO6,
e1e62b98 7242 {0x12, 0x90a60120},
e1e62b98 7243 {0x14, 0x90170110},
e1e62b98 7244 {0x21, 0x0321101f}),
1c303728 7245 SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
b4fd4012
HW
7246 {0x12, 0xb7a60130},
7247 {0x14, 0x90170110},
7248 {0x21, 0x04211020}),
e4442bcf 7249 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7250 ALC290_STANDARD_PINS,
e4442bcf 7251 {0x15, 0x04211040},
e4442bcf 7252 {0x18, 0x90170112},
11580297 7253 {0x1a, 0x04a11020}),
e4442bcf 7254 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7255 ALC290_STANDARD_PINS,
e4442bcf 7256 {0x15, 0x04211040},
e4442bcf 7257 {0x18, 0x90170110},
11580297 7258 {0x1a, 0x04a11020}),
e4442bcf 7259 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7260 ALC290_STANDARD_PINS,
e4442bcf 7261 {0x15, 0x0421101f},
11580297 7262 {0x1a, 0x04a11020}),
e4442bcf 7263 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7264 ALC290_STANDARD_PINS,
e4442bcf 7265 {0x15, 0x04211020},
11580297 7266 {0x1a, 0x04a11040}),
e4442bcf 7267 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7268 ALC290_STANDARD_PINS,
e4442bcf
HW
7269 {0x14, 0x90170110},
7270 {0x15, 0x04211020},
11580297 7271 {0x1a, 0x04a11040}),
e4442bcf 7272 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7273 ALC290_STANDARD_PINS,
e4442bcf
HW
7274 {0x14, 0x90170110},
7275 {0x15, 0x04211020},
11580297 7276 {0x1a, 0x04a11020}),
e4442bcf 7277 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 7278 ALC290_STANDARD_PINS,
e4442bcf
HW
7279 {0x14, 0x90170110},
7280 {0x15, 0x0421101f},
11580297 7281 {0x1a, 0x04a11020}),
e8818fa8 7282 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
aec856d0 7283 ALC292_STANDARD_PINS,
e8818fa8 7284 {0x12, 0x90a60140},
e8818fa8 7285 {0x16, 0x01014020},
11580297 7286 {0x19, 0x01a19030}),
e8818fa8 7287 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
aec856d0 7288 ALC292_STANDARD_PINS,
e8818fa8 7289 {0x12, 0x90a60140},
e8818fa8
HW
7290 {0x16, 0x01014020},
7291 {0x18, 0x02a19031},
11580297 7292 {0x19, 0x01a1903e}),
76c2132e 7293 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
aec856d0 7294 ALC292_STANDARD_PINS,
11580297 7295 {0x12, 0x90a60140}),
76c2132e 7296 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7297 ALC292_STANDARD_PINS,
76c2132e 7298 {0x13, 0x90a60140},
76c2132e 7299 {0x16, 0x21014020},
11580297 7300 {0x19, 0x21a19030}),
e03fdbde 7301 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 7302 ALC292_STANDARD_PINS,
11580297 7303 {0x13, 0x90a60140}),
dad6c4f4
CC
7304 SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
7305 {0x14, 0x90170110},
7306 {0x1b, 0x90a70130},
7307 {0x21, 0x04211020}),
3794a5cd
JHP
7308 SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
7309 {0x12, 0x90a60130},
7310 {0x17, 0x90170110},
7311 {0x21, 0x04211020}),
3f640970 7312 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
f771d5bb
HW
7313 ALC295_STANDARD_PINS,
7314 {0x17, 0x21014020},
7315 {0x18, 0x21a19030}),
7316 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7317 ALC295_STANDARD_PINS,
7318 {0x17, 0x21014040},
7319 {0x18, 0x21a19050}),
3f307834
HW
7320 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
7321 ALC295_STANDARD_PINS),
9f502ff5
TI
7322 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7323 ALC298_STANDARD_PINS,
7324 {0x17, 0x90170110}),
977e6276 7325 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
703867e2
WS
7326 ALC298_STANDARD_PINS,
7327 {0x17, 0x90170140}),
7328 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
7329 ALC298_STANDARD_PINS,
9f502ff5 7330 {0x17, 0x90170150}),
9f1bc2c4
KHF
7331 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
7332 {0x12, 0xb7a60140},
7333 {0x13, 0xb7a60150},
7334 {0x17, 0x90170110},
7335 {0x1a, 0x03011020},
7336 {0x21, 0x03211030}),
fcc6c877
KY
7337 SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
7338 ALC225_STANDARD_PINS,
7339 {0x12, 0xb7a60130},
fcc6c877 7340 {0x17, 0x90170110}),
9c54c712
CC
7341 SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
7342 {0x12, 0x90a60130},
7343 {0x17, 0x90170110},
7344 {0x21, 0x02211020}),
e1918938
HW
7345 {}
7346};
6dda9f4a 7347
546bb678 7348static void alc269_fill_coef(struct hda_codec *codec)
1d045db9 7349{
526af6eb 7350 struct alc_spec *spec = codec->spec;
1d045db9 7351 int val;
ebb83eeb 7352
526af6eb 7353 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
546bb678 7354 return;
526af6eb 7355
1bb7e43e 7356 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
1d045db9
TI
7357 alc_write_coef_idx(codec, 0xf, 0x960b);
7358 alc_write_coef_idx(codec, 0xe, 0x8817);
7359 }
ebb83eeb 7360
1bb7e43e 7361 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
1d045db9
TI
7362 alc_write_coef_idx(codec, 0xf, 0x960b);
7363 alc_write_coef_idx(codec, 0xe, 0x8814);
7364 }
ebb83eeb 7365
1bb7e43e 7366 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9 7367 /* Power up output pin */
98b24883 7368 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
1d045db9 7369 }
ebb83eeb 7370
1bb7e43e 7371 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9 7372 val = alc_read_coef_idx(codec, 0xd);
f3ee07d8 7373 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
1d045db9
TI
7374 /* Capless ramp up clock control */
7375 alc_write_coef_idx(codec, 0xd, val | (1<<10));
7376 }
7377 val = alc_read_coef_idx(codec, 0x17);
f3ee07d8 7378 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
1d045db9
TI
7379 /* Class D power on reset */
7380 alc_write_coef_idx(codec, 0x17, val | (1<<7));
7381 }
7382 }
ebb83eeb 7383
98b24883
TI
7384 /* HP */
7385 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
1d045db9 7386}
a7f2371f 7387
1d045db9
TI
7388/*
7389 */
1d045db9
TI
7390static int patch_alc269(struct hda_codec *codec)
7391{
7392 struct alc_spec *spec;
3de95173 7393 int err;
f1d4e28b 7394
3de95173 7395 err = alc_alloc_spec(codec, 0x0b);
e16fb6d1 7396 if (err < 0)
3de95173
TI
7397 return err;
7398
7399 spec = codec->spec;
08c189f2 7400 spec->gen.shared_mic_vref_pin = 0x18;
8b99aba7 7401 codec->power_save_node = 1;
e16fb6d1 7402
225068ab
TI
7403#ifdef CONFIG_PM
7404 codec->patch_ops.suspend = alc269_suspend;
7405 codec->patch_ops.resume = alc269_resume;
7406#endif
c2d6af53
KY
7407 spec->shutup = alc_default_shutup;
7408 spec->init_hook = alc_default_init;
225068ab 7409
1727a771 7410 snd_hda_pick_fixup(codec, alc269_fixup_models,
9f720bb9 7411 alc269_fixup_tbl, alc269_fixups);
e1918938 7412 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
214eef76
DH
7413 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
7414 alc269_fixups);
1727a771 7415 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9f720bb9
HRK
7416
7417 alc_auto_parse_customize_define(codec);
7418
7504b6cd
TI
7419 if (has_cdefine_beep(codec))
7420 spec->gen.beep_nid = 0x01;
7421
7639a06c 7422 switch (codec->core.vendor_id) {
065380f0 7423 case 0x10ec0269:
1d045db9 7424 spec->codec_variant = ALC269_TYPE_ALC269VA;
1bb7e43e
TI
7425 switch (alc_get_coef0(codec) & 0x00f0) {
7426 case 0x0010:
5100cd07
TI
7427 if (codec->bus->pci &&
7428 codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 7429 spec->cdefine.platform_type == 1)
20ca0c35 7430 err = alc_codec_rename(codec, "ALC271X");
1d045db9 7431 spec->codec_variant = ALC269_TYPE_ALC269VB;
1bb7e43e
TI
7432 break;
7433 case 0x0020:
5100cd07
TI
7434 if (codec->bus->pci &&
7435 codec->bus->pci->subsystem_vendor == 0x17aa &&
e16fb6d1 7436 codec->bus->pci->subsystem_device == 0x21f3)
20ca0c35 7437 err = alc_codec_rename(codec, "ALC3202");
1d045db9 7438 spec->codec_variant = ALC269_TYPE_ALC269VC;
1bb7e43e 7439 break;
adcc70b2
KY
7440 case 0x0030:
7441 spec->codec_variant = ALC269_TYPE_ALC269VD;
7442 break;
1bb7e43e 7443 default:
1d045db9 7444 alc_fix_pll_init(codec, 0x20, 0x04, 15);
1bb7e43e 7445 }
e16fb6d1
TI
7446 if (err < 0)
7447 goto error;
c2d6af53 7448 spec->shutup = alc269_shutup;
546bb678 7449 spec->init_hook = alc269_fill_coef;
1d045db9 7450 alc269_fill_coef(codec);
065380f0
KY
7451 break;
7452
7453 case 0x10ec0280:
7454 case 0x10ec0290:
7455 spec->codec_variant = ALC269_TYPE_ALC280;
7456 break;
7457 case 0x10ec0282:
065380f0 7458 spec->codec_variant = ALC269_TYPE_ALC282;
7b5c7a02
KY
7459 spec->shutup = alc282_shutup;
7460 spec->init_hook = alc282_init;
065380f0 7461 break;
2af02be7
KY
7462 case 0x10ec0233:
7463 case 0x10ec0283:
7464 spec->codec_variant = ALC269_TYPE_ALC283;
7465 spec->shutup = alc283_shutup;
7466 spec->init_hook = alc283_init;
7467 break;
065380f0
KY
7468 case 0x10ec0284:
7469 case 0x10ec0292:
7470 spec->codec_variant = ALC269_TYPE_ALC284;
7471 break;
161ebf29 7472 case 0x10ec0293:
4731d5de 7473 spec->codec_variant = ALC269_TYPE_ALC293;
161ebf29 7474 break;
7fc7d047 7475 case 0x10ec0286:
7c665932 7476 case 0x10ec0288:
7fc7d047
KY
7477 spec->codec_variant = ALC269_TYPE_ALC286;
7478 break;
506b62c3
KY
7479 case 0x10ec0298:
7480 spec->codec_variant = ALC269_TYPE_ALC298;
7481 break;
583142ca 7482 case 0x10ec0235:
1d04c9de
KY
7483 case 0x10ec0255:
7484 spec->codec_variant = ALC269_TYPE_ALC255;
016c6fdd
KY
7485 spec->shutup = alc256_shutup;
7486 spec->init_hook = alc256_init;
1d04c9de 7487 break;
736f20a7 7488 case 0x10ec0236:
4344aec8
KY
7489 case 0x10ec0256:
7490 spec->codec_variant = ALC269_TYPE_ALC256;
4a219ef8
KY
7491 spec->shutup = alc256_shutup;
7492 spec->init_hook = alc256_init;
7d1b6e29 7493 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
d32b6666 7494 alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
4344aec8 7495 break;
f429e7e4
KY
7496 case 0x10ec0257:
7497 spec->codec_variant = ALC269_TYPE_ALC257;
fc434f5a
KY
7498 spec->shutup = alc256_shutup;
7499 spec->init_hook = alc256_init;
f429e7e4
KY
7500 spec->gen.mixer_nid = 0;
7501 break;
0a6f0600
KY
7502 case 0x10ec0215:
7503 case 0x10ec0285:
7504 case 0x10ec0289:
7505 spec->codec_variant = ALC269_TYPE_ALC215;
7506 spec->gen.mixer_nid = 0;
7507 break;
4231430d 7508 case 0x10ec0225:
7d727869 7509 case 0x10ec0295:
fa16b69f 7510 spec->codec_variant = ALC269_TYPE_ALC225;
e674ac9a 7511 spec->gen.mixer_nid = 0; /* no loopback on ALC225 ALC295 */
fa16b69f 7512 break;
28f1f9b2 7513 case 0x10ec0299:
4231430d 7514 spec->codec_variant = ALC269_TYPE_ALC225;
0b4d8f55
KY
7515 spec->shutup = alc225_shutup;
7516 spec->init_hook = alc225_init;
7517 spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
4231430d 7518 break;
dcd4f0db
KY
7519 case 0x10ec0234:
7520 case 0x10ec0274:
7521 case 0x10ec0294:
7522 spec->codec_variant = ALC269_TYPE_ALC294;
532a7784 7523 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
71683c32 7524 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
6e25f0c7 7525 spec->init_hook = alc294_init;
dcd4f0db 7526 break;
9887cf53
KY
7527 case 0x10ec0300:
7528 spec->codec_variant = ALC269_TYPE_ALC300;
7529 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
7530 break;
6fbae35a
KY
7531 case 0x10ec0700:
7532 case 0x10ec0701:
7533 case 0x10ec0703:
7534 spec->codec_variant = ALC269_TYPE_ALC700;
7535 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
2d7fe618 7536 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
6e25f0c7 7537 spec->init_hook = alc294_init;
6fbae35a
KY
7538 break;
7539
1d045db9 7540 }
6dda9f4a 7541
ad60d502 7542 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
97a26570 7543 spec->has_alc5505_dsp = 1;
ad60d502
KY
7544 spec->init_hook = alc5505_dsp_init;
7545 }
7546
a4297b5d
TI
7547 /* automatic parse from the BIOS config */
7548 err = alc269_parse_auto_config(codec);
e16fb6d1
TI
7549 if (err < 0)
7550 goto error;
6dda9f4a 7551
7d1b6e29
DH
7552 if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid)
7553 set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
f1d4e28b 7554
1727a771 7555 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7556
1d045db9 7557 return 0;
e16fb6d1
TI
7558
7559 error:
7560 alc_free(codec);
7561 return err;
1d045db9 7562}
f1d4e28b 7563
1d045db9
TI
7564/*
7565 * ALC861
7566 */
622e84cd 7567
1d045db9 7568static int alc861_parse_auto_config(struct hda_codec *codec)
6dda9f4a 7569{
1d045db9 7570 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7571 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
7572 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
604401a9
TI
7573}
7574
1d045db9
TI
7575/* Pin config fixes */
7576enum {
e652f4c8
TI
7577 ALC861_FIXUP_FSC_AMILO_PI1505,
7578 ALC861_FIXUP_AMP_VREF_0F,
7579 ALC861_FIXUP_NO_JACK_DETECT,
7580 ALC861_FIXUP_ASUS_A6RP,
6ddf0fd1 7581 ALC660_FIXUP_ASUS_W7J,
1d045db9 7582};
7085ec12 7583
31150f23
TI
7584/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
7585static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
1727a771 7586 const struct hda_fixup *fix, int action)
31150f23
TI
7587{
7588 struct alc_spec *spec = codec->spec;
7589 unsigned int val;
7590
1727a771 7591 if (action != HDA_FIXUP_ACT_INIT)
31150f23 7592 return;
d3f02d60 7593 val = snd_hda_codec_get_pin_target(codec, 0x0f);
31150f23
TI
7594 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
7595 val |= AC_PINCTL_IN_EN;
7596 val |= AC_PINCTL_VREF_50;
cdd03ced 7597 snd_hda_set_pin_ctl(codec, 0x0f, val);
08c189f2 7598 spec->gen.keep_vref_in_automute = 1;
31150f23
TI
7599}
7600
e652f4c8
TI
7601/* suppress the jack-detection */
7602static void alc_fixup_no_jack_detect(struct hda_codec *codec,
1727a771 7603 const struct hda_fixup *fix, int action)
e652f4c8 7604{
1727a771 7605 if (action == HDA_FIXUP_ACT_PRE_PROBE)
e652f4c8 7606 codec->no_jack_detect = 1;
7d7eb9ea 7607}
e652f4c8 7608
1727a771 7609static const struct hda_fixup alc861_fixups[] = {
e652f4c8 7610 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
1727a771
TI
7611 .type = HDA_FIXUP_PINS,
7612 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
7613 { 0x0b, 0x0221101f }, /* HP */
7614 { 0x0f, 0x90170310 }, /* speaker */
7615 { }
7616 }
7617 },
e652f4c8 7618 [ALC861_FIXUP_AMP_VREF_0F] = {
1727a771 7619 .type = HDA_FIXUP_FUNC,
31150f23 7620 .v.func = alc861_fixup_asus_amp_vref_0f,
3b25eb69 7621 },
e652f4c8 7622 [ALC861_FIXUP_NO_JACK_DETECT] = {
1727a771 7623 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
7624 .v.func = alc_fixup_no_jack_detect,
7625 },
7626 [ALC861_FIXUP_ASUS_A6RP] = {
1727a771 7627 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
7628 .v.func = alc861_fixup_asus_amp_vref_0f,
7629 .chained = true,
7630 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
6ddf0fd1
TI
7631 },
7632 [ALC660_FIXUP_ASUS_W7J] = {
7633 .type = HDA_FIXUP_VERBS,
7634 .v.verbs = (const struct hda_verb[]) {
7635 /* ASUS W7J needs a magic pin setup on unused NID 0x10
7636 * for enabling outputs
7637 */
7638 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7639 { }
7640 },
e652f4c8 7641 }
1d045db9 7642};
7085ec12 7643
1d045db9 7644static const struct snd_pci_quirk alc861_fixup_tbl[] = {
6ddf0fd1 7645 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
e7ca237b 7646 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
e652f4c8
TI
7647 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
7648 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
7649 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
7650 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
7651 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
7652 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
1d045db9
TI
7653 {}
7654};
3af9ee6b 7655
1d045db9
TI
7656/*
7657 */
1d045db9 7658static int patch_alc861(struct hda_codec *codec)
7085ec12 7659{
1d045db9 7660 struct alc_spec *spec;
1d045db9 7661 int err;
7085ec12 7662
3de95173
TI
7663 err = alc_alloc_spec(codec, 0x15);
7664 if (err < 0)
7665 return err;
1d045db9 7666
3de95173 7667 spec = codec->spec;
7504b6cd 7668 spec->gen.beep_nid = 0x23;
1d045db9 7669
225068ab
TI
7670#ifdef CONFIG_PM
7671 spec->power_hook = alc_power_eapd;
7672#endif
7673
1727a771
TI
7674 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
7675 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3af9ee6b 7676
cb4e4824
TI
7677 /* automatic parse from the BIOS config */
7678 err = alc861_parse_auto_config(codec);
e16fb6d1
TI
7679 if (err < 0)
7680 goto error;
3af9ee6b 7681
7504b6cd 7682 if (!spec->gen.no_analog)
3e6179b8 7683 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7085ec12 7684
1727a771 7685 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7686
1d045db9 7687 return 0;
e16fb6d1
TI
7688
7689 error:
7690 alc_free(codec);
7691 return err;
7085ec12
TI
7692}
7693
1d045db9
TI
7694/*
7695 * ALC861-VD support
7696 *
7697 * Based on ALC882
7698 *
7699 * In addition, an independent DAC
7700 */
1d045db9 7701static int alc861vd_parse_auto_config(struct hda_codec *codec)
bc9f98a9 7702{
1d045db9 7703 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7704 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7705 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
ce764ab2
TI
7706}
7707
1d045db9 7708enum {
8fdcb6fe
TI
7709 ALC660VD_FIX_ASUS_GPIO1,
7710 ALC861VD_FIX_DALLAS,
1d045db9 7711};
ce764ab2 7712
8fdcb6fe
TI
7713/* exclude VREF80 */
7714static void alc861vd_fixup_dallas(struct hda_codec *codec,
1727a771 7715 const struct hda_fixup *fix, int action)
8fdcb6fe 7716{
1727a771 7717 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
b78562b1
TI
7718 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
7719 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8fdcb6fe
TI
7720 }
7721}
7722
1727a771 7723static const struct hda_fixup alc861vd_fixups[] = {
1d045db9 7724 [ALC660VD_FIX_ASUS_GPIO1] = {
1727a771 7725 .type = HDA_FIXUP_VERBS,
1d045db9 7726 .v.verbs = (const struct hda_verb[]) {
8fdcb6fe 7727 /* reset GPIO1 */
1d045db9
TI
7728 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7729 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
7730 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
7731 { }
7732 }
7733 },
8fdcb6fe 7734 [ALC861VD_FIX_DALLAS] = {
1727a771 7735 .type = HDA_FIXUP_FUNC,
8fdcb6fe
TI
7736 .v.func = alc861vd_fixup_dallas,
7737 },
1d045db9 7738};
ce764ab2 7739
1d045db9 7740static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8fdcb6fe 7741 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
1d045db9 7742 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8fdcb6fe 7743 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
1d045db9
TI
7744 {}
7745};
ce764ab2 7746
1d045db9
TI
7747/*
7748 */
1d045db9 7749static int patch_alc861vd(struct hda_codec *codec)
ce764ab2 7750{
1d045db9 7751 struct alc_spec *spec;
cb4e4824 7752 int err;
ce764ab2 7753
3de95173
TI
7754 err = alc_alloc_spec(codec, 0x0b);
7755 if (err < 0)
7756 return err;
1d045db9 7757
3de95173 7758 spec = codec->spec;
7504b6cd 7759 spec->gen.beep_nid = 0x23;
1d045db9 7760
225068ab
TI
7761 spec->shutup = alc_eapd_shutup;
7762
1727a771
TI
7763 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
7764 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1d045db9 7765
cb4e4824
TI
7766 /* automatic parse from the BIOS config */
7767 err = alc861vd_parse_auto_config(codec);
e16fb6d1
TI
7768 if (err < 0)
7769 goto error;
ce764ab2 7770
7504b6cd 7771 if (!spec->gen.no_analog)
3e6179b8 7772 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1d045db9 7773
1727a771 7774 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7775
ce764ab2 7776 return 0;
e16fb6d1
TI
7777
7778 error:
7779 alc_free(codec);
7780 return err;
ce764ab2
TI
7781}
7782
1d045db9
TI
7783/*
7784 * ALC662 support
7785 *
7786 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
7787 * configuration. Each pin widget can choose any input DACs and a mixer.
7788 * Each ADC is connected from a mixer of all inputs. This makes possible
7789 * 6-channel independent captures.
7790 *
7791 * In addition, an independent DAC for the multi-playback (not used in this
7792 * driver yet).
7793 */
1d045db9
TI
7794
7795/*
7796 * BIOS auto configuration
7797 */
7798
bc9f98a9
KY
7799static int alc662_parse_auto_config(struct hda_codec *codec)
7800{
4c6d72d1 7801 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7802 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
7803 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7804 const hda_nid_t *ssids;
ee979a14 7805
7639a06c
TI
7806 if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
7807 codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
7808 codec->core.vendor_id == 0x10ec0671)
3e6179b8 7809 ssids = alc663_ssids;
6227cdce 7810 else
3e6179b8
TI
7811 ssids = alc662_ssids;
7812 return alc_parse_auto_config(codec, alc662_ignore, ssids);
bc9f98a9
KY
7813}
7814
6be7948f 7815static void alc272_fixup_mario(struct hda_codec *codec,
1727a771 7816 const struct hda_fixup *fix, int action)
6fc398cb 7817{
9bb1f06f 7818 if (action != HDA_FIXUP_ACT_PRE_PROBE)
6fc398cb 7819 return;
6be7948f
TB
7820 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
7821 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
7822 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
7823 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7824 (0 << AC_AMPCAP_MUTE_SHIFT)))
4e76a883 7825 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
6be7948f
TB
7826}
7827
8e383953
TI
7828static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
7829 { .channels = 2,
7830 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
7831 { .channels = 4,
7832 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
7833 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
7834 { }
7835};
7836
7837/* override the 2.1 chmap */
eb9ca3ab 7838static void alc_fixup_bass_chmap(struct hda_codec *codec,
8e383953
TI
7839 const struct hda_fixup *fix, int action)
7840{
7841 if (action == HDA_FIXUP_ACT_BUILD) {
7842 struct alc_spec *spec = codec->spec;
bbbc7e85 7843 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
8e383953
TI
7844 }
7845}
7846
bf68665d
TI
7847/* avoid D3 for keeping GPIO up */
7848static unsigned int gpio_led_power_filter(struct hda_codec *codec,
7849 hda_nid_t nid,
7850 unsigned int power_state)
7851{
7852 struct alc_spec *spec = codec->spec;
7639a06c 7853 if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_led)
bf68665d
TI
7854 return AC_PWRST_D0;
7855 return power_state;
7856}
7857
3e887f37
TI
7858static void alc662_fixup_led_gpio1(struct hda_codec *codec,
7859 const struct hda_fixup *fix, int action)
7860{
7861 struct alc_spec *spec = codec->spec;
7862 static const struct hda_verb gpio_init[] = {
7863 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
7864 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
7865 {}
7866 };
7867
7868 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 7869 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3e887f37 7870 spec->gpio_led = 0;
0f32fd19
TI
7871 spec->mute_led_polarity = 1;
7872 spec->gpio_mute_led_mask = 0x01;
3e887f37 7873 snd_hda_add_verbs(codec, gpio_init);
bf68665d 7874 codec->power_filter = gpio_led_power_filter;
3e887f37
TI
7875 }
7876}
7877
c6790c8e
KY
7878static void alc662_usi_automute_hook(struct hda_codec *codec,
7879 struct hda_jack_callback *jack)
7880{
7881 struct alc_spec *spec = codec->spec;
7882 int vref;
7883 msleep(200);
7884 snd_hda_gen_hp_automute(codec, jack);
7885
7886 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
7887 msleep(100);
7888 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7889 vref);
7890}
7891
7892static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
7893 const struct hda_fixup *fix, int action)
7894{
7895 struct alc_spec *spec = codec->spec;
7896 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7897 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
7898 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
7899 }
7900}
7901
f3f9185f
KY
7902static struct coef_fw alc668_coefs[] = {
7903 WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0),
7904 WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80),
7905 WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b, 0x0),
7906 WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
7907 WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
7908 WRITE_COEF(0x13, 0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
7909 WRITE_COEF(0x19, 0x0), WRITE_COEF(0x1a, 0x0), WRITE_COEF(0x1b, 0x0),
7910 WRITE_COEF(0x1c, 0x0), WRITE_COEF(0x1d, 0x0), WRITE_COEF(0x1e, 0x7418),
7911 WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
7912 WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
7913 WRITE_COEF(0x27, 0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
7914 WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
7915 WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac, 0x0),
7916 WRITE_COEF(0xad, 0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
7917 WRITE_COEF(0xb0, 0x0), WRITE_COEF(0xb1, 0x0), WRITE_COEF(0xb2, 0x0),
7918 WRITE_COEF(0xb3, 0x0), WRITE_COEF(0xb4, 0x0), WRITE_COEF(0xb5, 0x1040),
7919 WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
7920 WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
7921 WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
7922 WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
7923 {}
7924};
7925
7926static void alc668_restore_default_value(struct hda_codec *codec)
7927{
7928 alc_process_coef_fw(codec, alc668_coefs);
7929}
7930
6cb3b707 7931enum {
2df03514 7932 ALC662_FIXUP_ASPIRE,
3e887f37 7933 ALC662_FIXUP_LED_GPIO1,
6cb3b707 7934 ALC662_FIXUP_IDEAPAD,
6be7948f 7935 ALC272_FIXUP_MARIO,
d2ebd479 7936 ALC662_FIXUP_CZC_P10T,
94024cd1 7937 ALC662_FIXUP_SKU_IGNORE,
e59ea3ed 7938 ALC662_FIXUP_HP_RP5800,
53c334ad
TI
7939 ALC662_FIXUP_ASUS_MODE1,
7940 ALC662_FIXUP_ASUS_MODE2,
7941 ALC662_FIXUP_ASUS_MODE3,
7942 ALC662_FIXUP_ASUS_MODE4,
7943 ALC662_FIXUP_ASUS_MODE5,
7944 ALC662_FIXUP_ASUS_MODE6,
7945 ALC662_FIXUP_ASUS_MODE7,
7946 ALC662_FIXUP_ASUS_MODE8,
1565cc35 7947 ALC662_FIXUP_NO_JACK_DETECT,
edfe3bfc 7948 ALC662_FIXUP_ZOTAC_Z68,
125821ae 7949 ALC662_FIXUP_INV_DMIC,
1f8b46cd 7950 ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
73bdd597 7951 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
1f8b46cd 7952 ALC662_FIXUP_HEADSET_MODE,
73bdd597 7953 ALC668_FIXUP_HEADSET_MODE,
8e54b4ac 7954 ALC662_FIXUP_BASS_MODE4_CHMAP,
61a75f13 7955 ALC662_FIXUP_BASS_16,
a30c9aaa 7956 ALC662_FIXUP_BASS_1A,
8e54b4ac 7957 ALC662_FIXUP_BASS_CHMAP,
493a52a9 7958 ALC668_FIXUP_AUTO_MUTE,
5e6db669 7959 ALC668_FIXUP_DELL_DISABLE_AAMIX,
033b0a7c 7960 ALC668_FIXUP_DELL_XPS13,
9d4dc584 7961 ALC662_FIXUP_ASUS_Nx50,
fc7438b1 7962 ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3231e205 7963 ALC668_FIXUP_ASUS_Nx51,
73d9844f 7964 ALC668_FIXUP_MIC_COEF,
495b327b 7965 ALC668_FIXUP_ASUS_G751,
78f4f7c2
KY
7966 ALC891_FIXUP_HEADSET_MODE,
7967 ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
9b51fe3e 7968 ALC662_FIXUP_ACER_VERITON,
1a3f0991 7969 ALC892_FIXUP_ASROCK_MOBO,
c6790c8e
KY
7970 ALC662_FIXUP_USI_FUNC,
7971 ALC662_FIXUP_USI_HEADSET_MODE,
ca169cc2 7972 ALC662_FIXUP_LENOVO_MULTI_CODECS,
6cb3b707
DH
7973};
7974
1727a771 7975static const struct hda_fixup alc662_fixups[] = {
2df03514 7976 [ALC662_FIXUP_ASPIRE] = {
1727a771
TI
7977 .type = HDA_FIXUP_PINS,
7978 .v.pins = (const struct hda_pintbl[]) {
2df03514
DC
7979 { 0x15, 0x99130112 }, /* subwoofer */
7980 { }
7981 }
7982 },
3e887f37
TI
7983 [ALC662_FIXUP_LED_GPIO1] = {
7984 .type = HDA_FIXUP_FUNC,
7985 .v.func = alc662_fixup_led_gpio1,
7986 },
6cb3b707 7987 [ALC662_FIXUP_IDEAPAD] = {
1727a771
TI
7988 .type = HDA_FIXUP_PINS,
7989 .v.pins = (const struct hda_pintbl[]) {
6cb3b707
DH
7990 { 0x17, 0x99130112 }, /* subwoofer */
7991 { }
3e887f37
TI
7992 },
7993 .chained = true,
7994 .chain_id = ALC662_FIXUP_LED_GPIO1,
6cb3b707 7995 },
6be7948f 7996 [ALC272_FIXUP_MARIO] = {
1727a771 7997 .type = HDA_FIXUP_FUNC,
b5bfbc67 7998 .v.func = alc272_fixup_mario,
d2ebd479
AA
7999 },
8000 [ALC662_FIXUP_CZC_P10T] = {
1727a771 8001 .type = HDA_FIXUP_VERBS,
d2ebd479
AA
8002 .v.verbs = (const struct hda_verb[]) {
8003 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
8004 {}
8005 }
8006 },
94024cd1 8007 [ALC662_FIXUP_SKU_IGNORE] = {
1727a771 8008 .type = HDA_FIXUP_FUNC,
23d30f28 8009 .v.func = alc_fixup_sku_ignore,
c6b35874 8010 },
e59ea3ed 8011 [ALC662_FIXUP_HP_RP5800] = {
1727a771
TI
8012 .type = HDA_FIXUP_PINS,
8013 .v.pins = (const struct hda_pintbl[]) {
e59ea3ed
TI
8014 { 0x14, 0x0221201f }, /* HP out */
8015 { }
8016 },
8017 .chained = true,
8018 .chain_id = ALC662_FIXUP_SKU_IGNORE
8019 },
53c334ad 8020 [ALC662_FIXUP_ASUS_MODE1] = {
1727a771
TI
8021 .type = HDA_FIXUP_PINS,
8022 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8023 { 0x14, 0x99130110 }, /* speaker */
8024 { 0x18, 0x01a19c20 }, /* mic */
8025 { 0x19, 0x99a3092f }, /* int-mic */
8026 { 0x21, 0x0121401f }, /* HP out */
8027 { }
8028 },
8029 .chained = true,
8030 .chain_id = ALC662_FIXUP_SKU_IGNORE
8031 },
8032 [ALC662_FIXUP_ASUS_MODE2] = {
1727a771
TI
8033 .type = HDA_FIXUP_PINS,
8034 .v.pins = (const struct hda_pintbl[]) {
2996bdba
TI
8035 { 0x14, 0x99130110 }, /* speaker */
8036 { 0x18, 0x01a19820 }, /* mic */
8037 { 0x19, 0x99a3092f }, /* int-mic */
8038 { 0x1b, 0x0121401f }, /* HP out */
8039 { }
8040 },
53c334ad
TI
8041 .chained = true,
8042 .chain_id = ALC662_FIXUP_SKU_IGNORE
8043 },
8044 [ALC662_FIXUP_ASUS_MODE3] = {
1727a771
TI
8045 .type = HDA_FIXUP_PINS,
8046 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8047 { 0x14, 0x99130110 }, /* speaker */
8048 { 0x15, 0x0121441f }, /* HP */
8049 { 0x18, 0x01a19840 }, /* mic */
8050 { 0x19, 0x99a3094f }, /* int-mic */
8051 { 0x21, 0x01211420 }, /* HP2 */
8052 { }
8053 },
8054 .chained = true,
8055 .chain_id = ALC662_FIXUP_SKU_IGNORE
8056 },
8057 [ALC662_FIXUP_ASUS_MODE4] = {
1727a771
TI
8058 .type = HDA_FIXUP_PINS,
8059 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8060 { 0x14, 0x99130110 }, /* speaker */
8061 { 0x16, 0x99130111 }, /* speaker */
8062 { 0x18, 0x01a19840 }, /* mic */
8063 { 0x19, 0x99a3094f }, /* int-mic */
8064 { 0x21, 0x0121441f }, /* HP */
8065 { }
8066 },
8067 .chained = true,
8068 .chain_id = ALC662_FIXUP_SKU_IGNORE
8069 },
8070 [ALC662_FIXUP_ASUS_MODE5] = {
1727a771
TI
8071 .type = HDA_FIXUP_PINS,
8072 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8073 { 0x14, 0x99130110 }, /* speaker */
8074 { 0x15, 0x0121441f }, /* HP */
8075 { 0x16, 0x99130111 }, /* speaker */
8076 { 0x18, 0x01a19840 }, /* mic */
8077 { 0x19, 0x99a3094f }, /* int-mic */
8078 { }
8079 },
8080 .chained = true,
8081 .chain_id = ALC662_FIXUP_SKU_IGNORE
8082 },
8083 [ALC662_FIXUP_ASUS_MODE6] = {
1727a771
TI
8084 .type = HDA_FIXUP_PINS,
8085 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8086 { 0x14, 0x99130110 }, /* speaker */
8087 { 0x15, 0x01211420 }, /* HP2 */
8088 { 0x18, 0x01a19840 }, /* mic */
8089 { 0x19, 0x99a3094f }, /* int-mic */
8090 { 0x1b, 0x0121441f }, /* HP */
8091 { }
8092 },
8093 .chained = true,
8094 .chain_id = ALC662_FIXUP_SKU_IGNORE
8095 },
8096 [ALC662_FIXUP_ASUS_MODE7] = {
1727a771
TI
8097 .type = HDA_FIXUP_PINS,
8098 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8099 { 0x14, 0x99130110 }, /* speaker */
8100 { 0x17, 0x99130111 }, /* speaker */
8101 { 0x18, 0x01a19840 }, /* mic */
8102 { 0x19, 0x99a3094f }, /* int-mic */
8103 { 0x1b, 0x01214020 }, /* HP */
8104 { 0x21, 0x0121401f }, /* HP */
8105 { }
8106 },
8107 .chained = true,
8108 .chain_id = ALC662_FIXUP_SKU_IGNORE
8109 },
8110 [ALC662_FIXUP_ASUS_MODE8] = {
1727a771
TI
8111 .type = HDA_FIXUP_PINS,
8112 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
8113 { 0x14, 0x99130110 }, /* speaker */
8114 { 0x12, 0x99a30970 }, /* int-mic */
8115 { 0x15, 0x01214020 }, /* HP */
8116 { 0x17, 0x99130111 }, /* speaker */
8117 { 0x18, 0x01a19840 }, /* mic */
8118 { 0x21, 0x0121401f }, /* HP */
8119 { }
8120 },
8121 .chained = true,
8122 .chain_id = ALC662_FIXUP_SKU_IGNORE
2996bdba 8123 },
1565cc35 8124 [ALC662_FIXUP_NO_JACK_DETECT] = {
1727a771 8125 .type = HDA_FIXUP_FUNC,
1565cc35
TI
8126 .v.func = alc_fixup_no_jack_detect,
8127 },
edfe3bfc 8128 [ALC662_FIXUP_ZOTAC_Z68] = {
1727a771
TI
8129 .type = HDA_FIXUP_PINS,
8130 .v.pins = (const struct hda_pintbl[]) {
edfe3bfc
DH
8131 { 0x1b, 0x02214020 }, /* Front HP */
8132 { }
8133 }
8134 },
125821ae 8135 [ALC662_FIXUP_INV_DMIC] = {
1727a771 8136 .type = HDA_FIXUP_FUNC,
9d36a7dc 8137 .v.func = alc_fixup_inv_dmic,
125821ae 8138 },
033b0a7c
GM
8139 [ALC668_FIXUP_DELL_XPS13] = {
8140 .type = HDA_FIXUP_FUNC,
8141 .v.func = alc_fixup_dell_xps13,
8142 .chained = true,
8143 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
8144 },
5e6db669
GM
8145 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
8146 .type = HDA_FIXUP_FUNC,
8147 .v.func = alc_fixup_disable_aamix,
8148 .chained = true,
8149 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
8150 },
493a52a9
HW
8151 [ALC668_FIXUP_AUTO_MUTE] = {
8152 .type = HDA_FIXUP_FUNC,
8153 .v.func = alc_fixup_auto_mute_via_amp,
8154 .chained = true,
8155 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
8156 },
1f8b46cd
DH
8157 [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
8158 .type = HDA_FIXUP_PINS,
8159 .v.pins = (const struct hda_pintbl[]) {
8160 { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8161 /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
8162 { }
8163 },
8164 .chained = true,
8165 .chain_id = ALC662_FIXUP_HEADSET_MODE
8166 },
8167 [ALC662_FIXUP_HEADSET_MODE] = {
8168 .type = HDA_FIXUP_FUNC,
8169 .v.func = alc_fixup_headset_mode_alc662,
8170 },
73bdd597
DH
8171 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
8172 .type = HDA_FIXUP_PINS,
8173 .v.pins = (const struct hda_pintbl[]) {
8174 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8175 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8176 { }
8177 },
8178 .chained = true,
8179 .chain_id = ALC668_FIXUP_HEADSET_MODE
8180 },
8181 [ALC668_FIXUP_HEADSET_MODE] = {
8182 .type = HDA_FIXUP_FUNC,
8183 .v.func = alc_fixup_headset_mode_alc668,
8184 },
8e54b4ac 8185 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
8e383953 8186 .type = HDA_FIXUP_FUNC,
eb9ca3ab 8187 .v.func = alc_fixup_bass_chmap,
8e383953
TI
8188 .chained = true,
8189 .chain_id = ALC662_FIXUP_ASUS_MODE4
8190 },
61a75f13
DH
8191 [ALC662_FIXUP_BASS_16] = {
8192 .type = HDA_FIXUP_PINS,
8193 .v.pins = (const struct hda_pintbl[]) {
8194 {0x16, 0x80106111}, /* bass speaker */
8195 {}
8196 },
8197 .chained = true,
8198 .chain_id = ALC662_FIXUP_BASS_CHMAP,
8199 },
a30c9aaa
TI
8200 [ALC662_FIXUP_BASS_1A] = {
8201 .type = HDA_FIXUP_PINS,
8202 .v.pins = (const struct hda_pintbl[]) {
8203 {0x1a, 0x80106111}, /* bass speaker */
8204 {}
8205 },
8e54b4ac
DH
8206 .chained = true,
8207 .chain_id = ALC662_FIXUP_BASS_CHMAP,
a30c9aaa 8208 },
8e54b4ac 8209 [ALC662_FIXUP_BASS_CHMAP] = {
a30c9aaa 8210 .type = HDA_FIXUP_FUNC,
eb9ca3ab 8211 .v.func = alc_fixup_bass_chmap,
a30c9aaa 8212 },
9d4dc584
BM
8213 [ALC662_FIXUP_ASUS_Nx50] = {
8214 .type = HDA_FIXUP_FUNC,
8215 .v.func = alc_fixup_auto_mute_via_amp,
8216 .chained = true,
8217 .chain_id = ALC662_FIXUP_BASS_1A
8218 },
fc7438b1
MP
8219 [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
8220 .type = HDA_FIXUP_FUNC,
8221 .v.func = alc_fixup_headset_mode_alc668,
8222 .chain_id = ALC662_FIXUP_BASS_CHMAP
8223 },
3231e205
YP
8224 [ALC668_FIXUP_ASUS_Nx51] = {
8225 .type = HDA_FIXUP_PINS,
8226 .v.pins = (const struct hda_pintbl[]) {
fc7438b1
MP
8227 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8228 { 0x1a, 0x90170151 }, /* bass speaker */
8229 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
3231e205
YP
8230 {}
8231 },
8232 .chained = true,
fc7438b1 8233 .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3231e205 8234 },
73d9844f 8235 [ALC668_FIXUP_MIC_COEF] = {
495b327b
TI
8236 .type = HDA_FIXUP_VERBS,
8237 .v.verbs = (const struct hda_verb[]) {
8238 { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
8239 { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
8240 {}
8241 },
8242 },
73d9844f
TI
8243 [ALC668_FIXUP_ASUS_G751] = {
8244 .type = HDA_FIXUP_PINS,
8245 .v.pins = (const struct hda_pintbl[]) {
8246 { 0x16, 0x0421101f }, /* HP */
8247 {}
8248 },
8249 .chained = true,
8250 .chain_id = ALC668_FIXUP_MIC_COEF
8251 },
78f4f7c2
KY
8252 [ALC891_FIXUP_HEADSET_MODE] = {
8253 .type = HDA_FIXUP_FUNC,
8254 .v.func = alc_fixup_headset_mode,
8255 },
8256 [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
8257 .type = HDA_FIXUP_PINS,
8258 .v.pins = (const struct hda_pintbl[]) {
8259 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
8260 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
8261 { }
8262 },
8263 .chained = true,
8264 .chain_id = ALC891_FIXUP_HEADSET_MODE
8265 },
9b51fe3e
SB
8266 [ALC662_FIXUP_ACER_VERITON] = {
8267 .type = HDA_FIXUP_PINS,
8268 .v.pins = (const struct hda_pintbl[]) {
8269 { 0x15, 0x50170120 }, /* no internal speaker */
8270 { }
8271 }
8272 },
1a3f0991
TI
8273 [ALC892_FIXUP_ASROCK_MOBO] = {
8274 .type = HDA_FIXUP_PINS,
8275 .v.pins = (const struct hda_pintbl[]) {
8276 { 0x15, 0x40f000f0 }, /* disabled */
8277 { 0x16, 0x40f000f0 }, /* disabled */
1a3f0991
TI
8278 { }
8279 }
8280 },
c6790c8e
KY
8281 [ALC662_FIXUP_USI_FUNC] = {
8282 .type = HDA_FIXUP_FUNC,
8283 .v.func = alc662_fixup_usi_headset_mic,
8284 },
8285 [ALC662_FIXUP_USI_HEADSET_MODE] = {
8286 .type = HDA_FIXUP_PINS,
8287 .v.pins = (const struct hda_pintbl[]) {
8288 { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
8289 { 0x18, 0x01a1903d },
8290 { }
8291 },
8292 .chained = true,
8293 .chain_id = ALC662_FIXUP_USI_FUNC
8294 },
ca169cc2
KY
8295 [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
8296 .type = HDA_FIXUP_FUNC,
8297 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
8298 },
6cb3b707
DH
8299};
8300
a9111321 8301static const struct snd_pci_quirk alc662_fixup_tbl[] = {
53c334ad 8302 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
d3d3835c 8303 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
02f6ff90 8304 SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
a6c47a85 8305 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
94024cd1 8306 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
125821ae 8307 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
1801928e 8308 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
2df03514 8309 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
73bdd597
DH
8310 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8311 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
c5d019c3 8312 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
033b0a7c 8313 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
467e1436 8314 SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
09d2014f 8315 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
ad8ff99e 8316 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8dc9abb9
KY
8317 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8318 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6a98e34b 8319 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
e59ea3ed 8320 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
2da2dc9e 8321 SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
83a9efb5 8322 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
db8948e6 8323 SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
9d4dc584 8324 SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
495b327b 8325 SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
8e54b4ac 8326 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
61a75f13 8327 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
3231e205
YP
8328 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
8329 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
c7efff92 8330 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
61a75f13 8331 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8e54b4ac 8332 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
1565cc35 8333 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
53c334ad 8334 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
a0e90acc 8335 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
c6790c8e 8336 SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
ca169cc2 8337 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
d4118588 8338 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6cb3b707 8339 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
1a3f0991 8340 SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
edfe3bfc 8341 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
9b51fe3e 8342 SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
d2ebd479 8343 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
53c334ad
TI
8344
8345#if 0
8346 /* Below is a quirk table taken from the old code.
8347 * Basically the device should work as is without the fixup table.
8348 * If BIOS doesn't give a proper info, enable the corresponding
8349 * fixup entry.
7d7eb9ea 8350 */
53c334ad
TI
8351 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
8352 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
8353 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
8354 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
8355 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8356 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8357 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8358 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
8359 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
8360 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8361 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
8362 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
8363 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
8364 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
8365 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
8366 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8367 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
8368 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
8369 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8370 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8371 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8372 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8373 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
8374 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
8375 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
8376 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8377 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
8378 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
8379 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8380 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
8381 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8382 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8383 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
8384 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
8385 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
8386 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
8387 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
8388 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
8389 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
8390 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
8391 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
8392 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
8393 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8394 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
8395 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
8396 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
8397 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
8398 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
8399 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
8400 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
8401#endif
6cb3b707
DH
8402 {}
8403};
8404
1727a771 8405static const struct hda_model_fixup alc662_fixup_models[] = {
6be7948f 8406 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
53c334ad
TI
8407 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
8408 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
8409 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
8410 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
8411 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
8412 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
8413 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
8414 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6e72aa5f 8415 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
e32aa85a 8416 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
ba90d6a6 8417 {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
6be7948f
TB
8418 {}
8419};
6cb3b707 8420
532895c5 8421static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
78f4f7c2
KY
8422 SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
8423 {0x17, 0x02211010},
8424 {0x18, 0x01a19030},
8425 {0x1a, 0x01813040},
8426 {0x21, 0x01014020}),
0b6758d3
HW
8427 SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
8428 {0x16, 0x01813030},
8429 {0x17, 0x02211010},
8430 {0x18, 0x01a19040},
8431 {0x21, 0x01014020}),
1f8b46cd 8432 SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
1f8b46cd 8433 {0x14, 0x01014010},
1f8b46cd 8434 {0x18, 0x01a19020},
1f8b46cd 8435 {0x1a, 0x0181302f},
11580297 8436 {0x1b, 0x0221401f}),
76c2132e
DH
8437 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8438 {0x12, 0x99a30130},
8439 {0x14, 0x90170110},
8440 {0x15, 0x0321101f},
11580297 8441 {0x16, 0x03011020}),
76c2132e
DH
8442 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8443 {0x12, 0x99a30140},
8444 {0x14, 0x90170110},
8445 {0x15, 0x0321101f},
11580297 8446 {0x16, 0x03011020}),
76c2132e
DH
8447 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
8448 {0x12, 0x99a30150},
8449 {0x14, 0x90170110},
8450 {0x15, 0x0321101f},
11580297 8451 {0x16, 0x03011020}),
76c2132e 8452 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
76c2132e
DH
8453 {0x14, 0x90170110},
8454 {0x15, 0x0321101f},
11580297 8455 {0x16, 0x03011020}),
76c2132e
DH
8456 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
8457 {0x12, 0x90a60130},
8458 {0x14, 0x90170110},
11580297 8459 {0x15, 0x0321101f}),
532895c5
HW
8460 {}
8461};
8462
1d045db9
TI
8463/*
8464 */
bc9f98a9
KY
8465static int patch_alc662(struct hda_codec *codec)
8466{
8467 struct alc_spec *spec;
3de95173 8468 int err;
bc9f98a9 8469
3de95173
TI
8470 err = alc_alloc_spec(codec, 0x0b);
8471 if (err < 0)
8472 return err;
bc9f98a9 8473
3de95173 8474 spec = codec->spec;
1f0f4b80 8475
225068ab
TI
8476 spec->shutup = alc_eapd_shutup;
8477
53c334ad
TI
8478 /* handle multiple HPs as is */
8479 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
8480
2c3bf9ab
TI
8481 alc_fix_pll_init(codec, 0x20, 0x04, 15);
8482
7639a06c 8483 switch (codec->core.vendor_id) {
f3f9185f
KY
8484 case 0x10ec0668:
8485 spec->init_hook = alc668_restore_default_value;
8486 break;
f3f9185f 8487 }
8663ff75 8488
1727a771 8489 snd_hda_pick_fixup(codec, alc662_fixup_models,
8e5a0509 8490 alc662_fixup_tbl, alc662_fixups);
532895c5 8491 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
1727a771 8492 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8e5a0509
TI
8493
8494 alc_auto_parse_customize_define(codec);
8495
7504b6cd
TI
8496 if (has_cdefine_beep(codec))
8497 spec->gen.beep_nid = 0x01;
8498
1bb7e43e 8499 if ((alc_get_coef0(codec) & (1 << 14)) &&
5100cd07 8500 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 8501 spec->cdefine.platform_type == 1) {
6134b1a2
WY
8502 err = alc_codec_rename(codec, "ALC272X");
8503 if (err < 0)
e16fb6d1 8504 goto error;
20ca0c35 8505 }
274693f3 8506
b9c5106c
TI
8507 /* automatic parse from the BIOS config */
8508 err = alc662_parse_auto_config(codec);
e16fb6d1
TI
8509 if (err < 0)
8510 goto error;
bc9f98a9 8511
7504b6cd 8512 if (!spec->gen.no_analog && spec->gen.beep_nid) {
7639a06c 8513 switch (codec->core.vendor_id) {
da00c244
KY
8514 case 0x10ec0662:
8515 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
8516 break;
8517 case 0x10ec0272:
8518 case 0x10ec0663:
8519 case 0x10ec0665:
9ad54547 8520 case 0x10ec0668:
da00c244
KY
8521 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
8522 break;
8523 case 0x10ec0273:
8524 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
8525 break;
8526 }
cec27c89 8527 }
2134ea4f 8528
1727a771 8529 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 8530
bc9f98a9 8531 return 0;
801f49d3 8532
e16fb6d1
TI
8533 error:
8534 alc_free(codec);
8535 return err;
b478b998
KY
8536}
8537
d1eb57f4
KY
8538/*
8539 * ALC680 support
8540 */
d1eb57f4 8541
d1eb57f4
KY
8542static int alc680_parse_auto_config(struct hda_codec *codec)
8543{
3e6179b8 8544 return alc_parse_auto_config(codec, NULL, NULL);
d1eb57f4
KY
8545}
8546
d1eb57f4 8547/*
d1eb57f4 8548 */
d1eb57f4
KY
8549static int patch_alc680(struct hda_codec *codec)
8550{
d1eb57f4
KY
8551 int err;
8552
1f0f4b80 8553 /* ALC680 has no aa-loopback mixer */
3de95173
TI
8554 err = alc_alloc_spec(codec, 0);
8555 if (err < 0)
8556 return err;
1f0f4b80 8557
1ebec5f2
TI
8558 /* automatic parse from the BIOS config */
8559 err = alc680_parse_auto_config(codec);
8560 if (err < 0) {
8561 alc_free(codec);
8562 return err;
d1eb57f4
KY
8563 }
8564
d1eb57f4
KY
8565 return 0;
8566}
8567
1da177e4
LT
8568/*
8569 * patch entries
8570 */
b9a94a9c 8571static const struct hda_device_id snd_hda_id_realtek[] = {
0a6f0600 8572 HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
b9a94a9c 8573 HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
4231430d 8574 HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
b9a94a9c
TI
8575 HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
8576 HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
dcd4f0db 8577 HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
b9a94a9c 8578 HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
736f20a7 8579 HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
b9a94a9c
TI
8580 HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
8581 HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
f429e7e4 8582 HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
b9a94a9c
TI
8583 HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
8584 HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
8585 HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
8586 HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
8587 HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
8588 HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
8589 HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
dcd4f0db 8590 HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
b9a94a9c
TI
8591 HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
8592 HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
8593 HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
8594 HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
8595 HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
8596 HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
0a6f0600 8597 HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
b9a94a9c
TI
8598 HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
8599 HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
0a6f0600 8600 HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
b9a94a9c
TI
8601 HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
8602 HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
8603 HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
dcd4f0db 8604 HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
7d727869 8605 HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
b9a94a9c 8606 HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
28f1f9b2 8607 HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
9887cf53 8608 HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
b9a94a9c
TI
8609 HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
8610 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
8611 HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
8612 HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
8613 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
8614 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
8615 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
8616 HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
8617 HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
8618 HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
8619 HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
8620 HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
8621 HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
8622 HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
6fbae35a
KY
8623 HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
8624 HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
8625 HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
78f4f7c2 8626 HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
b9a94a9c
TI
8627 HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
8628 HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
8629 HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
8630 HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
8631 HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
8632 HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
8633 HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
8634 HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
8635 HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
8636 HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
8637 HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
8638 HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
8639 HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
65553b12 8640 HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
a535ad57 8641 HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
1da177e4
LT
8642 {} /* terminator */
8643};
b9a94a9c 8644MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
1289e9e8
TI
8645
8646MODULE_LICENSE("GPL");
8647MODULE_DESCRIPTION("Realtek HD-audio codec");
8648
d8a766a1 8649static struct hda_codec_driver realtek_driver = {
b9a94a9c 8650 .id = snd_hda_id_realtek,
1289e9e8
TI
8651};
8652
d8a766a1 8653module_hda_codec_driver(realtek_driver);