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