blob: 1bd2d49194e7bb6335780fe94896208178315b05 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
Takashi Iwai1d045db2011-07-07 18:23:21 +02004 * HD audio interface patch for Realtek ALC codecs
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe409a3e92012-03-27 13:01:01 +10309 * Jonathan Woithe <jwoithe@just42.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
Takashi Iwai08fb0d02013-01-10 17:33:58 +010030#include <linux/dmi.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040031#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020033#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include "hda_codec.h"
35#include "hda_local.h"
Takashi Iwai23d30f22012-05-07 17:17:32 +020036#include "hda_auto_parser.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020037#include "hda_jack.h"
Takashi Iwai08c189f2012-12-19 15:22:24 +010038#include "hda_generic.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Takashi Iwai1d045db2011-07-07 18:23:21 +020040/* unsol event tags */
Takashi Iwai08c189f2012-12-19 15:22:24 +010041#define ALC_DCVOL_EVENT 0x08
Takashi Iwaid4a86d82010-06-23 17:51:26 +020042
Kailang Yangdf694da2005-12-05 19:42:22 +010043/* for GPIO Poll */
44#define GPIO_MASK 0x03
45
Takashi Iwai4a79ba32009-04-22 16:31:35 +020046/* 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
Kailang Yangda00c242010-03-19 11:23:45 +010055struct 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;
David Henningsson90622912010-10-14 14:50:18 +020065 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +010066};
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068struct alc_spec {
Takashi Iwai08c189f2012-12-19 15:22:24 +010069 struct hda_gen_spec gen; /* must be at head */
Takashi Iwai23d30f22012-05-07 17:17:32 +020070
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 /* codec parameterization */
Takashi Iwaia9111322011-05-02 11:30:18 +020072 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 unsigned int num_mixers;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010074 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Kailang Yangda00c242010-03-19 11:23:45 +010076 struct alc_customize_define cdefine;
Takashi Iwai08c189f2012-12-19 15:22:24 +010077 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
78
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? */
Takashi Iwai125821a2012-06-22 14:30:29 +020082 hda_nid_t inv_dmic_pin;
Takashi Iwai834be882006-03-01 14:16:17 +010083
Takashi Iwai08fb0d02013-01-10 17:33:58 +010084 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
85 int mute_led_polarity;
86 hda_nid_t mute_led_nid;
87
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +010088 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
89
Takashi Iwaiae6b8132006-03-03 16:47:17 +010090 /* hooks */
91 void (*init_hook)(struct hda_codec *codec);
Takashi Iwai83012a72012-08-24 18:38:08 +020092#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -050093 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +010094#endif
Takashi Iwai1c7161532011-04-07 10:37:16 +020095 void (*shutup)(struct hda_codec *codec);
Takashi Iwaid922b512011-04-28 12:18:53 +020096
Takashi Iwai4a79ba32009-04-22 16:31:35 +020097 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +020098 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010099
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200100 /* for PLL fix */
101 hda_nid_t pll_nid;
102 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200103 unsigned int coef0;
Kailang Yangdf694da2005-12-05 19:42:22 +0100104};
105
Takashi Iwai23f0c042009-02-26 13:03:58 +0100106/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200107 * 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().
Takashi Iwaid88897e2008-10-31 15:01:37 +0100110 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200111static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100112{
113 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
114 return;
115 spec->mixers[spec->num_mixers++] = mix;
116}
117
Takashi Iwaid88897e2008-10-31 15:01:37 +0100118/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200119 * GPIO setup tables, used in initialization
Kailang Yangdf694da2005-12-05 19:42:22 +0100120 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200121/* Enable GPIO mask and set output */
Takashi Iwaia9111322011-05-02 11:30:18 +0200122static const struct hda_verb alc_gpio1_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200123 {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
Takashi Iwaia9111322011-05-02 11:30:18 +0200129static const struct hda_verb alc_gpio2_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200130 {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
Takashi Iwaia9111322011-05-02 11:30:18 +0200136static const struct hda_verb alc_gpio3_init_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +0200137 {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
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200143/*
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
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100175/* update the master volume per volume-knob's unsol event */
David Henningsson29adc4b2012-09-25 11:31:00 +0200176static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100177{
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;
David Henningsson29adc4b2012-09-25 11:31:00 +0200188 val = snd_hda_codec_read(codec, jack->nid, 0,
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100189 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
David Henningsson29adc4b2012-09-25 11:31:00 +0200197static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100198{
David Henningsson29adc4b2012-09-25 11:31:00 +0200199 /* 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);
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100202}
203
Kailang Yangf9423e72008-05-27 12:32:25 +0200204/* 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);
Takashi Iwai37db6232009-03-05 09:40:16 +0100212 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +0200213 /* 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
Takashi Iwai1d045db2011-07-07 18:23:21 +0200222/* additional initialization for ALC889 variants */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200223static 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
Takashi Iwai3fb4a502010-01-19 15:46:37 +0100233/* 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
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200243/* 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 */
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200247 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);
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200253}
254
Takashi Iwai1c7161532011-04-07 10:37:16 +0200255/* 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
Takashi Iwai1d045db2011-07-07 18:23:21 +0200264/* generic EAPD initialization */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200265static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200266{
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200267 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200268
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200269 alc_auto_setup_eapd(codec, true);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270 switch (type) {
271 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200272 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
273 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200274 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200275 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
276 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200277 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200278 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
279 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200280 case ALC_INIT_DEFAULT:
Kailang Yangc9b58002007-10-16 14:30:01 +0200281 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:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +0100298 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +0100299 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200300 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200301 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200302 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200303 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +0200304 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +0100305#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +0200306 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,
Kailang Yangea1fb292008-08-26 12:58:38 +0200313 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200314 snd_hda_codec_write(codec, 0x20, 0,
315 AC_VERB_SET_PROC_COEF,
316 tmp | 0x3000);
317 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +0100318#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200319 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200320 break;
321 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200322}
Kailang Yangea1fb292008-08-26 12:58:38 +0200323
Takashi Iwai1d045db2011-07-07 18:23:21 +0200324
325/*
326 * Realtek SSID verification
327 */
328
David Henningsson90622912010-10-14 14:50:18 +0200329/* 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)
333
Takashi Iwai23d30f22012-05-07 17:17:32 +0200334static void alc_fixup_sku_ignore(struct hda_codec *codec,
335 const struct hda_fixup *fix, int action)
336{
337 struct alc_spec *spec = codec->spec;
338 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
339 spec->cdefine.fixup = 1;
340 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
341 }
342}
343
Kailang Yangda00c242010-03-19 11:23:45 +0100344static int alc_auto_parse_customize_define(struct hda_codec *codec)
345{
346 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +0100347 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +0100348 struct alc_spec *spec = codec->spec;
349
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200350 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
351
David Henningsson90622912010-10-14 14:50:18 +0200352 if (spec->cdefine.fixup) {
353 ass = spec->cdefine.sku_cfg;
354 if (ass == ALC_FIXUP_SKU_IGNORE)
355 return -1;
356 goto do_sku;
357 }
358
Kailang Yangda00c242010-03-19 11:23:45 +0100359 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200360 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +0100361 goto do_sku;
362
363 nid = 0x1d;
364 if (codec->vendor_id == 0x10ec0260)
365 nid = 0x17;
366 ass = snd_hda_codec_get_pincfg(codec, nid);
367
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;
372 }
373
374 /* check sum */
375 tmp = 0;
376 for (i = 1; i < 16; i++) {
377 if ((ass >> i) & 1)
378 tmp++;
379 }
380 if (((ass >> 16) & 0xf) != tmp)
381 return -1;
382
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
Takashi Iwai08c189f2012-12-19 15:22:24 +0100409/* 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}
Takashi Iwai1d045db2011-07-07 18:23:21 +0200418/* return true if the given NID is found in the list */
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200419static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
420{
Takashi Iwai21268962011-07-07 15:01:13 +0200421 return find_idx_in_nid_list(nid, list, nums) >= 0;
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200422}
423
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200424/* 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,
Kailang Yang6227cdc2010-02-25 08:36:52 +0100435 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200436{
437 unsigned int ass, tmp, i;
438 unsigned nid;
439 struct alc_spec *spec = codec->spec;
440
David Henningsson90622912010-10-14 14:50:18 +0200441 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
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200448 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 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400454 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200455 * 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",
Takashi Iwaicb6605c2009-04-28 13:03:19 +0200467 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +0100468 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200469 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:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +0100503 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200504 spec->init_amp = ALC_INIT_DEFAULT;
505 break;
506 }
507
508 /* is laptop or Desktop and enable the function "Mute internal speaker
509 * when the external headphone out jack is plugged"
510 */
511 if (!(ass & 0x8000))
512 return 1;
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 */
Takashi Iwai08c189f2012-12-19 15:22:24 +0100520 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)) {
Takashi Iwai01d48252009-10-06 13:21:54 +0200523 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200524 tmp = (ass >> 11) & 0x3; /* HP to chassis */
525 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +0200526 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +0200527 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +0200528 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +0200529 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +0200530 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +0100531 else if (tmp == 3)
532 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +0200533 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200534 return 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100535 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
536 spec->gen.autocfg.line_outs))
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200537 return 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100538 spec->gen.autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200539 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200540 return 1;
541}
Kailang Yangea1fb292008-08-26 12:58:38 +0200542
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200543/* 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)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200546{
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200547 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200548 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;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200552 }
Takashi Iwai21268962011-07-07 15:01:13 +0200553}
Takashi Iwai1a1455d2011-04-28 17:36:18 +0200554
Takashi Iwai41e41f12005-06-08 14:48:49 +0200555/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200556 * COEF access helper functions
557 */
Kailang Yang274693f2009-12-03 10:07:50 +0100558static 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
Kailang Yang977ddd62010-09-15 10:02:29 +0200569static 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
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200578/* 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
Takashi Iwai1d045db2011-07-07 18:23:21 +0200587/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200588 */
589
Takashi Iwai08c189f2012-12-19 15:22:24 +0100590static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
Takashi Iwai757899a2010-07-30 10:48:14 +0200591{
Takashi Iwai08c189f2012-12-19 15:22:24 +0100592 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];
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100596}
597
Takashi Iwai666a70d2012-12-17 20:29:29 +0100598static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200599{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100601 struct hda_input_mux *imux = &spec->gen.input_mux;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100602 struct nid_path *path;
603 hda_nid_t nid;
604 int i, dir, parm;
605 unsigned int val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200606
Takashi Iwai666a70d2012-12-17 20:29:29 +0100607 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai08c189f2012-12-19 15:22:24 +0100608 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
Takashi Iwai666a70d2012-12-17 20:29:29 +0100609 break;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200610 }
Takashi Iwai666a70d2012-12-17 20:29:29 +0100611 if (i >= imux->num_items)
612 return;
Takashi Iwaia23b6882009-03-23 15:21:36 +0100613
Takashi Iwai08c189f2012-12-19 15:22:24 +0100614 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
615 get_adc_nid(codec, adc_idx, i));
Takashi Iwai666a70d2012-12-17 20:29:29 +0100616 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);
Takashi Iwaia23b6882009-03-23 15:21:36 +0100623
Takashi Iwaic4f3ebe2012-12-20 11:33:20 +0100624 /* flush all cached amps at first */
Takashi Iwaidc870f32013-01-22 15:24:30 +0100625 snd_hda_codec_flush_cache(codec);
Takashi Iwaic4f3ebe2012-12-20 11:33:20 +0100626
Takashi Iwai666a70d2012-12-17 20:29:29 +0100627 /* 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);
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200634}
635
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200636/*
Takashi Iwai125821a2012-06-22 14:30:29 +0200637 * 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;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100654 int src, nums;
Takashi Iwai125821a2012-06-22 14:30:29 +0200655
656 if (!spec->inv_dmic_fixup)
657 return;
658 if (!spec->inv_dmic_muted && !force)
659 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100660 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100661 for (src = 0; src < nums; src++) {
Takashi Iwai125821a2012-06-22 14:30:29 +0200662 bool dmic_fixup = false;
Takashi Iwai125821a2012-06-22 14:30:29 +0200663
664 if (spec->inv_dmic_muted &&
Takashi Iwai08c189f2012-12-19 15:22:24 +0100665 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
Takashi Iwai125821a2012-06-22 14:30:29 +0200666 dmic_fixup = true;
667 if (!dmic_fixup && !force)
668 continue;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100669 alc_inv_dmic_sync_adc(codec, src);
Takashi Iwai125821a2012-06-22 14:30:29 +0200670 }
671}
672
Takashi Iwaia90229e2013-01-18 14:10:00 +0100673static void alc_inv_dmic_hook(struct hda_codec *codec,
674 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai08c189f2012-12-19 15:22:24 +0100675{
676 alc_inv_dmic_sync(codec, false);
677}
678
Takashi Iwai125821a2012-06-22 14:30:29 +0200679static 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,
Takashi Iwaibc549762012-12-18 15:35:11 +0100705 .name = "Inverted Internal Mic Capture Switch",
Takashi Iwai125821a2012-06-22 14:30:29 +0200706 .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;
Takashi Iwai668d1e92012-11-29 14:10:17 +0100714
Takashi Iwai08c189f2012-12-19 15:22:24 +0100715 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
Takashi Iwai125821a2012-06-22 14:30:29 +0200716 return -ENOMEM;
717 spec->inv_dmic_fixup = 1;
718 spec->inv_dmic_muted = 0;
719 spec->inv_dmic_pin = nid;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100720 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
Takashi Iwai125821a2012-06-22 14:30:29 +0200721 return 0;
722}
723
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200724/* typically the digital mic is put at node 0x12 */
725static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +0100726 const struct hda_fixup *fix, int action)
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200727{
Takashi Iwai1727a772013-01-10 09:52:52 +0100728 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200729 alc_add_inv_dmic_mixer(codec, 0x12);
730}
731
Takashi Iwai603c4012008-07-30 15:01:44 +0200732
Takashi Iwai67d634c2009-11-16 15:35:59 +0100733#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100734/* additional beep mixers; the actual parameters are overwritten at build */
Takashi Iwaia9111322011-05-02 11:30:18 +0200735static const struct snd_kcontrol_new alc_beep_mixer[] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100736 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +0200737 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100738 { } /* end */
739};
Takashi Iwai67d634c2009-11-16 15:35:59 +0100740#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100741
Takashi Iwai2eab6942012-12-18 15:30:41 +0100742static int alc_build_controls(struct hda_codec *codec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743{
744 struct alc_spec *spec = codec->spec;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100745 int i, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746
Takashi Iwai08c189f2012-12-19 15:22:24 +0100747 err = snd_hda_gen_build_controls(codec);
748 if (err < 0)
749 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750
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 }
Takashi Iwai2134ea42008-01-10 16:53:55 +0100756
Takashi Iwai67d634c2009-11-16 15:35:59 +0100757#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100758 /* create beep controls if needed */
759 if (spec->beep_amp) {
Takashi Iwaia9111322011-05-02 11:30:18 +0200760 const struct snd_kcontrol_new *knew;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100761 for (knew = alc_beep_mixer; knew->name; knew++) {
762 struct snd_kcontrol *kctl;
763 kctl = snd_ctl_new1(knew, codec);
764 if (!kctl)
765 return -ENOMEM;
766 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +0100767 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100768 if (err < 0)
769 return err;
770 }
771 }
Takashi Iwai67d634c2009-11-16 15:35:59 +0100772#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100773
Takashi Iwai1727a772013-01-10 09:52:52 +0100774 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
Takashi Iwai420b0fe2012-03-12 12:35:27 +0100775 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776}
777
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200778
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100780 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200781 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200782
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783static int alc_init(struct hda_codec *codec)
784{
785 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200786
Takashi Iwai546bb672012-03-07 08:37:19 +0100787 if (spec->init_hook)
788 spec->init_hook(codec);
Kailang Yang526af6e2012-03-07 08:25:20 +0100789
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200790 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200791 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200792
Takashi Iwai08c189f2012-12-19 15:22:24 +0100793 snd_hda_gen_init(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100794
Takashi Iwai1727a772013-01-10 09:52:52 +0100795 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
Takashi Iwaie08a0072006-09-07 17:52:14 +0200796
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 return 0;
798}
799
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100800static inline void alc_shutup(struct hda_codec *codec)
801{
Takashi Iwai1c7161532011-04-07 10:37:16 +0200802 struct alc_spec *spec = codec->spec;
803
804 if (spec && spec->shutup)
805 spec->shutup(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100806 snd_hda_shutup_pins(codec);
807}
808
Takashi Iwai7504b6c2013-03-18 11:25:51 +0100809#define alc_free snd_hda_gen_free
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810
Takashi Iwai83012a72012-08-24 18:38:08 +0200811#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -0500812static void alc_power_eapd(struct hda_codec *codec)
813{
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200814 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -0500815}
816
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200817static int alc_suspend(struct hda_codec *codec)
Hector Martinf5de24b2009-12-20 22:51:31 +0100818{
819 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100820 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100821 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -0500822 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100823 return 0;
824}
825#endif
826
Takashi Iwai2a439522011-07-26 09:52:50 +0200827#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100828static int alc_resume(struct hda_codec *codec)
829{
Takashi Iwai1c7161532011-04-07 10:37:16 +0200830 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +0100831 codec->patch_ops.init(codec);
832 snd_hda_codec_resume_amp(codec);
833 snd_hda_codec_resume_cache(codec);
Takashi Iwai125821a2012-06-22 14:30:29 +0200834 alc_inv_dmic_sync(codec, true);
Takashi Iwai9e5341b2010-09-21 09:57:06 +0200835 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +0100836 return 0;
837}
Takashi Iwaie044c392008-10-27 16:56:24 +0100838#endif
839
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840/*
841 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200842static const struct hda_codec_ops alc_patch_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 .build_controls = alc_build_controls,
Takashi Iwai08c189f2012-12-19 15:22:24 +0100844 .build_pcms = snd_hda_gen_build_pcms,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 .init = alc_init,
846 .free = alc_free,
David Henningsson29adc4b2012-09-25 11:31:00 +0200847 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +0200848#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100849 .resume = alc_resume,
Hector Martinf5de24b2009-12-20 22:51:31 +0100850 .suspend = alc_suspend,
Takashi Iwaifce52a32013-01-07 12:42:48 +0100851 .check_power_status = snd_hda_gen_check_power_status,
Takashi Iwaicb53c622007-08-10 17:21:45 +0200852#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -0500853 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854};
855
David Henningsson29adc4b2012-09-25 11:31:00 +0200856
Kailang Yangc027ddc2010-03-19 11:33:06 +0100857/* replace the codec chip_name with the given string */
858static int alc_codec_rename(struct hda_codec *codec, const char *name)
859{
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;
865 }
866 return 0;
867}
868
Takashi Iwai2fa522b2005-05-12 14:51:12 +0200869/*
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200870 * Rename codecs appropriately from COEF value
871 */
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};
878
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" },
Kailang Yangadcc70b2012-05-25 08:08:38 +0200887 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200888 { 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};
897
898static int alc_codec_rename_from_preset(struct hda_codec *codec)
899{
900 const struct alc_codec_rename_table *p;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200901
902 for (p = rename_tbl; p->vendor_id; p++) {
903 if (p->vendor_id != codec->vendor_id)
904 continue;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200905 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200906 return alc_codec_rename(codec, p->name);
907 }
908 return 0;
909}
910
Takashi Iwaie4770622011-07-08 11:11:35 +0200911
912/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200913 * 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))
918
919static const struct snd_pci_quirk beep_white_list[] = {
Duncan Roe71100052012-10-10 14:19:50 +0200920 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +0200921 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai8554ee42013-02-25 09:54:43 +0100922 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +0200923 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
924 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
925 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
Takashi Iwai78f8baf2012-03-06 14:02:32 +0100926 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +0200927 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
928 {}
929};
930
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
944
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 */
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200949static int alc_parse_auto_config(struct hda_codec *codec,
950 const hda_nid_t *ignore_nids,
951 const hda_nid_t *ssid_nids)
Takashi Iwai1d045db2011-07-07 18:23:21 +0200952{
953 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100954 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
Takashi Iwai1d045db2011-07-07 18:23:21 +0200955 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +0200956
Takashi Iwai53c334a2011-08-23 18:27:14 +0200957 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
958 spec->parse_flags);
Takashi Iwai1d045db2011-07-07 18:23:21 +0200959 if (err < 0)
960 return err;
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200961
962 if (ssid_nids)
963 alc_ssid_check(codec, ssid_nids);
964
Takashi Iwai08c189f2012-12-19 15:22:24 +0100965 err = snd_hda_gen_parse_auto_config(codec, cfg);
966 if (err < 0)
967 return err;
Takashi Iwai070cff42012-02-21 12:54:17 +0100968
Takashi Iwai1d045db2011-07-07 18:23:21 +0200969 return 1;
970}
971
Takashi Iwai3de95172012-05-07 18:03:15 +0200972/* 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;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100981 snd_hda_gen_spec_init(&spec->gen);
982 spec->gen.mixer_nid = mixer_nid;
983 spec->gen.own_eapd_ctl = 1;
Takashi Iwai1098b7c2012-12-17 20:03:15 +0100984 codec->single_adc_amp = 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100985 /* FIXME: do we need this for all Realtek codec models? */
986 codec->spdif_status_reset = 1;
Takashi Iwai3de95172012-05-07 18:03:15 +0200987
988 err = alc_codec_rename_from_preset(codec);
989 if (err < 0) {
990 kfree(spec);
991 return err;
992 }
993 return 0;
994}
995
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200996static int alc880_parse_auto_config(struct hda_codec *codec)
997{
998 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +0200999 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001000 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1001}
1002
Takashi Iwai1d045db2011-07-07 18:23:21 +02001003/*
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001004 * ALC880 fix-ups
1005 */
1006enum {
Takashi Iwai411225a2012-02-20 17:48:19 +01001007 ALC880_FIXUP_GPIO1,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001008 ALC880_FIXUP_GPIO2,
1009 ALC880_FIXUP_MEDION_RIM,
Takashi Iwaidc6af522012-02-17 16:18:59 +01001010 ALC880_FIXUP_LG,
Takashi Iwaif02aab52012-02-17 16:33:56 +01001011 ALC880_FIXUP_W810,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001012 ALC880_FIXUP_EAPD_COEF,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001013 ALC880_FIXUP_TCL_S700,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001014 ALC880_FIXUP_VOL_KNOB,
1015 ALC880_FIXUP_FUJITSU,
Takashi Iwaiba533812012-02-20 16:36:52 +01001016 ALC880_FIXUP_F1734,
Takashi Iwai817de922012-02-20 17:20:48 +01001017 ALC880_FIXUP_UNIWILL,
Takashi Iwai967b88c2012-02-20 17:31:02 +01001018 ALC880_FIXUP_UNIWILL_DIG,
Takashi Iwai96e225f2012-02-20 17:41:51 +01001019 ALC880_FIXUP_Z71V,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001020 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,
Takashi Iwai53971452013-01-23 18:21:37 +01001029 ALC880_FIXUP_6ST_AUTOMUTE,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001030};
1031
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001032/* enable the volume-knob widget support on NID 0x21 */
1033static void alc880_fixup_vol_knob(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001034 const struct hda_fixup *fix, int action)
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001035{
Takashi Iwai1727a772013-01-10 09:52:52 +01001036 if (action == HDA_FIXUP_ACT_PROBE)
David Henningsson29adc4b2012-09-25 11:31:00 +02001037 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001038}
1039
Takashi Iwai1727a772013-01-10 09:52:52 +01001040static const struct hda_fixup alc880_fixups[] = {
Takashi Iwai411225a2012-02-20 17:48:19 +01001041 [ALC880_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001042 .type = HDA_FIXUP_VERBS,
Takashi Iwai411225a2012-02-20 17:48:19 +01001043 .v.verbs = alc_gpio1_init_verbs,
1044 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001045 [ALC880_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001046 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001047 .v.verbs = alc_gpio2_init_verbs,
1048 },
1049 [ALC880_FIXUP_MEDION_RIM] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001050 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001051 .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 },
Takashi Iwaidc6af522012-02-17 16:18:59 +01001059 [ALC880_FIXUP_LG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001060 .type = HDA_FIXUP_PINS,
1061 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaidc6af522012-02-17 16:18:59 +01001062 /* disable bogus unused pins */
1063 { 0x16, 0x411111f0 },
1064 { 0x18, 0x411111f0 },
1065 { 0x1a, 0x411111f0 },
1066 { }
1067 }
1068 },
Takashi Iwaif02aab52012-02-17 16:33:56 +01001069 [ALC880_FIXUP_W810] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001070 .type = HDA_FIXUP_PINS,
1071 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001072 /* disable bogus unused pins */
1073 { 0x17, 0x411111f0 },
1074 { }
1075 },
1076 .chained = true,
1077 .chain_id = ALC880_FIXUP_GPIO2,
1078 },
Takashi Iwai27e917f2012-02-17 17:49:54 +01001079 [ALC880_FIXUP_EAPD_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001080 .type = HDA_FIXUP_VERBS,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001081 .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 },
Takashi Iwaib9368f52012-02-17 17:54:44 +01001088 [ALC880_FIXUP_TCL_S700] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001089 .type = HDA_FIXUP_VERBS,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001090 .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 },
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001099 [ALC880_FIXUP_VOL_KNOB] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001100 .type = HDA_FIXUP_FUNC,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001101 .v.func = alc880_fixup_vol_knob,
1102 },
1103 [ALC880_FIXUP_FUJITSU] = {
1104 /* override all pins as BIOS on old Amilo is broken */
Takashi Iwai1727a772013-01-10 09:52:52 +01001105 .type = HDA_FIXUP_PINS,
1106 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001107 { 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 },
Takashi Iwaiba533812012-02-20 16:36:52 +01001123 [ALC880_FIXUP_F1734] = {
1124 /* almost compatible with FUJITSU, but no bass and SPDIF */
Takashi Iwai1727a772013-01-10 09:52:52 +01001125 .type = HDA_FIXUP_PINS,
1126 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiba533812012-02-20 16:36:52 +01001127 { 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 },
Takashi Iwai817de922012-02-20 17:20:48 +01001143 [ALC880_FIXUP_UNIWILL] = {
1144 /* need to fix HP and speaker pins to be parsed correctly */
Takashi Iwai1727a772013-01-10 09:52:52 +01001145 .type = HDA_FIXUP_PINS,
1146 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai817de922012-02-20 17:20:48 +01001147 { 0x14, 0x0121411f }, /* HP */
1148 { 0x15, 0x99030120 }, /* speaker */
1149 { 0x16, 0x99030130 }, /* bass speaker */
1150 { }
1151 },
1152 },
Takashi Iwai967b88c2012-02-20 17:31:02 +01001153 [ALC880_FIXUP_UNIWILL_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001154 .type = HDA_FIXUP_PINS,
1155 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai967b88c2012-02-20 17:31:02 +01001156 /* disable bogus unused pins */
1157 { 0x17, 0x411111f0 },
1158 { 0x19, 0x411111f0 },
1159 { 0x1b, 0x411111f0 },
1160 { 0x1f, 0x411111f0 },
1161 { }
1162 }
1163 },
Takashi Iwai96e225f2012-02-20 17:41:51 +01001164 [ALC880_FIXUP_Z71V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001165 .type = HDA_FIXUP_PINS,
1166 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai96e225f2012-02-20 17:41:51 +01001167 /* 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 },
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001182 [ALC880_FIXUP_3ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001183 .type = HDA_FIXUP_PINS,
1184 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001185 { 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] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001201 .type = HDA_FIXUP_PINS,
1202 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001203 { 0x1e, 0x411111f0 }, /* N/A */
1204 { }
1205 },
1206 .chained = true,
1207 .chain_id = ALC880_FIXUP_3ST_BASE,
1208 },
1209 [ALC880_FIXUP_3ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001210 .type = HDA_FIXUP_PINS,
1211 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001212 { 0x1e, 0x0144111e }, /* SPDIF */
1213 { }
1214 },
1215 .chained = true,
1216 .chain_id = ALC880_FIXUP_3ST_BASE,
1217 },
1218 [ALC880_FIXUP_5ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001219 .type = HDA_FIXUP_PINS,
1220 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001221 { 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] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001237 .type = HDA_FIXUP_PINS,
1238 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001239 { 0x1e, 0x411111f0 }, /* N/A */
1240 { }
1241 },
1242 .chained = true,
1243 .chain_id = ALC880_FIXUP_5ST_BASE,
1244 },
1245 [ALC880_FIXUP_5ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001246 .type = HDA_FIXUP_PINS,
1247 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001248 { 0x1e, 0x0144111e }, /* SPDIF */
1249 { }
1250 },
1251 .chained = true,
1252 .chain_id = ALC880_FIXUP_5ST_BASE,
1253 },
1254 [ALC880_FIXUP_6ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001255 .type = HDA_FIXUP_PINS,
1256 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001257 { 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] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001273 .type = HDA_FIXUP_PINS,
1274 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001275 { 0x1e, 0x411111f0 }, /* N/A */
1276 { }
1277 },
1278 .chained = true,
1279 .chain_id = ALC880_FIXUP_6ST_BASE,
1280 },
1281 [ALC880_FIXUP_6ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001282 .type = HDA_FIXUP_PINS,
1283 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001284 { 0x1e, 0x0144111e }, /* SPDIF */
1285 { }
1286 },
1287 .chained = true,
1288 .chain_id = ALC880_FIXUP_6ST_BASE,
1289 },
Takashi Iwai53971452013-01-23 18:21:37 +01001290 [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 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001299};
1300
1301static const struct snd_pci_quirk alc880_fixup_tbl[] = {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001302 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
Takashi Iwai96e225f2012-02-20 17:41:51 +01001303 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001304 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1305 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
Takashi Iwai27e917f2012-02-17 17:49:54 +01001306 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
Takashi Iwai967b88c2012-02-20 17:31:02 +01001307 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
Takashi Iwaiba533812012-02-20 16:36:52 +01001308 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
Takashi Iwai817de922012-02-20 17:20:48 +01001309 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
Takashi Iwai7833c7e2012-02-20 17:11:38 +01001310 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
Takashi Iwaif02aab52012-02-17 16:33:56 +01001311 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001312 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
Takashi Iwai53971452013-01-23 18:21:37 +01001313 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwaiba533812012-02-20 16:36:52 +01001314 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001315 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
Takashi Iwaiba533812012-02-20 16:36:52 +01001316 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001317 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
Takashi Iwaidc6af522012-02-17 16:18:59 +01001318 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),
Takashi Iwaib9368f52012-02-17 17:54:44 +01001321 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001322
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
Takashi Iwai1727a772013-01-10 09:52:52 +01001369static const struct hda_model_fixup alc880_fixup_models[] = {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001370 {.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"},
Takashi Iwai53971452013-01-23 18:21:37 +01001376 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001377 {}
1378};
1379
1380
1381/*
Takashi Iwai1d045db2011-07-07 18:23:21 +02001382 * OK, here we have finally the patch for ALC880
1383 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001384static int patch_alc880(struct hda_codec *codec)
1385{
1386 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001387 int err;
1388
Takashi Iwai3de95172012-05-07 18:03:15 +02001389 err = alc_alloc_spec(codec, 0x0b);
1390 if (err < 0)
1391 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001392
Takashi Iwai3de95172012-05-07 18:03:15 +02001393 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001394 spec->gen.need_dac_fix = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001395 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001396
Takashi Iwai1727a772013-01-10 09:52:52 +01001397 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001398 alc880_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001399 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001400
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001401 /* automatic parse from the BIOS config */
1402 err = alc880_parse_auto_config(codec);
1403 if (err < 0)
1404 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001405
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001406 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001407 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001408
Takashi Iwai1d045db2011-07-07 18:23:21 +02001409 codec->patch_ops = alc_patch_ops;
David Henningsson29adc4b2012-09-25 11:31:00 +02001410 codec->patch_ops.unsol_event = alc880_unsol_event;
1411
Takashi Iwai1d045db2011-07-07 18:23:21 +02001412
Takashi Iwai1727a772013-01-10 09:52:52 +01001413 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001414
Takashi Iwai1d045db2011-07-07 18:23:21 +02001415 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001416
1417 error:
1418 alc_free(codec);
1419 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001420}
1421
1422
1423/*
1424 * ALC260 support
1425 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001426static int alc260_parse_auto_config(struct hda_codec *codec)
1427{
Takashi Iwai1d045db2011-07-07 18:23:21 +02001428 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001429 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1430 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001431}
1432
Takashi Iwai1d045db2011-07-07 18:23:21 +02001433/*
1434 * Pin config fixes
1435 */
1436enum {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001437 ALC260_FIXUP_HP_DC5750,
1438 ALC260_FIXUP_HP_PIN_0F,
1439 ALC260_FIXUP_COEF,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001440 ALC260_FIXUP_GPIO1,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001441 ALC260_FIXUP_GPIO1_TOGGLE,
1442 ALC260_FIXUP_REPLACER,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001443 ALC260_FIXUP_HP_B1900,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001444 ALC260_FIXUP_KN1,
Takashi Iwai39aedee2013-01-10 17:10:40 +01001445 ALC260_FIXUP_FSC_S7020,
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001446 ALC260_FIXUP_FSC_S7020_JWSE,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001447};
1448
Takashi Iwai20f7d922012-02-16 12:35:16 +01001449static 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,
Takashi Iwai08c189f2012-12-19 15:22:24 +01001453 spec->gen.hp_jack_present);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001454}
1455
1456static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001457 const struct hda_fixup *fix, int action)
Takashi Iwai20f7d922012-02-16 12:35:16 +01001458{
1459 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001460 if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwai20f7d922012-02-16 12:35:16 +01001461 /* although the machine has only one output pin, we need to
1462 * toggle GPIO1 according to the jack state
1463 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01001464 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);
Takashi Iwaic9ce6b22012-12-18 18:12:44 +01001470 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001471 }
1472}
1473
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001474static void alc260_fixup_kn1(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001475 const struct hda_fixup *fix, int action)
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001476{
1477 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001478 static const struct hda_pintbl pincfgs[] = {
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001479 { 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) {
Takashi Iwai1727a772013-01-10 09:52:52 +01001495 case HDA_FIXUP_ACT_PRE_PROBE:
1496 snd_hda_apply_pincfgs(codec, pincfgs);
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001497 break;
Takashi Iwai1727a772013-01-10 09:52:52 +01001498 case HDA_FIXUP_ACT_PROBE:
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001499 spec->init_amp = ALC_INIT_NONE;
1500 break;
1501 }
1502}
1503
Takashi Iwai39aedee2013-01-10 17:10:40 +01001504static 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;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001508 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001509 spec->init_amp = ALC_INIT_NONE;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001510}
1511
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) {
Takashi Iwaif811c3c2013-03-07 18:32:59 +01001517 spec->gen.add_jack_modes = 1;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001518 spec->gen.hp_mic = 1;
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001519 }
Takashi Iwai39aedee2013-01-10 17:10:40 +01001520}
1521
Takashi Iwai1727a772013-01-10 09:52:52 +01001522static const struct hda_fixup alc260_fixups[] = {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001523 [ALC260_FIXUP_HP_DC5750] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001524 .type = HDA_FIXUP_PINS,
1525 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001526 { 0x11, 0x90130110 }, /* speaker */
1527 { }
1528 }
1529 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001530 [ALC260_FIXUP_HP_PIN_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001531 .type = HDA_FIXUP_PINS,
1532 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001533 { 0x0f, 0x01214000 }, /* HP */
1534 { }
1535 }
1536 },
1537 [ALC260_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001538 .type = HDA_FIXUP_VERBS,
Takashi Iwaica8f0422012-02-16 11:51:19 +01001539 .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 },
Takashi Iwai15317ab2012-02-16 12:02:53 +01001547 [ALC260_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001548 .type = HDA_FIXUP_VERBS,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001549 .v.verbs = alc_gpio1_init_verbs,
1550 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001551 [ALC260_FIXUP_GPIO1_TOGGLE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001552 .type = HDA_FIXUP_FUNC,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001553 .v.func = alc260_fixup_gpio1_toggle,
1554 .chained = true,
1555 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1556 },
1557 [ALC260_FIXUP_REPLACER] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001558 .type = HDA_FIXUP_VERBS,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001559 .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 },
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001567 [ALC260_FIXUP_HP_B1900] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001568 .type = HDA_FIXUP_FUNC,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001569 .v.func = alc260_fixup_gpio1_toggle,
1570 .chained = true,
1571 .chain_id = ALC260_FIXUP_COEF,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001572 },
1573 [ALC260_FIXUP_KN1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001574 .type = HDA_FIXUP_FUNC,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001575 .v.func = alc260_fixup_kn1,
1576 },
Takashi Iwai39aedee2013-01-10 17:10:40 +01001577 [ALC260_FIXUP_FSC_S7020] = {
1578 .type = HDA_FIXUP_FUNC,
1579 .v.func = alc260_fixup_fsc_s7020,
1580 },
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001581 [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 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02001587};
1588
1589static const struct snd_pci_quirk alc260_fixup_tbl[] = {
Takashi Iwai15317ab2012-02-16 12:02:53 +01001590 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001591 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
Takashi Iwai15317ab2012-02-16 12:02:53 +01001592 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001593 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001594 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
Takashi Iwai39aedee2013-01-10 17:10:40 +01001595 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
Takashi Iwaib1f58082012-02-16 12:45:03 +01001596 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001597 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
Takashi Iwai20f7d922012-02-16 12:35:16 +01001598 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001599 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001600 {}
1601};
1602
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001603static 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
Takashi Iwai1d045db2011-07-07 18:23:21 +02001611/*
1612 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001613static int patch_alc260(struct hda_codec *codec)
1614{
1615 struct alc_spec *spec;
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001616 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001617
Takashi Iwai3de95172012-05-07 18:03:15 +02001618 err = alc_alloc_spec(codec, 0x07);
1619 if (err < 0)
1620 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001621
Takashi Iwai3de95172012-05-07 18:03:15 +02001622 spec = codec->spec;
Takashi Iwaiea46c3c2013-01-15 18:45:53 +01001623 /* 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;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001628 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001629
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001630 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1631 alc260_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001632 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001633
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001634 /* automatic parse from the BIOS config */
1635 err = alc260_parse_auto_config(codec);
1636 if (err < 0)
1637 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001638
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001639 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001640 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001641
Takashi Iwai1d045db2011-07-07 18:23:21 +02001642 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001643 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001644
Takashi Iwai1727a772013-01-10 09:52:52 +01001645 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001646
Takashi Iwai1d045db2011-07-07 18:23:21 +02001647 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001648
1649 error:
1650 alc_free(codec);
1651 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001652}
1653
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 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001666
1667/*
1668 * Pin config fixes
1669 */
1670enum {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001671 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,
Marton Balint8f239212012-03-05 21:33:23 +01001676 ALC889_FIXUP_CD,
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001677 ALC889_FIXUP_VAIO_TT,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001678 ALC888_FIXUP_EEE1601,
Takashi Iwai177943a2011-11-09 12:55:18 +01001679 ALC882_FIXUP_EAPD,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01001680 ALC883_FIXUP_EAPD,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01001681 ALC883_FIXUP_ACER_EAPD,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001682 ALC882_FIXUP_GPIO1,
1683 ALC882_FIXUP_GPIO2,
Takashi Iwaieb844d52011-11-09 18:03:07 +01001684 ALC882_FIXUP_GPIO3,
Takashi Iwai68ef0562011-11-09 18:24:44 +01001685 ALC889_FIXUP_COEF,
1686 ALC882_FIXUP_ASUS_W2JC,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001687 ALC882_FIXUP_ACER_ASPIRE_4930G,
1688 ALC882_FIXUP_ACER_ASPIRE_8930G,
1689 ALC882_FIXUP_ASPIRE_8930G_VERBS,
Takashi Iwai56710872011-11-14 17:42:11 +01001690 ALC885_FIXUP_MACPRO_GPIO,
Takashi Iwai02a237b2012-02-13 15:25:07 +01001691 ALC889_FIXUP_DAC_ROUTE,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001692 ALC889_FIXUP_MBP_VREF,
1693 ALC889_FIXUP_IMAC91_VREF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02001694 ALC882_FIXUP_INV_DMIC,
Takashi Iwaie427c232012-07-29 10:04:08 +02001695 ALC882_FIXUP_NO_PRIMARY_HP,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001696};
1697
Takashi Iwai68ef0562011-11-09 18:24:44 +01001698static void alc889_fixup_coef(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001699 const struct hda_fixup *fix, int action)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001700{
Takashi Iwai1727a772013-01-10 09:52:52 +01001701 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001702 return;
1703 alc889_coef_init(codec);
1704}
1705
Takashi Iwai56710872011-11-14 17:42:11 +01001706/* 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,
Takashi Iwai1727a772013-01-10 09:52:52 +01001741 const struct hda_fixup *fix, int action)
Takashi Iwai56710872011-11-14 17:42:11 +01001742{
Takashi Iwai1727a772013-01-10 09:52:52 +01001743 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai56710872011-11-14 17:42:11 +01001744 return;
1745 alc882_gpio_mute(codec, 0, 0);
1746 alc882_gpio_mute(codec, 1, 0);
1747}
1748
Takashi Iwai02a237b2012-02-13 15:25:07 +01001749/* 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,
Takashi Iwai1727a772013-01-10 09:52:52 +01001754 const struct hda_fixup *fix, int action)
Takashi Iwai02a237b2012-02-13 15:25:07 +01001755{
Takashi Iwai1727a772013-01-10 09:52:52 +01001756 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001757 /* fake the connections during parsing the tree */
Takashi Iwai02a237b2012-02-13 15:25:07 +01001758 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);
Takashi Iwai1727a772013-01-10 09:52:52 +01001764 } else if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001765 /* 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);
Takashi Iwai02a237b2012-02-13 15:25:07 +01001771 }
1772}
1773
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001774/* Set VREF on HP pin */
1775static void alc889_fixup_mbp_vref(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001776 const struct hda_fixup *fix, int action)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001777{
1778 struct alc_spec *spec = codec->spec;
1779 static hda_nid_t nids[2] = { 0x14, 0x15 };
1780 int i;
1781
Takashi Iwai1727a772013-01-10 09:52:52 +01001782 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001783 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;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001788 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001789 val |= AC_PINCTL_VREF_80;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001790 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01001791 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001792 break;
1793 }
1794}
1795
1796/* Set VREF on speaker pins on imac91 */
1797static void alc889_fixup_imac91_vref(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001798 const struct hda_fixup *fix, int action)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001799{
1800 struct alc_spec *spec = codec->spec;
1801 static hda_nid_t nids[2] = { 0x18, 0x1a };
1802 int i;
1803
Takashi Iwai1727a772013-01-10 09:52:52 +01001804 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001805 return;
1806 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1807 unsigned int val;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001808 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001809 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001810 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001811 }
Takashi Iwai08c189f2012-12-19 15:22:24 +01001812 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001813}
1814
Takashi Iwaie427c232012-07-29 10:04:08 +02001815/* Don't take HP output as primary
Fernando Luis Vázquez Caod9111492013-02-12 16:49:46 +09001816 * 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
Takashi Iwaie427c232012-07-29 10:04:08 +02001818 */
1819static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001820 const struct hda_fixup *fix, int action)
Takashi Iwaie427c232012-07-29 10:04:08 +02001821{
1822 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001823 if (action == HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwai08c189f2012-12-19 15:22:24 +01001824 spec->gen.no_primary_hp = 1;
Takashi Iwaie427c232012-07-29 10:04:08 +02001825}
1826
Takashi Iwai1727a772013-01-10 09:52:52 +01001827static const struct hda_fixup alc882_fixups[] = {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001828 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001829 .type = HDA_FIXUP_PINS,
1830 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001831 { 0x15, 0x01080104 }, /* side */
1832 { 0x16, 0x01011012 }, /* rear */
1833 { 0x17, 0x01016011 }, /* clfe */
1834 { }
1835 }
1836 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001837 [ALC882_FIXUP_LENOVO_Y530] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001838 .type = HDA_FIXUP_PINS,
1839 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001840 { 0x15, 0x99130112 }, /* rear int speakers */
1841 { 0x16, 0x99130111 }, /* subwoofer */
1842 { }
1843 }
1844 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001845 [ALC882_FIXUP_PB_M5210] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01001846 .type = HDA_FIXUP_PINCTLS,
1847 .v.pins = (const struct hda_pintbl[]) {
1848 { 0x19, PIN_VREF50 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02001849 {}
1850 }
1851 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001852 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001853 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02001854 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001855 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001856 [ALC882_FIXUP_ASUS_W90V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001857 .type = HDA_FIXUP_PINS,
1858 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5cdf7452011-10-26 23:04:08 +02001859 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
1860 { }
1861 }
1862 },
Marton Balint8f239212012-03-05 21:33:23 +01001863 [ALC889_FIXUP_CD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001864 .type = HDA_FIXUP_PINS,
1865 .v.pins = (const struct hda_pintbl[]) {
Marton Balint8f239212012-03-05 21:33:23 +01001866 { 0x1c, 0x993301f0 }, /* CD */
1867 { }
1868 }
1869 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001870 [ALC889_FIXUP_VAIO_TT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001871 .type = HDA_FIXUP_PINS,
1872 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001873 { 0x17, 0x90170111 }, /* hidden surround speaker */
1874 { }
1875 }
1876 },
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001877 [ALC888_FIXUP_EEE1601] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001878 .type = HDA_FIXUP_VERBS,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001879 .v.verbs = (const struct hda_verb[]) {
1880 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1881 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
1882 { }
1883 }
Takashi Iwai177943a2011-11-09 12:55:18 +01001884 },
1885 [ALC882_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001886 .type = HDA_FIXUP_VERBS,
Takashi Iwai177943a2011-11-09 12:55:18 +01001887 .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 },
Takashi Iwai7a6069b2011-11-09 15:22:01 +01001894 [ALC883_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001895 .type = HDA_FIXUP_VERBS,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01001896 .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 },
Takashi Iwai8812c4f2011-11-09 17:39:15 +01001903 [ALC883_FIXUP_ACER_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001904 .type = HDA_FIXUP_VERBS,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01001905 .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 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001912 [ALC882_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001913 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001914 .v.verbs = alc_gpio1_init_verbs,
1915 },
1916 [ALC882_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001917 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001918 .v.verbs = alc_gpio2_init_verbs,
1919 },
Takashi Iwaieb844d52011-11-09 18:03:07 +01001920 [ALC882_FIXUP_GPIO3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001921 .type = HDA_FIXUP_VERBS,
Takashi Iwaieb844d52011-11-09 18:03:07 +01001922 .v.verbs = alc_gpio3_init_verbs,
1923 },
Takashi Iwai68ef0562011-11-09 18:24:44 +01001924 [ALC882_FIXUP_ASUS_W2JC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001925 .type = HDA_FIXUP_VERBS,
Takashi Iwai68ef0562011-11-09 18:24:44 +01001926 .v.verbs = alc_gpio1_init_verbs,
1927 .chained = true,
1928 .chain_id = ALC882_FIXUP_EAPD,
1929 },
1930 [ALC889_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001931 .type = HDA_FIXUP_FUNC,
Takashi Iwai68ef0562011-11-09 18:24:44 +01001932 .v.func = alc889_fixup_coef,
1933 },
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001934 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001935 .type = HDA_FIXUP_PINS,
1936 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001937 { 0x16, 0x99130111 }, /* CLFE speaker */
1938 { 0x17, 0x99130112 }, /* surround speaker */
1939 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02001940 },
1941 .chained = true,
1942 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001943 },
1944 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001945 .type = HDA_FIXUP_PINS,
1946 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001947 { 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 */
Takashi Iwai1727a772013-01-10 09:52:52 +01001956 .type = HDA_FIXUP_VERBS,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001957 .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 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02001985 },
1986 .chained = true,
1987 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001988 },
Takashi Iwai56710872011-11-14 17:42:11 +01001989 [ALC885_FIXUP_MACPRO_GPIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001990 .type = HDA_FIXUP_FUNC,
Takashi Iwai56710872011-11-14 17:42:11 +01001991 .v.func = alc885_fixup_macpro_gpio,
1992 },
Takashi Iwai02a237b2012-02-13 15:25:07 +01001993 [ALC889_FIXUP_DAC_ROUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001994 .type = HDA_FIXUP_FUNC,
Takashi Iwai02a237b2012-02-13 15:25:07 +01001995 .v.func = alc889_fixup_dac_route,
1996 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001997 [ALC889_FIXUP_MBP_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001998 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001999 .v.func = alc889_fixup_mbp_vref,
2000 .chained = true,
2001 .chain_id = ALC882_FIXUP_GPIO1,
2002 },
2003 [ALC889_FIXUP_IMAC91_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002004 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002005 .v.func = alc889_fixup_imac91_vref,
2006 .chained = true,
2007 .chain_id = ALC882_FIXUP_GPIO1,
2008 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002009 [ALC882_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002010 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002011 .v.func = alc_fixup_inv_dmic_0x12,
2012 },
Takashi Iwaie427c232012-07-29 10:04:08 +02002013 [ALC882_FIXUP_NO_PRIMARY_HP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002014 .type = HDA_FIXUP_FUNC,
Takashi Iwaie427c232012-07-29 10:04:08 +02002015 .v.func = alc882_fixup_no_primary_hp,
2016 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002017};
2018
2019static const struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002020 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),
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002026 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),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002040 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
Takashi Iwaif5c53d82012-05-07 10:07:33 +02002041 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2042 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai02a237b2012-02-13 15:25:07 +01002043 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
Takashi Iwaife97da12012-04-12 08:00:19 +02002044 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002045 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
Takashi Iwai177943a2011-11-09 12:55:18 +01002046 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002047 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002048 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002049 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002050 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
Takashi Iwaie427c232012-07-29 10:04:08 +02002051 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
Fernando Luis Vázquez Cao12e31a72013-02-12 16:47:44 +09002052 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
Takashi Iwai56710872011-11-14 17:42:11 +01002053
2054 /* All Apple entries are in codec SSIDs */
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002055 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),
Takashi Iwai56710872011-11-14 17:42:11 +01002058 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),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002061 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2062 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002063 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002064 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),
Takashi Iwai56710872011-11-14 17:42:11 +01002068 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002069 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),
Josh Boyer29ebe402012-04-12 13:55:36 -04002072 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai05193632012-11-12 10:07:36 +01002073 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002074 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),
Takashi Iwai56710872011-11-14 17:42:11 +01002077
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002078 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
Takashi Iwaibca40132012-05-07 11:13:14 +02002079 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Takashi Iwaieb844d52011-11-09 18:03:07 +01002080 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
Marton Balint8f239212012-03-05 21:33:23 +01002081 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002082 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002083 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2084 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002085 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002086 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002087 {}
2088};
2089
Takashi Iwai1727a772013-01-10 09:52:52 +01002090static const struct hda_model_fixup alc882_fixup_models[] = {
Takashi Iwai912093b2012-04-11 14:03:41 +02002091 {.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"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002094 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaie427c232012-07-29 10:04:08 +02002095 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
Takashi Iwai912093b2012-04-11 14:03:41 +02002096 {}
2097};
2098
Takashi Iwai1d045db2011-07-07 18:23:21 +02002099/*
2100 * BIOS auto configuration
2101 */
2102/* almost identical with ALC880 parser... */
2103static int alc882_parse_auto_config(struct hda_codec *codec)
2104{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002105 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002106 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2107 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002108}
2109
Takashi Iwai1d045db2011-07-07 18:23:21 +02002110/*
2111 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002112static int patch_alc882(struct hda_codec *codec)
2113{
2114 struct alc_spec *spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002115 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002116
Takashi Iwai3de95172012-05-07 18:03:15 +02002117 err = alc_alloc_spec(codec, 0x0b);
2118 if (err < 0)
2119 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002120
Takashi Iwai3de95172012-05-07 18:03:15 +02002121 spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002122
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;
2131 }
2132
Takashi Iwai1727a772013-01-10 09:52:52 +01002133 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
Takashi Iwai912093b2012-04-11 14:03:41 +02002134 alc882_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002136
2137 alc_auto_parse_customize_define(codec);
2138
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002139 if (has_cdefine_beep(codec))
2140 spec->gen.beep_nid = 0x01;
2141
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002142 /* automatic parse from the BIOS config */
2143 err = alc882_parse_auto_config(codec);
2144 if (err < 0)
2145 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002146
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002147 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002148 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2149
Takashi Iwai1d045db2011-07-07 18:23:21 +02002150 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002151
Takashi Iwai1727a772013-01-10 09:52:52 +01002152 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002153
Takashi Iwai1d045db2011-07-07 18:23:21 +02002154 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002155
2156 error:
2157 alc_free(codec);
2158 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002159}
2160
2161
2162/*
2163 * ALC262 support
2164 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002165static int alc262_parse_auto_config(struct hda_codec *codec)
2166{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002167 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002168 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2169 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002170}
2171
2172/*
2173 * Pin config fixes
2174 */
2175enum {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002176 ALC262_FIXUP_FSC_H270,
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002177 ALC262_FIXUP_FSC_S7110,
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002178 ALC262_FIXUP_HP_Z200,
2179 ALC262_FIXUP_TYAN,
Takashi Iwaic4701502011-11-07 14:20:07 +01002180 ALC262_FIXUP_LENOVO_3000,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002181 ALC262_FIXUP_BENQ,
2182 ALC262_FIXUP_BENQ_T31,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002183 ALC262_FIXUP_INV_DMIC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002184};
2185
Takashi Iwai1727a772013-01-10 09:52:52 +01002186static const struct hda_fixup alc262_fixups[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002187 [ALC262_FIXUP_FSC_H270] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002188 .type = HDA_FIXUP_PINS,
2189 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002190 { 0x14, 0x99130110 }, /* speaker */
2191 { 0x15, 0x0221142f }, /* front HP */
2192 { 0x1b, 0x0121141f }, /* rear HP */
2193 { }
2194 }
2195 },
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002196 [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 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002205 [ALC262_FIXUP_HP_Z200] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002206 .type = HDA_FIXUP_PINS,
2207 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002208 { 0x16, 0x99130120 }, /* internal speaker */
2209 { }
2210 }
2211 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002212 [ALC262_FIXUP_TYAN] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002213 .type = HDA_FIXUP_PINS,
2214 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002215 { 0x14, 0x1993e1f0 }, /* int AUX */
2216 { }
2217 }
2218 },
Takashi Iwaic4701502011-11-07 14:20:07 +01002219 [ALC262_FIXUP_LENOVO_3000] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002220 .type = HDA_FIXUP_PINCTLS,
2221 .v.pins = (const struct hda_pintbl[]) {
2222 { 0x19, PIN_VREF50 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002223 {}
2224 },
2225 .chained = true,
2226 .chain_id = ALC262_FIXUP_BENQ,
2227 },
2228 [ALC262_FIXUP_BENQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002229 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002230 .v.verbs = (const struct hda_verb[]) {
Takashi Iwaic4701502011-11-07 14:20:07 +01002231 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2232 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2233 {}
2234 }
2235 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002236 [ALC262_FIXUP_BENQ_T31] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002237 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002238 .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 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002244 [ALC262_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002245 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002246 .v.func = alc_fixup_inv_dmic_0x12,
2247 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002248};
2249
2250static const struct snd_pci_quirk alc262_fixup_tbl[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002251 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002252 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
Takashi Iwai3dcd3be2011-11-07 14:59:40 +01002253 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002254 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2255 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
Takashi Iwaic4701502011-11-07 14:20:07 +01002256 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
Takashi Iwaib42590b2011-11-07 14:41:01 +01002257 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2258 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002259 {}
2260};
2261
Takashi Iwai1727a772013-01-10 09:52:52 +01002262static const struct hda_model_fixup alc262_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002263 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2264 {}
2265};
Takashi Iwai1d045db2011-07-07 18:23:21 +02002266
Takashi Iwai1d045db2011-07-07 18:23:21 +02002267/*
2268 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002269static int patch_alc262(struct hda_codec *codec)
2270{
2271 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002272 int err;
2273
Takashi Iwai3de95172012-05-07 18:03:15 +02002274 err = alc_alloc_spec(codec, 0x0b);
2275 if (err < 0)
2276 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002277
Takashi Iwai3de95172012-05-07 18:03:15 +02002278 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01002279 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002280
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
Takashi Iwai1d045db2011-07-07 18:23:21 +02002293 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2294
Takashi Iwai1727a772013-01-10 09:52:52 +01002295 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002296 alc262_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002297 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002298
Takashi Iwaiaf741c12012-05-07 18:09:48 +02002299 alc_auto_parse_customize_define(codec);
2300
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002301 if (has_cdefine_beep(codec))
2302 spec->gen.beep_nid = 0x01;
2303
Takashi Iwai42399f72011-11-07 17:18:44 +01002304 /* automatic parse from the BIOS config */
2305 err = alc262_parse_auto_config(codec);
2306 if (err < 0)
2307 goto error;
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002308
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002309 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002310 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2311
Takashi Iwai1d045db2011-07-07 18:23:21 +02002312 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002313 spec->shutup = alc_eapd_shutup;
2314
Takashi Iwai1727a772013-01-10 09:52:52 +01002315 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002316
Takashi Iwai1d045db2011-07-07 18:23:21 +02002317 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002318
2319 error:
2320 alc_free(codec);
2321 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002322}
2323
2324/*
2325 * ALC268
2326 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002327/* 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 },
2335};
2336
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 { }
2341};
2342
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 { }
2349};
2350
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002351enum {
2352 ALC268_FIXUP_INV_DMIC,
Takashi Iwaicb766402012-10-20 10:55:21 +02002353 ALC268_FIXUP_HP_EAPD,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002354};
2355
Takashi Iwai1727a772013-01-10 09:52:52 +01002356static const struct hda_fixup alc268_fixups[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002357 [ALC268_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002358 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002359 .v.func = alc_fixup_inv_dmic_0x12,
2360 },
Takashi Iwaicb766402012-10-20 10:55:21 +02002361 [ALC268_FIXUP_HP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002362 .type = HDA_FIXUP_VERBS,
Takashi Iwaicb766402012-10-20 10:55:21 +02002363 .v.verbs = (const struct hda_verb[]) {
2364 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2365 {}
2366 }
2367 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002368};
2369
Takashi Iwai1727a772013-01-10 09:52:52 +01002370static const struct hda_model_fixup alc268_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002371 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaicb766402012-10-20 10:55:21 +02002372 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2373 {}
2374};
2375
2376static const struct snd_pci_quirk alc268_fixup_tbl[] = {
David Henningssonfcd8f3b2013-01-28 05:45:47 +01002377 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
Takashi Iwaicb766402012-10-20 10:55:21 +02002378 /* 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),
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002382 {}
2383};
2384
Takashi Iwai1d045db2011-07-07 18:23:21 +02002385/*
2386 * BIOS auto configuration
2387 */
2388static int alc268_parse_auto_config(struct hda_codec *codec)
2389{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002390 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002391 return alc_parse_auto_config(codec, NULL, alc268_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002392}
2393
Takashi Iwai1d045db2011-07-07 18:23:21 +02002394/*
2395 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002396static int patch_alc268(struct hda_codec *codec)
2397{
2398 struct alc_spec *spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002399 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002400
Takashi Iwai1d045db2011-07-07 18:23:21 +02002401 /* ALC268 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02002402 err = alc_alloc_spec(codec, 0);
2403 if (err < 0)
2404 return err;
2405
2406 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002407 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002408
Takashi Iwai1727a772013-01-10 09:52:52 +01002409 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2410 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002411
Takashi Iwai6ebb8052011-08-16 15:15:40 +02002412 /* automatic parse from the BIOS config */
2413 err = alc268_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002414 if (err < 0)
2415 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002416
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002417 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);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002421 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));
2428 }
2429
Takashi Iwai1d045db2011-07-07 18:23:21 +02002430 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002431 spec->shutup = alc_eapd_shutup;
2432
Takashi Iwai1727a772013-01-10 09:52:52 +01002433 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002434
Takashi Iwai1d045db2011-07-07 18:23:21 +02002435 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002436
2437 error:
2438 alc_free(codec);
2439 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002440}
2441
2442/*
2443 * ALC269
2444 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01002445
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
Takashi Iwai1d045db2011-07-07 18:23:21 +02002474static 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 = {
Takashi Iwai08c189f2012-12-19 15:22:24 +01002481 .open = playback_pcm_open,
2482 .prepare = playback_pcm_prepare,
2483 .cleanup = playback_pcm_cleanup
Takashi Iwai1d045db2011-07-07 18:23:21 +02002484 },
2485};
2486
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 */
2493};
2494
Takashi Iwai1d045db2011-07-07 18:23:21 +02002495/* different alc269-variants */
2496enum {
2497 ALC269_TYPE_ALC269VA,
2498 ALC269_TYPE_ALC269VB,
2499 ALC269_TYPE_ALC269VC,
Kailang Yangadcc70b2012-05-25 08:08:38 +02002500 ALC269_TYPE_ALC269VD,
Kailang Yang065380f2013-01-10 10:25:48 +01002501 ALC269_TYPE_ALC280,
2502 ALC269_TYPE_ALC282,
2503 ALC269_TYPE_ALC284,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002504};
2505
2506/*
2507 * BIOS auto configuration
2508 */
2509static int alc269_parse_auto_config(struct hda_codec *codec)
2510{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002511 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002512 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;
Kailang Yangadcc70b2012-05-25 08:08:38 +02002515 const hda_nid_t *ssids;
2516
2517 switch (spec->codec_variant) {
2518 case ALC269_TYPE_ALC269VA:
2519 case ALC269_TYPE_ALC269VC:
Kailang Yang065380f2013-01-10 10:25:48 +01002520 case ALC269_TYPE_ALC280:
2521 case ALC269_TYPE_ALC284:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002522 ssids = alc269va_ssids;
2523 break;
2524 case ALC269_TYPE_ALC269VB:
2525 case ALC269_TYPE_ALC269VD:
Kailang Yang065380f2013-01-10 10:25:48 +01002526 case ALC269_TYPE_ALC282:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002527 ssids = alc269_ssids;
2528 break;
2529 default:
2530 ssids = alc269_ssids;
2531 break;
2532 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02002533
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002534 return alc_parse_auto_config(codec, alc269_ignore, ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002535}
2536
Kailang Yang1387e2d2012-11-08 10:23:18 +01002537static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002538{
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}
2546
2547static void alc269_shutup(struct hda_codec *codec)
2548{
Kailang Yangadcc70b2012-05-25 08:08:38 +02002549 struct alc_spec *spec = codec->spec;
2550
2551 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
2552 return;
2553
Kailang Yang1387e2d2012-11-08 10:23:18 +01002554 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) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002558 msleep(150);
2559 }
2560}
2561
Takashi Iwai2a439522011-07-26 09:52:50 +02002562#ifdef CONFIG_PM
Takashi Iwai1d045db2011-07-07 18:23:21 +02002563static int alc269_resume(struct hda_codec *codec)
2564{
Kailang Yangadcc70b2012-05-25 08:08:38 +02002565 struct alc_spec *spec = codec->spec;
2566
Kailang Yang1387e2d2012-11-08 10:23:18 +01002567 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2568 alc269vb_toggle_power_output(codec, 0);
2569 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02002570 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002571 msleep(150);
2572 }
2573
2574 codec->patch_ops.init(codec);
2575
Kailang Yang1387e2d2012-11-08 10:23:18 +01002576 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2577 alc269vb_toggle_power_output(codec, 1);
2578 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02002579 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002580 msleep(200);
2581 }
2582
Takashi Iwai1d045db2011-07-07 18:23:21 +02002583 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}
Takashi Iwai2a439522011-07-26 09:52:50 +02002588#endif /* CONFIG_PM */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002589
David Henningsson108cc102012-07-20 10:37:25 +02002590static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002591 const struct hda_fixup *fix, int action)
David Henningsson108cc102012-07-20 10:37:25 +02002592{
2593 struct alc_spec *spec = codec->spec;
2594
Takashi Iwai1727a772013-01-10 09:52:52 +01002595 if (action == HDA_FIXUP_ACT_PRE_PROBE)
David Henningsson108cc102012-07-20 10:37:25 +02002596 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
2597}
2598
Takashi Iwai1d045db2011-07-07 18:23:21 +02002599static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002600 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002601{
2602 int coef;
2603
Takashi Iwai1727a772013-01-10 09:52:52 +01002604 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002605 return;
2606 coef = alc_read_coef_idx(codec, 0x1e);
2607 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
2608}
2609
2610static void alc271_fixup_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002611 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002612{
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;
2619
2620 if (strcmp(codec->chip_name, "ALC271X"))
2621 return;
2622 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
2623 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
2624 snd_hda_sequence_write(codec, verbs);
2625}
2626
Takashi Iwai017f2a12011-07-09 14:42:25 +02002627static void alc269_fixup_pcm_44k(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002628 const struct hda_fixup *fix, int action)
Takashi Iwai017f2a12011-07-09 14:42:25 +02002629{
2630 struct alc_spec *spec = codec->spec;
2631
Takashi Iwai1727a772013-01-10 09:52:52 +01002632 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai017f2a12011-07-09 14:42:25 +02002633 return;
2634
2635 /* Due to a hardware problem on Lenovo Ideadpad, we need to
2636 * fix the sample rate of analog I/O to 44.1kHz
2637 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01002638 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
2639 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai017f2a12011-07-09 14:42:25 +02002640}
2641
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02002642static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002643 const struct hda_fixup *fix, int action)
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02002644{
2645 int coef;
2646
Takashi Iwai1727a772013-01-10 09:52:52 +01002647 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02002648 return;
2649 /* The digital-mic unit sends PDM (differential signal) instead of
2650 * the standard PCM, thus you can't record a valid mono stream as is.
2651 * Below is a workaround specific to ALC269 to control the dmic
2652 * signal source as mono.
2653 */
2654 coef = alc_read_coef_idx(codec, 0x07);
2655 alc_write_coef_idx(codec, 0x07, coef | 0x80);
2656}
2657
Takashi Iwai24519912011-08-16 15:08:49 +02002658static void alc269_quanta_automute(struct hda_codec *codec)
2659{
Takashi Iwai08c189f2012-12-19 15:22:24 +01002660 snd_hda_gen_update_outputs(codec);
Takashi Iwai24519912011-08-16 15:08:49 +02002661
2662 snd_hda_codec_write(codec, 0x20, 0,
2663 AC_VERB_SET_COEF_INDEX, 0x0c);
2664 snd_hda_codec_write(codec, 0x20, 0,
2665 AC_VERB_SET_PROC_COEF, 0x680);
2666
2667 snd_hda_codec_write(codec, 0x20, 0,
2668 AC_VERB_SET_COEF_INDEX, 0x0c);
2669 snd_hda_codec_write(codec, 0x20, 0,
2670 AC_VERB_SET_PROC_COEF, 0x480);
2671}
2672
2673static void alc269_fixup_quanta_mute(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002674 const struct hda_fixup *fix, int action)
Takashi Iwai24519912011-08-16 15:08:49 +02002675{
2676 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01002677 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai24519912011-08-16 15:08:49 +02002678 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +01002679 spec->gen.automute_hook = alc269_quanta_automute;
Takashi Iwai24519912011-08-16 15:08:49 +02002680}
2681
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002682/* update mute-LED according to the speaker mute state via mic VREF pin */
2683static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01002684{
2685 struct hda_codec *codec = private_data;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002686 struct alc_spec *spec = codec->spec;
2687 unsigned int pinval;
2688
2689 if (spec->mute_led_polarity)
2690 enabled = !enabled;
2691 pinval = AC_PINCTL_IN_EN |
2692 (enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80);
2693 if (spec->mute_led_nid)
2694 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01002695}
2696
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002697static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
2698 const struct hda_fixup *fix, int action)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01002699{
2700 struct alc_spec *spec = codec->spec;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002701 const struct dmi_device *dev = NULL;
2702
2703 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2704 return;
2705
2706 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
2707 int pol, pin;
2708 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
2709 continue;
2710 if (pin < 0x0a || pin >= 0x10)
2711 break;
2712 spec->mute_led_polarity = pol;
2713 spec->mute_led_nid = pin - 0x0a + 0x18;
2714 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01002715 spec->gen.vmaster_mute_enum = 1;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002716 snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
2717 spec->mute_led_polarity);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01002718 break;
2719 }
2720}
2721
David Henningssond06ac142013-02-18 11:41:55 +01002722static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
2723 const struct hda_fixup *fix, int action)
2724{
2725 struct alc_spec *spec = codec->spec;
2726 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2727 spec->mute_led_polarity = 0;
2728 spec->mute_led_nid = 0x18;
2729 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2730 spec->gen.vmaster_mute_enum = 1;
2731 }
2732}
2733
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002734static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
2735 const struct hda_fixup *fix, int action)
Takashi Iwai420b0fe2012-03-12 12:35:27 +01002736{
2737 struct alc_spec *spec = codec->spec;
Takashi Iwai9bb1f062013-01-10 17:14:29 +01002738 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002739 spec->mute_led_polarity = 0;
2740 spec->mute_led_nid = 0x19;
2741 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01002742 spec->gen.vmaster_mute_enum = 1;
Takashi Iwai420b0fe2012-03-12 12:35:27 +01002743 }
2744}
2745
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01002746/* turn on/off mute LED per vmaster hook */
2747static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
2748{
2749 struct hda_codec *codec = private_data;
2750 struct alc_spec *spec = codec->spec;
2751 unsigned int oldval = spec->gpio_led;
2752
2753 if (enabled)
2754 spec->gpio_led &= ~0x08;
2755 else
2756 spec->gpio_led |= 0x08;
2757 if (spec->gpio_led != oldval)
2758 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2759 spec->gpio_led);
2760}
2761
2762/* turn on/off mic-mute LED per capture hook */
2763static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
2764 struct snd_ctl_elem_value *ucontrol)
2765{
2766 struct alc_spec *spec = codec->spec;
2767 unsigned int oldval = spec->gpio_led;
2768
2769 if (!ucontrol)
2770 return;
2771
2772 if (ucontrol->value.integer.value[0] ||
2773 ucontrol->value.integer.value[1])
2774 spec->gpio_led &= ~0x10;
2775 else
2776 spec->gpio_led |= 0x10;
2777 if (spec->gpio_led != oldval)
2778 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2779 spec->gpio_led);
2780}
2781
2782static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
2783 const struct hda_fixup *fix, int action)
2784{
2785 struct alc_spec *spec = codec->spec;
2786 static const struct hda_verb gpio_init[] = {
2787 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
2788 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
2789 {}
2790 };
2791
2792 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2793 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
2794 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
2795 spec->gpio_led = 0;
2796 snd_hda_add_verbs(codec, gpio_init);
2797 }
2798}
2799
Dylan Reid08a978d2012-11-18 22:56:40 -08002800static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01002801 const struct hda_fixup *fix,
Dylan Reid08a978d2012-11-18 22:56:40 -08002802 int action)
2803{
2804 struct alc_spec *spec = codec->spec;
2805
Takashi Iwai0db75792013-01-23 13:57:20 +01002806 if (action == HDA_FIXUP_ACT_PROBE) {
2807 if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
2808 !spec->gen.autocfg.hp_pins[0]))
2809 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +01002810 snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin,
2811 spec->gen.autocfg.hp_pins[0]);
Takashi Iwai0db75792013-01-23 13:57:20 +01002812 }
Dylan Reid08a978d2012-11-18 22:56:40 -08002813}
David Henningsson693b6132012-06-22 19:12:10 +02002814
Takashi Iwai1d045db2011-07-07 18:23:21 +02002815enum {
2816 ALC269_FIXUP_SONY_VAIO,
2817 ALC275_FIXUP_SONY_VAIO_GPIO2,
2818 ALC269_FIXUP_DELL_M101Z,
2819 ALC269_FIXUP_SKU_IGNORE,
2820 ALC269_FIXUP_ASUS_G73JW,
2821 ALC269_FIXUP_LENOVO_EAPD,
2822 ALC275_FIXUP_SONY_HWEQ,
2823 ALC271_FIXUP_DMIC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02002824 ALC269_FIXUP_PCM_44K,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02002825 ALC269_FIXUP_STEREO_DMIC,
Takashi Iwai24519912011-08-16 15:08:49 +02002826 ALC269_FIXUP_QUANTA_MUTE,
2827 ALC269_FIXUP_LIFEBOOK,
Takashi Iwaia4297b52011-08-23 18:40:12 +02002828 ALC269_FIXUP_AMIC,
2829 ALC269_FIXUP_DMIC,
2830 ALC269VB_FIXUP_AMIC,
2831 ALC269VB_FIXUP_DMIC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002832 ALC269_FIXUP_HP_MUTE_LED,
David Henningssond06ac142013-02-18 11:41:55 +01002833 ALC269_FIXUP_HP_MUTE_LED_MIC1,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002834 ALC269_FIXUP_HP_MUTE_LED_MIC2,
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01002835 ALC269_FIXUP_HP_GPIO_LED,
David Henningsson693b6132012-06-22 19:12:10 +02002836 ALC269_FIXUP_INV_DMIC,
David Henningsson108cc102012-07-20 10:37:25 +02002837 ALC269_FIXUP_LENOVO_DOCK,
2838 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
Dylan Reid08a978d2012-11-18 22:56:40 -08002839 ALC271_FIXUP_AMIC_MIC2,
2840 ALC271_FIXUP_HP_GATE_MIC_JACK,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002841};
2842
Takashi Iwai1727a772013-01-10 09:52:52 +01002843static const struct hda_fixup alc269_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002844 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002845 .type = HDA_FIXUP_PINCTLS,
2846 .v.pins = (const struct hda_pintbl[]) {
2847 {0x19, PIN_VREFGRD},
Takashi Iwai1d045db2011-07-07 18:23:21 +02002848 {}
2849 }
2850 },
2851 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002852 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002853 .v.verbs = (const struct hda_verb[]) {
2854 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
2855 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
2856 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
2857 { }
2858 },
2859 .chained = true,
2860 .chain_id = ALC269_FIXUP_SONY_VAIO
2861 },
2862 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002863 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002864 .v.verbs = (const struct hda_verb[]) {
2865 /* Enables internal speaker */
2866 {0x20, AC_VERB_SET_COEF_INDEX, 13},
2867 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
2868 {}
2869 }
2870 },
2871 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002872 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02002873 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002874 },
2875 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002876 .type = HDA_FIXUP_PINS,
2877 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002878 { 0x17, 0x99130111 }, /* subwoofer */
2879 { }
2880 }
2881 },
2882 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002883 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002884 .v.verbs = (const struct hda_verb[]) {
2885 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
2886 {}
2887 }
2888 },
2889 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002890 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002891 .v.func = alc269_fixup_hweq,
2892 .chained = true,
2893 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
2894 },
2895 [ALC271_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002896 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002897 .v.func = alc271_fixup_dmic,
2898 },
Takashi Iwai017f2a12011-07-09 14:42:25 +02002899 [ALC269_FIXUP_PCM_44K] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002900 .type = HDA_FIXUP_FUNC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02002901 .v.func = alc269_fixup_pcm_44k,
David Henningsson012e7eb2012-08-08 08:43:37 +02002902 .chained = true,
2903 .chain_id = ALC269_FIXUP_QUANTA_MUTE
Takashi Iwai017f2a12011-07-09 14:42:25 +02002904 },
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02002905 [ALC269_FIXUP_STEREO_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002906 .type = HDA_FIXUP_FUNC,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02002907 .v.func = alc269_fixup_stereo_dmic,
2908 },
Takashi Iwai24519912011-08-16 15:08:49 +02002909 [ALC269_FIXUP_QUANTA_MUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002910 .type = HDA_FIXUP_FUNC,
Takashi Iwai24519912011-08-16 15:08:49 +02002911 .v.func = alc269_fixup_quanta_mute,
2912 },
2913 [ALC269_FIXUP_LIFEBOOK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002914 .type = HDA_FIXUP_PINS,
2915 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai24519912011-08-16 15:08:49 +02002916 { 0x1a, 0x2101103f }, /* dock line-out */
2917 { 0x1b, 0x23a11040 }, /* dock mic-in */
2918 { }
2919 },
2920 .chained = true,
2921 .chain_id = ALC269_FIXUP_QUANTA_MUTE
2922 },
Takashi Iwaia4297b52011-08-23 18:40:12 +02002923 [ALC269_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002924 .type = HDA_FIXUP_PINS,
2925 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02002926 { 0x14, 0x99130110 }, /* speaker */
2927 { 0x15, 0x0121401f }, /* HP out */
2928 { 0x18, 0x01a19c20 }, /* mic */
2929 { 0x19, 0x99a3092f }, /* int-mic */
2930 { }
2931 },
2932 },
2933 [ALC269_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002934 .type = HDA_FIXUP_PINS,
2935 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02002936 { 0x12, 0x99a3092f }, /* int-mic */
2937 { 0x14, 0x99130110 }, /* speaker */
2938 { 0x15, 0x0121401f }, /* HP out */
2939 { 0x18, 0x01a19c20 }, /* mic */
2940 { }
2941 },
2942 },
2943 [ALC269VB_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002944 .type = HDA_FIXUP_PINS,
2945 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02002946 { 0x14, 0x99130110 }, /* speaker */
2947 { 0x18, 0x01a19c20 }, /* mic */
2948 { 0x19, 0x99a3092f }, /* int-mic */
2949 { 0x21, 0x0121401f }, /* HP out */
2950 { }
2951 },
2952 },
David Henningsson2267ea92012-01-03 08:45:56 +01002953 [ALC269VB_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002954 .type = HDA_FIXUP_PINS,
2955 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02002956 { 0x12, 0x99a3092f }, /* int-mic */
2957 { 0x14, 0x99130110 }, /* speaker */
2958 { 0x18, 0x01a19c20 }, /* mic */
2959 { 0x21, 0x0121401f }, /* HP out */
2960 { }
2961 },
2962 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002963 [ALC269_FIXUP_HP_MUTE_LED] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002964 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002965 .v.func = alc269_fixup_hp_mute_led,
David Henningsson6d3cd5d2013-01-07 12:03:47 +01002966 },
David Henningssond06ac142013-02-18 11:41:55 +01002967 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
2968 .type = HDA_FIXUP_FUNC,
2969 .v.func = alc269_fixup_hp_mute_led_mic1,
2970 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002971 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002972 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01002973 .v.func = alc269_fixup_hp_mute_led_mic2,
Takashi Iwai420b0fe2012-03-12 12:35:27 +01002974 },
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01002975 [ALC269_FIXUP_HP_GPIO_LED] = {
2976 .type = HDA_FIXUP_FUNC,
2977 .v.func = alc269_fixup_hp_gpio_led,
2978 },
David Henningsson693b6132012-06-22 19:12:10 +02002979 [ALC269_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002980 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002981 .v.func = alc_fixup_inv_dmic_0x12,
David Henningsson693b6132012-06-22 19:12:10 +02002982 },
David Henningsson108cc102012-07-20 10:37:25 +02002983 [ALC269_FIXUP_LENOVO_DOCK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002984 .type = HDA_FIXUP_PINS,
2985 .v.pins = (const struct hda_pintbl[]) {
David Henningsson108cc102012-07-20 10:37:25 +02002986 { 0x19, 0x23a11040 }, /* dock mic */
2987 { 0x1b, 0x2121103f }, /* dock headphone */
2988 { }
2989 },
2990 .chained = true,
2991 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
2992 },
2993 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002994 .type = HDA_FIXUP_FUNC,
David Henningsson108cc102012-07-20 10:37:25 +02002995 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
2996 },
Dylan Reid08a978d2012-11-18 22:56:40 -08002997 [ALC271_FIXUP_AMIC_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002998 .type = HDA_FIXUP_PINS,
2999 .v.pins = (const struct hda_pintbl[]) {
Dylan Reid08a978d2012-11-18 22:56:40 -08003000 { 0x14, 0x99130110 }, /* speaker */
3001 { 0x19, 0x01a19c20 }, /* mic */
3002 { 0x1b, 0x99a7012f }, /* int-mic */
3003 { 0x21, 0x0121401f }, /* HP out */
3004 { }
3005 },
3006 },
3007 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003008 .type = HDA_FIXUP_FUNC,
Dylan Reid08a978d2012-11-18 22:56:40 -08003009 .v.func = alc271_hp_gate_mic_jack,
3010 .chained = true,
3011 .chain_id = ALC271_FIXUP_AMIC_MIC2,
3012 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02003013};
3014
3015static const struct snd_pci_quirk alc269_fixup_tbl[] = {
David Henningsson693b6132012-06-22 19:12:10 +02003016 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
3017 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003018 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003019 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
David Henningssond06ac142013-02-18 11:41:55 +01003020 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
3021 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003022 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
David Henningsson5ac57552012-04-20 10:01:46 +02003023 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
Oleksij Rempel148728f2012-09-21 17:44:58 +02003024 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC),
Takashi Iwai017f2a12011-07-09 14:42:25 +02003025 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
David Henningsson693b6132012-06-22 19:12:10 +02003026 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003027 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
3028 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
3029 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
3030 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
3031 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003032 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
3033 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3034 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3035 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
3036 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiec50b4c2013-01-19 12:17:54 +01003037 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
Dylan Reid08a978d2012-11-18 22:56:40 -08003038 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003039 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
Takashi Iwai24519912011-08-16 15:08:49 +02003040 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003041 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
3042 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
3043 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
3044 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
3045 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
Takashi Iwai707fba32012-08-02 09:04:39 +02003046 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
Felix Kaechelec8415a42012-08-06 23:02:01 +02003047 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
Stefán Freyr84f98fd2012-10-19 22:46:00 +02003048 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
Philipp A. Mohrenweiser4407be62012-08-06 13:14:18 +02003049 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
David Henningsson108cc102012-07-20 10:37:25 +02003050 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
David Henningsson012e7eb2012-08-08 08:43:37 +02003051 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003052 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaia4297b52011-08-23 18:40:12 +02003053
Takashi Iwaia7f3eed2012-02-16 13:03:18 +01003054#if 0
Takashi Iwaia4297b52011-08-23 18:40:12 +02003055 /* Below is a quirk table taken from the old code.
3056 * Basically the device should work as is without the fixup table.
3057 * If BIOS doesn't give a proper info, enable the corresponding
3058 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02003059 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02003060 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
3061 ALC269_FIXUP_AMIC),
3062 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
Takashi Iwaia4297b52011-08-23 18:40:12 +02003063 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
3064 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
3065 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
3066 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
3067 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
3068 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
3069 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
3070 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
3071 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
3072 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
3073 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
3074 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
3075 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
3076 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
3077 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
3078 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
3079 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
3080 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
3081 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
3082 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
3083 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
3084 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
3085 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
3086 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
3087 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
3088 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
3089 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
3090 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
3091 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
3092 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
3093 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
3094 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
3095 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
3096 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
3097 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
3098 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
3099 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
3100 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
3101#endif
3102 {}
3103};
3104
Takashi Iwai1727a772013-01-10 09:52:52 +01003105static const struct hda_model_fixup alc269_fixup_models[] = {
Takashi Iwaia4297b52011-08-23 18:40:12 +02003106 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
3107 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02003108 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
3109 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
3110 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningsson108cc102012-07-20 10:37:25 +02003111 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003112 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
Takashi Iwai1d045db2011-07-07 18:23:21 +02003113 {}
3114};
3115
3116
Takashi Iwai546bb672012-03-07 08:37:19 +01003117static void alc269_fill_coef(struct hda_codec *codec)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003118{
Kailang Yang526af6e2012-03-07 08:25:20 +01003119 struct alc_spec *spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003120 int val;
3121
Kailang Yang526af6e2012-03-07 08:25:20 +01003122 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
Takashi Iwai546bb672012-03-07 08:37:19 +01003123 return;
Kailang Yang526af6e2012-03-07 08:25:20 +01003124
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003125 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003126 alc_write_coef_idx(codec, 0xf, 0x960b);
3127 alc_write_coef_idx(codec, 0xe, 0x8817);
3128 }
3129
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003130 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003131 alc_write_coef_idx(codec, 0xf, 0x960b);
3132 alc_write_coef_idx(codec, 0xe, 0x8814);
3133 }
3134
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003135 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003136 val = alc_read_coef_idx(codec, 0x04);
3137 /* Power up output pin */
3138 alc_write_coef_idx(codec, 0x04, val | (1<<11));
3139 }
3140
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003141 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003142 val = alc_read_coef_idx(codec, 0xd);
3143 if ((val & 0x0c00) >> 10 != 0x1) {
3144 /* Capless ramp up clock control */
3145 alc_write_coef_idx(codec, 0xd, val | (1<<10));
3146 }
3147 val = alc_read_coef_idx(codec, 0x17);
3148 if ((val & 0x01c0) >> 6 != 0x4) {
3149 /* Class D power on reset */
3150 alc_write_coef_idx(codec, 0x17, val | (1<<7));
3151 }
3152 }
3153
3154 val = alc_read_coef_idx(codec, 0xd); /* Class D */
3155 alc_write_coef_idx(codec, 0xd, val | (1<<14));
3156
3157 val = alc_read_coef_idx(codec, 0x4); /* HP */
3158 alc_write_coef_idx(codec, 0x4, val | (1<<11));
Takashi Iwai1d045db2011-07-07 18:23:21 +02003159}
3160
3161/*
3162 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003163static int patch_alc269(struct hda_codec *codec)
3164{
3165 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02003166 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003167
Takashi Iwai3de95172012-05-07 18:03:15 +02003168 err = alc_alloc_spec(codec, 0x0b);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003169 if (err < 0)
Takashi Iwai3de95172012-05-07 18:03:15 +02003170 return err;
3171
3172 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01003173 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003174
Takashi Iwai1727a772013-01-10 09:52:52 +01003175 snd_hda_pick_fixup(codec, alc269_fixup_models,
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03003176 alc269_fixup_tbl, alc269_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01003177 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03003178
3179 alc_auto_parse_customize_define(codec);
3180
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003181 if (has_cdefine_beep(codec))
3182 spec->gen.beep_nid = 0x01;
3183
Kailang Yang065380f2013-01-10 10:25:48 +01003184 switch (codec->vendor_id) {
3185 case 0x10ec0269:
Takashi Iwai1d045db2011-07-07 18:23:21 +02003186 spec->codec_variant = ALC269_TYPE_ALC269VA;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003187 switch (alc_get_coef0(codec) & 0x00f0) {
3188 case 0x0010:
Takashi Iwai1d045db2011-07-07 18:23:21 +02003189 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003190 spec->cdefine.platform_type == 1)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02003191 err = alc_codec_rename(codec, "ALC271X");
Takashi Iwai1d045db2011-07-07 18:23:21 +02003192 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003193 break;
3194 case 0x0020:
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003195 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
3196 codec->bus->pci->subsystem_device == 0x21f3)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02003197 err = alc_codec_rename(codec, "ALC3202");
Takashi Iwai1d045db2011-07-07 18:23:21 +02003198 spec->codec_variant = ALC269_TYPE_ALC269VC;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003199 break;
Kailang Yangadcc70b2012-05-25 08:08:38 +02003200 case 0x0030:
3201 spec->codec_variant = ALC269_TYPE_ALC269VD;
3202 break;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003203 default:
Takashi Iwai1d045db2011-07-07 18:23:21 +02003204 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003205 }
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003206 if (err < 0)
3207 goto error;
Takashi Iwai546bb672012-03-07 08:37:19 +01003208 spec->init_hook = alc269_fill_coef;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003209 alc269_fill_coef(codec);
Kailang Yang065380f2013-01-10 10:25:48 +01003210 break;
3211
3212 case 0x10ec0280:
3213 case 0x10ec0290:
3214 spec->codec_variant = ALC269_TYPE_ALC280;
3215 break;
Kailang Yang84dfd0a2013-03-07 09:19:38 +01003216 case 0x10ec0233:
Kailang Yang065380f2013-01-10 10:25:48 +01003217 case 0x10ec0282:
3218 case 0x10ec0283:
3219 spec->codec_variant = ALC269_TYPE_ALC282;
3220 break;
3221 case 0x10ec0284:
3222 case 0x10ec0292:
3223 spec->codec_variant = ALC269_TYPE_ALC284;
3224 break;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003225 }
3226
Takashi Iwaia4297b52011-08-23 18:40:12 +02003227 /* automatic parse from the BIOS config */
3228 err = alc269_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003229 if (err < 0)
3230 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003231
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003232 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003233 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
3234
Takashi Iwai1d045db2011-07-07 18:23:21 +02003235 codec->patch_ops = alc_patch_ops;
Takashi Iwai2a439522011-07-26 09:52:50 +02003236#ifdef CONFIG_PM
Takashi Iwai1d045db2011-07-07 18:23:21 +02003237 codec->patch_ops.resume = alc269_resume;
3238#endif
Takashi Iwai1d045db2011-07-07 18:23:21 +02003239 spec->shutup = alc269_shutup;
3240
Takashi Iwai1727a772013-01-10 09:52:52 +01003241 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01003242
Takashi Iwai1d045db2011-07-07 18:23:21 +02003243 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003244
3245 error:
3246 alc_free(codec);
3247 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003248}
3249
3250/*
3251 * ALC861
3252 */
3253
Takashi Iwai1d045db2011-07-07 18:23:21 +02003254static int alc861_parse_auto_config(struct hda_codec *codec)
3255{
Takashi Iwai1d045db2011-07-07 18:23:21 +02003256 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003257 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
3258 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003259}
3260
Takashi Iwai1d045db2011-07-07 18:23:21 +02003261/* Pin config fixes */
3262enum {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003263 ALC861_FIXUP_FSC_AMILO_PI1505,
3264 ALC861_FIXUP_AMP_VREF_0F,
3265 ALC861_FIXUP_NO_JACK_DETECT,
3266 ALC861_FIXUP_ASUS_A6RP,
Takashi Iwai1d045db2011-07-07 18:23:21 +02003267};
3268
Takashi Iwai31150f22012-01-30 10:54:08 +01003269/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
3270static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003271 const struct hda_fixup *fix, int action)
Takashi Iwai31150f22012-01-30 10:54:08 +01003272{
3273 struct alc_spec *spec = codec->spec;
3274 unsigned int val;
3275
Takashi Iwai1727a772013-01-10 09:52:52 +01003276 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai31150f22012-01-30 10:54:08 +01003277 return;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01003278 val = snd_hda_codec_get_pin_target(codec, 0x0f);
Takashi Iwai31150f22012-01-30 10:54:08 +01003279 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
3280 val |= AC_PINCTL_IN_EN;
3281 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003282 snd_hda_set_pin_ctl(codec, 0x0f, val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01003283 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai31150f22012-01-30 10:54:08 +01003284}
3285
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003286/* suppress the jack-detection */
3287static void alc_fixup_no_jack_detect(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003288 const struct hda_fixup *fix, int action)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003289{
Takashi Iwai1727a772013-01-10 09:52:52 +01003290 if (action == HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003291 codec->no_jack_detect = 1;
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02003292}
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003293
Takashi Iwai1727a772013-01-10 09:52:52 +01003294static const struct hda_fixup alc861_fixups[] = {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003295 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003296 .type = HDA_FIXUP_PINS,
3297 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003298 { 0x0b, 0x0221101f }, /* HP */
3299 { 0x0f, 0x90170310 }, /* speaker */
3300 { }
3301 }
3302 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003303 [ALC861_FIXUP_AMP_VREF_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003304 .type = HDA_FIXUP_FUNC,
Takashi Iwai31150f22012-01-30 10:54:08 +01003305 .v.func = alc861_fixup_asus_amp_vref_0f,
Takashi Iwai3b25eb62012-01-25 09:55:46 +01003306 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003307 [ALC861_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003308 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003309 .v.func = alc_fixup_no_jack_detect,
3310 },
3311 [ALC861_FIXUP_ASUS_A6RP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003312 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003313 .v.func = alc861_fixup_asus_amp_vref_0f,
3314 .chained = true,
3315 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
3316 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02003317};
3318
3319static const struct snd_pci_quirk alc861_fixup_tbl[] = {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01003320 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
3321 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
3322 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
3323 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
3324 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
3325 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003326 {}
3327};
3328
3329/*
3330 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003331static int patch_alc861(struct hda_codec *codec)
3332{
3333 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003334 int err;
3335
Takashi Iwai3de95172012-05-07 18:03:15 +02003336 err = alc_alloc_spec(codec, 0x15);
3337 if (err < 0)
3338 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003339
Takashi Iwai3de95172012-05-07 18:03:15 +02003340 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003341 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003342
Takashi Iwai1727a772013-01-10 09:52:52 +01003343 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
3344 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003345
Takashi Iwaicb4e4822011-08-23 17:34:25 +02003346 /* automatic parse from the BIOS config */
3347 err = alc861_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003348 if (err < 0)
3349 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003350
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003351 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003352 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003353
Takashi Iwai1d045db2011-07-07 18:23:21 +02003354 codec->patch_ops = alc_patch_ops;
Takashi Iwai83012a72012-08-24 18:38:08 +02003355#ifdef CONFIG_PM
Takashi Iwaicb4e4822011-08-23 17:34:25 +02003356 spec->power_hook = alc_power_eapd;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003357#endif
3358
Takashi Iwai1727a772013-01-10 09:52:52 +01003359 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01003360
Takashi Iwai1d045db2011-07-07 18:23:21 +02003361 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003362
3363 error:
3364 alc_free(codec);
3365 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003366}
3367
3368/*
3369 * ALC861-VD support
3370 *
3371 * Based on ALC882
3372 *
3373 * In addition, an independent DAC
3374 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003375static int alc861vd_parse_auto_config(struct hda_codec *codec)
3376{
Takashi Iwai1d045db2011-07-07 18:23:21 +02003377 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003378 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3379 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003380}
3381
Takashi Iwai1d045db2011-07-07 18:23:21 +02003382enum {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003383 ALC660VD_FIX_ASUS_GPIO1,
3384 ALC861VD_FIX_DALLAS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02003385};
3386
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003387/* exclude VREF80 */
3388static void alc861vd_fixup_dallas(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003389 const struct hda_fixup *fix, int action)
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003390{
Takashi Iwai1727a772013-01-10 09:52:52 +01003391 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaib78562b2012-12-17 20:06:49 +01003392 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
3393 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003394 }
3395}
3396
Takashi Iwai1727a772013-01-10 09:52:52 +01003397static const struct hda_fixup alc861vd_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003398 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003399 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02003400 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003401 /* reset GPIO1 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003402 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
3403 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3404 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3405 { }
3406 }
3407 },
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003408 [ALC861VD_FIX_DALLAS] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003409 .type = HDA_FIXUP_FUNC,
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003410 .v.func = alc861vd_fixup_dallas,
3411 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02003412};
3413
3414static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003415 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003416 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02003417 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02003418 {}
3419};
3420
Takashi Iwai1d045db2011-07-07 18:23:21 +02003421/*
3422 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003423static int patch_alc861vd(struct hda_codec *codec)
3424{
3425 struct alc_spec *spec;
Takashi Iwaicb4e4822011-08-23 17:34:25 +02003426 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003427
Takashi Iwai3de95172012-05-07 18:03:15 +02003428 err = alc_alloc_spec(codec, 0x0b);
3429 if (err < 0)
3430 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003431
Takashi Iwai3de95172012-05-07 18:03:15 +02003432 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003433 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003434
Takashi Iwai1727a772013-01-10 09:52:52 +01003435 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
3436 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003437
Takashi Iwaicb4e4822011-08-23 17:34:25 +02003438 /* automatic parse from the BIOS config */
3439 err = alc861vd_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003440 if (err < 0)
3441 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003442
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003443 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003444 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003445
Takashi Iwai1d045db2011-07-07 18:23:21 +02003446 codec->patch_ops = alc_patch_ops;
3447
Takashi Iwai1d045db2011-07-07 18:23:21 +02003448 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003449
Takashi Iwai1727a772013-01-10 09:52:52 +01003450 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01003451
Takashi Iwai1d045db2011-07-07 18:23:21 +02003452 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003453
3454 error:
3455 alc_free(codec);
3456 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02003457}
3458
3459/*
3460 * ALC662 support
3461 *
3462 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
3463 * configuration. Each pin widget can choose any input DACs and a mixer.
3464 * Each ADC is connected from a mixer of all inputs. This makes possible
3465 * 6-channel independent captures.
3466 *
3467 * In addition, an independent DAC for the multi-playback (not used in this
3468 * driver yet).
3469 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003470
3471/*
3472 * BIOS auto configuration
3473 */
3474
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003475static int alc662_parse_auto_config(struct hda_codec *codec)
3476{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02003477 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003478 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
3479 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3480 const hda_nid_t *ssids;
Takashi Iwaiee979a142008-09-02 15:42:20 +02003481
Kailang Yang6227cdc2010-02-25 08:36:52 +01003482 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
3483 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003484 ssids = alc663_ssids;
Kailang Yang6227cdc2010-02-25 08:36:52 +01003485 else
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003486 ssids = alc662_ssids;
3487 return alc_parse_auto_config(codec, alc662_ignore, ssids);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003488}
3489
Todd Broch6be79482010-12-07 16:51:05 -08003490static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003491 const struct hda_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01003492{
Takashi Iwai9bb1f062013-01-10 17:14:29 +01003493 if (action != HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01003494 return;
Todd Broch6be79482010-12-07 16:51:05 -08003495 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
3496 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
3497 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
3498 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3499 (0 << AC_AMPCAP_MUTE_SHIFT)))
3500 printk(KERN_WARNING
3501 "hda_codec: failed to override amp caps for NID 0x2\n");
3502}
3503
David Henningsson6cb3b702010-09-09 08:51:44 +02003504enum {
Daniel T Chen2df03512010-10-10 22:39:28 -04003505 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +02003506 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -08003507 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +01003508 ALC662_FIXUP_CZC_P10T,
David Henningsson94024cd2011-04-29 14:10:55 +02003509 ALC662_FIXUP_SKU_IGNORE,
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02003510 ALC662_FIXUP_HP_RP5800,
Takashi Iwai53c334a2011-08-23 18:27:14 +02003511 ALC662_FIXUP_ASUS_MODE1,
3512 ALC662_FIXUP_ASUS_MODE2,
3513 ALC662_FIXUP_ASUS_MODE3,
3514 ALC662_FIXUP_ASUS_MODE4,
3515 ALC662_FIXUP_ASUS_MODE5,
3516 ALC662_FIXUP_ASUS_MODE6,
3517 ALC662_FIXUP_ASUS_MODE7,
3518 ALC662_FIXUP_ASUS_MODE8,
Takashi Iwai1565cc32012-02-13 12:03:25 +01003519 ALC662_FIXUP_NO_JACK_DETECT,
David Henningssonedfe3bf2012-06-12 13:15:12 +02003520 ALC662_FIXUP_ZOTAC_Z68,
Takashi Iwai125821a2012-06-22 14:30:29 +02003521 ALC662_FIXUP_INV_DMIC,
David Henningsson6cb3b702010-09-09 08:51:44 +02003522};
3523
Takashi Iwai1727a772013-01-10 09:52:52 +01003524static const struct hda_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -04003525 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003526 .type = HDA_FIXUP_PINS,
3527 .v.pins = (const struct hda_pintbl[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -04003528 { 0x15, 0x99130112 }, /* subwoofer */
3529 { }
3530 }
3531 },
David Henningsson6cb3b702010-09-09 08:51:44 +02003532 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003533 .type = HDA_FIXUP_PINS,
3534 .v.pins = (const struct hda_pintbl[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +02003535 { 0x17, 0x99130112 }, /* subwoofer */
3536 { }
3537 }
3538 },
Todd Broch6be79482010-12-07 16:51:05 -08003539 [ALC272_FIXUP_MARIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003540 .type = HDA_FIXUP_FUNC,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01003541 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +01003542 },
3543 [ALC662_FIXUP_CZC_P10T] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003544 .type = HDA_FIXUP_VERBS,
Anisse Astierd2ebd472011-01-20 12:36:21 +01003545 .v.verbs = (const struct hda_verb[]) {
3546 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
3547 {}
3548 }
3549 },
David Henningsson94024cd2011-04-29 14:10:55 +02003550 [ALC662_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003551 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02003552 .v.func = alc_fixup_sku_ignore,
Takashi Iwaic6b35872011-03-28 12:05:31 +02003553 },
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02003554 [ALC662_FIXUP_HP_RP5800] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003555 .type = HDA_FIXUP_PINS,
3556 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02003557 { 0x14, 0x0221201f }, /* HP out */
3558 { }
3559 },
3560 .chained = true,
3561 .chain_id = ALC662_FIXUP_SKU_IGNORE
3562 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02003563 [ALC662_FIXUP_ASUS_MODE1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003564 .type = HDA_FIXUP_PINS,
3565 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003566 { 0x14, 0x99130110 }, /* speaker */
3567 { 0x18, 0x01a19c20 }, /* mic */
3568 { 0x19, 0x99a3092f }, /* int-mic */
3569 { 0x21, 0x0121401f }, /* HP out */
3570 { }
3571 },
3572 .chained = true,
3573 .chain_id = ALC662_FIXUP_SKU_IGNORE
3574 },
3575 [ALC662_FIXUP_ASUS_MODE2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003576 .type = HDA_FIXUP_PINS,
3577 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai2996bdb2011-08-18 16:02:24 +02003578 { 0x14, 0x99130110 }, /* speaker */
3579 { 0x18, 0x01a19820 }, /* mic */
3580 { 0x19, 0x99a3092f }, /* int-mic */
3581 { 0x1b, 0x0121401f }, /* HP out */
3582 { }
3583 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02003584 .chained = true,
3585 .chain_id = ALC662_FIXUP_SKU_IGNORE
3586 },
3587 [ALC662_FIXUP_ASUS_MODE3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003588 .type = HDA_FIXUP_PINS,
3589 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003590 { 0x14, 0x99130110 }, /* speaker */
3591 { 0x15, 0x0121441f }, /* HP */
3592 { 0x18, 0x01a19840 }, /* mic */
3593 { 0x19, 0x99a3094f }, /* int-mic */
3594 { 0x21, 0x01211420 }, /* HP2 */
3595 { }
3596 },
3597 .chained = true,
3598 .chain_id = ALC662_FIXUP_SKU_IGNORE
3599 },
3600 [ALC662_FIXUP_ASUS_MODE4] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003601 .type = HDA_FIXUP_PINS,
3602 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003603 { 0x14, 0x99130110 }, /* speaker */
3604 { 0x16, 0x99130111 }, /* speaker */
3605 { 0x18, 0x01a19840 }, /* mic */
3606 { 0x19, 0x99a3094f }, /* int-mic */
3607 { 0x21, 0x0121441f }, /* HP */
3608 { }
3609 },
3610 .chained = true,
3611 .chain_id = ALC662_FIXUP_SKU_IGNORE
3612 },
3613 [ALC662_FIXUP_ASUS_MODE5] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003614 .type = HDA_FIXUP_PINS,
3615 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003616 { 0x14, 0x99130110 }, /* speaker */
3617 { 0x15, 0x0121441f }, /* HP */
3618 { 0x16, 0x99130111 }, /* speaker */
3619 { 0x18, 0x01a19840 }, /* mic */
3620 { 0x19, 0x99a3094f }, /* int-mic */
3621 { }
3622 },
3623 .chained = true,
3624 .chain_id = ALC662_FIXUP_SKU_IGNORE
3625 },
3626 [ALC662_FIXUP_ASUS_MODE6] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003627 .type = HDA_FIXUP_PINS,
3628 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003629 { 0x14, 0x99130110 }, /* speaker */
3630 { 0x15, 0x01211420 }, /* HP2 */
3631 { 0x18, 0x01a19840 }, /* mic */
3632 { 0x19, 0x99a3094f }, /* int-mic */
3633 { 0x1b, 0x0121441f }, /* HP */
3634 { }
3635 },
3636 .chained = true,
3637 .chain_id = ALC662_FIXUP_SKU_IGNORE
3638 },
3639 [ALC662_FIXUP_ASUS_MODE7] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003640 .type = HDA_FIXUP_PINS,
3641 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003642 { 0x14, 0x99130110 }, /* speaker */
3643 { 0x17, 0x99130111 }, /* speaker */
3644 { 0x18, 0x01a19840 }, /* mic */
3645 { 0x19, 0x99a3094f }, /* int-mic */
3646 { 0x1b, 0x01214020 }, /* HP */
3647 { 0x21, 0x0121401f }, /* HP */
3648 { }
3649 },
3650 .chained = true,
3651 .chain_id = ALC662_FIXUP_SKU_IGNORE
3652 },
3653 [ALC662_FIXUP_ASUS_MODE8] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003654 .type = HDA_FIXUP_PINS,
3655 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003656 { 0x14, 0x99130110 }, /* speaker */
3657 { 0x12, 0x99a30970 }, /* int-mic */
3658 { 0x15, 0x01214020 }, /* HP */
3659 { 0x17, 0x99130111 }, /* speaker */
3660 { 0x18, 0x01a19840 }, /* mic */
3661 { 0x21, 0x0121401f }, /* HP */
3662 { }
3663 },
3664 .chained = true,
3665 .chain_id = ALC662_FIXUP_SKU_IGNORE
Takashi Iwai2996bdb2011-08-18 16:02:24 +02003666 },
Takashi Iwai1565cc32012-02-13 12:03:25 +01003667 [ALC662_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003668 .type = HDA_FIXUP_FUNC,
Takashi Iwai1565cc32012-02-13 12:03:25 +01003669 .v.func = alc_fixup_no_jack_detect,
3670 },
David Henningssonedfe3bf2012-06-12 13:15:12 +02003671 [ALC662_FIXUP_ZOTAC_Z68] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003672 .type = HDA_FIXUP_PINS,
3673 .v.pins = (const struct hda_pintbl[]) {
David Henningssonedfe3bf2012-06-12 13:15:12 +02003674 { 0x1b, 0x02214020 }, /* Front HP */
3675 { }
3676 }
3677 },
Takashi Iwai125821a2012-06-22 14:30:29 +02003678 [ALC662_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01003679 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02003680 .v.func = alc_fixup_inv_dmic_0x12,
Takashi Iwai125821a2012-06-22 14:30:29 +02003681 },
David Henningsson6cb3b702010-09-09 08:51:44 +02003682};
3683
Takashi Iwaia9111322011-05-02 11:30:18 +02003684static const struct snd_pci_quirk alc662_fixup_tbl[] = {
Takashi Iwai53c334a2011-08-23 18:27:14 +02003685 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
David Henningssona6c47a82011-02-10 15:39:19 +01003686 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
David Henningsson94024cd2011-04-29 14:10:55 +02003687 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
Takashi Iwai125821a2012-06-22 14:30:29 +02003688 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
Daniel T Chen2df03512010-10-10 22:39:28 -04003689 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02003690 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
Takashi Iwai1565cc32012-02-13 12:03:25 +01003691 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
Takashi Iwai53c334a2011-08-23 18:27:14 +02003692 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
Daniel T Chena0e90ac2010-11-20 10:20:35 -05003693 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +06003694 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +02003695 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
David Henningssonedfe3bf2012-06-12 13:15:12 +02003696 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
Anisse Astierd2ebd472011-01-20 12:36:21 +01003697 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
Takashi Iwai53c334a2011-08-23 18:27:14 +02003698
3699#if 0
3700 /* Below is a quirk table taken from the old code.
3701 * Basically the device should work as is without the fixup table.
3702 * If BIOS doesn't give a proper info, enable the corresponding
3703 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02003704 */
Takashi Iwai53c334a2011-08-23 18:27:14 +02003705 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
3706 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
3707 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
3708 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
3709 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3710 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3711 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3712 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
3713 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
3714 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3715 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
3716 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
3717 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
3718 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
3719 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
3720 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3721 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
3722 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
3723 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3724 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3725 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3726 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3727 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
3728 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
3729 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
3730 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3731 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
3732 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3733 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3734 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
3735 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3736 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3737 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
3738 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
3739 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
3740 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
3741 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
3742 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
3743 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
3744 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3745 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
3746 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
3747 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3748 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
3749 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
3750 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
3751 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
3752 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
3753 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3754 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
3755#endif
David Henningsson6cb3b702010-09-09 08:51:44 +02003756 {}
3757};
3758
Takashi Iwai1727a772013-01-10 09:52:52 +01003759static const struct hda_model_fixup alc662_fixup_models[] = {
Todd Broch6be79482010-12-07 16:51:05 -08003760 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
Takashi Iwai53c334a2011-08-23 18:27:14 +02003761 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
3762 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
3763 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
3764 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
3765 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
3766 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
3767 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
3768 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02003769 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
Todd Broch6be79482010-12-07 16:51:05 -08003770 {}
3771};
David Henningsson6cb3b702010-09-09 08:51:44 +02003772
Kailang Yang8663ff72012-06-29 09:35:52 +02003773static void alc662_fill_coef(struct hda_codec *codec)
3774{
3775 int val, coef;
3776
3777 coef = alc_get_coef0(codec);
3778
3779 switch (codec->vendor_id) {
3780 case 0x10ec0662:
3781 if ((coef & 0x00f0) == 0x0030) {
3782 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
3783 alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
3784 }
3785 break;
3786 case 0x10ec0272:
3787 case 0x10ec0273:
3788 case 0x10ec0663:
3789 case 0x10ec0665:
3790 case 0x10ec0670:
3791 case 0x10ec0671:
3792 case 0x10ec0672:
3793 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
3794 alc_write_coef_idx(codec, 0xd, val | (1<<14));
3795 break;
3796 }
3797}
David Henningsson6cb3b702010-09-09 08:51:44 +02003798
Takashi Iwai1d045db2011-07-07 18:23:21 +02003799/*
3800 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003801static int patch_alc662(struct hda_codec *codec)
3802{
3803 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02003804 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003805
Takashi Iwai3de95172012-05-07 18:03:15 +02003806 err = alc_alloc_spec(codec, 0x0b);
3807 if (err < 0)
3808 return err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003809
Takashi Iwai3de95172012-05-07 18:03:15 +02003810 spec = codec->spec;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02003811
Takashi Iwai53c334a2011-08-23 18:27:14 +02003812 /* handle multiple HPs as is */
3813 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3814
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003815 alc_fix_pll_init(codec, 0x20, 0x04, 15);
3816
Kailang Yang8663ff72012-06-29 09:35:52 +02003817 spec->init_hook = alc662_fill_coef;
3818 alc662_fill_coef(codec);
3819
Takashi Iwai1727a772013-01-10 09:52:52 +01003820 snd_hda_pick_fixup(codec, alc662_fixup_models,
Takashi Iwai8e5a0502012-06-21 15:49:33 +02003821 alc662_fixup_tbl, alc662_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01003822 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai8e5a0502012-06-21 15:49:33 +02003823
3824 alc_auto_parse_customize_define(codec);
3825
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003826 if (has_cdefine_beep(codec))
3827 spec->gen.beep_nid = 0x01;
3828
Takashi Iwai1bb7e432011-10-17 16:50:59 +02003829 if ((alc_get_coef0(codec) & (1 << 14)) &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003830 codec->bus->pci->subsystem_vendor == 0x1025 &&
3831 spec->cdefine.platform_type == 1) {
3832 if (alc_codec_rename(codec, "ALC272X") < 0)
3833 goto error;
Takashi Iwai20ca0c32011-10-17 16:00:35 +02003834 }
Kailang Yang274693f2009-12-03 10:07:50 +01003835
Takashi Iwaib9c51062011-08-24 18:08:07 +02003836 /* automatic parse from the BIOS config */
3837 err = alc662_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003838 if (err < 0)
3839 goto error;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003840
Takashi Iwai7504b6c2013-03-18 11:25:51 +01003841 if (!spec->gen.no_analog && spec->gen.beep_nid) {
Kailang Yangda00c242010-03-19 11:23:45 +01003842 switch (codec->vendor_id) {
3843 case 0x10ec0662:
3844 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3845 break;
3846 case 0x10ec0272:
3847 case 0x10ec0663:
3848 case 0x10ec0665:
3849 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
3850 break;
3851 case 0x10ec0273:
3852 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
3853 break;
3854 }
Kailang Yangcec27c82010-02-04 14:18:18 +01003855 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003856
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003857 codec->patch_ops = alc_patch_ops;
Takashi Iwai1c7161532011-04-07 10:37:16 +02003858 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +02003859
Takashi Iwai1727a772013-01-10 09:52:52 +01003860 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01003861
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003862 return 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003863
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003864 error:
3865 alc_free(codec);
3866 return err;
Kailang Yangb478b992011-05-18 11:51:15 +02003867}
3868
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003869/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003870 * ALC680 support
3871 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003872
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003873static int alc680_parse_auto_config(struct hda_codec *codec)
3874{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02003875 return alc_parse_auto_config(codec, NULL, NULL);
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003876}
3877
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003878/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003879 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003880static int patch_alc680(struct hda_codec *codec)
3881{
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003882 int err;
3883
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02003884 /* ALC680 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02003885 err = alc_alloc_spec(codec, 0);
3886 if (err < 0)
3887 return err;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02003888
Takashi Iwai1ebec5f2011-08-15 13:21:48 +02003889 /* automatic parse from the BIOS config */
3890 err = alc680_parse_auto_config(codec);
3891 if (err < 0) {
3892 alc_free(codec);
3893 return err;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003894 }
3895
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003896 codec->patch_ops = alc_patch_ops;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003897
3898 return 0;
3899}
3900
3901/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003902 * patch entries
3903 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003904static const struct hda_codec_preset snd_hda_preset_realtek[] = {
Kailang Yang296f0332011-05-18 11:52:36 +02003905 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
Kailang Yang84dfd0a2013-03-07 09:19:38 +01003906 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003908 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +01003909 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +02003910 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +01003911 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01003912 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +02003913 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01003914 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Kailang Yang296f0332011-05-18 11:52:36 +02003915 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
David Henningssonbefae822012-06-25 19:49:28 +02003916 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
David Henningsson4e01ec62012-07-18 07:38:46 +02003917 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02003918 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
Kailang Yang065380f2013-01-10 10:25:48 +01003919 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02003920 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
David Henningssonaf02dde2012-11-21 08:57:58 +01003921 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01003922 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003923 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01003924 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
3925 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
3926 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003927 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +02003928 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003929 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
3930 .patch = patch_alc662 },
David Henningssoncc667a72011-10-18 14:07:51 +02003931 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
3932 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +02003933 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +01003934 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang19a62822012-11-08 10:25:37 +01003935 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +01003936 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +02003937 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01003938 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07003939 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02003940 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +02003941 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02003942 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +02003943 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02003944 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003945 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003946 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +02003947 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +02003948 .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003949 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02003950 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +01003951 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02003952 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
Kailang Yang19a62822012-11-08 10:25:37 +01003953 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07003954 {} /* terminator */
3955};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01003956
3957MODULE_ALIAS("snd-hda-codec-id:10ec*");
3958
3959MODULE_LICENSE("GPL");
3960MODULE_DESCRIPTION("Realtek HD-audio codec");
3961
3962static struct hda_codec_preset_list realtek_list = {
3963 .preset = snd_hda_preset_realtek,
3964 .owner = THIS_MODULE,
3965};
3966
3967static int __init patch_realtek_init(void)
3968{
3969 return snd_hda_add_codec_preset(&realtek_list);
3970}
3971
3972static void __exit patch_realtek_exit(void)
3973{
3974 snd_hda_delete_codec_preset(&realtek_list);
3975}
3976
3977module_init(patch_realtek_init)
3978module_exit(patch_realtek_exit)