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