ALSA: usb: Add quirk for 192KHz recording on E-Mu devices
[GitHub/mt8127/android_kernel_alcatel_ttab.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
1d045db9 40/* unsol event tags */
08c189f2 41#define ALC_DCVOL_EVENT 0x08
d4a86d81 42
df694daa
KY
43/* for GPIO Poll */
44#define GPIO_MASK 0x03
45
4a79ba34
TI
46/* extra amp-initialization sequence types */
47enum {
48 ALC_INIT_NONE,
49 ALC_INIT_DEFAULT,
50 ALC_INIT_GPIO1,
51 ALC_INIT_GPIO2,
52 ALC_INIT_GPIO3,
53};
54
da00c244
KY
55struct alc_customize_define {
56 unsigned int sku_cfg;
57 unsigned char port_connectivity;
58 unsigned char check_sum;
59 unsigned char customization;
60 unsigned char external_amp;
61 unsigned int enable_pcbeep:1;
62 unsigned int platform_type:1;
63 unsigned int swap:1;
64 unsigned int override:1;
90622917 65 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
da00c244
KY
66};
67
1da177e4 68struct alc_spec {
08c189f2 69 struct hda_gen_spec gen; /* must be at head */
23d30f28 70
1da177e4 71 /* codec parameterization */
a9111321 72 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
1da177e4 73 unsigned int num_mixers;
45bdd1c1 74 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
1da177e4 75
da00c244 76 struct alc_customize_define cdefine;
08c189f2 77 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
834be88d 78
08c189f2
TI
79 /* inverted dmic fix */
80 unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */
81 unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */
125821ae 82 hda_nid_t inv_dmic_pin;
834be88d 83
08fb0d0e
TI
84 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
85 int mute_led_polarity;
86 hda_nid_t mute_led_nid;
87
9f5c6faf
TI
88 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
89
ae6b813a
TI
90 /* hooks */
91 void (*init_hook)(struct hda_codec *codec);
83012a7c 92#ifdef CONFIG_PM
c97259df 93 void (*power_hook)(struct hda_codec *codec);
f5de24b0 94#endif
1c716153 95 void (*shutup)(struct hda_codec *codec);
d922b51d 96
4a79ba34 97 int init_amp;
d433a678 98 int codec_variant; /* flag for other variants */
e64f14f4 99
2c3bf9ab
TI
100 /* for PLL fix */
101 hda_nid_t pll_nid;
102 unsigned int pll_coef_idx, pll_coef_bit;
1bb7e43e 103 unsigned int coef0;
df694daa
KY
104};
105
d88897ea 106/*
1d045db9
TI
107 * Append the given mixer and verb elements for the later use
108 * The mixer array is referred in build_controls(), and init_verbs are
109 * called in init().
d88897ea 110 */
a9111321 111static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
d88897ea
TI
112{
113 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
114 return;
115 spec->mixers[spec->num_mixers++] = mix;
116}
117
df694daa 118/*
1d045db9 119 * GPIO setup tables, used in initialization
df694daa 120 */
bc9f98a9 121/* Enable GPIO mask and set output */
a9111321 122static const struct hda_verb alc_gpio1_init_verbs[] = {
bc9f98a9
KY
123 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
124 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
125 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
126 { }
127};
128
a9111321 129static const struct hda_verb alc_gpio2_init_verbs[] = {
bc9f98a9
KY
130 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
131 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
132 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
133 { }
134};
135
a9111321 136static const struct hda_verb alc_gpio3_init_verbs[] = {
bdd148a3
KY
137 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
138 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
139 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
140 { }
141};
142
2c3bf9ab
TI
143/*
144 * Fix hardware PLL issue
145 * On some codecs, the analog PLL gating control must be off while
146 * the default value is 1.
147 */
148static void alc_fix_pll(struct hda_codec *codec)
149{
150 struct alc_spec *spec = codec->spec;
151 unsigned int val;
152
153 if (!spec->pll_nid)
154 return;
155 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
156 spec->pll_coef_idx);
157 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
158 AC_VERB_GET_PROC_COEF, 0);
159 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
160 spec->pll_coef_idx);
161 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
162 val & ~(1 << spec->pll_coef_bit));
163}
164
165static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
166 unsigned int coef_idx, unsigned int coef_bit)
167{
168 struct alc_spec *spec = codec->spec;
169 spec->pll_nid = nid;
170 spec->pll_coef_idx = coef_idx;
171 spec->pll_coef_bit = coef_bit;
172 alc_fix_pll(codec);
173}
174
cf5a2279 175/* update the master volume per volume-knob's unsol event */
29adc4b9 176static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
cf5a2279
TI
177{
178 unsigned int val;
179 struct snd_kcontrol *kctl;
180 struct snd_ctl_elem_value *uctl;
181
182 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
183 if (!kctl)
184 return;
185 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
186 if (!uctl)
187 return;
29adc4b9 188 val = snd_hda_codec_read(codec, jack->nid, 0,
cf5a2279
TI
189 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
190 val &= HDA_AMP_VOLMASK;
191 uctl->value.integer.value[0] = val;
192 uctl->value.integer.value[1] = val;
193 kctl->put(kctl, uctl);
194 kfree(uctl);
195}
196
29adc4b9 197static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
f21d78e2 198{
29adc4b9
DH
199 /* For some reason, the res given from ALC880 is broken.
200 Here we adjust it properly. */
201 snd_hda_jack_unsol_event(codec, res >> 2);
f21d78e2
TI
202}
203
f9423e7a
KY
204/* additional initialization for ALC888 variants */
205static void alc888_coef_init(struct hda_codec *codec)
206{
207 unsigned int tmp;
208
209 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
210 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
211 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
37db623a 212 if ((tmp & 0xf0) == 0x20)
f9423e7a
KY
213 /* alc888S-VC */
214 snd_hda_codec_read(codec, 0x20, 0,
215 AC_VERB_SET_PROC_COEF, 0x830);
216 else
217 /* alc888-VB */
218 snd_hda_codec_read(codec, 0x20, 0,
219 AC_VERB_SET_PROC_COEF, 0x3030);
220}
221
1d045db9 222/* additional initialization for ALC889 variants */
87a8c370
JK
223static void alc889_coef_init(struct hda_codec *codec)
224{
225 unsigned int tmp;
226
227 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
228 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
229 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
230 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
231}
232
3fb4a508
TI
233/* turn on/off EAPD control (only if available) */
234static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
235{
236 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
237 return;
238 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
239 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
240 on ? 2 : 0);
241}
242
691f1fcc
TI
243/* turn on/off EAPD controls of the codec */
244static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
245{
246 /* We currently only handle front, HP */
39fa84e9
TI
247 static hda_nid_t pins[] = {
248 0x0f, 0x10, 0x14, 0x15, 0
249 };
250 hda_nid_t *p;
251 for (p = pins; *p; p++)
252 set_eapd(codec, *p, on);
691f1fcc
TI
253}
254
1c716153
TI
255/* generic shutup callback;
256 * just turning off EPAD and a little pause for avoiding pop-noise
257 */
258static void alc_eapd_shutup(struct hda_codec *codec)
259{
260 alc_auto_setup_eapd(codec, false);
261 msleep(200);
262}
263
1d045db9 264/* generic EAPD initialization */
4a79ba34 265static void alc_auto_init_amp(struct hda_codec *codec, int type)
bc9f98a9 266{
4a79ba34 267 unsigned int tmp;
bc9f98a9 268
39fa84e9 269 alc_auto_setup_eapd(codec, true);
4a79ba34
TI
270 switch (type) {
271 case ALC_INIT_GPIO1:
bc9f98a9
KY
272 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
273 break;
4a79ba34 274 case ALC_INIT_GPIO2:
bc9f98a9
KY
275 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
276 break;
4a79ba34 277 case ALC_INIT_GPIO3:
bdd148a3
KY
278 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
279 break;
4a79ba34 280 case ALC_INIT_DEFAULT:
c9b58006
KY
281 switch (codec->vendor_id) {
282 case 0x10ec0260:
283 snd_hda_codec_write(codec, 0x1a, 0,
284 AC_VERB_SET_COEF_INDEX, 7);
285 tmp = snd_hda_codec_read(codec, 0x1a, 0,
286 AC_VERB_GET_PROC_COEF, 0);
287 snd_hda_codec_write(codec, 0x1a, 0,
288 AC_VERB_SET_COEF_INDEX, 7);
289 snd_hda_codec_write(codec, 0x1a, 0,
290 AC_VERB_SET_PROC_COEF,
291 tmp | 0x2010);
292 break;
293 case 0x10ec0262:
294 case 0x10ec0880:
295 case 0x10ec0882:
296 case 0x10ec0883:
297 case 0x10ec0885:
4a5a4c56 298 case 0x10ec0887:
20b67ddd 299 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
87a8c370 300 alc889_coef_init(codec);
c9b58006 301 break;
f9423e7a 302 case 0x10ec0888:
4a79ba34 303 alc888_coef_init(codec);
f9423e7a 304 break;
0aea778e 305#if 0 /* XXX: This may cause the silent output on speaker on some machines */
c9b58006
KY
306 case 0x10ec0267:
307 case 0x10ec0268:
308 snd_hda_codec_write(codec, 0x20, 0,
309 AC_VERB_SET_COEF_INDEX, 7);
310 tmp = snd_hda_codec_read(codec, 0x20, 0,
311 AC_VERB_GET_PROC_COEF, 0);
312 snd_hda_codec_write(codec, 0x20, 0,
ea1fb29a 313 AC_VERB_SET_COEF_INDEX, 7);
c9b58006
KY
314 snd_hda_codec_write(codec, 0x20, 0,
315 AC_VERB_SET_PROC_COEF,
316 tmp | 0x3000);
317 break;
0aea778e 318#endif /* XXX */
bc9f98a9 319 }
4a79ba34
TI
320 break;
321 }
322}
323
08c189f2 324
1d045db9 325/*
08c189f2 326 * Realtek SSID verification
1d045db9 327 */
42cf0d01 328
08c189f2
TI
329/* Could be any non-zero and even value. When used as fixup, tells
330 * the driver to ignore any present sku defines.
331 */
332#define ALC_FIXUP_SKU_IGNORE (2)
1a1455de 333
08c189f2
TI
334static void alc_fixup_sku_ignore(struct hda_codec *codec,
335 const struct hda_fixup *fix, int action)
1a1455de 336{
1a1455de 337 struct alc_spec *spec = codec->spec;
08c189f2
TI
338 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
339 spec->cdefine.fixup = 1;
340 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
1a1455de 341 }
1a1455de
TI
342}
343
08c189f2 344static int alc_auto_parse_customize_define(struct hda_codec *codec)
4a79ba34 345{
08c189f2
TI
346 unsigned int ass, tmp, i;
347 unsigned nid = 0;
4a79ba34
TI
348 struct alc_spec *spec = codec->spec;
349
08c189f2 350 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
4a79ba34 351
08c189f2
TI
352 if (spec->cdefine.fixup) {
353 ass = spec->cdefine.sku_cfg;
354 if (ass == ALC_FIXUP_SKU_IGNORE)
355 return -1;
356 goto do_sku;
bb35febd
TI
357 }
358
08c189f2
TI
359 ass = codec->subsystem_id & 0xffff;
360 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
361 goto do_sku;
4a79ba34 362
08c189f2
TI
363 nid = 0x1d;
364 if (codec->vendor_id == 0x10ec0260)
365 nid = 0x17;
366 ass = snd_hda_codec_get_pincfg(codec, nid);
42cf0d01 367
08c189f2
TI
368 if (!(ass & 1)) {
369 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
370 codec->chip_name, ass);
371 return -1;
42cf0d01
DH
372 }
373
08c189f2
TI
374 /* check sum */
375 tmp = 0;
376 for (i = 1; i < 16; i++) {
377 if ((ass >> i) & 1)
378 tmp++;
ae8a60a5 379 }
08c189f2
TI
380 if (((ass >> 16) & 0xf) != tmp)
381 return -1;
ae8a60a5 382
da00c244
KY
383 spec->cdefine.port_connectivity = ass >> 30;
384 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
385 spec->cdefine.check_sum = (ass >> 16) & 0xf;
386 spec->cdefine.customization = ass >> 8;
387do_sku:
388 spec->cdefine.sku_cfg = ass;
389 spec->cdefine.external_amp = (ass & 0x38) >> 3;
390 spec->cdefine.platform_type = (ass & 0x4) >> 2;
391 spec->cdefine.swap = (ass & 0x2) >> 1;
392 spec->cdefine.override = ass & 0x1;
393
394 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
395 nid, spec->cdefine.sku_cfg);
396 snd_printd("SKU: port_connectivity=0x%x\n",
397 spec->cdefine.port_connectivity);
398 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
399 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
400 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
401 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
402 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
403 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
404 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
405
406 return 0;
407}
408
08c189f2
TI
409/* return the position of NID in the list, or -1 if not found */
410static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
411{
412 int i;
413 for (i = 0; i < nums; i++)
414 if (list[i] == nid)
415 return i;
416 return -1;
417}
1d045db9 418/* return true if the given NID is found in the list */
3af9ee6b
TI
419static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
420{
21268961 421 return find_idx_in_nid_list(nid, list, nums) >= 0;
3af9ee6b
TI
422}
423
4a79ba34
TI
424/* check subsystem ID and set up device-specific initialization;
425 * return 1 if initialized, 0 if invalid SSID
426 */
427/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
428 * 31 ~ 16 : Manufacture ID
429 * 15 ~ 8 : SKU ID
430 * 7 ~ 0 : Assembly ID
431 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
432 */
433static int alc_subsystem_id(struct hda_codec *codec,
434 hda_nid_t porta, hda_nid_t porte,
6227cdce 435 hda_nid_t portd, hda_nid_t porti)
4a79ba34
TI
436{
437 unsigned int ass, tmp, i;
438 unsigned nid;
439 struct alc_spec *spec = codec->spec;
440
90622917
DH
441 if (spec->cdefine.fixup) {
442 ass = spec->cdefine.sku_cfg;
443 if (ass == ALC_FIXUP_SKU_IGNORE)
444 return 0;
445 goto do_sku;
446 }
447
4a79ba34
TI
448 ass = codec->subsystem_id & 0xffff;
449 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
450 goto do_sku;
451
452 /* invalid SSID, check the special NID pin defcfg instead */
453 /*
def319f9 454 * 31~30 : port connectivity
4a79ba34
TI
455 * 29~21 : reserve
456 * 20 : PCBEEP input
457 * 19~16 : Check sum (15:1)
458 * 15~1 : Custom
459 * 0 : override
460 */
461 nid = 0x1d;
462 if (codec->vendor_id == 0x10ec0260)
463 nid = 0x17;
464 ass = snd_hda_codec_get_pincfg(codec, nid);
465 snd_printd("realtek: No valid SSID, "
466 "checking pincfg 0x%08x for NID 0x%x\n",
cb6605c1 467 ass, nid);
6227cdce 468 if (!(ass & 1))
4a79ba34
TI
469 return 0;
470 if ((ass >> 30) != 1) /* no physical connection */
471 return 0;
472
473 /* check sum */
474 tmp = 0;
475 for (i = 1; i < 16; i++) {
476 if ((ass >> i) & 1)
477 tmp++;
478 }
479 if (((ass >> 16) & 0xf) != tmp)
480 return 0;
481do_sku:
482 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
483 ass & 0xffff, codec->vendor_id);
484 /*
485 * 0 : override
486 * 1 : Swap Jack
487 * 2 : 0 --> Desktop, 1 --> Laptop
488 * 3~5 : External Amplifier control
489 * 7~6 : Reserved
490 */
491 tmp = (ass & 0x38) >> 3; /* external Amp control */
492 switch (tmp) {
493 case 1:
494 spec->init_amp = ALC_INIT_GPIO1;
495 break;
496 case 3:
497 spec->init_amp = ALC_INIT_GPIO2;
498 break;
499 case 7:
500 spec->init_amp = ALC_INIT_GPIO3;
501 break;
502 case 5:
5a8cfb4e 503 default:
4a79ba34 504 spec->init_amp = ALC_INIT_DEFAULT;
bc9f98a9
KY
505 break;
506 }
ea1fb29a 507
8c427226 508 /* is laptop or Desktop and enable the function "Mute internal speaker
c9b58006
KY
509 * when the external headphone out jack is plugged"
510 */
8c427226 511 if (!(ass & 0x8000))
4a79ba34 512 return 1;
c9b58006
KY
513 /*
514 * 10~8 : Jack location
515 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
516 * 14~13: Resvered
517 * 15 : 1 --> enable the function "Mute internal speaker
518 * when the external headphone out jack is plugged"
519 */
08c189f2
TI
520 if (!spec->gen.autocfg.hp_pins[0] &&
521 !(spec->gen.autocfg.line_out_pins[0] &&
522 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
01d4825d 523 hda_nid_t nid;
c9b58006
KY
524 tmp = (ass >> 11) & 0x3; /* HP to chassis */
525 if (tmp == 0)
01d4825d 526 nid = porta;
c9b58006 527 else if (tmp == 1)
01d4825d 528 nid = porte;
c9b58006 529 else if (tmp == 2)
01d4825d 530 nid = portd;
6227cdce
KY
531 else if (tmp == 3)
532 nid = porti;
c9b58006 533 else
4a79ba34 534 return 1;
08c189f2
TI
535 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
536 spec->gen.autocfg.line_outs))
3af9ee6b 537 return 1;
08c189f2 538 spec->gen.autocfg.hp_pins[0] = nid;
c9b58006 539 }
4a79ba34
TI
540 return 1;
541}
ea1fb29a 542
3e6179b8
TI
543/* Check the validity of ALC subsystem-id
544 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
545static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
4a79ba34 546{
3e6179b8 547 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
4a79ba34
TI
548 struct alc_spec *spec = codec->spec;
549 snd_printd("realtek: "
550 "Enable default setup for auto mode as fallback\n");
551 spec->init_amp = ALC_INIT_DEFAULT;
4a79ba34 552 }
21268961 553}
1a1455de 554
1d045db9
TI
555/*
556 * COEF access helper functions
557 */
274693f3
KY
558static int alc_read_coef_idx(struct hda_codec *codec,
559 unsigned int coef_idx)
560{
561 unsigned int val;
562 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
563 coef_idx);
564 val = snd_hda_codec_read(codec, 0x20, 0,
565 AC_VERB_GET_PROC_COEF, 0);
566 return val;
567}
568
977ddd6b
KY
569static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
570 unsigned int coef_val)
571{
572 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
573 coef_idx);
574 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
575 coef_val);
576}
577
1bb7e43e
TI
578/* a special bypass for COEF 0; read the cached value at the second time */
579static unsigned int alc_get_coef0(struct hda_codec *codec)
580{
581 struct alc_spec *spec = codec->spec;
582 if (!spec->coef0)
583 spec->coef0 = alc_read_coef_idx(codec, 0);
584 return spec->coef0;
585}
586
1d045db9 587/*
ef8ef5fb 588 */
f9e336f6 589
08c189f2 590static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
f9e336f6 591{
08c189f2
TI
592 struct hda_gen_spec *spec = codec->spec;
593 if (spec->dyn_adc_switch)
594 adc_idx = spec->dyn_adc_idx[imux_idx];
595 return spec->adc_nids[adc_idx];
f9e336f6
TI
596}
597
666a70d4 598static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
f9e336f6 599{
f9e336f6 600 struct alc_spec *spec = codec->spec;
08c189f2 601 struct hda_input_mux *imux = &spec->gen.input_mux;
666a70d4
TI
602 struct nid_path *path;
603 hda_nid_t nid;
604 int i, dir, parm;
605 unsigned int val;
f9e336f6 606
666a70d4 607 for (i = 0; i < imux->num_items; i++) {
08c189f2 608 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
666a70d4 609 break;
a23b688f 610 }
666a70d4
TI
611 if (i >= imux->num_items)
612 return;
a23b688f 613
08c189f2
TI
614 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
615 get_adc_nid(codec, adc_idx, i));
666a70d4
TI
616 val = path->ctls[NID_PATH_MUTE_CTL];
617 if (!val)
618 return;
619 nid = get_amp_nid_(val);
620 dir = get_amp_direction_(val);
621 parm = AC_AMP_SET_RIGHT |
622 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
a23b688f 623
c4f3ebed 624 /* flush all cached amps at first */
dc870f38 625 snd_hda_codec_flush_cache(codec);
a23b688f 626
666a70d4
TI
627 /* we care only right channel */
628 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
629 if (val & 0x80) /* if already muted, we don't need to touch */
630 return;
631 val |= 0x80;
632 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
633 parm | val);
f9e336f6
TI
634}
635
125821ae
TI
636/*
637 * Inverted digital-mic handling
638 *
639 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
640 * gives the additional mute only to the right channel of the digital mic
641 * capture stream. This is a workaround for avoiding the almost silence
642 * by summing the stereo stream from some (known to be ForteMedia)
643 * digital mic unit.
644 *
645 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
646 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
647 * without caching so that the cache can still keep the original value.
648 * The cached value is then restored when the flag is set off or any other
649 * than d-mic is used as the current input source.
650 */
651static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
652{
653 struct alc_spec *spec = codec->spec;
666a70d4 654 int src, nums;
125821ae
TI
655
656 if (!spec->inv_dmic_fixup)
657 return;
658 if (!spec->inv_dmic_muted && !force)
659 return;
08c189f2 660 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
666a70d4 661 for (src = 0; src < nums; src++) {
125821ae 662 bool dmic_fixup = false;
125821ae
TI
663
664 if (spec->inv_dmic_muted &&
08c189f2 665 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
125821ae
TI
666 dmic_fixup = true;
667 if (!dmic_fixup && !force)
668 continue;
666a70d4 669 alc_inv_dmic_sync_adc(codec, src);
125821ae
TI
670 }
671}
672
a90229e0
TI
673static void alc_inv_dmic_hook(struct hda_codec *codec,
674 struct snd_ctl_elem_value *ucontrol)
08c189f2
TI
675{
676 alc_inv_dmic_sync(codec, false);
677}
678
125821ae
TI
679static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
681{
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
683 struct alc_spec *spec = codec->spec;
684
685 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
686 return 0;
687}
688
689static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct alc_spec *spec = codec->spec;
694 unsigned int val = !ucontrol->value.integer.value[0];
695
696 if (val == spec->inv_dmic_muted)
697 return 0;
698 spec->inv_dmic_muted = val;
699 alc_inv_dmic_sync(codec, true);
700 return 0;
701}
702
703static const struct snd_kcontrol_new alc_inv_dmic_sw = {
704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
bc549767 705 .name = "Inverted Internal Mic Capture Switch",
125821ae
TI
706 .info = snd_ctl_boolean_mono_info,
707 .get = alc_inv_dmic_sw_get,
708 .put = alc_inv_dmic_sw_put,
709};
710
711static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
712{
713 struct alc_spec *spec = codec->spec;
668d1e96 714
08c189f2 715 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
125821ae
TI
716 return -ENOMEM;
717 spec->inv_dmic_fixup = 1;
718 spec->inv_dmic_muted = 0;
719 spec->inv_dmic_pin = nid;
08c189f2 720 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
125821ae
TI
721 return 0;
722}
723
6e72aa5f
TI
724/* typically the digital mic is put at node 0x12 */
725static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
1727a771 726 const struct hda_fixup *fix, int action)
6e72aa5f 727{
1727a771 728 if (action == HDA_FIXUP_ACT_PROBE)
6e72aa5f
TI
729 alc_add_inv_dmic_mixer(codec, 0x12);
730}
731
e9edcee0 732
1d045db9
TI
733#ifdef CONFIG_SND_HDA_INPUT_BEEP
734/* additional beep mixers; the actual parameters are overwritten at build */
735static const struct snd_kcontrol_new alc_beep_mixer[] = {
736 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
737 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
16ded525
TI
738 { } /* end */
739};
1d045db9 740#endif
16ded525 741
08c189f2 742static int alc_build_controls(struct hda_codec *codec)
1d045db9
TI
743{
744 struct alc_spec *spec = codec->spec;
08c189f2 745 int i, err;
e9427969 746
08c189f2
TI
747 err = snd_hda_gen_build_controls(codec);
748 if (err < 0)
749 return err;
1da177e4
LT
750
751 for (i = 0; i < spec->num_mixers; i++) {
752 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
753 if (err < 0)
754 return err;
755 }
2134ea4f 756
67d634c0 757#ifdef CONFIG_SND_HDA_INPUT_BEEP
45bdd1c1
TI
758 /* create beep controls if needed */
759 if (spec->beep_amp) {
a9111321 760 const struct snd_kcontrol_new *knew;
45bdd1c1
TI
761 for (knew = alc_beep_mixer; knew->name; knew++) {
762 struct snd_kcontrol *kctl;
763 kctl = snd_ctl_new1(knew, codec);
764 if (!kctl)
08c189f2
TI
765 return -ENOMEM;
766 kctl->private_value = spec->beep_amp;
767 err = snd_hda_ctl_add(codec, 0, kctl);
768 if (err < 0)
769 return err;
1d045db9 770 }
863b4518 771 }
08c189f2 772#endif
1c4a54b4 773
1727a771 774 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
1c4a54b4 775 return 0;
a361d84b
KY
776}
777
a361d84b 778
df694daa 779/*
08c189f2 780 * Common callbacks
df694daa 781 */
a361d84b 782
08c189f2 783static int alc_init(struct hda_codec *codec)
1d045db9
TI
784{
785 struct alc_spec *spec = codec->spec;
a361d84b 786
08c189f2
TI
787 if (spec->init_hook)
788 spec->init_hook(codec);
a361d84b 789
08c189f2
TI
790 alc_fix_pll(codec);
791 alc_auto_init_amp(codec, spec->init_amp);
3abf2f36 792
08c189f2 793 snd_hda_gen_init(codec);
a361d84b 794
1727a771 795 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
a361d84b 796
1d045db9
TI
797 return 0;
798}
a361d84b 799
08c189f2 800static inline void alc_shutup(struct hda_codec *codec)
1d045db9
TI
801{
802 struct alc_spec *spec = codec->spec;
a361d84b 803
08c189f2
TI
804 if (spec && spec->shutup)
805 spec->shutup(codec);
806 snd_hda_shutup_pins(codec);
1d045db9
TI
807}
808
7504b6cd 809#define alc_free snd_hda_gen_free
2134ea4f 810
08c189f2
TI
811#ifdef CONFIG_PM
812static void alc_power_eapd(struct hda_codec *codec)
1d045db9 813{
08c189f2 814 alc_auto_setup_eapd(codec, false);
1d045db9 815}
2134ea4f 816
08c189f2 817static int alc_suspend(struct hda_codec *codec)
1d045db9
TI
818{
819 struct alc_spec *spec = codec->spec;
08c189f2
TI
820 alc_shutup(codec);
821 if (spec && spec->power_hook)
822 spec->power_hook(codec);
a361d84b
KY
823 return 0;
824}
08c189f2 825#endif
a361d84b 826
08c189f2
TI
827#ifdef CONFIG_PM
828static int alc_resume(struct hda_codec *codec)
1d045db9 829{
08c189f2
TI
830 msleep(150); /* to avoid pop noise */
831 codec->patch_ops.init(codec);
832 snd_hda_codec_resume_amp(codec);
833 snd_hda_codec_resume_cache(codec);
834 alc_inv_dmic_sync(codec, true);
835 hda_call_check_power_status(codec, 0x01);
836 return 0;
1d045db9 837}
08c189f2 838#endif
f6a92248 839
1d045db9 840/*
1d045db9 841 */
08c189f2
TI
842static const struct hda_codec_ops alc_patch_ops = {
843 .build_controls = alc_build_controls,
844 .build_pcms = snd_hda_gen_build_pcms,
845 .init = alc_init,
846 .free = alc_free,
847 .unsol_event = snd_hda_jack_unsol_event,
848#ifdef CONFIG_PM
849 .resume = alc_resume,
08c189f2 850 .suspend = alc_suspend,
fce52a3b 851 .check_power_status = snd_hda_gen_check_power_status,
08c189f2
TI
852#endif
853 .reboot_notify = alc_shutup,
854};
f6a92248 855
f53281e6 856
08c189f2
TI
857/* replace the codec chip_name with the given string */
858static int alc_codec_rename(struct hda_codec *codec, const char *name)
1d045db9 859{
08c189f2
TI
860 kfree(codec->chip_name);
861 codec->chip_name = kstrdup(name, GFP_KERNEL);
862 if (!codec->chip_name) {
863 alc_free(codec);
864 return -ENOMEM;
1d045db9 865 }
a361d84b 866 return 0;
1d045db9 867}
e01bf509 868
e4770629 869/*
08c189f2 870 * Rename codecs appropriately from COEF value
e4770629 871 */
08c189f2
TI
872struct alc_codec_rename_table {
873 unsigned int vendor_id;
874 unsigned short coef_mask;
875 unsigned short coef_bits;
876 const char *name;
877};
84898e87 878
08c189f2
TI
879static struct alc_codec_rename_table rename_tbl[] = {
880 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
881 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
882 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
883 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
884 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
885 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
886 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
887 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
888 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
889 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
890 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
891 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
892 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
893 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
894 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
895 { } /* terminator */
896};
84898e87 897
08c189f2 898static int alc_codec_rename_from_preset(struct hda_codec *codec)
1d045db9 899{
08c189f2 900 const struct alc_codec_rename_table *p;
60db6b53 901
08c189f2
TI
902 for (p = rename_tbl; p->vendor_id; p++) {
903 if (p->vendor_id != codec->vendor_id)
904 continue;
905 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
906 return alc_codec_rename(codec, p->name);
1d045db9 907 }
08c189f2 908 return 0;
1d045db9 909}
f53281e6 910
e4770629 911
1d045db9
TI
912/*
913 * Digital-beep handlers
914 */
915#ifdef CONFIG_SND_HDA_INPUT_BEEP
916#define set_beep_amp(spec, nid, idx, dir) \
917 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
84898e87 918
1d045db9 919static const struct snd_pci_quirk beep_white_list[] = {
7110005e 920 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1d045db9 921 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
8554ee40 922 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1d045db9
TI
923 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
924 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
925 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
78f8baf1 926 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1d045db9
TI
927 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
928 {}
fe3eb0a7
KY
929};
930
1d045db9
TI
931static inline int has_cdefine_beep(struct hda_codec *codec)
932{
933 struct alc_spec *spec = codec->spec;
934 const struct snd_pci_quirk *q;
935 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
936 if (q)
937 return q->value;
938 return spec->cdefine.enable_pcbeep;
939}
940#else
941#define set_beep_amp(spec, nid, idx, dir) /* NOP */
942#define has_cdefine_beep(codec) 0
943#endif
84898e87 944
1d045db9
TI
945/* parse the BIOS configuration and set up the alc_spec */
946/* return 1 if successful, 0 if the proper config is not found,
947 * or a negative error code
948 */
3e6179b8
TI
949static int alc_parse_auto_config(struct hda_codec *codec,
950 const hda_nid_t *ignore_nids,
951 const hda_nid_t *ssid_nids)
1d045db9
TI
952{
953 struct alc_spec *spec = codec->spec;
08c189f2 954 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1d045db9 955 int err;
26f5df26 956
53c334ad
TI
957 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
958 spec->parse_flags);
1d045db9
TI
959 if (err < 0)
960 return err;
3e6179b8
TI
961
962 if (ssid_nids)
963 alc_ssid_check(codec, ssid_nids);
64154835 964
08c189f2
TI
965 err = snd_hda_gen_parse_auto_config(codec, cfg);
966 if (err < 0)
967 return err;
070cff4c 968
1d045db9 969 return 1;
60db6b53 970}
f6a92248 971
3de95173
TI
972/* common preparation job for alc_spec */
973static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
974{
975 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
976 int err;
977
978 if (!spec)
979 return -ENOMEM;
980 codec->spec = spec;
08c189f2
TI
981 snd_hda_gen_spec_init(&spec->gen);
982 spec->gen.mixer_nid = mixer_nid;
983 spec->gen.own_eapd_ctl = 1;
1098b7c2 984 codec->single_adc_amp = 1;
08c189f2
TI
985 /* FIXME: do we need this for all Realtek codec models? */
986 codec->spdif_status_reset = 1;
3de95173
TI
987
988 err = alc_codec_rename_from_preset(codec);
989 if (err < 0) {
990 kfree(spec);
991 return err;
992 }
993 return 0;
994}
995
3e6179b8
TI
996static int alc880_parse_auto_config(struct hda_codec *codec)
997{
998 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
7d7eb9ea 999 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3e6179b8
TI
1000 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1001}
1002
ee3b2969
TI
1003/*
1004 * ALC880 fix-ups
1005 */
1006enum {
411225a0 1007 ALC880_FIXUP_GPIO1,
ee3b2969
TI
1008 ALC880_FIXUP_GPIO2,
1009 ALC880_FIXUP_MEDION_RIM,
dc6af52d 1010 ALC880_FIXUP_LG,
f02aab5d 1011 ALC880_FIXUP_W810,
27e917f8 1012 ALC880_FIXUP_EAPD_COEF,
b9368f5c 1013 ALC880_FIXUP_TCL_S700,
cf5a2279
TI
1014 ALC880_FIXUP_VOL_KNOB,
1015 ALC880_FIXUP_FUJITSU,
ba533818 1016 ALC880_FIXUP_F1734,
817de92f 1017 ALC880_FIXUP_UNIWILL,
967b88c4 1018 ALC880_FIXUP_UNIWILL_DIG,
96e225f6 1019 ALC880_FIXUP_Z71V,
67b6ec31
TI
1020 ALC880_FIXUP_3ST_BASE,
1021 ALC880_FIXUP_3ST,
1022 ALC880_FIXUP_3ST_DIG,
1023 ALC880_FIXUP_5ST_BASE,
1024 ALC880_FIXUP_5ST,
1025 ALC880_FIXUP_5ST_DIG,
1026 ALC880_FIXUP_6ST_BASE,
1027 ALC880_FIXUP_6ST,
1028 ALC880_FIXUP_6ST_DIG,
5397145f 1029 ALC880_FIXUP_6ST_AUTOMUTE,
ee3b2969
TI
1030};
1031
cf5a2279
TI
1032/* enable the volume-knob widget support on NID 0x21 */
1033static void alc880_fixup_vol_knob(struct hda_codec *codec,
1727a771 1034 const struct hda_fixup *fix, int action)
cf5a2279 1035{
1727a771 1036 if (action == HDA_FIXUP_ACT_PROBE)
29adc4b9 1037 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
cf5a2279
TI
1038}
1039
1727a771 1040static const struct hda_fixup alc880_fixups[] = {
411225a0 1041 [ALC880_FIXUP_GPIO1] = {
1727a771 1042 .type = HDA_FIXUP_VERBS,
411225a0
TI
1043 .v.verbs = alc_gpio1_init_verbs,
1044 },
ee3b2969 1045 [ALC880_FIXUP_GPIO2] = {
1727a771 1046 .type = HDA_FIXUP_VERBS,
ee3b2969
TI
1047 .v.verbs = alc_gpio2_init_verbs,
1048 },
1049 [ALC880_FIXUP_MEDION_RIM] = {
1727a771 1050 .type = HDA_FIXUP_VERBS,
ee3b2969
TI
1051 .v.verbs = (const struct hda_verb[]) {
1052 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1053 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1054 { }
1055 },
1056 .chained = true,
1057 .chain_id = ALC880_FIXUP_GPIO2,
1058 },
dc6af52d 1059 [ALC880_FIXUP_LG] = {
1727a771
TI
1060 .type = HDA_FIXUP_PINS,
1061 .v.pins = (const struct hda_pintbl[]) {
dc6af52d
TI
1062 /* disable bogus unused pins */
1063 { 0x16, 0x411111f0 },
1064 { 0x18, 0x411111f0 },
1065 { 0x1a, 0x411111f0 },
1066 { }
1067 }
1068 },
f02aab5d 1069 [ALC880_FIXUP_W810] = {
1727a771
TI
1070 .type = HDA_FIXUP_PINS,
1071 .v.pins = (const struct hda_pintbl[]) {
f02aab5d
TI
1072 /* disable bogus unused pins */
1073 { 0x17, 0x411111f0 },
1074 { }
1075 },
1076 .chained = true,
1077 .chain_id = ALC880_FIXUP_GPIO2,
1078 },
27e917f8 1079 [ALC880_FIXUP_EAPD_COEF] = {
1727a771 1080 .type = HDA_FIXUP_VERBS,
27e917f8
TI
1081 .v.verbs = (const struct hda_verb[]) {
1082 /* change to EAPD mode */
1083 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1084 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1085 {}
1086 },
1087 },
b9368f5c 1088 [ALC880_FIXUP_TCL_S700] = {
1727a771 1089 .type = HDA_FIXUP_VERBS,
b9368f5c
TI
1090 .v.verbs = (const struct hda_verb[]) {
1091 /* change to EAPD mode */
1092 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1093 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1094 {}
1095 },
1096 .chained = true,
1097 .chain_id = ALC880_FIXUP_GPIO2,
1098 },
cf5a2279 1099 [ALC880_FIXUP_VOL_KNOB] = {
1727a771 1100 .type = HDA_FIXUP_FUNC,
cf5a2279
TI
1101 .v.func = alc880_fixup_vol_knob,
1102 },
1103 [ALC880_FIXUP_FUJITSU] = {
1104 /* override all pins as BIOS on old Amilo is broken */
1727a771
TI
1105 .type = HDA_FIXUP_PINS,
1106 .v.pins = (const struct hda_pintbl[]) {
cf5a2279
TI
1107 { 0x14, 0x0121411f }, /* HP */
1108 { 0x15, 0x99030120 }, /* speaker */
1109 { 0x16, 0x99030130 }, /* bass speaker */
1110 { 0x17, 0x411111f0 }, /* N/A */
1111 { 0x18, 0x411111f0 }, /* N/A */
1112 { 0x19, 0x01a19950 }, /* mic-in */
1113 { 0x1a, 0x411111f0 }, /* N/A */
1114 { 0x1b, 0x411111f0 }, /* N/A */
1115 { 0x1c, 0x411111f0 }, /* N/A */
1116 { 0x1d, 0x411111f0 }, /* N/A */
1117 { 0x1e, 0x01454140 }, /* SPDIF out */
1118 { }
1119 },
1120 .chained = true,
1121 .chain_id = ALC880_FIXUP_VOL_KNOB,
1122 },
ba533818
TI
1123 [ALC880_FIXUP_F1734] = {
1124 /* almost compatible with FUJITSU, but no bass and SPDIF */
1727a771
TI
1125 .type = HDA_FIXUP_PINS,
1126 .v.pins = (const struct hda_pintbl[]) {
ba533818
TI
1127 { 0x14, 0x0121411f }, /* HP */
1128 { 0x15, 0x99030120 }, /* speaker */
1129 { 0x16, 0x411111f0 }, /* N/A */
1130 { 0x17, 0x411111f0 }, /* N/A */
1131 { 0x18, 0x411111f0 }, /* N/A */
1132 { 0x19, 0x01a19950 }, /* mic-in */
1133 { 0x1a, 0x411111f0 }, /* N/A */
1134 { 0x1b, 0x411111f0 }, /* N/A */
1135 { 0x1c, 0x411111f0 }, /* N/A */
1136 { 0x1d, 0x411111f0 }, /* N/A */
1137 { 0x1e, 0x411111f0 }, /* N/A */
1138 { }
1139 },
1140 .chained = true,
1141 .chain_id = ALC880_FIXUP_VOL_KNOB,
1142 },
817de92f
TI
1143 [ALC880_FIXUP_UNIWILL] = {
1144 /* need to fix HP and speaker pins to be parsed correctly */
1727a771
TI
1145 .type = HDA_FIXUP_PINS,
1146 .v.pins = (const struct hda_pintbl[]) {
817de92f
TI
1147 { 0x14, 0x0121411f }, /* HP */
1148 { 0x15, 0x99030120 }, /* speaker */
1149 { 0x16, 0x99030130 }, /* bass speaker */
1150 { }
1151 },
1152 },
967b88c4 1153 [ALC880_FIXUP_UNIWILL_DIG] = {
1727a771
TI
1154 .type = HDA_FIXUP_PINS,
1155 .v.pins = (const struct hda_pintbl[]) {
967b88c4
TI
1156 /* disable bogus unused pins */
1157 { 0x17, 0x411111f0 },
1158 { 0x19, 0x411111f0 },
1159 { 0x1b, 0x411111f0 },
1160 { 0x1f, 0x411111f0 },
1161 { }
1162 }
1163 },
96e225f6 1164 [ALC880_FIXUP_Z71V] = {
1727a771
TI
1165 .type = HDA_FIXUP_PINS,
1166 .v.pins = (const struct hda_pintbl[]) {
96e225f6
TI
1167 /* set up the whole pins as BIOS is utterly broken */
1168 { 0x14, 0x99030120 }, /* speaker */
1169 { 0x15, 0x0121411f }, /* HP */
1170 { 0x16, 0x411111f0 }, /* N/A */
1171 { 0x17, 0x411111f0 }, /* N/A */
1172 { 0x18, 0x01a19950 }, /* mic-in */
1173 { 0x19, 0x411111f0 }, /* N/A */
1174 { 0x1a, 0x01813031 }, /* line-in */
1175 { 0x1b, 0x411111f0 }, /* N/A */
1176 { 0x1c, 0x411111f0 }, /* N/A */
1177 { 0x1d, 0x411111f0 }, /* N/A */
1178 { 0x1e, 0x0144111e }, /* SPDIF */
1179 { }
1180 }
1181 },
67b6ec31 1182 [ALC880_FIXUP_3ST_BASE] = {
1727a771
TI
1183 .type = HDA_FIXUP_PINS,
1184 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1185 { 0x14, 0x01014010 }, /* line-out */
1186 { 0x15, 0x411111f0 }, /* N/A */
1187 { 0x16, 0x411111f0 }, /* N/A */
1188 { 0x17, 0x411111f0 }, /* N/A */
1189 { 0x18, 0x01a19c30 }, /* mic-in */
1190 { 0x19, 0x0121411f }, /* HP */
1191 { 0x1a, 0x01813031 }, /* line-in */
1192 { 0x1b, 0x02a19c40 }, /* front-mic */
1193 { 0x1c, 0x411111f0 }, /* N/A */
1194 { 0x1d, 0x411111f0 }, /* N/A */
1195 /* 0x1e is filled in below */
1196 { 0x1f, 0x411111f0 }, /* N/A */
1197 { }
1198 }
1199 },
1200 [ALC880_FIXUP_3ST] = {
1727a771
TI
1201 .type = HDA_FIXUP_PINS,
1202 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1203 { 0x1e, 0x411111f0 }, /* N/A */
1204 { }
1205 },
1206 .chained = true,
1207 .chain_id = ALC880_FIXUP_3ST_BASE,
1208 },
1209 [ALC880_FIXUP_3ST_DIG] = {
1727a771
TI
1210 .type = HDA_FIXUP_PINS,
1211 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1212 { 0x1e, 0x0144111e }, /* SPDIF */
1213 { }
1214 },
1215 .chained = true,
1216 .chain_id = ALC880_FIXUP_3ST_BASE,
1217 },
1218 [ALC880_FIXUP_5ST_BASE] = {
1727a771
TI
1219 .type = HDA_FIXUP_PINS,
1220 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1221 { 0x14, 0x01014010 }, /* front */
1222 { 0x15, 0x411111f0 }, /* N/A */
1223 { 0x16, 0x01011411 }, /* CLFE */
1224 { 0x17, 0x01016412 }, /* surr */
1225 { 0x18, 0x01a19c30 }, /* mic-in */
1226 { 0x19, 0x0121411f }, /* HP */
1227 { 0x1a, 0x01813031 }, /* line-in */
1228 { 0x1b, 0x02a19c40 }, /* front-mic */
1229 { 0x1c, 0x411111f0 }, /* N/A */
1230 { 0x1d, 0x411111f0 }, /* N/A */
1231 /* 0x1e is filled in below */
1232 { 0x1f, 0x411111f0 }, /* N/A */
1233 { }
1234 }
1235 },
1236 [ALC880_FIXUP_5ST] = {
1727a771
TI
1237 .type = HDA_FIXUP_PINS,
1238 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1239 { 0x1e, 0x411111f0 }, /* N/A */
1240 { }
1241 },
1242 .chained = true,
1243 .chain_id = ALC880_FIXUP_5ST_BASE,
1244 },
1245 [ALC880_FIXUP_5ST_DIG] = {
1727a771
TI
1246 .type = HDA_FIXUP_PINS,
1247 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1248 { 0x1e, 0x0144111e }, /* SPDIF */
1249 { }
1250 },
1251 .chained = true,
1252 .chain_id = ALC880_FIXUP_5ST_BASE,
1253 },
1254 [ALC880_FIXUP_6ST_BASE] = {
1727a771
TI
1255 .type = HDA_FIXUP_PINS,
1256 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1257 { 0x14, 0x01014010 }, /* front */
1258 { 0x15, 0x01016412 }, /* surr */
1259 { 0x16, 0x01011411 }, /* CLFE */
1260 { 0x17, 0x01012414 }, /* side */
1261 { 0x18, 0x01a19c30 }, /* mic-in */
1262 { 0x19, 0x02a19c40 }, /* front-mic */
1263 { 0x1a, 0x01813031 }, /* line-in */
1264 { 0x1b, 0x0121411f }, /* HP */
1265 { 0x1c, 0x411111f0 }, /* N/A */
1266 { 0x1d, 0x411111f0 }, /* N/A */
1267 /* 0x1e is filled in below */
1268 { 0x1f, 0x411111f0 }, /* N/A */
1269 { }
1270 }
1271 },
1272 [ALC880_FIXUP_6ST] = {
1727a771
TI
1273 .type = HDA_FIXUP_PINS,
1274 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1275 { 0x1e, 0x411111f0 }, /* N/A */
1276 { }
1277 },
1278 .chained = true,
1279 .chain_id = ALC880_FIXUP_6ST_BASE,
1280 },
1281 [ALC880_FIXUP_6ST_DIG] = {
1727a771
TI
1282 .type = HDA_FIXUP_PINS,
1283 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1284 { 0x1e, 0x0144111e }, /* SPDIF */
1285 { }
1286 },
1287 .chained = true,
1288 .chain_id = ALC880_FIXUP_6ST_BASE,
1289 },
5397145f
TI
1290 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1291 .type = HDA_FIXUP_PINS,
1292 .v.pins = (const struct hda_pintbl[]) {
1293 { 0x1b, 0x0121401f }, /* HP with jack detect */
1294 { }
1295 },
1296 .chained_before = true,
1297 .chain_id = ALC880_FIXUP_6ST_BASE,
1298 },
ee3b2969
TI
1299};
1300
1301static const struct snd_pci_quirk alc880_fixup_tbl[] = {
f02aab5d 1302 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
96e225f6 1303 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
29e3fdcc
TI
1304 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1305 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
27e917f8 1306 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
967b88c4 1307 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
ba533818 1308 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
817de92f 1309 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
7833c7e8 1310 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
f02aab5d 1311 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
ee3b2969 1312 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
5397145f 1313 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
ba533818 1314 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
cf5a2279 1315 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
ba533818 1316 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
cf5a2279 1317 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
dc6af52d
TI
1318 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1319 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1320 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
b9368f5c 1321 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
67b6ec31
TI
1322
1323 /* Below is the copied entries from alc880_quirks.c.
1324 * It's not quite sure whether BIOS sets the correct pin-config table
1325 * on these machines, thus they are kept to be compatible with
1326 * the old static quirks. Once when it's confirmed to work without
1327 * these overrides, it'd be better to remove.
1328 */
1329 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1330 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1331 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1332 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1333 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1334 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1335 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1336 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1337 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1338 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1339 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1340 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1341 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1342 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1343 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1344 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1345 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1346 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1347 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1348 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1349 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1350 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1351 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1352 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1353 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1354 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1355 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1356 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1357 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1358 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1359 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1360 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1361 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1362 /* default Intel */
1363 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1364 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1365 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1366 {}
1367};
1368
1727a771 1369static const struct hda_model_fixup alc880_fixup_models[] = {
67b6ec31
TI
1370 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1371 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1372 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1373 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1374 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1375 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
5397145f 1376 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
ee3b2969
TI
1377 {}
1378};
1379
1380
1d045db9
TI
1381/*
1382 * OK, here we have finally the patch for ALC880
1383 */
1d045db9 1384static int patch_alc880(struct hda_codec *codec)
60db6b53 1385{
1d045db9 1386 struct alc_spec *spec;
1d045db9 1387 int err;
f6a92248 1388
3de95173
TI
1389 err = alc_alloc_spec(codec, 0x0b);
1390 if (err < 0)
1391 return err;
64154835 1392
3de95173 1393 spec = codec->spec;
08c189f2 1394 spec->gen.need_dac_fix = 1;
7504b6cd 1395 spec->gen.beep_nid = 0x01;
f53281e6 1396
1727a771 1397 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
67b6ec31 1398 alc880_fixups);
1727a771 1399 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ee3b2969 1400
67b6ec31
TI
1401 /* automatic parse from the BIOS config */
1402 err = alc880_parse_auto_config(codec);
1403 if (err < 0)
1404 goto error;
fe3eb0a7 1405
7504b6cd 1406 if (!spec->gen.no_analog)
3e6179b8 1407 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f53281e6 1408
1d045db9 1409 codec->patch_ops = alc_patch_ops;
29adc4b9
DH
1410 codec->patch_ops.unsol_event = alc880_unsol_event;
1411
f53281e6 1412
1727a771 1413 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 1414
1d045db9 1415 return 0;
e16fb6d1
TI
1416
1417 error:
1418 alc_free(codec);
1419 return err;
226b1ec8
KY
1420}
1421
1d045db9 1422
60db6b53 1423/*
1d045db9 1424 * ALC260 support
60db6b53 1425 */
1d045db9 1426static int alc260_parse_auto_config(struct hda_codec *codec)
f6a92248 1427{
1d045db9 1428 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
3e6179b8
TI
1429 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1430 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
f6a92248
KY
1431}
1432
1d045db9
TI
1433/*
1434 * Pin config fixes
1435 */
1436enum {
ca8f0424
TI
1437 ALC260_FIXUP_HP_DC5750,
1438 ALC260_FIXUP_HP_PIN_0F,
1439 ALC260_FIXUP_COEF,
15317ab2 1440 ALC260_FIXUP_GPIO1,
20f7d928
TI
1441 ALC260_FIXUP_GPIO1_TOGGLE,
1442 ALC260_FIXUP_REPLACER,
0a1c4fa2 1443 ALC260_FIXUP_HP_B1900,
118cb4a4 1444 ALC260_FIXUP_KN1,
39aedee7 1445 ALC260_FIXUP_FSC_S7020,
5ebd3bbd 1446 ALC260_FIXUP_FSC_S7020_JWSE,
1d045db9
TI
1447};
1448
20f7d928
TI
1449static void alc260_gpio1_automute(struct hda_codec *codec)
1450{
1451 struct alc_spec *spec = codec->spec;
1452 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
08c189f2 1453 spec->gen.hp_jack_present);
20f7d928
TI
1454}
1455
1456static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1727a771 1457 const struct hda_fixup *fix, int action)
20f7d928
TI
1458{
1459 struct alc_spec *spec = codec->spec;
1727a771 1460 if (action == HDA_FIXUP_ACT_PROBE) {
20f7d928
TI
1461 /* although the machine has only one output pin, we need to
1462 * toggle GPIO1 according to the jack state
1463 */
08c189f2
TI
1464 spec->gen.automute_hook = alc260_gpio1_automute;
1465 spec->gen.detect_hp = 1;
1466 spec->gen.automute_speaker = 1;
1467 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1468 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
1469 snd_hda_gen_hp_automute);
c9ce6b26 1470 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
20f7d928
TI
1471 }
1472}
1473
118cb4a4 1474static void alc260_fixup_kn1(struct hda_codec *codec,
1727a771 1475 const struct hda_fixup *fix, int action)
118cb4a4
TI
1476{
1477 struct alc_spec *spec = codec->spec;
1727a771 1478 static const struct hda_pintbl pincfgs[] = {
118cb4a4
TI
1479 { 0x0f, 0x02214000 }, /* HP/speaker */
1480 { 0x12, 0x90a60160 }, /* int mic */
1481 { 0x13, 0x02a19000 }, /* ext mic */
1482 { 0x18, 0x01446000 }, /* SPDIF out */
1483 /* disable bogus I/O pins */
1484 { 0x10, 0x411111f0 },
1485 { 0x11, 0x411111f0 },
1486 { 0x14, 0x411111f0 },
1487 { 0x15, 0x411111f0 },
1488 { 0x16, 0x411111f0 },
1489 { 0x17, 0x411111f0 },
1490 { 0x19, 0x411111f0 },
1491 { }
1492 };
1493
1494 switch (action) {
1727a771
TI
1495 case HDA_FIXUP_ACT_PRE_PROBE:
1496 snd_hda_apply_pincfgs(codec, pincfgs);
118cb4a4 1497 break;
1727a771 1498 case HDA_FIXUP_ACT_PROBE:
118cb4a4
TI
1499 spec->init_amp = ALC_INIT_NONE;
1500 break;
1501 }
1502}
1503
39aedee7
TI
1504static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1505 const struct hda_fixup *fix, int action)
1506{
1507 struct alc_spec *spec = codec->spec;
5ebd3bbd
TI
1508 if (action == HDA_FIXUP_ACT_PROBE)
1509 spec->init_amp = ALC_INIT_NONE;
1510}
39aedee7 1511
5ebd3bbd
TI
1512static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1513 const struct hda_fixup *fix, int action)
1514{
1515 struct alc_spec *spec = codec->spec;
1516 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
f811c3cf 1517 spec->gen.add_jack_modes = 1;
5ebd3bbd 1518 spec->gen.hp_mic = 1;
e6e0ee50 1519 }
39aedee7
TI
1520}
1521
1727a771 1522static const struct hda_fixup alc260_fixups[] = {
ca8f0424 1523 [ALC260_FIXUP_HP_DC5750] = {
1727a771
TI
1524 .type = HDA_FIXUP_PINS,
1525 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1526 { 0x11, 0x90130110 }, /* speaker */
1527 { }
1528 }
1529 },
ca8f0424 1530 [ALC260_FIXUP_HP_PIN_0F] = {
1727a771
TI
1531 .type = HDA_FIXUP_PINS,
1532 .v.pins = (const struct hda_pintbl[]) {
ca8f0424
TI
1533 { 0x0f, 0x01214000 }, /* HP */
1534 { }
1535 }
1536 },
1537 [ALC260_FIXUP_COEF] = {
1727a771 1538 .type = HDA_FIXUP_VERBS,
ca8f0424
TI
1539 .v.verbs = (const struct hda_verb[]) {
1540 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1541 { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 },
1542 { }
1543 },
1544 .chained = true,
1545 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1546 },
15317ab2 1547 [ALC260_FIXUP_GPIO1] = {
1727a771 1548 .type = HDA_FIXUP_VERBS,
15317ab2
TI
1549 .v.verbs = alc_gpio1_init_verbs,
1550 },
20f7d928 1551 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1727a771 1552 .type = HDA_FIXUP_FUNC,
20f7d928
TI
1553 .v.func = alc260_fixup_gpio1_toggle,
1554 .chained = true,
1555 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1556 },
1557 [ALC260_FIXUP_REPLACER] = {
1727a771 1558 .type = HDA_FIXUP_VERBS,
20f7d928
TI
1559 .v.verbs = (const struct hda_verb[]) {
1560 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1561 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
1562 { }
1563 },
1564 .chained = true,
1565 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1566 },
0a1c4fa2 1567 [ALC260_FIXUP_HP_B1900] = {
1727a771 1568 .type = HDA_FIXUP_FUNC,
0a1c4fa2
TI
1569 .v.func = alc260_fixup_gpio1_toggle,
1570 .chained = true,
1571 .chain_id = ALC260_FIXUP_COEF,
118cb4a4
TI
1572 },
1573 [ALC260_FIXUP_KN1] = {
1727a771 1574 .type = HDA_FIXUP_FUNC,
118cb4a4
TI
1575 .v.func = alc260_fixup_kn1,
1576 },
39aedee7
TI
1577 [ALC260_FIXUP_FSC_S7020] = {
1578 .type = HDA_FIXUP_FUNC,
1579 .v.func = alc260_fixup_fsc_s7020,
1580 },
5ebd3bbd
TI
1581 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1582 .type = HDA_FIXUP_FUNC,
1583 .v.func = alc260_fixup_fsc_s7020_jwse,
1584 .chained = true,
1585 .chain_id = ALC260_FIXUP_FSC_S7020,
1586 },
1d045db9
TI
1587};
1588
1589static const struct snd_pci_quirk alc260_fixup_tbl[] = {
15317ab2 1590 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
ca8f0424 1591 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
15317ab2 1592 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
ca8f0424 1593 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
0a1c4fa2 1594 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
39aedee7 1595 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
b1f58085 1596 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
118cb4a4 1597 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
20f7d928 1598 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
ca8f0424 1599 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1d045db9
TI
1600 {}
1601};
1602
5ebd3bbd
TI
1603static const struct hda_model_fixup alc260_fixup_models[] = {
1604 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1605 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1606 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1607 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1608 {}
1609};
1610
1d045db9
TI
1611/*
1612 */
1d045db9 1613static int patch_alc260(struct hda_codec *codec)
977ddd6b 1614{
1d045db9 1615 struct alc_spec *spec;
c3c2c9e7 1616 int err;
1d045db9 1617
3de95173
TI
1618 err = alc_alloc_spec(codec, 0x07);
1619 if (err < 0)
1620 return err;
1d045db9 1621
3de95173 1622 spec = codec->spec;
ea46c3c8
TI
1623 /* as quite a few machines require HP amp for speaker outputs,
1624 * it's easier to enable it unconditionally; even if it's unneeded,
1625 * it's almost harmless.
1626 */
1627 spec->gen.prefer_hp_amp = 1;
7504b6cd 1628 spec->gen.beep_nid = 0x01;
1d045db9 1629
5ebd3bbd
TI
1630 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1631 alc260_fixups);
1727a771 1632 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
977ddd6b 1633
c3c2c9e7
TI
1634 /* automatic parse from the BIOS config */
1635 err = alc260_parse_auto_config(codec);
1636 if (err < 0)
1637 goto error;
977ddd6b 1638
7504b6cd 1639 if (!spec->gen.no_analog)
3e6179b8 1640 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
977ddd6b 1641
1d045db9 1642 codec->patch_ops = alc_patch_ops;
1d045db9 1643 spec->shutup = alc_eapd_shutup;
6981d184 1644
1727a771 1645 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 1646
1d045db9 1647 return 0;
e16fb6d1
TI
1648
1649 error:
1650 alc_free(codec);
1651 return err;
6981d184
TI
1652}
1653
1d045db9
TI
1654
1655/*
1656 * ALC882/883/885/888/889 support
1657 *
1658 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1659 * configuration. Each pin widget can choose any input DACs and a mixer.
1660 * Each ADC is connected from a mixer of all inputs. This makes possible
1661 * 6-channel independent captures.
1662 *
1663 * In addition, an independent DAC for the multi-playback (not used in this
1664 * driver yet).
1665 */
1d045db9
TI
1666
1667/*
1668 * Pin config fixes
1669 */
ff818c24 1670enum {
5c0ebfbe
TI
1671 ALC882_FIXUP_ABIT_AW9D_MAX,
1672 ALC882_FIXUP_LENOVO_Y530,
1673 ALC882_FIXUP_PB_M5210,
1674 ALC882_FIXUP_ACER_ASPIRE_7736,
1675 ALC882_FIXUP_ASUS_W90V,
8f239214 1676 ALC889_FIXUP_CD,
5c0ebfbe 1677 ALC889_FIXUP_VAIO_TT,
0e7cc2e7 1678 ALC888_FIXUP_EEE1601,
177943a3 1679 ALC882_FIXUP_EAPD,
7a6069bf 1680 ALC883_FIXUP_EAPD,
8812c4f9 1681 ALC883_FIXUP_ACER_EAPD,
1a97b7f2
TI
1682 ALC882_FIXUP_GPIO1,
1683 ALC882_FIXUP_GPIO2,
eb844d51 1684 ALC882_FIXUP_GPIO3,
68ef0561
TI
1685 ALC889_FIXUP_COEF,
1686 ALC882_FIXUP_ASUS_W2JC,
c3e837bb
TI
1687 ALC882_FIXUP_ACER_ASPIRE_4930G,
1688 ALC882_FIXUP_ACER_ASPIRE_8930G,
1689 ALC882_FIXUP_ASPIRE_8930G_VERBS,
5671087f 1690 ALC885_FIXUP_MACPRO_GPIO,
02a237b2 1691 ALC889_FIXUP_DAC_ROUTE,
1a97b7f2
TI
1692 ALC889_FIXUP_MBP_VREF,
1693 ALC889_FIXUP_IMAC91_VREF,
6e72aa5f 1694 ALC882_FIXUP_INV_DMIC,
e427c237 1695 ALC882_FIXUP_NO_PRIMARY_HP,
ff818c24
TI
1696};
1697
68ef0561 1698static void alc889_fixup_coef(struct hda_codec *codec,
1727a771 1699 const struct hda_fixup *fix, int action)
68ef0561 1700{
1727a771 1701 if (action != HDA_FIXUP_ACT_INIT)
68ef0561
TI
1702 return;
1703 alc889_coef_init(codec);
1704}
1705
5671087f
TI
1706/* toggle speaker-output according to the hp-jack state */
1707static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1708{
1709 unsigned int gpiostate, gpiomask, gpiodir;
1710
1711 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1712 AC_VERB_GET_GPIO_DATA, 0);
1713
1714 if (!muted)
1715 gpiostate |= (1 << pin);
1716 else
1717 gpiostate &= ~(1 << pin);
1718
1719 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1720 AC_VERB_GET_GPIO_MASK, 0);
1721 gpiomask |= (1 << pin);
1722
1723 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1724 AC_VERB_GET_GPIO_DIRECTION, 0);
1725 gpiodir |= (1 << pin);
1726
1727
1728 snd_hda_codec_write(codec, codec->afg, 0,
1729 AC_VERB_SET_GPIO_MASK, gpiomask);
1730 snd_hda_codec_write(codec, codec->afg, 0,
1731 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1732
1733 msleep(1);
1734
1735 snd_hda_codec_write(codec, codec->afg, 0,
1736 AC_VERB_SET_GPIO_DATA, gpiostate);
1737}
1738
1739/* set up GPIO at initialization */
1740static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1727a771 1741 const struct hda_fixup *fix, int action)
5671087f 1742{
1727a771 1743 if (action != HDA_FIXUP_ACT_INIT)
5671087f
TI
1744 return;
1745 alc882_gpio_mute(codec, 0, 0);
1746 alc882_gpio_mute(codec, 1, 0);
1747}
1748
02a237b2
TI
1749/* Fix the connection of some pins for ALC889:
1750 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1751 * work correctly (bko#42740)
1752 */
1753static void alc889_fixup_dac_route(struct hda_codec *codec,
1727a771 1754 const struct hda_fixup *fix, int action)
02a237b2 1755{
1727a771 1756 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
ef8d60fb 1757 /* fake the connections during parsing the tree */
02a237b2
TI
1758 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1759 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1760 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1761 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1762 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1763 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1727a771 1764 } else if (action == HDA_FIXUP_ACT_PROBE) {
ef8d60fb
TI
1765 /* restore the connections */
1766 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1767 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1768 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1769 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1770 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
02a237b2
TI
1771 }
1772}
1773
1a97b7f2
TI
1774/* Set VREF on HP pin */
1775static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1727a771 1776 const struct hda_fixup *fix, int action)
1a97b7f2
TI
1777{
1778 struct alc_spec *spec = codec->spec;
1779 static hda_nid_t nids[2] = { 0x14, 0x15 };
1780 int i;
1781
1727a771 1782 if (action != HDA_FIXUP_ACT_INIT)
1a97b7f2
TI
1783 return;
1784 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1785 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1786 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1787 continue;
d3f02d60 1788 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1a97b7f2 1789 val |= AC_PINCTL_VREF_80;
cdd03ced 1790 snd_hda_set_pin_ctl(codec, nids[i], val);
08c189f2 1791 spec->gen.keep_vref_in_automute = 1;
1a97b7f2
TI
1792 break;
1793 }
1794}
1795
1796/* Set VREF on speaker pins on imac91 */
1797static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1727a771 1798 const struct hda_fixup *fix, int action)
1a97b7f2
TI
1799{
1800 struct alc_spec *spec = codec->spec;
1801 static hda_nid_t nids[2] = { 0x18, 0x1a };
1802 int i;
1803
1727a771 1804 if (action != HDA_FIXUP_ACT_INIT)
1a97b7f2
TI
1805 return;
1806 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1807 unsigned int val;
d3f02d60 1808 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1a97b7f2 1809 val |= AC_PINCTL_VREF_50;
cdd03ced 1810 snd_hda_set_pin_ctl(codec, nids[i], val);
1a97b7f2 1811 }
08c189f2 1812 spec->gen.keep_vref_in_automute = 1;
1a97b7f2
TI
1813}
1814
e427c237 1815/* Don't take HP output as primary
d9111496
FLVC
1816 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1817 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
e427c237
TI
1818 */
1819static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1727a771 1820 const struct hda_fixup *fix, int action)
e427c237
TI
1821{
1822 struct alc_spec *spec = codec->spec;
1727a771 1823 if (action == HDA_FIXUP_ACT_PRE_PROBE)
08c189f2 1824 spec->gen.no_primary_hp = 1;
e427c237
TI
1825}
1826
1727a771 1827static const struct hda_fixup alc882_fixups[] = {
5c0ebfbe 1828 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
1727a771
TI
1829 .type = HDA_FIXUP_PINS,
1830 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1831 { 0x15, 0x01080104 }, /* side */
1832 { 0x16, 0x01011012 }, /* rear */
1833 { 0x17, 0x01016011 }, /* clfe */
2785591a 1834 { }
145a902b
DH
1835 }
1836 },
5c0ebfbe 1837 [ALC882_FIXUP_LENOVO_Y530] = {
1727a771
TI
1838 .type = HDA_FIXUP_PINS,
1839 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1840 { 0x15, 0x99130112 }, /* rear int speakers */
1841 { 0x16, 0x99130111 }, /* subwoofer */
ac612407
DH
1842 { }
1843 }
1844 },
5c0ebfbe 1845 [ALC882_FIXUP_PB_M5210] = {
fd108215
TI
1846 .type = HDA_FIXUP_PINCTLS,
1847 .v.pins = (const struct hda_pintbl[]) {
1848 { 0x19, PIN_VREF50 },
357f915e
KY
1849 {}
1850 }
1851 },
5c0ebfbe 1852 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
1727a771 1853 .type = HDA_FIXUP_FUNC,
23d30f28 1854 .v.func = alc_fixup_sku_ignore,
6981d184 1855 },
5c0ebfbe 1856 [ALC882_FIXUP_ASUS_W90V] = {
1727a771
TI
1857 .type = HDA_FIXUP_PINS,
1858 .v.pins = (const struct hda_pintbl[]) {
5cdf745e
TI
1859 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
1860 { }
1861 }
1862 },
8f239214 1863 [ALC889_FIXUP_CD] = {
1727a771
TI
1864 .type = HDA_FIXUP_PINS,
1865 .v.pins = (const struct hda_pintbl[]) {
8f239214
MB
1866 { 0x1c, 0x993301f0 }, /* CD */
1867 { }
1868 }
1869 },
5c0ebfbe 1870 [ALC889_FIXUP_VAIO_TT] = {
1727a771
TI
1871 .type = HDA_FIXUP_PINS,
1872 .v.pins = (const struct hda_pintbl[]) {
5c0ebfbe
TI
1873 { 0x17, 0x90170111 }, /* hidden surround speaker */
1874 { }
1875 }
1876 },
0e7cc2e7 1877 [ALC888_FIXUP_EEE1601] = {
1727a771 1878 .type = HDA_FIXUP_VERBS,
0e7cc2e7
TI
1879 .v.verbs = (const struct hda_verb[]) {
1880 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1881 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
1882 { }
1883 }
177943a3
TI
1884 },
1885 [ALC882_FIXUP_EAPD] = {
1727a771 1886 .type = HDA_FIXUP_VERBS,
177943a3
TI
1887 .v.verbs = (const struct hda_verb[]) {
1888 /* change to EAPD mode */
1889 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1890 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1891 { }
1892 }
1893 },
7a6069bf 1894 [ALC883_FIXUP_EAPD] = {
1727a771 1895 .type = HDA_FIXUP_VERBS,
7a6069bf
TI
1896 .v.verbs = (const struct hda_verb[]) {
1897 /* change to EAPD mode */
1898 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1899 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1900 { }
1901 }
1902 },
8812c4f9 1903 [ALC883_FIXUP_ACER_EAPD] = {
1727a771 1904 .type = HDA_FIXUP_VERBS,
8812c4f9
TI
1905 .v.verbs = (const struct hda_verb[]) {
1906 /* eanable EAPD on Acer laptops */
1907 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1908 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
1909 { }
1910 }
1911 },
1a97b7f2 1912 [ALC882_FIXUP_GPIO1] = {
1727a771 1913 .type = HDA_FIXUP_VERBS,
1a97b7f2
TI
1914 .v.verbs = alc_gpio1_init_verbs,
1915 },
1916 [ALC882_FIXUP_GPIO2] = {
1727a771 1917 .type = HDA_FIXUP_VERBS,
1a97b7f2
TI
1918 .v.verbs = alc_gpio2_init_verbs,
1919 },
eb844d51 1920 [ALC882_FIXUP_GPIO3] = {
1727a771 1921 .type = HDA_FIXUP_VERBS,
eb844d51
TI
1922 .v.verbs = alc_gpio3_init_verbs,
1923 },
68ef0561 1924 [ALC882_FIXUP_ASUS_W2JC] = {
1727a771 1925 .type = HDA_FIXUP_VERBS,
68ef0561
TI
1926 .v.verbs = alc_gpio1_init_verbs,
1927 .chained = true,
1928 .chain_id = ALC882_FIXUP_EAPD,
1929 },
1930 [ALC889_FIXUP_COEF] = {
1727a771 1931 .type = HDA_FIXUP_FUNC,
68ef0561
TI
1932 .v.func = alc889_fixup_coef,
1933 },
c3e837bb 1934 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
1727a771
TI
1935 .type = HDA_FIXUP_PINS,
1936 .v.pins = (const struct hda_pintbl[]) {
c3e837bb
TI
1937 { 0x16, 0x99130111 }, /* CLFE speaker */
1938 { 0x17, 0x99130112 }, /* surround speaker */
1939 { }
038d4fef
TI
1940 },
1941 .chained = true,
1942 .chain_id = ALC882_FIXUP_GPIO1,
c3e837bb
TI
1943 },
1944 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
1727a771
TI
1945 .type = HDA_FIXUP_PINS,
1946 .v.pins = (const struct hda_pintbl[]) {
c3e837bb
TI
1947 { 0x16, 0x99130111 }, /* CLFE speaker */
1948 { 0x1b, 0x99130112 }, /* surround speaker */
1949 { }
1950 },
1951 .chained = true,
1952 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
1953 },
1954 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
1955 /* additional init verbs for Acer Aspire 8930G */
1727a771 1956 .type = HDA_FIXUP_VERBS,
c3e837bb
TI
1957 .v.verbs = (const struct hda_verb[]) {
1958 /* Enable all DACs */
1959 /* DAC DISABLE/MUTE 1? */
1960 /* setting bits 1-5 disables DAC nids 0x02-0x06
1961 * apparently. Init=0x38 */
1962 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
1963 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
1964 /* DAC DISABLE/MUTE 2? */
1965 /* some bit here disables the other DACs.
1966 * Init=0x4900 */
1967 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
1968 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
1969 /* DMIC fix
1970 * This laptop has a stereo digital microphone.
1971 * The mics are only 1cm apart which makes the stereo
1972 * useless. However, either the mic or the ALC889
1973 * makes the signal become a difference/sum signal
1974 * instead of standard stereo, which is annoying.
1975 * So instead we flip this bit which makes the
1976 * codec replicate the sum signal to both channels,
1977 * turning it into a normal mono mic.
1978 */
1979 /* DMIC_CONTROL? Init value = 0x0001 */
1980 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1981 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
1982 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1983 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
1984 { }
038d4fef
TI
1985 },
1986 .chained = true,
1987 .chain_id = ALC882_FIXUP_GPIO1,
c3e837bb 1988 },
5671087f 1989 [ALC885_FIXUP_MACPRO_GPIO] = {
1727a771 1990 .type = HDA_FIXUP_FUNC,
5671087f
TI
1991 .v.func = alc885_fixup_macpro_gpio,
1992 },
02a237b2 1993 [ALC889_FIXUP_DAC_ROUTE] = {
1727a771 1994 .type = HDA_FIXUP_FUNC,
02a237b2
TI
1995 .v.func = alc889_fixup_dac_route,
1996 },
1a97b7f2 1997 [ALC889_FIXUP_MBP_VREF] = {
1727a771 1998 .type = HDA_FIXUP_FUNC,
1a97b7f2
TI
1999 .v.func = alc889_fixup_mbp_vref,
2000 .chained = true,
2001 .chain_id = ALC882_FIXUP_GPIO1,
2002 },
2003 [ALC889_FIXUP_IMAC91_VREF] = {
1727a771 2004 .type = HDA_FIXUP_FUNC,
1a97b7f2
TI
2005 .v.func = alc889_fixup_imac91_vref,
2006 .chained = true,
2007 .chain_id = ALC882_FIXUP_GPIO1,
2008 },
6e72aa5f 2009 [ALC882_FIXUP_INV_DMIC] = {
1727a771 2010 .type = HDA_FIXUP_FUNC,
6e72aa5f
TI
2011 .v.func = alc_fixup_inv_dmic_0x12,
2012 },
e427c237 2013 [ALC882_FIXUP_NO_PRIMARY_HP] = {
1727a771 2014 .type = HDA_FIXUP_FUNC,
e427c237
TI
2015 .v.func = alc882_fixup_no_primary_hp,
2016 },
ff818c24
TI
2017};
2018
1d045db9 2019static const struct snd_pci_quirk alc882_fixup_tbl[] = {
8812c4f9
TI
2020 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2021 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2022 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2023 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2024 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2025 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
c3e837bb
TI
2026 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2027 ALC882_FIXUP_ACER_ASPIRE_4930G),
2028 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2029 ALC882_FIXUP_ACER_ASPIRE_4930G),
2030 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2031 ALC882_FIXUP_ACER_ASPIRE_8930G),
2032 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2033 ALC882_FIXUP_ACER_ASPIRE_8930G),
2034 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2035 ALC882_FIXUP_ACER_ASPIRE_4930G),
2036 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2037 ALC882_FIXUP_ACER_ASPIRE_4930G),
2038 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2039 ALC882_FIXUP_ACER_ASPIRE_4930G),
5c0ebfbe 2040 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
f5c53d89
TI
2041 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2042 ALC882_FIXUP_ACER_ASPIRE_4930G),
02a237b2 2043 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
fe97da1f 2044 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
ac9b1cdd 2045 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
177943a3 2046 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
5c0ebfbe 2047 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
68ef0561 2048 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
0e7cc2e7 2049 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
ac9b1cdd 2050 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
e427c237 2051 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
12e31a78 2052 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
5671087f
TI
2053
2054 /* All Apple entries are in codec SSIDs */
1a97b7f2
TI
2055 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2056 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2057 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5671087f
TI
2058 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
2059 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2060 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
1a97b7f2
TI
2061 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2062 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
5671087f 2063 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
1a97b7f2
TI
2064 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF),
2065 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF),
2066 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2067 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5671087f 2068 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
1a97b7f2
TI
2069 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2070 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2071 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
29ebe402 2072 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
05193639 2073 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
1a97b7f2
TI
2074 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2075 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2076 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
5671087f 2077
7a6069bf 2078 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
bca40138 2079 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
eb844d51 2080 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
8f239214 2081 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD),
5c0ebfbe 2082 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
7a6069bf
TI
2083 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2084 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
ac9b1cdd 2085 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
68ef0561 2086 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
ff818c24
TI
2087 {}
2088};
2089
1727a771 2090static const struct hda_model_fixup alc882_fixup_models[] = {
912093bc
TI
2091 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2092 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2093 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
6e72aa5f 2094 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
e427c237 2095 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
912093bc
TI
2096 {}
2097};
2098
f6a92248 2099/*
1d045db9 2100 * BIOS auto configuration
f6a92248 2101 */
1d045db9
TI
2102/* almost identical with ALC880 parser... */
2103static int alc882_parse_auto_config(struct hda_codec *codec)
2104{
1d045db9 2105 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2106 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2107 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
1d045db9 2108}
b896b4eb 2109
1d045db9
TI
2110/*
2111 */
1d045db9 2112static int patch_alc882(struct hda_codec *codec)
f6a92248
KY
2113{
2114 struct alc_spec *spec;
1a97b7f2 2115 int err;
f6a92248 2116
3de95173
TI
2117 err = alc_alloc_spec(codec, 0x0b);
2118 if (err < 0)
2119 return err;
f6a92248 2120
3de95173 2121 spec = codec->spec;
1f0f4b80 2122
1d045db9
TI
2123 switch (codec->vendor_id) {
2124 case 0x10ec0882:
2125 case 0x10ec0885:
2126 break;
2127 default:
2128 /* ALC883 and variants */
2129 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2130 break;
c793bec5 2131 }
977ddd6b 2132
1727a771 2133 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
912093bc 2134 alc882_fixups);
1727a771 2135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ff818c24 2136
1d045db9
TI
2137 alc_auto_parse_customize_define(codec);
2138
7504b6cd
TI
2139 if (has_cdefine_beep(codec))
2140 spec->gen.beep_nid = 0x01;
2141
1a97b7f2
TI
2142 /* automatic parse from the BIOS config */
2143 err = alc882_parse_auto_config(codec);
2144 if (err < 0)
2145 goto error;
f6a92248 2146
7504b6cd 2147 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2148 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f6a92248
KY
2149
2150 codec->patch_ops = alc_patch_ops;
bf1b0225 2151
1727a771 2152 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2153
f6a92248 2154 return 0;
e16fb6d1
TI
2155
2156 error:
2157 alc_free(codec);
2158 return err;
f6a92248
KY
2159}
2160
df694daa 2161
df694daa 2162/*
1d045db9 2163 * ALC262 support
df694daa 2164 */
1d045db9 2165static int alc262_parse_auto_config(struct hda_codec *codec)
df694daa 2166{
1d045db9 2167 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2168 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2169 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
df694daa
KY
2170}
2171
df694daa 2172/*
1d045db9 2173 * Pin config fixes
df694daa 2174 */
cfc9b06f 2175enum {
ea4e7af1 2176 ALC262_FIXUP_FSC_H270,
7513e6da 2177 ALC262_FIXUP_FSC_S7110,
ea4e7af1
TI
2178 ALC262_FIXUP_HP_Z200,
2179 ALC262_FIXUP_TYAN,
c470150c 2180 ALC262_FIXUP_LENOVO_3000,
b42590b8
TI
2181 ALC262_FIXUP_BENQ,
2182 ALC262_FIXUP_BENQ_T31,
6e72aa5f 2183 ALC262_FIXUP_INV_DMIC,
cfc9b06f
TI
2184};
2185
1727a771 2186static const struct hda_fixup alc262_fixups[] = {
ea4e7af1 2187 [ALC262_FIXUP_FSC_H270] = {
1727a771
TI
2188 .type = HDA_FIXUP_PINS,
2189 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2190 { 0x14, 0x99130110 }, /* speaker */
2191 { 0x15, 0x0221142f }, /* front HP */
2192 { 0x1b, 0x0121141f }, /* rear HP */
2193 { }
2194 }
2195 },
7513e6da
TI
2196 [ALC262_FIXUP_FSC_S7110] = {
2197 .type = HDA_FIXUP_PINS,
2198 .v.pins = (const struct hda_pintbl[]) {
2199 { 0x15, 0x90170110 }, /* speaker */
2200 { }
2201 },
2202 .chained = true,
2203 .chain_id = ALC262_FIXUP_BENQ,
2204 },
ea4e7af1 2205 [ALC262_FIXUP_HP_Z200] = {
1727a771
TI
2206 .type = HDA_FIXUP_PINS,
2207 .v.pins = (const struct hda_pintbl[]) {
1d045db9 2208 { 0x16, 0x99130120 }, /* internal speaker */
73413b12
TI
2209 { }
2210 }
cfc9b06f 2211 },
ea4e7af1 2212 [ALC262_FIXUP_TYAN] = {
1727a771
TI
2213 .type = HDA_FIXUP_PINS,
2214 .v.pins = (const struct hda_pintbl[]) {
ea4e7af1
TI
2215 { 0x14, 0x1993e1f0 }, /* int AUX */
2216 { }
2217 }
2218 },
c470150c 2219 [ALC262_FIXUP_LENOVO_3000] = {
fd108215
TI
2220 .type = HDA_FIXUP_PINCTLS,
2221 .v.pins = (const struct hda_pintbl[]) {
2222 { 0x19, PIN_VREF50 },
b42590b8
TI
2223 {}
2224 },
2225 .chained = true,
2226 .chain_id = ALC262_FIXUP_BENQ,
2227 },
2228 [ALC262_FIXUP_BENQ] = {
1727a771 2229 .type = HDA_FIXUP_VERBS,
b42590b8 2230 .v.verbs = (const struct hda_verb[]) {
c470150c
TI
2231 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2232 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2233 {}
2234 }
2235 },
b42590b8 2236 [ALC262_FIXUP_BENQ_T31] = {
1727a771 2237 .type = HDA_FIXUP_VERBS,
b42590b8
TI
2238 .v.verbs = (const struct hda_verb[]) {
2239 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2240 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2241 {}
2242 }
2243 },
6e72aa5f 2244 [ALC262_FIXUP_INV_DMIC] = {
1727a771 2245 .type = HDA_FIXUP_FUNC,
6e72aa5f
TI
2246 .v.func = alc_fixup_inv_dmic_0x12,
2247 },
cfc9b06f
TI
2248};
2249
1d045db9 2250static const struct snd_pci_quirk alc262_fixup_tbl[] = {
ea4e7af1 2251 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
7513e6da 2252 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
3dcd3be3 2253 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
ea4e7af1
TI
2254 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2255 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
c470150c 2256 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
b42590b8
TI
2257 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2258 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
cfc9b06f
TI
2259 {}
2260};
df694daa 2261
1727a771 2262static const struct hda_model_fixup alc262_fixup_models[] = {
6e72aa5f
TI
2263 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2264 {}
2265};
1d045db9 2266
1d045db9
TI
2267/*
2268 */
1d045db9 2269static int patch_alc262(struct hda_codec *codec)
df694daa
KY
2270{
2271 struct alc_spec *spec;
df694daa
KY
2272 int err;
2273
3de95173
TI
2274 err = alc_alloc_spec(codec, 0x0b);
2275 if (err < 0)
2276 return err;
df694daa 2277
3de95173 2278 spec = codec->spec;
08c189f2 2279 spec->gen.shared_mic_vref_pin = 0x18;
1d045db9
TI
2280
2281#if 0
2282 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2283 * under-run
2284 */
2285 {
2286 int tmp;
2287 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2288 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
2289 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2290 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
2291 }
2292#endif
1d045db9
TI
2293 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2294
1727a771 2295 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
6e72aa5f 2296 alc262_fixups);
1727a771 2297 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9c7f852e 2298
af741c15
TI
2299 alc_auto_parse_customize_define(codec);
2300
7504b6cd
TI
2301 if (has_cdefine_beep(codec))
2302 spec->gen.beep_nid = 0x01;
2303
42399f7a
TI
2304 /* automatic parse from the BIOS config */
2305 err = alc262_parse_auto_config(codec);
2306 if (err < 0)
2307 goto error;
df694daa 2308
7504b6cd 2309 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2310 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2134ea4f 2311
df694daa 2312 codec->patch_ops = alc_patch_ops;
1d045db9
TI
2313 spec->shutup = alc_eapd_shutup;
2314
1727a771 2315 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2316
1da177e4 2317 return 0;
e16fb6d1
TI
2318
2319 error:
2320 alc_free(codec);
2321 return err;
1da177e4
LT
2322}
2323
f32610ed 2324/*
1d045db9 2325 * ALC268
f32610ed 2326 */
1d045db9
TI
2327/* bind Beep switches of both NID 0x0f and 0x10 */
2328static const struct hda_bind_ctls alc268_bind_beep_sw = {
2329 .ops = &snd_hda_bind_sw,
2330 .values = {
2331 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2332 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2333 0
2334 },
f32610ed
JS
2335};
2336
1d045db9
TI
2337static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2338 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2339 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2340 { }
f32610ed
JS
2341};
2342
1d045db9
TI
2343/* set PCBEEP vol = 0, mute connections */
2344static const struct hda_verb alc268_beep_init_verbs[] = {
2345 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2347 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2348 { }
f32610ed
JS
2349};
2350
6e72aa5f
TI
2351enum {
2352 ALC268_FIXUP_INV_DMIC,
cb766404 2353 ALC268_FIXUP_HP_EAPD,
6e72aa5f
TI
2354};
2355
1727a771 2356static const struct hda_fixup alc268_fixups[] = {
6e72aa5f 2357 [ALC268_FIXUP_INV_DMIC] = {
1727a771 2358 .type = HDA_FIXUP_FUNC,
6e72aa5f
TI
2359 .v.func = alc_fixup_inv_dmic_0x12,
2360 },
cb766404 2361 [ALC268_FIXUP_HP_EAPD] = {
1727a771 2362 .type = HDA_FIXUP_VERBS,
cb766404
TI
2363 .v.verbs = (const struct hda_verb[]) {
2364 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2365 {}
2366 }
2367 },
6e72aa5f
TI
2368};
2369
1727a771 2370static const struct hda_model_fixup alc268_fixup_models[] = {
6e72aa5f 2371 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
cb766404
TI
2372 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2373 {}
2374};
2375
2376static const struct snd_pci_quirk alc268_fixup_tbl[] = {
fcd8f3b1 2377 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
cb766404
TI
2378 /* below is codec SSID since multiple Toshiba laptops have the
2379 * same PCI SSID 1179:ff00
2380 */
2381 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
6e72aa5f
TI
2382 {}
2383};
2384
f32610ed
JS
2385/*
2386 * BIOS auto configuration
2387 */
1d045db9 2388static int alc268_parse_auto_config(struct hda_codec *codec)
f32610ed 2389{
3e6179b8 2390 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7504b6cd 2391 return alc_parse_auto_config(codec, NULL, alc268_ssids);
f32610ed
JS
2392}
2393
1d045db9
TI
2394/*
2395 */
1d045db9 2396static int patch_alc268(struct hda_codec *codec)
f32610ed
JS
2397{
2398 struct alc_spec *spec;
7504b6cd 2399 int err;
f32610ed 2400
1d045db9 2401 /* ALC268 has no aa-loopback mixer */
3de95173
TI
2402 err = alc_alloc_spec(codec, 0);
2403 if (err < 0)
2404 return err;
2405
2406 spec = codec->spec;
7504b6cd 2407 spec->gen.beep_nid = 0x01;
1f0f4b80 2408
1727a771
TI
2409 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2410 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6e72aa5f 2411
6ebb8053
TI
2412 /* automatic parse from the BIOS config */
2413 err = alc268_parse_auto_config(codec);
e16fb6d1
TI
2414 if (err < 0)
2415 goto error;
f32610ed 2416
7504b6cd
TI
2417 if (err > 0 && !spec->gen.no_analog &&
2418 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2419 add_mixer(spec, alc268_beep_mixer);
2420 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
1d045db9
TI
2421 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2422 /* override the amp caps for beep generator */
2423 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2424 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2425 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2426 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2427 (0 << AC_AMPCAP_MUTE_SHIFT));
2f893286
KY
2428 }
2429
f32610ed 2430 codec->patch_ops = alc_patch_ops;
1c716153 2431 spec->shutup = alc_eapd_shutup;
1d045db9 2432
1727a771 2433 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6e72aa5f 2434
f32610ed 2435 return 0;
e16fb6d1
TI
2436
2437 error:
2438 alc_free(codec);
2439 return err;
f32610ed
JS
2440}
2441
bc9f98a9 2442/*
1d045db9 2443 * ALC269
bc9f98a9 2444 */
08c189f2
TI
2445
2446static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2447 struct hda_codec *codec,
2448 struct snd_pcm_substream *substream)
2449{
2450 struct hda_gen_spec *spec = codec->spec;
2451 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2452 hinfo);
2453}
2454
2455static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2456 struct hda_codec *codec,
2457 unsigned int stream_tag,
2458 unsigned int format,
2459 struct snd_pcm_substream *substream)
2460{
2461 struct hda_gen_spec *spec = codec->spec;
2462 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2463 stream_tag, format, substream);
2464}
2465
2466static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2467 struct hda_codec *codec,
2468 struct snd_pcm_substream *substream)
2469{
2470 struct hda_gen_spec *spec = codec->spec;
2471 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2472}
2473
1d045db9
TI
2474static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2475 .substreams = 1,
2476 .channels_min = 2,
2477 .channels_max = 8,
2478 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2479 /* NID is set in alc_build_pcms */
2480 .ops = {
08c189f2
TI
2481 .open = playback_pcm_open,
2482 .prepare = playback_pcm_prepare,
2483 .cleanup = playback_pcm_cleanup
bc9f98a9
KY
2484 },
2485};
2486
1d045db9
TI
2487static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2488 .substreams = 1,
2489 .channels_min = 2,
2490 .channels_max = 2,
2491 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2492 /* NID is set in alc_build_pcms */
bc9f98a9 2493};
291702f0 2494
1d045db9
TI
2495/* different alc269-variants */
2496enum {
2497 ALC269_TYPE_ALC269VA,
2498 ALC269_TYPE_ALC269VB,
2499 ALC269_TYPE_ALC269VC,
adcc70b2 2500 ALC269_TYPE_ALC269VD,
065380f0
KY
2501 ALC269_TYPE_ALC280,
2502 ALC269_TYPE_ALC282,
2503 ALC269_TYPE_ALC284,
bc9f98a9
KY
2504};
2505
2506/*
1d045db9 2507 * BIOS auto configuration
bc9f98a9 2508 */
1d045db9
TI
2509static int alc269_parse_auto_config(struct hda_codec *codec)
2510{
1d045db9 2511 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2512 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2513 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2514 struct alc_spec *spec = codec->spec;
adcc70b2
KY
2515 const hda_nid_t *ssids;
2516
2517 switch (spec->codec_variant) {
2518 case ALC269_TYPE_ALC269VA:
2519 case ALC269_TYPE_ALC269VC:
065380f0
KY
2520 case ALC269_TYPE_ALC280:
2521 case ALC269_TYPE_ALC284:
adcc70b2
KY
2522 ssids = alc269va_ssids;
2523 break;
2524 case ALC269_TYPE_ALC269VB:
2525 case ALC269_TYPE_ALC269VD:
065380f0 2526 case ALC269_TYPE_ALC282:
adcc70b2
KY
2527 ssids = alc269_ssids;
2528 break;
2529 default:
2530 ssids = alc269_ssids;
2531 break;
2532 }
bc9f98a9 2533
3e6179b8 2534 return alc_parse_auto_config(codec, alc269_ignore, ssids);
1d045db9 2535}
bc9f98a9 2536
1387e2d1 2537static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
1d045db9
TI
2538{
2539 int val = alc_read_coef_idx(codec, 0x04);
2540 if (power_up)
2541 val |= 1 << 11;
2542 else
2543 val &= ~(1 << 11);
2544 alc_write_coef_idx(codec, 0x04, val);
2545}
291702f0 2546
1d045db9
TI
2547static void alc269_shutup(struct hda_codec *codec)
2548{
adcc70b2
KY
2549 struct alc_spec *spec = codec->spec;
2550
2551 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
2552 return;
2553
1387e2d1
KY
2554 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2555 alc269vb_toggle_power_output(codec, 0);
2556 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2557 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
2558 msleep(150);
2559 }
2560}
291702f0 2561
2a43952a 2562#ifdef CONFIG_PM
1d045db9
TI
2563static int alc269_resume(struct hda_codec *codec)
2564{
adcc70b2
KY
2565 struct alc_spec *spec = codec->spec;
2566
1387e2d1
KY
2567 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2568 alc269vb_toggle_power_output(codec, 0);
2569 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 2570 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
2571 msleep(150);
2572 }
8c427226 2573
1d045db9 2574 codec->patch_ops.init(codec);
f1d4e28b 2575
1387e2d1
KY
2576 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2577 alc269vb_toggle_power_output(codec, 1);
2578 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 2579 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
2580 msleep(200);
2581 }
f1d4e28b 2582
1d045db9
TI
2583 snd_hda_codec_resume_amp(codec);
2584 snd_hda_codec_resume_cache(codec);
2585 hda_call_check_power_status(codec, 0x01);
2586 return 0;
2587}
2a43952a 2588#endif /* CONFIG_PM */
f1d4e28b 2589
108cc108 2590static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
1727a771 2591 const struct hda_fixup *fix, int action)
108cc108
DH
2592{
2593 struct alc_spec *spec = codec->spec;
2594
1727a771 2595 if (action == HDA_FIXUP_ACT_PRE_PROBE)
108cc108
DH
2596 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
2597}
2598
1d045db9 2599static void alc269_fixup_hweq(struct hda_codec *codec,
1727a771 2600 const struct hda_fixup *fix, int action)
1d045db9
TI
2601{
2602 int coef;
f1d4e28b 2603
1727a771 2604 if (action != HDA_FIXUP_ACT_INIT)
1d045db9
TI
2605 return;
2606 coef = alc_read_coef_idx(codec, 0x1e);
2607 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
2608}
f1d4e28b 2609
1d045db9 2610static void alc271_fixup_dmic(struct hda_codec *codec,
1727a771 2611 const struct hda_fixup *fix, int action)
1d045db9
TI
2612{
2613 static const struct hda_verb verbs[] = {
2614 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
2615 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
2616 {}
2617 };
2618 unsigned int cfg;
f1d4e28b 2619
42397004
DR
2620 if (strcmp(codec->chip_name, "ALC271X") &&
2621 strcmp(codec->chip_name, "ALC269VB"))
1d045db9
TI
2622 return;
2623 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
2624 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
2625 snd_hda_sequence_write(codec, verbs);
2626}
f1d4e28b 2627
017f2a10 2628static void alc269_fixup_pcm_44k(struct hda_codec *codec,
1727a771 2629 const struct hda_fixup *fix, int action)
017f2a10
TI
2630{
2631 struct alc_spec *spec = codec->spec;
2632
1727a771 2633 if (action != HDA_FIXUP_ACT_PROBE)
017f2a10
TI
2634 return;
2635
2636 /* Due to a hardware problem on Lenovo Ideadpad, we need to
2637 * fix the sample rate of analog I/O to 44.1kHz
2638 */
08c189f2
TI
2639 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
2640 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
017f2a10
TI
2641}
2642
adabb3ec 2643static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
1727a771 2644 const struct hda_fixup *fix, int action)
adabb3ec
TI
2645{
2646 int coef;
2647
1727a771 2648 if (action != HDA_FIXUP_ACT_INIT)
adabb3ec
TI
2649 return;
2650 /* The digital-mic unit sends PDM (differential signal) instead of
2651 * the standard PCM, thus you can't record a valid mono stream as is.
2652 * Below is a workaround specific to ALC269 to control the dmic
2653 * signal source as mono.
2654 */
2655 coef = alc_read_coef_idx(codec, 0x07);
2656 alc_write_coef_idx(codec, 0x07, coef | 0x80);
2657}
2658
24519911
TI
2659static void alc269_quanta_automute(struct hda_codec *codec)
2660{
08c189f2 2661 snd_hda_gen_update_outputs(codec);
24519911
TI
2662
2663 snd_hda_codec_write(codec, 0x20, 0,
2664 AC_VERB_SET_COEF_INDEX, 0x0c);
2665 snd_hda_codec_write(codec, 0x20, 0,
2666 AC_VERB_SET_PROC_COEF, 0x680);
2667
2668 snd_hda_codec_write(codec, 0x20, 0,
2669 AC_VERB_SET_COEF_INDEX, 0x0c);
2670 snd_hda_codec_write(codec, 0x20, 0,
2671 AC_VERB_SET_PROC_COEF, 0x480);
2672}
2673
2674static void alc269_fixup_quanta_mute(struct hda_codec *codec,
1727a771 2675 const struct hda_fixup *fix, int action)
24519911
TI
2676{
2677 struct alc_spec *spec = codec->spec;
1727a771 2678 if (action != HDA_FIXUP_ACT_PROBE)
24519911 2679 return;
08c189f2 2680 spec->gen.automute_hook = alc269_quanta_automute;
24519911
TI
2681}
2682
08fb0d0e
TI
2683/* update mute-LED according to the speaker mute state via mic VREF pin */
2684static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
6d3cd5d4
DH
2685{
2686 struct hda_codec *codec = private_data;
08fb0d0e
TI
2687 struct alc_spec *spec = codec->spec;
2688 unsigned int pinval;
2689
2690 if (spec->mute_led_polarity)
2691 enabled = !enabled;
2692 pinval = AC_PINCTL_IN_EN |
2693 (enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80);
2694 if (spec->mute_led_nid)
2695 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
6d3cd5d4
DH
2696}
2697
08fb0d0e
TI
2698static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
2699 const struct hda_fixup *fix, int action)
6d3cd5d4
DH
2700{
2701 struct alc_spec *spec = codec->spec;
08fb0d0e
TI
2702 const struct dmi_device *dev = NULL;
2703
2704 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2705 return;
2706
2707 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
2708 int pol, pin;
2709 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
2710 continue;
2711 if (pin < 0x0a || pin >= 0x10)
2712 break;
2713 spec->mute_led_polarity = pol;
2714 spec->mute_led_nid = pin - 0x0a + 0x18;
2715 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 2716 spec->gen.vmaster_mute_enum = 1;
08fb0d0e
TI
2717 snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
2718 spec->mute_led_polarity);
6d3cd5d4
DH
2719 break;
2720 }
2721}
2722
d06ac143
DH
2723static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
2724 const struct hda_fixup *fix, int action)
2725{
2726 struct alc_spec *spec = codec->spec;
2727 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2728 spec->mute_led_polarity = 0;
2729 spec->mute_led_nid = 0x18;
2730 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2731 spec->gen.vmaster_mute_enum = 1;
2732 }
2733}
2734
08fb0d0e
TI
2735static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
2736 const struct hda_fixup *fix, int action)
420b0feb
TI
2737{
2738 struct alc_spec *spec = codec->spec;
9bb1f06f 2739 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08fb0d0e
TI
2740 spec->mute_led_polarity = 0;
2741 spec->mute_led_nid = 0x19;
2742 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 2743 spec->gen.vmaster_mute_enum = 1;
420b0feb
TI
2744 }
2745}
2746
9f5c6faf
TI
2747/* turn on/off mute LED per vmaster hook */
2748static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
2749{
2750 struct hda_codec *codec = private_data;
2751 struct alc_spec *spec = codec->spec;
2752 unsigned int oldval = spec->gpio_led;
2753
2754 if (enabled)
2755 spec->gpio_led &= ~0x08;
2756 else
2757 spec->gpio_led |= 0x08;
2758 if (spec->gpio_led != oldval)
2759 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2760 spec->gpio_led);
2761}
2762
2763/* turn on/off mic-mute LED per capture hook */
2764static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
2765 struct snd_ctl_elem_value *ucontrol)
2766{
2767 struct alc_spec *spec = codec->spec;
2768 unsigned int oldval = spec->gpio_led;
2769
2770 if (!ucontrol)
2771 return;
2772
2773 if (ucontrol->value.integer.value[0] ||
2774 ucontrol->value.integer.value[1])
2775 spec->gpio_led &= ~0x10;
2776 else
2777 spec->gpio_led |= 0x10;
2778 if (spec->gpio_led != oldval)
2779 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2780 spec->gpio_led);
2781}
2782
2783static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
2784 const struct hda_fixup *fix, int action)
2785{
2786 struct alc_spec *spec = codec->spec;
2787 static const struct hda_verb gpio_init[] = {
2788 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
2789 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
2790 {}
2791 };
2792
2793 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2794 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
2795 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
2796 spec->gpio_led = 0;
2797 snd_hda_add_verbs(codec, gpio_init);
2798 }
2799}
2800
08a978db 2801static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
1727a771 2802 const struct hda_fixup *fix,
08a978db
DR
2803 int action)
2804{
2805 struct alc_spec *spec = codec->spec;
2806
0db75790
TI
2807 if (action == HDA_FIXUP_ACT_PROBE) {
2808 if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
2809 !spec->gen.autocfg.hp_pins[0]))
2810 return;
08c189f2
TI
2811 snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin,
2812 spec->gen.autocfg.hp_pins[0]);
0db75790 2813 }
08a978db 2814}
693b613d 2815
1d045db9
TI
2816enum {
2817 ALC269_FIXUP_SONY_VAIO,
2818 ALC275_FIXUP_SONY_VAIO_GPIO2,
2819 ALC269_FIXUP_DELL_M101Z,
2820 ALC269_FIXUP_SKU_IGNORE,
2821 ALC269_FIXUP_ASUS_G73JW,
2822 ALC269_FIXUP_LENOVO_EAPD,
2823 ALC275_FIXUP_SONY_HWEQ,
2824 ALC271_FIXUP_DMIC,
017f2a10 2825 ALC269_FIXUP_PCM_44K,
adabb3ec 2826 ALC269_FIXUP_STEREO_DMIC,
24519911
TI
2827 ALC269_FIXUP_QUANTA_MUTE,
2828 ALC269_FIXUP_LIFEBOOK,
a4297b5d
TI
2829 ALC269_FIXUP_AMIC,
2830 ALC269_FIXUP_DMIC,
2831 ALC269VB_FIXUP_AMIC,
2832 ALC269VB_FIXUP_DMIC,
08fb0d0e 2833 ALC269_FIXUP_HP_MUTE_LED,
d06ac143 2834 ALC269_FIXUP_HP_MUTE_LED_MIC1,
08fb0d0e 2835 ALC269_FIXUP_HP_MUTE_LED_MIC2,
9f5c6faf 2836 ALC269_FIXUP_HP_GPIO_LED,
693b613d 2837 ALC269_FIXUP_INV_DMIC,
108cc108
DH
2838 ALC269_FIXUP_LENOVO_DOCK,
2839 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
08a978db
DR
2840 ALC271_FIXUP_AMIC_MIC2,
2841 ALC271_FIXUP_HP_GATE_MIC_JACK,
42397004 2842 ALC269_FIXUP_ACER_AC700,
f1d4e28b
KY
2843};
2844
1727a771 2845static const struct hda_fixup alc269_fixups[] = {
1d045db9 2846 [ALC269_FIXUP_SONY_VAIO] = {
fd108215
TI
2847 .type = HDA_FIXUP_PINCTLS,
2848 .v.pins = (const struct hda_pintbl[]) {
2849 {0x19, PIN_VREFGRD},
1d045db9
TI
2850 {}
2851 }
f1d4e28b 2852 },
1d045db9 2853 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
1727a771 2854 .type = HDA_FIXUP_VERBS,
1d045db9
TI
2855 .v.verbs = (const struct hda_verb[]) {
2856 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
2857 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
2858 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
2859 { }
2860 },
2861 .chained = true,
2862 .chain_id = ALC269_FIXUP_SONY_VAIO
2863 },
2864 [ALC269_FIXUP_DELL_M101Z] = {
1727a771 2865 .type = HDA_FIXUP_VERBS,
1d045db9
TI
2866 .v.verbs = (const struct hda_verb[]) {
2867 /* Enables internal speaker */
2868 {0x20, AC_VERB_SET_COEF_INDEX, 13},
2869 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
2870 {}
2871 }
2872 },
2873 [ALC269_FIXUP_SKU_IGNORE] = {
1727a771 2874 .type = HDA_FIXUP_FUNC,
23d30f28 2875 .v.func = alc_fixup_sku_ignore,
1d045db9
TI
2876 },
2877 [ALC269_FIXUP_ASUS_G73JW] = {
1727a771
TI
2878 .type = HDA_FIXUP_PINS,
2879 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2880 { 0x17, 0x99130111 }, /* subwoofer */
2881 { }
2882 }
2883 },
2884 [ALC269_FIXUP_LENOVO_EAPD] = {
1727a771 2885 .type = HDA_FIXUP_VERBS,
1d045db9
TI
2886 .v.verbs = (const struct hda_verb[]) {
2887 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
2888 {}
2889 }
2890 },
2891 [ALC275_FIXUP_SONY_HWEQ] = {
1727a771 2892 .type = HDA_FIXUP_FUNC,
1d045db9
TI
2893 .v.func = alc269_fixup_hweq,
2894 .chained = true,
2895 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
2896 },
2897 [ALC271_FIXUP_DMIC] = {
1727a771 2898 .type = HDA_FIXUP_FUNC,
1d045db9 2899 .v.func = alc271_fixup_dmic,
f1d4e28b 2900 },
017f2a10 2901 [ALC269_FIXUP_PCM_44K] = {
1727a771 2902 .type = HDA_FIXUP_FUNC,
017f2a10 2903 .v.func = alc269_fixup_pcm_44k,
012e7eb1
DH
2904 .chained = true,
2905 .chain_id = ALC269_FIXUP_QUANTA_MUTE
017f2a10 2906 },
adabb3ec 2907 [ALC269_FIXUP_STEREO_DMIC] = {
1727a771 2908 .type = HDA_FIXUP_FUNC,
adabb3ec
TI
2909 .v.func = alc269_fixup_stereo_dmic,
2910 },
24519911 2911 [ALC269_FIXUP_QUANTA_MUTE] = {
1727a771 2912 .type = HDA_FIXUP_FUNC,
24519911
TI
2913 .v.func = alc269_fixup_quanta_mute,
2914 },
2915 [ALC269_FIXUP_LIFEBOOK] = {
1727a771
TI
2916 .type = HDA_FIXUP_PINS,
2917 .v.pins = (const struct hda_pintbl[]) {
24519911
TI
2918 { 0x1a, 0x2101103f }, /* dock line-out */
2919 { 0x1b, 0x23a11040 }, /* dock mic-in */
2920 { }
2921 },
2922 .chained = true,
2923 .chain_id = ALC269_FIXUP_QUANTA_MUTE
2924 },
a4297b5d 2925 [ALC269_FIXUP_AMIC] = {
1727a771
TI
2926 .type = HDA_FIXUP_PINS,
2927 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
2928 { 0x14, 0x99130110 }, /* speaker */
2929 { 0x15, 0x0121401f }, /* HP out */
2930 { 0x18, 0x01a19c20 }, /* mic */
2931 { 0x19, 0x99a3092f }, /* int-mic */
2932 { }
2933 },
2934 },
2935 [ALC269_FIXUP_DMIC] = {
1727a771
TI
2936 .type = HDA_FIXUP_PINS,
2937 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
2938 { 0x12, 0x99a3092f }, /* int-mic */
2939 { 0x14, 0x99130110 }, /* speaker */
2940 { 0x15, 0x0121401f }, /* HP out */
2941 { 0x18, 0x01a19c20 }, /* mic */
2942 { }
2943 },
2944 },
2945 [ALC269VB_FIXUP_AMIC] = {
1727a771
TI
2946 .type = HDA_FIXUP_PINS,
2947 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
2948 { 0x14, 0x99130110 }, /* speaker */
2949 { 0x18, 0x01a19c20 }, /* mic */
2950 { 0x19, 0x99a3092f }, /* int-mic */
2951 { 0x21, 0x0121401f }, /* HP out */
2952 { }
2953 },
2954 },
2267ea97 2955 [ALC269VB_FIXUP_DMIC] = {
1727a771
TI
2956 .type = HDA_FIXUP_PINS,
2957 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
2958 { 0x12, 0x99a3092f }, /* int-mic */
2959 { 0x14, 0x99130110 }, /* speaker */
2960 { 0x18, 0x01a19c20 }, /* mic */
2961 { 0x21, 0x0121401f }, /* HP out */
2962 { }
2963 },
2964 },
08fb0d0e 2965 [ALC269_FIXUP_HP_MUTE_LED] = {
1727a771 2966 .type = HDA_FIXUP_FUNC,
08fb0d0e 2967 .v.func = alc269_fixup_hp_mute_led,
6d3cd5d4 2968 },
d06ac143
DH
2969 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
2970 .type = HDA_FIXUP_FUNC,
2971 .v.func = alc269_fixup_hp_mute_led_mic1,
2972 },
08fb0d0e 2973 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
1727a771 2974 .type = HDA_FIXUP_FUNC,
08fb0d0e 2975 .v.func = alc269_fixup_hp_mute_led_mic2,
420b0feb 2976 },
9f5c6faf
TI
2977 [ALC269_FIXUP_HP_GPIO_LED] = {
2978 .type = HDA_FIXUP_FUNC,
2979 .v.func = alc269_fixup_hp_gpio_led,
2980 },
693b613d 2981 [ALC269_FIXUP_INV_DMIC] = {
1727a771 2982 .type = HDA_FIXUP_FUNC,
6e72aa5f 2983 .v.func = alc_fixup_inv_dmic_0x12,
693b613d 2984 },
108cc108 2985 [ALC269_FIXUP_LENOVO_DOCK] = {
1727a771
TI
2986 .type = HDA_FIXUP_PINS,
2987 .v.pins = (const struct hda_pintbl[]) {
108cc108
DH
2988 { 0x19, 0x23a11040 }, /* dock mic */
2989 { 0x1b, 0x2121103f }, /* dock headphone */
2990 { }
2991 },
2992 .chained = true,
2993 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
2994 },
2995 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
1727a771 2996 .type = HDA_FIXUP_FUNC,
108cc108
DH
2997 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
2998 },
08a978db 2999 [ALC271_FIXUP_AMIC_MIC2] = {
1727a771
TI
3000 .type = HDA_FIXUP_PINS,
3001 .v.pins = (const struct hda_pintbl[]) {
08a978db
DR
3002 { 0x14, 0x99130110 }, /* speaker */
3003 { 0x19, 0x01a19c20 }, /* mic */
3004 { 0x1b, 0x99a7012f }, /* int-mic */
3005 { 0x21, 0x0121401f }, /* HP out */
3006 { }
3007 },
3008 },
3009 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
1727a771 3010 .type = HDA_FIXUP_FUNC,
08a978db
DR
3011 .v.func = alc271_hp_gate_mic_jack,
3012 .chained = true,
3013 .chain_id = ALC271_FIXUP_AMIC_MIC2,
3014 },
42397004
DR
3015 [ALC269_FIXUP_ACER_AC700] = {
3016 .type = HDA_FIXUP_PINS,
3017 .v.pins = (const struct hda_pintbl[]) {
3018 { 0x12, 0x99a3092f }, /* int-mic */
3019 { 0x14, 0x99130110 }, /* speaker */
3020 { 0x18, 0x03a11c20 }, /* mic */
3021 { 0x1e, 0x0346101e }, /* SPDIF1 */
3022 { 0x21, 0x0321101f }, /* HP out */
3023 { }
3024 },
3025 .chained = true,
3026 .chain_id = ALC271_FIXUP_DMIC,
3027 },
f1d4e28b
KY
3028};
3029
1d045db9 3030static const struct snd_pci_quirk alc269_fixup_tbl[] = {
693b613d
DH
3031 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
3032 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
08fb0d0e 3033 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9f5c6faf 3034 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
d06ac143
DH
3035 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
3036 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
08fb0d0e 3037 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
5ac57550 3038 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
148728f1 3039 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC),
017f2a10 3040 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
693b613d 3041 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
adabb3ec
TI
3042 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
3043 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
3044 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
3045 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
3046 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
1d045db9
TI
3047 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
3048 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3049 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3050 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
3051 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
42397004 3052 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
ec50b4ce 3053 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
08a978db 3054 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
1d045db9 3055 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
24519911 3056 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
1d045db9
TI
3057 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
3058 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
3059 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
3060 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
3061 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
707fba3f 3062 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
c8415a48 3063 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
84f98fdf 3064 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
4407be6b 3065 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
108cc108 3066 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
012e7eb1 3067 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
1d045db9 3068 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
a4297b5d 3069
a7f3eedc 3070#if 0
a4297b5d
TI
3071 /* Below is a quirk table taken from the old code.
3072 * Basically the device should work as is without the fixup table.
3073 * If BIOS doesn't give a proper info, enable the corresponding
3074 * fixup entry.
7d7eb9ea 3075 */
a4297b5d
TI
3076 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
3077 ALC269_FIXUP_AMIC),
3078 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
a4297b5d
TI
3079 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
3080 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
3081 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
3082 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
3083 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
3084 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
3085 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
3086 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
3087 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
3088 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
3089 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
3090 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
3091 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
3092 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
3093 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
3094 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
3095 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
3096 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
3097 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
3098 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
3099 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
3100 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
3101 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
3102 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
3103 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
3104 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
3105 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
3106 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
3107 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
3108 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
3109 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
3110 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
3111 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
3112 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
3113 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
3114 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
3115 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
3116 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
3117#endif
3118 {}
3119};
3120
1727a771 3121static const struct hda_model_fixup alc269_fixup_models[] = {
a4297b5d
TI
3122 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
3123 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6e72aa5f
TI
3124 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
3125 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
3126 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
108cc108 3127 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9f5c6faf 3128 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
1d045db9 3129 {}
6dda9f4a
KY
3130};
3131
6dda9f4a 3132
546bb678 3133static void alc269_fill_coef(struct hda_codec *codec)
1d045db9 3134{
526af6eb 3135 struct alc_spec *spec = codec->spec;
1d045db9 3136 int val;
ebb83eeb 3137
526af6eb 3138 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
546bb678 3139 return;
526af6eb 3140
1bb7e43e 3141 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
1d045db9
TI
3142 alc_write_coef_idx(codec, 0xf, 0x960b);
3143 alc_write_coef_idx(codec, 0xe, 0x8817);
3144 }
ebb83eeb 3145
1bb7e43e 3146 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
1d045db9
TI
3147 alc_write_coef_idx(codec, 0xf, 0x960b);
3148 alc_write_coef_idx(codec, 0xe, 0x8814);
3149 }
ebb83eeb 3150
1bb7e43e 3151 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
3152 val = alc_read_coef_idx(codec, 0x04);
3153 /* Power up output pin */
3154 alc_write_coef_idx(codec, 0x04, val | (1<<11));
3155 }
ebb83eeb 3156
1bb7e43e 3157 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
3158 val = alc_read_coef_idx(codec, 0xd);
3159 if ((val & 0x0c00) >> 10 != 0x1) {
3160 /* Capless ramp up clock control */
3161 alc_write_coef_idx(codec, 0xd, val | (1<<10));
3162 }
3163 val = alc_read_coef_idx(codec, 0x17);
3164 if ((val & 0x01c0) >> 6 != 0x4) {
3165 /* Class D power on reset */
3166 alc_write_coef_idx(codec, 0x17, val | (1<<7));
3167 }
3168 }
ebb83eeb 3169
1d045db9
TI
3170 val = alc_read_coef_idx(codec, 0xd); /* Class D */
3171 alc_write_coef_idx(codec, 0xd, val | (1<<14));
bc9f98a9 3172
1d045db9
TI
3173 val = alc_read_coef_idx(codec, 0x4); /* HP */
3174 alc_write_coef_idx(codec, 0x4, val | (1<<11));
1d045db9 3175}
a7f2371f 3176
1d045db9
TI
3177/*
3178 */
1d045db9
TI
3179static int patch_alc269(struct hda_codec *codec)
3180{
3181 struct alc_spec *spec;
3de95173 3182 int err;
f1d4e28b 3183
3de95173 3184 err = alc_alloc_spec(codec, 0x0b);
e16fb6d1 3185 if (err < 0)
3de95173
TI
3186 return err;
3187
3188 spec = codec->spec;
08c189f2 3189 spec->gen.shared_mic_vref_pin = 0x18;
e16fb6d1 3190
1727a771 3191 snd_hda_pick_fixup(codec, alc269_fixup_models,
9f720bb9 3192 alc269_fixup_tbl, alc269_fixups);
1727a771 3193 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9f720bb9
HRK
3194
3195 alc_auto_parse_customize_define(codec);
3196
7504b6cd
TI
3197 if (has_cdefine_beep(codec))
3198 spec->gen.beep_nid = 0x01;
3199
065380f0
KY
3200 switch (codec->vendor_id) {
3201 case 0x10ec0269:
1d045db9 3202 spec->codec_variant = ALC269_TYPE_ALC269VA;
1bb7e43e
TI
3203 switch (alc_get_coef0(codec) & 0x00f0) {
3204 case 0x0010:
1d045db9 3205 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 3206 spec->cdefine.platform_type == 1)
20ca0c35 3207 err = alc_codec_rename(codec, "ALC271X");
1d045db9 3208 spec->codec_variant = ALC269_TYPE_ALC269VB;
1bb7e43e
TI
3209 break;
3210 case 0x0020:
e16fb6d1
TI
3211 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
3212 codec->bus->pci->subsystem_device == 0x21f3)
20ca0c35 3213 err = alc_codec_rename(codec, "ALC3202");
1d045db9 3214 spec->codec_variant = ALC269_TYPE_ALC269VC;
1bb7e43e 3215 break;
adcc70b2
KY
3216 case 0x0030:
3217 spec->codec_variant = ALC269_TYPE_ALC269VD;
3218 break;
1bb7e43e 3219 default:
1d045db9 3220 alc_fix_pll_init(codec, 0x20, 0x04, 15);
1bb7e43e 3221 }
e16fb6d1
TI
3222 if (err < 0)
3223 goto error;
546bb678 3224 spec->init_hook = alc269_fill_coef;
1d045db9 3225 alc269_fill_coef(codec);
065380f0
KY
3226 break;
3227
3228 case 0x10ec0280:
3229 case 0x10ec0290:
3230 spec->codec_variant = ALC269_TYPE_ALC280;
3231 break;
84dfd0ac 3232 case 0x10ec0233:
065380f0
KY
3233 case 0x10ec0282:
3234 case 0x10ec0283:
3235 spec->codec_variant = ALC269_TYPE_ALC282;
3236 break;
3237 case 0x10ec0284:
3238 case 0x10ec0292:
3239 spec->codec_variant = ALC269_TYPE_ALC284;
3240 break;
1d045db9 3241 }
6dda9f4a 3242
a4297b5d
TI
3243 /* automatic parse from the BIOS config */
3244 err = alc269_parse_auto_config(codec);
e16fb6d1
TI
3245 if (err < 0)
3246 goto error;
6dda9f4a 3247
7504b6cd 3248 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 3249 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
f1d4e28b 3250
1d045db9 3251 codec->patch_ops = alc_patch_ops;
2a43952a 3252#ifdef CONFIG_PM
1d045db9
TI
3253 codec->patch_ops.resume = alc269_resume;
3254#endif
1d045db9 3255 spec->shutup = alc269_shutup;
ebb83eeb 3256
1727a771 3257 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 3258
1d045db9 3259 return 0;
e16fb6d1
TI
3260
3261 error:
3262 alc_free(codec);
3263 return err;
1d045db9 3264}
f1d4e28b 3265
1d045db9
TI
3266/*
3267 * ALC861
3268 */
622e84cd 3269
1d045db9 3270static int alc861_parse_auto_config(struct hda_codec *codec)
6dda9f4a 3271{
1d045db9 3272 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3e6179b8
TI
3273 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
3274 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
604401a9
TI
3275}
3276
1d045db9
TI
3277/* Pin config fixes */
3278enum {
e652f4c8
TI
3279 ALC861_FIXUP_FSC_AMILO_PI1505,
3280 ALC861_FIXUP_AMP_VREF_0F,
3281 ALC861_FIXUP_NO_JACK_DETECT,
3282 ALC861_FIXUP_ASUS_A6RP,
1d045db9 3283};
7085ec12 3284
31150f23
TI
3285/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
3286static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
1727a771 3287 const struct hda_fixup *fix, int action)
31150f23
TI
3288{
3289 struct alc_spec *spec = codec->spec;
3290 unsigned int val;
3291
1727a771 3292 if (action != HDA_FIXUP_ACT_INIT)
31150f23 3293 return;
d3f02d60 3294 val = snd_hda_codec_get_pin_target(codec, 0x0f);
31150f23
TI
3295 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
3296 val |= AC_PINCTL_IN_EN;
3297 val |= AC_PINCTL_VREF_50;
cdd03ced 3298 snd_hda_set_pin_ctl(codec, 0x0f, val);
08c189f2 3299 spec->gen.keep_vref_in_automute = 1;
31150f23
TI
3300}
3301
e652f4c8
TI
3302/* suppress the jack-detection */
3303static void alc_fixup_no_jack_detect(struct hda_codec *codec,
1727a771 3304 const struct hda_fixup *fix, int action)
e652f4c8 3305{
1727a771 3306 if (action == HDA_FIXUP_ACT_PRE_PROBE)
e652f4c8 3307 codec->no_jack_detect = 1;
7d7eb9ea 3308}
e652f4c8 3309
1727a771 3310static const struct hda_fixup alc861_fixups[] = {
e652f4c8 3311 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
1727a771
TI
3312 .type = HDA_FIXUP_PINS,
3313 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
3314 { 0x0b, 0x0221101f }, /* HP */
3315 { 0x0f, 0x90170310 }, /* speaker */
3316 { }
3317 }
3318 },
e652f4c8 3319 [ALC861_FIXUP_AMP_VREF_0F] = {
1727a771 3320 .type = HDA_FIXUP_FUNC,
31150f23 3321 .v.func = alc861_fixup_asus_amp_vref_0f,
3b25eb69 3322 },
e652f4c8 3323 [ALC861_FIXUP_NO_JACK_DETECT] = {
1727a771 3324 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
3325 .v.func = alc_fixup_no_jack_detect,
3326 },
3327 [ALC861_FIXUP_ASUS_A6RP] = {
1727a771 3328 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
3329 .v.func = alc861_fixup_asus_amp_vref_0f,
3330 .chained = true,
3331 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
3332 }
1d045db9 3333};
7085ec12 3334
1d045db9 3335static const struct snd_pci_quirk alc861_fixup_tbl[] = {
e652f4c8
TI
3336 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
3337 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
3338 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
3339 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
3340 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
3341 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
1d045db9
TI
3342 {}
3343};
3af9ee6b 3344
1d045db9
TI
3345/*
3346 */
1d045db9 3347static int patch_alc861(struct hda_codec *codec)
7085ec12 3348{
1d045db9 3349 struct alc_spec *spec;
1d045db9 3350 int err;
7085ec12 3351
3de95173
TI
3352 err = alc_alloc_spec(codec, 0x15);
3353 if (err < 0)
3354 return err;
1d045db9 3355
3de95173 3356 spec = codec->spec;
7504b6cd 3357 spec->gen.beep_nid = 0x23;
1d045db9 3358
1727a771
TI
3359 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
3360 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3af9ee6b 3361
cb4e4824
TI
3362 /* automatic parse from the BIOS config */
3363 err = alc861_parse_auto_config(codec);
e16fb6d1
TI
3364 if (err < 0)
3365 goto error;
3af9ee6b 3366
7504b6cd 3367 if (!spec->gen.no_analog)
3e6179b8 3368 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7085ec12 3369
1d045db9 3370 codec->patch_ops = alc_patch_ops;
83012a7c 3371#ifdef CONFIG_PM
cb4e4824 3372 spec->power_hook = alc_power_eapd;
1d045db9
TI
3373#endif
3374
1727a771 3375 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 3376
1d045db9 3377 return 0;
e16fb6d1
TI
3378
3379 error:
3380 alc_free(codec);
3381 return err;
7085ec12
TI
3382}
3383
1d045db9
TI
3384/*
3385 * ALC861-VD support
3386 *
3387 * Based on ALC882
3388 *
3389 * In addition, an independent DAC
3390 */
1d045db9 3391static int alc861vd_parse_auto_config(struct hda_codec *codec)
bc9f98a9 3392{
1d045db9 3393 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3e6179b8
TI
3394 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3395 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
ce764ab2
TI
3396}
3397
1d045db9 3398enum {
8fdcb6fe
TI
3399 ALC660VD_FIX_ASUS_GPIO1,
3400 ALC861VD_FIX_DALLAS,
1d045db9 3401};
ce764ab2 3402
8fdcb6fe
TI
3403/* exclude VREF80 */
3404static void alc861vd_fixup_dallas(struct hda_codec *codec,
1727a771 3405 const struct hda_fixup *fix, int action)
8fdcb6fe 3406{
1727a771 3407 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
b78562b1
TI
3408 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
3409 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8fdcb6fe
TI
3410 }
3411}
3412
1727a771 3413static const struct hda_fixup alc861vd_fixups[] = {
1d045db9 3414 [ALC660VD_FIX_ASUS_GPIO1] = {
1727a771 3415 .type = HDA_FIXUP_VERBS,
1d045db9 3416 .v.verbs = (const struct hda_verb[]) {
8fdcb6fe 3417 /* reset GPIO1 */
1d045db9
TI
3418 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
3419 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3420 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3421 { }
3422 }
3423 },
8fdcb6fe 3424 [ALC861VD_FIX_DALLAS] = {
1727a771 3425 .type = HDA_FIXUP_FUNC,
8fdcb6fe
TI
3426 .v.func = alc861vd_fixup_dallas,
3427 },
1d045db9 3428};
ce764ab2 3429
1d045db9 3430static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8fdcb6fe 3431 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
1d045db9 3432 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8fdcb6fe 3433 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
1d045db9
TI
3434 {}
3435};
ce764ab2 3436
1d045db9
TI
3437/*
3438 */
1d045db9 3439static int patch_alc861vd(struct hda_codec *codec)
ce764ab2 3440{
1d045db9 3441 struct alc_spec *spec;
cb4e4824 3442 int err;
ce764ab2 3443
3de95173
TI
3444 err = alc_alloc_spec(codec, 0x0b);
3445 if (err < 0)
3446 return err;
1d045db9 3447
3de95173 3448 spec = codec->spec;
7504b6cd 3449 spec->gen.beep_nid = 0x23;
1d045db9 3450
1727a771
TI
3451 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
3452 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1d045db9 3453
cb4e4824
TI
3454 /* automatic parse from the BIOS config */
3455 err = alc861vd_parse_auto_config(codec);
e16fb6d1
TI
3456 if (err < 0)
3457 goto error;
ce764ab2 3458
7504b6cd 3459 if (!spec->gen.no_analog)
3e6179b8 3460 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1d045db9 3461
1d045db9
TI
3462 codec->patch_ops = alc_patch_ops;
3463
1d045db9 3464 spec->shutup = alc_eapd_shutup;
1d045db9 3465
1727a771 3466 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 3467
ce764ab2 3468 return 0;
e16fb6d1
TI
3469
3470 error:
3471 alc_free(codec);
3472 return err;
ce764ab2
TI
3473}
3474
1d045db9
TI
3475/*
3476 * ALC662 support
3477 *
3478 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
3479 * configuration. Each pin widget can choose any input DACs and a mixer.
3480 * Each ADC is connected from a mixer of all inputs. This makes possible
3481 * 6-channel independent captures.
3482 *
3483 * In addition, an independent DAC for the multi-playback (not used in this
3484 * driver yet).
3485 */
1d045db9
TI
3486
3487/*
3488 * BIOS auto configuration
3489 */
3490
bc9f98a9
KY
3491static int alc662_parse_auto_config(struct hda_codec *codec)
3492{
4c6d72d1 3493 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3e6179b8
TI
3494 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
3495 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3496 const hda_nid_t *ssids;
ee979a14 3497
6227cdce
KY
3498 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
3499 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
3e6179b8 3500 ssids = alc663_ssids;
6227cdce 3501 else
3e6179b8
TI
3502 ssids = alc662_ssids;
3503 return alc_parse_auto_config(codec, alc662_ignore, ssids);
bc9f98a9
KY
3504}
3505
6be7948f 3506static void alc272_fixup_mario(struct hda_codec *codec,
1727a771 3507 const struct hda_fixup *fix, int action)
6fc398cb 3508{
9bb1f06f 3509 if (action != HDA_FIXUP_ACT_PRE_PROBE)
6fc398cb 3510 return;
6be7948f
TB
3511 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
3512 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
3513 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
3514 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3515 (0 << AC_AMPCAP_MUTE_SHIFT)))
3516 printk(KERN_WARNING
3517 "hda_codec: failed to override amp caps for NID 0x2\n");
3518}
3519
6cb3b707 3520enum {
2df03514 3521 ALC662_FIXUP_ASPIRE,
6cb3b707 3522 ALC662_FIXUP_IDEAPAD,
6be7948f 3523 ALC272_FIXUP_MARIO,
d2ebd479 3524 ALC662_FIXUP_CZC_P10T,
94024cd1 3525 ALC662_FIXUP_SKU_IGNORE,
e59ea3ed 3526 ALC662_FIXUP_HP_RP5800,
53c334ad
TI
3527 ALC662_FIXUP_ASUS_MODE1,
3528 ALC662_FIXUP_ASUS_MODE2,
3529 ALC662_FIXUP_ASUS_MODE3,
3530 ALC662_FIXUP_ASUS_MODE4,
3531 ALC662_FIXUP_ASUS_MODE5,
3532 ALC662_FIXUP_ASUS_MODE6,
3533 ALC662_FIXUP_ASUS_MODE7,
3534 ALC662_FIXUP_ASUS_MODE8,
1565cc35 3535 ALC662_FIXUP_NO_JACK_DETECT,
edfe3bfc 3536 ALC662_FIXUP_ZOTAC_Z68,
125821ae 3537 ALC662_FIXUP_INV_DMIC,
6cb3b707
DH
3538};
3539
1727a771 3540static const struct hda_fixup alc662_fixups[] = {
2df03514 3541 [ALC662_FIXUP_ASPIRE] = {
1727a771
TI
3542 .type = HDA_FIXUP_PINS,
3543 .v.pins = (const struct hda_pintbl[]) {
2df03514
DC
3544 { 0x15, 0x99130112 }, /* subwoofer */
3545 { }
3546 }
3547 },
6cb3b707 3548 [ALC662_FIXUP_IDEAPAD] = {
1727a771
TI
3549 .type = HDA_FIXUP_PINS,
3550 .v.pins = (const struct hda_pintbl[]) {
6cb3b707
DH
3551 { 0x17, 0x99130112 }, /* subwoofer */
3552 { }
3553 }
3554 },
6be7948f 3555 [ALC272_FIXUP_MARIO] = {
1727a771 3556 .type = HDA_FIXUP_FUNC,
b5bfbc67 3557 .v.func = alc272_fixup_mario,
d2ebd479
AA
3558 },
3559 [ALC662_FIXUP_CZC_P10T] = {
1727a771 3560 .type = HDA_FIXUP_VERBS,
d2ebd479
AA
3561 .v.verbs = (const struct hda_verb[]) {
3562 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
3563 {}
3564 }
3565 },
94024cd1 3566 [ALC662_FIXUP_SKU_IGNORE] = {
1727a771 3567 .type = HDA_FIXUP_FUNC,
23d30f28 3568 .v.func = alc_fixup_sku_ignore,
c6b35874 3569 },
e59ea3ed 3570 [ALC662_FIXUP_HP_RP5800] = {
1727a771
TI
3571 .type = HDA_FIXUP_PINS,
3572 .v.pins = (const struct hda_pintbl[]) {
e59ea3ed
TI
3573 { 0x14, 0x0221201f }, /* HP out */
3574 { }
3575 },
3576 .chained = true,
3577 .chain_id = ALC662_FIXUP_SKU_IGNORE
3578 },
53c334ad 3579 [ALC662_FIXUP_ASUS_MODE1] = {
1727a771
TI
3580 .type = HDA_FIXUP_PINS,
3581 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3582 { 0x14, 0x99130110 }, /* speaker */
3583 { 0x18, 0x01a19c20 }, /* mic */
3584 { 0x19, 0x99a3092f }, /* int-mic */
3585 { 0x21, 0x0121401f }, /* HP out */
3586 { }
3587 },
3588 .chained = true,
3589 .chain_id = ALC662_FIXUP_SKU_IGNORE
3590 },
3591 [ALC662_FIXUP_ASUS_MODE2] = {
1727a771
TI
3592 .type = HDA_FIXUP_PINS,
3593 .v.pins = (const struct hda_pintbl[]) {
2996bdba
TI
3594 { 0x14, 0x99130110 }, /* speaker */
3595 { 0x18, 0x01a19820 }, /* mic */
3596 { 0x19, 0x99a3092f }, /* int-mic */
3597 { 0x1b, 0x0121401f }, /* HP out */
3598 { }
3599 },
53c334ad
TI
3600 .chained = true,
3601 .chain_id = ALC662_FIXUP_SKU_IGNORE
3602 },
3603 [ALC662_FIXUP_ASUS_MODE3] = {
1727a771
TI
3604 .type = HDA_FIXUP_PINS,
3605 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3606 { 0x14, 0x99130110 }, /* speaker */
3607 { 0x15, 0x0121441f }, /* HP */
3608 { 0x18, 0x01a19840 }, /* mic */
3609 { 0x19, 0x99a3094f }, /* int-mic */
3610 { 0x21, 0x01211420 }, /* HP2 */
3611 { }
3612 },
3613 .chained = true,
3614 .chain_id = ALC662_FIXUP_SKU_IGNORE
3615 },
3616 [ALC662_FIXUP_ASUS_MODE4] = {
1727a771
TI
3617 .type = HDA_FIXUP_PINS,
3618 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3619 { 0x14, 0x99130110 }, /* speaker */
3620 { 0x16, 0x99130111 }, /* speaker */
3621 { 0x18, 0x01a19840 }, /* mic */
3622 { 0x19, 0x99a3094f }, /* int-mic */
3623 { 0x21, 0x0121441f }, /* HP */
3624 { }
3625 },
3626 .chained = true,
3627 .chain_id = ALC662_FIXUP_SKU_IGNORE
3628 },
3629 [ALC662_FIXUP_ASUS_MODE5] = {
1727a771
TI
3630 .type = HDA_FIXUP_PINS,
3631 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3632 { 0x14, 0x99130110 }, /* speaker */
3633 { 0x15, 0x0121441f }, /* HP */
3634 { 0x16, 0x99130111 }, /* speaker */
3635 { 0x18, 0x01a19840 }, /* mic */
3636 { 0x19, 0x99a3094f }, /* int-mic */
3637 { }
3638 },
3639 .chained = true,
3640 .chain_id = ALC662_FIXUP_SKU_IGNORE
3641 },
3642 [ALC662_FIXUP_ASUS_MODE6] = {
1727a771
TI
3643 .type = HDA_FIXUP_PINS,
3644 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3645 { 0x14, 0x99130110 }, /* speaker */
3646 { 0x15, 0x01211420 }, /* HP2 */
3647 { 0x18, 0x01a19840 }, /* mic */
3648 { 0x19, 0x99a3094f }, /* int-mic */
3649 { 0x1b, 0x0121441f }, /* HP */
3650 { }
3651 },
3652 .chained = true,
3653 .chain_id = ALC662_FIXUP_SKU_IGNORE
3654 },
3655 [ALC662_FIXUP_ASUS_MODE7] = {
1727a771
TI
3656 .type = HDA_FIXUP_PINS,
3657 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3658 { 0x14, 0x99130110 }, /* speaker */
3659 { 0x17, 0x99130111 }, /* speaker */
3660 { 0x18, 0x01a19840 }, /* mic */
3661 { 0x19, 0x99a3094f }, /* int-mic */
3662 { 0x1b, 0x01214020 }, /* HP */
3663 { 0x21, 0x0121401f }, /* HP */
3664 { }
3665 },
3666 .chained = true,
3667 .chain_id = ALC662_FIXUP_SKU_IGNORE
3668 },
3669 [ALC662_FIXUP_ASUS_MODE8] = {
1727a771
TI
3670 .type = HDA_FIXUP_PINS,
3671 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
3672 { 0x14, 0x99130110 }, /* speaker */
3673 { 0x12, 0x99a30970 }, /* int-mic */
3674 { 0x15, 0x01214020 }, /* HP */
3675 { 0x17, 0x99130111 }, /* speaker */
3676 { 0x18, 0x01a19840 }, /* mic */
3677 { 0x21, 0x0121401f }, /* HP */
3678 { }
3679 },
3680 .chained = true,
3681 .chain_id = ALC662_FIXUP_SKU_IGNORE
2996bdba 3682 },
1565cc35 3683 [ALC662_FIXUP_NO_JACK_DETECT] = {
1727a771 3684 .type = HDA_FIXUP_FUNC,
1565cc35
TI
3685 .v.func = alc_fixup_no_jack_detect,
3686 },
edfe3bfc 3687 [ALC662_FIXUP_ZOTAC_Z68] = {
1727a771
TI
3688 .type = HDA_FIXUP_PINS,
3689 .v.pins = (const struct hda_pintbl[]) {
edfe3bfc
DH
3690 { 0x1b, 0x02214020 }, /* Front HP */
3691 { }
3692 }
3693 },
125821ae 3694 [ALC662_FIXUP_INV_DMIC] = {
1727a771 3695 .type = HDA_FIXUP_FUNC,
6e72aa5f 3696 .v.func = alc_fixup_inv_dmic_0x12,
125821ae 3697 },
6cb3b707
DH
3698};
3699
a9111321 3700static const struct snd_pci_quirk alc662_fixup_tbl[] = {
53c334ad 3701 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
a6c47a85 3702 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
94024cd1 3703 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
125821ae 3704 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
2df03514 3705 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
e59ea3ed 3706 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
1565cc35 3707 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
53c334ad 3708 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
a0e90acc 3709 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
d4118588 3710 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6cb3b707 3711 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
edfe3bfc 3712 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
d2ebd479 3713 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
53c334ad
TI
3714
3715#if 0
3716 /* Below is a quirk table taken from the old code.
3717 * Basically the device should work as is without the fixup table.
3718 * If BIOS doesn't give a proper info, enable the corresponding
3719 * fixup entry.
7d7eb9ea 3720 */
53c334ad
TI
3721 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
3722 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
3723 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
3724 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
3725 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3726 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3727 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3728 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
3729 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
3730 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3731 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
3732 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
3733 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
3734 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
3735 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
3736 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3737 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
3738 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
3739 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3740 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3741 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3742 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3743 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
3744 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
3745 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
3746 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3747 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
3748 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3749 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3750 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
3751 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3752 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3753 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
3754 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
3755 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
3756 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
3757 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
3758 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
3759 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
3760 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3761 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
3762 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
3763 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3764 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
3765 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
3766 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
3767 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
3768 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
3769 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3770 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
3771#endif
6cb3b707
DH
3772 {}
3773};
3774
1727a771 3775static const struct hda_model_fixup alc662_fixup_models[] = {
6be7948f 3776 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
53c334ad
TI
3777 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
3778 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
3779 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
3780 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
3781 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
3782 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
3783 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
3784 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6e72aa5f 3785 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
6be7948f
TB
3786 {}
3787};
6cb3b707 3788
8663ff75
KY
3789static void alc662_fill_coef(struct hda_codec *codec)
3790{
3791 int val, coef;
3792
3793 coef = alc_get_coef0(codec);
3794
3795 switch (codec->vendor_id) {
3796 case 0x10ec0662:
3797 if ((coef & 0x00f0) == 0x0030) {
3798 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
3799 alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
3800 }
3801 break;
3802 case 0x10ec0272:
3803 case 0x10ec0273:
3804 case 0x10ec0663:
3805 case 0x10ec0665:
3806 case 0x10ec0670:
3807 case 0x10ec0671:
3808 case 0x10ec0672:
3809 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
3810 alc_write_coef_idx(codec, 0xd, val | (1<<14));
3811 break;
3812 }
3813}
6cb3b707 3814
1d045db9
TI
3815/*
3816 */
bc9f98a9
KY
3817static int patch_alc662(struct hda_codec *codec)
3818{
3819 struct alc_spec *spec;
3de95173 3820 int err;
bc9f98a9 3821
3de95173
TI
3822 err = alc_alloc_spec(codec, 0x0b);
3823 if (err < 0)
3824 return err;
bc9f98a9 3825
3de95173 3826 spec = codec->spec;
1f0f4b80 3827
53c334ad
TI
3828 /* handle multiple HPs as is */
3829 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3830
2c3bf9ab
TI
3831 alc_fix_pll_init(codec, 0x20, 0x04, 15);
3832
8663ff75
KY
3833 spec->init_hook = alc662_fill_coef;
3834 alc662_fill_coef(codec);
3835
1727a771 3836 snd_hda_pick_fixup(codec, alc662_fixup_models,
8e5a0509 3837 alc662_fixup_tbl, alc662_fixups);
1727a771 3838 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8e5a0509
TI
3839
3840 alc_auto_parse_customize_define(codec);
3841
7504b6cd
TI
3842 if (has_cdefine_beep(codec))
3843 spec->gen.beep_nid = 0x01;
3844
1bb7e43e 3845 if ((alc_get_coef0(codec) & (1 << 14)) &&
e16fb6d1
TI
3846 codec->bus->pci->subsystem_vendor == 0x1025 &&
3847 spec->cdefine.platform_type == 1) {
3848 if (alc_codec_rename(codec, "ALC272X") < 0)
3849 goto error;
20ca0c35 3850 }
274693f3 3851
b9c5106c
TI
3852 /* automatic parse from the BIOS config */
3853 err = alc662_parse_auto_config(codec);
e16fb6d1
TI
3854 if (err < 0)
3855 goto error;
bc9f98a9 3856
7504b6cd 3857 if (!spec->gen.no_analog && spec->gen.beep_nid) {
da00c244
KY
3858 switch (codec->vendor_id) {
3859 case 0x10ec0662:
3860 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3861 break;
3862 case 0x10ec0272:
3863 case 0x10ec0663:
3864 case 0x10ec0665:
3865 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
3866 break;
3867 case 0x10ec0273:
3868 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
3869 break;
3870 }
cec27c89 3871 }
2134ea4f 3872
bc9f98a9 3873 codec->patch_ops = alc_patch_ops;
1c716153 3874 spec->shutup = alc_eapd_shutup;
6cb3b707 3875
1727a771 3876 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 3877
bc9f98a9 3878 return 0;
801f49d3 3879
e16fb6d1
TI
3880 error:
3881 alc_free(codec);
3882 return err;
b478b998
KY
3883}
3884
d1eb57f4
KY
3885/*
3886 * ALC680 support
3887 */
d1eb57f4 3888
d1eb57f4
KY
3889static int alc680_parse_auto_config(struct hda_codec *codec)
3890{
3e6179b8 3891 return alc_parse_auto_config(codec, NULL, NULL);
d1eb57f4
KY
3892}
3893
d1eb57f4 3894/*
d1eb57f4 3895 */
d1eb57f4
KY
3896static int patch_alc680(struct hda_codec *codec)
3897{
d1eb57f4
KY
3898 int err;
3899
1f0f4b80 3900 /* ALC680 has no aa-loopback mixer */
3de95173
TI
3901 err = alc_alloc_spec(codec, 0);
3902 if (err < 0)
3903 return err;
1f0f4b80 3904
1ebec5f2
TI
3905 /* automatic parse from the BIOS config */
3906 err = alc680_parse_auto_config(codec);
3907 if (err < 0) {
3908 alc_free(codec);
3909 return err;
d1eb57f4
KY
3910 }
3911
d1eb57f4 3912 codec->patch_ops = alc_patch_ops;
d1eb57f4
KY
3913
3914 return 0;
3915}
3916
1da177e4
LT
3917/*
3918 * patch entries
3919 */
a9111321 3920static const struct hda_codec_preset snd_hda_preset_realtek[] = {
296f0338 3921 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
84dfd0ac 3922 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
1da177e4 3923 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
df694daa 3924 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
f6a92248 3925 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
a361d84b 3926 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
f6a92248 3927 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
ebb83eeb 3928 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
01afd41f 3929 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
ebb83eeb 3930 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
296f0338 3931 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
befae82e 3932 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
4e01ec63 3933 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
7ff34ad8 3934 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
065380f0 3935 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
7ff34ad8 3936 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
af02dde8 3937 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
f32610ed 3938 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
bc9f98a9 3939 .patch = patch_alc861 },
f32610ed
JS
3940 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
3941 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
3942 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
bc9f98a9 3943 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
4953550a 3944 .patch = patch_alc882 },
bc9f98a9
KY
3945 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
3946 .patch = patch_alc662 },
cc667a72
DH
3947 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
3948 .patch = patch_alc662 },
6dda9f4a 3949 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
cec27c89 3950 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
19a62823 3951 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
6227cdce 3952 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
d1eb57f4 3953 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
f32610ed 3954 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
1da177e4 3955 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4953550a 3956 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
669faba2 3957 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
4953550a 3958 .patch = patch_alc882 },
cb308f97 3959 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
4953550a 3960 .patch = patch_alc882 },
df694daa 3961 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
e16fb6d1 3962 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
4442608d 3963 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
4953550a 3964 .patch = patch_alc882 },
e16fb6d1 3965 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
4953550a 3966 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
274693f3 3967 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
e16fb6d1 3968 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
19a62823 3969 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
1da177e4
LT
3970 {} /* terminator */
3971};
1289e9e8
TI
3972
3973MODULE_ALIAS("snd-hda-codec-id:10ec*");
3974
3975MODULE_LICENSE("GPL");
3976MODULE_DESCRIPTION("Realtek HD-audio codec");
3977
3978static struct hda_codec_preset_list realtek_list = {
3979 .preset = snd_hda_preset_realtek,
3980 .owner = THIS_MODULE,
3981};
3982
3983static int __init patch_realtek_init(void)
3984{
3985 return snd_hda_add_codec_preset(&realtek_list);
3986}
3987
3988static void __exit patch_realtek_exit(void)
3989{
3990 snd_hda_delete_codec_preset(&realtek_list);
3991}
3992
3993module_init(patch_realtek_init)
3994module_exit(patch_realtek_exit)