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