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