]> git.ipfire.org Git - thirdparty/linux.git/blame - sound/pci/hda/patch_realtek.c
ALSA: hda/realtek - Add alc_update_coef*_idx() helper
[thirdparty/linux.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>
1da177e4 32#include <sound/core.h>
9ad0e496 33#include <sound/jack.h>
1da177e4
LT
34#include "hda_codec.h"
35#include "hda_local.h"
23d30f28 36#include "hda_auto_parser.h"
1835a0f9 37#include "hda_jack.h"
08c189f2 38#include "hda_generic.h"
1da177e4 39
cd63a5ff
TI
40/* keep halting ALC5505 DSP, for power saving */
41#define HALT_REALTEK_ALC5505
42
1d045db9 43/* unsol event tags */
08c189f2 44#define ALC_DCVOL_EVENT 0x08
d4a86d81 45
df694daa
KY
46/* for GPIO Poll */
47#define GPIO_MASK 0x03
48
4a79ba34
TI
49/* extra amp-initialization sequence types */
50enum {
51 ALC_INIT_NONE,
52 ALC_INIT_DEFAULT,
53 ALC_INIT_GPIO1,
54 ALC_INIT_GPIO2,
55 ALC_INIT_GPIO3,
56};
57
73bdd597
DH
58enum {
59 ALC_HEADSET_MODE_UNKNOWN,
60 ALC_HEADSET_MODE_UNPLUGGED,
61 ALC_HEADSET_MODE_HEADSET,
62 ALC_HEADSET_MODE_MIC,
63 ALC_HEADSET_MODE_HEADPHONE,
64};
65
66enum {
67 ALC_HEADSET_TYPE_UNKNOWN,
68 ALC_HEADSET_TYPE_CTIA,
69 ALC_HEADSET_TYPE_OMTP,
70};
71
da00c244
KY
72struct alc_customize_define {
73 unsigned int sku_cfg;
74 unsigned char port_connectivity;
75 unsigned char check_sum;
76 unsigned char customization;
77 unsigned char external_amp;
78 unsigned int enable_pcbeep:1;
79 unsigned int platform_type:1;
80 unsigned int swap:1;
81 unsigned int override:1;
90622917 82 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
da00c244
KY
83};
84
1da177e4 85struct alc_spec {
08c189f2 86 struct hda_gen_spec gen; /* must be at head */
23d30f28 87
1da177e4 88 /* codec parameterization */
a9111321 89 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
1da177e4 90 unsigned int num_mixers;
45bdd1c1 91 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
1da177e4 92
da00c244 93 struct alc_customize_define cdefine;
08c189f2 94 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
834be88d 95
08c189f2
TI
96 /* inverted dmic fix */
97 unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */
98 unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */
125821ae 99 hda_nid_t inv_dmic_pin;
834be88d 100
08fb0d0e
TI
101 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
102 int mute_led_polarity;
103 hda_nid_t mute_led_nid;
9c5dc3bf 104 hda_nid_t cap_mute_led_nid;
08fb0d0e 105
9f5c6faf
TI
106 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
107
73bdd597
DH
108 hda_nid_t headset_mic_pin;
109 hda_nid_t headphone_mic_pin;
110 int current_headset_mode;
111 int current_headset_type;
112
ae6b813a
TI
113 /* hooks */
114 void (*init_hook)(struct hda_codec *codec);
83012a7c 115#ifdef CONFIG_PM
c97259df 116 void (*power_hook)(struct hda_codec *codec);
f5de24b0 117#endif
1c716153 118 void (*shutup)(struct hda_codec *codec);
d922b51d 119
4a79ba34 120 int init_amp;
d433a678 121 int codec_variant; /* flag for other variants */
97a26570
KY
122 unsigned int has_alc5505_dsp:1;
123 unsigned int no_depop_delay:1;
e64f14f4 124
2c3bf9ab
TI
125 /* for PLL fix */
126 hda_nid_t pll_nid;
127 unsigned int pll_coef_idx, pll_coef_bit;
1bb7e43e 128 unsigned int coef0;
df694daa
KY
129};
130
f2a227cd
TI
131/*
132 * COEF access helper functions
133 */
134
135static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
136 unsigned int coef_idx)
137{
138 unsigned int val;
139
140 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
141 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
142 return val;
143}
144
145#define alc_read_coef_idx(codec, coef_idx) \
146 alc_read_coefex_idx(codec, 0x20, coef_idx)
147
148static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
149 unsigned int coef_idx, unsigned int coef_val)
150{
151 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
152 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
153}
154
155#define alc_write_coef_idx(codec, coef_idx, coef_val) \
156 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
157
98b24883
TI
158static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
159 unsigned int coef_idx, unsigned int mask,
160 unsigned int bits_set)
161{
162 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
163
164 if (val != -1)
165 alc_write_coefex_idx(codec, nid, coef_idx,
166 (val & ~mask) | bits_set);
167}
168
169#define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
170 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
171
f2a227cd
TI
172/* a special bypass for COEF 0; read the cached value at the second time */
173static unsigned int alc_get_coef0(struct hda_codec *codec)
174{
175 struct alc_spec *spec = codec->spec;
176
177 if (!spec->coef0)
178 spec->coef0 = alc_read_coef_idx(codec, 0);
179 return spec->coef0;
180}
181
d88897ea 182/*
1d045db9
TI
183 * Append the given mixer and verb elements for the later use
184 * The mixer array is referred in build_controls(), and init_verbs are
185 * called in init().
d88897ea 186 */
a9111321 187static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
d88897ea
TI
188{
189 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
190 return;
191 spec->mixers[spec->num_mixers++] = mix;
192}
193
df694daa 194/*
1d045db9 195 * GPIO setup tables, used in initialization
df694daa 196 */
bc9f98a9 197/* Enable GPIO mask and set output */
a9111321 198static const struct hda_verb alc_gpio1_init_verbs[] = {
bc9f98a9
KY
199 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
200 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
201 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
202 { }
203};
204
a9111321 205static const struct hda_verb alc_gpio2_init_verbs[] = {
bc9f98a9
KY
206 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
207 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
208 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
209 { }
210};
211
a9111321 212static const struct hda_verb alc_gpio3_init_verbs[] = {
bdd148a3
KY
213 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
214 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
215 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
216 { }
217};
218
2c3bf9ab
TI
219/*
220 * Fix hardware PLL issue
221 * On some codecs, the analog PLL gating control must be off while
222 * the default value is 1.
223 */
224static void alc_fix_pll(struct hda_codec *codec)
225{
226 struct alc_spec *spec = codec->spec;
2c3bf9ab 227
98b24883
TI
228 if (spec->pll_nid)
229 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
230 1 << spec->pll_coef_bit, 0);
2c3bf9ab
TI
231}
232
233static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
234 unsigned int coef_idx, unsigned int coef_bit)
235{
236 struct alc_spec *spec = codec->spec;
237 spec->pll_nid = nid;
238 spec->pll_coef_idx = coef_idx;
239 spec->pll_coef_bit = coef_bit;
240 alc_fix_pll(codec);
241}
242
cf5a2279 243/* update the master volume per volume-knob's unsol event */
29adc4b9 244static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
cf5a2279
TI
245{
246 unsigned int val;
247 struct snd_kcontrol *kctl;
248 struct snd_ctl_elem_value *uctl;
249
250 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
251 if (!kctl)
252 return;
253 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
254 if (!uctl)
255 return;
29adc4b9 256 val = snd_hda_codec_read(codec, jack->nid, 0,
cf5a2279
TI
257 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
258 val &= HDA_AMP_VOLMASK;
259 uctl->value.integer.value[0] = val;
260 uctl->value.integer.value[1] = val;
261 kctl->put(kctl, uctl);
262 kfree(uctl);
263}
264
29adc4b9 265static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
f21d78e2 266{
29adc4b9
DH
267 /* For some reason, the res given from ALC880 is broken.
268 Here we adjust it properly. */
269 snd_hda_jack_unsol_event(codec, res >> 2);
f21d78e2
TI
270}
271
f9423e7a
KY
272/* additional initialization for ALC888 variants */
273static void alc888_coef_init(struct hda_codec *codec)
274{
f2a227cd 275 if (alc_get_coef0(codec) == 0x20)
f9423e7a 276 /* alc888S-VC */
f2a227cd 277 alc_write_coef_idx(codec, 7, 0x830);
f9423e7a
KY
278 else
279 /* alc888-VB */
f2a227cd 280 alc_write_coef_idx(codec, 7, 0x3030);
f9423e7a
KY
281}
282
1d045db9 283/* additional initialization for ALC889 variants */
87a8c370
JK
284static void alc889_coef_init(struct hda_codec *codec)
285{
98b24883 286 alc_update_coef_idx(codec, 7, 0, 0x2010);
87a8c370
JK
287}
288
3fb4a508
TI
289/* turn on/off EAPD control (only if available) */
290static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
291{
292 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
293 return;
294 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
295 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
296 on ? 2 : 0);
297}
298
691f1fcc
TI
299/* turn on/off EAPD controls of the codec */
300static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
301{
302 /* We currently only handle front, HP */
39fa84e9
TI
303 static hda_nid_t pins[] = {
304 0x0f, 0x10, 0x14, 0x15, 0
305 };
306 hda_nid_t *p;
307 for (p = pins; *p; p++)
308 set_eapd(codec, *p, on);
691f1fcc
TI
309}
310
1c716153
TI
311/* generic shutup callback;
312 * just turning off EPAD and a little pause for avoiding pop-noise
313 */
314static void alc_eapd_shutup(struct hda_codec *codec)
315{
97a26570
KY
316 struct alc_spec *spec = codec->spec;
317
1c716153 318 alc_auto_setup_eapd(codec, false);
97a26570
KY
319 if (!spec->no_depop_delay)
320 msleep(200);
9bfb2844 321 snd_hda_shutup_pins(codec);
1c716153
TI
322}
323
1d045db9 324/* generic EAPD initialization */
4a79ba34 325static void alc_auto_init_amp(struct hda_codec *codec, int type)
bc9f98a9 326{
39fa84e9 327 alc_auto_setup_eapd(codec, true);
4a79ba34
TI
328 switch (type) {
329 case ALC_INIT_GPIO1:
bc9f98a9
KY
330 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
331 break;
4a79ba34 332 case ALC_INIT_GPIO2:
bc9f98a9
KY
333 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
334 break;
4a79ba34 335 case ALC_INIT_GPIO3:
bdd148a3
KY
336 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
337 break;
4a79ba34 338 case ALC_INIT_DEFAULT:
c9b58006
KY
339 switch (codec->vendor_id) {
340 case 0x10ec0260:
98b24883 341 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
c9b58006
KY
342 break;
343 case 0x10ec0262:
344 case 0x10ec0880:
345 case 0x10ec0882:
346 case 0x10ec0883:
347 case 0x10ec0885:
4a5a4c56 348 case 0x10ec0887:
20b67ddd 349 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
87a8c370 350 alc889_coef_init(codec);
c9b58006 351 break;
f9423e7a 352 case 0x10ec0888:
4a79ba34 353 alc888_coef_init(codec);
f9423e7a 354 break;
0aea778e 355#if 0 /* XXX: This may cause the silent output on speaker on some machines */
c9b58006
KY
356 case 0x10ec0267:
357 case 0x10ec0268:
98b24883 358 alc_update_coef_idx(codec, 7, 0, 0x3000);
c9b58006 359 break;
0aea778e 360#endif /* XXX */
bc9f98a9 361 }
4a79ba34
TI
362 break;
363 }
364}
365
08c189f2 366
1d045db9 367/*
08c189f2 368 * Realtek SSID verification
1d045db9 369 */
42cf0d01 370
08c189f2
TI
371/* Could be any non-zero and even value. When used as fixup, tells
372 * the driver to ignore any present sku defines.
373 */
374#define ALC_FIXUP_SKU_IGNORE (2)
1a1455de 375
08c189f2
TI
376static void alc_fixup_sku_ignore(struct hda_codec *codec,
377 const struct hda_fixup *fix, int action)
1a1455de 378{
1a1455de 379 struct alc_spec *spec = codec->spec;
08c189f2
TI
380 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
381 spec->cdefine.fixup = 1;
382 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
1a1455de 383 }
1a1455de
TI
384}
385
b5c6611f
ML
386static void alc_fixup_no_depop_delay(struct hda_codec *codec,
387 const struct hda_fixup *fix, int action)
388{
389 struct alc_spec *spec = codec->spec;
390
84d2dc3e 391 if (action == HDA_FIXUP_ACT_PROBE) {
b5c6611f 392 spec->no_depop_delay = 1;
84d2dc3e
ML
393 codec->depop_delay = 0;
394 }
b5c6611f
ML
395}
396
08c189f2 397static int alc_auto_parse_customize_define(struct hda_codec *codec)
4a79ba34 398{
08c189f2
TI
399 unsigned int ass, tmp, i;
400 unsigned nid = 0;
4a79ba34
TI
401 struct alc_spec *spec = codec->spec;
402
08c189f2 403 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
4a79ba34 404
08c189f2
TI
405 if (spec->cdefine.fixup) {
406 ass = spec->cdefine.sku_cfg;
407 if (ass == ALC_FIXUP_SKU_IGNORE)
408 return -1;
409 goto do_sku;
bb35febd
TI
410 }
411
5100cd07
TI
412 if (!codec->bus->pci)
413 return -1;
08c189f2
TI
414 ass = codec->subsystem_id & 0xffff;
415 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
416 goto do_sku;
4a79ba34 417
08c189f2
TI
418 nid = 0x1d;
419 if (codec->vendor_id == 0x10ec0260)
420 nid = 0x17;
421 ass = snd_hda_codec_get_pincfg(codec, nid);
42cf0d01 422
08c189f2 423 if (!(ass & 1)) {
4e76a883
TI
424 codec_info(codec, "%s: SKU not ready 0x%08x\n",
425 codec->chip_name, ass);
08c189f2 426 return -1;
42cf0d01
DH
427 }
428
08c189f2
TI
429 /* check sum */
430 tmp = 0;
431 for (i = 1; i < 16; i++) {
432 if ((ass >> i) & 1)
433 tmp++;
ae8a60a5 434 }
08c189f2
TI
435 if (((ass >> 16) & 0xf) != tmp)
436 return -1;
ae8a60a5 437
da00c244
KY
438 spec->cdefine.port_connectivity = ass >> 30;
439 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
440 spec->cdefine.check_sum = (ass >> 16) & 0xf;
441 spec->cdefine.customization = ass >> 8;
442do_sku:
443 spec->cdefine.sku_cfg = ass;
444 spec->cdefine.external_amp = (ass & 0x38) >> 3;
445 spec->cdefine.platform_type = (ass & 0x4) >> 2;
446 spec->cdefine.swap = (ass & 0x2) >> 1;
447 spec->cdefine.override = ass & 0x1;
448
4e76a883 449 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
da00c244 450 nid, spec->cdefine.sku_cfg);
4e76a883 451 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
da00c244 452 spec->cdefine.port_connectivity);
4e76a883
TI
453 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
454 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
455 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
456 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
457 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
458 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
459 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
da00c244
KY
460
461 return 0;
462}
463
08c189f2
TI
464/* return the position of NID in the list, or -1 if not found */
465static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
466{
467 int i;
468 for (i = 0; i < nums; i++)
469 if (list[i] == nid)
470 return i;
471 return -1;
472}
1d045db9 473/* return true if the given NID is found in the list */
3af9ee6b
TI
474static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
475{
21268961 476 return find_idx_in_nid_list(nid, list, nums) >= 0;
3af9ee6b
TI
477}
478
4a79ba34
TI
479/* check subsystem ID and set up device-specific initialization;
480 * return 1 if initialized, 0 if invalid SSID
481 */
482/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
483 * 31 ~ 16 : Manufacture ID
484 * 15 ~ 8 : SKU ID
485 * 7 ~ 0 : Assembly ID
486 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
487 */
58c57cfa 488static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
4a79ba34
TI
489{
490 unsigned int ass, tmp, i;
491 unsigned nid;
492 struct alc_spec *spec = codec->spec;
493
90622917
DH
494 if (spec->cdefine.fixup) {
495 ass = spec->cdefine.sku_cfg;
496 if (ass == ALC_FIXUP_SKU_IGNORE)
497 return 0;
498 goto do_sku;
499 }
500
4a79ba34 501 ass = codec->subsystem_id & 0xffff;
5100cd07
TI
502 if (codec->bus->pci &&
503 ass != codec->bus->pci->subsystem_device && (ass & 1))
4a79ba34
TI
504 goto do_sku;
505
506 /* invalid SSID, check the special NID pin defcfg instead */
507 /*
def319f9 508 * 31~30 : port connectivity
4a79ba34
TI
509 * 29~21 : reserve
510 * 20 : PCBEEP input
511 * 19~16 : Check sum (15:1)
512 * 15~1 : Custom
513 * 0 : override
514 */
515 nid = 0x1d;
516 if (codec->vendor_id == 0x10ec0260)
517 nid = 0x17;
518 ass = snd_hda_codec_get_pincfg(codec, nid);
4e76a883
TI
519 codec_dbg(codec,
520 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
cb6605c1 521 ass, nid);
6227cdce 522 if (!(ass & 1))
4a79ba34
TI
523 return 0;
524 if ((ass >> 30) != 1) /* no physical connection */
525 return 0;
526
527 /* check sum */
528 tmp = 0;
529 for (i = 1; i < 16; i++) {
530 if ((ass >> i) & 1)
531 tmp++;
532 }
533 if (((ass >> 16) & 0xf) != tmp)
534 return 0;
535do_sku:
4e76a883 536 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
4a79ba34
TI
537 ass & 0xffff, codec->vendor_id);
538 /*
539 * 0 : override
540 * 1 : Swap Jack
541 * 2 : 0 --> Desktop, 1 --> Laptop
542 * 3~5 : External Amplifier control
543 * 7~6 : Reserved
544 */
545 tmp = (ass & 0x38) >> 3; /* external Amp control */
546 switch (tmp) {
547 case 1:
548 spec->init_amp = ALC_INIT_GPIO1;
549 break;
550 case 3:
551 spec->init_amp = ALC_INIT_GPIO2;
552 break;
553 case 7:
554 spec->init_amp = ALC_INIT_GPIO3;
555 break;
556 case 5:
5a8cfb4e 557 default:
4a79ba34 558 spec->init_amp = ALC_INIT_DEFAULT;
bc9f98a9
KY
559 break;
560 }
ea1fb29a 561
8c427226 562 /* is laptop or Desktop and enable the function "Mute internal speaker
c9b58006
KY
563 * when the external headphone out jack is plugged"
564 */
8c427226 565 if (!(ass & 0x8000))
4a79ba34 566 return 1;
c9b58006
KY
567 /*
568 * 10~8 : Jack location
569 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
570 * 14~13: Resvered
571 * 15 : 1 --> enable the function "Mute internal speaker
572 * when the external headphone out jack is plugged"
573 */
08c189f2
TI
574 if (!spec->gen.autocfg.hp_pins[0] &&
575 !(spec->gen.autocfg.line_out_pins[0] &&
576 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
01d4825d 577 hda_nid_t nid;
c9b58006 578 tmp = (ass >> 11) & 0x3; /* HP to chassis */
58c57cfa 579 nid = ports[tmp];
08c189f2
TI
580 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
581 spec->gen.autocfg.line_outs))
3af9ee6b 582 return 1;
08c189f2 583 spec->gen.autocfg.hp_pins[0] = nid;
c9b58006 584 }
4a79ba34
TI
585 return 1;
586}
ea1fb29a 587
3e6179b8
TI
588/* Check the validity of ALC subsystem-id
589 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
590static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
4a79ba34 591{
58c57cfa 592 if (!alc_subsystem_id(codec, ports)) {
4a79ba34 593 struct alc_spec *spec = codec->spec;
4e76a883
TI
594 codec_dbg(codec,
595 "realtek: Enable default setup for auto mode as fallback\n");
4a79ba34 596 spec->init_amp = ALC_INIT_DEFAULT;
4a79ba34 597 }
21268961 598}
1a1455de 599
1d045db9 600/*
ef8ef5fb 601 */
f9e336f6 602
08c189f2 603static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
f9e336f6 604{
08c189f2
TI
605 struct hda_gen_spec *spec = codec->spec;
606 if (spec->dyn_adc_switch)
607 adc_idx = spec->dyn_adc_idx[imux_idx];
608 return spec->adc_nids[adc_idx];
f9e336f6
TI
609}
610
666a70d4 611static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
f9e336f6 612{
f9e336f6 613 struct alc_spec *spec = codec->spec;
08c189f2 614 struct hda_input_mux *imux = &spec->gen.input_mux;
666a70d4
TI
615 struct nid_path *path;
616 hda_nid_t nid;
617 int i, dir, parm;
618 unsigned int val;
f9e336f6 619
666a70d4 620 for (i = 0; i < imux->num_items; i++) {
08c189f2 621 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
666a70d4 622 break;
a23b688f 623 }
666a70d4
TI
624 if (i >= imux->num_items)
625 return;
a23b688f 626
08c189f2
TI
627 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
628 get_adc_nid(codec, adc_idx, i));
666a70d4
TI
629 val = path->ctls[NID_PATH_MUTE_CTL];
630 if (!val)
631 return;
632 nid = get_amp_nid_(val);
633 dir = get_amp_direction_(val);
634 parm = AC_AMP_SET_RIGHT |
635 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
a23b688f 636
c4f3ebed 637 /* flush all cached amps at first */
dc870f38 638 snd_hda_codec_flush_cache(codec);
a23b688f 639
666a70d4
TI
640 /* we care only right channel */
641 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
642 if (val & 0x80) /* if already muted, we don't need to touch */
643 return;
644 val |= 0x80;
645 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
646 parm | val);
f9e336f6
TI
647}
648
125821ae
TI
649/*
650 * Inverted digital-mic handling
651 *
652 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
653 * gives the additional mute only to the right channel of the digital mic
654 * capture stream. This is a workaround for avoiding the almost silence
655 * by summing the stereo stream from some (known to be ForteMedia)
656 * digital mic unit.
657 *
658 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
659 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
660 * without caching so that the cache can still keep the original value.
661 * The cached value is then restored when the flag is set off or any other
662 * than d-mic is used as the current input source.
663 */
664static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
665{
666 struct alc_spec *spec = codec->spec;
666a70d4 667 int src, nums;
125821ae
TI
668
669 if (!spec->inv_dmic_fixup)
670 return;
671 if (!spec->inv_dmic_muted && !force)
672 return;
08c189f2 673 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
666a70d4 674 for (src = 0; src < nums; src++) {
125821ae 675 bool dmic_fixup = false;
125821ae
TI
676
677 if (spec->inv_dmic_muted &&
08c189f2 678 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
125821ae
TI
679 dmic_fixup = true;
680 if (!dmic_fixup && !force)
681 continue;
666a70d4 682 alc_inv_dmic_sync_adc(codec, src);
125821ae
TI
683 }
684}
685
a90229e0 686static void alc_inv_dmic_hook(struct hda_codec *codec,
7fe30711
TI
687 struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
08c189f2
TI
689{
690 alc_inv_dmic_sync(codec, false);
691}
692
125821ae
TI
693static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
695{
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 struct alc_spec *spec = codec->spec;
698
699 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
700 return 0;
701}
702
703static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value *ucontrol)
705{
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 struct alc_spec *spec = codec->spec;
708 unsigned int val = !ucontrol->value.integer.value[0];
709
710 if (val == spec->inv_dmic_muted)
711 return 0;
712 spec->inv_dmic_muted = val;
713 alc_inv_dmic_sync(codec, true);
714 return 0;
715}
716
717static const struct snd_kcontrol_new alc_inv_dmic_sw = {
718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
bc549767 719 .name = "Inverted Internal Mic Capture Switch",
125821ae
TI
720 .info = snd_ctl_boolean_mono_info,
721 .get = alc_inv_dmic_sw_get,
722 .put = alc_inv_dmic_sw_put,
723};
724
725static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
726{
727 struct alc_spec *spec = codec->spec;
668d1e96 728
08c189f2 729 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
125821ae
TI
730 return -ENOMEM;
731 spec->inv_dmic_fixup = 1;
732 spec->inv_dmic_muted = 0;
733 spec->inv_dmic_pin = nid;
08c189f2 734 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
125821ae
TI
735 return 0;
736}
737
6e72aa5f
TI
738/* typically the digital mic is put at node 0x12 */
739static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
1727a771 740 const struct hda_fixup *fix, int action)
6e72aa5f 741{
1727a771 742 if (action == HDA_FIXUP_ACT_PROBE)
6e72aa5f
TI
743 alc_add_inv_dmic_mixer(codec, 0x12);
744}
745
e9edcee0 746
1d045db9
TI
747#ifdef CONFIG_SND_HDA_INPUT_BEEP
748/* additional beep mixers; the actual parameters are overwritten at build */
749static const struct snd_kcontrol_new alc_beep_mixer[] = {
750 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
751 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
16ded525
TI
752 { } /* end */
753};
1d045db9 754#endif
16ded525 755
08c189f2 756static int alc_build_controls(struct hda_codec *codec)
1d045db9
TI
757{
758 struct alc_spec *spec = codec->spec;
08c189f2 759 int i, err;
e9427969 760
08c189f2
TI
761 err = snd_hda_gen_build_controls(codec);
762 if (err < 0)
763 return err;
1da177e4
LT
764
765 for (i = 0; i < spec->num_mixers; i++) {
766 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
767 if (err < 0)
768 return err;
769 }
2134ea4f 770
67d634c0 771#ifdef CONFIG_SND_HDA_INPUT_BEEP
45bdd1c1
TI
772 /* create beep controls if needed */
773 if (spec->beep_amp) {
a9111321 774 const struct snd_kcontrol_new *knew;
45bdd1c1
TI
775 for (knew = alc_beep_mixer; knew->name; knew++) {
776 struct snd_kcontrol *kctl;
777 kctl = snd_ctl_new1(knew, codec);
778 if (!kctl)
08c189f2
TI
779 return -ENOMEM;
780 kctl->private_value = spec->beep_amp;
781 err = snd_hda_ctl_add(codec, 0, kctl);
782 if (err < 0)
783 return err;
1d045db9 784 }
863b4518 785 }
08c189f2 786#endif
1c4a54b4 787
1727a771 788 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
1c4a54b4 789 return 0;
a361d84b
KY
790}
791
a361d84b 792
df694daa 793/*
08c189f2 794 * Common callbacks
df694daa 795 */
a361d84b 796
08c189f2 797static int alc_init(struct hda_codec *codec)
1d045db9
TI
798{
799 struct alc_spec *spec = codec->spec;
a361d84b 800
08c189f2
TI
801 if (spec->init_hook)
802 spec->init_hook(codec);
a361d84b 803
08c189f2
TI
804 alc_fix_pll(codec);
805 alc_auto_init_amp(codec, spec->init_amp);
3abf2f36 806
08c189f2 807 snd_hda_gen_init(codec);
a361d84b 808
1727a771 809 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
a361d84b 810
1d045db9
TI
811 return 0;
812}
a361d84b 813
08c189f2 814static inline void alc_shutup(struct hda_codec *codec)
1d045db9
TI
815{
816 struct alc_spec *spec = codec->spec;
a361d84b 817
08c189f2
TI
818 if (spec && spec->shutup)
819 spec->shutup(codec);
9bfb2844
TI
820 else
821 snd_hda_shutup_pins(codec);
1d045db9
TI
822}
823
8a02c0cc 824#define alc_free snd_hda_gen_free
2134ea4f 825
08c189f2
TI
826#ifdef CONFIG_PM
827static void alc_power_eapd(struct hda_codec *codec)
1d045db9 828{
08c189f2 829 alc_auto_setup_eapd(codec, false);
1d045db9 830}
2134ea4f 831
08c189f2 832static int alc_suspend(struct hda_codec *codec)
1d045db9
TI
833{
834 struct alc_spec *spec = codec->spec;
08c189f2
TI
835 alc_shutup(codec);
836 if (spec && spec->power_hook)
837 spec->power_hook(codec);
a361d84b
KY
838 return 0;
839}
08c189f2 840#endif
a361d84b 841
08c189f2
TI
842#ifdef CONFIG_PM
843static int alc_resume(struct hda_codec *codec)
1d045db9 844{
97a26570
KY
845 struct alc_spec *spec = codec->spec;
846
847 if (!spec->no_depop_delay)
848 msleep(150); /* to avoid pop noise */
08c189f2
TI
849 codec->patch_ops.init(codec);
850 snd_hda_codec_resume_amp(codec);
851 snd_hda_codec_resume_cache(codec);
852 alc_inv_dmic_sync(codec, true);
853 hda_call_check_power_status(codec, 0x01);
854 return 0;
1d045db9 855}
08c189f2 856#endif
f6a92248 857
1d045db9 858/*
1d045db9 859 */
08c189f2
TI
860static const struct hda_codec_ops alc_patch_ops = {
861 .build_controls = alc_build_controls,
862 .build_pcms = snd_hda_gen_build_pcms,
863 .init = alc_init,
864 .free = alc_free,
865 .unsol_event = snd_hda_jack_unsol_event,
866#ifdef CONFIG_PM
867 .resume = alc_resume,
08c189f2 868 .suspend = alc_suspend,
fce52a3b 869 .check_power_status = snd_hda_gen_check_power_status,
08c189f2
TI
870#endif
871 .reboot_notify = alc_shutup,
872};
f6a92248 873
f53281e6 874
08c189f2
TI
875/* replace the codec chip_name with the given string */
876static int alc_codec_rename(struct hda_codec *codec, const char *name)
1d045db9 877{
08c189f2
TI
878 kfree(codec->chip_name);
879 codec->chip_name = kstrdup(name, GFP_KERNEL);
880 if (!codec->chip_name) {
881 alc_free(codec);
882 return -ENOMEM;
1d045db9 883 }
a361d84b 884 return 0;
1d045db9 885}
e01bf509 886
e4770629 887/*
4b016931 888 * Rename codecs appropriately from COEF value or subvendor id
e4770629 889 */
08c189f2
TI
890struct alc_codec_rename_table {
891 unsigned int vendor_id;
892 unsigned short coef_mask;
893 unsigned short coef_bits;
894 const char *name;
895};
84898e87 896
4b016931
KY
897struct alc_codec_rename_pci_table {
898 unsigned int codec_vendor_id;
899 unsigned short pci_subvendor;
900 unsigned short pci_subdevice;
901 const char *name;
902};
903
08c189f2 904static struct alc_codec_rename_table rename_tbl[] = {
e6e5f7ad 905 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
08c189f2
TI
906 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
907 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
908 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
909 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
910 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
911 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
912 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
913 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
e6e5f7ad 914 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
08c189f2
TI
915 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
916 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
917 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
918 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
919 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
920 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
921 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
922 { } /* terminator */
923};
84898e87 924
4b016931
KY
925static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
926 { 0x10ec0280, 0x1028, 0, "ALC3220" },
927 { 0x10ec0282, 0x1028, 0, "ALC3221" },
928 { 0x10ec0283, 0x1028, 0, "ALC3223" },
193177de 929 { 0x10ec0288, 0x1028, 0, "ALC3263" },
4b016931 930 { 0x10ec0292, 0x1028, 0, "ALC3226" },
193177de 931 { 0x10ec0293, 0x1028, 0, "ALC3235" },
4b016931
KY
932 { 0x10ec0255, 0x1028, 0, "ALC3234" },
933 { 0x10ec0668, 0x1028, 0, "ALC3661" },
e6e5f7ad
KY
934 { 0x10ec0275, 0x1028, 0, "ALC3260" },
935 { 0x10ec0899, 0x1028, 0, "ALC3861" },
936 { 0x10ec0670, 0x1025, 0, "ALC669X" },
937 { 0x10ec0676, 0x1025, 0, "ALC679X" },
938 { 0x10ec0282, 0x1043, 0, "ALC3229" },
939 { 0x10ec0233, 0x1043, 0, "ALC3236" },
940 { 0x10ec0280, 0x103c, 0, "ALC3228" },
941 { 0x10ec0282, 0x103c, 0, "ALC3227" },
942 { 0x10ec0286, 0x103c, 0, "ALC3242" },
943 { 0x10ec0290, 0x103c, 0, "ALC3241" },
944 { 0x10ec0668, 0x103c, 0, "ALC3662" },
945 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
946 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
4b016931
KY
947 { } /* terminator */
948};
949
08c189f2 950static int alc_codec_rename_from_preset(struct hda_codec *codec)
1d045db9 951{
08c189f2 952 const struct alc_codec_rename_table *p;
4b016931 953 const struct alc_codec_rename_pci_table *q;
60db6b53 954
08c189f2
TI
955 for (p = rename_tbl; p->vendor_id; p++) {
956 if (p->vendor_id != codec->vendor_id)
957 continue;
958 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
959 return alc_codec_rename(codec, p->name);
1d045db9 960 }
4b016931 961
5100cd07
TI
962 if (!codec->bus->pci)
963 return 0;
4b016931
KY
964 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
965 if (q->codec_vendor_id != codec->vendor_id)
966 continue;
967 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
968 continue;
969 if (!q->pci_subdevice ||
970 q->pci_subdevice == codec->bus->pci->subsystem_device)
971 return alc_codec_rename(codec, q->name);
972 }
973
08c189f2 974 return 0;
1d045db9 975}
f53281e6 976
e4770629 977
1d045db9
TI
978/*
979 * Digital-beep handlers
980 */
981#ifdef CONFIG_SND_HDA_INPUT_BEEP
982#define set_beep_amp(spec, nid, idx, dir) \
983 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
84898e87 984
1d045db9 985static const struct snd_pci_quirk beep_white_list[] = {
7110005e 986 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
a4b7f21d 987 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1d045db9 988 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
8554ee40 989 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1d045db9
TI
990 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
991 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
992 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
78f8baf1 993 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1d045db9
TI
994 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
995 {}
fe3eb0a7
KY
996};
997
1d045db9
TI
998static inline int has_cdefine_beep(struct hda_codec *codec)
999{
1000 struct alc_spec *spec = codec->spec;
1001 const struct snd_pci_quirk *q;
1002 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1003 if (q)
1004 return q->value;
1005 return spec->cdefine.enable_pcbeep;
1006}
1007#else
1008#define set_beep_amp(spec, nid, idx, dir) /* NOP */
1009#define has_cdefine_beep(codec) 0
1010#endif
84898e87 1011
1d045db9
TI
1012/* parse the BIOS configuration and set up the alc_spec */
1013/* return 1 if successful, 0 if the proper config is not found,
1014 * or a negative error code
1015 */
3e6179b8
TI
1016static int alc_parse_auto_config(struct hda_codec *codec,
1017 const hda_nid_t *ignore_nids,
1018 const hda_nid_t *ssid_nids)
1d045db9
TI
1019{
1020 struct alc_spec *spec = codec->spec;
08c189f2 1021 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1d045db9 1022 int err;
26f5df26 1023
53c334ad
TI
1024 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1025 spec->parse_flags);
1d045db9
TI
1026 if (err < 0)
1027 return err;
3e6179b8
TI
1028
1029 if (ssid_nids)
1030 alc_ssid_check(codec, ssid_nids);
64154835 1031
08c189f2
TI
1032 err = snd_hda_gen_parse_auto_config(codec, cfg);
1033 if (err < 0)
1034 return err;
070cff4c 1035
1d045db9 1036 return 1;
60db6b53 1037}
f6a92248 1038
3de95173
TI
1039/* common preparation job for alc_spec */
1040static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1041{
1042 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1043 int err;
1044
1045 if (!spec)
1046 return -ENOMEM;
1047 codec->spec = spec;
08c189f2
TI
1048 snd_hda_gen_spec_init(&spec->gen);
1049 spec->gen.mixer_nid = mixer_nid;
1050 spec->gen.own_eapd_ctl = 1;
1098b7c2 1051 codec->single_adc_amp = 1;
08c189f2
TI
1052 /* FIXME: do we need this for all Realtek codec models? */
1053 codec->spdif_status_reset = 1;
3de95173
TI
1054
1055 err = alc_codec_rename_from_preset(codec);
1056 if (err < 0) {
1057 kfree(spec);
1058 return err;
1059 }
1060 return 0;
1061}
1062
3e6179b8
TI
1063static int alc880_parse_auto_config(struct hda_codec *codec)
1064{
1065 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
7d7eb9ea 1066 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3e6179b8
TI
1067 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1068}
1069
ee3b2969
TI
1070/*
1071 * ALC880 fix-ups
1072 */
1073enum {
411225a0 1074 ALC880_FIXUP_GPIO1,
ee3b2969
TI
1075 ALC880_FIXUP_GPIO2,
1076 ALC880_FIXUP_MEDION_RIM,
dc6af52d 1077 ALC880_FIXUP_LG,
db8a38e5 1078 ALC880_FIXUP_LG_LW25,
f02aab5d 1079 ALC880_FIXUP_W810,
27e917f8 1080 ALC880_FIXUP_EAPD_COEF,
b9368f5c 1081 ALC880_FIXUP_TCL_S700,
cf5a2279
TI
1082 ALC880_FIXUP_VOL_KNOB,
1083 ALC880_FIXUP_FUJITSU,
ba533818 1084 ALC880_FIXUP_F1734,
817de92f 1085 ALC880_FIXUP_UNIWILL,
967b88c4 1086 ALC880_FIXUP_UNIWILL_DIG,
96e225f6 1087 ALC880_FIXUP_Z71V,
487a588d 1088 ALC880_FIXUP_ASUS_W5A,
67b6ec31
TI
1089 ALC880_FIXUP_3ST_BASE,
1090 ALC880_FIXUP_3ST,
1091 ALC880_FIXUP_3ST_DIG,
1092 ALC880_FIXUP_5ST_BASE,
1093 ALC880_FIXUP_5ST,
1094 ALC880_FIXUP_5ST_DIG,
1095 ALC880_FIXUP_6ST_BASE,
1096 ALC880_FIXUP_6ST,
1097 ALC880_FIXUP_6ST_DIG,
5397145f 1098 ALC880_FIXUP_6ST_AUTOMUTE,
ee3b2969
TI
1099};
1100
cf5a2279
TI
1101/* enable the volume-knob widget support on NID 0x21 */
1102static void alc880_fixup_vol_knob(struct hda_codec *codec,
1727a771 1103 const struct hda_fixup *fix, int action)
cf5a2279 1104{
1727a771 1105 if (action == HDA_FIXUP_ACT_PROBE)
29adc4b9 1106 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
cf5a2279
TI
1107}
1108
1727a771 1109static const struct hda_fixup alc880_fixups[] = {
411225a0 1110 [ALC880_FIXUP_GPIO1] = {
1727a771 1111 .type = HDA_FIXUP_VERBS,
411225a0
TI
1112 .v.verbs = alc_gpio1_init_verbs,
1113 },
ee3b2969 1114 [ALC880_FIXUP_GPIO2] = {
1727a771 1115 .type = HDA_FIXUP_VERBS,
ee3b2969
TI
1116 .v.verbs = alc_gpio2_init_verbs,
1117 },
1118 [ALC880_FIXUP_MEDION_RIM] = {
1727a771 1119 .type = HDA_FIXUP_VERBS,
ee3b2969
TI
1120 .v.verbs = (const struct hda_verb[]) {
1121 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1122 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1123 { }
1124 },
1125 .chained = true,
1126 .chain_id = ALC880_FIXUP_GPIO2,
1127 },
dc6af52d 1128 [ALC880_FIXUP_LG] = {
1727a771
TI
1129 .type = HDA_FIXUP_PINS,
1130 .v.pins = (const struct hda_pintbl[]) {
dc6af52d
TI
1131 /* disable bogus unused pins */
1132 { 0x16, 0x411111f0 },
1133 { 0x18, 0x411111f0 },
1134 { 0x1a, 0x411111f0 },
1135 { }
1136 }
1137 },
db8a38e5
TI
1138 [ALC880_FIXUP_LG_LW25] = {
1139 .type = HDA_FIXUP_PINS,
1140 .v.pins = (const struct hda_pintbl[]) {
1141 { 0x1a, 0x0181344f }, /* line-in */
1142 { 0x1b, 0x0321403f }, /* headphone */
1143 { }
1144 }
1145 },
f02aab5d 1146 [ALC880_FIXUP_W810] = {
1727a771
TI
1147 .type = HDA_FIXUP_PINS,
1148 .v.pins = (const struct hda_pintbl[]) {
f02aab5d
TI
1149 /* disable bogus unused pins */
1150 { 0x17, 0x411111f0 },
1151 { }
1152 },
1153 .chained = true,
1154 .chain_id = ALC880_FIXUP_GPIO2,
1155 },
27e917f8 1156 [ALC880_FIXUP_EAPD_COEF] = {
1727a771 1157 .type = HDA_FIXUP_VERBS,
27e917f8
TI
1158 .v.verbs = (const struct hda_verb[]) {
1159 /* change to EAPD mode */
1160 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1161 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1162 {}
1163 },
1164 },
b9368f5c 1165 [ALC880_FIXUP_TCL_S700] = {
1727a771 1166 .type = HDA_FIXUP_VERBS,
b9368f5c
TI
1167 .v.verbs = (const struct hda_verb[]) {
1168 /* change to EAPD mode */
1169 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1170 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1171 {}
1172 },
1173 .chained = true,
1174 .chain_id = ALC880_FIXUP_GPIO2,
1175 },
cf5a2279 1176 [ALC880_FIXUP_VOL_KNOB] = {
1727a771 1177 .type = HDA_FIXUP_FUNC,
cf5a2279
TI
1178 .v.func = alc880_fixup_vol_knob,
1179 },
1180 [ALC880_FIXUP_FUJITSU] = {
1181 /* override all pins as BIOS on old Amilo is broken */
1727a771
TI
1182 .type = HDA_FIXUP_PINS,
1183 .v.pins = (const struct hda_pintbl[]) {
cf5a2279
TI
1184 { 0x14, 0x0121411f }, /* HP */
1185 { 0x15, 0x99030120 }, /* speaker */
1186 { 0x16, 0x99030130 }, /* bass speaker */
1187 { 0x17, 0x411111f0 }, /* N/A */
1188 { 0x18, 0x411111f0 }, /* N/A */
1189 { 0x19, 0x01a19950 }, /* mic-in */
1190 { 0x1a, 0x411111f0 }, /* N/A */
1191 { 0x1b, 0x411111f0 }, /* N/A */
1192 { 0x1c, 0x411111f0 }, /* N/A */
1193 { 0x1d, 0x411111f0 }, /* N/A */
1194 { 0x1e, 0x01454140 }, /* SPDIF out */
1195 { }
1196 },
1197 .chained = true,
1198 .chain_id = ALC880_FIXUP_VOL_KNOB,
1199 },
ba533818
TI
1200 [ALC880_FIXUP_F1734] = {
1201 /* almost compatible with FUJITSU, but no bass and SPDIF */
1727a771
TI
1202 .type = HDA_FIXUP_PINS,
1203 .v.pins = (const struct hda_pintbl[]) {
ba533818
TI
1204 { 0x14, 0x0121411f }, /* HP */
1205 { 0x15, 0x99030120 }, /* speaker */
1206 { 0x16, 0x411111f0 }, /* N/A */
1207 { 0x17, 0x411111f0 }, /* N/A */
1208 { 0x18, 0x411111f0 }, /* N/A */
1209 { 0x19, 0x01a19950 }, /* mic-in */
1210 { 0x1a, 0x411111f0 }, /* N/A */
1211 { 0x1b, 0x411111f0 }, /* N/A */
1212 { 0x1c, 0x411111f0 }, /* N/A */
1213 { 0x1d, 0x411111f0 }, /* N/A */
1214 { 0x1e, 0x411111f0 }, /* N/A */
1215 { }
1216 },
1217 .chained = true,
1218 .chain_id = ALC880_FIXUP_VOL_KNOB,
1219 },
817de92f
TI
1220 [ALC880_FIXUP_UNIWILL] = {
1221 /* need to fix HP and speaker pins to be parsed correctly */
1727a771
TI
1222 .type = HDA_FIXUP_PINS,
1223 .v.pins = (const struct hda_pintbl[]) {
817de92f
TI
1224 { 0x14, 0x0121411f }, /* HP */
1225 { 0x15, 0x99030120 }, /* speaker */
1226 { 0x16, 0x99030130 }, /* bass speaker */
1227 { }
1228 },
1229 },
967b88c4 1230 [ALC880_FIXUP_UNIWILL_DIG] = {
1727a771
TI
1231 .type = HDA_FIXUP_PINS,
1232 .v.pins = (const struct hda_pintbl[]) {
967b88c4
TI
1233 /* disable bogus unused pins */
1234 { 0x17, 0x411111f0 },
1235 { 0x19, 0x411111f0 },
1236 { 0x1b, 0x411111f0 },
1237 { 0x1f, 0x411111f0 },
1238 { }
1239 }
1240 },
96e225f6 1241 [ALC880_FIXUP_Z71V] = {
1727a771
TI
1242 .type = HDA_FIXUP_PINS,
1243 .v.pins = (const struct hda_pintbl[]) {
96e225f6
TI
1244 /* set up the whole pins as BIOS is utterly broken */
1245 { 0x14, 0x99030120 }, /* speaker */
1246 { 0x15, 0x0121411f }, /* HP */
1247 { 0x16, 0x411111f0 }, /* N/A */
1248 { 0x17, 0x411111f0 }, /* N/A */
1249 { 0x18, 0x01a19950 }, /* mic-in */
1250 { 0x19, 0x411111f0 }, /* N/A */
1251 { 0x1a, 0x01813031 }, /* line-in */
1252 { 0x1b, 0x411111f0 }, /* N/A */
1253 { 0x1c, 0x411111f0 }, /* N/A */
1254 { 0x1d, 0x411111f0 }, /* N/A */
1255 { 0x1e, 0x0144111e }, /* SPDIF */
1256 { }
1257 }
1258 },
487a588d
TI
1259 [ALC880_FIXUP_ASUS_W5A] = {
1260 .type = HDA_FIXUP_PINS,
1261 .v.pins = (const struct hda_pintbl[]) {
1262 /* set up the whole pins as BIOS is utterly broken */
1263 { 0x14, 0x0121411f }, /* HP */
1264 { 0x15, 0x411111f0 }, /* N/A */
1265 { 0x16, 0x411111f0 }, /* N/A */
1266 { 0x17, 0x411111f0 }, /* N/A */
1267 { 0x18, 0x90a60160 }, /* mic */
1268 { 0x19, 0x411111f0 }, /* N/A */
1269 { 0x1a, 0x411111f0 }, /* N/A */
1270 { 0x1b, 0x411111f0 }, /* N/A */
1271 { 0x1c, 0x411111f0 }, /* N/A */
1272 { 0x1d, 0x411111f0 }, /* N/A */
1273 { 0x1e, 0xb743111e }, /* SPDIF out */
1274 { }
1275 },
1276 .chained = true,
1277 .chain_id = ALC880_FIXUP_GPIO1,
1278 },
67b6ec31 1279 [ALC880_FIXUP_3ST_BASE] = {
1727a771
TI
1280 .type = HDA_FIXUP_PINS,
1281 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1282 { 0x14, 0x01014010 }, /* line-out */
1283 { 0x15, 0x411111f0 }, /* N/A */
1284 { 0x16, 0x411111f0 }, /* N/A */
1285 { 0x17, 0x411111f0 }, /* N/A */
1286 { 0x18, 0x01a19c30 }, /* mic-in */
1287 { 0x19, 0x0121411f }, /* HP */
1288 { 0x1a, 0x01813031 }, /* line-in */
1289 { 0x1b, 0x02a19c40 }, /* front-mic */
1290 { 0x1c, 0x411111f0 }, /* N/A */
1291 { 0x1d, 0x411111f0 }, /* N/A */
1292 /* 0x1e is filled in below */
1293 { 0x1f, 0x411111f0 }, /* N/A */
1294 { }
1295 }
1296 },
1297 [ALC880_FIXUP_3ST] = {
1727a771
TI
1298 .type = HDA_FIXUP_PINS,
1299 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1300 { 0x1e, 0x411111f0 }, /* N/A */
1301 { }
1302 },
1303 .chained = true,
1304 .chain_id = ALC880_FIXUP_3ST_BASE,
1305 },
1306 [ALC880_FIXUP_3ST_DIG] = {
1727a771
TI
1307 .type = HDA_FIXUP_PINS,
1308 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1309 { 0x1e, 0x0144111e }, /* SPDIF */
1310 { }
1311 },
1312 .chained = true,
1313 .chain_id = ALC880_FIXUP_3ST_BASE,
1314 },
1315 [ALC880_FIXUP_5ST_BASE] = {
1727a771
TI
1316 .type = HDA_FIXUP_PINS,
1317 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1318 { 0x14, 0x01014010 }, /* front */
1319 { 0x15, 0x411111f0 }, /* N/A */
1320 { 0x16, 0x01011411 }, /* CLFE */
1321 { 0x17, 0x01016412 }, /* surr */
1322 { 0x18, 0x01a19c30 }, /* mic-in */
1323 { 0x19, 0x0121411f }, /* HP */
1324 { 0x1a, 0x01813031 }, /* line-in */
1325 { 0x1b, 0x02a19c40 }, /* front-mic */
1326 { 0x1c, 0x411111f0 }, /* N/A */
1327 { 0x1d, 0x411111f0 }, /* N/A */
1328 /* 0x1e is filled in below */
1329 { 0x1f, 0x411111f0 }, /* N/A */
1330 { }
1331 }
1332 },
1333 [ALC880_FIXUP_5ST] = {
1727a771
TI
1334 .type = HDA_FIXUP_PINS,
1335 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1336 { 0x1e, 0x411111f0 }, /* N/A */
1337 { }
1338 },
1339 .chained = true,
1340 .chain_id = ALC880_FIXUP_5ST_BASE,
1341 },
1342 [ALC880_FIXUP_5ST_DIG] = {
1727a771
TI
1343 .type = HDA_FIXUP_PINS,
1344 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1345 { 0x1e, 0x0144111e }, /* SPDIF */
1346 { }
1347 },
1348 .chained = true,
1349 .chain_id = ALC880_FIXUP_5ST_BASE,
1350 },
1351 [ALC880_FIXUP_6ST_BASE] = {
1727a771
TI
1352 .type = HDA_FIXUP_PINS,
1353 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1354 { 0x14, 0x01014010 }, /* front */
1355 { 0x15, 0x01016412 }, /* surr */
1356 { 0x16, 0x01011411 }, /* CLFE */
1357 { 0x17, 0x01012414 }, /* side */
1358 { 0x18, 0x01a19c30 }, /* mic-in */
1359 { 0x19, 0x02a19c40 }, /* front-mic */
1360 { 0x1a, 0x01813031 }, /* line-in */
1361 { 0x1b, 0x0121411f }, /* HP */
1362 { 0x1c, 0x411111f0 }, /* N/A */
1363 { 0x1d, 0x411111f0 }, /* N/A */
1364 /* 0x1e is filled in below */
1365 { 0x1f, 0x411111f0 }, /* N/A */
1366 { }
1367 }
1368 },
1369 [ALC880_FIXUP_6ST] = {
1727a771
TI
1370 .type = HDA_FIXUP_PINS,
1371 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1372 { 0x1e, 0x411111f0 }, /* N/A */
1373 { }
1374 },
1375 .chained = true,
1376 .chain_id = ALC880_FIXUP_6ST_BASE,
1377 },
1378 [ALC880_FIXUP_6ST_DIG] = {
1727a771
TI
1379 .type = HDA_FIXUP_PINS,
1380 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1381 { 0x1e, 0x0144111e }, /* SPDIF */
1382 { }
1383 },
1384 .chained = true,
1385 .chain_id = ALC880_FIXUP_6ST_BASE,
1386 },
5397145f
TI
1387 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1388 .type = HDA_FIXUP_PINS,
1389 .v.pins = (const struct hda_pintbl[]) {
1390 { 0x1b, 0x0121401f }, /* HP with jack detect */
1391 { }
1392 },
1393 .chained_before = true,
1394 .chain_id = ALC880_FIXUP_6ST_BASE,
1395 },
ee3b2969
TI
1396};
1397
1398static const struct snd_pci_quirk alc880_fixup_tbl[] = {
f02aab5d 1399 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
487a588d 1400 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
96e225f6 1401 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
29e3fdcc 1402 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
6538de03 1403 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
29e3fdcc 1404 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
27e917f8 1405 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
967b88c4 1406 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
ba533818 1407 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
817de92f 1408 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
7833c7e8 1409 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
f02aab5d 1410 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
ee3b2969 1411 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
5397145f 1412 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
ba533818 1413 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
cf5a2279 1414 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
ba533818 1415 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
cf5a2279 1416 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
dc6af52d
TI
1417 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1418 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1419 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
db8a38e5 1420 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
b9368f5c 1421 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
67b6ec31
TI
1422
1423 /* Below is the copied entries from alc880_quirks.c.
1424 * It's not quite sure whether BIOS sets the correct pin-config table
1425 * on these machines, thus they are kept to be compatible with
1426 * the old static quirks. Once when it's confirmed to work without
1427 * these overrides, it'd be better to remove.
1428 */
1429 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1430 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1431 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1432 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1433 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1434 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1435 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1436 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1437 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1438 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1439 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1440 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1441 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1442 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1443 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1444 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1445 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1446 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1447 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1448 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1449 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1450 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1451 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1452 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1453 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1454 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1455 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1456 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1457 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1458 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1459 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1460 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1461 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1462 /* default Intel */
1463 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1464 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1465 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1466 {}
1467};
1468
1727a771 1469static const struct hda_model_fixup alc880_fixup_models[] = {
67b6ec31
TI
1470 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1471 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1472 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1473 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1474 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1475 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
5397145f 1476 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
ee3b2969
TI
1477 {}
1478};
1479
1480
1d045db9
TI
1481/*
1482 * OK, here we have finally the patch for ALC880
1483 */
1d045db9 1484static int patch_alc880(struct hda_codec *codec)
60db6b53 1485{
1d045db9 1486 struct alc_spec *spec;
1d045db9 1487 int err;
f6a92248 1488
3de95173
TI
1489 err = alc_alloc_spec(codec, 0x0b);
1490 if (err < 0)
1491 return err;
64154835 1492
3de95173 1493 spec = codec->spec;
08c189f2 1494 spec->gen.need_dac_fix = 1;
7504b6cd 1495 spec->gen.beep_nid = 0x01;
f53281e6 1496
1727a771 1497 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
67b6ec31 1498 alc880_fixups);
1727a771 1499 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ee3b2969 1500
67b6ec31
TI
1501 /* automatic parse from the BIOS config */
1502 err = alc880_parse_auto_config(codec);
1503 if (err < 0)
1504 goto error;
fe3eb0a7 1505
7504b6cd 1506 if (!spec->gen.no_analog)
3e6179b8 1507 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f53281e6 1508
1d045db9 1509 codec->patch_ops = alc_patch_ops;
29adc4b9
DH
1510 codec->patch_ops.unsol_event = alc880_unsol_event;
1511
f53281e6 1512
1727a771 1513 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 1514
1d045db9 1515 return 0;
e16fb6d1
TI
1516
1517 error:
1518 alc_free(codec);
1519 return err;
226b1ec8
KY
1520}
1521
1d045db9 1522
60db6b53 1523/*
1d045db9 1524 * ALC260 support
60db6b53 1525 */
1d045db9 1526static int alc260_parse_auto_config(struct hda_codec *codec)
f6a92248 1527{
1d045db9 1528 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
3e6179b8
TI
1529 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1530 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
f6a92248
KY
1531}
1532
1d045db9
TI
1533/*
1534 * Pin config fixes
1535 */
1536enum {
ca8f0424
TI
1537 ALC260_FIXUP_HP_DC5750,
1538 ALC260_FIXUP_HP_PIN_0F,
1539 ALC260_FIXUP_COEF,
15317ab2 1540 ALC260_FIXUP_GPIO1,
20f7d928
TI
1541 ALC260_FIXUP_GPIO1_TOGGLE,
1542 ALC260_FIXUP_REPLACER,
0a1c4fa2 1543 ALC260_FIXUP_HP_B1900,
118cb4a4 1544 ALC260_FIXUP_KN1,
39aedee7 1545 ALC260_FIXUP_FSC_S7020,
5ebd3bbd 1546 ALC260_FIXUP_FSC_S7020_JWSE,
d08c5ef2 1547 ALC260_FIXUP_VAIO_PINS,
1d045db9
TI
1548};
1549
20f7d928
TI
1550static void alc260_gpio1_automute(struct hda_codec *codec)
1551{
1552 struct alc_spec *spec = codec->spec;
1553 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
08c189f2 1554 spec->gen.hp_jack_present);
20f7d928
TI
1555}
1556
1557static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1727a771 1558 const struct hda_fixup *fix, int action)
20f7d928
TI
1559{
1560 struct alc_spec *spec = codec->spec;
1727a771 1561 if (action == HDA_FIXUP_ACT_PROBE) {
20f7d928
TI
1562 /* although the machine has only one output pin, we need to
1563 * toggle GPIO1 according to the jack state
1564 */
08c189f2
TI
1565 spec->gen.automute_hook = alc260_gpio1_automute;
1566 spec->gen.detect_hp = 1;
1567 spec->gen.automute_speaker = 1;
1568 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1569 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
1570 snd_hda_gen_hp_automute);
c9ce6b26 1571 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
20f7d928
TI
1572 }
1573}
1574
118cb4a4 1575static void alc260_fixup_kn1(struct hda_codec *codec,
1727a771 1576 const struct hda_fixup *fix, int action)
118cb4a4
TI
1577{
1578 struct alc_spec *spec = codec->spec;
1727a771 1579 static const struct hda_pintbl pincfgs[] = {
118cb4a4
TI
1580 { 0x0f, 0x02214000 }, /* HP/speaker */
1581 { 0x12, 0x90a60160 }, /* int mic */
1582 { 0x13, 0x02a19000 }, /* ext mic */
1583 { 0x18, 0x01446000 }, /* SPDIF out */
1584 /* disable bogus I/O pins */
1585 { 0x10, 0x411111f0 },
1586 { 0x11, 0x411111f0 },
1587 { 0x14, 0x411111f0 },
1588 { 0x15, 0x411111f0 },
1589 { 0x16, 0x411111f0 },
1590 { 0x17, 0x411111f0 },
1591 { 0x19, 0x411111f0 },
1592 { }
1593 };
1594
1595 switch (action) {
1727a771
TI
1596 case HDA_FIXUP_ACT_PRE_PROBE:
1597 snd_hda_apply_pincfgs(codec, pincfgs);
118cb4a4 1598 break;
1727a771 1599 case HDA_FIXUP_ACT_PROBE:
118cb4a4
TI
1600 spec->init_amp = ALC_INIT_NONE;
1601 break;
1602 }
1603}
1604
39aedee7
TI
1605static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1606 const struct hda_fixup *fix, int action)
1607{
1608 struct alc_spec *spec = codec->spec;
5ebd3bbd
TI
1609 if (action == HDA_FIXUP_ACT_PROBE)
1610 spec->init_amp = ALC_INIT_NONE;
1611}
39aedee7 1612
5ebd3bbd
TI
1613static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1614 const struct hda_fixup *fix, int action)
1615{
1616 struct alc_spec *spec = codec->spec;
1617 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
f811c3cf 1618 spec->gen.add_jack_modes = 1;
5ebd3bbd 1619 spec->gen.hp_mic = 1;
e6e0ee50 1620 }
39aedee7
TI
1621}
1622
1727a771 1623static const struct hda_fixup alc260_fixups[] = {
ca8f0424 1624 [ALC260_FIXUP_HP_DC5750] = {
1727a771
TI
1625 .type = HDA_FIXUP_PINS,
1626 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1627 { 0x11, 0x90130110 }, /* speaker */
1628 { }
1629 }
1630 },
ca8f0424 1631 [ALC260_FIXUP_HP_PIN_0F] = {
1727a771
TI
1632 .type = HDA_FIXUP_PINS,
1633 .v.pins = (const struct hda_pintbl[]) {
ca8f0424
TI
1634 { 0x0f, 0x01214000 }, /* HP */
1635 { }
1636 }
1637 },
1638 [ALC260_FIXUP_COEF] = {
1727a771 1639 .type = HDA_FIXUP_VERBS,
ca8f0424 1640 .v.verbs = (const struct hda_verb[]) {
e30cf2d2
RM
1641 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1642 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
ca8f0424
TI
1643 { }
1644 },
ca8f0424 1645 },
15317ab2 1646 [ALC260_FIXUP_GPIO1] = {
1727a771 1647 .type = HDA_FIXUP_VERBS,
15317ab2
TI
1648 .v.verbs = alc_gpio1_init_verbs,
1649 },
20f7d928 1650 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1727a771 1651 .type = HDA_FIXUP_FUNC,
20f7d928
TI
1652 .v.func = alc260_fixup_gpio1_toggle,
1653 .chained = true,
1654 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1655 },
1656 [ALC260_FIXUP_REPLACER] = {
1727a771 1657 .type = HDA_FIXUP_VERBS,
20f7d928 1658 .v.verbs = (const struct hda_verb[]) {
192a98e2
TI
1659 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1660 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
20f7d928
TI
1661 { }
1662 },
1663 .chained = true,
1664 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1665 },
0a1c4fa2 1666 [ALC260_FIXUP_HP_B1900] = {
1727a771 1667 .type = HDA_FIXUP_FUNC,
0a1c4fa2
TI
1668 .v.func = alc260_fixup_gpio1_toggle,
1669 .chained = true,
1670 .chain_id = ALC260_FIXUP_COEF,
118cb4a4
TI
1671 },
1672 [ALC260_FIXUP_KN1] = {
1727a771 1673 .type = HDA_FIXUP_FUNC,
118cb4a4
TI
1674 .v.func = alc260_fixup_kn1,
1675 },
39aedee7
TI
1676 [ALC260_FIXUP_FSC_S7020] = {
1677 .type = HDA_FIXUP_FUNC,
1678 .v.func = alc260_fixup_fsc_s7020,
1679 },
5ebd3bbd
TI
1680 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1681 .type = HDA_FIXUP_FUNC,
1682 .v.func = alc260_fixup_fsc_s7020_jwse,
1683 .chained = true,
1684 .chain_id = ALC260_FIXUP_FSC_S7020,
1685 },
d08c5ef2
TI
1686 [ALC260_FIXUP_VAIO_PINS] = {
1687 .type = HDA_FIXUP_PINS,
1688 .v.pins = (const struct hda_pintbl[]) {
1689 /* Pin configs are missing completely on some VAIOs */
1690 { 0x0f, 0x01211020 },
1691 { 0x10, 0x0001003f },
1692 { 0x11, 0x411111f0 },
1693 { 0x12, 0x01a15930 },
1694 { 0x13, 0x411111f0 },
1695 { 0x14, 0x411111f0 },
1696 { 0x15, 0x411111f0 },
1697 { 0x16, 0x411111f0 },
1698 { 0x17, 0x411111f0 },
1699 { 0x18, 0x411111f0 },
1700 { 0x19, 0x411111f0 },
1701 { }
1702 }
1703 },
1d045db9
TI
1704};
1705
1706static const struct snd_pci_quirk alc260_fixup_tbl[] = {
15317ab2 1707 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
ca8f0424 1708 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
15317ab2 1709 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
ca8f0424 1710 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
0a1c4fa2 1711 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
d08c5ef2 1712 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
0f5a5b85 1713 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
39aedee7 1714 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
b1f58085 1715 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
118cb4a4 1716 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
20f7d928 1717 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
ca8f0424 1718 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1d045db9
TI
1719 {}
1720};
1721
5ebd3bbd
TI
1722static const struct hda_model_fixup alc260_fixup_models[] = {
1723 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1724 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1725 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1726 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1727 {}
1728};
1729
1d045db9
TI
1730/*
1731 */
1d045db9 1732static int patch_alc260(struct hda_codec *codec)
977ddd6b 1733{
1d045db9 1734 struct alc_spec *spec;
c3c2c9e7 1735 int err;
1d045db9 1736
3de95173
TI
1737 err = alc_alloc_spec(codec, 0x07);
1738 if (err < 0)
1739 return err;
1d045db9 1740
3de95173 1741 spec = codec->spec;
ea46c3c8
TI
1742 /* as quite a few machines require HP amp for speaker outputs,
1743 * it's easier to enable it unconditionally; even if it's unneeded,
1744 * it's almost harmless.
1745 */
1746 spec->gen.prefer_hp_amp = 1;
7504b6cd 1747 spec->gen.beep_nid = 0x01;
1d045db9 1748
5ebd3bbd
TI
1749 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1750 alc260_fixups);
1727a771 1751 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
977ddd6b 1752
c3c2c9e7
TI
1753 /* automatic parse from the BIOS config */
1754 err = alc260_parse_auto_config(codec);
1755 if (err < 0)
1756 goto error;
977ddd6b 1757
7504b6cd 1758 if (!spec->gen.no_analog)
3e6179b8 1759 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
977ddd6b 1760
1d045db9 1761 codec->patch_ops = alc_patch_ops;
1d045db9 1762 spec->shutup = alc_eapd_shutup;
6981d184 1763
1727a771 1764 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 1765
1d045db9 1766 return 0;
e16fb6d1
TI
1767
1768 error:
1769 alc_free(codec);
1770 return err;
6981d184
TI
1771}
1772
1d045db9
TI
1773
1774/*
1775 * ALC882/883/885/888/889 support
1776 *
1777 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1778 * configuration. Each pin widget can choose any input DACs and a mixer.
1779 * Each ADC is connected from a mixer of all inputs. This makes possible
1780 * 6-channel independent captures.
1781 *
1782 * In addition, an independent DAC for the multi-playback (not used in this
1783 * driver yet).
1784 */
1d045db9
TI
1785
1786/*
1787 * Pin config fixes
1788 */
ff818c24 1789enum {
5c0ebfbe
TI
1790 ALC882_FIXUP_ABIT_AW9D_MAX,
1791 ALC882_FIXUP_LENOVO_Y530,
1792 ALC882_FIXUP_PB_M5210,
1793 ALC882_FIXUP_ACER_ASPIRE_7736,
1794 ALC882_FIXUP_ASUS_W90V,
8f239214 1795 ALC889_FIXUP_CD,
b2c53e20 1796 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
5c0ebfbe 1797 ALC889_FIXUP_VAIO_TT,
0e7cc2e7 1798 ALC888_FIXUP_EEE1601,
177943a3 1799 ALC882_FIXUP_EAPD,
7a6069bf 1800 ALC883_FIXUP_EAPD,
8812c4f9 1801 ALC883_FIXUP_ACER_EAPD,
1a97b7f2
TI
1802 ALC882_FIXUP_GPIO1,
1803 ALC882_FIXUP_GPIO2,
eb844d51 1804 ALC882_FIXUP_GPIO3,
68ef0561
TI
1805 ALC889_FIXUP_COEF,
1806 ALC882_FIXUP_ASUS_W2JC,
c3e837bb
TI
1807 ALC882_FIXUP_ACER_ASPIRE_4930G,
1808 ALC882_FIXUP_ACER_ASPIRE_8930G,
1809 ALC882_FIXUP_ASPIRE_8930G_VERBS,
5671087f 1810 ALC885_FIXUP_MACPRO_GPIO,
02a237b2 1811 ALC889_FIXUP_DAC_ROUTE,
1a97b7f2
TI
1812 ALC889_FIXUP_MBP_VREF,
1813 ALC889_FIXUP_IMAC91_VREF,
e7729a41 1814 ALC889_FIXUP_MBA11_VREF,
0756f09c 1815 ALC889_FIXUP_MBA21_VREF,
c20f31ec 1816 ALC889_FIXUP_MP11_VREF,
6e72aa5f 1817 ALC882_FIXUP_INV_DMIC,
e427c237 1818 ALC882_FIXUP_NO_PRIMARY_HP,
1f0bbf03 1819 ALC887_FIXUP_ASUS_BASS,
eb9ca3ab 1820 ALC887_FIXUP_BASS_CHMAP,
ff818c24
TI
1821};
1822
68ef0561 1823static void alc889_fixup_coef(struct hda_codec *codec,
1727a771 1824 const struct hda_fixup *fix, int action)
68ef0561 1825{
1727a771 1826 if (action != HDA_FIXUP_ACT_INIT)
68ef0561
TI
1827 return;
1828 alc889_coef_init(codec);
1829}
1830
5671087f
TI
1831/* toggle speaker-output according to the hp-jack state */
1832static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1833{
1834 unsigned int gpiostate, gpiomask, gpiodir;
1835
1836 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1837 AC_VERB_GET_GPIO_DATA, 0);
1838
1839 if (!muted)
1840 gpiostate |= (1 << pin);
1841 else
1842 gpiostate &= ~(1 << pin);
1843
1844 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1845 AC_VERB_GET_GPIO_MASK, 0);
1846 gpiomask |= (1 << pin);
1847
1848 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1849 AC_VERB_GET_GPIO_DIRECTION, 0);
1850 gpiodir |= (1 << pin);
1851
1852
1853 snd_hda_codec_write(codec, codec->afg, 0,
1854 AC_VERB_SET_GPIO_MASK, gpiomask);
1855 snd_hda_codec_write(codec, codec->afg, 0,
1856 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1857
1858 msleep(1);
1859
1860 snd_hda_codec_write(codec, codec->afg, 0,
1861 AC_VERB_SET_GPIO_DATA, gpiostate);
1862}
1863
1864/* set up GPIO at initialization */
1865static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1727a771 1866 const struct hda_fixup *fix, int action)
5671087f 1867{
1727a771 1868 if (action != HDA_FIXUP_ACT_INIT)
5671087f
TI
1869 return;
1870 alc882_gpio_mute(codec, 0, 0);
1871 alc882_gpio_mute(codec, 1, 0);
1872}
1873
02a237b2
TI
1874/* Fix the connection of some pins for ALC889:
1875 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1876 * work correctly (bko#42740)
1877 */
1878static void alc889_fixup_dac_route(struct hda_codec *codec,
1727a771 1879 const struct hda_fixup *fix, int action)
02a237b2 1880{
1727a771 1881 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
ef8d60fb 1882 /* fake the connections during parsing the tree */
02a237b2
TI
1883 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1884 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1885 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1886 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1887 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1888 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1727a771 1889 } else if (action == HDA_FIXUP_ACT_PROBE) {
ef8d60fb
TI
1890 /* restore the connections */
1891 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1892 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1893 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1894 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1895 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
02a237b2
TI
1896 }
1897}
1898
1a97b7f2
TI
1899/* Set VREF on HP pin */
1900static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1727a771 1901 const struct hda_fixup *fix, int action)
1a97b7f2
TI
1902{
1903 struct alc_spec *spec = codec->spec;
1904 static hda_nid_t nids[2] = { 0x14, 0x15 };
1905 int i;
1906
1727a771 1907 if (action != HDA_FIXUP_ACT_INIT)
1a97b7f2
TI
1908 return;
1909 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1910 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1911 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1912 continue;
d3f02d60 1913 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1a97b7f2 1914 val |= AC_PINCTL_VREF_80;
cdd03ced 1915 snd_hda_set_pin_ctl(codec, nids[i], val);
08c189f2 1916 spec->gen.keep_vref_in_automute = 1;
1a97b7f2
TI
1917 break;
1918 }
1919}
1920
0756f09c
TI
1921static void alc889_fixup_mac_pins(struct hda_codec *codec,
1922 const hda_nid_t *nids, int num_nids)
1a97b7f2
TI
1923{
1924 struct alc_spec *spec = codec->spec;
1a97b7f2
TI
1925 int i;
1926
0756f09c 1927 for (i = 0; i < num_nids; i++) {
1a97b7f2 1928 unsigned int val;
d3f02d60 1929 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1a97b7f2 1930 val |= AC_PINCTL_VREF_50;
cdd03ced 1931 snd_hda_set_pin_ctl(codec, nids[i], val);
1a97b7f2 1932 }
08c189f2 1933 spec->gen.keep_vref_in_automute = 1;
1a97b7f2
TI
1934}
1935
0756f09c
TI
1936/* Set VREF on speaker pins on imac91 */
1937static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1938 const struct hda_fixup *fix, int action)
1939{
1940 static hda_nid_t nids[2] = { 0x18, 0x1a };
1941
1942 if (action == HDA_FIXUP_ACT_INIT)
1943 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1944}
1945
e7729a41
AV
1946/* Set VREF on speaker pins on mba11 */
1947static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1948 const struct hda_fixup *fix, int action)
1949{
1950 static hda_nid_t nids[1] = { 0x18 };
1951
1952 if (action == HDA_FIXUP_ACT_INIT)
1953 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1954}
1955
0756f09c
TI
1956/* Set VREF on speaker pins on mba21 */
1957static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1958 const struct hda_fixup *fix, int action)
1959{
1960 static hda_nid_t nids[2] = { 0x18, 0x19 };
1961
1962 if (action == HDA_FIXUP_ACT_INIT)
1963 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1964}
1965
e427c237 1966/* Don't take HP output as primary
d9111496
FLVC
1967 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1968 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
e427c237
TI
1969 */
1970static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1727a771 1971 const struct hda_fixup *fix, int action)
e427c237
TI
1972{
1973 struct alc_spec *spec = codec->spec;
da96fb5b 1974 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08c189f2 1975 spec->gen.no_primary_hp = 1;
da96fb5b
TI
1976 spec->gen.no_multi_io = 1;
1977 }
e427c237
TI
1978}
1979
eb9ca3ab
TI
1980static void alc_fixup_bass_chmap(struct hda_codec *codec,
1981 const struct hda_fixup *fix, int action);
1982
1727a771 1983static const struct hda_fixup alc882_fixups[] = {
5c0ebfbe 1984 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
1727a771
TI
1985 .type = HDA_FIXUP_PINS,
1986 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1987 { 0x15, 0x01080104 }, /* side */
1988 { 0x16, 0x01011012 }, /* rear */
1989 { 0x17, 0x01016011 }, /* clfe */
2785591a 1990 { }
145a902b
DH
1991 }
1992 },
5c0ebfbe 1993 [ALC882_FIXUP_LENOVO_Y530] = {
1727a771
TI
1994 .type = HDA_FIXUP_PINS,
1995 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1996 { 0x15, 0x99130112 }, /* rear int speakers */
1997 { 0x16, 0x99130111 }, /* subwoofer */
ac612407
DH
1998 { }
1999 }
2000 },
5c0ebfbe 2001 [ALC882_FIXUP_PB_M5210] = {
fd108215
TI
2002 .type = HDA_FIXUP_PINCTLS,
2003 .v.pins = (const struct hda_pintbl[]) {
2004 { 0x19, PIN_VREF50 },
357f915e
KY
2005 {}
2006 }
2007 },
5c0ebfbe 2008 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
1727a771 2009 .type = HDA_FIXUP_FUNC,
23d30f28 2010 .v.func = alc_fixup_sku_ignore,
6981d184 2011 },
5c0ebfbe 2012 [ALC882_FIXUP_ASUS_W90V] = {
1727a771
TI
2013 .type = HDA_FIXUP_PINS,
2014 .v.pins = (const struct hda_pintbl[]) {
5cdf745e
TI
2015 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2016 { }
2017 }
2018 },
8f239214 2019 [ALC889_FIXUP_CD] = {
1727a771
TI
2020 .type = HDA_FIXUP_PINS,
2021 .v.pins = (const struct hda_pintbl[]) {
8f239214
MB
2022 { 0x1c, 0x993301f0 }, /* CD */
2023 { }
2024 }
2025 },
b2c53e20
DH
2026 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2027 .type = HDA_FIXUP_PINS,
2028 .v.pins = (const struct hda_pintbl[]) {
2029 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2030 { }
2031 },
2032 .chained = true,
2033 .chain_id = ALC889_FIXUP_CD,
2034 },
5c0ebfbe 2035 [ALC889_FIXUP_VAIO_TT] = {
1727a771
TI
2036 .type = HDA_FIXUP_PINS,
2037 .v.pins = (const struct hda_pintbl[]) {
5c0ebfbe
TI
2038 { 0x17, 0x90170111 }, /* hidden surround speaker */
2039 { }
2040 }
2041 },
0e7cc2e7 2042 [ALC888_FIXUP_EEE1601] = {
1727a771 2043 .type = HDA_FIXUP_VERBS,
0e7cc2e7
TI
2044 .v.verbs = (const struct hda_verb[]) {
2045 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2046 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2047 { }
2048 }
177943a3
TI
2049 },
2050 [ALC882_FIXUP_EAPD] = {
1727a771 2051 .type = HDA_FIXUP_VERBS,
177943a3
TI
2052 .v.verbs = (const struct hda_verb[]) {
2053 /* change to EAPD mode */
2054 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2055 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2056 { }
2057 }
2058 },
7a6069bf 2059 [ALC883_FIXUP_EAPD] = {
1727a771 2060 .type = HDA_FIXUP_VERBS,
7a6069bf
TI
2061 .v.verbs = (const struct hda_verb[]) {
2062 /* change to EAPD mode */
2063 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2064 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2065 { }
2066 }
2067 },
8812c4f9 2068 [ALC883_FIXUP_ACER_EAPD] = {
1727a771 2069 .type = HDA_FIXUP_VERBS,
8812c4f9
TI
2070 .v.verbs = (const struct hda_verb[]) {
2071 /* eanable EAPD on Acer laptops */
2072 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2073 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2074 { }
2075 }
2076 },
1a97b7f2 2077 [ALC882_FIXUP_GPIO1] = {
1727a771 2078 .type = HDA_FIXUP_VERBS,
1a97b7f2
TI
2079 .v.verbs = alc_gpio1_init_verbs,
2080 },
2081 [ALC882_FIXUP_GPIO2] = {
1727a771 2082 .type = HDA_FIXUP_VERBS,
1a97b7f2
TI
2083 .v.verbs = alc_gpio2_init_verbs,
2084 },
eb844d51 2085 [ALC882_FIXUP_GPIO3] = {
1727a771 2086 .type = HDA_FIXUP_VERBS,
eb844d51
TI
2087 .v.verbs = alc_gpio3_init_verbs,
2088 },
68ef0561 2089 [ALC882_FIXUP_ASUS_W2JC] = {
1727a771 2090 .type = HDA_FIXUP_VERBS,
68ef0561
TI
2091 .v.verbs = alc_gpio1_init_verbs,
2092 .chained = true,
2093 .chain_id = ALC882_FIXUP_EAPD,
2094 },
2095 [ALC889_FIXUP_COEF] = {
1727a771 2096 .type = HDA_FIXUP_FUNC,
68ef0561
TI
2097 .v.func = alc889_fixup_coef,
2098 },
c3e837bb 2099 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
1727a771
TI
2100 .type = HDA_FIXUP_PINS,
2101 .v.pins = (const struct hda_pintbl[]) {
c3e837bb
TI
2102 { 0x16, 0x99130111 }, /* CLFE speaker */
2103 { 0x17, 0x99130112 }, /* surround speaker */
2104 { }
038d4fef
TI
2105 },
2106 .chained = true,
2107 .chain_id = ALC882_FIXUP_GPIO1,
c3e837bb
TI
2108 },
2109 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
1727a771
TI
2110 .type = HDA_FIXUP_PINS,
2111 .v.pins = (const struct hda_pintbl[]) {
c3e837bb
TI
2112 { 0x16, 0x99130111 }, /* CLFE speaker */
2113 { 0x1b, 0x99130112 }, /* surround speaker */
2114 { }
2115 },
2116 .chained = true,
2117 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2118 },
2119 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2120 /* additional init verbs for Acer Aspire 8930G */
1727a771 2121 .type = HDA_FIXUP_VERBS,
c3e837bb
TI
2122 .v.verbs = (const struct hda_verb[]) {
2123 /* Enable all DACs */
2124 /* DAC DISABLE/MUTE 1? */
2125 /* setting bits 1-5 disables DAC nids 0x02-0x06
2126 * apparently. Init=0x38 */
2127 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2128 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2129 /* DAC DISABLE/MUTE 2? */
2130 /* some bit here disables the other DACs.
2131 * Init=0x4900 */
2132 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2133 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2134 /* DMIC fix
2135 * This laptop has a stereo digital microphone.
2136 * The mics are only 1cm apart which makes the stereo
2137 * useless. However, either the mic or the ALC889
2138 * makes the signal become a difference/sum signal
2139 * instead of standard stereo, which is annoying.
2140 * So instead we flip this bit which makes the
2141 * codec replicate the sum signal to both channels,
2142 * turning it into a normal mono mic.
2143 */
2144 /* DMIC_CONTROL? Init value = 0x0001 */
2145 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2146 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2147 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2148 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2149 { }
038d4fef
TI
2150 },
2151 .chained = true,
2152 .chain_id = ALC882_FIXUP_GPIO1,
c3e837bb 2153 },
5671087f 2154 [ALC885_FIXUP_MACPRO_GPIO] = {
1727a771 2155 .type = HDA_FIXUP_FUNC,
5671087f
TI
2156 .v.func = alc885_fixup_macpro_gpio,
2157 },
02a237b2 2158 [ALC889_FIXUP_DAC_ROUTE] = {
1727a771 2159 .type = HDA_FIXUP_FUNC,
02a237b2
TI
2160 .v.func = alc889_fixup_dac_route,
2161 },
1a97b7f2 2162 [ALC889_FIXUP_MBP_VREF] = {
1727a771 2163 .type = HDA_FIXUP_FUNC,
1a97b7f2
TI
2164 .v.func = alc889_fixup_mbp_vref,
2165 .chained = true,
2166 .chain_id = ALC882_FIXUP_GPIO1,
2167 },
2168 [ALC889_FIXUP_IMAC91_VREF] = {
1727a771 2169 .type = HDA_FIXUP_FUNC,
1a97b7f2
TI
2170 .v.func = alc889_fixup_imac91_vref,
2171 .chained = true,
2172 .chain_id = ALC882_FIXUP_GPIO1,
2173 },
e7729a41
AV
2174 [ALC889_FIXUP_MBA11_VREF] = {
2175 .type = HDA_FIXUP_FUNC,
2176 .v.func = alc889_fixup_mba11_vref,
2177 .chained = true,
2178 .chain_id = ALC889_FIXUP_MBP_VREF,
2179 },
0756f09c
TI
2180 [ALC889_FIXUP_MBA21_VREF] = {
2181 .type = HDA_FIXUP_FUNC,
2182 .v.func = alc889_fixup_mba21_vref,
2183 .chained = true,
2184 .chain_id = ALC889_FIXUP_MBP_VREF,
2185 },
c20f31ec
TI
2186 [ALC889_FIXUP_MP11_VREF] = {
2187 .type = HDA_FIXUP_FUNC,
2188 .v.func = alc889_fixup_mba11_vref,
2189 .chained = true,
2190 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2191 },
6e72aa5f 2192 [ALC882_FIXUP_INV_DMIC] = {
1727a771 2193 .type = HDA_FIXUP_FUNC,
6e72aa5f
TI
2194 .v.func = alc_fixup_inv_dmic_0x12,
2195 },
e427c237 2196 [ALC882_FIXUP_NO_PRIMARY_HP] = {
1727a771 2197 .type = HDA_FIXUP_FUNC,
e427c237
TI
2198 .v.func = alc882_fixup_no_primary_hp,
2199 },
1f0bbf03
TI
2200 [ALC887_FIXUP_ASUS_BASS] = {
2201 .type = HDA_FIXUP_PINS,
2202 .v.pins = (const struct hda_pintbl[]) {
2203 {0x16, 0x99130130}, /* bass speaker */
2204 {}
2205 },
eb9ca3ab
TI
2206 .chained = true,
2207 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2208 },
2209 [ALC887_FIXUP_BASS_CHMAP] = {
2210 .type = HDA_FIXUP_FUNC,
2211 .v.func = alc_fixup_bass_chmap,
1f0bbf03 2212 },
ff818c24
TI
2213};
2214
1d045db9 2215static const struct snd_pci_quirk alc882_fixup_tbl[] = {
8812c4f9
TI
2216 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2217 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2218 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2219 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2220 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2221 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
c3e837bb
TI
2222 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2223 ALC882_FIXUP_ACER_ASPIRE_4930G),
2224 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2225 ALC882_FIXUP_ACER_ASPIRE_4930G),
2226 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2227 ALC882_FIXUP_ACER_ASPIRE_8930G),
2228 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2229 ALC882_FIXUP_ACER_ASPIRE_8930G),
2230 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2231 ALC882_FIXUP_ACER_ASPIRE_4930G),
2232 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2233 ALC882_FIXUP_ACER_ASPIRE_4930G),
2234 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2235 ALC882_FIXUP_ACER_ASPIRE_4930G),
5c0ebfbe 2236 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
f5c53d89
TI
2237 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2238 ALC882_FIXUP_ACER_ASPIRE_4930G),
02a237b2 2239 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
fe97da1f 2240 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
ac9b1cdd 2241 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
177943a3 2242 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
5c0ebfbe 2243 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
68ef0561 2244 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
0e7cc2e7 2245 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
1f0bbf03 2246 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
ac9b1cdd 2247 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
e427c237 2248 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
12e31a78 2249 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
5671087f
TI
2250
2251 /* All Apple entries are in codec SSIDs */
1a97b7f2
TI
2252 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2253 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2254 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
c20f31ec 2255 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
5671087f
TI
2256 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2257 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
1a97b7f2
TI
2258 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2259 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
5671087f 2260 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
e7729a41 2261 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
0756f09c 2262 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
1a97b7f2
TI
2263 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2264 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5671087f 2265 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
1a97b7f2
TI
2266 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2267 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2268 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
29ebe402 2269 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
05193639 2270 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
1a97b7f2
TI
2271 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2272 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2273 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
5671087f 2274
7a6069bf 2275 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
bca40138 2276 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
eb844d51 2277 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
b2c53e20 2278 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
5c0ebfbe 2279 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
7a6069bf
TI
2280 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2281 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
ac9b1cdd 2282 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
68ef0561 2283 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
ff818c24
TI
2284 {}
2285};
2286
1727a771 2287static const struct hda_model_fixup alc882_fixup_models[] = {
912093bc
TI
2288 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2289 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2290 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
6e72aa5f 2291 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
e427c237 2292 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
912093bc
TI
2293 {}
2294};
2295
f6a92248 2296/*
1d045db9 2297 * BIOS auto configuration
f6a92248 2298 */
1d045db9
TI
2299/* almost identical with ALC880 parser... */
2300static int alc882_parse_auto_config(struct hda_codec *codec)
2301{
1d045db9 2302 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2303 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2304 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
1d045db9 2305}
b896b4eb 2306
1d045db9
TI
2307/*
2308 */
1d045db9 2309static int patch_alc882(struct hda_codec *codec)
f6a92248
KY
2310{
2311 struct alc_spec *spec;
1a97b7f2 2312 int err;
f6a92248 2313
3de95173
TI
2314 err = alc_alloc_spec(codec, 0x0b);
2315 if (err < 0)
2316 return err;
f6a92248 2317
3de95173 2318 spec = codec->spec;
1f0f4b80 2319
1d045db9
TI
2320 switch (codec->vendor_id) {
2321 case 0x10ec0882:
2322 case 0x10ec0885:
2323 break;
2324 default:
2325 /* ALC883 and variants */
2326 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2327 break;
c793bec5 2328 }
977ddd6b 2329
1727a771 2330 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
912093bc 2331 alc882_fixups);
1727a771 2332 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ff818c24 2333
1d045db9
TI
2334 alc_auto_parse_customize_define(codec);
2335
7504b6cd
TI
2336 if (has_cdefine_beep(codec))
2337 spec->gen.beep_nid = 0x01;
2338
1a97b7f2
TI
2339 /* automatic parse from the BIOS config */
2340 err = alc882_parse_auto_config(codec);
2341 if (err < 0)
2342 goto error;
f6a92248 2343
7504b6cd 2344 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2345 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f6a92248
KY
2346
2347 codec->patch_ops = alc_patch_ops;
bf1b0225 2348
1727a771 2349 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2350
f6a92248 2351 return 0;
e16fb6d1
TI
2352
2353 error:
2354 alc_free(codec);
2355 return err;
f6a92248
KY
2356}
2357
df694daa 2358
df694daa 2359/*
1d045db9 2360 * ALC262 support
df694daa 2361 */
1d045db9 2362static int alc262_parse_auto_config(struct hda_codec *codec)
df694daa 2363{
1d045db9 2364 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2365 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2366 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
df694daa
KY
2367}
2368
df694daa 2369/*
1d045db9 2370 * Pin config fixes
df694daa 2371 */
cfc9b06f 2372enum {
ea4e7af1 2373 ALC262_FIXUP_FSC_H270,
7513e6da 2374 ALC262_FIXUP_FSC_S7110,
ea4e7af1
TI
2375 ALC262_FIXUP_HP_Z200,
2376 ALC262_FIXUP_TYAN,
c470150c 2377 ALC262_FIXUP_LENOVO_3000,
b42590b8
TI
2378 ALC262_FIXUP_BENQ,
2379 ALC262_FIXUP_BENQ_T31,
6e72aa5f 2380 ALC262_FIXUP_INV_DMIC,
b5c6611f 2381 ALC262_FIXUP_INTEL_BAYLEYBAY,
cfc9b06f
TI
2382};
2383
1727a771 2384static const struct hda_fixup alc262_fixups[] = {
ea4e7af1 2385 [ALC262_FIXUP_FSC_H270] = {
1727a771
TI
2386 .type = HDA_FIXUP_PINS,
2387 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2388 { 0x14, 0x99130110 }, /* speaker */
2389 { 0x15, 0x0221142f }, /* front HP */
2390 { 0x1b, 0x0121141f }, /* rear HP */
2391 { }
2392 }
2393 },
7513e6da
TI
2394 [ALC262_FIXUP_FSC_S7110] = {
2395 .type = HDA_FIXUP_PINS,
2396 .v.pins = (const struct hda_pintbl[]) {
2397 { 0x15, 0x90170110 }, /* speaker */
2398 { }
2399 },
2400 .chained = true,
2401 .chain_id = ALC262_FIXUP_BENQ,
2402 },
ea4e7af1 2403 [ALC262_FIXUP_HP_Z200] = {
1727a771
TI
2404 .type = HDA_FIXUP_PINS,
2405 .v.pins = (const struct hda_pintbl[]) {
1d045db9 2406 { 0x16, 0x99130120 }, /* internal speaker */
73413b12
TI
2407 { }
2408 }
cfc9b06f 2409 },
ea4e7af1 2410 [ALC262_FIXUP_TYAN] = {
1727a771
TI
2411 .type = HDA_FIXUP_PINS,
2412 .v.pins = (const struct hda_pintbl[]) {
ea4e7af1
TI
2413 { 0x14, 0x1993e1f0 }, /* int AUX */
2414 { }
2415 }
2416 },
c470150c 2417 [ALC262_FIXUP_LENOVO_3000] = {
fd108215
TI
2418 .type = HDA_FIXUP_PINCTLS,
2419 .v.pins = (const struct hda_pintbl[]) {
2420 { 0x19, PIN_VREF50 },
b42590b8
TI
2421 {}
2422 },
2423 .chained = true,
2424 .chain_id = ALC262_FIXUP_BENQ,
2425 },
2426 [ALC262_FIXUP_BENQ] = {
1727a771 2427 .type = HDA_FIXUP_VERBS,
b42590b8 2428 .v.verbs = (const struct hda_verb[]) {
c470150c
TI
2429 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2430 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2431 {}
2432 }
2433 },
b42590b8 2434 [ALC262_FIXUP_BENQ_T31] = {
1727a771 2435 .type = HDA_FIXUP_VERBS,
b42590b8
TI
2436 .v.verbs = (const struct hda_verb[]) {
2437 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2438 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2439 {}
2440 }
2441 },
6e72aa5f 2442 [ALC262_FIXUP_INV_DMIC] = {
1727a771 2443 .type = HDA_FIXUP_FUNC,
6e72aa5f
TI
2444 .v.func = alc_fixup_inv_dmic_0x12,
2445 },
b5c6611f
ML
2446 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2447 .type = HDA_FIXUP_FUNC,
2448 .v.func = alc_fixup_no_depop_delay,
2449 },
cfc9b06f
TI
2450};
2451
1d045db9 2452static const struct snd_pci_quirk alc262_fixup_tbl[] = {
ea4e7af1 2453 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
7513e6da 2454 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
3dcd3be3 2455 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
ea4e7af1
TI
2456 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2457 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
c470150c 2458 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
b42590b8
TI
2459 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2460 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
b5c6611f 2461 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
cfc9b06f
TI
2462 {}
2463};
df694daa 2464
1727a771 2465static const struct hda_model_fixup alc262_fixup_models[] = {
6e72aa5f
TI
2466 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2467 {}
2468};
1d045db9 2469
1d045db9
TI
2470/*
2471 */
1d045db9 2472static int patch_alc262(struct hda_codec *codec)
df694daa
KY
2473{
2474 struct alc_spec *spec;
df694daa
KY
2475 int err;
2476
3de95173
TI
2477 err = alc_alloc_spec(codec, 0x0b);
2478 if (err < 0)
2479 return err;
df694daa 2480
3de95173 2481 spec = codec->spec;
08c189f2 2482 spec->gen.shared_mic_vref_pin = 0x18;
1d045db9
TI
2483
2484#if 0
2485 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2486 * under-run
2487 */
98b24883 2488 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
1d045db9 2489#endif
1d045db9
TI
2490 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2491
1727a771 2492 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
6e72aa5f 2493 alc262_fixups);
1727a771 2494 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9c7f852e 2495
af741c15
TI
2496 alc_auto_parse_customize_define(codec);
2497
7504b6cd
TI
2498 if (has_cdefine_beep(codec))
2499 spec->gen.beep_nid = 0x01;
2500
42399f7a
TI
2501 /* automatic parse from the BIOS config */
2502 err = alc262_parse_auto_config(codec);
2503 if (err < 0)
2504 goto error;
df694daa 2505
7504b6cd 2506 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2507 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2134ea4f 2508
df694daa 2509 codec->patch_ops = alc_patch_ops;
1d045db9
TI
2510 spec->shutup = alc_eapd_shutup;
2511
1727a771 2512 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2513
1da177e4 2514 return 0;
e16fb6d1
TI
2515
2516 error:
2517 alc_free(codec);
2518 return err;
1da177e4
LT
2519}
2520
f32610ed 2521/*
1d045db9 2522 * ALC268
f32610ed 2523 */
1d045db9
TI
2524/* bind Beep switches of both NID 0x0f and 0x10 */
2525static const struct hda_bind_ctls alc268_bind_beep_sw = {
2526 .ops = &snd_hda_bind_sw,
2527 .values = {
2528 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2529 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2530 0
2531 },
f32610ed
JS
2532};
2533
1d045db9
TI
2534static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2535 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2536 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2537 { }
f32610ed
JS
2538};
2539
1d045db9
TI
2540/* set PCBEEP vol = 0, mute connections */
2541static const struct hda_verb alc268_beep_init_verbs[] = {
2542 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2544 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2545 { }
f32610ed
JS
2546};
2547
6e72aa5f
TI
2548enum {
2549 ALC268_FIXUP_INV_DMIC,
cb766404 2550 ALC268_FIXUP_HP_EAPD,
24eff328 2551 ALC268_FIXUP_SPDIF,
6e72aa5f
TI
2552};
2553
1727a771 2554static const struct hda_fixup alc268_fixups[] = {
6e72aa5f 2555 [ALC268_FIXUP_INV_DMIC] = {
1727a771 2556 .type = HDA_FIXUP_FUNC,
6e72aa5f
TI
2557 .v.func = alc_fixup_inv_dmic_0x12,
2558 },
cb766404 2559 [ALC268_FIXUP_HP_EAPD] = {
1727a771 2560 .type = HDA_FIXUP_VERBS,
cb766404
TI
2561 .v.verbs = (const struct hda_verb[]) {
2562 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2563 {}
2564 }
2565 },
24eff328
TI
2566 [ALC268_FIXUP_SPDIF] = {
2567 .type = HDA_FIXUP_PINS,
2568 .v.pins = (const struct hda_pintbl[]) {
2569 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2570 {}
2571 }
2572 },
6e72aa5f
TI
2573};
2574
1727a771 2575static const struct hda_model_fixup alc268_fixup_models[] = {
6e72aa5f 2576 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
cb766404
TI
2577 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2578 {}
2579};
2580
2581static const struct snd_pci_quirk alc268_fixup_tbl[] = {
24eff328 2582 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
fcd8f3b1 2583 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
cb766404
TI
2584 /* below is codec SSID since multiple Toshiba laptops have the
2585 * same PCI SSID 1179:ff00
2586 */
2587 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
6e72aa5f
TI
2588 {}
2589};
2590
f32610ed
JS
2591/*
2592 * BIOS auto configuration
2593 */
1d045db9 2594static int alc268_parse_auto_config(struct hda_codec *codec)
f32610ed 2595{
3e6179b8 2596 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7504b6cd 2597 return alc_parse_auto_config(codec, NULL, alc268_ssids);
f32610ed
JS
2598}
2599
1d045db9
TI
2600/*
2601 */
1d045db9 2602static int patch_alc268(struct hda_codec *codec)
f32610ed
JS
2603{
2604 struct alc_spec *spec;
7504b6cd 2605 int err;
f32610ed 2606
1d045db9 2607 /* ALC268 has no aa-loopback mixer */
3de95173
TI
2608 err = alc_alloc_spec(codec, 0);
2609 if (err < 0)
2610 return err;
2611
2612 spec = codec->spec;
7504b6cd 2613 spec->gen.beep_nid = 0x01;
1f0f4b80 2614
1727a771
TI
2615 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2616 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6e72aa5f 2617
6ebb8053
TI
2618 /* automatic parse from the BIOS config */
2619 err = alc268_parse_auto_config(codec);
e16fb6d1
TI
2620 if (err < 0)
2621 goto error;
f32610ed 2622
7504b6cd
TI
2623 if (err > 0 && !spec->gen.no_analog &&
2624 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2625 add_mixer(spec, alc268_beep_mixer);
2626 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
1d045db9
TI
2627 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2628 /* override the amp caps for beep generator */
2629 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2630 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2631 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2632 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2633 (0 << AC_AMPCAP_MUTE_SHIFT));
2f893286
KY
2634 }
2635
f32610ed 2636 codec->patch_ops = alc_patch_ops;
1c716153 2637 spec->shutup = alc_eapd_shutup;
1d045db9 2638
1727a771 2639 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6e72aa5f 2640
f32610ed 2641 return 0;
e16fb6d1
TI
2642
2643 error:
2644 alc_free(codec);
2645 return err;
f32610ed
JS
2646}
2647
bc9f98a9 2648/*
1d045db9 2649 * ALC269
bc9f98a9 2650 */
08c189f2
TI
2651
2652static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2653 struct hda_codec *codec,
2654 struct snd_pcm_substream *substream)
2655{
2656 struct hda_gen_spec *spec = codec->spec;
2657 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2658 hinfo);
2659}
2660
2661static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2662 struct hda_codec *codec,
2663 unsigned int stream_tag,
2664 unsigned int format,
2665 struct snd_pcm_substream *substream)
2666{
2667 struct hda_gen_spec *spec = codec->spec;
2668 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2669 stream_tag, format, substream);
2670}
2671
2672static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2673 struct hda_codec *codec,
2674 struct snd_pcm_substream *substream)
2675{
2676 struct hda_gen_spec *spec = codec->spec;
2677 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2678}
2679
1d045db9
TI
2680static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2681 .substreams = 1,
2682 .channels_min = 2,
2683 .channels_max = 8,
2684 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2685 /* NID is set in alc_build_pcms */
2686 .ops = {
08c189f2
TI
2687 .open = playback_pcm_open,
2688 .prepare = playback_pcm_prepare,
2689 .cleanup = playback_pcm_cleanup
bc9f98a9
KY
2690 },
2691};
2692
1d045db9
TI
2693static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2694 .substreams = 1,
2695 .channels_min = 2,
2696 .channels_max = 2,
2697 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2698 /* NID is set in alc_build_pcms */
bc9f98a9 2699};
291702f0 2700
1d045db9
TI
2701/* different alc269-variants */
2702enum {
2703 ALC269_TYPE_ALC269VA,
2704 ALC269_TYPE_ALC269VB,
2705 ALC269_TYPE_ALC269VC,
adcc70b2 2706 ALC269_TYPE_ALC269VD,
065380f0
KY
2707 ALC269_TYPE_ALC280,
2708 ALC269_TYPE_ALC282,
2af02be7 2709 ALC269_TYPE_ALC283,
065380f0 2710 ALC269_TYPE_ALC284,
161ebf29 2711 ALC269_TYPE_ALC285,
7fc7d047 2712 ALC269_TYPE_ALC286,
1d04c9de 2713 ALC269_TYPE_ALC255,
bc9f98a9
KY
2714};
2715
2716/*
1d045db9 2717 * BIOS auto configuration
bc9f98a9 2718 */
1d045db9
TI
2719static int alc269_parse_auto_config(struct hda_codec *codec)
2720{
1d045db9 2721 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2722 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2723 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2724 struct alc_spec *spec = codec->spec;
adcc70b2
KY
2725 const hda_nid_t *ssids;
2726
2727 switch (spec->codec_variant) {
2728 case ALC269_TYPE_ALC269VA:
2729 case ALC269_TYPE_ALC269VC:
065380f0
KY
2730 case ALC269_TYPE_ALC280:
2731 case ALC269_TYPE_ALC284:
161ebf29 2732 case ALC269_TYPE_ALC285:
adcc70b2
KY
2733 ssids = alc269va_ssids;
2734 break;
2735 case ALC269_TYPE_ALC269VB:
2736 case ALC269_TYPE_ALC269VD:
065380f0 2737 case ALC269_TYPE_ALC282:
2af02be7 2738 case ALC269_TYPE_ALC283:
7fc7d047 2739 case ALC269_TYPE_ALC286:
1d04c9de 2740 case ALC269_TYPE_ALC255:
adcc70b2
KY
2741 ssids = alc269_ssids;
2742 break;
2743 default:
2744 ssids = alc269_ssids;
2745 break;
2746 }
bc9f98a9 2747
3e6179b8 2748 return alc_parse_auto_config(codec, alc269_ignore, ssids);
1d045db9 2749}
bc9f98a9 2750
f7ae9ba0
KY
2751static int find_ext_mic_pin(struct hda_codec *codec);
2752
2753static void alc286_shutup(struct hda_codec *codec)
2754{
2755 int i;
2756 int mic_pin = find_ext_mic_pin(codec);
2757 /* don't shut up pins when unloading the driver; otherwise it breaks
2758 * the default pin setup at the next load of the driver
2759 */
2760 if (codec->bus->shutdown)
2761 return;
2762 for (i = 0; i < codec->init_pins.used; i++) {
2763 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
2764 /* use read here for syncing after issuing each verb */
2765 if (pin->nid != mic_pin)
2766 snd_hda_codec_read(codec, pin->nid, 0,
2767 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2768 }
2769 codec->pins_shutup = 1;
2770}
2771
1387e2d1 2772static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
1d045db9 2773{
98b24883 2774 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
1d045db9 2775}
291702f0 2776
1d045db9
TI
2777static void alc269_shutup(struct hda_codec *codec)
2778{
adcc70b2
KY
2779 struct alc_spec *spec = codec->spec;
2780
1387e2d1
KY
2781 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2782 alc269vb_toggle_power_output(codec, 0);
2783 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2784 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
2785 msleep(150);
2786 }
9bfb2844 2787 snd_hda_shutup_pins(codec);
1d045db9 2788}
291702f0 2789
cb149cb3
KY
2790static void alc282_restore_default_value(struct hda_codec *codec)
2791{
cb149cb3
KY
2792 /* Power Down Control */
2793 alc_write_coef_idx(codec, 0x03, 0x0002);
2794 /* FIFO and filter clock */
2795 alc_write_coef_idx(codec, 0x05, 0x0700);
2796 /* DMIC control */
2797 alc_write_coef_idx(codec, 0x07, 0x0200);
2798 /* Analog clock */
98b24883 2799 alc_update_coef_idx(codec, 0x06, 0x00f0, 0);
cb149cb3 2800 /* JD */
98b24883 2801 alc_update_coef_idx(codec, 0x08, 0xfffc, 0x0c2c);
cb149cb3
KY
2802 /* JD offset1 */
2803 alc_write_coef_idx(codec, 0x0a, 0xcccc);
2804 /* JD offset2 */
2805 alc_write_coef_idx(codec, 0x0b, 0xcccc);
2806 /* LDO1/2/3, DAC/ADC */
2807 alc_write_coef_idx(codec, 0x0e, 0x6e00);
2808 /* JD */
98b24883 2809 alc_update_coef_idx(codec, 0x0f, 0xf800, 0x1000);
cb149cb3 2810 /* Capless */
98b24883 2811 alc_update_coef_idx(codec, 0x10, 0xfc00, 0x0c00);
cb149cb3
KY
2812 /* Class D test 4 */
2813 alc_write_coef_idx(codec, 0x6f, 0x0);
2814 /* IO power down directly */
98b24883 2815 alc_update_coef_idx(codec, 0x0c, 0xfe00, 0);
cb149cb3
KY
2816 /* ANC */
2817 alc_write_coef_idx(codec, 0x34, 0xa0c0);
2818 /* AGC MUX */
98b24883 2819 alc_update_coef_idx(codec, 0x16, 0x0008, 0);
cb149cb3 2820 /* DAC simple content protection */
98b24883 2821 alc_update_coef_idx(codec, 0x1d, 0x00e0, 0);
cb149cb3 2822 /* ADC simple content protection */
98b24883 2823 alc_update_coef_idx(codec, 0x1f, 0x00e0, 0);
cb149cb3
KY
2824 /* DAC ADC Zero Detection */
2825 alc_write_coef_idx(codec, 0x21, 0x8804);
2826 /* PLL */
2827 alc_write_coef_idx(codec, 0x63, 0x2902);
2828 /* capless control 2 */
2829 alc_write_coef_idx(codec, 0x68, 0xa080);
2830 /* capless control 3 */
2831 alc_write_coef_idx(codec, 0x69, 0x3400);
2832 /* capless control 4 */
2833 alc_write_coef_idx(codec, 0x6a, 0x2f3e);
2834 /* capless control 5 */
2835 alc_write_coef_idx(codec, 0x6b, 0x0);
2836 /* class D test 2 */
98b24883 2837 alc_update_coef_idx(codec, 0x6d, 0x0fff, 0x0900);
cb149cb3
KY
2838 /* class D test 3 */
2839 alc_write_coef_idx(codec, 0x6e, 0x110a);
2840 /* class D test 5 */
98b24883 2841 alc_update_coef_idx(codec, 0x70, 0x00f8, 0x00d8);
cb149cb3
KY
2842 /* class D test 6 */
2843 alc_write_coef_idx(codec, 0x71, 0x0014);
2844 /* classD OCP */
2845 alc_write_coef_idx(codec, 0x72, 0xc2ba);
2846 /* classD pure DC test */
98b24883 2847 alc_update_coef_idx(codec, 0x77, 0x0f80, 0);
cb149cb3
KY
2848 /* Class D amp control */
2849 alc_write_coef_idx(codec, 0x6c, 0xfc06);
2850}
2851
7b5c7a02
KY
2852static void alc282_init(struct hda_codec *codec)
2853{
2854 struct alc_spec *spec = codec->spec;
2855 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2856 bool hp_pin_sense;
2857 int coef78;
2858
cb149cb3
KY
2859 alc282_restore_default_value(codec);
2860
7b5c7a02
KY
2861 if (!hp_pin)
2862 return;
2863 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2864 coef78 = alc_read_coef_idx(codec, 0x78);
2865
2866 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2867 /* Headphone capless set to high power mode */
2868 alc_write_coef_idx(codec, 0x78, 0x9004);
2869
2870 if (hp_pin_sense)
2871 msleep(2);
2872
2873 snd_hda_codec_write(codec, hp_pin, 0,
2874 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2875
2876 if (hp_pin_sense)
2877 msleep(85);
2878
2879 snd_hda_codec_write(codec, hp_pin, 0,
2880 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2881
2882 if (hp_pin_sense)
2883 msleep(100);
2884
2885 /* Headphone capless set to normal mode */
2886 alc_write_coef_idx(codec, 0x78, coef78);
2887}
2888
2889static void alc282_shutup(struct hda_codec *codec)
2890{
2891 struct alc_spec *spec = codec->spec;
2892 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2893 bool hp_pin_sense;
2894 int coef78;
2895
2896 if (!hp_pin) {
2897 alc269_shutup(codec);
2898 return;
2899 }
2900
2901 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2902 coef78 = alc_read_coef_idx(codec, 0x78);
2903 alc_write_coef_idx(codec, 0x78, 0x9004);
2904
2905 if (hp_pin_sense)
2906 msleep(2);
2907
2908 snd_hda_codec_write(codec, hp_pin, 0,
2909 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2910
2911 if (hp_pin_sense)
2912 msleep(85);
2913
2914 snd_hda_codec_write(codec, hp_pin, 0,
2915 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2916
2917 if (hp_pin_sense)
2918 msleep(100);
2919
2920 alc_auto_setup_eapd(codec, false);
2921 snd_hda_shutup_pins(codec);
2922 alc_write_coef_idx(codec, 0x78, coef78);
2923}
2924
6bd55b04
KY
2925static void alc283_restore_default_value(struct hda_codec *codec)
2926{
6bd55b04
KY
2927 /* Power Down Control */
2928 alc_write_coef_idx(codec, 0x03, 0x0002);
2929 /* FIFO and filter clock */
2930 alc_write_coef_idx(codec, 0x05, 0x0700);
2931 /* DMIC control */
2932 alc_write_coef_idx(codec, 0x07, 0x0200);
2933 /* Analog clock */
98b24883 2934 alc_update_coef_idx(codec, 0x06, 0x00f0, 0);
6bd55b04 2935 /* JD */
98b24883 2936 alc_update_coef_idx(codec, 0x08, 0xfffc, 0x0c2c);
6bd55b04
KY
2937 /* JD offset1 */
2938 alc_write_coef_idx(codec, 0x0a, 0xcccc);
2939 /* JD offset2 */
2940 alc_write_coef_idx(codec, 0x0b, 0xcccc);
2941 /* LDO1/2/3, DAC/ADC */
2942 alc_write_coef_idx(codec, 0x0e, 0x6fc0);
2943 /* JD */
98b24883 2944 alc_update_coef_idx(codec, 0x0f, 0xf800, 0x1000);
6bd55b04 2945 /* Capless */
98b24883 2946 alc_update_coef_idx(codec, 0x10, 0xfc00, 0x0c00);
6bd55b04
KY
2947 /* Class D test 4 */
2948 alc_write_coef_idx(codec, 0x3a, 0x0);
2949 /* IO power down directly */
98b24883 2950 alc_update_coef_idx(codec, 0x0c, 0xfe00, 0x0);
6bd55b04
KY
2951 /* ANC */
2952 alc_write_coef_idx(codec, 0x22, 0xa0c0);
2953 /* AGC MUX */
98b24883 2954 alc_update_coefex_idx(codec, 0x53, 0x01, 0x000f, 0x0008);
6bd55b04 2955 /* DAC simple content protection */
98b24883 2956 alc_update_coef_idx(codec, 0x1d, 0x00e0, 0x0);
6bd55b04 2957 /* ADC simple content protection */
98b24883 2958 alc_update_coef_idx(codec, 0x1f, 0x00e0, 0x0);
6bd55b04
KY
2959 /* DAC ADC Zero Detection */
2960 alc_write_coef_idx(codec, 0x21, 0x8804);
2961 /* PLL */
2962 alc_write_coef_idx(codec, 0x2e, 0x2902);
2963 /* capless control 2 */
2964 alc_write_coef_idx(codec, 0x33, 0xa080);
2965 /* capless control 3 */
2966 alc_write_coef_idx(codec, 0x34, 0x3400);
2967 /* capless control 4 */
2968 alc_write_coef_idx(codec, 0x35, 0x2f3e);
2969 /* capless control 5 */
2970 alc_write_coef_idx(codec, 0x36, 0x0);
2971 /* class D test 2 */
98b24883 2972 alc_update_coef_idx(codec, 0x38, 0x0fff, 0x0900);
6bd55b04
KY
2973 /* class D test 3 */
2974 alc_write_coef_idx(codec, 0x39, 0x110a);
2975 /* class D test 5 */
98b24883 2976 alc_update_coef_idx(codec, 0x3b, 0x00f8, 0x00d8);
6bd55b04
KY
2977 /* class D test 6 */
2978 alc_write_coef_idx(codec, 0x3c, 0x0014);
2979 /* classD OCP */
2980 alc_write_coef_idx(codec, 0x3d, 0xc2ba);
2981 /* classD pure DC test */
98b24883 2982 alc_update_coef_idx(codec, 0x42, 0x0f80, 0x0);
6bd55b04
KY
2983 /* test mode */
2984 alc_write_coef_idx(codec, 0x49, 0x0);
2985 /* Class D DC enable */
98b24883 2986 alc_update_coef_idx(codec, 0x40, 0xf800, 0x9800);
6bd55b04 2987 /* DC offset */
98b24883 2988 alc_update_coef_idx(codec, 0x42, 0xf000, 0x2000);
6bd55b04
KY
2989 /* Class D amp control */
2990 alc_write_coef_idx(codec, 0x37, 0xfc06);
2991}
2992
2af02be7
KY
2993static void alc283_init(struct hda_codec *codec)
2994{
2995 struct alc_spec *spec = codec->spec;
2996 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2997 bool hp_pin_sense;
2af02be7 2998
8314f225
KY
2999 if (!spec->gen.autocfg.hp_outs) {
3000 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3001 hp_pin = spec->gen.autocfg.line_out_pins[0];
3002 }
3003
6bd55b04
KY
3004 alc283_restore_default_value(codec);
3005
2af02be7
KY
3006 if (!hp_pin)
3007 return;
3008 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3009
3010 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3011 /* Headphone capless set to high power mode */
3012 alc_write_coef_idx(codec, 0x43, 0x9004);
3013
3014 snd_hda_codec_write(codec, hp_pin, 0,
3015 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3016
3017 if (hp_pin_sense)
3018 msleep(85);
3019
3020 snd_hda_codec_write(codec, hp_pin, 0,
3021 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3022
3023 if (hp_pin_sense)
3024 msleep(85);
3025 /* Index 0x46 Combo jack auto switch control 2 */
3026 /* 3k pull low control for Headset jack. */
98b24883 3027 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
2af02be7
KY
3028 /* Headphone capless set to normal mode */
3029 alc_write_coef_idx(codec, 0x43, 0x9614);
3030}
3031
3032static void alc283_shutup(struct hda_codec *codec)
3033{
3034 struct alc_spec *spec = codec->spec;
3035 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3036 bool hp_pin_sense;
2af02be7 3037
8314f225
KY
3038 if (!spec->gen.autocfg.hp_outs) {
3039 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3040 hp_pin = spec->gen.autocfg.line_out_pins[0];
3041 }
3042
2af02be7
KY
3043 if (!hp_pin) {
3044 alc269_shutup(codec);
3045 return;
3046 }
3047
3048 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3049
3050 alc_write_coef_idx(codec, 0x43, 0x9004);
3051
3052 snd_hda_codec_write(codec, hp_pin, 0,
3053 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3054
3055 if (hp_pin_sense)
88011c09 3056 msleep(100);
2af02be7
KY
3057
3058 snd_hda_codec_write(codec, hp_pin, 0,
3059 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3060
98b24883 3061 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
2af02be7
KY
3062
3063 if (hp_pin_sense)
88011c09 3064 msleep(100);
0435b3ff 3065 alc_auto_setup_eapd(codec, false);
2af02be7
KY
3066 snd_hda_shutup_pins(codec);
3067 alc_write_coef_idx(codec, 0x43, 0x9614);
3068}
3069
ad60d502
KY
3070static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3071 unsigned int val)
3072{
3073 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3074 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3075 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3076}
3077
3078static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3079{
3080 unsigned int val;
3081
3082 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3083 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3084 & 0xffff;
3085 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3086 << 16;
3087 return val;
3088}
3089
3090static void alc5505_dsp_halt(struct hda_codec *codec)
3091{
3092 unsigned int val;
3093
3094 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3095 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3096 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3097 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3098 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3099 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3100 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3101 val = alc5505_coef_get(codec, 0x6220);
3102 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3103}
3104
3105static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3106{
3107 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3108 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3109 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3110 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3111 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3112 alc5505_coef_set(codec, 0x880c, 0x00000004);
3113}
3114
3115static void alc5505_dsp_init(struct hda_codec *codec)
3116{
3117 unsigned int val;
3118
3119 alc5505_dsp_halt(codec);
3120 alc5505_dsp_back_from_halt(codec);
3121 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3122 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3123 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3124 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3125 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3126 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3127 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3128 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3129 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3130 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3131 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3132 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3133 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3134
3135 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3136 if (val <= 3)
3137 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3138 else
3139 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3140
3141 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3142 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3143 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3144 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3145 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3146 alc5505_coef_set(codec, 0x880c, 0x00000003);
3147 alc5505_coef_set(codec, 0x880c, 0x00000010);
cd63a5ff
TI
3148
3149#ifdef HALT_REALTEK_ALC5505
3150 alc5505_dsp_halt(codec);
3151#endif
ad60d502
KY
3152}
3153
cd63a5ff
TI
3154#ifdef HALT_REALTEK_ALC5505
3155#define alc5505_dsp_suspend(codec) /* NOP */
3156#define alc5505_dsp_resume(codec) /* NOP */
3157#else
3158#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3159#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3160#endif
3161
2a43952a 3162#ifdef CONFIG_PM
ad60d502
KY
3163static int alc269_suspend(struct hda_codec *codec)
3164{
3165 struct alc_spec *spec = codec->spec;
3166
3167 if (spec->has_alc5505_dsp)
cd63a5ff 3168 alc5505_dsp_suspend(codec);
ad60d502
KY
3169 return alc_suspend(codec);
3170}
3171
1d045db9
TI
3172static int alc269_resume(struct hda_codec *codec)
3173{
adcc70b2
KY
3174 struct alc_spec *spec = codec->spec;
3175
1387e2d1
KY
3176 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3177 alc269vb_toggle_power_output(codec, 0);
3178 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3179 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
3180 msleep(150);
3181 }
8c427226 3182
1d045db9 3183 codec->patch_ops.init(codec);
f1d4e28b 3184
1387e2d1
KY
3185 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3186 alc269vb_toggle_power_output(codec, 1);
3187 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3188 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
3189 msleep(200);
3190 }
f1d4e28b 3191
1d045db9
TI
3192 snd_hda_codec_resume_amp(codec);
3193 snd_hda_codec_resume_cache(codec);
0623a889 3194 alc_inv_dmic_sync(codec, true);
1d045db9 3195 hda_call_check_power_status(codec, 0x01);
f475371a
HW
3196
3197 /* on some machine, the BIOS will clear the codec gpio data when enter
3198 * suspend, and won't restore the data after resume, so we restore it
3199 * in the driver.
3200 */
3201 if (spec->gpio_led)
3202 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA,
3203 spec->gpio_led);
3204
ad60d502 3205 if (spec->has_alc5505_dsp)
cd63a5ff 3206 alc5505_dsp_resume(codec);
c5177c86 3207
1d045db9
TI
3208 return 0;
3209}
2a43952a 3210#endif /* CONFIG_PM */
f1d4e28b 3211
108cc108 3212static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
1727a771 3213 const struct hda_fixup *fix, int action)
108cc108
DH
3214{
3215 struct alc_spec *spec = codec->spec;
3216
1727a771 3217 if (action == HDA_FIXUP_ACT_PRE_PROBE)
108cc108
DH
3218 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3219}
3220
1d045db9 3221static void alc269_fixup_hweq(struct hda_codec *codec,
1727a771 3222 const struct hda_fixup *fix, int action)
1d045db9 3223{
98b24883
TI
3224 if (action == HDA_FIXUP_ACT_INIT)
3225 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
1d045db9 3226}
f1d4e28b 3227
7c478f03
DH
3228static void alc269_fixup_headset_mic(struct hda_codec *codec,
3229 const struct hda_fixup *fix, int action)
3230{
3231 struct alc_spec *spec = codec->spec;
3232
3233 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3234 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3235}
3236
1d045db9 3237static void alc271_fixup_dmic(struct hda_codec *codec,
1727a771 3238 const struct hda_fixup *fix, int action)
1d045db9
TI
3239{
3240 static const struct hda_verb verbs[] = {
3241 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3242 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3243 {}
3244 };
3245 unsigned int cfg;
f1d4e28b 3246
42397004
DR
3247 if (strcmp(codec->chip_name, "ALC271X") &&
3248 strcmp(codec->chip_name, "ALC269VB"))
1d045db9
TI
3249 return;
3250 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3251 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3252 snd_hda_sequence_write(codec, verbs);
3253}
f1d4e28b 3254
017f2a10 3255static void alc269_fixup_pcm_44k(struct hda_codec *codec,
1727a771 3256 const struct hda_fixup *fix, int action)
017f2a10
TI
3257{
3258 struct alc_spec *spec = codec->spec;
3259
1727a771 3260 if (action != HDA_FIXUP_ACT_PROBE)
017f2a10
TI
3261 return;
3262
3263 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3264 * fix the sample rate of analog I/O to 44.1kHz
3265 */
08c189f2
TI
3266 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3267 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
017f2a10
TI
3268}
3269
adabb3ec 3270static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
1727a771 3271 const struct hda_fixup *fix, int action)
adabb3ec 3272{
adabb3ec
TI
3273 /* The digital-mic unit sends PDM (differential signal) instead of
3274 * the standard PCM, thus you can't record a valid mono stream as is.
3275 * Below is a workaround specific to ALC269 to control the dmic
3276 * signal source as mono.
3277 */
98b24883
TI
3278 if (action == HDA_FIXUP_ACT_INIT)
3279 alc_update_coef_idx(codec, 0x07, 0, 0x80);
adabb3ec
TI
3280}
3281
24519911
TI
3282static void alc269_quanta_automute(struct hda_codec *codec)
3283{
08c189f2 3284 snd_hda_gen_update_outputs(codec);
24519911 3285
1687ccc8
TI
3286 alc_write_coef_idx(codec, 0x0c, 0x680);
3287 alc_write_coef_idx(codec, 0x0c, 0x480);
24519911
TI
3288}
3289
3290static void alc269_fixup_quanta_mute(struct hda_codec *codec,
1727a771 3291 const struct hda_fixup *fix, int action)
24519911
TI
3292{
3293 struct alc_spec *spec = codec->spec;
1727a771 3294 if (action != HDA_FIXUP_ACT_PROBE)
24519911 3295 return;
08c189f2 3296 spec->gen.automute_hook = alc269_quanta_automute;
24519911
TI
3297}
3298
d240d1dc
DH
3299static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3300 struct hda_jack_tbl *jack)
3301{
3302 struct alc_spec *spec = codec->spec;
3303 int vref;
3304 msleep(200);
3305 snd_hda_gen_hp_automute(codec, jack);
3306
3307 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3308 msleep(100);
3309 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3310 vref);
3311 msleep(500);
3312 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3313 vref);
3314}
3315
3316static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3317 const struct hda_fixup *fix, int action)
3318{
3319 struct alc_spec *spec = codec->spec;
3320 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3321 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3322 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3323 }
3324}
3325
3326
08fb0d0e
TI
3327/* update mute-LED according to the speaker mute state via mic VREF pin */
3328static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
6d3cd5d4
DH
3329{
3330 struct hda_codec *codec = private_data;
08fb0d0e
TI
3331 struct alc_spec *spec = codec->spec;
3332 unsigned int pinval;
3333
3334 if (spec->mute_led_polarity)
3335 enabled = !enabled;
415d555e
TI
3336 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3337 pinval &= ~AC_PINCTL_VREFEN;
3338 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
08fb0d0e
TI
3339 if (spec->mute_led_nid)
3340 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
6d3cd5d4
DH
3341}
3342
d5b6b65e
DH
3343/* Make sure the led works even in runtime suspend */
3344static unsigned int led_power_filter(struct hda_codec *codec,
3345 hda_nid_t nid,
3346 unsigned int power_state)
3347{
3348 struct alc_spec *spec = codec->spec;
3349
50dd9050
HW
3350 if (power_state != AC_PWRST_D3 || nid == 0 ||
3351 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
d5b6b65e
DH
3352 return power_state;
3353
3354 /* Set pin ctl again, it might have just been set to 0 */
3355 snd_hda_set_pin_ctl(codec, nid,
3356 snd_hda_codec_get_pin_target(codec, nid));
3357
3358 return AC_PWRST_D0;
3359}
3360
08fb0d0e
TI
3361static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3362 const struct hda_fixup *fix, int action)
6d3cd5d4
DH
3363{
3364 struct alc_spec *spec = codec->spec;
08fb0d0e
TI
3365 const struct dmi_device *dev = NULL;
3366
3367 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3368 return;
3369
3370 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3371 int pol, pin;
3372 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3373 continue;
3374 if (pin < 0x0a || pin >= 0x10)
3375 break;
3376 spec->mute_led_polarity = pol;
3377 spec->mute_led_nid = pin - 0x0a + 0x18;
3378 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3379 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3380 codec->power_filter = led_power_filter;
4e76a883
TI
3381 codec_dbg(codec,
3382 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
08fb0d0e 3383 spec->mute_led_polarity);
6d3cd5d4
DH
3384 break;
3385 }
3386}
3387
d06ac143
DH
3388static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3389 const struct hda_fixup *fix, int action)
3390{
3391 struct alc_spec *spec = codec->spec;
3392 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3393 spec->mute_led_polarity = 0;
3394 spec->mute_led_nid = 0x18;
3395 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3396 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3397 codec->power_filter = led_power_filter;
d06ac143
DH
3398 }
3399}
3400
08fb0d0e
TI
3401static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3402 const struct hda_fixup *fix, int action)
420b0feb
TI
3403{
3404 struct alc_spec *spec = codec->spec;
9bb1f06f 3405 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08fb0d0e
TI
3406 spec->mute_led_polarity = 0;
3407 spec->mute_led_nid = 0x19;
3408 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3409 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3410 codec->power_filter = led_power_filter;
420b0feb
TI
3411 }
3412}
3413
9f5c6faf
TI
3414/* turn on/off mute LED per vmaster hook */
3415static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
3416{
3417 struct hda_codec *codec = private_data;
3418 struct alc_spec *spec = codec->spec;
3419 unsigned int oldval = spec->gpio_led;
3420
3421 if (enabled)
3422 spec->gpio_led &= ~0x08;
3423 else
3424 spec->gpio_led |= 0x08;
3425 if (spec->gpio_led != oldval)
3426 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3427 spec->gpio_led);
3428}
3429
3430/* turn on/off mic-mute LED per capture hook */
3431static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
7fe30711
TI
3432 struct snd_kcontrol *kcontrol,
3433 struct snd_ctl_elem_value *ucontrol)
9f5c6faf
TI
3434{
3435 struct alc_spec *spec = codec->spec;
3436 unsigned int oldval = spec->gpio_led;
3437
3438 if (!ucontrol)
3439 return;
3440
3441 if (ucontrol->value.integer.value[0] ||
3442 ucontrol->value.integer.value[1])
3443 spec->gpio_led &= ~0x10;
3444 else
3445 spec->gpio_led |= 0x10;
3446 if (spec->gpio_led != oldval)
3447 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3448 spec->gpio_led);
3449}
3450
3451static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3452 const struct hda_fixup *fix, int action)
3453{
3454 struct alc_spec *spec = codec->spec;
3455 static const struct hda_verb gpio_init[] = {
3456 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3457 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3458 {}
3459 };
3460
3461 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3462 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3463 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
3464 spec->gpio_led = 0;
3465 snd_hda_add_verbs(codec, gpio_init);
3466 }
3467}
3468
9c5dc3bf
KY
3469/* turn on/off mic-mute LED per capture hook */
3470static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3471 struct snd_kcontrol *kcontrol,
3472 struct snd_ctl_elem_value *ucontrol)
3473{
3474 struct alc_spec *spec = codec->spec;
3475 unsigned int pinval, enable, disable;
3476
fc1fad93 3477 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
9c5dc3bf
KY
3478 pinval &= ~AC_PINCTL_VREFEN;
3479 enable = pinval | AC_PINCTL_VREF_80;
3480 disable = pinval | AC_PINCTL_VREF_HIZ;
3481
3482 if (!ucontrol)
3483 return;
3484
3485 if (ucontrol->value.integer.value[0] ||
3486 ucontrol->value.integer.value[1])
3487 pinval = disable;
3488 else
3489 pinval = enable;
3490
3491 if (spec->cap_mute_led_nid)
3492 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3493}
3494
3495static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3496 const struct hda_fixup *fix, int action)
3497{
3498 struct alc_spec *spec = codec->spec;
3499 static const struct hda_verb gpio_init[] = {
3500 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3501 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3502 {}
3503 };
3504
3505 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3506 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3507 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3508 spec->gpio_led = 0;
3509 spec->cap_mute_led_nid = 0x18;
3510 snd_hda_add_verbs(codec, gpio_init);
50dd9050 3511 codec->power_filter = led_power_filter;
9c5dc3bf
KY
3512 }
3513}
3514
3515static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3516 const struct hda_fixup *fix, int action)
3517{
3518 struct alc_spec *spec = codec->spec;
3519
3520 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3521 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3522 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3523 spec->mute_led_polarity = 0;
3524 spec->mute_led_nid = 0x1a;
3525 spec->cap_mute_led_nid = 0x18;
3526 spec->gen.vmaster_mute_enum = 1;
3527 codec->power_filter = led_power_filter;
3528 }
3529}
3530
73bdd597
DH
3531static void alc_headset_mode_unplugged(struct hda_codec *codec)
3532{
73bdd597 3533 switch (codec->vendor_id) {
9a22a8f5
KY
3534 case 0x10ec0255:
3535 /* LDO and MISC control */
3536 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3537 /* UAJ function set to menual mode */
3538 alc_write_coef_idx(codec, 0x45, 0xd089);
3539 /* Direct Drive HP Amp control(Set to verb control)*/
98b24883 3540 alc_update_coefex_idx(codec, 0x57, 0x05, 1<<14, 0);
9a22a8f5
KY
3541 /* Set MIC2 Vref gate with HP */
3542 alc_write_coef_idx(codec, 0x06, 0x6104);
3543 /* Direct Drive HP Amp control */
3544 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3545 break;
13fd08a3 3546 case 0x10ec0233:
73bdd597
DH
3547 case 0x10ec0283:
3548 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3549 alc_write_coef_idx(codec, 0x45, 0xc429);
98b24883 3550 alc_update_coef_idx(codec, 0x35, 0x4000, 0);
73bdd597
DH
3551 alc_write_coef_idx(codec, 0x06, 0x2104);
3552 alc_write_coef_idx(codec, 0x1a, 0x0001);
3553 alc_write_coef_idx(codec, 0x26, 0x0004);
3554 alc_write_coef_idx(codec, 0x32, 0x42a3);
3555 break;
3556 case 0x10ec0292:
3557 alc_write_coef_idx(codec, 0x76, 0x000e);
3558 alc_write_coef_idx(codec, 0x6c, 0x2400);
3559 alc_write_coef_idx(codec, 0x18, 0x7308);
3560 alc_write_coef_idx(codec, 0x6b, 0xc429);
3561 break;
a22aa26f
KY
3562 case 0x10ec0293:
3563 /* SET Line1 JD to 0 */
98b24883 3564 alc_update_coef_idx(codec, 0x10, 7<<8, 6<<8);
a22aa26f 3565 /* SET charge pump by verb */
98b24883 3566 alc_update_coefex_idx(codec, 0x57, 0x05, 1<<15|1<<13, 0x0);
a22aa26f 3567 /* SET EN_OSW to 1 */
98b24883 3568 alc_update_coefex_idx(codec, 0x57, 0x03, 1<<10, 1<<10);
a22aa26f 3569 /* Combo JD gating with LINE1-VREFO */
98b24883 3570 alc_update_coef_idx(codec, 0x1a, 1<<3, 1<<3);
a22aa26f
KY
3571 /* Set to TRS type */
3572 alc_write_coef_idx(codec, 0x45, 0xc429);
3573 /* Combo Jack auto detect */
98b24883 3574 alc_update_coef_idx(codec, 0x4a, 0x000f, 0x000e);
a22aa26f 3575 break;
73bdd597
DH
3576 case 0x10ec0668:
3577 alc_write_coef_idx(codec, 0x15, 0x0d40);
3578 alc_write_coef_idx(codec, 0xb7, 0x802b);
3579 break;
3580 }
4e76a883 3581 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
73bdd597
DH
3582}
3583
3584
3585static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3586 hda_nid_t mic_pin)
3587{
73bdd597 3588 switch (codec->vendor_id) {
9a22a8f5
KY
3589 case 0x10ec0255:
3590 alc_write_coef_idx(codec, 0x45, 0xc489);
3591 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3592 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3593 /* Set MIC2 Vref gate to normal */
3594 alc_write_coef_idx(codec, 0x06, 0x6100);
3595 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3596 break;
13fd08a3 3597 case 0x10ec0233:
73bdd597
DH
3598 case 0x10ec0283:
3599 alc_write_coef_idx(codec, 0x45, 0xc429);
3600 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
98b24883 3601 alc_update_coef_idx(codec, 0x35, 0, 1<<14);
73bdd597
DH
3602 alc_write_coef_idx(codec, 0x06, 0x2100);
3603 alc_write_coef_idx(codec, 0x1a, 0x0021);
3604 alc_write_coef_idx(codec, 0x26, 0x008c);
3605 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3606 break;
3607 case 0x10ec0292:
3608 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3609 alc_write_coef_idx(codec, 0x19, 0xa208);
3610 alc_write_coef_idx(codec, 0x2e, 0xacf0);
3611 break;
a22aa26f
KY
3612 case 0x10ec0293:
3613 /* Set to TRS mode */
3614 alc_write_coef_idx(codec, 0x45, 0xc429);
3615 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3616 /* SET charge pump by verb */
98b24883 3617 alc_update_coefex_idx(codec, 0x57, 0x05, 0, 1<<15|1<<13);
a22aa26f 3618 /* SET EN_OSW to 0 */
98b24883 3619 alc_update_coefex_idx(codec, 0x57, 0x03, 1<<10, 0);
a22aa26f 3620 /* Combo JD gating without LINE1-VREFO */
98b24883 3621 alc_update_coef_idx(codec, 0x1a, 1<<3, 0);
a22aa26f
KY
3622 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3623 break;
73bdd597
DH
3624 case 0x10ec0668:
3625 alc_write_coef_idx(codec, 0x11, 0x0001);
3626 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3627 alc_write_coef_idx(codec, 0xb7, 0x802b);
3628 alc_write_coef_idx(codec, 0xb5, 0x1040);
98b24883 3629 alc_update_coef_idx(codec, 0xc3, 0, 1<<12);
73bdd597
DH
3630 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3631 break;
3632 }
4e76a883 3633 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
73bdd597
DH
3634}
3635
3636static void alc_headset_mode_default(struct hda_codec *codec)
3637{
3638 switch (codec->vendor_id) {
9a22a8f5
KY
3639 case 0x10ec0255:
3640 alc_write_coef_idx(codec, 0x45, 0xc089);
3641 alc_write_coef_idx(codec, 0x45, 0xc489);
3642 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3643 alc_write_coef_idx(codec, 0x49, 0x0049);
3644 break;
13fd08a3 3645 case 0x10ec0233:
73bdd597
DH
3646 case 0x10ec0283:
3647 alc_write_coef_idx(codec, 0x06, 0x2100);
3648 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3649 break;
3650 case 0x10ec0292:
3651 alc_write_coef_idx(codec, 0x76, 0x000e);
3652 alc_write_coef_idx(codec, 0x6c, 0x2400);
3653 alc_write_coef_idx(codec, 0x6b, 0xc429);
3654 alc_write_coef_idx(codec, 0x18, 0x7308);
3655 break;
a22aa26f
KY
3656 case 0x10ec0293:
3657 /* Combo Jack auto detect */
98b24883 3658 alc_update_coef_idx(codec, 0x4a, 0x000f, 0x000e);
a22aa26f
KY
3659 /* Set to TRS type */
3660 alc_write_coef_idx(codec, 0x45, 0xC429);
3661 /* Combo JD gating without LINE1-VREFO */
98b24883 3662 alc_update_coef_idx(codec, 0x1a, 1<<3, 0);
a22aa26f 3663 break;
73bdd597
DH
3664 case 0x10ec0668:
3665 alc_write_coef_idx(codec, 0x11, 0x0041);
3666 alc_write_coef_idx(codec, 0x15, 0x0d40);
3667 alc_write_coef_idx(codec, 0xb7, 0x802b);
3668 break;
3669 }
4e76a883 3670 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
73bdd597
DH
3671}
3672
3673/* Iphone type */
3674static void alc_headset_mode_ctia(struct hda_codec *codec)
3675{
3676 switch (codec->vendor_id) {
9a22a8f5
KY
3677 case 0x10ec0255:
3678 /* Set to CTIA type */
3679 alc_write_coef_idx(codec, 0x45, 0xd489);
3680 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3681 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3682 break;
13fd08a3 3683 case 0x10ec0233:
73bdd597
DH
3684 case 0x10ec0283:
3685 alc_write_coef_idx(codec, 0x45, 0xd429);
3686 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3687 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3688 break;
3689 case 0x10ec0292:
3690 alc_write_coef_idx(codec, 0x6b, 0xd429);
3691 alc_write_coef_idx(codec, 0x76, 0x0008);
3692 alc_write_coef_idx(codec, 0x18, 0x7388);
3693 break;
a22aa26f
KY
3694 case 0x10ec0293:
3695 /* Set to ctia type */
3696 alc_write_coef_idx(codec, 0x45, 0xd429);
3697 /* SET Line1 JD to 1 */
98b24883 3698 alc_update_coef_idx(codec, 0x10, 7<<8, 7<<8);
a22aa26f 3699 break;
73bdd597 3700 case 0x10ec0668:
d59915d0 3701 alc_write_coef_idx(codec, 0x11, 0x0001);
73bdd597
DH
3702 alc_write_coef_idx(codec, 0x15, 0x0d60);
3703 alc_write_coef_idx(codec, 0xc3, 0x0000);
3704 break;
3705 }
4e76a883 3706 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
73bdd597
DH
3707}
3708
3709/* Nokia type */
3710static void alc_headset_mode_omtp(struct hda_codec *codec)
3711{
3712 switch (codec->vendor_id) {
9a22a8f5
KY
3713 case 0x10ec0255:
3714 /* Set to OMTP Type */
3715 alc_write_coef_idx(codec, 0x45, 0xe489);
3716 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3717 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3718 break;
13fd08a3 3719 case 0x10ec0233:
73bdd597
DH
3720 case 0x10ec0283:
3721 alc_write_coef_idx(codec, 0x45, 0xe429);
3722 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3723 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3724 break;
3725 case 0x10ec0292:
3726 alc_write_coef_idx(codec, 0x6b, 0xe429);
3727 alc_write_coef_idx(codec, 0x76, 0x0008);
3728 alc_write_coef_idx(codec, 0x18, 0x7388);
3729 break;
a22aa26f
KY
3730 case 0x10ec0293:
3731 /* Set to omtp type */
3732 alc_write_coef_idx(codec, 0x45, 0xe429);
3733 /* SET Line1 JD to 1 */
98b24883 3734 alc_update_coef_idx(codec, 0x10, 7<<8, 7<<8);
a22aa26f 3735 break;
73bdd597 3736 case 0x10ec0668:
d59915d0 3737 alc_write_coef_idx(codec, 0x11, 0x0001);
73bdd597
DH
3738 alc_write_coef_idx(codec, 0x15, 0x0d50);
3739 alc_write_coef_idx(codec, 0xc3, 0x0000);
3740 break;
3741 }
4e76a883 3742 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
73bdd597
DH
3743}
3744
3745static void alc_determine_headset_type(struct hda_codec *codec)
3746{
3747 int val;
3748 bool is_ctia = false;
3749 struct alc_spec *spec = codec->spec;
3750
3751 switch (codec->vendor_id) {
9a22a8f5
KY
3752 case 0x10ec0255:
3753 /* combo jack auto switch control(Check type)*/
3754 alc_write_coef_idx(codec, 0x45, 0xd089);
3755 /* combo jack auto switch control(Vref conteol) */
3756 alc_write_coef_idx(codec, 0x49, 0x0149);
3757 msleep(300);
3758 val = alc_read_coef_idx(codec, 0x46);
3759 is_ctia = (val & 0x0070) == 0x0070;
3760 break;
13fd08a3 3761 case 0x10ec0233:
73bdd597
DH
3762 case 0x10ec0283:
3763 alc_write_coef_idx(codec, 0x45, 0xd029);
3764 msleep(300);
3765 val = alc_read_coef_idx(codec, 0x46);
3766 is_ctia = (val & 0x0070) == 0x0070;
3767 break;
3768 case 0x10ec0292:
3769 alc_write_coef_idx(codec, 0x6b, 0xd429);
3770 msleep(300);
3771 val = alc_read_coef_idx(codec, 0x6c);
3772 is_ctia = (val & 0x001c) == 0x001c;
3773 break;
a22aa26f
KY
3774 case 0x10ec0293:
3775 /* Combo Jack auto detect */
98b24883 3776 alc_update_coef_idx(codec, 0x4a, 0x000f, 0x0008);
a22aa26f
KY
3777 /* Set to ctia type */
3778 alc_write_coef_idx(codec, 0x45, 0xD429);
3779 msleep(300);
3780 val = alc_read_coef_idx(codec, 0x46);
3781 is_ctia = (val & 0x0070) == 0x0070;
3782 break;
73bdd597
DH
3783 case 0x10ec0668:
3784 alc_write_coef_idx(codec, 0x11, 0x0001);
3785 alc_write_coef_idx(codec, 0xb7, 0x802b);
3786 alc_write_coef_idx(codec, 0x15, 0x0d60);
3787 alc_write_coef_idx(codec, 0xc3, 0x0c00);
3788 msleep(300);
3789 val = alc_read_coef_idx(codec, 0xbe);
3790 is_ctia = (val & 0x1c02) == 0x1c02;
3791 break;
3792 }
3793
4e76a883 3794 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
73bdd597
DH
3795 is_ctia ? "yes" : "no");
3796 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3797}
3798
3799static void alc_update_headset_mode(struct hda_codec *codec)
3800{
3801 struct alc_spec *spec = codec->spec;
3802
3803 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
3804 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3805
3806 int new_headset_mode;
3807
3808 if (!snd_hda_jack_detect(codec, hp_pin))
3809 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
3810 else if (mux_pin == spec->headset_mic_pin)
3811 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
3812 else if (mux_pin == spec->headphone_mic_pin)
3813 new_headset_mode = ALC_HEADSET_MODE_MIC;
3814 else
3815 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
3816
5959a6bc
DH
3817 if (new_headset_mode == spec->current_headset_mode) {
3818 snd_hda_gen_update_outputs(codec);
73bdd597 3819 return;
5959a6bc 3820 }
73bdd597
DH
3821
3822 switch (new_headset_mode) {
3823 case ALC_HEADSET_MODE_UNPLUGGED:
3824 alc_headset_mode_unplugged(codec);
3825 spec->gen.hp_jack_present = false;
3826 break;
3827 case ALC_HEADSET_MODE_HEADSET:
3828 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
3829 alc_determine_headset_type(codec);
3830 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
3831 alc_headset_mode_ctia(codec);
3832 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
3833 alc_headset_mode_omtp(codec);
3834 spec->gen.hp_jack_present = true;
3835 break;
3836 case ALC_HEADSET_MODE_MIC:
3837 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
3838 spec->gen.hp_jack_present = false;
3839 break;
3840 case ALC_HEADSET_MODE_HEADPHONE:
3841 alc_headset_mode_default(codec);
3842 spec->gen.hp_jack_present = true;
3843 break;
3844 }
3845 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
3846 snd_hda_set_pin_ctl_cache(codec, hp_pin,
3847 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3848 if (spec->headphone_mic_pin)
3849 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
3850 PIN_VREFHIZ);
3851 }
3852 spec->current_headset_mode = new_headset_mode;
3853
3854 snd_hda_gen_update_outputs(codec);
3855}
3856
3857static void alc_update_headset_mode_hook(struct hda_codec *codec,
7fe30711
TI
3858 struct snd_kcontrol *kcontrol,
3859 struct snd_ctl_elem_value *ucontrol)
73bdd597
DH
3860{
3861 alc_update_headset_mode(codec);
3862}
3863
3864static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack)
3865{
3866 struct alc_spec *spec = codec->spec;
5db4d34b 3867 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
73bdd597
DH
3868 snd_hda_gen_hp_automute(codec, jack);
3869}
3870
3871static void alc_probe_headset_mode(struct hda_codec *codec)
3872{
3873 int i;
3874 struct alc_spec *spec = codec->spec;
3875 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3876
3877 /* Find mic pins */
3878 for (i = 0; i < cfg->num_inputs; i++) {
3879 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
3880 spec->headset_mic_pin = cfg->inputs[i].pin;
3881 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
3882 spec->headphone_mic_pin = cfg->inputs[i].pin;
3883 }
3884
3885 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
3886 spec->gen.automute_hook = alc_update_headset_mode;
3887 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
3888}
3889
3890static void alc_fixup_headset_mode(struct hda_codec *codec,
3891 const struct hda_fixup *fix, int action)
3892{
3893 struct alc_spec *spec = codec->spec;
3894
3895 switch (action) {
3896 case HDA_FIXUP_ACT_PRE_PROBE:
3897 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
3898 break;
3899 case HDA_FIXUP_ACT_PROBE:
3900 alc_probe_headset_mode(codec);
3901 break;
3902 case HDA_FIXUP_ACT_INIT:
3903 spec->current_headset_mode = 0;
3904 alc_update_headset_mode(codec);
3905 break;
3906 }
3907}
3908
3909static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
3910 const struct hda_fixup *fix, int action)
3911{
3912 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3913 struct alc_spec *spec = codec->spec;
3914 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3915 }
3916 else
3917 alc_fixup_headset_mode(codec, fix, action);
3918}
3919
31278997
KY
3920static void alc255_set_default_jack_type(struct hda_codec *codec)
3921{
3922 /* Set to iphone type */
3923 alc_write_coef_idx(codec, 0x1b, 0x880b);
3924 alc_write_coef_idx(codec, 0x45, 0xd089);
3925 alc_write_coef_idx(codec, 0x1b, 0x080b);
3926 alc_write_coef_idx(codec, 0x46, 0x0004);
3927 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3928 msleep(30);
3929}
3930
9a22a8f5
KY
3931static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
3932 const struct hda_fixup *fix, int action)
3933{
3934 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
31278997 3935 alc255_set_default_jack_type(codec);
9a22a8f5
KY
3936 }
3937 alc_fixup_headset_mode(codec, fix, action);
3938}
3939
31278997
KY
3940static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
3941 const struct hda_fixup *fix, int action)
3942{
3943 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3944 struct alc_spec *spec = codec->spec;
3945 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3946 alc255_set_default_jack_type(codec);
3947 }
3948 else
3949 alc_fixup_headset_mode(codec, fix, action);
3950}
3951
493a52a9
HW
3952static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
3953 const struct hda_fixup *fix, int action)
3954{
3955 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3956 struct alc_spec *spec = codec->spec;
3957 spec->gen.auto_mute_via_amp = 1;
3958 }
3959}
3960
9b745ab8
TI
3961static void alc_no_shutup(struct hda_codec *codec)
3962{
3963}
3964
3965static void alc_fixup_no_shutup(struct hda_codec *codec,
3966 const struct hda_fixup *fix, int action)
3967{
3968 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3969 struct alc_spec *spec = codec->spec;
3970 spec->shutup = alc_no_shutup;
3971 }
3972}
3973
5e6db669
GM
3974static void alc_fixup_disable_aamix(struct hda_codec *codec,
3975 const struct hda_fixup *fix, int action)
3976{
3977 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3978 struct alc_spec *spec = codec->spec;
3979 /* Disable AA-loopback as it causes white noise */
3980 spec->gen.mixer_nid = 0;
3981 }
3982}
3983
033b0a7c
GM
3984static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
3985 hda_nid_t nid,
3986 unsigned int power_state)
3987{
3988 struct alc_spec *spec = codec->spec;
3989
3990 /* Avoid pop noises when headphones are plugged in */
3991 if (spec->gen.hp_jack_present)
de3da4f6 3992 if (nid == codec->afg || nid == 0x02 || nid == 0x15)
033b0a7c
GM
3993 return AC_PWRST_D0;
3994 return power_state;
3995}
3996
3997static void alc_fixup_dell_xps13(struct hda_codec *codec,
3998 const struct hda_fixup *fix, int action)
3999{
4000 if (action == HDA_FIXUP_ACT_PROBE) {
4001 struct alc_spec *spec = codec->spec;
f38663ab
GM
4002 struct hda_input_mux *imux = &spec->gen.input_mux;
4003 int i;
4004
033b0a7c
GM
4005 spec->shutup = alc_no_shutup;
4006 codec->power_filter = alc_power_filter_xps13;
f38663ab
GM
4007
4008 /* Make the internal mic the default input source. */
4009 for (i = 0; i < imux->num_items; i++) {
4010 if (spec->gen.imux_pins[i] == 0x12) {
4011 spec->gen.cur_mux[0] = i;
4012 break;
4013 }
4014 }
033b0a7c
GM
4015 }
4016}
4017
73bdd597
DH
4018static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
4019 const struct hda_fixup *fix, int action)
4020{
4021 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
73bdd597 4022 alc_write_coef_idx(codec, 0xc4, 0x8000);
98b24883 4023 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
73bdd597
DH
4024 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
4025 }
4026 alc_fixup_headset_mode(codec, fix, action);
4027}
4028
bde7bc60
CCC
4029/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
4030static int find_ext_mic_pin(struct hda_codec *codec)
4031{
4032 struct alc_spec *spec = codec->spec;
4033 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4034 hda_nid_t nid;
4035 unsigned int defcfg;
4036 int i;
4037
4038 for (i = 0; i < cfg->num_inputs; i++) {
4039 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4040 continue;
4041 nid = cfg->inputs[i].pin;
4042 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4043 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
4044 continue;
4045 return nid;
4046 }
4047
4048 return 0;
4049}
4050
08a978db 4051static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
1727a771 4052 const struct hda_fixup *fix,
08a978db
DR
4053 int action)
4054{
4055 struct alc_spec *spec = codec->spec;
4056
0db75790 4057 if (action == HDA_FIXUP_ACT_PROBE) {
bde7bc60
CCC
4058 int mic_pin = find_ext_mic_pin(codec);
4059 int hp_pin = spec->gen.autocfg.hp_pins[0];
4060
4061 if (snd_BUG_ON(!mic_pin || !hp_pin))
0db75790 4062 return;
bde7bc60 4063 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
0db75790 4064 }
08a978db 4065}
693b613d 4066
3e0d611b
DH
4067static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
4068 const struct hda_fixup *fix,
4069 int action)
4070{
4071 struct alc_spec *spec = codec->spec;
4072 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4073 int i;
4074
4075 /* The mic boosts on level 2 and 3 are too noisy
4076 on the internal mic input.
4077 Therefore limit the boost to 0 or 1. */
4078
4079 if (action != HDA_FIXUP_ACT_PROBE)
4080 return;
4081
4082 for (i = 0; i < cfg->num_inputs; i++) {
4083 hda_nid_t nid = cfg->inputs[i].pin;
4084 unsigned int defcfg;
4085 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4086 continue;
4087 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4088 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
4089 continue;
4090
4091 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
4092 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
4093 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4094 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
4095 (0 << AC_AMPCAP_MUTE_SHIFT));
4096 }
4097}
4098
cd217a63
KY
4099static void alc283_hp_automute_hook(struct hda_codec *codec,
4100 struct hda_jack_tbl *jack)
4101{
4102 struct alc_spec *spec = codec->spec;
4103 int vref;
4104
4105 msleep(200);
4106 snd_hda_gen_hp_automute(codec, jack);
4107
4108 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4109
4110 msleep(600);
4111 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4112 vref);
4113}
4114
cd217a63
KY
4115static void alc283_fixup_chromebook(struct hda_codec *codec,
4116 const struct hda_fixup *fix, int action)
4117{
4118 struct alc_spec *spec = codec->spec;
cd217a63
KY
4119
4120 switch (action) {
4121 case HDA_FIXUP_ACT_PRE_PROBE:
0202e99c 4122 snd_hda_override_wcaps(codec, 0x03, 0);
d2e92709
TI
4123 /* Disable AA-loopback as it causes white noise */
4124 spec->gen.mixer_nid = 0;
38070219 4125 break;
0202e99c 4126 case HDA_FIXUP_ACT_INIT:
de9481cb
KY
4127 /* MIC2-VREF control */
4128 /* Set to manual mode */
98b24883 4129 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
0202e99c 4130 /* Enable Line1 input control by verb */
98b24883 4131 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
0202e99c
KY
4132 break;
4133 }
4134}
4135
4136static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
4137 const struct hda_fixup *fix, int action)
4138{
4139 struct alc_spec *spec = codec->spec;
0202e99c
KY
4140
4141 switch (action) {
4142 case HDA_FIXUP_ACT_PRE_PROBE:
cd217a63 4143 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
38070219
KY
4144 break;
4145 case HDA_FIXUP_ACT_INIT:
cd217a63
KY
4146 /* MIC2-VREF control */
4147 /* Set to manual mode */
98b24883 4148 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
cd217a63
KY
4149 break;
4150 }
4151}
4152
7bba2157
TI
4153/* mute tablet speaker pin (0x14) via dock plugging in addition */
4154static void asus_tx300_automute(struct hda_codec *codec)
4155{
4156 struct alc_spec *spec = codec->spec;
4157 snd_hda_gen_update_outputs(codec);
4158 if (snd_hda_jack_detect(codec, 0x1b))
4159 spec->gen.mute_bits |= (1ULL << 0x14);
4160}
4161
4162static void alc282_fixup_asus_tx300(struct hda_codec *codec,
4163 const struct hda_fixup *fix, int action)
4164{
4165 struct alc_spec *spec = codec->spec;
4166 /* TX300 needs to set up GPIO2 for the speaker amp */
4167 static const struct hda_verb gpio2_verbs[] = {
4168 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4169 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4170 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
4171 {}
4172 };
4173 static const struct hda_pintbl dock_pins[] = {
4174 { 0x1b, 0x21114000 }, /* dock speaker pin */
4175 {}
4176 };
4177 struct snd_kcontrol *kctl;
4178
4179 switch (action) {
4180 case HDA_FIXUP_ACT_PRE_PROBE:
4181 snd_hda_add_verbs(codec, gpio2_verbs);
4182 snd_hda_apply_pincfgs(codec, dock_pins);
4183 spec->gen.auto_mute_via_amp = 1;
4184 spec->gen.automute_hook = asus_tx300_automute;
4185 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4186 HDA_GEN_HP_EVENT,
4187 snd_hda_gen_hp_automute);
4188 break;
4189 case HDA_FIXUP_ACT_BUILD:
4190 /* this is a bit tricky; give more sane names for the main
4191 * (tablet) speaker and the dock speaker, respectively
4192 */
4193 kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch");
4194 if (kctl)
4195 strcpy(kctl->id.name, "Dock Speaker Playback Switch");
4196 kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch");
4197 if (kctl)
4198 strcpy(kctl->id.name, "Speaker Playback Switch");
4199 break;
4200 }
4201}
4202
338cae56
DH
4203static void alc290_fixup_mono_speakers(struct hda_codec *codec,
4204 const struct hda_fixup *fix, int action)
4205{
0f4881dc
DH
4206 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4207 /* DAC node 0x03 is giving mono output. We therefore want to
4208 make sure 0x14 (front speaker) and 0x15 (headphones) use the
4209 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
4210 hda_nid_t conn1[2] = { 0x0c };
4211 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
4212 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
4213 }
338cae56
DH
4214}
4215
b317b032
TI
4216/* for hda_fixup_thinkpad_acpi() */
4217#include "thinkpad_helper.c"
b67ae3f1 4218
00ef9940
HW
4219/* for dell wmi mic mute led */
4220#include "dell_wmi_helper.c"
4221
1d045db9
TI
4222enum {
4223 ALC269_FIXUP_SONY_VAIO,
4224 ALC275_FIXUP_SONY_VAIO_GPIO2,
4225 ALC269_FIXUP_DELL_M101Z,
4226 ALC269_FIXUP_SKU_IGNORE,
4227 ALC269_FIXUP_ASUS_G73JW,
4228 ALC269_FIXUP_LENOVO_EAPD,
4229 ALC275_FIXUP_SONY_HWEQ,
e9bd7d5c 4230 ALC275_FIXUP_SONY_DISABLE_AAMIX,
1d045db9 4231 ALC271_FIXUP_DMIC,
017f2a10 4232 ALC269_FIXUP_PCM_44K,
adabb3ec 4233 ALC269_FIXUP_STEREO_DMIC,
7c478f03 4234 ALC269_FIXUP_HEADSET_MIC,
24519911
TI
4235 ALC269_FIXUP_QUANTA_MUTE,
4236 ALC269_FIXUP_LIFEBOOK,
2041d564 4237 ALC269_FIXUP_LIFEBOOK_EXTMIC,
a4297b5d
TI
4238 ALC269_FIXUP_AMIC,
4239 ALC269_FIXUP_DMIC,
4240 ALC269VB_FIXUP_AMIC,
4241 ALC269VB_FIXUP_DMIC,
08fb0d0e 4242 ALC269_FIXUP_HP_MUTE_LED,
d06ac143 4243 ALC269_FIXUP_HP_MUTE_LED_MIC1,
08fb0d0e 4244 ALC269_FIXUP_HP_MUTE_LED_MIC2,
9f5c6faf 4245 ALC269_FIXUP_HP_GPIO_LED,
9c5dc3bf
KY
4246 ALC269_FIXUP_HP_GPIO_MIC1_LED,
4247 ALC269_FIXUP_HP_LINE1_MIC1_LED,
693b613d 4248 ALC269_FIXUP_INV_DMIC,
108cc108 4249 ALC269_FIXUP_LENOVO_DOCK,
9b745ab8 4250 ALC269_FIXUP_NO_SHUTUP,
88cfcf86 4251 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
108cc108 4252 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
73bdd597
DH
4253 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
4254 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
338cae56 4255 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
73bdd597
DH
4256 ALC269_FIXUP_HEADSET_MODE,
4257 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
d240d1dc
DH
4258 ALC269_FIXUP_ASUS_X101_FUNC,
4259 ALC269_FIXUP_ASUS_X101_VERB,
4260 ALC269_FIXUP_ASUS_X101,
08a978db
DR
4261 ALC271_FIXUP_AMIC_MIC2,
4262 ALC271_FIXUP_HP_GATE_MIC_JACK,
b1e8972e 4263 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
42397004 4264 ALC269_FIXUP_ACER_AC700,
3e0d611b 4265 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
2cede303 4266 ALC269VB_FIXUP_ASUS_ZENBOOK,
23870831 4267 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
8e35cd4a 4268 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
02b504d9 4269 ALC269VB_FIXUP_ORDISSIMO_EVE2,
cd217a63 4270 ALC283_FIXUP_CHROME_BOOK,
0202e99c 4271 ALC283_FIXUP_SENSE_COMBO_JACK,
7bba2157 4272 ALC282_FIXUP_ASUS_TX300,
1bb3e062 4273 ALC283_FIXUP_INT_MIC,
338cae56 4274 ALC290_FIXUP_MONO_SPEAKERS,
0f4881dc
DH
4275 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4276 ALC290_FIXUP_SUBWOOFER,
4277 ALC290_FIXUP_SUBWOOFER_HSJACK,
b67ae3f1 4278 ALC269_FIXUP_THINKPAD_ACPI,
9a22a8f5 4279 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
31278997 4280 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9a22a8f5 4281 ALC255_FIXUP_HEADSET_MODE,
31278997 4282 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
a22aa26f 4283 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
1c37c223 4284 ALC292_FIXUP_TPT440_DOCK,
9dc12862 4285 ALC283_FIXUP_BXBT2807_MIC,
00ef9940 4286 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
f1d4e28b
KY
4287};
4288
1727a771 4289static const struct hda_fixup alc269_fixups[] = {
1d045db9 4290 [ALC269_FIXUP_SONY_VAIO] = {
fd108215
TI
4291 .type = HDA_FIXUP_PINCTLS,
4292 .v.pins = (const struct hda_pintbl[]) {
4293 {0x19, PIN_VREFGRD},
1d045db9
TI
4294 {}
4295 }
f1d4e28b 4296 },
1d045db9 4297 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
1727a771 4298 .type = HDA_FIXUP_VERBS,
1d045db9
TI
4299 .v.verbs = (const struct hda_verb[]) {
4300 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
4301 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
4302 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4303 { }
4304 },
4305 .chained = true,
4306 .chain_id = ALC269_FIXUP_SONY_VAIO
4307 },
4308 [ALC269_FIXUP_DELL_M101Z] = {
1727a771 4309 .type = HDA_FIXUP_VERBS,
1d045db9
TI
4310 .v.verbs = (const struct hda_verb[]) {
4311 /* Enables internal speaker */
4312 {0x20, AC_VERB_SET_COEF_INDEX, 13},
4313 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4314 {}
4315 }
4316 },
4317 [ALC269_FIXUP_SKU_IGNORE] = {
1727a771 4318 .type = HDA_FIXUP_FUNC,
23d30f28 4319 .v.func = alc_fixup_sku_ignore,
1d045db9
TI
4320 },
4321 [ALC269_FIXUP_ASUS_G73JW] = {
1727a771
TI
4322 .type = HDA_FIXUP_PINS,
4323 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
4324 { 0x17, 0x99130111 }, /* subwoofer */
4325 { }
4326 }
4327 },
4328 [ALC269_FIXUP_LENOVO_EAPD] = {
1727a771 4329 .type = HDA_FIXUP_VERBS,
1d045db9
TI
4330 .v.verbs = (const struct hda_verb[]) {
4331 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4332 {}
4333 }
4334 },
4335 [ALC275_FIXUP_SONY_HWEQ] = {
1727a771 4336 .type = HDA_FIXUP_FUNC,
1d045db9
TI
4337 .v.func = alc269_fixup_hweq,
4338 .chained = true,
4339 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
4340 },
e9bd7d5c
TI
4341 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
4342 .type = HDA_FIXUP_FUNC,
4343 .v.func = alc_fixup_disable_aamix,
4344 .chained = true,
4345 .chain_id = ALC269_FIXUP_SONY_VAIO
4346 },
1d045db9 4347 [ALC271_FIXUP_DMIC] = {
1727a771 4348 .type = HDA_FIXUP_FUNC,
1d045db9 4349 .v.func = alc271_fixup_dmic,
f1d4e28b 4350 },
017f2a10 4351 [ALC269_FIXUP_PCM_44K] = {
1727a771 4352 .type = HDA_FIXUP_FUNC,
017f2a10 4353 .v.func = alc269_fixup_pcm_44k,
012e7eb1
DH
4354 .chained = true,
4355 .chain_id = ALC269_FIXUP_QUANTA_MUTE
017f2a10 4356 },
adabb3ec 4357 [ALC269_FIXUP_STEREO_DMIC] = {
1727a771 4358 .type = HDA_FIXUP_FUNC,
adabb3ec
TI
4359 .v.func = alc269_fixup_stereo_dmic,
4360 },
7c478f03
DH
4361 [ALC269_FIXUP_HEADSET_MIC] = {
4362 .type = HDA_FIXUP_FUNC,
4363 .v.func = alc269_fixup_headset_mic,
4364 },
24519911 4365 [ALC269_FIXUP_QUANTA_MUTE] = {
1727a771 4366 .type = HDA_FIXUP_FUNC,
24519911
TI
4367 .v.func = alc269_fixup_quanta_mute,
4368 },
4369 [ALC269_FIXUP_LIFEBOOK] = {
1727a771
TI
4370 .type = HDA_FIXUP_PINS,
4371 .v.pins = (const struct hda_pintbl[]) {
24519911
TI
4372 { 0x1a, 0x2101103f }, /* dock line-out */
4373 { 0x1b, 0x23a11040 }, /* dock mic-in */
4374 { }
4375 },
4376 .chained = true,
4377 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4378 },
2041d564
DH
4379 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
4380 .type = HDA_FIXUP_PINS,
4381 .v.pins = (const struct hda_pintbl[]) {
4382 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
4383 { }
4384 },
4385 },
a4297b5d 4386 [ALC269_FIXUP_AMIC] = {
1727a771
TI
4387 .type = HDA_FIXUP_PINS,
4388 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4389 { 0x14, 0x99130110 }, /* speaker */
4390 { 0x15, 0x0121401f }, /* HP out */
4391 { 0x18, 0x01a19c20 }, /* mic */
4392 { 0x19, 0x99a3092f }, /* int-mic */
4393 { }
4394 },
4395 },
4396 [ALC269_FIXUP_DMIC] = {
1727a771
TI
4397 .type = HDA_FIXUP_PINS,
4398 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4399 { 0x12, 0x99a3092f }, /* int-mic */
4400 { 0x14, 0x99130110 }, /* speaker */
4401 { 0x15, 0x0121401f }, /* HP out */
4402 { 0x18, 0x01a19c20 }, /* mic */
4403 { }
4404 },
4405 },
4406 [ALC269VB_FIXUP_AMIC] = {
1727a771
TI
4407 .type = HDA_FIXUP_PINS,
4408 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4409 { 0x14, 0x99130110 }, /* speaker */
4410 { 0x18, 0x01a19c20 }, /* mic */
4411 { 0x19, 0x99a3092f }, /* int-mic */
4412 { 0x21, 0x0121401f }, /* HP out */
4413 { }
4414 },
4415 },
2267ea97 4416 [ALC269VB_FIXUP_DMIC] = {
1727a771
TI
4417 .type = HDA_FIXUP_PINS,
4418 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4419 { 0x12, 0x99a3092f }, /* int-mic */
4420 { 0x14, 0x99130110 }, /* speaker */
4421 { 0x18, 0x01a19c20 }, /* mic */
4422 { 0x21, 0x0121401f }, /* HP out */
4423 { }
4424 },
4425 },
08fb0d0e 4426 [ALC269_FIXUP_HP_MUTE_LED] = {
1727a771 4427 .type = HDA_FIXUP_FUNC,
08fb0d0e 4428 .v.func = alc269_fixup_hp_mute_led,
6d3cd5d4 4429 },
d06ac143
DH
4430 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
4431 .type = HDA_FIXUP_FUNC,
4432 .v.func = alc269_fixup_hp_mute_led_mic1,
4433 },
08fb0d0e 4434 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
1727a771 4435 .type = HDA_FIXUP_FUNC,
08fb0d0e 4436 .v.func = alc269_fixup_hp_mute_led_mic2,
420b0feb 4437 },
9f5c6faf
TI
4438 [ALC269_FIXUP_HP_GPIO_LED] = {
4439 .type = HDA_FIXUP_FUNC,
4440 .v.func = alc269_fixup_hp_gpio_led,
4441 },
9c5dc3bf
KY
4442 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
4443 .type = HDA_FIXUP_FUNC,
4444 .v.func = alc269_fixup_hp_gpio_mic1_led,
4445 },
4446 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
4447 .type = HDA_FIXUP_FUNC,
4448 .v.func = alc269_fixup_hp_line1_mic1_led,
4449 },
693b613d 4450 [ALC269_FIXUP_INV_DMIC] = {
1727a771 4451 .type = HDA_FIXUP_FUNC,
6e72aa5f 4452 .v.func = alc_fixup_inv_dmic_0x12,
693b613d 4453 },
9b745ab8
TI
4454 [ALC269_FIXUP_NO_SHUTUP] = {
4455 .type = HDA_FIXUP_FUNC,
4456 .v.func = alc_fixup_no_shutup,
4457 },
108cc108 4458 [ALC269_FIXUP_LENOVO_DOCK] = {
1727a771
TI
4459 .type = HDA_FIXUP_PINS,
4460 .v.pins = (const struct hda_pintbl[]) {
108cc108
DH
4461 { 0x19, 0x23a11040 }, /* dock mic */
4462 { 0x1b, 0x2121103f }, /* dock headphone */
4463 { }
4464 },
4465 .chained = true,
4466 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
4467 },
4468 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
1727a771 4469 .type = HDA_FIXUP_FUNC,
108cc108 4470 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
52129000
DH
4471 .chained = true,
4472 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
108cc108 4473 },
73bdd597
DH
4474 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4475 .type = HDA_FIXUP_PINS,
4476 .v.pins = (const struct hda_pintbl[]) {
4477 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4478 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4479 { }
4480 },
4481 .chained = true,
4482 .chain_id = ALC269_FIXUP_HEADSET_MODE
4483 },
4484 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4485 .type = HDA_FIXUP_PINS,
4486 .v.pins = (const struct hda_pintbl[]) {
4487 { 0x16, 0x21014020 }, /* dock line out */
4488 { 0x19, 0x21a19030 }, /* dock mic */
4489 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4490 { }
4491 },
4492 .chained = true,
4493 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4494 },
338cae56
DH
4495 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
4496 .type = HDA_FIXUP_PINS,
4497 .v.pins = (const struct hda_pintbl[]) {
4498 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4499 { }
4500 },
4501 .chained = true,
4502 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4503 },
73bdd597
DH
4504 [ALC269_FIXUP_HEADSET_MODE] = {
4505 .type = HDA_FIXUP_FUNC,
4506 .v.func = alc_fixup_headset_mode,
4507 },
4508 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4509 .type = HDA_FIXUP_FUNC,
4510 .v.func = alc_fixup_headset_mode_no_hp_mic,
4511 },
88cfcf86
DH
4512 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
4513 .type = HDA_FIXUP_PINS,
4514 .v.pins = (const struct hda_pintbl[]) {
4515 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4516 { }
4517 },
fbc78ad6
DH
4518 .chained = true,
4519 .chain_id = ALC269_FIXUP_HEADSET_MIC
88cfcf86 4520 },
d240d1dc
DH
4521 [ALC269_FIXUP_ASUS_X101_FUNC] = {
4522 .type = HDA_FIXUP_FUNC,
4523 .v.func = alc269_fixup_x101_headset_mic,
4524 },
4525 [ALC269_FIXUP_ASUS_X101_VERB] = {
4526 .type = HDA_FIXUP_VERBS,
4527 .v.verbs = (const struct hda_verb[]) {
4528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4529 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
4530 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
4531 { }
4532 },
4533 .chained = true,
4534 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
4535 },
4536 [ALC269_FIXUP_ASUS_X101] = {
4537 .type = HDA_FIXUP_PINS,
4538 .v.pins = (const struct hda_pintbl[]) {
4539 { 0x18, 0x04a1182c }, /* Headset mic */
4540 { }
4541 },
4542 .chained = true,
4543 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
4544 },
08a978db 4545 [ALC271_FIXUP_AMIC_MIC2] = {
1727a771
TI
4546 .type = HDA_FIXUP_PINS,
4547 .v.pins = (const struct hda_pintbl[]) {
08a978db
DR
4548 { 0x14, 0x99130110 }, /* speaker */
4549 { 0x19, 0x01a19c20 }, /* mic */
4550 { 0x1b, 0x99a7012f }, /* int-mic */
4551 { 0x21, 0x0121401f }, /* HP out */
4552 { }
4553 },
4554 },
4555 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
1727a771 4556 .type = HDA_FIXUP_FUNC,
08a978db
DR
4557 .v.func = alc271_hp_gate_mic_jack,
4558 .chained = true,
4559 .chain_id = ALC271_FIXUP_AMIC_MIC2,
4560 },
b1e8972e
OR
4561 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
4562 .type = HDA_FIXUP_FUNC,
4563 .v.func = alc269_fixup_limit_int_mic_boost,
4564 .chained = true,
4565 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
4566 },
42397004
DR
4567 [ALC269_FIXUP_ACER_AC700] = {
4568 .type = HDA_FIXUP_PINS,
4569 .v.pins = (const struct hda_pintbl[]) {
4570 { 0x12, 0x99a3092f }, /* int-mic */
4571 { 0x14, 0x99130110 }, /* speaker */
4572 { 0x18, 0x03a11c20 }, /* mic */
4573 { 0x1e, 0x0346101e }, /* SPDIF1 */
4574 { 0x21, 0x0321101f }, /* HP out */
4575 { }
4576 },
4577 .chained = true,
4578 .chain_id = ALC271_FIXUP_DMIC,
4579 },
3e0d611b
DH
4580 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
4581 .type = HDA_FIXUP_FUNC,
4582 .v.func = alc269_fixup_limit_int_mic_boost,
2793769f
DH
4583 .chained = true,
4584 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
3e0d611b 4585 },
2cede303
OR
4586 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
4587 .type = HDA_FIXUP_FUNC,
4588 .v.func = alc269_fixup_limit_int_mic_boost,
4589 .chained = true,
4590 .chain_id = ALC269VB_FIXUP_DMIC,
4591 },
23870831
TI
4592 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
4593 .type = HDA_FIXUP_VERBS,
4594 .v.verbs = (const struct hda_verb[]) {
4595 /* class-D output amp +5dB */
4596 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
4597 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
4598 {}
4599 },
4600 .chained = true,
4601 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
4602 },
8e35cd4a
DH
4603 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
4604 .type = HDA_FIXUP_FUNC,
4605 .v.func = alc269_fixup_limit_int_mic_boost,
4606 .chained = true,
4607 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
4608 },
02b504d9
AA
4609 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
4610 .type = HDA_FIXUP_PINS,
4611 .v.pins = (const struct hda_pintbl[]) {
4612 { 0x12, 0x99a3092f }, /* int-mic */
4613 { 0x18, 0x03a11d20 }, /* mic */
4614 { 0x19, 0x411111f0 }, /* Unused bogus pin */
4615 { }
4616 },
4617 },
cd217a63
KY
4618 [ALC283_FIXUP_CHROME_BOOK] = {
4619 .type = HDA_FIXUP_FUNC,
4620 .v.func = alc283_fixup_chromebook,
4621 },
0202e99c
KY
4622 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
4623 .type = HDA_FIXUP_FUNC,
4624 .v.func = alc283_fixup_sense_combo_jack,
4625 .chained = true,
4626 .chain_id = ALC283_FIXUP_CHROME_BOOK,
4627 },
7bba2157
TI
4628 [ALC282_FIXUP_ASUS_TX300] = {
4629 .type = HDA_FIXUP_FUNC,
4630 .v.func = alc282_fixup_asus_tx300,
4631 },
1bb3e062
KY
4632 [ALC283_FIXUP_INT_MIC] = {
4633 .type = HDA_FIXUP_VERBS,
4634 .v.verbs = (const struct hda_verb[]) {
4635 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
4636 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
4637 { }
4638 },
4639 .chained = true,
4640 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4641 },
0f4881dc
DH
4642 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
4643 .type = HDA_FIXUP_PINS,
4644 .v.pins = (const struct hda_pintbl[]) {
4645 { 0x17, 0x90170112 }, /* subwoofer */
4646 { }
4647 },
4648 .chained = true,
4649 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4650 },
4651 [ALC290_FIXUP_SUBWOOFER] = {
4652 .type = HDA_FIXUP_PINS,
4653 .v.pins = (const struct hda_pintbl[]) {
4654 { 0x17, 0x90170112 }, /* subwoofer */
4655 { }
4656 },
4657 .chained = true,
4658 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
4659 },
338cae56
DH
4660 [ALC290_FIXUP_MONO_SPEAKERS] = {
4661 .type = HDA_FIXUP_FUNC,
4662 .v.func = alc290_fixup_mono_speakers,
0f4881dc
DH
4663 },
4664 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
4665 .type = HDA_FIXUP_FUNC,
4666 .v.func = alc290_fixup_mono_speakers,
338cae56
DH
4667 .chained = true,
4668 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
4669 },
b67ae3f1
DH
4670 [ALC269_FIXUP_THINKPAD_ACPI] = {
4671 .type = HDA_FIXUP_FUNC,
b317b032 4672 .v.func = hda_fixup_thinkpad_acpi,
b67ae3f1 4673 },
9a22a8f5
KY
4674 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4675 .type = HDA_FIXUP_PINS,
4676 .v.pins = (const struct hda_pintbl[]) {
4677 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4678 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4679 { }
4680 },
4681 .chained = true,
4682 .chain_id = ALC255_FIXUP_HEADSET_MODE
4683 },
31278997
KY
4684 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4685 .type = HDA_FIXUP_PINS,
4686 .v.pins = (const struct hda_pintbl[]) {
4687 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4688 { }
4689 },
4690 .chained = true,
4691 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
4692 },
9a22a8f5
KY
4693 [ALC255_FIXUP_HEADSET_MODE] = {
4694 .type = HDA_FIXUP_FUNC,
4695 .v.func = alc_fixup_headset_mode_alc255,
4696 },
31278997
KY
4697 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4698 .type = HDA_FIXUP_FUNC,
4699 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
4700 },
a22aa26f
KY
4701 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4702 .type = HDA_FIXUP_PINS,
4703 .v.pins = (const struct hda_pintbl[]) {
4704 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4705 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4706 { }
4707 },
4708 .chained = true,
4709 .chain_id = ALC269_FIXUP_HEADSET_MODE
4710 },
1c37c223
TI
4711 [ALC292_FIXUP_TPT440_DOCK] = {
4712 .type = HDA_FIXUP_PINS,
4713 .v.pins = (const struct hda_pintbl[]) {
4714 { 0x16, 0x21211010 }, /* dock headphone */
4715 { 0x19, 0x21a11010 }, /* dock mic */
4716 { }
4717 },
4718 .chained = true,
4719 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4720 },
9dc12862
DD
4721 [ALC283_FIXUP_BXBT2807_MIC] = {
4722 .type = HDA_FIXUP_PINS,
4723 .v.pins = (const struct hda_pintbl[]) {
4724 { 0x19, 0x04a110f0 },
4725 { },
4726 },
4727 },
00ef9940
HW
4728 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
4729 .type = HDA_FIXUP_FUNC,
4730 .v.func = alc_fixup_dell_wmi,
4731 .chained_before = true,
4732 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
4733 },
4734
f1d4e28b
KY
4735};
4736
1d045db9 4737static const struct snd_pci_quirk alc269_fixup_tbl[] = {
a6b92b66 4738 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
693b613d
DH
4739 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
4740 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
aaedfb47
DH
4741 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
4742 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4743 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
b1e8972e 4744 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
aaedfb47 4745 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
73bdd597
DH
4746 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4747 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4748 SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4749 SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4750 SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4751 SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4752 SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4753 SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4754 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4755 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
05843c07
KY
4756 SND_PCI_QUIRK(0x1028, 0x05cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4757 SND_PCI_QUIRK(0x1028, 0x05cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
0f4881dc 4758 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
436c4a0c 4759 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
d81bf8cf 4760 SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
73bdd597
DH
4761 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4762 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4763 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4764 SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4765 SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4766 SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4767 SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4768 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4769 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4770 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3ee2102f 4771 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
cd6fb679
DH
4772 SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4773 SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
d81bf8cf
DH
4774 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4775 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3ee2102f 4776 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
00ef9940 4777 SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
6c29d68a 4778 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
b8362e70 4779 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
0f4881dc
DH
4780 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4781 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
00ef9940 4782 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
0f4881dc 4783 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
9a22a8f5 4784 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
a22aa26f
KY
4785 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4786 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
31278997
KY
4787 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4788 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
a1f3b5fa 4789 SND_PCI_QUIRK(0x1028, 0x0684, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
05843c07
KY
4790 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4791 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
a22aa26f
KY
4792 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4793 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
08fb0d0e 4794 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9f5c6faf 4795 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
d06ac143
DH
4796 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4797 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8e35cd4a 4798 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
c60666bd 4799 /* ALC282 */
549d8782
HW
4800 SND_PCI_QUIRK(0x103c, 0x21f8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4801 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4802 SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4803 SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 4804 SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4805 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4806 SND_PCI_QUIRK(0x103c, 0x2211, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4807 SND_PCI_QUIRK(0x103c, 0x2212, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 4808 SND_PCI_QUIRK(0x103c, 0x2213, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 4809 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
4810 SND_PCI_QUIRK(0x103c, 0x2234, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4811 SND_PCI_QUIRK(0x103c, 0x2235, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4812 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4813 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4814 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4815 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4816 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4817 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4818 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4819 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4820 SND_PCI_QUIRK(0x103c, 0x224a, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4821 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4822 SND_PCI_QUIRK(0x103c, 0x224c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4823 SND_PCI_QUIRK(0x103c, 0x224d, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
c60666bd
KY
4824 SND_PCI_QUIRK(0x103c, 0x2266, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4825 SND_PCI_QUIRK(0x103c, 0x2267, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4826 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4827 SND_PCI_QUIRK(0x103c, 0x2269, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4828 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4829 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4830 SND_PCI_QUIRK(0x103c, 0x226c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4831 SND_PCI_QUIRK(0x103c, 0x226d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4832 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4833 SND_PCI_QUIRK(0x103c, 0x226f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
4834 SND_PCI_QUIRK(0x103c, 0x227a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4835 SND_PCI_QUIRK(0x103c, 0x227b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4836 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4837 SND_PCI_QUIRK(0x103c, 0x22a0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4838 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4839 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4840 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4841 SND_PCI_QUIRK(0x103c, 0x22c0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4842 SND_PCI_QUIRK(0x103c, 0x22c1, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4843 SND_PCI_QUIRK(0x103c, 0x22c2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4844 SND_PCI_QUIRK(0x103c, 0x22cd, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4845 SND_PCI_QUIRK(0x103c, 0x22ce, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4846 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4847 SND_PCI_QUIRK(0x103c, 0x22d0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
4848 SND_PCI_QUIRK(0x103c, 0x22da, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4849 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4850 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4851 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4852 SND_PCI_QUIRK(0x103c, 0x8004, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 4853 /* ALC290 */
9c5dc3bf 4854 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
549d8782
HW
4855 SND_PCI_QUIRK(0x103c, 0x221c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4856 SND_PCI_QUIRK(0x103c, 0x221d, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf
KY
4857 SND_PCI_QUIRK(0x103c, 0x2220, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4858 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4859 SND_PCI_QUIRK(0x103c, 0x2222, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4860 SND_PCI_QUIRK(0x103c, 0x2223, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4861 SND_PCI_QUIRK(0x103c, 0x2224, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4862 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4863 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4864 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4865 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4866 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4867 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4868 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4869 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4870 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4871 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4872 SND_PCI_QUIRK(0x103c, 0x2258, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4873 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4874 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd
KY
4875 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4876 SND_PCI_QUIRK(0x103c, 0x2261, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4877 SND_PCI_QUIRK(0x103c, 0x2262, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4878 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4879 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4880 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
4881 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4882 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4883 SND_PCI_QUIRK(0x103c, 0x2277, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4884 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd
KY
4885 SND_PCI_QUIRK(0x103c, 0x227d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4886 SND_PCI_QUIRK(0x103c, 0x227e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4887 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4888 SND_PCI_QUIRK(0x103c, 0x2280, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4889 SND_PCI_QUIRK(0x103c, 0x2281, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4890 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4891 SND_PCI_QUIRK(0x103c, 0x2289, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4892 SND_PCI_QUIRK(0x103c, 0x228a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4893 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4894 SND_PCI_QUIRK(0x103c, 0x228c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
fce0a0c7 4895 SND_PCI_QUIRK(0x103c, 0x228d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
4896 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4897 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4898 SND_PCI_QUIRK(0x103c, 0x22c6, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4899 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4900 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4901 SND_PCI_QUIRK(0x103c, 0x22c3, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4902 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4903 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4904 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4905 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4906 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7bba2157 4907 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
3e0d611b
DH
4908 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4909 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
2cede303 4910 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
23870831 4911 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
3e0d611b 4912 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
017f2a10 4913 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
693b613d 4914 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
3e0d611b 4915 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
adabb3ec
TI
4916 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
4917 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
4918 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
4919 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
d240d1dc 4920 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
f88abaa0 4921 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
88cfcf86 4922 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
1d045db9
TI
4923 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
4924 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
4925 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
e9bd7d5c 4926 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
24519911 4927 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
2041d564 4928 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
9dc12862 4929 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
1d045db9
TI
4930 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
4931 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
4932 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
4933 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
4934 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
707fba3f 4935 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
c8415a48 4936 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
84f98fdf 4937 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
4407be6b 4938 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
108cc108 4939 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
aaedfb47 4940 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
1c37c223
TI
4941 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
4942 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
a12137e7 4943 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
cd5302c0 4944 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
2793769f 4945 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
a4a9e082 4946 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9b745ab8 4947 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
a4a9e082 4948 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
1bb3e062 4949 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
cd5302c0
DH
4950 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4951 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
012e7eb1 4952 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
1d045db9 4953 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
02b504d9 4954 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
a4297b5d 4955
a7f3eedc 4956#if 0
a4297b5d
TI
4957 /* Below is a quirk table taken from the old code.
4958 * Basically the device should work as is without the fixup table.
4959 * If BIOS doesn't give a proper info, enable the corresponding
4960 * fixup entry.
7d7eb9ea 4961 */
a4297b5d
TI
4962 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
4963 ALC269_FIXUP_AMIC),
4964 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
a4297b5d
TI
4965 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
4966 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
4967 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
4968 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
4969 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
4970 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
4971 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
4972 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
4973 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
4974 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
4975 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
4976 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
4977 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
4978 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
4979 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
4980 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
4981 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
4982 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
4983 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
4984 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
4985 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
4986 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
4987 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
4988 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
4989 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
4990 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
4991 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
4992 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
4993 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
4994 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
4995 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
4996 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
4997 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
4998 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
4999 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
5000 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
5001 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
5002 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
5003#endif
5004 {}
5005};
5006
214eef76
DH
5007static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
5008 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
5009 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
5010 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
5011 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
5012 {}
5013};
5014
1727a771 5015static const struct hda_model_fixup alc269_fixup_models[] = {
a4297b5d
TI
5016 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5017 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6e72aa5f
TI
5018 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
5019 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
5020 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
7c478f03 5021 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
108cc108 5022 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9f5c6faf 5023 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
e32aa85a
DH
5024 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
5025 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
be8ef16a 5026 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
0202e99c 5027 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
1c37c223 5028 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
1d045db9 5029 {}
6dda9f4a
KY
5030};
5031
e1918938 5032static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
76c2132e
DH
5033 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5034 {0x12, 0x90a60140},
5035 {0x14, 0x90170110},
5036 {0x17, 0x40000000},
5037 {0x18, 0x411111f0},
5038 {0x19, 0x411111f0},
5039 {0x1a, 0x411111f0},
5040 {0x1b, 0x411111f0},
5041 {0x1d, 0x40700001},
5042 {0x1e, 0x411111f0},
5043 {0x21, 0x02211020}),
5044 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5045 {0x12, 0x90a60160},
5046 {0x14, 0x90170120},
5047 {0x17, 0x40000000},
5048 {0x18, 0x411111f0},
5049 {0x19, 0x411111f0},
5050 {0x1a, 0x411111f0},
5051 {0x1b, 0x411111f0},
5052 {0x1d, 0x40700001},
5053 {0x1e, 0x411111f0},
5054 {0x21, 0x02211030}),
5055 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5056 {0x12, 0x90a60160},
5057 {0x14, 0x90170120},
5058 {0x17, 0x90170140},
5059 {0x18, 0x40000000},
5060 {0x19, 0x411111f0},
5061 {0x1a, 0x411111f0},
5062 {0x1b, 0x411111f0},
5063 {0x1d, 0x41163b05},
5064 {0x1e, 0x411111f0},
5065 {0x21, 0x0321102f}),
5066 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5067 {0x12, 0x90a60160},
5068 {0x14, 0x90170130},
5069 {0x17, 0x40000000},
5070 {0x18, 0x411111f0},
5071 {0x19, 0x411111f0},
5072 {0x1a, 0x411111f0},
5073 {0x1b, 0x411111f0},
5074 {0x1d, 0x40700001},
5075 {0x1e, 0x411111f0},
5076 {0x21, 0x02211040}),
5077 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5078 {0x12, 0x90a60160},
5079 {0x14, 0x90170140},
5080 {0x17, 0x40000000},
5081 {0x18, 0x411111f0},
5082 {0x19, 0x411111f0},
5083 {0x1a, 0x411111f0},
5084 {0x1b, 0x411111f0},
5085 {0x1d, 0x40700001},
5086 {0x1e, 0x411111f0},
5087 {0x21, 0x02211050}),
5088 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5089 {0x12, 0x90a60170},
5090 {0x14, 0x90170120},
5091 {0x17, 0x40000000},
5092 {0x18, 0x411111f0},
5093 {0x19, 0x411111f0},
5094 {0x1a, 0x411111f0},
5095 {0x1b, 0x411111f0},
5096 {0x1d, 0x40700001},
5097 {0x1e, 0x411111f0},
5098 {0x21, 0x02211030}),
5099 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5100 {0x12, 0x90a60170},
5101 {0x14, 0x90170130},
5102 {0x17, 0x40000000},
5103 {0x18, 0x411111f0},
5104 {0x19, 0x411111f0},
5105 {0x1a, 0x411111f0},
5106 {0x1b, 0x411111f0},
5107 {0x1d, 0x40700001},
5108 {0x1e, 0x411111f0},
5109 {0x21, 0x02211040}),
42304474
DH
5110 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5111 {0x12, 0x99a30130},
5112 {0x14, 0x90170110},
5113 {0x17, 0x40000000},
5114 {0x18, 0x411111f0},
5115 {0x19, 0x03a11020},
5116 {0x1a, 0x411111f0},
5117 {0x1b, 0x411111f0},
5118 {0x1d, 0x40f41905},
5119 {0x1e, 0x411111f0},
5120 {0x21, 0x0321101f}),
76c2132e
DH
5121 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5122 {0x12, 0x90a60130},
5123 {0x14, 0x90170110},
5124 {0x17, 0x40020008},
5125 {0x18, 0x411111f0},
5126 {0x19, 0x411111f0},
5127 {0x1a, 0x411111f0},
5128 {0x1b, 0x411111f0},
5129 {0x1d, 0x40e00001},
5130 {0x1e, 0x411111f0},
5131 {0x21, 0x0321101f}),
5132 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5133 {0x12, 0x90a60160},
5134 {0x14, 0x90170120},
5135 {0x17, 0x40000000},
5136 {0x18, 0x411111f0},
5137 {0x19, 0x411111f0},
5138 {0x1a, 0x411111f0},
5139 {0x1b, 0x411111f0},
5140 {0x1d, 0x40700001},
5141 {0x1e, 0x411111f0},
5142 {0x21, 0x02211030}),
5143 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5144 {0x12, 0x90a60140},
5145 {0x13, 0x411111f0},
5146 {0x14, 0x90170110},
5147 {0x15, 0x0221401f},
5148 {0x16, 0x411111f0},
5149 {0x18, 0x411111f0},
5150 {0x19, 0x411111f0},
5151 {0x1a, 0x411111f0},
5152 {0x1b, 0x411111f0},
5153 {0x1d, 0x40700001},
5154 {0x1e, 0x411111f0}),
5155 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5156 {0x12, 0x40000000},
5157 {0x13, 0x90a60140},
5158 {0x14, 0x90170110},
5159 {0x15, 0x0221401f},
5160 {0x16, 0x21014020},
5161 {0x18, 0x411111f0},
5162 {0x19, 0x21a19030},
5163 {0x1a, 0x411111f0},
5164 {0x1b, 0x411111f0},
5165 {0x1d, 0x40700001},
5166 {0x1e, 0x411111f0}),
e03fdbde
DH
5167 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5168 {0x12, 0x40000000},
5169 {0x13, 0x90a60140},
5170 {0x14, 0x90170110},
5171 {0x15, 0x0221401f},
5172 {0x16, 0x411111f0},
5173 {0x18, 0x411111f0},
5174 {0x19, 0x411111f0},
5175 {0x1a, 0x411111f0},
5176 {0x1b, 0x411111f0},
5177 {0x1d, 0x40700001},
5178 {0x1e, 0x411111f0}),
e1918938
HW
5179 {}
5180};
6dda9f4a 5181
546bb678 5182static void alc269_fill_coef(struct hda_codec *codec)
1d045db9 5183{
526af6eb 5184 struct alc_spec *spec = codec->spec;
1d045db9 5185 int val;
ebb83eeb 5186
526af6eb 5187 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
546bb678 5188 return;
526af6eb 5189
1bb7e43e 5190 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
1d045db9
TI
5191 alc_write_coef_idx(codec, 0xf, 0x960b);
5192 alc_write_coef_idx(codec, 0xe, 0x8817);
5193 }
ebb83eeb 5194
1bb7e43e 5195 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
1d045db9
TI
5196 alc_write_coef_idx(codec, 0xf, 0x960b);
5197 alc_write_coef_idx(codec, 0xe, 0x8814);
5198 }
ebb83eeb 5199
1bb7e43e 5200 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9 5201 /* Power up output pin */
98b24883 5202 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
1d045db9 5203 }
ebb83eeb 5204
1bb7e43e 5205 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9 5206 val = alc_read_coef_idx(codec, 0xd);
f3ee07d8 5207 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
1d045db9
TI
5208 /* Capless ramp up clock control */
5209 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5210 }
5211 val = alc_read_coef_idx(codec, 0x17);
f3ee07d8 5212 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
1d045db9
TI
5213 /* Class D power on reset */
5214 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5215 }
5216 }
ebb83eeb 5217
98b24883
TI
5218 /* Class D */
5219 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
bc9f98a9 5220
98b24883
TI
5221 /* HP */
5222 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
1d045db9 5223}
a7f2371f 5224
1d045db9
TI
5225/*
5226 */
1d045db9
TI
5227static int patch_alc269(struct hda_codec *codec)
5228{
5229 struct alc_spec *spec;
3de95173 5230 int err;
f1d4e28b 5231
3de95173 5232 err = alc_alloc_spec(codec, 0x0b);
e16fb6d1 5233 if (err < 0)
3de95173
TI
5234 return err;
5235
5236 spec = codec->spec;
08c189f2 5237 spec->gen.shared_mic_vref_pin = 0x18;
e16fb6d1 5238
1727a771 5239 snd_hda_pick_fixup(codec, alc269_fixup_models,
9f720bb9 5240 alc269_fixup_tbl, alc269_fixups);
e1918938 5241 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
214eef76
DH
5242 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
5243 alc269_fixups);
1727a771 5244 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9f720bb9
HRK
5245
5246 alc_auto_parse_customize_define(codec);
5247
7504b6cd
TI
5248 if (has_cdefine_beep(codec))
5249 spec->gen.beep_nid = 0x01;
5250
065380f0
KY
5251 switch (codec->vendor_id) {
5252 case 0x10ec0269:
1d045db9 5253 spec->codec_variant = ALC269_TYPE_ALC269VA;
1bb7e43e
TI
5254 switch (alc_get_coef0(codec) & 0x00f0) {
5255 case 0x0010:
5100cd07
TI
5256 if (codec->bus->pci &&
5257 codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 5258 spec->cdefine.platform_type == 1)
20ca0c35 5259 err = alc_codec_rename(codec, "ALC271X");
1d045db9 5260 spec->codec_variant = ALC269_TYPE_ALC269VB;
1bb7e43e
TI
5261 break;
5262 case 0x0020:
5100cd07
TI
5263 if (codec->bus->pci &&
5264 codec->bus->pci->subsystem_vendor == 0x17aa &&
e16fb6d1 5265 codec->bus->pci->subsystem_device == 0x21f3)
20ca0c35 5266 err = alc_codec_rename(codec, "ALC3202");
1d045db9 5267 spec->codec_variant = ALC269_TYPE_ALC269VC;
1bb7e43e 5268 break;
adcc70b2
KY
5269 case 0x0030:
5270 spec->codec_variant = ALC269_TYPE_ALC269VD;
5271 break;
1bb7e43e 5272 default:
1d045db9 5273 alc_fix_pll_init(codec, 0x20, 0x04, 15);
1bb7e43e 5274 }
e16fb6d1
TI
5275 if (err < 0)
5276 goto error;
546bb678 5277 spec->init_hook = alc269_fill_coef;
1d045db9 5278 alc269_fill_coef(codec);
065380f0
KY
5279 break;
5280
5281 case 0x10ec0280:
5282 case 0x10ec0290:
5283 spec->codec_variant = ALC269_TYPE_ALC280;
5284 break;
5285 case 0x10ec0282:
065380f0 5286 spec->codec_variant = ALC269_TYPE_ALC282;
7b5c7a02
KY
5287 spec->shutup = alc282_shutup;
5288 spec->init_hook = alc282_init;
065380f0 5289 break;
2af02be7
KY
5290 case 0x10ec0233:
5291 case 0x10ec0283:
5292 spec->codec_variant = ALC269_TYPE_ALC283;
5293 spec->shutup = alc283_shutup;
5294 spec->init_hook = alc283_init;
5295 break;
065380f0
KY
5296 case 0x10ec0284:
5297 case 0x10ec0292:
5298 spec->codec_variant = ALC269_TYPE_ALC284;
5299 break;
161ebf29
KY
5300 case 0x10ec0285:
5301 case 0x10ec0293:
5302 spec->codec_variant = ALC269_TYPE_ALC285;
5303 break;
7fc7d047 5304 case 0x10ec0286:
7c665932 5305 case 0x10ec0288:
7fc7d047 5306 spec->codec_variant = ALC269_TYPE_ALC286;
f7ae9ba0 5307 spec->shutup = alc286_shutup;
7fc7d047 5308 break;
1d04c9de
KY
5309 case 0x10ec0255:
5310 spec->codec_variant = ALC269_TYPE_ALC255;
5311 break;
1d045db9 5312 }
6dda9f4a 5313
ad60d502 5314 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
97a26570 5315 spec->has_alc5505_dsp = 1;
ad60d502
KY
5316 spec->init_hook = alc5505_dsp_init;
5317 }
5318
a4297b5d
TI
5319 /* automatic parse from the BIOS config */
5320 err = alc269_parse_auto_config(codec);
e16fb6d1
TI
5321 if (err < 0)
5322 goto error;
6dda9f4a 5323
7504b6cd 5324 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 5325 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
f1d4e28b 5326
1d045db9 5327 codec->patch_ops = alc_patch_ops;
2a43952a 5328#ifdef CONFIG_PM
ad60d502 5329 codec->patch_ops.suspend = alc269_suspend;
1d045db9
TI
5330 codec->patch_ops.resume = alc269_resume;
5331#endif
c5177c86
KY
5332 if (!spec->shutup)
5333 spec->shutup = alc269_shutup;
ebb83eeb 5334
1727a771 5335 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 5336
1d045db9 5337 return 0;
e16fb6d1
TI
5338
5339 error:
5340 alc_free(codec);
5341 return err;
1d045db9 5342}
f1d4e28b 5343
1d045db9
TI
5344/*
5345 * ALC861
5346 */
622e84cd 5347
1d045db9 5348static int alc861_parse_auto_config(struct hda_codec *codec)
6dda9f4a 5349{
1d045db9 5350 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3e6179b8
TI
5351 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5352 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
604401a9
TI
5353}
5354
1d045db9
TI
5355/* Pin config fixes */
5356enum {
e652f4c8
TI
5357 ALC861_FIXUP_FSC_AMILO_PI1505,
5358 ALC861_FIXUP_AMP_VREF_0F,
5359 ALC861_FIXUP_NO_JACK_DETECT,
5360 ALC861_FIXUP_ASUS_A6RP,
6ddf0fd1 5361 ALC660_FIXUP_ASUS_W7J,
1d045db9 5362};
7085ec12 5363
31150f23
TI
5364/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
5365static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
1727a771 5366 const struct hda_fixup *fix, int action)
31150f23
TI
5367{
5368 struct alc_spec *spec = codec->spec;
5369 unsigned int val;
5370
1727a771 5371 if (action != HDA_FIXUP_ACT_INIT)
31150f23 5372 return;
d3f02d60 5373 val = snd_hda_codec_get_pin_target(codec, 0x0f);
31150f23
TI
5374 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
5375 val |= AC_PINCTL_IN_EN;
5376 val |= AC_PINCTL_VREF_50;
cdd03ced 5377 snd_hda_set_pin_ctl(codec, 0x0f, val);
08c189f2 5378 spec->gen.keep_vref_in_automute = 1;
31150f23
TI
5379}
5380
e652f4c8
TI
5381/* suppress the jack-detection */
5382static void alc_fixup_no_jack_detect(struct hda_codec *codec,
1727a771 5383 const struct hda_fixup *fix, int action)
e652f4c8 5384{
1727a771 5385 if (action == HDA_FIXUP_ACT_PRE_PROBE)
e652f4c8 5386 codec->no_jack_detect = 1;
7d7eb9ea 5387}
e652f4c8 5388
1727a771 5389static const struct hda_fixup alc861_fixups[] = {
e652f4c8 5390 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
1727a771
TI
5391 .type = HDA_FIXUP_PINS,
5392 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
5393 { 0x0b, 0x0221101f }, /* HP */
5394 { 0x0f, 0x90170310 }, /* speaker */
5395 { }
5396 }
5397 },
e652f4c8 5398 [ALC861_FIXUP_AMP_VREF_0F] = {
1727a771 5399 .type = HDA_FIXUP_FUNC,
31150f23 5400 .v.func = alc861_fixup_asus_amp_vref_0f,
3b25eb69 5401 },
e652f4c8 5402 [ALC861_FIXUP_NO_JACK_DETECT] = {
1727a771 5403 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
5404 .v.func = alc_fixup_no_jack_detect,
5405 },
5406 [ALC861_FIXUP_ASUS_A6RP] = {
1727a771 5407 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
5408 .v.func = alc861_fixup_asus_amp_vref_0f,
5409 .chained = true,
5410 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
6ddf0fd1
TI
5411 },
5412 [ALC660_FIXUP_ASUS_W7J] = {
5413 .type = HDA_FIXUP_VERBS,
5414 .v.verbs = (const struct hda_verb[]) {
5415 /* ASUS W7J needs a magic pin setup on unused NID 0x10
5416 * for enabling outputs
5417 */
5418 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5419 { }
5420 },
e652f4c8 5421 }
1d045db9 5422};
7085ec12 5423
1d045db9 5424static const struct snd_pci_quirk alc861_fixup_tbl[] = {
6ddf0fd1 5425 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
e7ca237b 5426 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
e652f4c8
TI
5427 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
5428 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
5429 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
5430 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
5431 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
5432 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
1d045db9
TI
5433 {}
5434};
3af9ee6b 5435
1d045db9
TI
5436/*
5437 */
1d045db9 5438static int patch_alc861(struct hda_codec *codec)
7085ec12 5439{
1d045db9 5440 struct alc_spec *spec;
1d045db9 5441 int err;
7085ec12 5442
3de95173
TI
5443 err = alc_alloc_spec(codec, 0x15);
5444 if (err < 0)
5445 return err;
1d045db9 5446
3de95173 5447 spec = codec->spec;
7504b6cd 5448 spec->gen.beep_nid = 0x23;
1d045db9 5449
1727a771
TI
5450 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5451 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3af9ee6b 5452
cb4e4824
TI
5453 /* automatic parse from the BIOS config */
5454 err = alc861_parse_auto_config(codec);
e16fb6d1
TI
5455 if (err < 0)
5456 goto error;
3af9ee6b 5457
7504b6cd 5458 if (!spec->gen.no_analog)
3e6179b8 5459 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7085ec12 5460
1d045db9 5461 codec->patch_ops = alc_patch_ops;
83012a7c 5462#ifdef CONFIG_PM
cb4e4824 5463 spec->power_hook = alc_power_eapd;
1d045db9
TI
5464#endif
5465
1727a771 5466 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 5467
1d045db9 5468 return 0;
e16fb6d1
TI
5469
5470 error:
5471 alc_free(codec);
5472 return err;
7085ec12
TI
5473}
5474
1d045db9
TI
5475/*
5476 * ALC861-VD support
5477 *
5478 * Based on ALC882
5479 *
5480 * In addition, an independent DAC
5481 */
1d045db9 5482static int alc861vd_parse_auto_config(struct hda_codec *codec)
bc9f98a9 5483{
1d045db9 5484 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3e6179b8
TI
5485 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5486 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
ce764ab2
TI
5487}
5488
1d045db9 5489enum {
8fdcb6fe
TI
5490 ALC660VD_FIX_ASUS_GPIO1,
5491 ALC861VD_FIX_DALLAS,
1d045db9 5492};
ce764ab2 5493
8fdcb6fe
TI
5494/* exclude VREF80 */
5495static void alc861vd_fixup_dallas(struct hda_codec *codec,
1727a771 5496 const struct hda_fixup *fix, int action)
8fdcb6fe 5497{
1727a771 5498 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
b78562b1
TI
5499 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
5500 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8fdcb6fe
TI
5501 }
5502}
5503
1727a771 5504static const struct hda_fixup alc861vd_fixups[] = {
1d045db9 5505 [ALC660VD_FIX_ASUS_GPIO1] = {
1727a771 5506 .type = HDA_FIXUP_VERBS,
1d045db9 5507 .v.verbs = (const struct hda_verb[]) {
8fdcb6fe 5508 /* reset GPIO1 */
1d045db9
TI
5509 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5510 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5511 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5512 { }
5513 }
5514 },
8fdcb6fe 5515 [ALC861VD_FIX_DALLAS] = {
1727a771 5516 .type = HDA_FIXUP_FUNC,
8fdcb6fe
TI
5517 .v.func = alc861vd_fixup_dallas,
5518 },
1d045db9 5519};
ce764ab2 5520
1d045db9 5521static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8fdcb6fe 5522 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
1d045db9 5523 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8fdcb6fe 5524 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
1d045db9
TI
5525 {}
5526};
ce764ab2 5527
1d045db9
TI
5528/*
5529 */
1d045db9 5530static int patch_alc861vd(struct hda_codec *codec)
ce764ab2 5531{
1d045db9 5532 struct alc_spec *spec;
cb4e4824 5533 int err;
ce764ab2 5534
3de95173
TI
5535 err = alc_alloc_spec(codec, 0x0b);
5536 if (err < 0)
5537 return err;
1d045db9 5538
3de95173 5539 spec = codec->spec;
7504b6cd 5540 spec->gen.beep_nid = 0x23;
1d045db9 5541
1727a771
TI
5542 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5543 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1d045db9 5544
cb4e4824
TI
5545 /* automatic parse from the BIOS config */
5546 err = alc861vd_parse_auto_config(codec);
e16fb6d1
TI
5547 if (err < 0)
5548 goto error;
ce764ab2 5549
7504b6cd 5550 if (!spec->gen.no_analog)
3e6179b8 5551 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1d045db9 5552
1d045db9
TI
5553 codec->patch_ops = alc_patch_ops;
5554
1d045db9 5555 spec->shutup = alc_eapd_shutup;
1d045db9 5556
1727a771 5557 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 5558
ce764ab2 5559 return 0;
e16fb6d1
TI
5560
5561 error:
5562 alc_free(codec);
5563 return err;
ce764ab2
TI
5564}
5565
1d045db9
TI
5566/*
5567 * ALC662 support
5568 *
5569 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5570 * configuration. Each pin widget can choose any input DACs and a mixer.
5571 * Each ADC is connected from a mixer of all inputs. This makes possible
5572 * 6-channel independent captures.
5573 *
5574 * In addition, an independent DAC for the multi-playback (not used in this
5575 * driver yet).
5576 */
1d045db9
TI
5577
5578/*
5579 * BIOS auto configuration
5580 */
5581
bc9f98a9
KY
5582static int alc662_parse_auto_config(struct hda_codec *codec)
5583{
4c6d72d1 5584 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3e6179b8
TI
5585 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5586 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5587 const hda_nid_t *ssids;
ee979a14 5588
6227cdce 5589 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
1d87caa6
RK
5590 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
5591 codec->vendor_id == 0x10ec0671)
3e6179b8 5592 ssids = alc663_ssids;
6227cdce 5593 else
3e6179b8
TI
5594 ssids = alc662_ssids;
5595 return alc_parse_auto_config(codec, alc662_ignore, ssids);
bc9f98a9
KY
5596}
5597
6be7948f 5598static void alc272_fixup_mario(struct hda_codec *codec,
1727a771 5599 const struct hda_fixup *fix, int action)
6fc398cb 5600{
9bb1f06f 5601 if (action != HDA_FIXUP_ACT_PRE_PROBE)
6fc398cb 5602 return;
6be7948f
TB
5603 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5604 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5605 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5606 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5607 (0 << AC_AMPCAP_MUTE_SHIFT)))
4e76a883 5608 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
6be7948f
TB
5609}
5610
8e383953
TI
5611static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
5612 { .channels = 2,
5613 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
5614 { .channels = 4,
5615 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
5616 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
5617 { }
5618};
5619
5620/* override the 2.1 chmap */
eb9ca3ab 5621static void alc_fixup_bass_chmap(struct hda_codec *codec,
8e383953
TI
5622 const struct hda_fixup *fix, int action)
5623{
5624 if (action == HDA_FIXUP_ACT_BUILD) {
5625 struct alc_spec *spec = codec->spec;
5626 spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps;
5627 }
5628}
5629
3e887f37
TI
5630/* turn on/off mute LED per vmaster hook */
5631static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
5632{
5633 struct hda_codec *codec = private_data;
5634 struct alc_spec *spec = codec->spec;
5635 unsigned int oldval = spec->gpio_led;
5636
5637 if (enabled)
5638 spec->gpio_led &= ~0x01;
5639 else
5640 spec->gpio_led |= 0x01;
5641 if (spec->gpio_led != oldval)
5642 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5643 spec->gpio_led);
5644}
5645
bf68665d
TI
5646/* avoid D3 for keeping GPIO up */
5647static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5648 hda_nid_t nid,
5649 unsigned int power_state)
5650{
5651 struct alc_spec *spec = codec->spec;
5652 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5653 return AC_PWRST_D0;
5654 return power_state;
5655}
5656
3e887f37
TI
5657static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5658 const struct hda_fixup *fix, int action)
5659{
5660 struct alc_spec *spec = codec->spec;
5661 static const struct hda_verb gpio_init[] = {
5662 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
5663 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
5664 {}
5665 };
5666
5667 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5668 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
5669 spec->gpio_led = 0;
5670 snd_hda_add_verbs(codec, gpio_init);
bf68665d 5671 codec->power_filter = gpio_led_power_filter;
3e887f37
TI
5672 }
5673}
5674
6cb3b707 5675enum {
2df03514 5676 ALC662_FIXUP_ASPIRE,
3e887f37 5677 ALC662_FIXUP_LED_GPIO1,
6cb3b707 5678 ALC662_FIXUP_IDEAPAD,
6be7948f 5679 ALC272_FIXUP_MARIO,
d2ebd479 5680 ALC662_FIXUP_CZC_P10T,
94024cd1 5681 ALC662_FIXUP_SKU_IGNORE,
e59ea3ed 5682 ALC662_FIXUP_HP_RP5800,
53c334ad
TI
5683 ALC662_FIXUP_ASUS_MODE1,
5684 ALC662_FIXUP_ASUS_MODE2,
5685 ALC662_FIXUP_ASUS_MODE3,
5686 ALC662_FIXUP_ASUS_MODE4,
5687 ALC662_FIXUP_ASUS_MODE5,
5688 ALC662_FIXUP_ASUS_MODE6,
5689 ALC662_FIXUP_ASUS_MODE7,
5690 ALC662_FIXUP_ASUS_MODE8,
1565cc35 5691 ALC662_FIXUP_NO_JACK_DETECT,
edfe3bfc 5692 ALC662_FIXUP_ZOTAC_Z68,
125821ae 5693 ALC662_FIXUP_INV_DMIC,
73bdd597
DH
5694 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
5695 ALC668_FIXUP_HEADSET_MODE,
8e54b4ac 5696 ALC662_FIXUP_BASS_MODE4_CHMAP,
61a75f13 5697 ALC662_FIXUP_BASS_16,
a30c9aaa 5698 ALC662_FIXUP_BASS_1A,
8e54b4ac 5699 ALC662_FIXUP_BASS_CHMAP,
493a52a9 5700 ALC668_FIXUP_AUTO_MUTE,
5e6db669 5701 ALC668_FIXUP_DELL_DISABLE_AAMIX,
033b0a7c 5702 ALC668_FIXUP_DELL_XPS13,
6cb3b707
DH
5703};
5704
1727a771 5705static const struct hda_fixup alc662_fixups[] = {
2df03514 5706 [ALC662_FIXUP_ASPIRE] = {
1727a771
TI
5707 .type = HDA_FIXUP_PINS,
5708 .v.pins = (const struct hda_pintbl[]) {
2df03514
DC
5709 { 0x15, 0x99130112 }, /* subwoofer */
5710 { }
5711 }
5712 },
3e887f37
TI
5713 [ALC662_FIXUP_LED_GPIO1] = {
5714 .type = HDA_FIXUP_FUNC,
5715 .v.func = alc662_fixup_led_gpio1,
5716 },
6cb3b707 5717 [ALC662_FIXUP_IDEAPAD] = {
1727a771
TI
5718 .type = HDA_FIXUP_PINS,
5719 .v.pins = (const struct hda_pintbl[]) {
6cb3b707
DH
5720 { 0x17, 0x99130112 }, /* subwoofer */
5721 { }
3e887f37
TI
5722 },
5723 .chained = true,
5724 .chain_id = ALC662_FIXUP_LED_GPIO1,
6cb3b707 5725 },
6be7948f 5726 [ALC272_FIXUP_MARIO] = {
1727a771 5727 .type = HDA_FIXUP_FUNC,
b5bfbc67 5728 .v.func = alc272_fixup_mario,
d2ebd479
AA
5729 },
5730 [ALC662_FIXUP_CZC_P10T] = {
1727a771 5731 .type = HDA_FIXUP_VERBS,
d2ebd479
AA
5732 .v.verbs = (const struct hda_verb[]) {
5733 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5734 {}
5735 }
5736 },
94024cd1 5737 [ALC662_FIXUP_SKU_IGNORE] = {
1727a771 5738 .type = HDA_FIXUP_FUNC,
23d30f28 5739 .v.func = alc_fixup_sku_ignore,
c6b35874 5740 },
e59ea3ed 5741 [ALC662_FIXUP_HP_RP5800] = {
1727a771
TI
5742 .type = HDA_FIXUP_PINS,
5743 .v.pins = (const struct hda_pintbl[]) {
e59ea3ed
TI
5744 { 0x14, 0x0221201f }, /* HP out */
5745 { }
5746 },
5747 .chained = true,
5748 .chain_id = ALC662_FIXUP_SKU_IGNORE
5749 },
53c334ad 5750 [ALC662_FIXUP_ASUS_MODE1] = {
1727a771
TI
5751 .type = HDA_FIXUP_PINS,
5752 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5753 { 0x14, 0x99130110 }, /* speaker */
5754 { 0x18, 0x01a19c20 }, /* mic */
5755 { 0x19, 0x99a3092f }, /* int-mic */
5756 { 0x21, 0x0121401f }, /* HP out */
5757 { }
5758 },
5759 .chained = true,
5760 .chain_id = ALC662_FIXUP_SKU_IGNORE
5761 },
5762 [ALC662_FIXUP_ASUS_MODE2] = {
1727a771
TI
5763 .type = HDA_FIXUP_PINS,
5764 .v.pins = (const struct hda_pintbl[]) {
2996bdba
TI
5765 { 0x14, 0x99130110 }, /* speaker */
5766 { 0x18, 0x01a19820 }, /* mic */
5767 { 0x19, 0x99a3092f }, /* int-mic */
5768 { 0x1b, 0x0121401f }, /* HP out */
5769 { }
5770 },
53c334ad
TI
5771 .chained = true,
5772 .chain_id = ALC662_FIXUP_SKU_IGNORE
5773 },
5774 [ALC662_FIXUP_ASUS_MODE3] = {
1727a771
TI
5775 .type = HDA_FIXUP_PINS,
5776 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5777 { 0x14, 0x99130110 }, /* speaker */
5778 { 0x15, 0x0121441f }, /* HP */
5779 { 0x18, 0x01a19840 }, /* mic */
5780 { 0x19, 0x99a3094f }, /* int-mic */
5781 { 0x21, 0x01211420 }, /* HP2 */
5782 { }
5783 },
5784 .chained = true,
5785 .chain_id = ALC662_FIXUP_SKU_IGNORE
5786 },
5787 [ALC662_FIXUP_ASUS_MODE4] = {
1727a771
TI
5788 .type = HDA_FIXUP_PINS,
5789 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5790 { 0x14, 0x99130110 }, /* speaker */
5791 { 0x16, 0x99130111 }, /* speaker */
5792 { 0x18, 0x01a19840 }, /* mic */
5793 { 0x19, 0x99a3094f }, /* int-mic */
5794 { 0x21, 0x0121441f }, /* HP */
5795 { }
5796 },
5797 .chained = true,
5798 .chain_id = ALC662_FIXUP_SKU_IGNORE
5799 },
5800 [ALC662_FIXUP_ASUS_MODE5] = {
1727a771
TI
5801 .type = HDA_FIXUP_PINS,
5802 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5803 { 0x14, 0x99130110 }, /* speaker */
5804 { 0x15, 0x0121441f }, /* HP */
5805 { 0x16, 0x99130111 }, /* speaker */
5806 { 0x18, 0x01a19840 }, /* mic */
5807 { 0x19, 0x99a3094f }, /* int-mic */
5808 { }
5809 },
5810 .chained = true,
5811 .chain_id = ALC662_FIXUP_SKU_IGNORE
5812 },
5813 [ALC662_FIXUP_ASUS_MODE6] = {
1727a771
TI
5814 .type = HDA_FIXUP_PINS,
5815 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5816 { 0x14, 0x99130110 }, /* speaker */
5817 { 0x15, 0x01211420 }, /* HP2 */
5818 { 0x18, 0x01a19840 }, /* mic */
5819 { 0x19, 0x99a3094f }, /* int-mic */
5820 { 0x1b, 0x0121441f }, /* HP */
5821 { }
5822 },
5823 .chained = true,
5824 .chain_id = ALC662_FIXUP_SKU_IGNORE
5825 },
5826 [ALC662_FIXUP_ASUS_MODE7] = {
1727a771
TI
5827 .type = HDA_FIXUP_PINS,
5828 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5829 { 0x14, 0x99130110 }, /* speaker */
5830 { 0x17, 0x99130111 }, /* speaker */
5831 { 0x18, 0x01a19840 }, /* mic */
5832 { 0x19, 0x99a3094f }, /* int-mic */
5833 { 0x1b, 0x01214020 }, /* HP */
5834 { 0x21, 0x0121401f }, /* HP */
5835 { }
5836 },
5837 .chained = true,
5838 .chain_id = ALC662_FIXUP_SKU_IGNORE
5839 },
5840 [ALC662_FIXUP_ASUS_MODE8] = {
1727a771
TI
5841 .type = HDA_FIXUP_PINS,
5842 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5843 { 0x14, 0x99130110 }, /* speaker */
5844 { 0x12, 0x99a30970 }, /* int-mic */
5845 { 0x15, 0x01214020 }, /* HP */
5846 { 0x17, 0x99130111 }, /* speaker */
5847 { 0x18, 0x01a19840 }, /* mic */
5848 { 0x21, 0x0121401f }, /* HP */
5849 { }
5850 },
5851 .chained = true,
5852 .chain_id = ALC662_FIXUP_SKU_IGNORE
2996bdba 5853 },
1565cc35 5854 [ALC662_FIXUP_NO_JACK_DETECT] = {
1727a771 5855 .type = HDA_FIXUP_FUNC,
1565cc35
TI
5856 .v.func = alc_fixup_no_jack_detect,
5857 },
edfe3bfc 5858 [ALC662_FIXUP_ZOTAC_Z68] = {
1727a771
TI
5859 .type = HDA_FIXUP_PINS,
5860 .v.pins = (const struct hda_pintbl[]) {
edfe3bfc
DH
5861 { 0x1b, 0x02214020 }, /* Front HP */
5862 { }
5863 }
5864 },
125821ae 5865 [ALC662_FIXUP_INV_DMIC] = {
1727a771 5866 .type = HDA_FIXUP_FUNC,
6e72aa5f 5867 .v.func = alc_fixup_inv_dmic_0x12,
125821ae 5868 },
033b0a7c
GM
5869 [ALC668_FIXUP_DELL_XPS13] = {
5870 .type = HDA_FIXUP_FUNC,
5871 .v.func = alc_fixup_dell_xps13,
5872 .chained = true,
5873 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
5874 },
5e6db669
GM
5875 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
5876 .type = HDA_FIXUP_FUNC,
5877 .v.func = alc_fixup_disable_aamix,
5878 .chained = true,
5879 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5880 },
493a52a9
HW
5881 [ALC668_FIXUP_AUTO_MUTE] = {
5882 .type = HDA_FIXUP_FUNC,
5883 .v.func = alc_fixup_auto_mute_via_amp,
5884 .chained = true,
5885 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5886 },
73bdd597
DH
5887 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
5888 .type = HDA_FIXUP_PINS,
5889 .v.pins = (const struct hda_pintbl[]) {
5890 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
5891 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
5892 { }
5893 },
5894 .chained = true,
5895 .chain_id = ALC668_FIXUP_HEADSET_MODE
5896 },
5897 [ALC668_FIXUP_HEADSET_MODE] = {
5898 .type = HDA_FIXUP_FUNC,
5899 .v.func = alc_fixup_headset_mode_alc668,
5900 },
8e54b4ac 5901 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
8e383953 5902 .type = HDA_FIXUP_FUNC,
eb9ca3ab 5903 .v.func = alc_fixup_bass_chmap,
8e383953
TI
5904 .chained = true,
5905 .chain_id = ALC662_FIXUP_ASUS_MODE4
5906 },
61a75f13
DH
5907 [ALC662_FIXUP_BASS_16] = {
5908 .type = HDA_FIXUP_PINS,
5909 .v.pins = (const struct hda_pintbl[]) {
5910 {0x16, 0x80106111}, /* bass speaker */
5911 {}
5912 },
5913 .chained = true,
5914 .chain_id = ALC662_FIXUP_BASS_CHMAP,
5915 },
a30c9aaa
TI
5916 [ALC662_FIXUP_BASS_1A] = {
5917 .type = HDA_FIXUP_PINS,
5918 .v.pins = (const struct hda_pintbl[]) {
5919 {0x1a, 0x80106111}, /* bass speaker */
5920 {}
5921 },
8e54b4ac
DH
5922 .chained = true,
5923 .chain_id = ALC662_FIXUP_BASS_CHMAP,
a30c9aaa 5924 },
8e54b4ac 5925 [ALC662_FIXUP_BASS_CHMAP] = {
a30c9aaa 5926 .type = HDA_FIXUP_FUNC,
eb9ca3ab 5927 .v.func = alc_fixup_bass_chmap,
a30c9aaa 5928 },
6cb3b707
DH
5929};
5930
a9111321 5931static const struct snd_pci_quirk alc662_fixup_tbl[] = {
53c334ad 5932 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
d3d3835c 5933 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
a6c47a85 5934 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
94024cd1 5935 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
125821ae 5936 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
1801928e 5937 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
2df03514 5938 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
73bdd597
DH
5939 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5940 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
c5d019c3 5941 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
033b0a7c 5942 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
09d2014f 5943 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
ad8ff99e 5944 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8dc9abb9
KY
5945 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5946 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
e59ea3ed 5947 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
8e54b4ac
DH
5948 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
5949 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
61a75f13
DH
5950 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
5951 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8e54b4ac 5952 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
1565cc35 5953 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
53c334ad 5954 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
a0e90acc 5955 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
d4118588 5956 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6cb3b707 5957 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
edfe3bfc 5958 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
d2ebd479 5959 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
53c334ad
TI
5960
5961#if 0
5962 /* Below is a quirk table taken from the old code.
5963 * Basically the device should work as is without the fixup table.
5964 * If BIOS doesn't give a proper info, enable the corresponding
5965 * fixup entry.
7d7eb9ea 5966 */
53c334ad
TI
5967 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
5968 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
5969 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
5970 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
5971 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5972 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5973 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5974 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
5975 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
5976 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5977 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
5978 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
5979 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
5980 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
5981 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
5982 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5983 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
5984 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
5985 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5986 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5987 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5988 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5989 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
5990 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
5991 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
5992 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5993 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
5994 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5995 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5996 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
5997 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5998 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5999 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6000 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6001 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6002 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6003 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6004 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6005 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6006 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6007 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6008 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6009 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6010 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6011 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6012 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6013 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6014 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6015 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6016 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6017#endif
6cb3b707
DH
6018 {}
6019};
6020
1727a771 6021static const struct hda_model_fixup alc662_fixup_models[] = {
6be7948f 6022 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
53c334ad
TI
6023 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6024 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6025 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6026 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6027 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6028 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6029 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6030 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6e72aa5f 6031 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
e32aa85a 6032 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
6be7948f
TB
6033 {}
6034};
6cb3b707 6035
532895c5 6036static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
76c2132e
DH
6037 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6038 {0x12, 0x99a30130},
6039 {0x14, 0x90170110},
6040 {0x15, 0x0321101f},
6041 {0x16, 0x03011020},
6042 {0x18, 0x40000008},
6043 {0x19, 0x411111f0},
6044 {0x1a, 0x411111f0},
6045 {0x1b, 0x411111f0},
6046 {0x1d, 0x41000001},
6047 {0x1e, 0x411111f0},
6048 {0x1f, 0x411111f0}),
6049 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6050 {0x12, 0x99a30140},
6051 {0x14, 0x90170110},
6052 {0x15, 0x0321101f},
6053 {0x16, 0x03011020},
6054 {0x18, 0x40000008},
6055 {0x19, 0x411111f0},
6056 {0x1a, 0x411111f0},
6057 {0x1b, 0x411111f0},
6058 {0x1d, 0x41000001},
6059 {0x1e, 0x411111f0},
6060 {0x1f, 0x411111f0}),
6061 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6062 {0x12, 0x99a30150},
6063 {0x14, 0x90170110},
6064 {0x15, 0x0321101f},
6065 {0x16, 0x03011020},
6066 {0x18, 0x40000008},
6067 {0x19, 0x411111f0},
6068 {0x1a, 0x411111f0},
6069 {0x1b, 0x411111f0},
6070 {0x1d, 0x41000001},
6071 {0x1e, 0x411111f0},
6072 {0x1f, 0x411111f0}),
6073 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6074 {0x12, 0x411111f0},
6075 {0x14, 0x90170110},
6076 {0x15, 0x0321101f},
6077 {0x16, 0x03011020},
6078 {0x18, 0x40000008},
6079 {0x19, 0x411111f0},
6080 {0x1a, 0x411111f0},
6081 {0x1b, 0x411111f0},
6082 {0x1d, 0x41000001},
6083 {0x1e, 0x411111f0},
6084 {0x1f, 0x411111f0}),
6085 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
6086 {0x12, 0x90a60130},
6087 {0x14, 0x90170110},
6088 {0x15, 0x0321101f},
6089 {0x16, 0x40000000},
6090 {0x18, 0x411111f0},
6091 {0x19, 0x411111f0},
6092 {0x1a, 0x411111f0},
6093 {0x1b, 0x411111f0},
6094 {0x1d, 0x40d6832d},
6095 {0x1e, 0x411111f0},
6096 {0x1f, 0x411111f0}),
532895c5
HW
6097 {}
6098};
6099
8663ff75
KY
6100static void alc662_fill_coef(struct hda_codec *codec)
6101{
98b24883 6102 int coef;
8663ff75
KY
6103
6104 coef = alc_get_coef0(codec);
6105
6106 switch (codec->vendor_id) {
6107 case 0x10ec0662:
98b24883
TI
6108 if ((coef & 0x00f0) == 0x0030)
6109 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
8663ff75
KY
6110 break;
6111 case 0x10ec0272:
6112 case 0x10ec0273:
6113 case 0x10ec0663:
6114 case 0x10ec0665:
6115 case 0x10ec0670:
6116 case 0x10ec0671:
6117 case 0x10ec0672:
98b24883 6118 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
8663ff75
KY
6119 break;
6120 }
6121}
6cb3b707 6122
1d045db9
TI
6123/*
6124 */
bc9f98a9
KY
6125static int patch_alc662(struct hda_codec *codec)
6126{
6127 struct alc_spec *spec;
3de95173 6128 int err;
bc9f98a9 6129
3de95173
TI
6130 err = alc_alloc_spec(codec, 0x0b);
6131 if (err < 0)
6132 return err;
bc9f98a9 6133
3de95173 6134 spec = codec->spec;
1f0f4b80 6135
53c334ad
TI
6136 /* handle multiple HPs as is */
6137 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6138
2c3bf9ab
TI
6139 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6140
8663ff75
KY
6141 spec->init_hook = alc662_fill_coef;
6142 alc662_fill_coef(codec);
6143
1727a771 6144 snd_hda_pick_fixup(codec, alc662_fixup_models,
8e5a0509 6145 alc662_fixup_tbl, alc662_fixups);
532895c5 6146 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
1727a771 6147 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8e5a0509
TI
6148
6149 alc_auto_parse_customize_define(codec);
6150
7504b6cd
TI
6151 if (has_cdefine_beep(codec))
6152 spec->gen.beep_nid = 0x01;
6153
1bb7e43e 6154 if ((alc_get_coef0(codec) & (1 << 14)) &&
5100cd07 6155 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 6156 spec->cdefine.platform_type == 1) {
6134b1a2
WY
6157 err = alc_codec_rename(codec, "ALC272X");
6158 if (err < 0)
e16fb6d1 6159 goto error;
20ca0c35 6160 }
274693f3 6161
b9c5106c
TI
6162 /* automatic parse from the BIOS config */
6163 err = alc662_parse_auto_config(codec);
e16fb6d1
TI
6164 if (err < 0)
6165 goto error;
bc9f98a9 6166
7504b6cd 6167 if (!spec->gen.no_analog && spec->gen.beep_nid) {
da00c244
KY
6168 switch (codec->vendor_id) {
6169 case 0x10ec0662:
6170 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6171 break;
6172 case 0x10ec0272:
6173 case 0x10ec0663:
6174 case 0x10ec0665:
9ad54547 6175 case 0x10ec0668:
da00c244
KY
6176 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6177 break;
6178 case 0x10ec0273:
6179 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6180 break;
6181 }
cec27c89 6182 }
2134ea4f 6183
bc9f98a9 6184 codec->patch_ops = alc_patch_ops;
1c716153 6185 spec->shutup = alc_eapd_shutup;
6cb3b707 6186
1727a771 6187 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 6188
bc9f98a9 6189 return 0;
801f49d3 6190
e16fb6d1
TI
6191 error:
6192 alc_free(codec);
6193 return err;
b478b998
KY
6194}
6195
d1eb57f4
KY
6196/*
6197 * ALC680 support
6198 */
d1eb57f4 6199
d1eb57f4
KY
6200static int alc680_parse_auto_config(struct hda_codec *codec)
6201{
3e6179b8 6202 return alc_parse_auto_config(codec, NULL, NULL);
d1eb57f4
KY
6203}
6204
d1eb57f4 6205/*
d1eb57f4 6206 */
d1eb57f4
KY
6207static int patch_alc680(struct hda_codec *codec)
6208{
d1eb57f4
KY
6209 int err;
6210
1f0f4b80 6211 /* ALC680 has no aa-loopback mixer */
3de95173
TI
6212 err = alc_alloc_spec(codec, 0);
6213 if (err < 0)
6214 return err;
1f0f4b80 6215
1ebec5f2
TI
6216 /* automatic parse from the BIOS config */
6217 err = alc680_parse_auto_config(codec);
6218 if (err < 0) {
6219 alc_free(codec);
6220 return err;
d1eb57f4
KY
6221 }
6222
d1eb57f4 6223 codec->patch_ops = alc_patch_ops;
d1eb57f4
KY
6224
6225 return 0;
6226}
6227
1da177e4
LT
6228/*
6229 * patch entries
6230 */
a9111321 6231static const struct hda_codec_preset snd_hda_preset_realtek[] = {
296f0338 6232 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
ba4c4d0a 6233 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
84dfd0ac 6234 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
92f974df 6235 { .id = 0x10ec0235, .name = "ALC233", .patch = patch_alc269 },
1d04c9de 6236 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
1da177e4 6237 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
df694daa 6238 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
f6a92248 6239 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
a361d84b 6240 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
f6a92248 6241 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
ebb83eeb 6242 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
01afd41f 6243 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
ebb83eeb 6244 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
296f0338 6245 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
befae82e 6246 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
4e01ec63 6247 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
7ff34ad8 6248 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
065380f0 6249 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
161ebf29 6250 { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
7fc7d047 6251 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
7c665932 6252 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
7ff34ad8 6253 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
af02dde8 6254 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
161ebf29 6255 { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
f32610ed 6256 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
bc9f98a9 6257 .patch = patch_alc861 },
f32610ed
JS
6258 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6259 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6260 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
bc9f98a9 6261 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
4953550a 6262 .patch = patch_alc882 },
bc9f98a9
KY
6263 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6264 .patch = patch_alc662 },
cc667a72
DH
6265 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6266 .patch = patch_alc662 },
6dda9f4a 6267 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
cec27c89 6268 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
72009433 6269 { .id = 0x10ec0667, .name = "ALC667", .patch = patch_alc662 },
19a62823 6270 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
6227cdce 6271 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
1d87caa6 6272 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
d1eb57f4 6273 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
b6c5fbad 6274 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
f32610ed 6275 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
1da177e4 6276 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4953550a 6277 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
669faba2 6278 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
4953550a 6279 .patch = patch_alc882 },
cb308f97 6280 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
4953550a 6281 .patch = patch_alc882 },
df694daa 6282 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
e16fb6d1 6283 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
4442608d 6284 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
4953550a 6285 .patch = patch_alc882 },
e16fb6d1 6286 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
4953550a 6287 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
274693f3 6288 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
e16fb6d1 6289 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
19a62823 6290 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
1da177e4
LT
6291 {} /* terminator */
6292};
1289e9e8
TI
6293
6294MODULE_ALIAS("snd-hda-codec-id:10ec*");
6295
6296MODULE_LICENSE("GPL");
6297MODULE_DESCRIPTION("Realtek HD-audio codec");
6298
6299static struct hda_codec_preset_list realtek_list = {
6300 .preset = snd_hda_preset_realtek,
6301 .owner = THIS_MODULE,
6302};
6303
6304static int __init patch_realtek_init(void)
6305{
6306 return snd_hda_add_codec_preset(&realtek_list);
6307}
6308
6309static void __exit patch_realtek_exit(void)
6310{
6311 snd_hda_delete_codec_preset(&realtek_list);
6312}
6313
6314module_init(patch_realtek_init)
6315module_exit(patch_realtek_exit)