]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - sound/pci/hda/patch_realtek.c
ALSA: hda/realtek - Avoid setting wrong COEF on ALC269 & co
[mirror_ubuntu-artful-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);
ad60d502 3271 if (spec->has_alc5505_dsp)
cd63a5ff 3272 alc5505_dsp_resume(codec);
c5177c86 3273
1d045db9
TI
3274 return 0;
3275}
2a43952a 3276#endif /* CONFIG_PM */
f1d4e28b 3277
108cc108 3278static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
1727a771 3279 const struct hda_fixup *fix, int action)
108cc108
DH
3280{
3281 struct alc_spec *spec = codec->spec;
3282
1727a771 3283 if (action == HDA_FIXUP_ACT_PRE_PROBE)
108cc108
DH
3284 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3285}
3286
1d045db9 3287static void alc269_fixup_hweq(struct hda_codec *codec,
1727a771 3288 const struct hda_fixup *fix, int action)
1d045db9
TI
3289{
3290 int coef;
f1d4e28b 3291
1727a771 3292 if (action != HDA_FIXUP_ACT_INIT)
1d045db9
TI
3293 return;
3294 coef = alc_read_coef_idx(codec, 0x1e);
3295 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
3296}
f1d4e28b 3297
7c478f03
DH
3298static void alc269_fixup_headset_mic(struct hda_codec *codec,
3299 const struct hda_fixup *fix, int action)
3300{
3301 struct alc_spec *spec = codec->spec;
3302
3303 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3304 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3305}
3306
1d045db9 3307static void alc271_fixup_dmic(struct hda_codec *codec,
1727a771 3308 const struct hda_fixup *fix, int action)
1d045db9
TI
3309{
3310 static const struct hda_verb verbs[] = {
3311 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3312 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3313 {}
3314 };
3315 unsigned int cfg;
f1d4e28b 3316
42397004
DR
3317 if (strcmp(codec->chip_name, "ALC271X") &&
3318 strcmp(codec->chip_name, "ALC269VB"))
1d045db9
TI
3319 return;
3320 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3321 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3322 snd_hda_sequence_write(codec, verbs);
3323}
f1d4e28b 3324
017f2a10 3325static void alc269_fixup_pcm_44k(struct hda_codec *codec,
1727a771 3326 const struct hda_fixup *fix, int action)
017f2a10
TI
3327{
3328 struct alc_spec *spec = codec->spec;
3329
1727a771 3330 if (action != HDA_FIXUP_ACT_PROBE)
017f2a10
TI
3331 return;
3332
3333 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3334 * fix the sample rate of analog I/O to 44.1kHz
3335 */
08c189f2
TI
3336 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3337 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
017f2a10
TI
3338}
3339
adabb3ec 3340static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
1727a771 3341 const struct hda_fixup *fix, int action)
adabb3ec
TI
3342{
3343 int coef;
3344
1727a771 3345 if (action != HDA_FIXUP_ACT_INIT)
adabb3ec
TI
3346 return;
3347 /* The digital-mic unit sends PDM (differential signal) instead of
3348 * the standard PCM, thus you can't record a valid mono stream as is.
3349 * Below is a workaround specific to ALC269 to control the dmic
3350 * signal source as mono.
3351 */
3352 coef = alc_read_coef_idx(codec, 0x07);
3353 alc_write_coef_idx(codec, 0x07, coef | 0x80);
3354}
3355
24519911
TI
3356static void alc269_quanta_automute(struct hda_codec *codec)
3357{
08c189f2 3358 snd_hda_gen_update_outputs(codec);
24519911
TI
3359
3360 snd_hda_codec_write(codec, 0x20, 0,
3361 AC_VERB_SET_COEF_INDEX, 0x0c);
3362 snd_hda_codec_write(codec, 0x20, 0,
3363 AC_VERB_SET_PROC_COEF, 0x680);
3364
3365 snd_hda_codec_write(codec, 0x20, 0,
3366 AC_VERB_SET_COEF_INDEX, 0x0c);
3367 snd_hda_codec_write(codec, 0x20, 0,
3368 AC_VERB_SET_PROC_COEF, 0x480);
3369}
3370
3371static void alc269_fixup_quanta_mute(struct hda_codec *codec,
1727a771 3372 const struct hda_fixup *fix, int action)
24519911
TI
3373{
3374 struct alc_spec *spec = codec->spec;
1727a771 3375 if (action != HDA_FIXUP_ACT_PROBE)
24519911 3376 return;
08c189f2 3377 spec->gen.automute_hook = alc269_quanta_automute;
24519911
TI
3378}
3379
d240d1dc
DH
3380static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3381 struct hda_jack_tbl *jack)
3382{
3383 struct alc_spec *spec = codec->spec;
3384 int vref;
3385 msleep(200);
3386 snd_hda_gen_hp_automute(codec, jack);
3387
3388 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3389 msleep(100);
3390 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3391 vref);
3392 msleep(500);
3393 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3394 vref);
3395}
3396
3397static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3398 const struct hda_fixup *fix, int action)
3399{
3400 struct alc_spec *spec = codec->spec;
3401 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3402 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3403 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3404 }
3405}
3406
3407
08fb0d0e
TI
3408/* update mute-LED according to the speaker mute state via mic VREF pin */
3409static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
6d3cd5d4
DH
3410{
3411 struct hda_codec *codec = private_data;
08fb0d0e
TI
3412 struct alc_spec *spec = codec->spec;
3413 unsigned int pinval;
3414
3415 if (spec->mute_led_polarity)
3416 enabled = !enabled;
415d555e
TI
3417 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3418 pinval &= ~AC_PINCTL_VREFEN;
3419 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
08fb0d0e
TI
3420 if (spec->mute_led_nid)
3421 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
6d3cd5d4
DH
3422}
3423
d5b6b65e
DH
3424/* Make sure the led works even in runtime suspend */
3425static unsigned int led_power_filter(struct hda_codec *codec,
3426 hda_nid_t nid,
3427 unsigned int power_state)
3428{
3429 struct alc_spec *spec = codec->spec;
3430
50dd9050
HW
3431 if (power_state != AC_PWRST_D3 || nid == 0 ||
3432 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
d5b6b65e
DH
3433 return power_state;
3434
3435 /* Set pin ctl again, it might have just been set to 0 */
3436 snd_hda_set_pin_ctl(codec, nid,
3437 snd_hda_codec_get_pin_target(codec, nid));
3438
3439 return AC_PWRST_D0;
3440}
3441
08fb0d0e
TI
3442static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3443 const struct hda_fixup *fix, int action)
6d3cd5d4
DH
3444{
3445 struct alc_spec *spec = codec->spec;
08fb0d0e
TI
3446 const struct dmi_device *dev = NULL;
3447
3448 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3449 return;
3450
3451 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3452 int pol, pin;
3453 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3454 continue;
3455 if (pin < 0x0a || pin >= 0x10)
3456 break;
3457 spec->mute_led_polarity = pol;
3458 spec->mute_led_nid = pin - 0x0a + 0x18;
3459 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3460 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3461 codec->power_filter = led_power_filter;
4e76a883
TI
3462 codec_dbg(codec,
3463 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
08fb0d0e 3464 spec->mute_led_polarity);
6d3cd5d4
DH
3465 break;
3466 }
3467}
3468
d06ac143
DH
3469static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3470 const struct hda_fixup *fix, int action)
3471{
3472 struct alc_spec *spec = codec->spec;
3473 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3474 spec->mute_led_polarity = 0;
3475 spec->mute_led_nid = 0x18;
3476 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3477 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3478 codec->power_filter = led_power_filter;
d06ac143
DH
3479 }
3480}
3481
08fb0d0e
TI
3482static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3483 const struct hda_fixup *fix, int action)
420b0feb
TI
3484{
3485 struct alc_spec *spec = codec->spec;
9bb1f06f 3486 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08fb0d0e
TI
3487 spec->mute_led_polarity = 0;
3488 spec->mute_led_nid = 0x19;
3489 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3490 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3491 codec->power_filter = led_power_filter;
420b0feb
TI
3492 }
3493}
3494
9f5c6faf
TI
3495/* turn on/off mute LED per vmaster hook */
3496static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
3497{
3498 struct hda_codec *codec = private_data;
3499 struct alc_spec *spec = codec->spec;
3500 unsigned int oldval = spec->gpio_led;
3501
3502 if (enabled)
3503 spec->gpio_led &= ~0x08;
3504 else
3505 spec->gpio_led |= 0x08;
3506 if (spec->gpio_led != oldval)
3507 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3508 spec->gpio_led);
3509}
3510
3511/* turn on/off mic-mute LED per capture hook */
3512static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
7fe30711
TI
3513 struct snd_kcontrol *kcontrol,
3514 struct snd_ctl_elem_value *ucontrol)
9f5c6faf
TI
3515{
3516 struct alc_spec *spec = codec->spec;
3517 unsigned int oldval = spec->gpio_led;
3518
3519 if (!ucontrol)
3520 return;
3521
3522 if (ucontrol->value.integer.value[0] ||
3523 ucontrol->value.integer.value[1])
3524 spec->gpio_led &= ~0x10;
3525 else
3526 spec->gpio_led |= 0x10;
3527 if (spec->gpio_led != oldval)
3528 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3529 spec->gpio_led);
3530}
3531
3532static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3533 const struct hda_fixup *fix, int action)
3534{
3535 struct alc_spec *spec = codec->spec;
3536 static const struct hda_verb gpio_init[] = {
3537 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3538 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3539 {}
3540 };
3541
3542 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3543 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3544 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
3545 spec->gpio_led = 0;
3546 snd_hda_add_verbs(codec, gpio_init);
3547 }
3548}
3549
9c5dc3bf
KY
3550/* turn on/off mic-mute LED per capture hook */
3551static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3552 struct snd_kcontrol *kcontrol,
3553 struct snd_ctl_elem_value *ucontrol)
3554{
3555 struct alc_spec *spec = codec->spec;
3556 unsigned int pinval, enable, disable;
3557
fc1fad93 3558 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
9c5dc3bf
KY
3559 pinval &= ~AC_PINCTL_VREFEN;
3560 enable = pinval | AC_PINCTL_VREF_80;
3561 disable = pinval | AC_PINCTL_VREF_HIZ;
3562
3563 if (!ucontrol)
3564 return;
3565
3566 if (ucontrol->value.integer.value[0] ||
3567 ucontrol->value.integer.value[1])
3568 pinval = disable;
3569 else
3570 pinval = enable;
3571
3572 if (spec->cap_mute_led_nid)
3573 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3574}
3575
3576static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3577 const struct hda_fixup *fix, int action)
3578{
3579 struct alc_spec *spec = codec->spec;
3580 static const struct hda_verb gpio_init[] = {
3581 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3582 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3583 {}
3584 };
3585
3586 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3587 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3588 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3589 spec->gpio_led = 0;
3590 spec->cap_mute_led_nid = 0x18;
3591 snd_hda_add_verbs(codec, gpio_init);
50dd9050 3592 codec->power_filter = led_power_filter;
9c5dc3bf
KY
3593 }
3594}
3595
3596static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3597 const struct hda_fixup *fix, int action)
3598{
3599 struct alc_spec *spec = codec->spec;
3600
3601 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3602 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3603 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3604 spec->mute_led_polarity = 0;
3605 spec->mute_led_nid = 0x1a;
3606 spec->cap_mute_led_nid = 0x18;
3607 spec->gen.vmaster_mute_enum = 1;
3608 codec->power_filter = led_power_filter;
3609 }
3610}
3611
73bdd597
DH
3612static void alc_headset_mode_unplugged(struct hda_codec *codec)
3613{
3614 int val;
3615
3616 switch (codec->vendor_id) {
9a22a8f5
KY
3617 case 0x10ec0255:
3618 /* LDO and MISC control */
3619 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3620 /* UAJ function set to menual mode */
3621 alc_write_coef_idx(codec, 0x45, 0xd089);
3622 /* Direct Drive HP Amp control(Set to verb control)*/
3623 val = alc_read_coefex_idx(codec, 0x57, 0x05);
3624 alc_write_coefex_idx(codec, 0x57, 0x05, val & ~(1<<14));
3625 /* Set MIC2 Vref gate with HP */
3626 alc_write_coef_idx(codec, 0x06, 0x6104);
3627 /* Direct Drive HP Amp control */
3628 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3629 break;
13fd08a3 3630 case 0x10ec0233:
73bdd597
DH
3631 case 0x10ec0283:
3632 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3633 alc_write_coef_idx(codec, 0x45, 0xc429);
3634 val = alc_read_coef_idx(codec, 0x35);
3635 alc_write_coef_idx(codec, 0x35, val & 0xbfff);
3636 alc_write_coef_idx(codec, 0x06, 0x2104);
3637 alc_write_coef_idx(codec, 0x1a, 0x0001);
3638 alc_write_coef_idx(codec, 0x26, 0x0004);
3639 alc_write_coef_idx(codec, 0x32, 0x42a3);
3640 break;
3641 case 0x10ec0292:
3642 alc_write_coef_idx(codec, 0x76, 0x000e);
3643 alc_write_coef_idx(codec, 0x6c, 0x2400);
3644 alc_write_coef_idx(codec, 0x18, 0x7308);
3645 alc_write_coef_idx(codec, 0x6b, 0xc429);
3646 break;
a22aa26f
KY
3647 case 0x10ec0293:
3648 /* SET Line1 JD to 0 */
3649 val = alc_read_coef_idx(codec, 0x10);
3650 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 6<<8);
3651 /* SET charge pump by verb */
3652 val = alc_read_coefex_idx(codec, 0x57, 0x05);
3653 alc_write_coefex_idx(codec, 0x57, 0x05, (val & ~(1<<15|1<<13)) | 0x0);
3654 /* SET EN_OSW to 1 */
3655 val = alc_read_coefex_idx(codec, 0x57, 0x03);
3656 alc_write_coefex_idx(codec, 0x57, 0x03, (val & ~(1<<10)) | (1<<10) );
3657 /* Combo JD gating with LINE1-VREFO */
3658 val = alc_read_coef_idx(codec, 0x1a);
3659 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | (1<<3));
3660 /* Set to TRS type */
3661 alc_write_coef_idx(codec, 0x45, 0xc429);
3662 /* Combo Jack auto detect */
3663 val = alc_read_coef_idx(codec, 0x4a);
3664 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x000e);
3665 break;
73bdd597
DH
3666 case 0x10ec0668:
3667 alc_write_coef_idx(codec, 0x15, 0x0d40);
3668 alc_write_coef_idx(codec, 0xb7, 0x802b);
3669 break;
3670 }
4e76a883 3671 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
73bdd597
DH
3672}
3673
3674
3675static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3676 hda_nid_t mic_pin)
3677{
3678 int val;
3679
3680 switch (codec->vendor_id) {
9a22a8f5
KY
3681 case 0x10ec0255:
3682 alc_write_coef_idx(codec, 0x45, 0xc489);
3683 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3684 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3685 /* Set MIC2 Vref gate to normal */
3686 alc_write_coef_idx(codec, 0x06, 0x6100);
3687 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3688 break;
13fd08a3 3689 case 0x10ec0233:
73bdd597
DH
3690 case 0x10ec0283:
3691 alc_write_coef_idx(codec, 0x45, 0xc429);
3692 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3693 val = alc_read_coef_idx(codec, 0x35);
3694 alc_write_coef_idx(codec, 0x35, val | 1<<14);
3695 alc_write_coef_idx(codec, 0x06, 0x2100);
3696 alc_write_coef_idx(codec, 0x1a, 0x0021);
3697 alc_write_coef_idx(codec, 0x26, 0x008c);
3698 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3699 break;
3700 case 0x10ec0292:
3701 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3702 alc_write_coef_idx(codec, 0x19, 0xa208);
3703 alc_write_coef_idx(codec, 0x2e, 0xacf0);
3704 break;
a22aa26f
KY
3705 case 0x10ec0293:
3706 /* Set to TRS mode */
3707 alc_write_coef_idx(codec, 0x45, 0xc429);
3708 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3709 /* SET charge pump by verb */
3710 val = alc_read_coefex_idx(codec, 0x57, 0x05);
3711 alc_write_coefex_idx(codec, 0x57, 0x05, (val & ~(1<<15|1<<13)) | (1<<15|1<<13));
3712 /* SET EN_OSW to 0 */
3713 val = alc_read_coefex_idx(codec, 0x57, 0x03);
3714 alc_write_coefex_idx(codec, 0x57, 0x03, (val & ~(1<<10)) | 0x0);
3715 /* Combo JD gating without LINE1-VREFO */
3716 val = alc_read_coef_idx(codec, 0x1a);
3717 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | 0x0);
3718 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3719 break;
73bdd597
DH
3720 case 0x10ec0668:
3721 alc_write_coef_idx(codec, 0x11, 0x0001);
3722 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3723 alc_write_coef_idx(codec, 0xb7, 0x802b);
3724 alc_write_coef_idx(codec, 0xb5, 0x1040);
3725 val = alc_read_coef_idx(codec, 0xc3);
3726 alc_write_coef_idx(codec, 0xc3, val | 1<<12);
3727 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3728 break;
3729 }
4e76a883 3730 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
73bdd597
DH
3731}
3732
3733static void alc_headset_mode_default(struct hda_codec *codec)
3734{
a22aa26f
KY
3735 int val;
3736
73bdd597 3737 switch (codec->vendor_id) {
9a22a8f5
KY
3738 case 0x10ec0255:
3739 alc_write_coef_idx(codec, 0x45, 0xc089);
3740 alc_write_coef_idx(codec, 0x45, 0xc489);
3741 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3742 alc_write_coef_idx(codec, 0x49, 0x0049);
3743 break;
13fd08a3 3744 case 0x10ec0233:
73bdd597
DH
3745 case 0x10ec0283:
3746 alc_write_coef_idx(codec, 0x06, 0x2100);
3747 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3748 break;
3749 case 0x10ec0292:
3750 alc_write_coef_idx(codec, 0x76, 0x000e);
3751 alc_write_coef_idx(codec, 0x6c, 0x2400);
3752 alc_write_coef_idx(codec, 0x6b, 0xc429);
3753 alc_write_coef_idx(codec, 0x18, 0x7308);
3754 break;
a22aa26f
KY
3755 case 0x10ec0293:
3756 /* Combo Jack auto detect */
3757 val = alc_read_coef_idx(codec, 0x4a);
3758 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x000e);
3759 /* Set to TRS type */
3760 alc_write_coef_idx(codec, 0x45, 0xC429);
3761 /* Combo JD gating without LINE1-VREFO */
3762 val = alc_read_coef_idx(codec, 0x1a);
3763 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | 0x0);
3764 break;
73bdd597
DH
3765 case 0x10ec0668:
3766 alc_write_coef_idx(codec, 0x11, 0x0041);
3767 alc_write_coef_idx(codec, 0x15, 0x0d40);
3768 alc_write_coef_idx(codec, 0xb7, 0x802b);
3769 break;
3770 }
4e76a883 3771 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
73bdd597
DH
3772}
3773
3774/* Iphone type */
3775static void alc_headset_mode_ctia(struct hda_codec *codec)
3776{
a22aa26f
KY
3777 int val;
3778
73bdd597 3779 switch (codec->vendor_id) {
9a22a8f5
KY
3780 case 0x10ec0255:
3781 /* Set to CTIA type */
3782 alc_write_coef_idx(codec, 0x45, 0xd489);
3783 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3784 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3785 break;
13fd08a3 3786 case 0x10ec0233:
73bdd597
DH
3787 case 0x10ec0283:
3788 alc_write_coef_idx(codec, 0x45, 0xd429);
3789 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3790 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3791 break;
3792 case 0x10ec0292:
3793 alc_write_coef_idx(codec, 0x6b, 0xd429);
3794 alc_write_coef_idx(codec, 0x76, 0x0008);
3795 alc_write_coef_idx(codec, 0x18, 0x7388);
3796 break;
a22aa26f
KY
3797 case 0x10ec0293:
3798 /* Set to ctia type */
3799 alc_write_coef_idx(codec, 0x45, 0xd429);
3800 /* SET Line1 JD to 1 */
3801 val = alc_read_coef_idx(codec, 0x10);
3802 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 7<<8);
3803 break;
73bdd597 3804 case 0x10ec0668:
d59915d0 3805 alc_write_coef_idx(codec, 0x11, 0x0001);
73bdd597
DH
3806 alc_write_coef_idx(codec, 0x15, 0x0d60);
3807 alc_write_coef_idx(codec, 0xc3, 0x0000);
3808 break;
3809 }
4e76a883 3810 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
73bdd597
DH
3811}
3812
3813/* Nokia type */
3814static void alc_headset_mode_omtp(struct hda_codec *codec)
3815{
a22aa26f
KY
3816 int val;
3817
73bdd597 3818 switch (codec->vendor_id) {
9a22a8f5
KY
3819 case 0x10ec0255:
3820 /* Set to OMTP Type */
3821 alc_write_coef_idx(codec, 0x45, 0xe489);
3822 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3823 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3824 break;
13fd08a3 3825 case 0x10ec0233:
73bdd597
DH
3826 case 0x10ec0283:
3827 alc_write_coef_idx(codec, 0x45, 0xe429);
3828 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3829 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3830 break;
3831 case 0x10ec0292:
3832 alc_write_coef_idx(codec, 0x6b, 0xe429);
3833 alc_write_coef_idx(codec, 0x76, 0x0008);
3834 alc_write_coef_idx(codec, 0x18, 0x7388);
3835 break;
a22aa26f
KY
3836 case 0x10ec0293:
3837 /* Set to omtp type */
3838 alc_write_coef_idx(codec, 0x45, 0xe429);
3839 /* SET Line1 JD to 1 */
3840 val = alc_read_coef_idx(codec, 0x10);
3841 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 7<<8);
3842 break;
73bdd597 3843 case 0x10ec0668:
d59915d0 3844 alc_write_coef_idx(codec, 0x11, 0x0001);
73bdd597
DH
3845 alc_write_coef_idx(codec, 0x15, 0x0d50);
3846 alc_write_coef_idx(codec, 0xc3, 0x0000);
3847 break;
3848 }
4e76a883 3849 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
73bdd597
DH
3850}
3851
3852static void alc_determine_headset_type(struct hda_codec *codec)
3853{
3854 int val;
3855 bool is_ctia = false;
3856 struct alc_spec *spec = codec->spec;
3857
3858 switch (codec->vendor_id) {
9a22a8f5
KY
3859 case 0x10ec0255:
3860 /* combo jack auto switch control(Check type)*/
3861 alc_write_coef_idx(codec, 0x45, 0xd089);
3862 /* combo jack auto switch control(Vref conteol) */
3863 alc_write_coef_idx(codec, 0x49, 0x0149);
3864 msleep(300);
3865 val = alc_read_coef_idx(codec, 0x46);
3866 is_ctia = (val & 0x0070) == 0x0070;
3867 break;
13fd08a3 3868 case 0x10ec0233:
73bdd597
DH
3869 case 0x10ec0283:
3870 alc_write_coef_idx(codec, 0x45, 0xd029);
3871 msleep(300);
3872 val = alc_read_coef_idx(codec, 0x46);
3873 is_ctia = (val & 0x0070) == 0x0070;
3874 break;
3875 case 0x10ec0292:
3876 alc_write_coef_idx(codec, 0x6b, 0xd429);
3877 msleep(300);
3878 val = alc_read_coef_idx(codec, 0x6c);
3879 is_ctia = (val & 0x001c) == 0x001c;
3880 break;
a22aa26f
KY
3881 case 0x10ec0293:
3882 /* Combo Jack auto detect */
3883 val = alc_read_coef_idx(codec, 0x4a);
3884 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x0008);
3885 /* Set to ctia type */
3886 alc_write_coef_idx(codec, 0x45, 0xD429);
3887 msleep(300);
3888 val = alc_read_coef_idx(codec, 0x46);
3889 is_ctia = (val & 0x0070) == 0x0070;
3890 break;
73bdd597
DH
3891 case 0x10ec0668:
3892 alc_write_coef_idx(codec, 0x11, 0x0001);
3893 alc_write_coef_idx(codec, 0xb7, 0x802b);
3894 alc_write_coef_idx(codec, 0x15, 0x0d60);
3895 alc_write_coef_idx(codec, 0xc3, 0x0c00);
3896 msleep(300);
3897 val = alc_read_coef_idx(codec, 0xbe);
3898 is_ctia = (val & 0x1c02) == 0x1c02;
3899 break;
3900 }
3901
4e76a883 3902 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
73bdd597
DH
3903 is_ctia ? "yes" : "no");
3904 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3905}
3906
3907static void alc_update_headset_mode(struct hda_codec *codec)
3908{
3909 struct alc_spec *spec = codec->spec;
3910
3911 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
3912 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3913
3914 int new_headset_mode;
3915
3916 if (!snd_hda_jack_detect(codec, hp_pin))
3917 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
3918 else if (mux_pin == spec->headset_mic_pin)
3919 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
3920 else if (mux_pin == spec->headphone_mic_pin)
3921 new_headset_mode = ALC_HEADSET_MODE_MIC;
3922 else
3923 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
3924
5959a6bc
DH
3925 if (new_headset_mode == spec->current_headset_mode) {
3926 snd_hda_gen_update_outputs(codec);
73bdd597 3927 return;
5959a6bc 3928 }
73bdd597
DH
3929
3930 switch (new_headset_mode) {
3931 case ALC_HEADSET_MODE_UNPLUGGED:
3932 alc_headset_mode_unplugged(codec);
3933 spec->gen.hp_jack_present = false;
3934 break;
3935 case ALC_HEADSET_MODE_HEADSET:
3936 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
3937 alc_determine_headset_type(codec);
3938 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
3939 alc_headset_mode_ctia(codec);
3940 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
3941 alc_headset_mode_omtp(codec);
3942 spec->gen.hp_jack_present = true;
3943 break;
3944 case ALC_HEADSET_MODE_MIC:
3945 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
3946 spec->gen.hp_jack_present = false;
3947 break;
3948 case ALC_HEADSET_MODE_HEADPHONE:
3949 alc_headset_mode_default(codec);
3950 spec->gen.hp_jack_present = true;
3951 break;
3952 }
3953 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
3954 snd_hda_set_pin_ctl_cache(codec, hp_pin,
3955 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3956 if (spec->headphone_mic_pin)
3957 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
3958 PIN_VREFHIZ);
3959 }
3960 spec->current_headset_mode = new_headset_mode;
3961
3962 snd_hda_gen_update_outputs(codec);
3963}
3964
3965static void alc_update_headset_mode_hook(struct hda_codec *codec,
7fe30711
TI
3966 struct snd_kcontrol *kcontrol,
3967 struct snd_ctl_elem_value *ucontrol)
73bdd597
DH
3968{
3969 alc_update_headset_mode(codec);
3970}
3971
3972static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack)
3973{
3974 struct alc_spec *spec = codec->spec;
5db4d34b 3975 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
73bdd597
DH
3976 snd_hda_gen_hp_automute(codec, jack);
3977}
3978
3979static void alc_probe_headset_mode(struct hda_codec *codec)
3980{
3981 int i;
3982 struct alc_spec *spec = codec->spec;
3983 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3984
3985 /* Find mic pins */
3986 for (i = 0; i < cfg->num_inputs; i++) {
3987 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
3988 spec->headset_mic_pin = cfg->inputs[i].pin;
3989 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
3990 spec->headphone_mic_pin = cfg->inputs[i].pin;
3991 }
3992
3993 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
3994 spec->gen.automute_hook = alc_update_headset_mode;
3995 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
3996}
3997
3998static void alc_fixup_headset_mode(struct hda_codec *codec,
3999 const struct hda_fixup *fix, int action)
4000{
4001 struct alc_spec *spec = codec->spec;
4002
4003 switch (action) {
4004 case HDA_FIXUP_ACT_PRE_PROBE:
4005 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
4006 break;
4007 case HDA_FIXUP_ACT_PROBE:
4008 alc_probe_headset_mode(codec);
4009 break;
4010 case HDA_FIXUP_ACT_INIT:
4011 spec->current_headset_mode = 0;
4012 alc_update_headset_mode(codec);
4013 break;
4014 }
4015}
4016
4017static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
4018 const struct hda_fixup *fix, int action)
4019{
4020 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4021 struct alc_spec *spec = codec->spec;
4022 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4023 }
4024 else
4025 alc_fixup_headset_mode(codec, fix, action);
4026}
4027
31278997
KY
4028static void alc255_set_default_jack_type(struct hda_codec *codec)
4029{
4030 /* Set to iphone type */
4031 alc_write_coef_idx(codec, 0x1b, 0x880b);
4032 alc_write_coef_idx(codec, 0x45, 0xd089);
4033 alc_write_coef_idx(codec, 0x1b, 0x080b);
4034 alc_write_coef_idx(codec, 0x46, 0x0004);
4035 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
4036 msleep(30);
4037}
4038
9a22a8f5
KY
4039static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
4040 const struct hda_fixup *fix, int action)
4041{
4042 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
31278997 4043 alc255_set_default_jack_type(codec);
9a22a8f5
KY
4044 }
4045 alc_fixup_headset_mode(codec, fix, action);
4046}
4047
31278997
KY
4048static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
4049 const struct hda_fixup *fix, int action)
4050{
4051 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4052 struct alc_spec *spec = codec->spec;
4053 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4054 alc255_set_default_jack_type(codec);
4055 }
4056 else
4057 alc_fixup_headset_mode(codec, fix, action);
4058}
4059
493a52a9
HW
4060static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
4061 const struct hda_fixup *fix, int action)
4062{
4063 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4064 struct alc_spec *spec = codec->spec;
4065 spec->gen.auto_mute_via_amp = 1;
4066 }
4067}
4068
9b745ab8
TI
4069static void alc_no_shutup(struct hda_codec *codec)
4070{
4071}
4072
4073static void alc_fixup_no_shutup(struct hda_codec *codec,
4074 const struct hda_fixup *fix, int action)
4075{
4076 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4077 struct alc_spec *spec = codec->spec;
4078 spec->shutup = alc_no_shutup;
4079 }
4080}
4081
5e6db669
GM
4082static void alc_fixup_disable_aamix(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 /* Disable AA-loopback as it causes white noise */
4088 spec->gen.mixer_nid = 0;
4089 }
4090}
4091
033b0a7c
GM
4092static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
4093 hda_nid_t nid,
4094 unsigned int power_state)
4095{
4096 struct alc_spec *spec = codec->spec;
4097
4098 /* Avoid pop noises when headphones are plugged in */
4099 if (spec->gen.hp_jack_present)
de3da4f6 4100 if (nid == codec->afg || nid == 0x02 || nid == 0x15)
033b0a7c
GM
4101 return AC_PWRST_D0;
4102 return power_state;
4103}
4104
4105static void alc_fixup_dell_xps13(struct hda_codec *codec,
4106 const struct hda_fixup *fix, int action)
4107{
4108 if (action == HDA_FIXUP_ACT_PROBE) {
4109 struct alc_spec *spec = codec->spec;
f38663ab
GM
4110 struct hda_input_mux *imux = &spec->gen.input_mux;
4111 int i;
4112
033b0a7c
GM
4113 spec->shutup = alc_no_shutup;
4114 codec->power_filter = alc_power_filter_xps13;
f38663ab
GM
4115
4116 /* Make the internal mic the default input source. */
4117 for (i = 0; i < imux->num_items; i++) {
4118 if (spec->gen.imux_pins[i] == 0x12) {
4119 spec->gen.cur_mux[0] = i;
4120 break;
4121 }
4122 }
033b0a7c
GM
4123 }
4124}
4125
73bdd597
DH
4126static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
4127 const struct hda_fixup *fix, int action)
4128{
4129 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4130 int val;
4131 alc_write_coef_idx(codec, 0xc4, 0x8000);
4132 val = alc_read_coef_idx(codec, 0xc2);
4133 alc_write_coef_idx(codec, 0xc2, val & 0xfe);
4134 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
4135 }
4136 alc_fixup_headset_mode(codec, fix, action);
4137}
4138
bde7bc60
CCC
4139/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
4140static int find_ext_mic_pin(struct hda_codec *codec)
4141{
4142 struct alc_spec *spec = codec->spec;
4143 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4144 hda_nid_t nid;
4145 unsigned int defcfg;
4146 int i;
4147
4148 for (i = 0; i < cfg->num_inputs; i++) {
4149 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4150 continue;
4151 nid = cfg->inputs[i].pin;
4152 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4153 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
4154 continue;
4155 return nid;
4156 }
4157
4158 return 0;
4159}
4160
08a978db 4161static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
1727a771 4162 const struct hda_fixup *fix,
08a978db
DR
4163 int action)
4164{
4165 struct alc_spec *spec = codec->spec;
4166
0db75790 4167 if (action == HDA_FIXUP_ACT_PROBE) {
bde7bc60
CCC
4168 int mic_pin = find_ext_mic_pin(codec);
4169 int hp_pin = spec->gen.autocfg.hp_pins[0];
4170
4171 if (snd_BUG_ON(!mic_pin || !hp_pin))
0db75790 4172 return;
bde7bc60 4173 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
0db75790 4174 }
08a978db 4175}
693b613d 4176
3e0d611b
DH
4177static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
4178 const struct hda_fixup *fix,
4179 int action)
4180{
4181 struct alc_spec *spec = codec->spec;
4182 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4183 int i;
4184
4185 /* The mic boosts on level 2 and 3 are too noisy
4186 on the internal mic input.
4187 Therefore limit the boost to 0 or 1. */
4188
4189 if (action != HDA_FIXUP_ACT_PROBE)
4190 return;
4191
4192 for (i = 0; i < cfg->num_inputs; i++) {
4193 hda_nid_t nid = cfg->inputs[i].pin;
4194 unsigned int defcfg;
4195 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4196 continue;
4197 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4198 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
4199 continue;
4200
4201 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
4202 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
4203 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4204 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
4205 (0 << AC_AMPCAP_MUTE_SHIFT));
4206 }
4207}
4208
cd217a63
KY
4209static void alc283_hp_automute_hook(struct hda_codec *codec,
4210 struct hda_jack_tbl *jack)
4211{
4212 struct alc_spec *spec = codec->spec;
4213 int vref;
4214
4215 msleep(200);
4216 snd_hda_gen_hp_automute(codec, jack);
4217
4218 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4219
4220 msleep(600);
4221 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4222 vref);
4223}
4224
cd217a63
KY
4225static void alc283_fixup_chromebook(struct hda_codec *codec,
4226 const struct hda_fixup *fix, int action)
4227{
4228 struct alc_spec *spec = codec->spec;
4229 int val;
4230
4231 switch (action) {
4232 case HDA_FIXUP_ACT_PRE_PROBE:
0202e99c 4233 snd_hda_override_wcaps(codec, 0x03, 0);
d2e92709
TI
4234 /* Disable AA-loopback as it causes white noise */
4235 spec->gen.mixer_nid = 0;
38070219 4236 break;
0202e99c 4237 case HDA_FIXUP_ACT_INIT:
de9481cb
KY
4238 /* MIC2-VREF control */
4239 /* Set to manual mode */
4240 val = alc_read_coef_idx(codec, 0x06);
4241 alc_write_coef_idx(codec, 0x06, val & ~0x000c);
0202e99c
KY
4242 /* Enable Line1 input control by verb */
4243 val = alc_read_coef_idx(codec, 0x1a);
4244 alc_write_coef_idx(codec, 0x1a, val | (1 << 4));
4245 break;
4246 }
4247}
4248
4249static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
4250 const struct hda_fixup *fix, int action)
4251{
4252 struct alc_spec *spec = codec->spec;
4253 int val;
4254
4255 switch (action) {
4256 case HDA_FIXUP_ACT_PRE_PROBE:
cd217a63 4257 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
38070219
KY
4258 break;
4259 case HDA_FIXUP_ACT_INIT:
cd217a63
KY
4260 /* MIC2-VREF control */
4261 /* Set to manual mode */
4262 val = alc_read_coef_idx(codec, 0x06);
4263 alc_write_coef_idx(codec, 0x06, val & ~0x000c);
4264 break;
4265 }
4266}
4267
7bba2157
TI
4268/* mute tablet speaker pin (0x14) via dock plugging in addition */
4269static void asus_tx300_automute(struct hda_codec *codec)
4270{
4271 struct alc_spec *spec = codec->spec;
4272 snd_hda_gen_update_outputs(codec);
4273 if (snd_hda_jack_detect(codec, 0x1b))
4274 spec->gen.mute_bits |= (1ULL << 0x14);
4275}
4276
4277static void alc282_fixup_asus_tx300(struct hda_codec *codec,
4278 const struct hda_fixup *fix, int action)
4279{
4280 struct alc_spec *spec = codec->spec;
4281 /* TX300 needs to set up GPIO2 for the speaker amp */
4282 static const struct hda_verb gpio2_verbs[] = {
4283 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4284 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4285 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
4286 {}
4287 };
4288 static const struct hda_pintbl dock_pins[] = {
4289 { 0x1b, 0x21114000 }, /* dock speaker pin */
4290 {}
4291 };
4292 struct snd_kcontrol *kctl;
4293
4294 switch (action) {
4295 case HDA_FIXUP_ACT_PRE_PROBE:
4296 snd_hda_add_verbs(codec, gpio2_verbs);
4297 snd_hda_apply_pincfgs(codec, dock_pins);
4298 spec->gen.auto_mute_via_amp = 1;
4299 spec->gen.automute_hook = asus_tx300_automute;
4300 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4301 HDA_GEN_HP_EVENT,
4302 snd_hda_gen_hp_automute);
4303 break;
4304 case HDA_FIXUP_ACT_BUILD:
4305 /* this is a bit tricky; give more sane names for the main
4306 * (tablet) speaker and the dock speaker, respectively
4307 */
4308 kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch");
4309 if (kctl)
4310 strcpy(kctl->id.name, "Dock Speaker Playback Switch");
4311 kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch");
4312 if (kctl)
4313 strcpy(kctl->id.name, "Speaker Playback Switch");
4314 break;
4315 }
4316}
4317
338cae56
DH
4318static void alc290_fixup_mono_speakers(struct hda_codec *codec,
4319 const struct hda_fixup *fix, int action)
4320{
0f4881dc
DH
4321 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4322 /* DAC node 0x03 is giving mono output. We therefore want to
4323 make sure 0x14 (front speaker) and 0x15 (headphones) use the
4324 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
4325 hda_nid_t conn1[2] = { 0x0c };
4326 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
4327 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
4328 }
338cae56
DH
4329}
4330
b317b032
TI
4331/* for hda_fixup_thinkpad_acpi() */
4332#include "thinkpad_helper.c"
b67ae3f1 4333
00ef9940
HW
4334/* for dell wmi mic mute led */
4335#include "dell_wmi_helper.c"
4336
1d045db9
TI
4337enum {
4338 ALC269_FIXUP_SONY_VAIO,
4339 ALC275_FIXUP_SONY_VAIO_GPIO2,
4340 ALC269_FIXUP_DELL_M101Z,
4341 ALC269_FIXUP_SKU_IGNORE,
4342 ALC269_FIXUP_ASUS_G73JW,
4343 ALC269_FIXUP_LENOVO_EAPD,
4344 ALC275_FIXUP_SONY_HWEQ,
e9bd7d5c 4345 ALC275_FIXUP_SONY_DISABLE_AAMIX,
1d045db9 4346 ALC271_FIXUP_DMIC,
017f2a10 4347 ALC269_FIXUP_PCM_44K,
adabb3ec 4348 ALC269_FIXUP_STEREO_DMIC,
7c478f03 4349 ALC269_FIXUP_HEADSET_MIC,
24519911
TI
4350 ALC269_FIXUP_QUANTA_MUTE,
4351 ALC269_FIXUP_LIFEBOOK,
2041d564 4352 ALC269_FIXUP_LIFEBOOK_EXTMIC,
a4297b5d
TI
4353 ALC269_FIXUP_AMIC,
4354 ALC269_FIXUP_DMIC,
4355 ALC269VB_FIXUP_AMIC,
4356 ALC269VB_FIXUP_DMIC,
08fb0d0e 4357 ALC269_FIXUP_HP_MUTE_LED,
d06ac143 4358 ALC269_FIXUP_HP_MUTE_LED_MIC1,
08fb0d0e 4359 ALC269_FIXUP_HP_MUTE_LED_MIC2,
9f5c6faf 4360 ALC269_FIXUP_HP_GPIO_LED,
9c5dc3bf
KY
4361 ALC269_FIXUP_HP_GPIO_MIC1_LED,
4362 ALC269_FIXUP_HP_LINE1_MIC1_LED,
693b613d 4363 ALC269_FIXUP_INV_DMIC,
108cc108 4364 ALC269_FIXUP_LENOVO_DOCK,
9b745ab8 4365 ALC269_FIXUP_NO_SHUTUP,
88cfcf86 4366 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
108cc108 4367 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
73bdd597
DH
4368 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
4369 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
338cae56 4370 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
73bdd597
DH
4371 ALC269_FIXUP_HEADSET_MODE,
4372 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
d240d1dc
DH
4373 ALC269_FIXUP_ASUS_X101_FUNC,
4374 ALC269_FIXUP_ASUS_X101_VERB,
4375 ALC269_FIXUP_ASUS_X101,
08a978db
DR
4376 ALC271_FIXUP_AMIC_MIC2,
4377 ALC271_FIXUP_HP_GATE_MIC_JACK,
b1e8972e 4378 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
42397004 4379 ALC269_FIXUP_ACER_AC700,
3e0d611b 4380 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
2cede303 4381 ALC269VB_FIXUP_ASUS_ZENBOOK,
23870831 4382 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
8e35cd4a 4383 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
02b504d9 4384 ALC269VB_FIXUP_ORDISSIMO_EVE2,
cd217a63 4385 ALC283_FIXUP_CHROME_BOOK,
0202e99c 4386 ALC283_FIXUP_SENSE_COMBO_JACK,
7bba2157 4387 ALC282_FIXUP_ASUS_TX300,
1bb3e062 4388 ALC283_FIXUP_INT_MIC,
338cae56 4389 ALC290_FIXUP_MONO_SPEAKERS,
0f4881dc
DH
4390 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4391 ALC290_FIXUP_SUBWOOFER,
4392 ALC290_FIXUP_SUBWOOFER_HSJACK,
b67ae3f1 4393 ALC269_FIXUP_THINKPAD_ACPI,
9a22a8f5 4394 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
31278997 4395 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9a22a8f5 4396 ALC255_FIXUP_HEADSET_MODE,
31278997 4397 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
a22aa26f 4398 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
1c37c223 4399 ALC292_FIXUP_TPT440_DOCK,
9dc12862 4400 ALC283_FIXUP_BXBT2807_MIC,
00ef9940 4401 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
f1d4e28b
KY
4402};
4403
1727a771 4404static const struct hda_fixup alc269_fixups[] = {
1d045db9 4405 [ALC269_FIXUP_SONY_VAIO] = {
fd108215
TI
4406 .type = HDA_FIXUP_PINCTLS,
4407 .v.pins = (const struct hda_pintbl[]) {
4408 {0x19, PIN_VREFGRD},
1d045db9
TI
4409 {}
4410 }
f1d4e28b 4411 },
1d045db9 4412 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
1727a771 4413 .type = HDA_FIXUP_VERBS,
1d045db9
TI
4414 .v.verbs = (const struct hda_verb[]) {
4415 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
4416 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
4417 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4418 { }
4419 },
4420 .chained = true,
4421 .chain_id = ALC269_FIXUP_SONY_VAIO
4422 },
4423 [ALC269_FIXUP_DELL_M101Z] = {
1727a771 4424 .type = HDA_FIXUP_VERBS,
1d045db9
TI
4425 .v.verbs = (const struct hda_verb[]) {
4426 /* Enables internal speaker */
4427 {0x20, AC_VERB_SET_COEF_INDEX, 13},
4428 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4429 {}
4430 }
4431 },
4432 [ALC269_FIXUP_SKU_IGNORE] = {
1727a771 4433 .type = HDA_FIXUP_FUNC,
23d30f28 4434 .v.func = alc_fixup_sku_ignore,
1d045db9
TI
4435 },
4436 [ALC269_FIXUP_ASUS_G73JW] = {
1727a771
TI
4437 .type = HDA_FIXUP_PINS,
4438 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
4439 { 0x17, 0x99130111 }, /* subwoofer */
4440 { }
4441 }
4442 },
4443 [ALC269_FIXUP_LENOVO_EAPD] = {
1727a771 4444 .type = HDA_FIXUP_VERBS,
1d045db9
TI
4445 .v.verbs = (const struct hda_verb[]) {
4446 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4447 {}
4448 }
4449 },
4450 [ALC275_FIXUP_SONY_HWEQ] = {
1727a771 4451 .type = HDA_FIXUP_FUNC,
1d045db9
TI
4452 .v.func = alc269_fixup_hweq,
4453 .chained = true,
4454 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
4455 },
e9bd7d5c
TI
4456 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
4457 .type = HDA_FIXUP_FUNC,
4458 .v.func = alc_fixup_disable_aamix,
4459 .chained = true,
4460 .chain_id = ALC269_FIXUP_SONY_VAIO
4461 },
1d045db9 4462 [ALC271_FIXUP_DMIC] = {
1727a771 4463 .type = HDA_FIXUP_FUNC,
1d045db9 4464 .v.func = alc271_fixup_dmic,
f1d4e28b 4465 },
017f2a10 4466 [ALC269_FIXUP_PCM_44K] = {
1727a771 4467 .type = HDA_FIXUP_FUNC,
017f2a10 4468 .v.func = alc269_fixup_pcm_44k,
012e7eb1
DH
4469 .chained = true,
4470 .chain_id = ALC269_FIXUP_QUANTA_MUTE
017f2a10 4471 },
adabb3ec 4472 [ALC269_FIXUP_STEREO_DMIC] = {
1727a771 4473 .type = HDA_FIXUP_FUNC,
adabb3ec
TI
4474 .v.func = alc269_fixup_stereo_dmic,
4475 },
7c478f03
DH
4476 [ALC269_FIXUP_HEADSET_MIC] = {
4477 .type = HDA_FIXUP_FUNC,
4478 .v.func = alc269_fixup_headset_mic,
4479 },
24519911 4480 [ALC269_FIXUP_QUANTA_MUTE] = {
1727a771 4481 .type = HDA_FIXUP_FUNC,
24519911
TI
4482 .v.func = alc269_fixup_quanta_mute,
4483 },
4484 [ALC269_FIXUP_LIFEBOOK] = {
1727a771
TI
4485 .type = HDA_FIXUP_PINS,
4486 .v.pins = (const struct hda_pintbl[]) {
24519911
TI
4487 { 0x1a, 0x2101103f }, /* dock line-out */
4488 { 0x1b, 0x23a11040 }, /* dock mic-in */
4489 { }
4490 },
4491 .chained = true,
4492 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4493 },
2041d564
DH
4494 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
4495 .type = HDA_FIXUP_PINS,
4496 .v.pins = (const struct hda_pintbl[]) {
4497 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
4498 { }
4499 },
4500 },
a4297b5d 4501 [ALC269_FIXUP_AMIC] = {
1727a771
TI
4502 .type = HDA_FIXUP_PINS,
4503 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4504 { 0x14, 0x99130110 }, /* speaker */
4505 { 0x15, 0x0121401f }, /* HP out */
4506 { 0x18, 0x01a19c20 }, /* mic */
4507 { 0x19, 0x99a3092f }, /* int-mic */
4508 { }
4509 },
4510 },
4511 [ALC269_FIXUP_DMIC] = {
1727a771
TI
4512 .type = HDA_FIXUP_PINS,
4513 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4514 { 0x12, 0x99a3092f }, /* int-mic */
4515 { 0x14, 0x99130110 }, /* speaker */
4516 { 0x15, 0x0121401f }, /* HP out */
4517 { 0x18, 0x01a19c20 }, /* mic */
4518 { }
4519 },
4520 },
4521 [ALC269VB_FIXUP_AMIC] = {
1727a771
TI
4522 .type = HDA_FIXUP_PINS,
4523 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4524 { 0x14, 0x99130110 }, /* speaker */
4525 { 0x18, 0x01a19c20 }, /* mic */
4526 { 0x19, 0x99a3092f }, /* int-mic */
4527 { 0x21, 0x0121401f }, /* HP out */
4528 { }
4529 },
4530 },
2267ea97 4531 [ALC269VB_FIXUP_DMIC] = {
1727a771
TI
4532 .type = HDA_FIXUP_PINS,
4533 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
4534 { 0x12, 0x99a3092f }, /* int-mic */
4535 { 0x14, 0x99130110 }, /* speaker */
4536 { 0x18, 0x01a19c20 }, /* mic */
4537 { 0x21, 0x0121401f }, /* HP out */
4538 { }
4539 },
4540 },
08fb0d0e 4541 [ALC269_FIXUP_HP_MUTE_LED] = {
1727a771 4542 .type = HDA_FIXUP_FUNC,
08fb0d0e 4543 .v.func = alc269_fixup_hp_mute_led,
6d3cd5d4 4544 },
d06ac143
DH
4545 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
4546 .type = HDA_FIXUP_FUNC,
4547 .v.func = alc269_fixup_hp_mute_led_mic1,
4548 },
08fb0d0e 4549 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
1727a771 4550 .type = HDA_FIXUP_FUNC,
08fb0d0e 4551 .v.func = alc269_fixup_hp_mute_led_mic2,
420b0feb 4552 },
9f5c6faf
TI
4553 [ALC269_FIXUP_HP_GPIO_LED] = {
4554 .type = HDA_FIXUP_FUNC,
4555 .v.func = alc269_fixup_hp_gpio_led,
4556 },
9c5dc3bf
KY
4557 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
4558 .type = HDA_FIXUP_FUNC,
4559 .v.func = alc269_fixup_hp_gpio_mic1_led,
4560 },
4561 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
4562 .type = HDA_FIXUP_FUNC,
4563 .v.func = alc269_fixup_hp_line1_mic1_led,
4564 },
693b613d 4565 [ALC269_FIXUP_INV_DMIC] = {
1727a771 4566 .type = HDA_FIXUP_FUNC,
6e72aa5f 4567 .v.func = alc_fixup_inv_dmic_0x12,
693b613d 4568 },
9b745ab8
TI
4569 [ALC269_FIXUP_NO_SHUTUP] = {
4570 .type = HDA_FIXUP_FUNC,
4571 .v.func = alc_fixup_no_shutup,
4572 },
108cc108 4573 [ALC269_FIXUP_LENOVO_DOCK] = {
1727a771
TI
4574 .type = HDA_FIXUP_PINS,
4575 .v.pins = (const struct hda_pintbl[]) {
108cc108
DH
4576 { 0x19, 0x23a11040 }, /* dock mic */
4577 { 0x1b, 0x2121103f }, /* dock headphone */
4578 { }
4579 },
4580 .chained = true,
4581 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
4582 },
4583 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
1727a771 4584 .type = HDA_FIXUP_FUNC,
108cc108 4585 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
52129000
DH
4586 .chained = true,
4587 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
108cc108 4588 },
73bdd597
DH
4589 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4590 .type = HDA_FIXUP_PINS,
4591 .v.pins = (const struct hda_pintbl[]) {
4592 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4593 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4594 { }
4595 },
4596 .chained = true,
4597 .chain_id = ALC269_FIXUP_HEADSET_MODE
4598 },
4599 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4600 .type = HDA_FIXUP_PINS,
4601 .v.pins = (const struct hda_pintbl[]) {
4602 { 0x16, 0x21014020 }, /* dock line out */
4603 { 0x19, 0x21a19030 }, /* dock mic */
4604 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4605 { }
4606 },
4607 .chained = true,
4608 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4609 },
338cae56
DH
4610 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
4611 .type = HDA_FIXUP_PINS,
4612 .v.pins = (const struct hda_pintbl[]) {
4613 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4614 { }
4615 },
4616 .chained = true,
4617 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4618 },
73bdd597
DH
4619 [ALC269_FIXUP_HEADSET_MODE] = {
4620 .type = HDA_FIXUP_FUNC,
4621 .v.func = alc_fixup_headset_mode,
4622 },
4623 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4624 .type = HDA_FIXUP_FUNC,
4625 .v.func = alc_fixup_headset_mode_no_hp_mic,
4626 },
88cfcf86
DH
4627 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
4628 .type = HDA_FIXUP_PINS,
4629 .v.pins = (const struct hda_pintbl[]) {
4630 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4631 { }
4632 },
fbc78ad6
DH
4633 .chained = true,
4634 .chain_id = ALC269_FIXUP_HEADSET_MIC
88cfcf86 4635 },
d240d1dc
DH
4636 [ALC269_FIXUP_ASUS_X101_FUNC] = {
4637 .type = HDA_FIXUP_FUNC,
4638 .v.func = alc269_fixup_x101_headset_mic,
4639 },
4640 [ALC269_FIXUP_ASUS_X101_VERB] = {
4641 .type = HDA_FIXUP_VERBS,
4642 .v.verbs = (const struct hda_verb[]) {
4643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4644 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
4645 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
4646 { }
4647 },
4648 .chained = true,
4649 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
4650 },
4651 [ALC269_FIXUP_ASUS_X101] = {
4652 .type = HDA_FIXUP_PINS,
4653 .v.pins = (const struct hda_pintbl[]) {
4654 { 0x18, 0x04a1182c }, /* Headset mic */
4655 { }
4656 },
4657 .chained = true,
4658 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
4659 },
08a978db 4660 [ALC271_FIXUP_AMIC_MIC2] = {
1727a771
TI
4661 .type = HDA_FIXUP_PINS,
4662 .v.pins = (const struct hda_pintbl[]) {
08a978db
DR
4663 { 0x14, 0x99130110 }, /* speaker */
4664 { 0x19, 0x01a19c20 }, /* mic */
4665 { 0x1b, 0x99a7012f }, /* int-mic */
4666 { 0x21, 0x0121401f }, /* HP out */
4667 { }
4668 },
4669 },
4670 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
1727a771 4671 .type = HDA_FIXUP_FUNC,
08a978db
DR
4672 .v.func = alc271_hp_gate_mic_jack,
4673 .chained = true,
4674 .chain_id = ALC271_FIXUP_AMIC_MIC2,
4675 },
b1e8972e
OR
4676 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
4677 .type = HDA_FIXUP_FUNC,
4678 .v.func = alc269_fixup_limit_int_mic_boost,
4679 .chained = true,
4680 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
4681 },
42397004
DR
4682 [ALC269_FIXUP_ACER_AC700] = {
4683 .type = HDA_FIXUP_PINS,
4684 .v.pins = (const struct hda_pintbl[]) {
4685 { 0x12, 0x99a3092f }, /* int-mic */
4686 { 0x14, 0x99130110 }, /* speaker */
4687 { 0x18, 0x03a11c20 }, /* mic */
4688 { 0x1e, 0x0346101e }, /* SPDIF1 */
4689 { 0x21, 0x0321101f }, /* HP out */
4690 { }
4691 },
4692 .chained = true,
4693 .chain_id = ALC271_FIXUP_DMIC,
4694 },
3e0d611b
DH
4695 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
4696 .type = HDA_FIXUP_FUNC,
4697 .v.func = alc269_fixup_limit_int_mic_boost,
2793769f
DH
4698 .chained = true,
4699 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
3e0d611b 4700 },
2cede303
OR
4701 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
4702 .type = HDA_FIXUP_FUNC,
4703 .v.func = alc269_fixup_limit_int_mic_boost,
4704 .chained = true,
4705 .chain_id = ALC269VB_FIXUP_DMIC,
4706 },
23870831
TI
4707 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
4708 .type = HDA_FIXUP_VERBS,
4709 .v.verbs = (const struct hda_verb[]) {
4710 /* class-D output amp +5dB */
4711 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
4712 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
4713 {}
4714 },
4715 .chained = true,
4716 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
4717 },
8e35cd4a
DH
4718 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
4719 .type = HDA_FIXUP_FUNC,
4720 .v.func = alc269_fixup_limit_int_mic_boost,
4721 .chained = true,
4722 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
4723 },
02b504d9
AA
4724 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
4725 .type = HDA_FIXUP_PINS,
4726 .v.pins = (const struct hda_pintbl[]) {
4727 { 0x12, 0x99a3092f }, /* int-mic */
4728 { 0x18, 0x03a11d20 }, /* mic */
4729 { 0x19, 0x411111f0 }, /* Unused bogus pin */
4730 { }
4731 },
4732 },
cd217a63
KY
4733 [ALC283_FIXUP_CHROME_BOOK] = {
4734 .type = HDA_FIXUP_FUNC,
4735 .v.func = alc283_fixup_chromebook,
4736 },
0202e99c
KY
4737 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
4738 .type = HDA_FIXUP_FUNC,
4739 .v.func = alc283_fixup_sense_combo_jack,
4740 .chained = true,
4741 .chain_id = ALC283_FIXUP_CHROME_BOOK,
4742 },
7bba2157
TI
4743 [ALC282_FIXUP_ASUS_TX300] = {
4744 .type = HDA_FIXUP_FUNC,
4745 .v.func = alc282_fixup_asus_tx300,
4746 },
1bb3e062
KY
4747 [ALC283_FIXUP_INT_MIC] = {
4748 .type = HDA_FIXUP_VERBS,
4749 .v.verbs = (const struct hda_verb[]) {
4750 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
4751 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
4752 { }
4753 },
4754 .chained = true,
4755 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4756 },
0f4881dc
DH
4757 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
4758 .type = HDA_FIXUP_PINS,
4759 .v.pins = (const struct hda_pintbl[]) {
4760 { 0x17, 0x90170112 }, /* subwoofer */
4761 { }
4762 },
4763 .chained = true,
4764 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4765 },
4766 [ALC290_FIXUP_SUBWOOFER] = {
4767 .type = HDA_FIXUP_PINS,
4768 .v.pins = (const struct hda_pintbl[]) {
4769 { 0x17, 0x90170112 }, /* subwoofer */
4770 { }
4771 },
4772 .chained = true,
4773 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
4774 },
338cae56
DH
4775 [ALC290_FIXUP_MONO_SPEAKERS] = {
4776 .type = HDA_FIXUP_FUNC,
4777 .v.func = alc290_fixup_mono_speakers,
0f4881dc
DH
4778 },
4779 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
4780 .type = HDA_FIXUP_FUNC,
4781 .v.func = alc290_fixup_mono_speakers,
338cae56
DH
4782 .chained = true,
4783 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
4784 },
b67ae3f1
DH
4785 [ALC269_FIXUP_THINKPAD_ACPI] = {
4786 .type = HDA_FIXUP_FUNC,
b317b032 4787 .v.func = hda_fixup_thinkpad_acpi,
b67ae3f1 4788 },
9a22a8f5
KY
4789 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4790 .type = HDA_FIXUP_PINS,
4791 .v.pins = (const struct hda_pintbl[]) {
4792 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4793 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4794 { }
4795 },
4796 .chained = true,
4797 .chain_id = ALC255_FIXUP_HEADSET_MODE
4798 },
31278997
KY
4799 [ALC255_FIXUP_DELL2_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 { }
4804 },
4805 .chained = true,
4806 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
4807 },
9a22a8f5
KY
4808 [ALC255_FIXUP_HEADSET_MODE] = {
4809 .type = HDA_FIXUP_FUNC,
4810 .v.func = alc_fixup_headset_mode_alc255,
4811 },
31278997
KY
4812 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4813 .type = HDA_FIXUP_FUNC,
4814 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
4815 },
a22aa26f
KY
4816 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4817 .type = HDA_FIXUP_PINS,
4818 .v.pins = (const struct hda_pintbl[]) {
4819 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4820 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4821 { }
4822 },
4823 .chained = true,
4824 .chain_id = ALC269_FIXUP_HEADSET_MODE
4825 },
1c37c223
TI
4826 [ALC292_FIXUP_TPT440_DOCK] = {
4827 .type = HDA_FIXUP_PINS,
4828 .v.pins = (const struct hda_pintbl[]) {
4829 { 0x16, 0x21211010 }, /* dock headphone */
4830 { 0x19, 0x21a11010 }, /* dock mic */
4831 { }
4832 },
4833 .chained = true,
4834 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4835 },
9dc12862
DD
4836 [ALC283_FIXUP_BXBT2807_MIC] = {
4837 .type = HDA_FIXUP_PINS,
4838 .v.pins = (const struct hda_pintbl[]) {
4839 { 0x19, 0x04a110f0 },
4840 { },
4841 },
4842 },
00ef9940
HW
4843 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
4844 .type = HDA_FIXUP_FUNC,
4845 .v.func = alc_fixup_dell_wmi,
4846 .chained_before = true,
4847 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
4848 },
4849
f1d4e28b
KY
4850};
4851
1d045db9 4852static const struct snd_pci_quirk alc269_fixup_tbl[] = {
a6b92b66 4853 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
693b613d
DH
4854 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
4855 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
aaedfb47
DH
4856 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
4857 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4858 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
b1e8972e 4859 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
aaedfb47 4860 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
73bdd597
DH
4861 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4862 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4863 SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4864 SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4865 SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4866 SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4867 SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4868 SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4869 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4870 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
05843c07
KY
4871 SND_PCI_QUIRK(0x1028, 0x05cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4872 SND_PCI_QUIRK(0x1028, 0x05cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
0f4881dc 4873 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
436c4a0c 4874 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
d81bf8cf 4875 SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
73bdd597
DH
4876 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4877 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4878 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4879 SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4880 SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4881 SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4882 SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4883 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4884 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4885 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3ee2102f 4886 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
cd6fb679
DH
4887 SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4888 SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
d81bf8cf
DH
4889 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4890 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3ee2102f 4891 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
00ef9940 4892 SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
6c29d68a 4893 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
b8362e70 4894 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
0f4881dc
DH
4895 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4896 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
00ef9940 4897 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
0f4881dc 4898 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
9a22a8f5 4899 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
a22aa26f
KY
4900 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4901 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
31278997
KY
4902 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4903 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
a1f3b5fa 4904 SND_PCI_QUIRK(0x1028, 0x0684, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
05843c07
KY
4905 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4906 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
a22aa26f
KY
4907 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4908 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
08fb0d0e 4909 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9f5c6faf 4910 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
d06ac143
DH
4911 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4912 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8e35cd4a 4913 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
c60666bd 4914 /* ALC282 */
549d8782
HW
4915 SND_PCI_QUIRK(0x103c, 0x21f8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4916 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4917 SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4918 SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 4919 SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4920 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4921 SND_PCI_QUIRK(0x103c, 0x2211, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4922 SND_PCI_QUIRK(0x103c, 0x2212, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 4923 SND_PCI_QUIRK(0x103c, 0x2213, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 4924 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
4925 SND_PCI_QUIRK(0x103c, 0x2234, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4926 SND_PCI_QUIRK(0x103c, 0x2235, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4927 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4928 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4929 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4930 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4931 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4932 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4933 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4934 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4935 SND_PCI_QUIRK(0x103c, 0x224a, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4936 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4937 SND_PCI_QUIRK(0x103c, 0x224c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4938 SND_PCI_QUIRK(0x103c, 0x224d, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
c60666bd
KY
4939 SND_PCI_QUIRK(0x103c, 0x2266, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4940 SND_PCI_QUIRK(0x103c, 0x2267, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4941 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4942 SND_PCI_QUIRK(0x103c, 0x2269, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4943 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4944 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
4945 SND_PCI_QUIRK(0x103c, 0x226c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4946 SND_PCI_QUIRK(0x103c, 0x226d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4947 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4948 SND_PCI_QUIRK(0x103c, 0x226f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
4949 SND_PCI_QUIRK(0x103c, 0x227a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4950 SND_PCI_QUIRK(0x103c, 0x227b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4951 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4952 SND_PCI_QUIRK(0x103c, 0x22a0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4953 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4954 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4955 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4956 SND_PCI_QUIRK(0x103c, 0x22c0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4957 SND_PCI_QUIRK(0x103c, 0x22c1, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4958 SND_PCI_QUIRK(0x103c, 0x22c2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4959 SND_PCI_QUIRK(0x103c, 0x22cd, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4960 SND_PCI_QUIRK(0x103c, 0x22ce, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4961 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4962 SND_PCI_QUIRK(0x103c, 0x22d0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
4963 SND_PCI_QUIRK(0x103c, 0x22da, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4964 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4965 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4966 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4967 SND_PCI_QUIRK(0x103c, 0x8004, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 4968 /* ALC290 */
9c5dc3bf 4969 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
549d8782
HW
4970 SND_PCI_QUIRK(0x103c, 0x221c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4971 SND_PCI_QUIRK(0x103c, 0x221d, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf
KY
4972 SND_PCI_QUIRK(0x103c, 0x2220, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4973 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4974 SND_PCI_QUIRK(0x103c, 0x2222, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4975 SND_PCI_QUIRK(0x103c, 0x2223, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4976 SND_PCI_QUIRK(0x103c, 0x2224, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4977 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4978 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4979 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4980 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4981 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4982 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4983 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4984 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4985 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4986 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4987 SND_PCI_QUIRK(0x103c, 0x2258, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4988 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4989 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd
KY
4990 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4991 SND_PCI_QUIRK(0x103c, 0x2261, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4992 SND_PCI_QUIRK(0x103c, 0x2262, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4993 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4994 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4995 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
4996 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4997 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4998 SND_PCI_QUIRK(0x103c, 0x2277, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4999 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd
KY
5000 SND_PCI_QUIRK(0x103c, 0x227d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5001 SND_PCI_QUIRK(0x103c, 0x227e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5002 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5003 SND_PCI_QUIRK(0x103c, 0x2280, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5004 SND_PCI_QUIRK(0x103c, 0x2281, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5005 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5006 SND_PCI_QUIRK(0x103c, 0x2289, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5007 SND_PCI_QUIRK(0x103c, 0x228a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5008 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5009 SND_PCI_QUIRK(0x103c, 0x228c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
fce0a0c7 5010 SND_PCI_QUIRK(0x103c, 0x228d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
5011 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5012 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5013 SND_PCI_QUIRK(0x103c, 0x22c6, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5014 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5015 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5016 SND_PCI_QUIRK(0x103c, 0x22c3, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5017 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
5018 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5019 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5020 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
5021 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
7bba2157 5022 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
3e0d611b
DH
5023 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5024 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
2cede303 5025 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
23870831 5026 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
3e0d611b 5027 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
017f2a10 5028 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
693b613d 5029 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
3e0d611b 5030 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
adabb3ec
TI
5031 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
5032 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
5033 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5034 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
d240d1dc 5035 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
f88abaa0 5036 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
88cfcf86 5037 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
1d045db9
TI
5038 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
5039 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5040 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
e9bd7d5c 5041 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
24519911 5042 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
2041d564 5043 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
9dc12862 5044 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
1d045db9
TI
5045 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
5046 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
5047 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
5048 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
5049 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
707fba3f 5050 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
c8415a48 5051 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
84f98fdf 5052 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
4407be6b 5053 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
108cc108 5054 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
aaedfb47 5055 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
1c37c223
TI
5056 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
5057 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
a12137e7 5058 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
cd5302c0 5059 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
2793769f 5060 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
a4a9e082 5061 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
9b745ab8 5062 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
a4a9e082 5063 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
1bb3e062 5064 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
cd5302c0
DH
5065 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5066 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
012e7eb1 5067 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
1d045db9 5068 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
02b504d9 5069 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
a4297b5d 5070
a7f3eedc 5071#if 0
a4297b5d
TI
5072 /* Below is a quirk table taken from the old code.
5073 * Basically the device should work as is without the fixup table.
5074 * If BIOS doesn't give a proper info, enable the corresponding
5075 * fixup entry.
7d7eb9ea 5076 */
a4297b5d
TI
5077 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
5078 ALC269_FIXUP_AMIC),
5079 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
a4297b5d
TI
5080 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
5081 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
5082 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
5083 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
5084 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
5085 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
5086 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
5087 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
5088 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
5089 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
5090 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
5091 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
5092 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
5093 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
5094 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
5095 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
5096 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
5097 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
5098 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
5099 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
5100 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
5101 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
5102 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
5103 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
5104 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
5105 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
5106 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
5107 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
5108 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
5109 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
5110 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
5111 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
5112 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
5113 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
5114 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
5115 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
5116 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
5117 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
5118#endif
5119 {}
5120};
5121
214eef76
DH
5122static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
5123 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
5124 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
5125 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
5126 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
5127 {}
5128};
5129
1727a771 5130static const struct hda_model_fixup alc269_fixup_models[] = {
a4297b5d
TI
5131 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5132 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6e72aa5f
TI
5133 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
5134 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
5135 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
7c478f03 5136 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
108cc108 5137 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9f5c6faf 5138 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
e32aa85a
DH
5139 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
5140 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
be8ef16a 5141 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
0202e99c 5142 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
1c37c223 5143 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
1d045db9 5144 {}
6dda9f4a
KY
5145};
5146
e1918938 5147static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
76c2132e
DH
5148 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5149 {0x12, 0x90a60140},
5150 {0x14, 0x90170110},
5151 {0x17, 0x40000000},
5152 {0x18, 0x411111f0},
5153 {0x19, 0x411111f0},
5154 {0x1a, 0x411111f0},
5155 {0x1b, 0x411111f0},
5156 {0x1d, 0x40700001},
5157 {0x1e, 0x411111f0},
5158 {0x21, 0x02211020}),
5159 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5160 {0x12, 0x90a60160},
5161 {0x14, 0x90170120},
5162 {0x17, 0x40000000},
5163 {0x18, 0x411111f0},
5164 {0x19, 0x411111f0},
5165 {0x1a, 0x411111f0},
5166 {0x1b, 0x411111f0},
5167 {0x1d, 0x40700001},
5168 {0x1e, 0x411111f0},
5169 {0x21, 0x02211030}),
5170 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5171 {0x12, 0x90a60160},
5172 {0x14, 0x90170120},
5173 {0x17, 0x90170140},
5174 {0x18, 0x40000000},
5175 {0x19, 0x411111f0},
5176 {0x1a, 0x411111f0},
5177 {0x1b, 0x411111f0},
5178 {0x1d, 0x41163b05},
5179 {0x1e, 0x411111f0},
5180 {0x21, 0x0321102f}),
5181 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5182 {0x12, 0x90a60160},
5183 {0x14, 0x90170130},
5184 {0x17, 0x40000000},
5185 {0x18, 0x411111f0},
5186 {0x19, 0x411111f0},
5187 {0x1a, 0x411111f0},
5188 {0x1b, 0x411111f0},
5189 {0x1d, 0x40700001},
5190 {0x1e, 0x411111f0},
5191 {0x21, 0x02211040}),
5192 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5193 {0x12, 0x90a60160},
5194 {0x14, 0x90170140},
5195 {0x17, 0x40000000},
5196 {0x18, 0x411111f0},
5197 {0x19, 0x411111f0},
5198 {0x1a, 0x411111f0},
5199 {0x1b, 0x411111f0},
5200 {0x1d, 0x40700001},
5201 {0x1e, 0x411111f0},
5202 {0x21, 0x02211050}),
5203 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5204 {0x12, 0x90a60170},
5205 {0x14, 0x90170120},
5206 {0x17, 0x40000000},
5207 {0x18, 0x411111f0},
5208 {0x19, 0x411111f0},
5209 {0x1a, 0x411111f0},
5210 {0x1b, 0x411111f0},
5211 {0x1d, 0x40700001},
5212 {0x1e, 0x411111f0},
5213 {0x21, 0x02211030}),
5214 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5215 {0x12, 0x90a60170},
5216 {0x14, 0x90170130},
5217 {0x17, 0x40000000},
5218 {0x18, 0x411111f0},
5219 {0x19, 0x411111f0},
5220 {0x1a, 0x411111f0},
5221 {0x1b, 0x411111f0},
5222 {0x1d, 0x40700001},
5223 {0x1e, 0x411111f0},
5224 {0x21, 0x02211040}),
42304474
DH
5225 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5226 {0x12, 0x99a30130},
5227 {0x14, 0x90170110},
5228 {0x17, 0x40000000},
5229 {0x18, 0x411111f0},
5230 {0x19, 0x03a11020},
5231 {0x1a, 0x411111f0},
5232 {0x1b, 0x411111f0},
5233 {0x1d, 0x40f41905},
5234 {0x1e, 0x411111f0},
5235 {0x21, 0x0321101f}),
76c2132e
DH
5236 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5237 {0x12, 0x90a60130},
5238 {0x14, 0x90170110},
5239 {0x17, 0x40020008},
5240 {0x18, 0x411111f0},
5241 {0x19, 0x411111f0},
5242 {0x1a, 0x411111f0},
5243 {0x1b, 0x411111f0},
5244 {0x1d, 0x40e00001},
5245 {0x1e, 0x411111f0},
5246 {0x21, 0x0321101f}),
5247 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5248 {0x12, 0x90a60160},
5249 {0x14, 0x90170120},
5250 {0x17, 0x40000000},
5251 {0x18, 0x411111f0},
5252 {0x19, 0x411111f0},
5253 {0x1a, 0x411111f0},
5254 {0x1b, 0x411111f0},
5255 {0x1d, 0x40700001},
5256 {0x1e, 0x411111f0},
5257 {0x21, 0x02211030}),
5258 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5259 {0x12, 0x90a60140},
5260 {0x13, 0x411111f0},
5261 {0x14, 0x90170110},
5262 {0x15, 0x0221401f},
5263 {0x16, 0x411111f0},
5264 {0x18, 0x411111f0},
5265 {0x19, 0x411111f0},
5266 {0x1a, 0x411111f0},
5267 {0x1b, 0x411111f0},
5268 {0x1d, 0x40700001},
5269 {0x1e, 0x411111f0}),
5270 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5271 {0x12, 0x40000000},
5272 {0x13, 0x90a60140},
5273 {0x14, 0x90170110},
5274 {0x15, 0x0221401f},
5275 {0x16, 0x21014020},
5276 {0x18, 0x411111f0},
5277 {0x19, 0x21a19030},
5278 {0x1a, 0x411111f0},
5279 {0x1b, 0x411111f0},
5280 {0x1d, 0x40700001},
5281 {0x1e, 0x411111f0}),
e03fdbde
DH
5282 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5283 {0x12, 0x40000000},
5284 {0x13, 0x90a60140},
5285 {0x14, 0x90170110},
5286 {0x15, 0x0221401f},
5287 {0x16, 0x411111f0},
5288 {0x18, 0x411111f0},
5289 {0x19, 0x411111f0},
5290 {0x1a, 0x411111f0},
5291 {0x1b, 0x411111f0},
5292 {0x1d, 0x40700001},
5293 {0x1e, 0x411111f0}),
e1918938
HW
5294 {}
5295};
6dda9f4a 5296
546bb678 5297static void alc269_fill_coef(struct hda_codec *codec)
1d045db9 5298{
526af6eb 5299 struct alc_spec *spec = codec->spec;
1d045db9 5300 int val;
ebb83eeb 5301
526af6eb 5302 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
546bb678 5303 return;
526af6eb 5304
1bb7e43e 5305 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
1d045db9
TI
5306 alc_write_coef_idx(codec, 0xf, 0x960b);
5307 alc_write_coef_idx(codec, 0xe, 0x8817);
5308 }
ebb83eeb 5309
1bb7e43e 5310 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
1d045db9
TI
5311 alc_write_coef_idx(codec, 0xf, 0x960b);
5312 alc_write_coef_idx(codec, 0xe, 0x8814);
5313 }
ebb83eeb 5314
1bb7e43e 5315 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
5316 val = alc_read_coef_idx(codec, 0x04);
5317 /* Power up output pin */
f3ee07d8
TI
5318 if (val != -1)
5319 alc_write_coef_idx(codec, 0x04, val | (1<<11));
1d045db9 5320 }
ebb83eeb 5321
1bb7e43e 5322 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9 5323 val = alc_read_coef_idx(codec, 0xd);
f3ee07d8 5324 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
1d045db9
TI
5325 /* Capless ramp up clock control */
5326 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5327 }
5328 val = alc_read_coef_idx(codec, 0x17);
f3ee07d8 5329 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
1d045db9
TI
5330 /* Class D power on reset */
5331 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5332 }
5333 }
ebb83eeb 5334
1d045db9 5335 val = alc_read_coef_idx(codec, 0xd); /* Class D */
f3ee07d8
TI
5336 if (val != -1)
5337 alc_write_coef_idx(codec, 0xd, val | (1<<14));
bc9f98a9 5338
1d045db9 5339 val = alc_read_coef_idx(codec, 0x4); /* HP */
f3ee07d8
TI
5340 if (val != -1)
5341 alc_write_coef_idx(codec, 0x4, val | (1<<11));
1d045db9 5342}
a7f2371f 5343
1d045db9
TI
5344/*
5345 */
1d045db9
TI
5346static int patch_alc269(struct hda_codec *codec)
5347{
5348 struct alc_spec *spec;
3de95173 5349 int err;
f1d4e28b 5350
3de95173 5351 err = alc_alloc_spec(codec, 0x0b);
e16fb6d1 5352 if (err < 0)
3de95173
TI
5353 return err;
5354
5355 spec = codec->spec;
08c189f2 5356 spec->gen.shared_mic_vref_pin = 0x18;
e16fb6d1 5357
1727a771 5358 snd_hda_pick_fixup(codec, alc269_fixup_models,
9f720bb9 5359 alc269_fixup_tbl, alc269_fixups);
e1918938 5360 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
214eef76
DH
5361 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
5362 alc269_fixups);
1727a771 5363 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9f720bb9
HRK
5364
5365 alc_auto_parse_customize_define(codec);
5366
7504b6cd
TI
5367 if (has_cdefine_beep(codec))
5368 spec->gen.beep_nid = 0x01;
5369
065380f0
KY
5370 switch (codec->vendor_id) {
5371 case 0x10ec0269:
1d045db9 5372 spec->codec_variant = ALC269_TYPE_ALC269VA;
1bb7e43e
TI
5373 switch (alc_get_coef0(codec) & 0x00f0) {
5374 case 0x0010:
5100cd07
TI
5375 if (codec->bus->pci &&
5376 codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 5377 spec->cdefine.platform_type == 1)
20ca0c35 5378 err = alc_codec_rename(codec, "ALC271X");
1d045db9 5379 spec->codec_variant = ALC269_TYPE_ALC269VB;
1bb7e43e
TI
5380 break;
5381 case 0x0020:
5100cd07
TI
5382 if (codec->bus->pci &&
5383 codec->bus->pci->subsystem_vendor == 0x17aa &&
e16fb6d1 5384 codec->bus->pci->subsystem_device == 0x21f3)
20ca0c35 5385 err = alc_codec_rename(codec, "ALC3202");
1d045db9 5386 spec->codec_variant = ALC269_TYPE_ALC269VC;
1bb7e43e 5387 break;
adcc70b2
KY
5388 case 0x0030:
5389 spec->codec_variant = ALC269_TYPE_ALC269VD;
5390 break;
1bb7e43e 5391 default:
1d045db9 5392 alc_fix_pll_init(codec, 0x20, 0x04, 15);
1bb7e43e 5393 }
e16fb6d1
TI
5394 if (err < 0)
5395 goto error;
546bb678 5396 spec->init_hook = alc269_fill_coef;
1d045db9 5397 alc269_fill_coef(codec);
065380f0
KY
5398 break;
5399
5400 case 0x10ec0280:
5401 case 0x10ec0290:
5402 spec->codec_variant = ALC269_TYPE_ALC280;
5403 break;
5404 case 0x10ec0282:
065380f0 5405 spec->codec_variant = ALC269_TYPE_ALC282;
7b5c7a02
KY
5406 spec->shutup = alc282_shutup;
5407 spec->init_hook = alc282_init;
065380f0 5408 break;
2af02be7
KY
5409 case 0x10ec0233:
5410 case 0x10ec0283:
5411 spec->codec_variant = ALC269_TYPE_ALC283;
5412 spec->shutup = alc283_shutup;
5413 spec->init_hook = alc283_init;
5414 break;
065380f0
KY
5415 case 0x10ec0284:
5416 case 0x10ec0292:
5417 spec->codec_variant = ALC269_TYPE_ALC284;
5418 break;
161ebf29
KY
5419 case 0x10ec0285:
5420 case 0x10ec0293:
5421 spec->codec_variant = ALC269_TYPE_ALC285;
5422 break;
7fc7d047 5423 case 0x10ec0286:
7c665932 5424 case 0x10ec0288:
7fc7d047 5425 spec->codec_variant = ALC269_TYPE_ALC286;
f7ae9ba0 5426 spec->shutup = alc286_shutup;
7fc7d047 5427 break;
1d04c9de
KY
5428 case 0x10ec0255:
5429 spec->codec_variant = ALC269_TYPE_ALC255;
5430 break;
1d045db9 5431 }
6dda9f4a 5432
ad60d502 5433 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
97a26570 5434 spec->has_alc5505_dsp = 1;
ad60d502
KY
5435 spec->init_hook = alc5505_dsp_init;
5436 }
5437
a4297b5d
TI
5438 /* automatic parse from the BIOS config */
5439 err = alc269_parse_auto_config(codec);
e16fb6d1
TI
5440 if (err < 0)
5441 goto error;
6dda9f4a 5442
7504b6cd 5443 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 5444 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
f1d4e28b 5445
1d045db9 5446 codec->patch_ops = alc_patch_ops;
2a43952a 5447#ifdef CONFIG_PM
ad60d502 5448 codec->patch_ops.suspend = alc269_suspend;
1d045db9
TI
5449 codec->patch_ops.resume = alc269_resume;
5450#endif
c5177c86
KY
5451 if (!spec->shutup)
5452 spec->shutup = alc269_shutup;
ebb83eeb 5453
1727a771 5454 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 5455
1d045db9 5456 return 0;
e16fb6d1
TI
5457
5458 error:
5459 alc_free(codec);
5460 return err;
1d045db9 5461}
f1d4e28b 5462
1d045db9
TI
5463/*
5464 * ALC861
5465 */
622e84cd 5466
1d045db9 5467static int alc861_parse_auto_config(struct hda_codec *codec)
6dda9f4a 5468{
1d045db9 5469 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3e6179b8
TI
5470 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5471 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
604401a9
TI
5472}
5473
1d045db9
TI
5474/* Pin config fixes */
5475enum {
e652f4c8
TI
5476 ALC861_FIXUP_FSC_AMILO_PI1505,
5477 ALC861_FIXUP_AMP_VREF_0F,
5478 ALC861_FIXUP_NO_JACK_DETECT,
5479 ALC861_FIXUP_ASUS_A6RP,
6ddf0fd1 5480 ALC660_FIXUP_ASUS_W7J,
1d045db9 5481};
7085ec12 5482
31150f23
TI
5483/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
5484static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
1727a771 5485 const struct hda_fixup *fix, int action)
31150f23
TI
5486{
5487 struct alc_spec *spec = codec->spec;
5488 unsigned int val;
5489
1727a771 5490 if (action != HDA_FIXUP_ACT_INIT)
31150f23 5491 return;
d3f02d60 5492 val = snd_hda_codec_get_pin_target(codec, 0x0f);
31150f23
TI
5493 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
5494 val |= AC_PINCTL_IN_EN;
5495 val |= AC_PINCTL_VREF_50;
cdd03ced 5496 snd_hda_set_pin_ctl(codec, 0x0f, val);
08c189f2 5497 spec->gen.keep_vref_in_automute = 1;
31150f23
TI
5498}
5499
e652f4c8
TI
5500/* suppress the jack-detection */
5501static void alc_fixup_no_jack_detect(struct hda_codec *codec,
1727a771 5502 const struct hda_fixup *fix, int action)
e652f4c8 5503{
1727a771 5504 if (action == HDA_FIXUP_ACT_PRE_PROBE)
e652f4c8 5505 codec->no_jack_detect = 1;
7d7eb9ea 5506}
e652f4c8 5507
1727a771 5508static const struct hda_fixup alc861_fixups[] = {
e652f4c8 5509 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
1727a771
TI
5510 .type = HDA_FIXUP_PINS,
5511 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
5512 { 0x0b, 0x0221101f }, /* HP */
5513 { 0x0f, 0x90170310 }, /* speaker */
5514 { }
5515 }
5516 },
e652f4c8 5517 [ALC861_FIXUP_AMP_VREF_0F] = {
1727a771 5518 .type = HDA_FIXUP_FUNC,
31150f23 5519 .v.func = alc861_fixup_asus_amp_vref_0f,
3b25eb69 5520 },
e652f4c8 5521 [ALC861_FIXUP_NO_JACK_DETECT] = {
1727a771 5522 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
5523 .v.func = alc_fixup_no_jack_detect,
5524 },
5525 [ALC861_FIXUP_ASUS_A6RP] = {
1727a771 5526 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
5527 .v.func = alc861_fixup_asus_amp_vref_0f,
5528 .chained = true,
5529 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
6ddf0fd1
TI
5530 },
5531 [ALC660_FIXUP_ASUS_W7J] = {
5532 .type = HDA_FIXUP_VERBS,
5533 .v.verbs = (const struct hda_verb[]) {
5534 /* ASUS W7J needs a magic pin setup on unused NID 0x10
5535 * for enabling outputs
5536 */
5537 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5538 { }
5539 },
e652f4c8 5540 }
1d045db9 5541};
7085ec12 5542
1d045db9 5543static const struct snd_pci_quirk alc861_fixup_tbl[] = {
6ddf0fd1 5544 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
e7ca237b 5545 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
e652f4c8
TI
5546 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
5547 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
5548 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
5549 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
5550 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
5551 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
1d045db9
TI
5552 {}
5553};
3af9ee6b 5554
1d045db9
TI
5555/*
5556 */
1d045db9 5557static int patch_alc861(struct hda_codec *codec)
7085ec12 5558{
1d045db9 5559 struct alc_spec *spec;
1d045db9 5560 int err;
7085ec12 5561
3de95173
TI
5562 err = alc_alloc_spec(codec, 0x15);
5563 if (err < 0)
5564 return err;
1d045db9 5565
3de95173 5566 spec = codec->spec;
7504b6cd 5567 spec->gen.beep_nid = 0x23;
1d045db9 5568
1727a771
TI
5569 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5570 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3af9ee6b 5571
cb4e4824
TI
5572 /* automatic parse from the BIOS config */
5573 err = alc861_parse_auto_config(codec);
e16fb6d1
TI
5574 if (err < 0)
5575 goto error;
3af9ee6b 5576
7504b6cd 5577 if (!spec->gen.no_analog)
3e6179b8 5578 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7085ec12 5579
1d045db9 5580 codec->patch_ops = alc_patch_ops;
83012a7c 5581#ifdef CONFIG_PM
cb4e4824 5582 spec->power_hook = alc_power_eapd;
1d045db9
TI
5583#endif
5584
1727a771 5585 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 5586
1d045db9 5587 return 0;
e16fb6d1
TI
5588
5589 error:
5590 alc_free(codec);
5591 return err;
7085ec12
TI
5592}
5593
1d045db9
TI
5594/*
5595 * ALC861-VD support
5596 *
5597 * Based on ALC882
5598 *
5599 * In addition, an independent DAC
5600 */
1d045db9 5601static int alc861vd_parse_auto_config(struct hda_codec *codec)
bc9f98a9 5602{
1d045db9 5603 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3e6179b8
TI
5604 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5605 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
ce764ab2
TI
5606}
5607
1d045db9 5608enum {
8fdcb6fe
TI
5609 ALC660VD_FIX_ASUS_GPIO1,
5610 ALC861VD_FIX_DALLAS,
1d045db9 5611};
ce764ab2 5612
8fdcb6fe
TI
5613/* exclude VREF80 */
5614static void alc861vd_fixup_dallas(struct hda_codec *codec,
1727a771 5615 const struct hda_fixup *fix, int action)
8fdcb6fe 5616{
1727a771 5617 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
b78562b1
TI
5618 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
5619 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8fdcb6fe
TI
5620 }
5621}
5622
1727a771 5623static const struct hda_fixup alc861vd_fixups[] = {
1d045db9 5624 [ALC660VD_FIX_ASUS_GPIO1] = {
1727a771 5625 .type = HDA_FIXUP_VERBS,
1d045db9 5626 .v.verbs = (const struct hda_verb[]) {
8fdcb6fe 5627 /* reset GPIO1 */
1d045db9
TI
5628 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5629 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5630 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5631 { }
5632 }
5633 },
8fdcb6fe 5634 [ALC861VD_FIX_DALLAS] = {
1727a771 5635 .type = HDA_FIXUP_FUNC,
8fdcb6fe
TI
5636 .v.func = alc861vd_fixup_dallas,
5637 },
1d045db9 5638};
ce764ab2 5639
1d045db9 5640static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8fdcb6fe 5641 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
1d045db9 5642 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8fdcb6fe 5643 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
1d045db9
TI
5644 {}
5645};
ce764ab2 5646
1d045db9
TI
5647/*
5648 */
1d045db9 5649static int patch_alc861vd(struct hda_codec *codec)
ce764ab2 5650{
1d045db9 5651 struct alc_spec *spec;
cb4e4824 5652 int err;
ce764ab2 5653
3de95173
TI
5654 err = alc_alloc_spec(codec, 0x0b);
5655 if (err < 0)
5656 return err;
1d045db9 5657
3de95173 5658 spec = codec->spec;
7504b6cd 5659 spec->gen.beep_nid = 0x23;
1d045db9 5660
1727a771
TI
5661 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5662 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1d045db9 5663
cb4e4824
TI
5664 /* automatic parse from the BIOS config */
5665 err = alc861vd_parse_auto_config(codec);
e16fb6d1
TI
5666 if (err < 0)
5667 goto error;
ce764ab2 5668
7504b6cd 5669 if (!spec->gen.no_analog)
3e6179b8 5670 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1d045db9 5671
1d045db9
TI
5672 codec->patch_ops = alc_patch_ops;
5673
1d045db9 5674 spec->shutup = alc_eapd_shutup;
1d045db9 5675
1727a771 5676 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 5677
ce764ab2 5678 return 0;
e16fb6d1
TI
5679
5680 error:
5681 alc_free(codec);
5682 return err;
ce764ab2
TI
5683}
5684
1d045db9
TI
5685/*
5686 * ALC662 support
5687 *
5688 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5689 * configuration. Each pin widget can choose any input DACs and a mixer.
5690 * Each ADC is connected from a mixer of all inputs. This makes possible
5691 * 6-channel independent captures.
5692 *
5693 * In addition, an independent DAC for the multi-playback (not used in this
5694 * driver yet).
5695 */
1d045db9
TI
5696
5697/*
5698 * BIOS auto configuration
5699 */
5700
bc9f98a9
KY
5701static int alc662_parse_auto_config(struct hda_codec *codec)
5702{
4c6d72d1 5703 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3e6179b8
TI
5704 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5705 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5706 const hda_nid_t *ssids;
ee979a14 5707
6227cdce 5708 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
1d87caa6
RK
5709 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
5710 codec->vendor_id == 0x10ec0671)
3e6179b8 5711 ssids = alc663_ssids;
6227cdce 5712 else
3e6179b8
TI
5713 ssids = alc662_ssids;
5714 return alc_parse_auto_config(codec, alc662_ignore, ssids);
bc9f98a9
KY
5715}
5716
6be7948f 5717static void alc272_fixup_mario(struct hda_codec *codec,
1727a771 5718 const struct hda_fixup *fix, int action)
6fc398cb 5719{
9bb1f06f 5720 if (action != HDA_FIXUP_ACT_PRE_PROBE)
6fc398cb 5721 return;
6be7948f
TB
5722 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5723 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5724 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5725 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5726 (0 << AC_AMPCAP_MUTE_SHIFT)))
4e76a883 5727 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
6be7948f
TB
5728}
5729
8e383953
TI
5730static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
5731 { .channels = 2,
5732 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
5733 { .channels = 4,
5734 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
5735 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
5736 { }
5737};
5738
5739/* override the 2.1 chmap */
eb9ca3ab 5740static void alc_fixup_bass_chmap(struct hda_codec *codec,
8e383953
TI
5741 const struct hda_fixup *fix, int action)
5742{
5743 if (action == HDA_FIXUP_ACT_BUILD) {
5744 struct alc_spec *spec = codec->spec;
5745 spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps;
5746 }
5747}
5748
3e887f37
TI
5749/* turn on/off mute LED per vmaster hook */
5750static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
5751{
5752 struct hda_codec *codec = private_data;
5753 struct alc_spec *spec = codec->spec;
5754 unsigned int oldval = spec->gpio_led;
5755
5756 if (enabled)
5757 spec->gpio_led &= ~0x01;
5758 else
5759 spec->gpio_led |= 0x01;
5760 if (spec->gpio_led != oldval)
5761 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5762 spec->gpio_led);
5763}
5764
bf68665d
TI
5765/* avoid D3 for keeping GPIO up */
5766static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5767 hda_nid_t nid,
5768 unsigned int power_state)
5769{
5770 struct alc_spec *spec = codec->spec;
5771 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5772 return AC_PWRST_D0;
5773 return power_state;
5774}
5775
3e887f37
TI
5776static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5777 const struct hda_fixup *fix, int action)
5778{
5779 struct alc_spec *spec = codec->spec;
5780 static const struct hda_verb gpio_init[] = {
5781 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
5782 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
5783 {}
5784 };
5785
5786 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5787 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
5788 spec->gpio_led = 0;
5789 snd_hda_add_verbs(codec, gpio_init);
bf68665d 5790 codec->power_filter = gpio_led_power_filter;
3e887f37
TI
5791 }
5792}
5793
6cb3b707 5794enum {
2df03514 5795 ALC662_FIXUP_ASPIRE,
3e887f37 5796 ALC662_FIXUP_LED_GPIO1,
6cb3b707 5797 ALC662_FIXUP_IDEAPAD,
6be7948f 5798 ALC272_FIXUP_MARIO,
d2ebd479 5799 ALC662_FIXUP_CZC_P10T,
94024cd1 5800 ALC662_FIXUP_SKU_IGNORE,
e59ea3ed 5801 ALC662_FIXUP_HP_RP5800,
53c334ad
TI
5802 ALC662_FIXUP_ASUS_MODE1,
5803 ALC662_FIXUP_ASUS_MODE2,
5804 ALC662_FIXUP_ASUS_MODE3,
5805 ALC662_FIXUP_ASUS_MODE4,
5806 ALC662_FIXUP_ASUS_MODE5,
5807 ALC662_FIXUP_ASUS_MODE6,
5808 ALC662_FIXUP_ASUS_MODE7,
5809 ALC662_FIXUP_ASUS_MODE8,
1565cc35 5810 ALC662_FIXUP_NO_JACK_DETECT,
edfe3bfc 5811 ALC662_FIXUP_ZOTAC_Z68,
125821ae 5812 ALC662_FIXUP_INV_DMIC,
73bdd597
DH
5813 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
5814 ALC668_FIXUP_HEADSET_MODE,
8e54b4ac 5815 ALC662_FIXUP_BASS_MODE4_CHMAP,
61a75f13 5816 ALC662_FIXUP_BASS_16,
a30c9aaa 5817 ALC662_FIXUP_BASS_1A,
8e54b4ac 5818 ALC662_FIXUP_BASS_CHMAP,
493a52a9 5819 ALC668_FIXUP_AUTO_MUTE,
5e6db669 5820 ALC668_FIXUP_DELL_DISABLE_AAMIX,
033b0a7c 5821 ALC668_FIXUP_DELL_XPS13,
6cb3b707
DH
5822};
5823
1727a771 5824static const struct hda_fixup alc662_fixups[] = {
2df03514 5825 [ALC662_FIXUP_ASPIRE] = {
1727a771
TI
5826 .type = HDA_FIXUP_PINS,
5827 .v.pins = (const struct hda_pintbl[]) {
2df03514
DC
5828 { 0x15, 0x99130112 }, /* subwoofer */
5829 { }
5830 }
5831 },
3e887f37
TI
5832 [ALC662_FIXUP_LED_GPIO1] = {
5833 .type = HDA_FIXUP_FUNC,
5834 .v.func = alc662_fixup_led_gpio1,
5835 },
6cb3b707 5836 [ALC662_FIXUP_IDEAPAD] = {
1727a771
TI
5837 .type = HDA_FIXUP_PINS,
5838 .v.pins = (const struct hda_pintbl[]) {
6cb3b707
DH
5839 { 0x17, 0x99130112 }, /* subwoofer */
5840 { }
3e887f37
TI
5841 },
5842 .chained = true,
5843 .chain_id = ALC662_FIXUP_LED_GPIO1,
6cb3b707 5844 },
6be7948f 5845 [ALC272_FIXUP_MARIO] = {
1727a771 5846 .type = HDA_FIXUP_FUNC,
b5bfbc67 5847 .v.func = alc272_fixup_mario,
d2ebd479
AA
5848 },
5849 [ALC662_FIXUP_CZC_P10T] = {
1727a771 5850 .type = HDA_FIXUP_VERBS,
d2ebd479
AA
5851 .v.verbs = (const struct hda_verb[]) {
5852 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5853 {}
5854 }
5855 },
94024cd1 5856 [ALC662_FIXUP_SKU_IGNORE] = {
1727a771 5857 .type = HDA_FIXUP_FUNC,
23d30f28 5858 .v.func = alc_fixup_sku_ignore,
c6b35874 5859 },
e59ea3ed 5860 [ALC662_FIXUP_HP_RP5800] = {
1727a771
TI
5861 .type = HDA_FIXUP_PINS,
5862 .v.pins = (const struct hda_pintbl[]) {
e59ea3ed
TI
5863 { 0x14, 0x0221201f }, /* HP out */
5864 { }
5865 },
5866 .chained = true,
5867 .chain_id = ALC662_FIXUP_SKU_IGNORE
5868 },
53c334ad 5869 [ALC662_FIXUP_ASUS_MODE1] = {
1727a771
TI
5870 .type = HDA_FIXUP_PINS,
5871 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5872 { 0x14, 0x99130110 }, /* speaker */
5873 { 0x18, 0x01a19c20 }, /* mic */
5874 { 0x19, 0x99a3092f }, /* int-mic */
5875 { 0x21, 0x0121401f }, /* HP out */
5876 { }
5877 },
5878 .chained = true,
5879 .chain_id = ALC662_FIXUP_SKU_IGNORE
5880 },
5881 [ALC662_FIXUP_ASUS_MODE2] = {
1727a771
TI
5882 .type = HDA_FIXUP_PINS,
5883 .v.pins = (const struct hda_pintbl[]) {
2996bdba
TI
5884 { 0x14, 0x99130110 }, /* speaker */
5885 { 0x18, 0x01a19820 }, /* mic */
5886 { 0x19, 0x99a3092f }, /* int-mic */
5887 { 0x1b, 0x0121401f }, /* HP out */
5888 { }
5889 },
53c334ad
TI
5890 .chained = true,
5891 .chain_id = ALC662_FIXUP_SKU_IGNORE
5892 },
5893 [ALC662_FIXUP_ASUS_MODE3] = {
1727a771
TI
5894 .type = HDA_FIXUP_PINS,
5895 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5896 { 0x14, 0x99130110 }, /* speaker */
5897 { 0x15, 0x0121441f }, /* HP */
5898 { 0x18, 0x01a19840 }, /* mic */
5899 { 0x19, 0x99a3094f }, /* int-mic */
5900 { 0x21, 0x01211420 }, /* HP2 */
5901 { }
5902 },
5903 .chained = true,
5904 .chain_id = ALC662_FIXUP_SKU_IGNORE
5905 },
5906 [ALC662_FIXUP_ASUS_MODE4] = {
1727a771
TI
5907 .type = HDA_FIXUP_PINS,
5908 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5909 { 0x14, 0x99130110 }, /* speaker */
5910 { 0x16, 0x99130111 }, /* speaker */
5911 { 0x18, 0x01a19840 }, /* mic */
5912 { 0x19, 0x99a3094f }, /* int-mic */
5913 { 0x21, 0x0121441f }, /* HP */
5914 { }
5915 },
5916 .chained = true,
5917 .chain_id = ALC662_FIXUP_SKU_IGNORE
5918 },
5919 [ALC662_FIXUP_ASUS_MODE5] = {
1727a771
TI
5920 .type = HDA_FIXUP_PINS,
5921 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5922 { 0x14, 0x99130110 }, /* speaker */
5923 { 0x15, 0x0121441f }, /* HP */
5924 { 0x16, 0x99130111 }, /* speaker */
5925 { 0x18, 0x01a19840 }, /* mic */
5926 { 0x19, 0x99a3094f }, /* int-mic */
5927 { }
5928 },
5929 .chained = true,
5930 .chain_id = ALC662_FIXUP_SKU_IGNORE
5931 },
5932 [ALC662_FIXUP_ASUS_MODE6] = {
1727a771
TI
5933 .type = HDA_FIXUP_PINS,
5934 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5935 { 0x14, 0x99130110 }, /* speaker */
5936 { 0x15, 0x01211420 }, /* HP2 */
5937 { 0x18, 0x01a19840 }, /* mic */
5938 { 0x19, 0x99a3094f }, /* int-mic */
5939 { 0x1b, 0x0121441f }, /* HP */
5940 { }
5941 },
5942 .chained = true,
5943 .chain_id = ALC662_FIXUP_SKU_IGNORE
5944 },
5945 [ALC662_FIXUP_ASUS_MODE7] = {
1727a771
TI
5946 .type = HDA_FIXUP_PINS,
5947 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5948 { 0x14, 0x99130110 }, /* speaker */
5949 { 0x17, 0x99130111 }, /* speaker */
5950 { 0x18, 0x01a19840 }, /* mic */
5951 { 0x19, 0x99a3094f }, /* int-mic */
5952 { 0x1b, 0x01214020 }, /* HP */
5953 { 0x21, 0x0121401f }, /* HP */
5954 { }
5955 },
5956 .chained = true,
5957 .chain_id = ALC662_FIXUP_SKU_IGNORE
5958 },
5959 [ALC662_FIXUP_ASUS_MODE8] = {
1727a771
TI
5960 .type = HDA_FIXUP_PINS,
5961 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
5962 { 0x14, 0x99130110 }, /* speaker */
5963 { 0x12, 0x99a30970 }, /* int-mic */
5964 { 0x15, 0x01214020 }, /* HP */
5965 { 0x17, 0x99130111 }, /* speaker */
5966 { 0x18, 0x01a19840 }, /* mic */
5967 { 0x21, 0x0121401f }, /* HP */
5968 { }
5969 },
5970 .chained = true,
5971 .chain_id = ALC662_FIXUP_SKU_IGNORE
2996bdba 5972 },
1565cc35 5973 [ALC662_FIXUP_NO_JACK_DETECT] = {
1727a771 5974 .type = HDA_FIXUP_FUNC,
1565cc35
TI
5975 .v.func = alc_fixup_no_jack_detect,
5976 },
edfe3bfc 5977 [ALC662_FIXUP_ZOTAC_Z68] = {
1727a771
TI
5978 .type = HDA_FIXUP_PINS,
5979 .v.pins = (const struct hda_pintbl[]) {
edfe3bfc
DH
5980 { 0x1b, 0x02214020 }, /* Front HP */
5981 { }
5982 }
5983 },
125821ae 5984 [ALC662_FIXUP_INV_DMIC] = {
1727a771 5985 .type = HDA_FIXUP_FUNC,
6e72aa5f 5986 .v.func = alc_fixup_inv_dmic_0x12,
125821ae 5987 },
033b0a7c
GM
5988 [ALC668_FIXUP_DELL_XPS13] = {
5989 .type = HDA_FIXUP_FUNC,
5990 .v.func = alc_fixup_dell_xps13,
5991 .chained = true,
5992 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
5993 },
5e6db669
GM
5994 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
5995 .type = HDA_FIXUP_FUNC,
5996 .v.func = alc_fixup_disable_aamix,
5997 .chained = true,
5998 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5999 },
493a52a9
HW
6000 [ALC668_FIXUP_AUTO_MUTE] = {
6001 .type = HDA_FIXUP_FUNC,
6002 .v.func = alc_fixup_auto_mute_via_amp,
6003 .chained = true,
6004 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
6005 },
73bdd597
DH
6006 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
6007 .type = HDA_FIXUP_PINS,
6008 .v.pins = (const struct hda_pintbl[]) {
6009 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
6010 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
6011 { }
6012 },
6013 .chained = true,
6014 .chain_id = ALC668_FIXUP_HEADSET_MODE
6015 },
6016 [ALC668_FIXUP_HEADSET_MODE] = {
6017 .type = HDA_FIXUP_FUNC,
6018 .v.func = alc_fixup_headset_mode_alc668,
6019 },
8e54b4ac 6020 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
8e383953 6021 .type = HDA_FIXUP_FUNC,
eb9ca3ab 6022 .v.func = alc_fixup_bass_chmap,
8e383953
TI
6023 .chained = true,
6024 .chain_id = ALC662_FIXUP_ASUS_MODE4
6025 },
61a75f13
DH
6026 [ALC662_FIXUP_BASS_16] = {
6027 .type = HDA_FIXUP_PINS,
6028 .v.pins = (const struct hda_pintbl[]) {
6029 {0x16, 0x80106111}, /* bass speaker */
6030 {}
6031 },
6032 .chained = true,
6033 .chain_id = ALC662_FIXUP_BASS_CHMAP,
6034 },
a30c9aaa
TI
6035 [ALC662_FIXUP_BASS_1A] = {
6036 .type = HDA_FIXUP_PINS,
6037 .v.pins = (const struct hda_pintbl[]) {
6038 {0x1a, 0x80106111}, /* bass speaker */
6039 {}
6040 },
8e54b4ac
DH
6041 .chained = true,
6042 .chain_id = ALC662_FIXUP_BASS_CHMAP,
a30c9aaa 6043 },
8e54b4ac 6044 [ALC662_FIXUP_BASS_CHMAP] = {
a30c9aaa 6045 .type = HDA_FIXUP_FUNC,
eb9ca3ab 6046 .v.func = alc_fixup_bass_chmap,
a30c9aaa 6047 },
6cb3b707
DH
6048};
6049
a9111321 6050static const struct snd_pci_quirk alc662_fixup_tbl[] = {
53c334ad 6051 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
d3d3835c 6052 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
a6c47a85 6053 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
94024cd1 6054 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
125821ae 6055 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
1801928e 6056 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
2df03514 6057 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
73bdd597
DH
6058 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6059 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
c5d019c3 6060 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
033b0a7c 6061 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
09d2014f 6062 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
ad8ff99e 6063 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8dc9abb9
KY
6064 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6065 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
e59ea3ed 6066 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
8e54b4ac
DH
6067 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
6068 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
61a75f13
DH
6069 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
6070 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8e54b4ac 6071 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
1565cc35 6072 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
53c334ad 6073 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
a0e90acc 6074 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
d4118588 6075 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6cb3b707 6076 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
edfe3bfc 6077 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
d2ebd479 6078 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
53c334ad
TI
6079
6080#if 0
6081 /* Below is a quirk table taken from the old code.
6082 * Basically the device should work as is without the fixup table.
6083 * If BIOS doesn't give a proper info, enable the corresponding
6084 * fixup entry.
7d7eb9ea 6085 */
53c334ad
TI
6086 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6087 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6088 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6089 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6090 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6091 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6092 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6093 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6094 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6095 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6096 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6097 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6098 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6099 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6100 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6101 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6102 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6103 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6104 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6105 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6106 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6107 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6108 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6109 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6110 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6111 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6112 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6113 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6114 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6115 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6116 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6117 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6118 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6119 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6120 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6121 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6122 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6123 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6124 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6125 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6126 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6127 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6128 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6129 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6130 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6131 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6132 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6133 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6134 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6135 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6136#endif
6cb3b707
DH
6137 {}
6138};
6139
1727a771 6140static const struct hda_model_fixup alc662_fixup_models[] = {
6be7948f 6141 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
53c334ad
TI
6142 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6143 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6144 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6145 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6146 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6147 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6148 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6149 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6e72aa5f 6150 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
e32aa85a 6151 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
6be7948f
TB
6152 {}
6153};
6cb3b707 6154
532895c5 6155static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
76c2132e
DH
6156 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6157 {0x12, 0x99a30130},
6158 {0x14, 0x90170110},
6159 {0x15, 0x0321101f},
6160 {0x16, 0x03011020},
6161 {0x18, 0x40000008},
6162 {0x19, 0x411111f0},
6163 {0x1a, 0x411111f0},
6164 {0x1b, 0x411111f0},
6165 {0x1d, 0x41000001},
6166 {0x1e, 0x411111f0},
6167 {0x1f, 0x411111f0}),
6168 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6169 {0x12, 0x99a30140},
6170 {0x14, 0x90170110},
6171 {0x15, 0x0321101f},
6172 {0x16, 0x03011020},
6173 {0x18, 0x40000008},
6174 {0x19, 0x411111f0},
6175 {0x1a, 0x411111f0},
6176 {0x1b, 0x411111f0},
6177 {0x1d, 0x41000001},
6178 {0x1e, 0x411111f0},
6179 {0x1f, 0x411111f0}),
6180 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6181 {0x12, 0x99a30150},
6182 {0x14, 0x90170110},
6183 {0x15, 0x0321101f},
6184 {0x16, 0x03011020},
6185 {0x18, 0x40000008},
6186 {0x19, 0x411111f0},
6187 {0x1a, 0x411111f0},
6188 {0x1b, 0x411111f0},
6189 {0x1d, 0x41000001},
6190 {0x1e, 0x411111f0},
6191 {0x1f, 0x411111f0}),
6192 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6193 {0x12, 0x411111f0},
6194 {0x14, 0x90170110},
6195 {0x15, 0x0321101f},
6196 {0x16, 0x03011020},
6197 {0x18, 0x40000008},
6198 {0x19, 0x411111f0},
6199 {0x1a, 0x411111f0},
6200 {0x1b, 0x411111f0},
6201 {0x1d, 0x41000001},
6202 {0x1e, 0x411111f0},
6203 {0x1f, 0x411111f0}),
6204 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
6205 {0x12, 0x90a60130},
6206 {0x14, 0x90170110},
6207 {0x15, 0x0321101f},
6208 {0x16, 0x40000000},
6209 {0x18, 0x411111f0},
6210 {0x19, 0x411111f0},
6211 {0x1a, 0x411111f0},
6212 {0x1b, 0x411111f0},
6213 {0x1d, 0x40d6832d},
6214 {0x1e, 0x411111f0},
6215 {0x1f, 0x411111f0}),
532895c5
HW
6216 {}
6217};
6218
8663ff75
KY
6219static void alc662_fill_coef(struct hda_codec *codec)
6220{
6221 int val, coef;
6222
6223 coef = alc_get_coef0(codec);
6224
6225 switch (codec->vendor_id) {
6226 case 0x10ec0662:
6227 if ((coef & 0x00f0) == 0x0030) {
6228 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
6229 alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
6230 }
6231 break;
6232 case 0x10ec0272:
6233 case 0x10ec0273:
6234 case 0x10ec0663:
6235 case 0x10ec0665:
6236 case 0x10ec0670:
6237 case 0x10ec0671:
6238 case 0x10ec0672:
6239 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
6240 alc_write_coef_idx(codec, 0xd, val | (1<<14));
6241 break;
6242 }
6243}
6cb3b707 6244
1d045db9
TI
6245/*
6246 */
bc9f98a9
KY
6247static int patch_alc662(struct hda_codec *codec)
6248{
6249 struct alc_spec *spec;
3de95173 6250 int err;
bc9f98a9 6251
3de95173
TI
6252 err = alc_alloc_spec(codec, 0x0b);
6253 if (err < 0)
6254 return err;
bc9f98a9 6255
3de95173 6256 spec = codec->spec;
1f0f4b80 6257
53c334ad
TI
6258 /* handle multiple HPs as is */
6259 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6260
2c3bf9ab
TI
6261 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6262
8663ff75
KY
6263 spec->init_hook = alc662_fill_coef;
6264 alc662_fill_coef(codec);
6265
1727a771 6266 snd_hda_pick_fixup(codec, alc662_fixup_models,
8e5a0509 6267 alc662_fixup_tbl, alc662_fixups);
532895c5 6268 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
1727a771 6269 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8e5a0509
TI
6270
6271 alc_auto_parse_customize_define(codec);
6272
7504b6cd
TI
6273 if (has_cdefine_beep(codec))
6274 spec->gen.beep_nid = 0x01;
6275
1bb7e43e 6276 if ((alc_get_coef0(codec) & (1 << 14)) &&
5100cd07 6277 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 6278 spec->cdefine.platform_type == 1) {
6134b1a2
WY
6279 err = alc_codec_rename(codec, "ALC272X");
6280 if (err < 0)
e16fb6d1 6281 goto error;
20ca0c35 6282 }
274693f3 6283
b9c5106c
TI
6284 /* automatic parse from the BIOS config */
6285 err = alc662_parse_auto_config(codec);
e16fb6d1
TI
6286 if (err < 0)
6287 goto error;
bc9f98a9 6288
7504b6cd 6289 if (!spec->gen.no_analog && spec->gen.beep_nid) {
da00c244
KY
6290 switch (codec->vendor_id) {
6291 case 0x10ec0662:
6292 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6293 break;
6294 case 0x10ec0272:
6295 case 0x10ec0663:
6296 case 0x10ec0665:
9ad54547 6297 case 0x10ec0668:
da00c244
KY
6298 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6299 break;
6300 case 0x10ec0273:
6301 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6302 break;
6303 }
cec27c89 6304 }
2134ea4f 6305
bc9f98a9 6306 codec->patch_ops = alc_patch_ops;
1c716153 6307 spec->shutup = alc_eapd_shutup;
6cb3b707 6308
1727a771 6309 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 6310
bc9f98a9 6311 return 0;
801f49d3 6312
e16fb6d1
TI
6313 error:
6314 alc_free(codec);
6315 return err;
b478b998
KY
6316}
6317
d1eb57f4
KY
6318/*
6319 * ALC680 support
6320 */
d1eb57f4 6321
d1eb57f4
KY
6322static int alc680_parse_auto_config(struct hda_codec *codec)
6323{
3e6179b8 6324 return alc_parse_auto_config(codec, NULL, NULL);
d1eb57f4
KY
6325}
6326
d1eb57f4 6327/*
d1eb57f4 6328 */
d1eb57f4
KY
6329static int patch_alc680(struct hda_codec *codec)
6330{
d1eb57f4
KY
6331 int err;
6332
1f0f4b80 6333 /* ALC680 has no aa-loopback mixer */
3de95173
TI
6334 err = alc_alloc_spec(codec, 0);
6335 if (err < 0)
6336 return err;
1f0f4b80 6337
1ebec5f2
TI
6338 /* automatic parse from the BIOS config */
6339 err = alc680_parse_auto_config(codec);
6340 if (err < 0) {
6341 alc_free(codec);
6342 return err;
d1eb57f4
KY
6343 }
6344
d1eb57f4 6345 codec->patch_ops = alc_patch_ops;
d1eb57f4
KY
6346
6347 return 0;
6348}
6349
1da177e4
LT
6350/*
6351 * patch entries
6352 */
a9111321 6353static const struct hda_codec_preset snd_hda_preset_realtek[] = {
296f0338 6354 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
ba4c4d0a 6355 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
84dfd0ac 6356 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
92f974df 6357 { .id = 0x10ec0235, .name = "ALC233", .patch = patch_alc269 },
1d04c9de 6358 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
1da177e4 6359 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
df694daa 6360 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
f6a92248 6361 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
a361d84b 6362 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
f6a92248 6363 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
ebb83eeb 6364 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
01afd41f 6365 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
ebb83eeb 6366 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
296f0338 6367 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
befae82e 6368 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
4e01ec63 6369 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
7ff34ad8 6370 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
065380f0 6371 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
161ebf29 6372 { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
7fc7d047 6373 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
7c665932 6374 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
7ff34ad8 6375 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
af02dde8 6376 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
161ebf29 6377 { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
f32610ed 6378 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
bc9f98a9 6379 .patch = patch_alc861 },
f32610ed
JS
6380 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6381 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6382 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
bc9f98a9 6383 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
4953550a 6384 .patch = patch_alc882 },
bc9f98a9
KY
6385 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6386 .patch = patch_alc662 },
cc667a72
DH
6387 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6388 .patch = patch_alc662 },
6dda9f4a 6389 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
cec27c89 6390 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
72009433 6391 { .id = 0x10ec0667, .name = "ALC667", .patch = patch_alc662 },
19a62823 6392 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
6227cdce 6393 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
1d87caa6 6394 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
d1eb57f4 6395 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
b6c5fbad 6396 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
f32610ed 6397 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
1da177e4 6398 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4953550a 6399 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
669faba2 6400 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
4953550a 6401 .patch = patch_alc882 },
cb308f97 6402 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
4953550a 6403 .patch = patch_alc882 },
df694daa 6404 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
e16fb6d1 6405 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
4442608d 6406 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
4953550a 6407 .patch = patch_alc882 },
e16fb6d1 6408 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
4953550a 6409 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
274693f3 6410 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
e16fb6d1 6411 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
19a62823 6412 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
1da177e4
LT
6413 {} /* terminator */
6414};
1289e9e8
TI
6415
6416MODULE_ALIAS("snd-hda-codec-id:10ec*");
6417
6418MODULE_LICENSE("GPL");
6419MODULE_DESCRIPTION("Realtek HD-audio codec");
6420
6421static struct hda_codec_preset_list realtek_list = {
6422 .preset = snd_hda_preset_realtek,
6423 .owner = THIS_MODULE,
6424};
6425
6426static int __init patch_realtek_init(void)
6427{
6428 return snd_hda_add_codec_preset(&realtek_list);
6429}
6430
6431static void __exit patch_realtek_exit(void)
6432{
6433 snd_hda_delete_codec_preset(&realtek_list);
6434}
6435
6436module_init(patch_realtek_init)
6437module_exit(patch_realtek_exit)