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