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