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