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