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