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