blob: 124272bc935bf0e41d96735ec81c5bad6cb41367 [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 Iwaicd63a5f2013-07-05 12:13:59 +020040/* keep halting ALC5505 DSP, for power saving */
41#define HALT_REALTEK_ALC5505
42
Takashi Iwai1d045db2011-07-07 18:23:21 +020043/* unsol event tags */
Takashi Iwai08c189f2012-12-19 15:22:24 +010044#define ALC_DCVOL_EVENT 0x08
Takashi Iwaid4a86d82010-06-23 17:51:26 +020045
Kailang Yangdf694da2005-12-05 19:42:22 +010046/* for GPIO Poll */
47#define GPIO_MASK 0x03
48
Takashi Iwai4a79ba32009-04-22 16:31:35 +020049/* extra amp-initialization sequence types */
50enum {
51 ALC_INIT_NONE,
52 ALC_INIT_DEFAULT,
53 ALC_INIT_GPIO1,
54 ALC_INIT_GPIO2,
55 ALC_INIT_GPIO3,
56};
57
David Henningsson73bdd592013-04-15 15:44:14 +020058enum {
59 ALC_HEADSET_MODE_UNKNOWN,
60 ALC_HEADSET_MODE_UNPLUGGED,
61 ALC_HEADSET_MODE_HEADSET,
62 ALC_HEADSET_MODE_MIC,
63 ALC_HEADSET_MODE_HEADPHONE,
64};
65
66enum {
67 ALC_HEADSET_TYPE_UNKNOWN,
68 ALC_HEADSET_TYPE_CTIA,
69 ALC_HEADSET_TYPE_OMTP,
70};
71
Kailang Yangda00c242010-03-19 11:23:45 +010072struct alc_customize_define {
73 unsigned int sku_cfg;
74 unsigned char port_connectivity;
75 unsigned char check_sum;
76 unsigned char customization;
77 unsigned char external_amp;
78 unsigned int enable_pcbeep:1;
79 unsigned int platform_type:1;
80 unsigned int swap:1;
81 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +020082 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +010083};
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085struct alc_spec {
Takashi Iwai08c189f2012-12-19 15:22:24 +010086 struct hda_gen_spec gen; /* must be at head */
Takashi Iwai23d30f22012-05-07 17:17:32 +020087
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 /* codec parameterization */
Takashi Iwaia9111322011-05-02 11:30:18 +020089 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 unsigned int num_mixers;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010091 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Kailang Yangda00c242010-03-19 11:23:45 +010093 struct alc_customize_define cdefine;
Takashi Iwai08c189f2012-12-19 15:22:24 +010094 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
95
96 /* inverted dmic fix */
97 unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */
98 unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */
Takashi Iwai125821a2012-06-22 14:30:29 +020099 hda_nid_t inv_dmic_pin;
Takashi Iwai834be882006-03-01 14:16:17 +0100100
Takashi Iwai08fb0d02013-01-10 17:33:58 +0100101 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
102 int mute_led_polarity;
103 hda_nid_t mute_led_nid;
Kailang Yang9c5dc3b2014-06-19 16:11:36 +0800104 hda_nid_t cap_mute_led_nid;
Takashi Iwai08fb0d02013-01-10 17:33:58 +0100105
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +0100106 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
107
David Henningsson73bdd592013-04-15 15:44:14 +0200108 hda_nid_t headset_mic_pin;
109 hda_nid_t headphone_mic_pin;
110 int current_headset_mode;
111 int current_headset_type;
112
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100113 /* hooks */
114 void (*init_hook)(struct hda_codec *codec);
Takashi Iwai83012a72012-08-24 18:38:08 +0200115#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -0500116 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100117#endif
Takashi Iwai1c7161532011-04-07 10:37:16 +0200118 void (*shutup)(struct hda_codec *codec);
Takashi Iwaid922b512011-04-28 12:18:53 +0200119
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200120 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200121 int codec_variant; /* flag for other variants */
Kailang Yang97a26572013-11-29 00:35:26 -0500122 unsigned int has_alc5505_dsp:1;
123 unsigned int no_depop_delay:1;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100124
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200125 /* for PLL fix */
126 hda_nid_t pll_nid;
127 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200128 unsigned int coef0;
Kailang Yangdf694da2005-12-05 19:42:22 +0100129};
130
Takashi Iwai23f0c042009-02-26 13:03:58 +0100131/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200132 * Append the given mixer and verb elements for the later use
133 * The mixer array is referred in build_controls(), and init_verbs are
134 * called in init().
Takashi Iwaid88897e2008-10-31 15:01:37 +0100135 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200136static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100137{
138 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
139 return;
140 spec->mixers[spec->num_mixers++] = mix;
141}
142
Takashi Iwaid88897e2008-10-31 15:01:37 +0100143/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200144 * GPIO setup tables, used in initialization
Kailang Yangdf694da2005-12-05 19:42:22 +0100145 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200146/* Enable GPIO mask and set output */
Takashi Iwaia9111322011-05-02 11:30:18 +0200147static const struct hda_verb alc_gpio1_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200148 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
149 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
150 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
151 { }
152};
153
Takashi Iwaia9111322011-05-02 11:30:18 +0200154static const struct hda_verb alc_gpio2_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200155 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
156 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
157 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
158 { }
159};
160
Takashi Iwaia9111322011-05-02 11:30:18 +0200161static const struct hda_verb alc_gpio3_init_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +0200162 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
163 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
164 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
165 { }
166};
167
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200168/*
169 * Fix hardware PLL issue
170 * On some codecs, the analog PLL gating control must be off while
171 * the default value is 1.
172 */
173static void alc_fix_pll(struct hda_codec *codec)
174{
175 struct alc_spec *spec = codec->spec;
176 unsigned int val;
177
178 if (!spec->pll_nid)
179 return;
180 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
181 spec->pll_coef_idx);
182 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
183 AC_VERB_GET_PROC_COEF, 0);
184 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
185 spec->pll_coef_idx);
186 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
187 val & ~(1 << spec->pll_coef_bit));
188}
189
190static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
191 unsigned int coef_idx, unsigned int coef_bit)
192{
193 struct alc_spec *spec = codec->spec;
194 spec->pll_nid = nid;
195 spec->pll_coef_idx = coef_idx;
196 spec->pll_coef_bit = coef_bit;
197 alc_fix_pll(codec);
198}
199
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100200/* update the master volume per volume-knob's unsol event */
David Henningsson29adc4b2012-09-25 11:31:00 +0200201static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100202{
203 unsigned int val;
204 struct snd_kcontrol *kctl;
205 struct snd_ctl_elem_value *uctl;
206
207 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
208 if (!kctl)
209 return;
210 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
211 if (!uctl)
212 return;
David Henningsson29adc4b2012-09-25 11:31:00 +0200213 val = snd_hda_codec_read(codec, jack->nid, 0,
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100214 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
215 val &= HDA_AMP_VOLMASK;
216 uctl->value.integer.value[0] = val;
217 uctl->value.integer.value[1] = val;
218 kctl->put(kctl, uctl);
219 kfree(uctl);
220}
221
David Henningsson29adc4b2012-09-25 11:31:00 +0200222static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100223{
David Henningsson29adc4b2012-09-25 11:31:00 +0200224 /* For some reason, the res given from ALC880 is broken.
225 Here we adjust it properly. */
226 snd_hda_jack_unsol_event(codec, res >> 2);
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100227}
228
Kailang Yangf9423e72008-05-27 12:32:25 +0200229/* additional initialization for ALC888 variants */
230static void alc888_coef_init(struct hda_codec *codec)
231{
232 unsigned int tmp;
233
234 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
235 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
236 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +0100237 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +0200238 /* alc888S-VC */
239 snd_hda_codec_read(codec, 0x20, 0,
240 AC_VERB_SET_PROC_COEF, 0x830);
241 else
242 /* alc888-VB */
243 snd_hda_codec_read(codec, 0x20, 0,
244 AC_VERB_SET_PROC_COEF, 0x3030);
245}
246
Takashi Iwai1d045db2011-07-07 18:23:21 +0200247/* additional initialization for ALC889 variants */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200248static void alc889_coef_init(struct hda_codec *codec)
249{
250 unsigned int tmp;
251
252 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
253 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
254 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
255 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
256}
257
Takashi Iwai3fb4a502010-01-19 15:46:37 +0100258/* turn on/off EAPD control (only if available) */
259static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
260{
261 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
262 return;
263 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
264 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
265 on ? 2 : 0);
266}
267
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200268/* turn on/off EAPD controls of the codec */
269static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
270{
271 /* We currently only handle front, HP */
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200272 static hda_nid_t pins[] = {
273 0x0f, 0x10, 0x14, 0x15, 0
274 };
275 hda_nid_t *p;
276 for (p = pins; *p; p++)
277 set_eapd(codec, *p, on);
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200278}
279
Takashi Iwai1c7161532011-04-07 10:37:16 +0200280/* generic shutup callback;
281 * just turning off EPAD and a little pause for avoiding pop-noise
282 */
283static void alc_eapd_shutup(struct hda_codec *codec)
284{
Kailang Yang97a26572013-11-29 00:35:26 -0500285 struct alc_spec *spec = codec->spec;
286
Takashi Iwai1c7161532011-04-07 10:37:16 +0200287 alc_auto_setup_eapd(codec, false);
Kailang Yang97a26572013-11-29 00:35:26 -0500288 if (!spec->no_depop_delay)
289 msleep(200);
Takashi Iwai9bfb2842013-07-24 14:31:50 +0200290 snd_hda_shutup_pins(codec);
Takashi Iwai1c7161532011-04-07 10:37:16 +0200291}
292
Takashi Iwai1d045db2011-07-07 18:23:21 +0200293/* generic EAPD initialization */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200294static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200295{
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200296 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200297
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200298 alc_auto_setup_eapd(codec, true);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200299 switch (type) {
300 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200301 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
302 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200303 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200304 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
305 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200306 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200307 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
308 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200309 case ALC_INIT_DEFAULT:
Kailang Yangc9b58002007-10-16 14:30:01 +0200310 switch (codec->vendor_id) {
311 case 0x10ec0260:
312 snd_hda_codec_write(codec, 0x1a, 0,
313 AC_VERB_SET_COEF_INDEX, 7);
314 tmp = snd_hda_codec_read(codec, 0x1a, 0,
315 AC_VERB_GET_PROC_COEF, 0);
316 snd_hda_codec_write(codec, 0x1a, 0,
317 AC_VERB_SET_COEF_INDEX, 7);
318 snd_hda_codec_write(codec, 0x1a, 0,
319 AC_VERB_SET_PROC_COEF,
320 tmp | 0x2010);
321 break;
322 case 0x10ec0262:
323 case 0x10ec0880:
324 case 0x10ec0882:
325 case 0x10ec0883:
326 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +0100327 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +0100328 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200329 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200330 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200331 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200332 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +0200333 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +0100334#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +0200335 case 0x10ec0267:
336 case 0x10ec0268:
337 snd_hda_codec_write(codec, 0x20, 0,
338 AC_VERB_SET_COEF_INDEX, 7);
339 tmp = snd_hda_codec_read(codec, 0x20, 0,
340 AC_VERB_GET_PROC_COEF, 0);
341 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200342 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200343 snd_hda_codec_write(codec, 0x20, 0,
344 AC_VERB_SET_PROC_COEF,
345 tmp | 0x3000);
346 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +0100347#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200348 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200349 break;
350 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200351}
Kailang Yangea1fb292008-08-26 12:58:38 +0200352
Takashi Iwai1d045db2011-07-07 18:23:21 +0200353
354/*
355 * Realtek SSID verification
356 */
357
David Henningsson90622912010-10-14 14:50:18 +0200358/* Could be any non-zero and even value. When used as fixup, tells
359 * the driver to ignore any present sku defines.
360 */
361#define ALC_FIXUP_SKU_IGNORE (2)
362
Takashi Iwai23d30f22012-05-07 17:17:32 +0200363static void alc_fixup_sku_ignore(struct hda_codec *codec,
364 const struct hda_fixup *fix, int action)
365{
366 struct alc_spec *spec = codec->spec;
367 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
368 spec->cdefine.fixup = 1;
369 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
370 }
371}
372
Mengdong Linb5c66112013-11-29 00:35:35 -0500373static void alc_fixup_no_depop_delay(struct hda_codec *codec,
374 const struct hda_fixup *fix, int action)
375{
376 struct alc_spec *spec = codec->spec;
377
Mengdong Lin84d2dc32013-12-02 22:26:03 -0500378 if (action == HDA_FIXUP_ACT_PROBE) {
Mengdong Linb5c66112013-11-29 00:35:35 -0500379 spec->no_depop_delay = 1;
Mengdong Lin84d2dc32013-12-02 22:26:03 -0500380 codec->depop_delay = 0;
381 }
Mengdong Linb5c66112013-11-29 00:35:35 -0500382}
383
Kailang Yangda00c242010-03-19 11:23:45 +0100384static int alc_auto_parse_customize_define(struct hda_codec *codec)
385{
386 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +0100387 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +0100388 struct alc_spec *spec = codec->spec;
389
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200390 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
391
David Henningsson90622912010-10-14 14:50:18 +0200392 if (spec->cdefine.fixup) {
393 ass = spec->cdefine.sku_cfg;
394 if (ass == ALC_FIXUP_SKU_IGNORE)
395 return -1;
396 goto do_sku;
397 }
398
Takashi Iwai5100cd02014-02-15 10:03:19 +0100399 if (!codec->bus->pci)
400 return -1;
Kailang Yangda00c242010-03-19 11:23:45 +0100401 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200402 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +0100403 goto do_sku;
404
405 nid = 0x1d;
406 if (codec->vendor_id == 0x10ec0260)
407 nid = 0x17;
408 ass = snd_hda_codec_get_pincfg(codec, nid);
409
410 if (!(ass & 1)) {
Takashi Iwai4e76a882014-02-25 12:21:03 +0100411 codec_info(codec, "%s: SKU not ready 0x%08x\n",
412 codec->chip_name, ass);
Kailang Yangda00c242010-03-19 11:23:45 +0100413 return -1;
414 }
415
416 /* check sum */
417 tmp = 0;
418 for (i = 1; i < 16; i++) {
419 if ((ass >> i) & 1)
420 tmp++;
421 }
422 if (((ass >> 16) & 0xf) != tmp)
423 return -1;
424
425 spec->cdefine.port_connectivity = ass >> 30;
426 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
427 spec->cdefine.check_sum = (ass >> 16) & 0xf;
428 spec->cdefine.customization = ass >> 8;
429do_sku:
430 spec->cdefine.sku_cfg = ass;
431 spec->cdefine.external_amp = (ass & 0x38) >> 3;
432 spec->cdefine.platform_type = (ass & 0x4) >> 2;
433 spec->cdefine.swap = (ass & 0x2) >> 1;
434 spec->cdefine.override = ass & 0x1;
435
Takashi Iwai4e76a882014-02-25 12:21:03 +0100436 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
Kailang Yangda00c242010-03-19 11:23:45 +0100437 nid, spec->cdefine.sku_cfg);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100438 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
Kailang Yangda00c242010-03-19 11:23:45 +0100439 spec->cdefine.port_connectivity);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100440 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
441 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
442 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
443 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
444 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
445 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
446 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
Kailang Yangda00c242010-03-19 11:23:45 +0100447
448 return 0;
449}
450
Takashi Iwai08c189f2012-12-19 15:22:24 +0100451/* return the position of NID in the list, or -1 if not found */
452static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
453{
454 int i;
455 for (i = 0; i < nums; i++)
456 if (list[i] == nid)
457 return i;
458 return -1;
459}
Takashi Iwai1d045db2011-07-07 18:23:21 +0200460/* return true if the given NID is found in the list */
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200461static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
462{
Takashi Iwai21268962011-07-07 15:01:13 +0200463 return find_idx_in_nid_list(nid, list, nums) >= 0;
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200464}
465
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200466/* check subsystem ID and set up device-specific initialization;
467 * return 1 if initialized, 0 if invalid SSID
468 */
469/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
470 * 31 ~ 16 : Manufacture ID
471 * 15 ~ 8 : SKU ID
472 * 7 ~ 0 : Assembly ID
473 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
474 */
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100475static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200476{
477 unsigned int ass, tmp, i;
478 unsigned nid;
479 struct alc_spec *spec = codec->spec;
480
David Henningsson90622912010-10-14 14:50:18 +0200481 if (spec->cdefine.fixup) {
482 ass = spec->cdefine.sku_cfg;
483 if (ass == ALC_FIXUP_SKU_IGNORE)
484 return 0;
485 goto do_sku;
486 }
487
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200488 ass = codec->subsystem_id & 0xffff;
Takashi Iwai5100cd02014-02-15 10:03:19 +0100489 if (codec->bus->pci &&
490 ass != codec->bus->pci->subsystem_device && (ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200491 goto do_sku;
492
493 /* invalid SSID, check the special NID pin defcfg instead */
494 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400495 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200496 * 29~21 : reserve
497 * 20 : PCBEEP input
498 * 19~16 : Check sum (15:1)
499 * 15~1 : Custom
500 * 0 : override
501 */
502 nid = 0x1d;
503 if (codec->vendor_id == 0x10ec0260)
504 nid = 0x17;
505 ass = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100506 codec_dbg(codec,
507 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +0200508 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +0100509 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200510 return 0;
511 if ((ass >> 30) != 1) /* no physical connection */
512 return 0;
513
514 /* check sum */
515 tmp = 0;
516 for (i = 1; i < 16; i++) {
517 if ((ass >> i) & 1)
518 tmp++;
519 }
520 if (((ass >> 16) & 0xf) != tmp)
521 return 0;
522do_sku:
Takashi Iwai4e76a882014-02-25 12:21:03 +0100523 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200524 ass & 0xffff, codec->vendor_id);
525 /*
526 * 0 : override
527 * 1 : Swap Jack
528 * 2 : 0 --> Desktop, 1 --> Laptop
529 * 3~5 : External Amplifier control
530 * 7~6 : Reserved
531 */
532 tmp = (ass & 0x38) >> 3; /* external Amp control */
533 switch (tmp) {
534 case 1:
535 spec->init_amp = ALC_INIT_GPIO1;
536 break;
537 case 3:
538 spec->init_amp = ALC_INIT_GPIO2;
539 break;
540 case 7:
541 spec->init_amp = ALC_INIT_GPIO3;
542 break;
543 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +0100544 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200545 spec->init_amp = ALC_INIT_DEFAULT;
546 break;
547 }
548
549 /* is laptop or Desktop and enable the function "Mute internal speaker
550 * when the external headphone out jack is plugged"
551 */
552 if (!(ass & 0x8000))
553 return 1;
554 /*
555 * 10~8 : Jack location
556 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
557 * 14~13: Resvered
558 * 15 : 1 --> enable the function "Mute internal speaker
559 * when the external headphone out jack is plugged"
560 */
Takashi Iwai08c189f2012-12-19 15:22:24 +0100561 if (!spec->gen.autocfg.hp_pins[0] &&
562 !(spec->gen.autocfg.line_out_pins[0] &&
563 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
Takashi Iwai01d48252009-10-06 13:21:54 +0200564 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200565 tmp = (ass >> 11) & 0x3; /* HP to chassis */
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100566 nid = ports[tmp];
Takashi Iwai08c189f2012-12-19 15:22:24 +0100567 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
568 spec->gen.autocfg.line_outs))
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200569 return 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100570 spec->gen.autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200571 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200572 return 1;
573}
Kailang Yangea1fb292008-08-26 12:58:38 +0200574
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200575/* Check the validity of ALC subsystem-id
576 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
577static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200578{
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100579 if (!alc_subsystem_id(codec, ports)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200580 struct alc_spec *spec = codec->spec;
Takashi Iwai4e76a882014-02-25 12:21:03 +0100581 codec_dbg(codec,
582 "realtek: Enable default setup for auto mode as fallback\n");
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200583 spec->init_amp = ALC_INIT_DEFAULT;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200584 }
Takashi Iwai21268962011-07-07 15:01:13 +0200585}
Takashi Iwai1a1455d2011-04-28 17:36:18 +0200586
Takashi Iwai41e41f12005-06-08 14:48:49 +0200587/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200588 * COEF access helper functions
589 */
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800590
591static int alc_read_coefex_idx(struct hda_codec *codec,
592 hda_nid_t nid,
593 unsigned int coef_idx)
Kailang Yang274693f2009-12-03 10:07:50 +0100594{
595 unsigned int val;
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800596 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX,
Kailang Yang274693f2009-12-03 10:07:50 +0100597 coef_idx);
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800598 val = snd_hda_codec_read(codec, nid, 0,
Kailang Yang274693f2009-12-03 10:07:50 +0100599 AC_VERB_GET_PROC_COEF, 0);
600 return val;
601}
602
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800603#define alc_read_coef_idx(codec, coef_idx) \
604 alc_read_coefex_idx(codec, 0x20, coef_idx)
605
606static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
607 unsigned int coef_idx,
Kailang Yang977ddd62010-09-15 10:02:29 +0200608 unsigned int coef_val)
609{
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800610 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX,
Kailang Yang977ddd62010-09-15 10:02:29 +0200611 coef_idx);
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800612 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF,
Kailang Yang977ddd62010-09-15 10:02:29 +0200613 coef_val);
614}
615
Kailang Yang9a22a8f52013-11-08 15:54:49 +0800616#define alc_write_coef_idx(codec, coef_idx, coef_val) \
617 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
618
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200619/* a special bypass for COEF 0; read the cached value at the second time */
620static unsigned int alc_get_coef0(struct hda_codec *codec)
621{
622 struct alc_spec *spec = codec->spec;
623 if (!spec->coef0)
624 spec->coef0 = alc_read_coef_idx(codec, 0);
625 return spec->coef0;
626}
627
Takashi Iwai1d045db2011-07-07 18:23:21 +0200628/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200629 */
630
Takashi Iwai08c189f2012-12-19 15:22:24 +0100631static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
Takashi Iwai757899a2010-07-30 10:48:14 +0200632{
Takashi Iwai08c189f2012-12-19 15:22:24 +0100633 struct hda_gen_spec *spec = codec->spec;
634 if (spec->dyn_adc_switch)
635 adc_idx = spec->dyn_adc_idx[imux_idx];
636 return spec->adc_nids[adc_idx];
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100637}
638
Takashi Iwai666a70d2012-12-17 20:29:29 +0100639static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200640{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100642 struct hda_input_mux *imux = &spec->gen.input_mux;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100643 struct nid_path *path;
644 hda_nid_t nid;
645 int i, dir, parm;
646 unsigned int val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200647
Takashi Iwai666a70d2012-12-17 20:29:29 +0100648 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai08c189f2012-12-19 15:22:24 +0100649 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
Takashi Iwai666a70d2012-12-17 20:29:29 +0100650 break;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200651 }
Takashi Iwai666a70d2012-12-17 20:29:29 +0100652 if (i >= imux->num_items)
653 return;
Takashi Iwaia23b6882009-03-23 15:21:36 +0100654
Takashi Iwai08c189f2012-12-19 15:22:24 +0100655 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
656 get_adc_nid(codec, adc_idx, i));
Takashi Iwai666a70d2012-12-17 20:29:29 +0100657 val = path->ctls[NID_PATH_MUTE_CTL];
658 if (!val)
659 return;
660 nid = get_amp_nid_(val);
661 dir = get_amp_direction_(val);
662 parm = AC_AMP_SET_RIGHT |
663 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
Takashi Iwaia23b6882009-03-23 15:21:36 +0100664
Takashi Iwaic4f3ebe2012-12-20 11:33:20 +0100665 /* flush all cached amps at first */
Takashi Iwaidc870f32013-01-22 15:24:30 +0100666 snd_hda_codec_flush_cache(codec);
Takashi Iwaic4f3ebe2012-12-20 11:33:20 +0100667
Takashi Iwai666a70d2012-12-17 20:29:29 +0100668 /* we care only right channel */
669 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
670 if (val & 0x80) /* if already muted, we don't need to touch */
671 return;
672 val |= 0x80;
673 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
674 parm | val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200675}
676
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200677/*
Takashi Iwai125821a2012-06-22 14:30:29 +0200678 * Inverted digital-mic handling
679 *
680 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
681 * gives the additional mute only to the right channel of the digital mic
682 * capture stream. This is a workaround for avoiding the almost silence
683 * by summing the stereo stream from some (known to be ForteMedia)
684 * digital mic unit.
685 *
686 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
687 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
688 * without caching so that the cache can still keep the original value.
689 * The cached value is then restored when the flag is set off or any other
690 * than d-mic is used as the current input source.
691 */
692static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
693{
694 struct alc_spec *spec = codec->spec;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100695 int src, nums;
Takashi Iwai125821a2012-06-22 14:30:29 +0200696
697 if (!spec->inv_dmic_fixup)
698 return;
699 if (!spec->inv_dmic_muted && !force)
700 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100701 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100702 for (src = 0; src < nums; src++) {
Takashi Iwai125821a2012-06-22 14:30:29 +0200703 bool dmic_fixup = false;
Takashi Iwai125821a2012-06-22 14:30:29 +0200704
705 if (spec->inv_dmic_muted &&
Takashi Iwai08c189f2012-12-19 15:22:24 +0100706 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
Takashi Iwai125821a2012-06-22 14:30:29 +0200707 dmic_fixup = true;
708 if (!dmic_fixup && !force)
709 continue;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100710 alc_inv_dmic_sync_adc(codec, src);
Takashi Iwai125821a2012-06-22 14:30:29 +0200711 }
712}
713
Takashi Iwaia90229e2013-01-18 14:10:00 +0100714static void alc_inv_dmic_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +0100715 struct snd_kcontrol *kcontrol,
716 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai08c189f2012-12-19 15:22:24 +0100717{
718 alc_inv_dmic_sync(codec, false);
719}
720
Takashi Iwai125821a2012-06-22 14:30:29 +0200721static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
722 struct snd_ctl_elem_value *ucontrol)
723{
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725 struct alc_spec *spec = codec->spec;
726
727 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
728 return 0;
729}
730
731static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
735 struct alc_spec *spec = codec->spec;
736 unsigned int val = !ucontrol->value.integer.value[0];
737
738 if (val == spec->inv_dmic_muted)
739 return 0;
740 spec->inv_dmic_muted = val;
741 alc_inv_dmic_sync(codec, true);
742 return 0;
743}
744
745static const struct snd_kcontrol_new alc_inv_dmic_sw = {
746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Takashi Iwaibc549762012-12-18 15:35:11 +0100747 .name = "Inverted Internal Mic Capture Switch",
Takashi Iwai125821a2012-06-22 14:30:29 +0200748 .info = snd_ctl_boolean_mono_info,
749 .get = alc_inv_dmic_sw_get,
750 .put = alc_inv_dmic_sw_put,
751};
752
753static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
754{
755 struct alc_spec *spec = codec->spec;
Takashi Iwai668d1e92012-11-29 14:10:17 +0100756
Takashi Iwai08c189f2012-12-19 15:22:24 +0100757 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
Takashi Iwai125821a2012-06-22 14:30:29 +0200758 return -ENOMEM;
759 spec->inv_dmic_fixup = 1;
760 spec->inv_dmic_muted = 0;
761 spec->inv_dmic_pin = nid;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100762 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
Takashi Iwai125821a2012-06-22 14:30:29 +0200763 return 0;
764}
765
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200766/* typically the digital mic is put at node 0x12 */
767static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +0100768 const struct hda_fixup *fix, int action)
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200769{
Takashi Iwai1727a772013-01-10 09:52:52 +0100770 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200771 alc_add_inv_dmic_mixer(codec, 0x12);
772}
773
Takashi Iwai603c4012008-07-30 15:01:44 +0200774
Takashi Iwai67d634c2009-11-16 15:35:59 +0100775#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100776/* additional beep mixers; the actual parameters are overwritten at build */
Takashi Iwaia9111322011-05-02 11:30:18 +0200777static const struct snd_kcontrol_new alc_beep_mixer[] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100778 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +0200779 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100780 { } /* end */
781};
Takashi Iwai67d634c2009-11-16 15:35:59 +0100782#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100783
Takashi Iwai2eab6942012-12-18 15:30:41 +0100784static int alc_build_controls(struct hda_codec *codec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785{
786 struct alc_spec *spec = codec->spec;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100787 int i, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788
Takashi Iwai08c189f2012-12-19 15:22:24 +0100789 err = snd_hda_gen_build_controls(codec);
790 if (err < 0)
791 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792
793 for (i = 0; i < spec->num_mixers; i++) {
794 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
795 if (err < 0)
796 return err;
797 }
Takashi Iwai2134ea42008-01-10 16:53:55 +0100798
Takashi Iwai67d634c2009-11-16 15:35:59 +0100799#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100800 /* create beep controls if needed */
801 if (spec->beep_amp) {
Takashi Iwaia9111322011-05-02 11:30:18 +0200802 const struct snd_kcontrol_new *knew;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100803 for (knew = alc_beep_mixer; knew->name; knew++) {
804 struct snd_kcontrol *kctl;
805 kctl = snd_ctl_new1(knew, codec);
806 if (!kctl)
807 return -ENOMEM;
808 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +0100809 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100810 if (err < 0)
811 return err;
812 }
813 }
Takashi Iwai67d634c2009-11-16 15:35:59 +0100814#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100815
Takashi Iwai1727a772013-01-10 09:52:52 +0100816 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
Takashi Iwai420b0fe2012-03-12 12:35:27 +0100817 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818}
819
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200820
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100822 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200823 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200824
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825static int alc_init(struct hda_codec *codec)
826{
827 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200828
Takashi Iwai546bb672012-03-07 08:37:19 +0100829 if (spec->init_hook)
830 spec->init_hook(codec);
Kailang Yang526af6e2012-03-07 08:25:20 +0100831
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200832 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200833 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200834
Takashi Iwai08c189f2012-12-19 15:22:24 +0100835 snd_hda_gen_init(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100836
Takashi Iwai1727a772013-01-10 09:52:52 +0100837 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
Takashi Iwaie08a0072006-09-07 17:52:14 +0200838
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 return 0;
840}
841
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100842static inline void alc_shutup(struct hda_codec *codec)
843{
Takashi Iwai1c7161532011-04-07 10:37:16 +0200844 struct alc_spec *spec = codec->spec;
845
846 if (spec && spec->shutup)
847 spec->shutup(codec);
Takashi Iwai9bfb2842013-07-24 14:31:50 +0200848 else
849 snd_hda_shutup_pins(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100850}
851
Takashi Iwai8a02c0c2014-02-10 18:09:45 +0100852#define alc_free snd_hda_gen_free
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853
Takashi Iwai83012a72012-08-24 18:38:08 +0200854#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -0500855static void alc_power_eapd(struct hda_codec *codec)
856{
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200857 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -0500858}
859
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200860static int alc_suspend(struct hda_codec *codec)
Hector Martinf5de24b2009-12-20 22:51:31 +0100861{
862 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100863 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100864 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -0500865 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100866 return 0;
867}
868#endif
869
Takashi Iwai2a439522011-07-26 09:52:50 +0200870#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100871static int alc_resume(struct hda_codec *codec)
872{
Kailang Yang97a26572013-11-29 00:35:26 -0500873 struct alc_spec *spec = codec->spec;
874
875 if (!spec->no_depop_delay)
876 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +0100877 codec->patch_ops.init(codec);
878 snd_hda_codec_resume_amp(codec);
879 snd_hda_codec_resume_cache(codec);
Takashi Iwai125821a2012-06-22 14:30:29 +0200880 alc_inv_dmic_sync(codec, true);
Takashi Iwai9e5341b2010-09-21 09:57:06 +0200881 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +0100882 return 0;
883}
Takashi Iwaie044c392008-10-27 16:56:24 +0100884#endif
885
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886/*
887 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200888static const struct hda_codec_ops alc_patch_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 .build_controls = alc_build_controls,
Takashi Iwai08c189f2012-12-19 15:22:24 +0100890 .build_pcms = snd_hda_gen_build_pcms,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 .init = alc_init,
892 .free = alc_free,
David Henningsson29adc4b2012-09-25 11:31:00 +0200893 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +0200894#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100895 .resume = alc_resume,
Hector Martinf5de24b2009-12-20 22:51:31 +0100896 .suspend = alc_suspend,
Takashi Iwaifce52a32013-01-07 12:42:48 +0100897 .check_power_status = snd_hda_gen_check_power_status,
Takashi Iwaicb53c622007-08-10 17:21:45 +0200898#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -0500899 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900};
901
David Henningsson29adc4b2012-09-25 11:31:00 +0200902
Kailang Yangc027ddc2010-03-19 11:33:06 +0100903/* replace the codec chip_name with the given string */
904static int alc_codec_rename(struct hda_codec *codec, const char *name)
905{
906 kfree(codec->chip_name);
907 codec->chip_name = kstrdup(name, GFP_KERNEL);
908 if (!codec->chip_name) {
909 alc_free(codec);
910 return -ENOMEM;
911 }
912 return 0;
913}
914
Takashi Iwai2fa522b2005-05-12 14:51:12 +0200915/*
Kailang Yang4b016932013-11-28 11:55:09 +0100916 * Rename codecs appropriately from COEF value or subvendor id
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200917 */
918struct alc_codec_rename_table {
919 unsigned int vendor_id;
920 unsigned short coef_mask;
921 unsigned short coef_bits;
922 const char *name;
923};
924
Kailang Yang4b016932013-11-28 11:55:09 +0100925struct alc_codec_rename_pci_table {
926 unsigned int codec_vendor_id;
927 unsigned short pci_subvendor;
928 unsigned short pci_subdevice;
929 const char *name;
930};
931
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200932static struct alc_codec_rename_table rename_tbl[] = {
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800933 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200934 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
935 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
936 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
937 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
938 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
939 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
940 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
Kailang Yangadcc70b2012-05-25 08:08:38 +0200941 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800942 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200943 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
944 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
945 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
946 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
947 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
948 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
949 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
950 { } /* terminator */
951};
952
Kailang Yang4b016932013-11-28 11:55:09 +0100953static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
954 { 0x10ec0280, 0x1028, 0, "ALC3220" },
955 { 0x10ec0282, 0x1028, 0, "ALC3221" },
956 { 0x10ec0283, 0x1028, 0, "ALC3223" },
Kailang Yang193177d2014-04-23 16:06:13 +0800957 { 0x10ec0288, 0x1028, 0, "ALC3263" },
Kailang Yang4b016932013-11-28 11:55:09 +0100958 { 0x10ec0292, 0x1028, 0, "ALC3226" },
Kailang Yang193177d2014-04-23 16:06:13 +0800959 { 0x10ec0293, 0x1028, 0, "ALC3235" },
Kailang Yang4b016932013-11-28 11:55:09 +0100960 { 0x10ec0255, 0x1028, 0, "ALC3234" },
961 { 0x10ec0668, 0x1028, 0, "ALC3661" },
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800962 { 0x10ec0275, 0x1028, 0, "ALC3260" },
963 { 0x10ec0899, 0x1028, 0, "ALC3861" },
964 { 0x10ec0670, 0x1025, 0, "ALC669X" },
965 { 0x10ec0676, 0x1025, 0, "ALC679X" },
966 { 0x10ec0282, 0x1043, 0, "ALC3229" },
967 { 0x10ec0233, 0x1043, 0, "ALC3236" },
968 { 0x10ec0280, 0x103c, 0, "ALC3228" },
969 { 0x10ec0282, 0x103c, 0, "ALC3227" },
970 { 0x10ec0286, 0x103c, 0, "ALC3242" },
971 { 0x10ec0290, 0x103c, 0, "ALC3241" },
972 { 0x10ec0668, 0x103c, 0, "ALC3662" },
973 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
974 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
Kailang Yang4b016932013-11-28 11:55:09 +0100975 { } /* terminator */
976};
977
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200978static int alc_codec_rename_from_preset(struct hda_codec *codec)
979{
980 const struct alc_codec_rename_table *p;
Kailang Yang4b016932013-11-28 11:55:09 +0100981 const struct alc_codec_rename_pci_table *q;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200982
983 for (p = rename_tbl; p->vendor_id; p++) {
984 if (p->vendor_id != codec->vendor_id)
985 continue;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200986 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200987 return alc_codec_rename(codec, p->name);
988 }
Kailang Yang4b016932013-11-28 11:55:09 +0100989
Takashi Iwai5100cd02014-02-15 10:03:19 +0100990 if (!codec->bus->pci)
991 return 0;
Kailang Yang4b016932013-11-28 11:55:09 +0100992 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
993 if (q->codec_vendor_id != codec->vendor_id)
994 continue;
995 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
996 continue;
997 if (!q->pci_subdevice ||
998 q->pci_subdevice == codec->bus->pci->subsystem_device)
999 return alc_codec_rename(codec, q->name);
1000 }
1001
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001002 return 0;
1003}
1004
Takashi Iwaie4770622011-07-08 11:11:35 +02001005
1006/*
Takashi Iwai1d045db2011-07-07 18:23:21 +02001007 * Digital-beep handlers
1008 */
1009#ifdef CONFIG_SND_HDA_INPUT_BEEP
1010#define set_beep_amp(spec, nid, idx, dir) \
1011 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
1012
1013static const struct snd_pci_quirk beep_white_list[] = {
Duncan Roe71100052012-10-10 14:19:50 +02001014 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
W. Trevor Kinga4b7f21d2014-03-29 17:47:24 -07001015 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001016 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai8554ee42013-02-25 09:54:43 +01001017 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001018 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1019 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1020 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
Takashi Iwai78f8baf2012-03-06 14:02:32 +01001021 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001022 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1023 {}
1024};
1025
1026static inline int has_cdefine_beep(struct hda_codec *codec)
1027{
1028 struct alc_spec *spec = codec->spec;
1029 const struct snd_pci_quirk *q;
1030 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1031 if (q)
1032 return q->value;
1033 return spec->cdefine.enable_pcbeep;
1034}
1035#else
1036#define set_beep_amp(spec, nid, idx, dir) /* NOP */
1037#define has_cdefine_beep(codec) 0
1038#endif
1039
1040/* parse the BIOS configuration and set up the alc_spec */
1041/* return 1 if successful, 0 if the proper config is not found,
1042 * or a negative error code
1043 */
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001044static int alc_parse_auto_config(struct hda_codec *codec,
1045 const hda_nid_t *ignore_nids,
1046 const hda_nid_t *ssid_nids)
Takashi Iwai1d045db2011-07-07 18:23:21 +02001047{
1048 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001049 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001050 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001051
Takashi Iwai53c334a2011-08-23 18:27:14 +02001052 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1053 spec->parse_flags);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001054 if (err < 0)
1055 return err;
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001056
1057 if (ssid_nids)
1058 alc_ssid_check(codec, ssid_nids);
1059
Takashi Iwai08c189f2012-12-19 15:22:24 +01001060 err = snd_hda_gen_parse_auto_config(codec, cfg);
1061 if (err < 0)
1062 return err;
Takashi Iwai070cff42012-02-21 12:54:17 +01001063
Takashi Iwai1d045db2011-07-07 18:23:21 +02001064 return 1;
1065}
1066
Takashi Iwai3de95172012-05-07 18:03:15 +02001067/* common preparation job for alc_spec */
1068static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1069{
1070 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1071 int err;
1072
1073 if (!spec)
1074 return -ENOMEM;
1075 codec->spec = spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001076 snd_hda_gen_spec_init(&spec->gen);
1077 spec->gen.mixer_nid = mixer_nid;
1078 spec->gen.own_eapd_ctl = 1;
Takashi Iwai1098b7c2012-12-17 20:03:15 +01001079 codec->single_adc_amp = 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001080 /* FIXME: do we need this for all Realtek codec models? */
1081 codec->spdif_status_reset = 1;
Takashi Iwai3de95172012-05-07 18:03:15 +02001082
1083 err = alc_codec_rename_from_preset(codec);
1084 if (err < 0) {
1085 kfree(spec);
1086 return err;
1087 }
1088 return 0;
1089}
1090
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001091static int alc880_parse_auto_config(struct hda_codec *codec)
1092{
1093 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02001094 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001095 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1096}
1097
Takashi Iwai1d045db2011-07-07 18:23:21 +02001098/*
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001099 * ALC880 fix-ups
1100 */
1101enum {
Takashi Iwai411225a2012-02-20 17:48:19 +01001102 ALC880_FIXUP_GPIO1,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001103 ALC880_FIXUP_GPIO2,
1104 ALC880_FIXUP_MEDION_RIM,
Takashi Iwaidc6af522012-02-17 16:18:59 +01001105 ALC880_FIXUP_LG,
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001106 ALC880_FIXUP_LG_LW25,
Takashi Iwaif02aab52012-02-17 16:33:56 +01001107 ALC880_FIXUP_W810,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001108 ALC880_FIXUP_EAPD_COEF,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001109 ALC880_FIXUP_TCL_S700,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001110 ALC880_FIXUP_VOL_KNOB,
1111 ALC880_FIXUP_FUJITSU,
Takashi Iwaiba533812012-02-20 16:36:52 +01001112 ALC880_FIXUP_F1734,
Takashi Iwai817de922012-02-20 17:20:48 +01001113 ALC880_FIXUP_UNIWILL,
Takashi Iwai967b88c2012-02-20 17:31:02 +01001114 ALC880_FIXUP_UNIWILL_DIG,
Takashi Iwai96e225f2012-02-20 17:41:51 +01001115 ALC880_FIXUP_Z71V,
Takashi Iwai487a5882013-11-07 07:29:30 +01001116 ALC880_FIXUP_ASUS_W5A,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001117 ALC880_FIXUP_3ST_BASE,
1118 ALC880_FIXUP_3ST,
1119 ALC880_FIXUP_3ST_DIG,
1120 ALC880_FIXUP_5ST_BASE,
1121 ALC880_FIXUP_5ST,
1122 ALC880_FIXUP_5ST_DIG,
1123 ALC880_FIXUP_6ST_BASE,
1124 ALC880_FIXUP_6ST,
1125 ALC880_FIXUP_6ST_DIG,
Takashi Iwai53971452013-01-23 18:21:37 +01001126 ALC880_FIXUP_6ST_AUTOMUTE,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001127};
1128
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001129/* enable the volume-knob widget support on NID 0x21 */
1130static void alc880_fixup_vol_knob(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001131 const struct hda_fixup *fix, int action)
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001132{
Takashi Iwai1727a772013-01-10 09:52:52 +01001133 if (action == HDA_FIXUP_ACT_PROBE)
David Henningsson29adc4b2012-09-25 11:31:00 +02001134 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001135}
1136
Takashi Iwai1727a772013-01-10 09:52:52 +01001137static const struct hda_fixup alc880_fixups[] = {
Takashi Iwai411225a2012-02-20 17:48:19 +01001138 [ALC880_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001139 .type = HDA_FIXUP_VERBS,
Takashi Iwai411225a2012-02-20 17:48:19 +01001140 .v.verbs = alc_gpio1_init_verbs,
1141 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001142 [ALC880_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001143 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001144 .v.verbs = alc_gpio2_init_verbs,
1145 },
1146 [ALC880_FIXUP_MEDION_RIM] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001147 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001148 .v.verbs = (const struct hda_verb[]) {
1149 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1150 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1151 { }
1152 },
1153 .chained = true,
1154 .chain_id = ALC880_FIXUP_GPIO2,
1155 },
Takashi Iwaidc6af522012-02-17 16:18:59 +01001156 [ALC880_FIXUP_LG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001157 .type = HDA_FIXUP_PINS,
1158 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaidc6af522012-02-17 16:18:59 +01001159 /* disable bogus unused pins */
1160 { 0x16, 0x411111f0 },
1161 { 0x18, 0x411111f0 },
1162 { 0x1a, 0x411111f0 },
1163 { }
1164 }
1165 },
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001166 [ALC880_FIXUP_LG_LW25] = {
1167 .type = HDA_FIXUP_PINS,
1168 .v.pins = (const struct hda_pintbl[]) {
1169 { 0x1a, 0x0181344f }, /* line-in */
1170 { 0x1b, 0x0321403f }, /* headphone */
1171 { }
1172 }
1173 },
Takashi Iwaif02aab52012-02-17 16:33:56 +01001174 [ALC880_FIXUP_W810] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001175 .type = HDA_FIXUP_PINS,
1176 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001177 /* disable bogus unused pins */
1178 { 0x17, 0x411111f0 },
1179 { }
1180 },
1181 .chained = true,
1182 .chain_id = ALC880_FIXUP_GPIO2,
1183 },
Takashi Iwai27e917f2012-02-17 17:49:54 +01001184 [ALC880_FIXUP_EAPD_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001185 .type = HDA_FIXUP_VERBS,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001186 .v.verbs = (const struct hda_verb[]) {
1187 /* change to EAPD mode */
1188 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1189 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1190 {}
1191 },
1192 },
Takashi Iwaib9368f52012-02-17 17:54:44 +01001193 [ALC880_FIXUP_TCL_S700] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001194 .type = HDA_FIXUP_VERBS,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001195 .v.verbs = (const struct hda_verb[]) {
1196 /* change to EAPD mode */
1197 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1198 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1199 {}
1200 },
1201 .chained = true,
1202 .chain_id = ALC880_FIXUP_GPIO2,
1203 },
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001204 [ALC880_FIXUP_VOL_KNOB] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001205 .type = HDA_FIXUP_FUNC,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001206 .v.func = alc880_fixup_vol_knob,
1207 },
1208 [ALC880_FIXUP_FUJITSU] = {
1209 /* override all pins as BIOS on old Amilo is broken */
Takashi Iwai1727a772013-01-10 09:52:52 +01001210 .type = HDA_FIXUP_PINS,
1211 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001212 { 0x14, 0x0121411f }, /* HP */
1213 { 0x15, 0x99030120 }, /* speaker */
1214 { 0x16, 0x99030130 }, /* bass speaker */
1215 { 0x17, 0x411111f0 }, /* N/A */
1216 { 0x18, 0x411111f0 }, /* N/A */
1217 { 0x19, 0x01a19950 }, /* mic-in */
1218 { 0x1a, 0x411111f0 }, /* N/A */
1219 { 0x1b, 0x411111f0 }, /* N/A */
1220 { 0x1c, 0x411111f0 }, /* N/A */
1221 { 0x1d, 0x411111f0 }, /* N/A */
1222 { 0x1e, 0x01454140 }, /* SPDIF out */
1223 { }
1224 },
1225 .chained = true,
1226 .chain_id = ALC880_FIXUP_VOL_KNOB,
1227 },
Takashi Iwaiba533812012-02-20 16:36:52 +01001228 [ALC880_FIXUP_F1734] = {
1229 /* almost compatible with FUJITSU, but no bass and SPDIF */
Takashi Iwai1727a772013-01-10 09:52:52 +01001230 .type = HDA_FIXUP_PINS,
1231 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiba533812012-02-20 16:36:52 +01001232 { 0x14, 0x0121411f }, /* HP */
1233 { 0x15, 0x99030120 }, /* speaker */
1234 { 0x16, 0x411111f0 }, /* N/A */
1235 { 0x17, 0x411111f0 }, /* N/A */
1236 { 0x18, 0x411111f0 }, /* N/A */
1237 { 0x19, 0x01a19950 }, /* mic-in */
1238 { 0x1a, 0x411111f0 }, /* N/A */
1239 { 0x1b, 0x411111f0 }, /* N/A */
1240 { 0x1c, 0x411111f0 }, /* N/A */
1241 { 0x1d, 0x411111f0 }, /* N/A */
1242 { 0x1e, 0x411111f0 }, /* N/A */
1243 { }
1244 },
1245 .chained = true,
1246 .chain_id = ALC880_FIXUP_VOL_KNOB,
1247 },
Takashi Iwai817de922012-02-20 17:20:48 +01001248 [ALC880_FIXUP_UNIWILL] = {
1249 /* need to fix HP and speaker pins to be parsed correctly */
Takashi Iwai1727a772013-01-10 09:52:52 +01001250 .type = HDA_FIXUP_PINS,
1251 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai817de922012-02-20 17:20:48 +01001252 { 0x14, 0x0121411f }, /* HP */
1253 { 0x15, 0x99030120 }, /* speaker */
1254 { 0x16, 0x99030130 }, /* bass speaker */
1255 { }
1256 },
1257 },
Takashi Iwai967b88c2012-02-20 17:31:02 +01001258 [ALC880_FIXUP_UNIWILL_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001259 .type = HDA_FIXUP_PINS,
1260 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai967b88c2012-02-20 17:31:02 +01001261 /* disable bogus unused pins */
1262 { 0x17, 0x411111f0 },
1263 { 0x19, 0x411111f0 },
1264 { 0x1b, 0x411111f0 },
1265 { 0x1f, 0x411111f0 },
1266 { }
1267 }
1268 },
Takashi Iwai96e225f2012-02-20 17:41:51 +01001269 [ALC880_FIXUP_Z71V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001270 .type = HDA_FIXUP_PINS,
1271 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai96e225f2012-02-20 17:41:51 +01001272 /* set up the whole pins as BIOS is utterly broken */
1273 { 0x14, 0x99030120 }, /* speaker */
1274 { 0x15, 0x0121411f }, /* HP */
1275 { 0x16, 0x411111f0 }, /* N/A */
1276 { 0x17, 0x411111f0 }, /* N/A */
1277 { 0x18, 0x01a19950 }, /* mic-in */
1278 { 0x19, 0x411111f0 }, /* N/A */
1279 { 0x1a, 0x01813031 }, /* line-in */
1280 { 0x1b, 0x411111f0 }, /* N/A */
1281 { 0x1c, 0x411111f0 }, /* N/A */
1282 { 0x1d, 0x411111f0 }, /* N/A */
1283 { 0x1e, 0x0144111e }, /* SPDIF */
1284 { }
1285 }
1286 },
Takashi Iwai487a5882013-11-07 07:29:30 +01001287 [ALC880_FIXUP_ASUS_W5A] = {
1288 .type = HDA_FIXUP_PINS,
1289 .v.pins = (const struct hda_pintbl[]) {
1290 /* set up the whole pins as BIOS is utterly broken */
1291 { 0x14, 0x0121411f }, /* HP */
1292 { 0x15, 0x411111f0 }, /* N/A */
1293 { 0x16, 0x411111f0 }, /* N/A */
1294 { 0x17, 0x411111f0 }, /* N/A */
1295 { 0x18, 0x90a60160 }, /* mic */
1296 { 0x19, 0x411111f0 }, /* N/A */
1297 { 0x1a, 0x411111f0 }, /* N/A */
1298 { 0x1b, 0x411111f0 }, /* N/A */
1299 { 0x1c, 0x411111f0 }, /* N/A */
1300 { 0x1d, 0x411111f0 }, /* N/A */
1301 { 0x1e, 0xb743111e }, /* SPDIF out */
1302 { }
1303 },
1304 .chained = true,
1305 .chain_id = ALC880_FIXUP_GPIO1,
1306 },
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001307 [ALC880_FIXUP_3ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001308 .type = HDA_FIXUP_PINS,
1309 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001310 { 0x14, 0x01014010 }, /* line-out */
1311 { 0x15, 0x411111f0 }, /* N/A */
1312 { 0x16, 0x411111f0 }, /* N/A */
1313 { 0x17, 0x411111f0 }, /* N/A */
1314 { 0x18, 0x01a19c30 }, /* mic-in */
1315 { 0x19, 0x0121411f }, /* HP */
1316 { 0x1a, 0x01813031 }, /* line-in */
1317 { 0x1b, 0x02a19c40 }, /* front-mic */
1318 { 0x1c, 0x411111f0 }, /* N/A */
1319 { 0x1d, 0x411111f0 }, /* N/A */
1320 /* 0x1e is filled in below */
1321 { 0x1f, 0x411111f0 }, /* N/A */
1322 { }
1323 }
1324 },
1325 [ALC880_FIXUP_3ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001326 .type = HDA_FIXUP_PINS,
1327 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001328 { 0x1e, 0x411111f0 }, /* N/A */
1329 { }
1330 },
1331 .chained = true,
1332 .chain_id = ALC880_FIXUP_3ST_BASE,
1333 },
1334 [ALC880_FIXUP_3ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001335 .type = HDA_FIXUP_PINS,
1336 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001337 { 0x1e, 0x0144111e }, /* SPDIF */
1338 { }
1339 },
1340 .chained = true,
1341 .chain_id = ALC880_FIXUP_3ST_BASE,
1342 },
1343 [ALC880_FIXUP_5ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001344 .type = HDA_FIXUP_PINS,
1345 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001346 { 0x14, 0x01014010 }, /* front */
1347 { 0x15, 0x411111f0 }, /* N/A */
1348 { 0x16, 0x01011411 }, /* CLFE */
1349 { 0x17, 0x01016412 }, /* surr */
1350 { 0x18, 0x01a19c30 }, /* mic-in */
1351 { 0x19, 0x0121411f }, /* HP */
1352 { 0x1a, 0x01813031 }, /* line-in */
1353 { 0x1b, 0x02a19c40 }, /* front-mic */
1354 { 0x1c, 0x411111f0 }, /* N/A */
1355 { 0x1d, 0x411111f0 }, /* N/A */
1356 /* 0x1e is filled in below */
1357 { 0x1f, 0x411111f0 }, /* N/A */
1358 { }
1359 }
1360 },
1361 [ALC880_FIXUP_5ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001362 .type = HDA_FIXUP_PINS,
1363 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001364 { 0x1e, 0x411111f0 }, /* N/A */
1365 { }
1366 },
1367 .chained = true,
1368 .chain_id = ALC880_FIXUP_5ST_BASE,
1369 },
1370 [ALC880_FIXUP_5ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001371 .type = HDA_FIXUP_PINS,
1372 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001373 { 0x1e, 0x0144111e }, /* SPDIF */
1374 { }
1375 },
1376 .chained = true,
1377 .chain_id = ALC880_FIXUP_5ST_BASE,
1378 },
1379 [ALC880_FIXUP_6ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001380 .type = HDA_FIXUP_PINS,
1381 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001382 { 0x14, 0x01014010 }, /* front */
1383 { 0x15, 0x01016412 }, /* surr */
1384 { 0x16, 0x01011411 }, /* CLFE */
1385 { 0x17, 0x01012414 }, /* side */
1386 { 0x18, 0x01a19c30 }, /* mic-in */
1387 { 0x19, 0x02a19c40 }, /* front-mic */
1388 { 0x1a, 0x01813031 }, /* line-in */
1389 { 0x1b, 0x0121411f }, /* HP */
1390 { 0x1c, 0x411111f0 }, /* N/A */
1391 { 0x1d, 0x411111f0 }, /* N/A */
1392 /* 0x1e is filled in below */
1393 { 0x1f, 0x411111f0 }, /* N/A */
1394 { }
1395 }
1396 },
1397 [ALC880_FIXUP_6ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001398 .type = HDA_FIXUP_PINS,
1399 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001400 { 0x1e, 0x411111f0 }, /* N/A */
1401 { }
1402 },
1403 .chained = true,
1404 .chain_id = ALC880_FIXUP_6ST_BASE,
1405 },
1406 [ALC880_FIXUP_6ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001407 .type = HDA_FIXUP_PINS,
1408 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001409 { 0x1e, 0x0144111e }, /* SPDIF */
1410 { }
1411 },
1412 .chained = true,
1413 .chain_id = ALC880_FIXUP_6ST_BASE,
1414 },
Takashi Iwai53971452013-01-23 18:21:37 +01001415 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1416 .type = HDA_FIXUP_PINS,
1417 .v.pins = (const struct hda_pintbl[]) {
1418 { 0x1b, 0x0121401f }, /* HP with jack detect */
1419 { }
1420 },
1421 .chained_before = true,
1422 .chain_id = ALC880_FIXUP_6ST_BASE,
1423 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001424};
1425
1426static const struct snd_pci_quirk alc880_fixup_tbl[] = {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001427 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
Takashi Iwai487a5882013-11-07 07:29:30 +01001428 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
Takashi Iwai96e225f2012-02-20 17:41:51 +01001429 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001430 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
David Henningsson6538de02014-06-10 10:52:50 +02001431 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001432 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
Takashi Iwai27e917f2012-02-17 17:49:54 +01001433 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
Takashi Iwai967b88c2012-02-20 17:31:02 +01001434 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
Takashi Iwaiba533812012-02-20 16:36:52 +01001435 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
Takashi Iwai817de922012-02-20 17:20:48 +01001436 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
Takashi Iwai7833c7e2012-02-20 17:11:38 +01001437 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
Takashi Iwaif02aab52012-02-17 16:33:56 +01001438 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001439 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
Takashi Iwai53971452013-01-23 18:21:37 +01001440 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwaiba533812012-02-20 16:36:52 +01001441 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001442 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
Takashi Iwaiba533812012-02-20 16:36:52 +01001443 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001444 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
Takashi Iwaidc6af522012-02-17 16:18:59 +01001445 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1446 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1447 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001448 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
Takashi Iwaib9368f52012-02-17 17:54:44 +01001449 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001450
1451 /* Below is the copied entries from alc880_quirks.c.
1452 * It's not quite sure whether BIOS sets the correct pin-config table
1453 * on these machines, thus they are kept to be compatible with
1454 * the old static quirks. Once when it's confirmed to work without
1455 * these overrides, it'd be better to remove.
1456 */
1457 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1458 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1459 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1460 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1461 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1462 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1463 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1464 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1465 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1466 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1467 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1468 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1469 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1470 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1471 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1472 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1473 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1474 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1475 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1476 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1477 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1478 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1479 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1480 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1481 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1482 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1483 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1484 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1485 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1486 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1487 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1488 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1489 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1490 /* default Intel */
1491 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1492 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1493 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1494 {}
1495};
1496
Takashi Iwai1727a772013-01-10 09:52:52 +01001497static const struct hda_model_fixup alc880_fixup_models[] = {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001498 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1499 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1500 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1501 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1502 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1503 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
Takashi Iwai53971452013-01-23 18:21:37 +01001504 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001505 {}
1506};
1507
1508
1509/*
Takashi Iwai1d045db2011-07-07 18:23:21 +02001510 * OK, here we have finally the patch for ALC880
1511 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001512static int patch_alc880(struct hda_codec *codec)
1513{
1514 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001515 int err;
1516
Takashi Iwai3de95172012-05-07 18:03:15 +02001517 err = alc_alloc_spec(codec, 0x0b);
1518 if (err < 0)
1519 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001520
Takashi Iwai3de95172012-05-07 18:03:15 +02001521 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001522 spec->gen.need_dac_fix = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001523 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001524
Takashi Iwai1727a772013-01-10 09:52:52 +01001525 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001526 alc880_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001527 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001528
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001529 /* automatic parse from the BIOS config */
1530 err = alc880_parse_auto_config(codec);
1531 if (err < 0)
1532 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001533
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001534 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001535 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001536
Takashi Iwai1d045db2011-07-07 18:23:21 +02001537 codec->patch_ops = alc_patch_ops;
David Henningsson29adc4b2012-09-25 11:31:00 +02001538 codec->patch_ops.unsol_event = alc880_unsol_event;
1539
Takashi Iwai1d045db2011-07-07 18:23:21 +02001540
Takashi Iwai1727a772013-01-10 09:52:52 +01001541 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001542
Takashi Iwai1d045db2011-07-07 18:23:21 +02001543 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001544
1545 error:
1546 alc_free(codec);
1547 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001548}
1549
1550
1551/*
1552 * ALC260 support
1553 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001554static int alc260_parse_auto_config(struct hda_codec *codec)
1555{
Takashi Iwai1d045db2011-07-07 18:23:21 +02001556 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001557 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1558 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001559}
1560
Takashi Iwai1d045db2011-07-07 18:23:21 +02001561/*
1562 * Pin config fixes
1563 */
1564enum {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001565 ALC260_FIXUP_HP_DC5750,
1566 ALC260_FIXUP_HP_PIN_0F,
1567 ALC260_FIXUP_COEF,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001568 ALC260_FIXUP_GPIO1,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001569 ALC260_FIXUP_GPIO1_TOGGLE,
1570 ALC260_FIXUP_REPLACER,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001571 ALC260_FIXUP_HP_B1900,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001572 ALC260_FIXUP_KN1,
Takashi Iwai39aedee2013-01-10 17:10:40 +01001573 ALC260_FIXUP_FSC_S7020,
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001574 ALC260_FIXUP_FSC_S7020_JWSE,
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001575 ALC260_FIXUP_VAIO_PINS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001576};
1577
Takashi Iwai20f7d922012-02-16 12:35:16 +01001578static void alc260_gpio1_automute(struct hda_codec *codec)
1579{
1580 struct alc_spec *spec = codec->spec;
1581 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwai08c189f2012-12-19 15:22:24 +01001582 spec->gen.hp_jack_present);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001583}
1584
1585static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001586 const struct hda_fixup *fix, int action)
Takashi Iwai20f7d922012-02-16 12:35:16 +01001587{
1588 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001589 if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwai20f7d922012-02-16 12:35:16 +01001590 /* although the machine has only one output pin, we need to
1591 * toggle GPIO1 according to the jack state
1592 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01001593 spec->gen.automute_hook = alc260_gpio1_automute;
1594 spec->gen.detect_hp = 1;
1595 spec->gen.automute_speaker = 1;
1596 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1597 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
1598 snd_hda_gen_hp_automute);
Takashi Iwaic9ce6b22012-12-18 18:12:44 +01001599 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001600 }
1601}
1602
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001603static void alc260_fixup_kn1(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001604 const struct hda_fixup *fix, int action)
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001605{
1606 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001607 static const struct hda_pintbl pincfgs[] = {
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001608 { 0x0f, 0x02214000 }, /* HP/speaker */
1609 { 0x12, 0x90a60160 }, /* int mic */
1610 { 0x13, 0x02a19000 }, /* ext mic */
1611 { 0x18, 0x01446000 }, /* SPDIF out */
1612 /* disable bogus I/O pins */
1613 { 0x10, 0x411111f0 },
1614 { 0x11, 0x411111f0 },
1615 { 0x14, 0x411111f0 },
1616 { 0x15, 0x411111f0 },
1617 { 0x16, 0x411111f0 },
1618 { 0x17, 0x411111f0 },
1619 { 0x19, 0x411111f0 },
1620 { }
1621 };
1622
1623 switch (action) {
Takashi Iwai1727a772013-01-10 09:52:52 +01001624 case HDA_FIXUP_ACT_PRE_PROBE:
1625 snd_hda_apply_pincfgs(codec, pincfgs);
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001626 break;
Takashi Iwai1727a772013-01-10 09:52:52 +01001627 case HDA_FIXUP_ACT_PROBE:
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001628 spec->init_amp = ALC_INIT_NONE;
1629 break;
1630 }
1631}
1632
Takashi Iwai39aedee2013-01-10 17:10:40 +01001633static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1634 const struct hda_fixup *fix, int action)
1635{
1636 struct alc_spec *spec = codec->spec;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001637 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001638 spec->init_amp = ALC_INIT_NONE;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001639}
1640
1641static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1642 const struct hda_fixup *fix, int action)
1643{
1644 struct alc_spec *spec = codec->spec;
1645 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaif811c3c2013-03-07 18:32:59 +01001646 spec->gen.add_jack_modes = 1;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001647 spec->gen.hp_mic = 1;
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001648 }
Takashi Iwai39aedee2013-01-10 17:10:40 +01001649}
1650
Takashi Iwai1727a772013-01-10 09:52:52 +01001651static const struct hda_fixup alc260_fixups[] = {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001652 [ALC260_FIXUP_HP_DC5750] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001653 .type = HDA_FIXUP_PINS,
1654 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001655 { 0x11, 0x90130110 }, /* speaker */
1656 { }
1657 }
1658 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001659 [ALC260_FIXUP_HP_PIN_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001660 .type = HDA_FIXUP_PINS,
1661 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001662 { 0x0f, 0x01214000 }, /* HP */
1663 { }
1664 }
1665 },
1666 [ALC260_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001667 .type = HDA_FIXUP_VERBS,
Takashi Iwaica8f0422012-02-16 11:51:19 +01001668 .v.verbs = (const struct hda_verb[]) {
Ronan Marquete30cf2d2014-06-01 18:38:53 +02001669 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1670 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001671 { }
1672 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001673 },
Takashi Iwai15317ab2012-02-16 12:02:53 +01001674 [ALC260_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001675 .type = HDA_FIXUP_VERBS,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001676 .v.verbs = alc_gpio1_init_verbs,
1677 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001678 [ALC260_FIXUP_GPIO1_TOGGLE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001679 .type = HDA_FIXUP_FUNC,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001680 .v.func = alc260_fixup_gpio1_toggle,
1681 .chained = true,
1682 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1683 },
1684 [ALC260_FIXUP_REPLACER] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001685 .type = HDA_FIXUP_VERBS,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001686 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai192a98e2014-06-02 15:16:07 +02001687 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1688 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001689 { }
1690 },
1691 .chained = true,
1692 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1693 },
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001694 [ALC260_FIXUP_HP_B1900] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001695 .type = HDA_FIXUP_FUNC,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001696 .v.func = alc260_fixup_gpio1_toggle,
1697 .chained = true,
1698 .chain_id = ALC260_FIXUP_COEF,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001699 },
1700 [ALC260_FIXUP_KN1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001701 .type = HDA_FIXUP_FUNC,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001702 .v.func = alc260_fixup_kn1,
1703 },
Takashi Iwai39aedee2013-01-10 17:10:40 +01001704 [ALC260_FIXUP_FSC_S7020] = {
1705 .type = HDA_FIXUP_FUNC,
1706 .v.func = alc260_fixup_fsc_s7020,
1707 },
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001708 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1709 .type = HDA_FIXUP_FUNC,
1710 .v.func = alc260_fixup_fsc_s7020_jwse,
1711 .chained = true,
1712 .chain_id = ALC260_FIXUP_FSC_S7020,
1713 },
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001714 [ALC260_FIXUP_VAIO_PINS] = {
1715 .type = HDA_FIXUP_PINS,
1716 .v.pins = (const struct hda_pintbl[]) {
1717 /* Pin configs are missing completely on some VAIOs */
1718 { 0x0f, 0x01211020 },
1719 { 0x10, 0x0001003f },
1720 { 0x11, 0x411111f0 },
1721 { 0x12, 0x01a15930 },
1722 { 0x13, 0x411111f0 },
1723 { 0x14, 0x411111f0 },
1724 { 0x15, 0x411111f0 },
1725 { 0x16, 0x411111f0 },
1726 { 0x17, 0x411111f0 },
1727 { 0x18, 0x411111f0 },
1728 { 0x19, 0x411111f0 },
1729 { }
1730 }
1731 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02001732};
1733
1734static const struct snd_pci_quirk alc260_fixup_tbl[] = {
Takashi Iwai15317ab2012-02-16 12:02:53 +01001735 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001736 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
Takashi Iwai15317ab2012-02-16 12:02:53 +01001737 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001738 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001739 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001740 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
Takashi Iwai0f5a5b82013-11-21 09:12:52 +01001741 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
Takashi Iwai39aedee2013-01-10 17:10:40 +01001742 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
Takashi Iwaib1f58082012-02-16 12:45:03 +01001743 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001744 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
Takashi Iwai20f7d922012-02-16 12:35:16 +01001745 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001746 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001747 {}
1748};
1749
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001750static const struct hda_model_fixup alc260_fixup_models[] = {
1751 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1752 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1753 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1754 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1755 {}
1756};
1757
Takashi Iwai1d045db2011-07-07 18:23:21 +02001758/*
1759 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001760static int patch_alc260(struct hda_codec *codec)
1761{
1762 struct alc_spec *spec;
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001763 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001764
Takashi Iwai3de95172012-05-07 18:03:15 +02001765 err = alc_alloc_spec(codec, 0x07);
1766 if (err < 0)
1767 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001768
Takashi Iwai3de95172012-05-07 18:03:15 +02001769 spec = codec->spec;
Takashi Iwaiea46c3c2013-01-15 18:45:53 +01001770 /* as quite a few machines require HP amp for speaker outputs,
1771 * it's easier to enable it unconditionally; even if it's unneeded,
1772 * it's almost harmless.
1773 */
1774 spec->gen.prefer_hp_amp = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001775 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001776
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001777 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1778 alc260_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001779 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001780
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001781 /* automatic parse from the BIOS config */
1782 err = alc260_parse_auto_config(codec);
1783 if (err < 0)
1784 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001785
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001786 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001787 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001788
Takashi Iwai1d045db2011-07-07 18:23:21 +02001789 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001790 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001791
Takashi Iwai1727a772013-01-10 09:52:52 +01001792 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001793
Takashi Iwai1d045db2011-07-07 18:23:21 +02001794 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001795
1796 error:
1797 alc_free(codec);
1798 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001799}
1800
1801
1802/*
1803 * ALC882/883/885/888/889 support
1804 *
1805 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1806 * configuration. Each pin widget can choose any input DACs and a mixer.
1807 * Each ADC is connected from a mixer of all inputs. This makes possible
1808 * 6-channel independent captures.
1809 *
1810 * In addition, an independent DAC for the multi-playback (not used in this
1811 * driver yet).
1812 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001813
1814/*
1815 * Pin config fixes
1816 */
1817enum {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001818 ALC882_FIXUP_ABIT_AW9D_MAX,
1819 ALC882_FIXUP_LENOVO_Y530,
1820 ALC882_FIXUP_PB_M5210,
1821 ALC882_FIXUP_ACER_ASPIRE_7736,
1822 ALC882_FIXUP_ASUS_W90V,
Marton Balint8f239212012-03-05 21:33:23 +01001823 ALC889_FIXUP_CD,
David Henningssonb2c53e22014-01-01 14:01:34 +01001824 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001825 ALC889_FIXUP_VAIO_TT,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001826 ALC888_FIXUP_EEE1601,
Takashi Iwai177943a32011-11-09 12:55:18 +01001827 ALC882_FIXUP_EAPD,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01001828 ALC883_FIXUP_EAPD,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01001829 ALC883_FIXUP_ACER_EAPD,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001830 ALC882_FIXUP_GPIO1,
1831 ALC882_FIXUP_GPIO2,
Takashi Iwaieb844d52011-11-09 18:03:07 +01001832 ALC882_FIXUP_GPIO3,
Takashi Iwai68ef0562011-11-09 18:24:44 +01001833 ALC889_FIXUP_COEF,
1834 ALC882_FIXUP_ASUS_W2JC,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001835 ALC882_FIXUP_ACER_ASPIRE_4930G,
1836 ALC882_FIXUP_ACER_ASPIRE_8930G,
1837 ALC882_FIXUP_ASPIRE_8930G_VERBS,
Takashi Iwai56710872011-11-14 17:42:11 +01001838 ALC885_FIXUP_MACPRO_GPIO,
Takashi Iwai02a237b2012-02-13 15:25:07 +01001839 ALC889_FIXUP_DAC_ROUTE,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001840 ALC889_FIXUP_MBP_VREF,
1841 ALC889_FIXUP_IMAC91_VREF,
Adrien Vergée7729a42014-01-24 14:56:14 -05001842 ALC889_FIXUP_MBA11_VREF,
Takashi Iwai0756f092013-12-04 13:59:45 +01001843 ALC889_FIXUP_MBA21_VREF,
Takashi Iwaic20f31e2014-02-03 11:02:10 +01001844 ALC889_FIXUP_MP11_VREF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02001845 ALC882_FIXUP_INV_DMIC,
Takashi Iwaie427c232012-07-29 10:04:08 +02001846 ALC882_FIXUP_NO_PRIMARY_HP,
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01001847 ALC887_FIXUP_ASUS_BASS,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01001848 ALC887_FIXUP_BASS_CHMAP,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001849};
1850
Takashi Iwai68ef0562011-11-09 18:24:44 +01001851static void alc889_fixup_coef(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001852 const struct hda_fixup *fix, int action)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001853{
Takashi Iwai1727a772013-01-10 09:52:52 +01001854 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001855 return;
1856 alc889_coef_init(codec);
1857}
1858
Takashi Iwai56710872011-11-14 17:42:11 +01001859/* toggle speaker-output according to the hp-jack state */
1860static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1861{
1862 unsigned int gpiostate, gpiomask, gpiodir;
1863
1864 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1865 AC_VERB_GET_GPIO_DATA, 0);
1866
1867 if (!muted)
1868 gpiostate |= (1 << pin);
1869 else
1870 gpiostate &= ~(1 << pin);
1871
1872 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1873 AC_VERB_GET_GPIO_MASK, 0);
1874 gpiomask |= (1 << pin);
1875
1876 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1877 AC_VERB_GET_GPIO_DIRECTION, 0);
1878 gpiodir |= (1 << pin);
1879
1880
1881 snd_hda_codec_write(codec, codec->afg, 0,
1882 AC_VERB_SET_GPIO_MASK, gpiomask);
1883 snd_hda_codec_write(codec, codec->afg, 0,
1884 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1885
1886 msleep(1);
1887
1888 snd_hda_codec_write(codec, codec->afg, 0,
1889 AC_VERB_SET_GPIO_DATA, gpiostate);
1890}
1891
1892/* set up GPIO at initialization */
1893static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001894 const struct hda_fixup *fix, int action)
Takashi Iwai56710872011-11-14 17:42:11 +01001895{
Takashi Iwai1727a772013-01-10 09:52:52 +01001896 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai56710872011-11-14 17:42:11 +01001897 return;
1898 alc882_gpio_mute(codec, 0, 0);
1899 alc882_gpio_mute(codec, 1, 0);
1900}
1901
Takashi Iwai02a237b2012-02-13 15:25:07 +01001902/* Fix the connection of some pins for ALC889:
1903 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1904 * work correctly (bko#42740)
1905 */
1906static void alc889_fixup_dac_route(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001907 const struct hda_fixup *fix, int action)
Takashi Iwai02a237b2012-02-13 15:25:07 +01001908{
Takashi Iwai1727a772013-01-10 09:52:52 +01001909 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001910 /* fake the connections during parsing the tree */
Takashi Iwai02a237b2012-02-13 15:25:07 +01001911 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1912 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1913 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1914 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1915 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1916 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
Takashi Iwai1727a772013-01-10 09:52:52 +01001917 } else if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001918 /* restore the connections */
1919 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1920 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1921 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1922 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1923 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
Takashi Iwai02a237b2012-02-13 15:25:07 +01001924 }
1925}
1926
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001927/* Set VREF on HP pin */
1928static void alc889_fixup_mbp_vref(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001929 const struct hda_fixup *fix, int action)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001930{
1931 struct alc_spec *spec = codec->spec;
1932 static hda_nid_t nids[2] = { 0x14, 0x15 };
1933 int i;
1934
Takashi Iwai1727a772013-01-10 09:52:52 +01001935 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001936 return;
1937 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1938 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1939 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1940 continue;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001941 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001942 val |= AC_PINCTL_VREF_80;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001943 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01001944 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001945 break;
1946 }
1947}
1948
Takashi Iwai0756f092013-12-04 13:59:45 +01001949static void alc889_fixup_mac_pins(struct hda_codec *codec,
1950 const hda_nid_t *nids, int num_nids)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001951{
1952 struct alc_spec *spec = codec->spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001953 int i;
1954
Takashi Iwai0756f092013-12-04 13:59:45 +01001955 for (i = 0; i < num_nids; i++) {
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001956 unsigned int val;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001957 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001958 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001959 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001960 }
Takashi Iwai08c189f2012-12-19 15:22:24 +01001961 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001962}
1963
Takashi Iwai0756f092013-12-04 13:59:45 +01001964/* Set VREF on speaker pins on imac91 */
1965static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1966 const struct hda_fixup *fix, int action)
1967{
1968 static hda_nid_t nids[2] = { 0x18, 0x1a };
1969
1970 if (action == HDA_FIXUP_ACT_INIT)
1971 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1972}
1973
Adrien Vergée7729a42014-01-24 14:56:14 -05001974/* Set VREF on speaker pins on mba11 */
1975static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1976 const struct hda_fixup *fix, int action)
1977{
1978 static hda_nid_t nids[1] = { 0x18 };
1979
1980 if (action == HDA_FIXUP_ACT_INIT)
1981 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1982}
1983
Takashi Iwai0756f092013-12-04 13:59:45 +01001984/* Set VREF on speaker pins on mba21 */
1985static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1986 const struct hda_fixup *fix, int action)
1987{
1988 static hda_nid_t nids[2] = { 0x18, 0x19 };
1989
1990 if (action == HDA_FIXUP_ACT_INIT)
1991 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1992}
1993
Takashi Iwaie427c232012-07-29 10:04:08 +02001994/* Don't take HP output as primary
Fernando Luis Vázquez Caod9111492013-02-12 16:49:46 +09001995 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1996 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
Takashi Iwaie427c232012-07-29 10:04:08 +02001997 */
1998static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001999 const struct hda_fixup *fix, int action)
Takashi Iwaie427c232012-07-29 10:04:08 +02002000{
2001 struct alc_spec *spec = codec->spec;
Takashi Iwaida96fb52013-07-29 16:54:36 +02002002 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08c189f2012-12-19 15:22:24 +01002003 spec->gen.no_primary_hp = 1;
Takashi Iwaida96fb52013-07-29 16:54:36 +02002004 spec->gen.no_multi_io = 1;
2005 }
Takashi Iwaie427c232012-07-29 10:04:08 +02002006}
2007
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01002008static void alc_fixup_bass_chmap(struct hda_codec *codec,
2009 const struct hda_fixup *fix, int action);
2010
Takashi Iwai1727a772013-01-10 09:52:52 +01002011static const struct hda_fixup alc882_fixups[] = {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002012 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002013 .type = HDA_FIXUP_PINS,
2014 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002015 { 0x15, 0x01080104 }, /* side */
2016 { 0x16, 0x01011012 }, /* rear */
2017 { 0x17, 0x01016011 }, /* clfe */
2018 { }
2019 }
2020 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002021 [ALC882_FIXUP_LENOVO_Y530] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002022 .type = HDA_FIXUP_PINS,
2023 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002024 { 0x15, 0x99130112 }, /* rear int speakers */
2025 { 0x16, 0x99130111 }, /* subwoofer */
2026 { }
2027 }
2028 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002029 [ALC882_FIXUP_PB_M5210] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002030 .type = HDA_FIXUP_PINCTLS,
2031 .v.pins = (const struct hda_pintbl[]) {
2032 { 0x19, PIN_VREF50 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002033 {}
2034 }
2035 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002036 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002037 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02002038 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002039 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002040 [ALC882_FIXUP_ASUS_W90V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002041 .type = HDA_FIXUP_PINS,
2042 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5cdf7452011-10-26 23:04:08 +02002043 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2044 { }
2045 }
2046 },
Marton Balint8f239212012-03-05 21:33:23 +01002047 [ALC889_FIXUP_CD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002048 .type = HDA_FIXUP_PINS,
2049 .v.pins = (const struct hda_pintbl[]) {
Marton Balint8f239212012-03-05 21:33:23 +01002050 { 0x1c, 0x993301f0 }, /* CD */
2051 { }
2052 }
2053 },
David Henningssonb2c53e22014-01-01 14:01:34 +01002054 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2055 .type = HDA_FIXUP_PINS,
2056 .v.pins = (const struct hda_pintbl[]) {
2057 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2058 { }
2059 },
2060 .chained = true,
2061 .chain_id = ALC889_FIXUP_CD,
2062 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002063 [ALC889_FIXUP_VAIO_TT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002064 .type = HDA_FIXUP_PINS,
2065 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002066 { 0x17, 0x90170111 }, /* hidden surround speaker */
2067 { }
2068 }
2069 },
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002070 [ALC888_FIXUP_EEE1601] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002071 .type = HDA_FIXUP_VERBS,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002072 .v.verbs = (const struct hda_verb[]) {
2073 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2074 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2075 { }
2076 }
Takashi Iwai177943a32011-11-09 12:55:18 +01002077 },
2078 [ALC882_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002079 .type = HDA_FIXUP_VERBS,
Takashi Iwai177943a32011-11-09 12:55:18 +01002080 .v.verbs = (const struct hda_verb[]) {
2081 /* change to EAPD mode */
2082 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2083 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2084 { }
2085 }
2086 },
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002087 [ALC883_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002088 .type = HDA_FIXUP_VERBS,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002089 .v.verbs = (const struct hda_verb[]) {
2090 /* change to EAPD mode */
2091 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2092 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2093 { }
2094 }
2095 },
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002096 [ALC883_FIXUP_ACER_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002097 .type = HDA_FIXUP_VERBS,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002098 .v.verbs = (const struct hda_verb[]) {
2099 /* eanable EAPD on Acer laptops */
2100 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2101 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2102 { }
2103 }
2104 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002105 [ALC882_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002106 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002107 .v.verbs = alc_gpio1_init_verbs,
2108 },
2109 [ALC882_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002110 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002111 .v.verbs = alc_gpio2_init_verbs,
2112 },
Takashi Iwaieb844d52011-11-09 18:03:07 +01002113 [ALC882_FIXUP_GPIO3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002114 .type = HDA_FIXUP_VERBS,
Takashi Iwaieb844d52011-11-09 18:03:07 +01002115 .v.verbs = alc_gpio3_init_verbs,
2116 },
Takashi Iwai68ef0562011-11-09 18:24:44 +01002117 [ALC882_FIXUP_ASUS_W2JC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002118 .type = HDA_FIXUP_VERBS,
Takashi Iwai68ef0562011-11-09 18:24:44 +01002119 .v.verbs = alc_gpio1_init_verbs,
2120 .chained = true,
2121 .chain_id = ALC882_FIXUP_EAPD,
2122 },
2123 [ALC889_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002124 .type = HDA_FIXUP_FUNC,
Takashi Iwai68ef0562011-11-09 18:24:44 +01002125 .v.func = alc889_fixup_coef,
2126 },
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002127 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002128 .type = HDA_FIXUP_PINS,
2129 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002130 { 0x16, 0x99130111 }, /* CLFE speaker */
2131 { 0x17, 0x99130112 }, /* surround speaker */
2132 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02002133 },
2134 .chained = true,
2135 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002136 },
2137 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002138 .type = HDA_FIXUP_PINS,
2139 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002140 { 0x16, 0x99130111 }, /* CLFE speaker */
2141 { 0x1b, 0x99130112 }, /* surround speaker */
2142 { }
2143 },
2144 .chained = true,
2145 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2146 },
2147 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2148 /* additional init verbs for Acer Aspire 8930G */
Takashi Iwai1727a772013-01-10 09:52:52 +01002149 .type = HDA_FIXUP_VERBS,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002150 .v.verbs = (const struct hda_verb[]) {
2151 /* Enable all DACs */
2152 /* DAC DISABLE/MUTE 1? */
2153 /* setting bits 1-5 disables DAC nids 0x02-0x06
2154 * apparently. Init=0x38 */
2155 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2156 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2157 /* DAC DISABLE/MUTE 2? */
2158 /* some bit here disables the other DACs.
2159 * Init=0x4900 */
2160 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2161 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2162 /* DMIC fix
2163 * This laptop has a stereo digital microphone.
2164 * The mics are only 1cm apart which makes the stereo
2165 * useless. However, either the mic or the ALC889
2166 * makes the signal become a difference/sum signal
2167 * instead of standard stereo, which is annoying.
2168 * So instead we flip this bit which makes the
2169 * codec replicate the sum signal to both channels,
2170 * turning it into a normal mono mic.
2171 */
2172 /* DMIC_CONTROL? Init value = 0x0001 */
2173 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2174 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2175 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2176 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2177 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02002178 },
2179 .chained = true,
2180 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002181 },
Takashi Iwai56710872011-11-14 17:42:11 +01002182 [ALC885_FIXUP_MACPRO_GPIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002183 .type = HDA_FIXUP_FUNC,
Takashi Iwai56710872011-11-14 17:42:11 +01002184 .v.func = alc885_fixup_macpro_gpio,
2185 },
Takashi Iwai02a237b2012-02-13 15:25:07 +01002186 [ALC889_FIXUP_DAC_ROUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002187 .type = HDA_FIXUP_FUNC,
Takashi Iwai02a237b2012-02-13 15:25:07 +01002188 .v.func = alc889_fixup_dac_route,
2189 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002190 [ALC889_FIXUP_MBP_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002191 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002192 .v.func = alc889_fixup_mbp_vref,
2193 .chained = true,
2194 .chain_id = ALC882_FIXUP_GPIO1,
2195 },
2196 [ALC889_FIXUP_IMAC91_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002197 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002198 .v.func = alc889_fixup_imac91_vref,
2199 .chained = true,
2200 .chain_id = ALC882_FIXUP_GPIO1,
2201 },
Adrien Vergée7729a42014-01-24 14:56:14 -05002202 [ALC889_FIXUP_MBA11_VREF] = {
2203 .type = HDA_FIXUP_FUNC,
2204 .v.func = alc889_fixup_mba11_vref,
2205 .chained = true,
2206 .chain_id = ALC889_FIXUP_MBP_VREF,
2207 },
Takashi Iwai0756f092013-12-04 13:59:45 +01002208 [ALC889_FIXUP_MBA21_VREF] = {
2209 .type = HDA_FIXUP_FUNC,
2210 .v.func = alc889_fixup_mba21_vref,
2211 .chained = true,
2212 .chain_id = ALC889_FIXUP_MBP_VREF,
2213 },
Takashi Iwaic20f31e2014-02-03 11:02:10 +01002214 [ALC889_FIXUP_MP11_VREF] = {
2215 .type = HDA_FIXUP_FUNC,
2216 .v.func = alc889_fixup_mba11_vref,
2217 .chained = true,
2218 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2219 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002220 [ALC882_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002221 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002222 .v.func = alc_fixup_inv_dmic_0x12,
2223 },
Takashi Iwaie427c232012-07-29 10:04:08 +02002224 [ALC882_FIXUP_NO_PRIMARY_HP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002225 .type = HDA_FIXUP_FUNC,
Takashi Iwaie427c232012-07-29 10:04:08 +02002226 .v.func = alc882_fixup_no_primary_hp,
2227 },
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002228 [ALC887_FIXUP_ASUS_BASS] = {
2229 .type = HDA_FIXUP_PINS,
2230 .v.pins = (const struct hda_pintbl[]) {
2231 {0x16, 0x99130130}, /* bass speaker */
2232 {}
2233 },
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01002234 .chained = true,
2235 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2236 },
2237 [ALC887_FIXUP_BASS_CHMAP] = {
2238 .type = HDA_FIXUP_FUNC,
2239 .v.func = alc_fixup_bass_chmap,
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002240 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002241};
2242
2243static const struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002244 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2245 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2246 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2247 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2248 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2249 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002250 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2251 ALC882_FIXUP_ACER_ASPIRE_4930G),
2252 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2253 ALC882_FIXUP_ACER_ASPIRE_4930G),
2254 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2255 ALC882_FIXUP_ACER_ASPIRE_8930G),
2256 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2257 ALC882_FIXUP_ACER_ASPIRE_8930G),
2258 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2259 ALC882_FIXUP_ACER_ASPIRE_4930G),
2260 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2261 ALC882_FIXUP_ACER_ASPIRE_4930G),
2262 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2263 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002264 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
Takashi Iwaif5c53d82012-05-07 10:07:33 +02002265 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2266 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai02a237b2012-02-13 15:25:07 +01002267 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
Takashi Iwaife97da12012-04-12 08:00:19 +02002268 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002269 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
Takashi Iwai177943a32011-11-09 12:55:18 +01002270 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002271 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002272 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002273 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002274 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002275 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
Takashi Iwaie427c232012-07-29 10:04:08 +02002276 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
Fernando Luis Vázquez Cao12e31a72013-02-12 16:47:44 +09002277 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
Takashi Iwai56710872011-11-14 17:42:11 +01002278
2279 /* All Apple entries are in codec SSIDs */
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002280 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2281 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2282 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
Takashi Iwaic20f31e2014-02-03 11:02:10 +01002283 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002284 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2285 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002286 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2287 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002288 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
Adrien Vergée7729a42014-01-24 14:56:14 -05002289 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
Takashi Iwai0756f092013-12-04 13:59:45 +01002290 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002291 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2292 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002293 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002294 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2295 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2296 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
Josh Boyer29ebe402012-04-12 13:55:36 -04002297 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai05193632012-11-12 10:07:36 +01002298 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002299 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2300 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2301 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002302
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002303 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
Takashi Iwaibca40132012-05-07 11:13:14 +02002304 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Takashi Iwaieb844d52011-11-09 18:03:07 +01002305 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
David Henningssonb2c53e22014-01-01 14:01:34 +01002306 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002307 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002308 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2309 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002310 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002311 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002312 {}
2313};
2314
Takashi Iwai1727a772013-01-10 09:52:52 +01002315static const struct hda_model_fixup alc882_fixup_models[] = {
Takashi Iwai912093b2012-04-11 14:03:41 +02002316 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2317 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2318 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002319 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaie427c232012-07-29 10:04:08 +02002320 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
Takashi Iwai912093b2012-04-11 14:03:41 +02002321 {}
2322};
2323
Takashi Iwai1d045db2011-07-07 18:23:21 +02002324/*
2325 * BIOS auto configuration
2326 */
2327/* almost identical with ALC880 parser... */
2328static int alc882_parse_auto_config(struct hda_codec *codec)
2329{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002330 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002331 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2332 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002333}
2334
Takashi Iwai1d045db2011-07-07 18:23:21 +02002335/*
2336 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002337static int patch_alc882(struct hda_codec *codec)
2338{
2339 struct alc_spec *spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002340 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002341
Takashi Iwai3de95172012-05-07 18:03:15 +02002342 err = alc_alloc_spec(codec, 0x0b);
2343 if (err < 0)
2344 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002345
Takashi Iwai3de95172012-05-07 18:03:15 +02002346 spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002347
2348 switch (codec->vendor_id) {
2349 case 0x10ec0882:
2350 case 0x10ec0885:
2351 break;
2352 default:
2353 /* ALC883 and variants */
2354 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2355 break;
2356 }
2357
Takashi Iwai1727a772013-01-10 09:52:52 +01002358 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
Takashi Iwai912093b2012-04-11 14:03:41 +02002359 alc882_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002360 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002361
2362 alc_auto_parse_customize_define(codec);
2363
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002364 if (has_cdefine_beep(codec))
2365 spec->gen.beep_nid = 0x01;
2366
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002367 /* automatic parse from the BIOS config */
2368 err = alc882_parse_auto_config(codec);
2369 if (err < 0)
2370 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002371
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002372 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002373 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2374
Takashi Iwai1d045db2011-07-07 18:23:21 +02002375 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002376
Takashi Iwai1727a772013-01-10 09:52:52 +01002377 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002378
Takashi Iwai1d045db2011-07-07 18:23:21 +02002379 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002380
2381 error:
2382 alc_free(codec);
2383 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002384}
2385
2386
2387/*
2388 * ALC262 support
2389 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002390static int alc262_parse_auto_config(struct hda_codec *codec)
2391{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002392 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002393 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2394 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002395}
2396
2397/*
2398 * Pin config fixes
2399 */
2400enum {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002401 ALC262_FIXUP_FSC_H270,
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002402 ALC262_FIXUP_FSC_S7110,
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002403 ALC262_FIXUP_HP_Z200,
2404 ALC262_FIXUP_TYAN,
Takashi Iwaic4701502011-11-07 14:20:07 +01002405 ALC262_FIXUP_LENOVO_3000,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002406 ALC262_FIXUP_BENQ,
2407 ALC262_FIXUP_BENQ_T31,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002408 ALC262_FIXUP_INV_DMIC,
Mengdong Linb5c66112013-11-29 00:35:35 -05002409 ALC262_FIXUP_INTEL_BAYLEYBAY,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002410};
2411
Takashi Iwai1727a772013-01-10 09:52:52 +01002412static const struct hda_fixup alc262_fixups[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002413 [ALC262_FIXUP_FSC_H270] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002414 .type = HDA_FIXUP_PINS,
2415 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002416 { 0x14, 0x99130110 }, /* speaker */
2417 { 0x15, 0x0221142f }, /* front HP */
2418 { 0x1b, 0x0121141f }, /* rear HP */
2419 { }
2420 }
2421 },
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002422 [ALC262_FIXUP_FSC_S7110] = {
2423 .type = HDA_FIXUP_PINS,
2424 .v.pins = (const struct hda_pintbl[]) {
2425 { 0x15, 0x90170110 }, /* speaker */
2426 { }
2427 },
2428 .chained = true,
2429 .chain_id = ALC262_FIXUP_BENQ,
2430 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002431 [ALC262_FIXUP_HP_Z200] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002432 .type = HDA_FIXUP_PINS,
2433 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002434 { 0x16, 0x99130120 }, /* internal speaker */
2435 { }
2436 }
2437 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002438 [ALC262_FIXUP_TYAN] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002439 .type = HDA_FIXUP_PINS,
2440 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002441 { 0x14, 0x1993e1f0 }, /* int AUX */
2442 { }
2443 }
2444 },
Takashi Iwaic4701502011-11-07 14:20:07 +01002445 [ALC262_FIXUP_LENOVO_3000] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002446 .type = HDA_FIXUP_PINCTLS,
2447 .v.pins = (const struct hda_pintbl[]) {
2448 { 0x19, PIN_VREF50 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002449 {}
2450 },
2451 .chained = true,
2452 .chain_id = ALC262_FIXUP_BENQ,
2453 },
2454 [ALC262_FIXUP_BENQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002455 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002456 .v.verbs = (const struct hda_verb[]) {
Takashi Iwaic4701502011-11-07 14:20:07 +01002457 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2458 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2459 {}
2460 }
2461 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002462 [ALC262_FIXUP_BENQ_T31] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002463 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002464 .v.verbs = (const struct hda_verb[]) {
2465 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2466 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2467 {}
2468 }
2469 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002470 [ALC262_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002471 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002472 .v.func = alc_fixup_inv_dmic_0x12,
2473 },
Mengdong Linb5c66112013-11-29 00:35:35 -05002474 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2475 .type = HDA_FIXUP_FUNC,
2476 .v.func = alc_fixup_no_depop_delay,
2477 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002478};
2479
2480static const struct snd_pci_quirk alc262_fixup_tbl[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002481 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002482 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
Takashi Iwai3dcd3be2011-11-07 14:59:40 +01002483 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002484 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2485 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
Takashi Iwaic4701502011-11-07 14:20:07 +01002486 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
Takashi Iwaib42590b2011-11-07 14:41:01 +01002487 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2488 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
Mengdong Linb5c66112013-11-29 00:35:35 -05002489 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002490 {}
2491};
2492
Takashi Iwai1727a772013-01-10 09:52:52 +01002493static const struct hda_model_fixup alc262_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002494 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2495 {}
2496};
Takashi Iwai1d045db2011-07-07 18:23:21 +02002497
Takashi Iwai1d045db2011-07-07 18:23:21 +02002498/*
2499 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002500static int patch_alc262(struct hda_codec *codec)
2501{
2502 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002503 int err;
2504
Takashi Iwai3de95172012-05-07 18:03:15 +02002505 err = alc_alloc_spec(codec, 0x0b);
2506 if (err < 0)
2507 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002508
Takashi Iwai3de95172012-05-07 18:03:15 +02002509 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01002510 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002511
2512#if 0
2513 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2514 * under-run
2515 */
2516 {
2517 int tmp;
2518 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2519 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
2520 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2521 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
2522 }
2523#endif
Takashi Iwai1d045db2011-07-07 18:23:21 +02002524 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2525
Takashi Iwai1727a772013-01-10 09:52:52 +01002526 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002527 alc262_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002528 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002529
Takashi Iwaiaf741c12012-05-07 18:09:48 +02002530 alc_auto_parse_customize_define(codec);
2531
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002532 if (has_cdefine_beep(codec))
2533 spec->gen.beep_nid = 0x01;
2534
Takashi Iwai42399f72011-11-07 17:18:44 +01002535 /* automatic parse from the BIOS config */
2536 err = alc262_parse_auto_config(codec);
2537 if (err < 0)
2538 goto error;
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002539
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002540 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002541 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2542
Takashi Iwai1d045db2011-07-07 18:23:21 +02002543 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002544 spec->shutup = alc_eapd_shutup;
2545
Takashi Iwai1727a772013-01-10 09:52:52 +01002546 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002547
Takashi Iwai1d045db2011-07-07 18:23:21 +02002548 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002549
2550 error:
2551 alc_free(codec);
2552 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002553}
2554
2555/*
2556 * ALC268
2557 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002558/* bind Beep switches of both NID 0x0f and 0x10 */
2559static const struct hda_bind_ctls alc268_bind_beep_sw = {
2560 .ops = &snd_hda_bind_sw,
2561 .values = {
2562 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2563 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2564 0
2565 },
2566};
2567
2568static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2569 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2570 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2571 { }
2572};
2573
2574/* set PCBEEP vol = 0, mute connections */
2575static const struct hda_verb alc268_beep_init_verbs[] = {
2576 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2577 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2578 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2579 { }
2580};
2581
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002582enum {
2583 ALC268_FIXUP_INV_DMIC,
Takashi Iwaicb766402012-10-20 10:55:21 +02002584 ALC268_FIXUP_HP_EAPD,
Takashi Iwai24eff322013-11-04 18:21:08 +01002585 ALC268_FIXUP_SPDIF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002586};
2587
Takashi Iwai1727a772013-01-10 09:52:52 +01002588static const struct hda_fixup alc268_fixups[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002589 [ALC268_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002590 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002591 .v.func = alc_fixup_inv_dmic_0x12,
2592 },
Takashi Iwaicb766402012-10-20 10:55:21 +02002593 [ALC268_FIXUP_HP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002594 .type = HDA_FIXUP_VERBS,
Takashi Iwaicb766402012-10-20 10:55:21 +02002595 .v.verbs = (const struct hda_verb[]) {
2596 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2597 {}
2598 }
2599 },
Takashi Iwai24eff322013-11-04 18:21:08 +01002600 [ALC268_FIXUP_SPDIF] = {
2601 .type = HDA_FIXUP_PINS,
2602 .v.pins = (const struct hda_pintbl[]) {
2603 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2604 {}
2605 }
2606 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002607};
2608
Takashi Iwai1727a772013-01-10 09:52:52 +01002609static const struct hda_model_fixup alc268_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002610 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaicb766402012-10-20 10:55:21 +02002611 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2612 {}
2613};
2614
2615static const struct snd_pci_quirk alc268_fixup_tbl[] = {
Takashi Iwai24eff322013-11-04 18:21:08 +01002616 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
David Henningssonfcd8f3b2013-01-28 05:45:47 +01002617 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
Takashi Iwaicb766402012-10-20 10:55:21 +02002618 /* below is codec SSID since multiple Toshiba laptops have the
2619 * same PCI SSID 1179:ff00
2620 */
2621 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002622 {}
2623};
2624
Takashi Iwai1d045db2011-07-07 18:23:21 +02002625/*
2626 * BIOS auto configuration
2627 */
2628static int alc268_parse_auto_config(struct hda_codec *codec)
2629{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002630 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002631 return alc_parse_auto_config(codec, NULL, alc268_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002632}
2633
Takashi Iwai1d045db2011-07-07 18:23:21 +02002634/*
2635 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002636static int patch_alc268(struct hda_codec *codec)
2637{
2638 struct alc_spec *spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002639 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002640
Takashi Iwai1d045db2011-07-07 18:23:21 +02002641 /* ALC268 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02002642 err = alc_alloc_spec(codec, 0);
2643 if (err < 0)
2644 return err;
2645
2646 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002647 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002648
Takashi Iwai1727a772013-01-10 09:52:52 +01002649 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2650 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002651
Takashi Iwai6ebb8052011-08-16 15:15:40 +02002652 /* automatic parse from the BIOS config */
2653 err = alc268_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002654 if (err < 0)
2655 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002656
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002657 if (err > 0 && !spec->gen.no_analog &&
2658 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2659 add_mixer(spec, alc268_beep_mixer);
2660 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002661 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2662 /* override the amp caps for beep generator */
2663 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2664 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2665 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2666 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2667 (0 << AC_AMPCAP_MUTE_SHIFT));
2668 }
2669
Takashi Iwai1d045db2011-07-07 18:23:21 +02002670 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002671 spec->shutup = alc_eapd_shutup;
2672
Takashi Iwai1727a772013-01-10 09:52:52 +01002673 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002674
Takashi Iwai1d045db2011-07-07 18:23:21 +02002675 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002676
2677 error:
2678 alc_free(codec);
2679 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002680}
2681
2682/*
2683 * ALC269
2684 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01002685
2686static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2687 struct hda_codec *codec,
2688 struct snd_pcm_substream *substream)
2689{
2690 struct hda_gen_spec *spec = codec->spec;
2691 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2692 hinfo);
2693}
2694
2695static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2696 struct hda_codec *codec,
2697 unsigned int stream_tag,
2698 unsigned int format,
2699 struct snd_pcm_substream *substream)
2700{
2701 struct hda_gen_spec *spec = codec->spec;
2702 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2703 stream_tag, format, substream);
2704}
2705
2706static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2707 struct hda_codec *codec,
2708 struct snd_pcm_substream *substream)
2709{
2710 struct hda_gen_spec *spec = codec->spec;
2711 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2712}
2713
Takashi Iwai1d045db2011-07-07 18:23:21 +02002714static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2715 .substreams = 1,
2716 .channels_min = 2,
2717 .channels_max = 8,
2718 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2719 /* NID is set in alc_build_pcms */
2720 .ops = {
Takashi Iwai08c189f2012-12-19 15:22:24 +01002721 .open = playback_pcm_open,
2722 .prepare = playback_pcm_prepare,
2723 .cleanup = playback_pcm_cleanup
Takashi Iwai1d045db2011-07-07 18:23:21 +02002724 },
2725};
2726
2727static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2728 .substreams = 1,
2729 .channels_min = 2,
2730 .channels_max = 2,
2731 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2732 /* NID is set in alc_build_pcms */
2733};
2734
Takashi Iwai1d045db2011-07-07 18:23:21 +02002735/* different alc269-variants */
2736enum {
2737 ALC269_TYPE_ALC269VA,
2738 ALC269_TYPE_ALC269VB,
2739 ALC269_TYPE_ALC269VC,
Kailang Yangadcc70b2012-05-25 08:08:38 +02002740 ALC269_TYPE_ALC269VD,
Kailang Yang065380f2013-01-10 10:25:48 +01002741 ALC269_TYPE_ALC280,
2742 ALC269_TYPE_ALC282,
Kailang Yang2af02be2013-08-22 10:03:50 +02002743 ALC269_TYPE_ALC283,
Kailang Yang065380f2013-01-10 10:25:48 +01002744 ALC269_TYPE_ALC284,
Kailang Yang161ebf22013-10-24 11:36:33 +02002745 ALC269_TYPE_ALC285,
Kailang Yang7fc7d042013-04-25 11:04:43 +02002746 ALC269_TYPE_ALC286,
Kailang Yang1d04c9d2013-10-24 11:35:18 +02002747 ALC269_TYPE_ALC255,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002748};
2749
2750/*
2751 * BIOS auto configuration
2752 */
2753static int alc269_parse_auto_config(struct hda_codec *codec)
2754{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002755 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002756 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2757 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2758 struct alc_spec *spec = codec->spec;
Kailang Yangadcc70b2012-05-25 08:08:38 +02002759 const hda_nid_t *ssids;
2760
2761 switch (spec->codec_variant) {
2762 case ALC269_TYPE_ALC269VA:
2763 case ALC269_TYPE_ALC269VC:
Kailang Yang065380f2013-01-10 10:25:48 +01002764 case ALC269_TYPE_ALC280:
2765 case ALC269_TYPE_ALC284:
Kailang Yang161ebf22013-10-24 11:36:33 +02002766 case ALC269_TYPE_ALC285:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002767 ssids = alc269va_ssids;
2768 break;
2769 case ALC269_TYPE_ALC269VB:
2770 case ALC269_TYPE_ALC269VD:
Kailang Yang065380f2013-01-10 10:25:48 +01002771 case ALC269_TYPE_ALC282:
Kailang Yang2af02be2013-08-22 10:03:50 +02002772 case ALC269_TYPE_ALC283:
Kailang Yang7fc7d042013-04-25 11:04:43 +02002773 case ALC269_TYPE_ALC286:
Kailang Yang1d04c9d2013-10-24 11:35:18 +02002774 case ALC269_TYPE_ALC255:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002775 ssids = alc269_ssids;
2776 break;
2777 default:
2778 ssids = alc269_ssids;
2779 break;
2780 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02002781
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002782 return alc_parse_auto_config(codec, alc269_ignore, ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002783}
2784
Kailang Yang1387e2d2012-11-08 10:23:18 +01002785static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002786{
2787 int val = alc_read_coef_idx(codec, 0x04);
2788 if (power_up)
2789 val |= 1 << 11;
2790 else
2791 val &= ~(1 << 11);
2792 alc_write_coef_idx(codec, 0x04, val);
2793}
2794
2795static void alc269_shutup(struct hda_codec *codec)
2796{
Kailang Yangadcc70b2012-05-25 08:08:38 +02002797 struct alc_spec *spec = codec->spec;
2798
Kailang Yang1387e2d2012-11-08 10:23:18 +01002799 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2800 alc269vb_toggle_power_output(codec, 0);
2801 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2802 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002803 msleep(150);
2804 }
Takashi Iwai9bfb2842013-07-24 14:31:50 +02002805 snd_hda_shutup_pins(codec);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002806}
2807
Kailang Yangcb149cb2014-03-18 16:45:32 +08002808static void alc282_restore_default_value(struct hda_codec *codec)
2809{
2810 int val;
2811
2812 /* Power Down Control */
2813 alc_write_coef_idx(codec, 0x03, 0x0002);
2814 /* FIFO and filter clock */
2815 alc_write_coef_idx(codec, 0x05, 0x0700);
2816 /* DMIC control */
2817 alc_write_coef_idx(codec, 0x07, 0x0200);
2818 /* Analog clock */
2819 val = alc_read_coef_idx(codec, 0x06);
2820 alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
2821 /* JD */
2822 val = alc_read_coef_idx(codec, 0x08);
2823 alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
2824 /* JD offset1 */
2825 alc_write_coef_idx(codec, 0x0a, 0xcccc);
2826 /* JD offset2 */
2827 alc_write_coef_idx(codec, 0x0b, 0xcccc);
2828 /* LDO1/2/3, DAC/ADC */
2829 alc_write_coef_idx(codec, 0x0e, 0x6e00);
2830 /* JD */
2831 val = alc_read_coef_idx(codec, 0x0f);
2832 alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
2833 /* Capless */
2834 val = alc_read_coef_idx(codec, 0x10);
2835 alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
2836 /* Class D test 4 */
2837 alc_write_coef_idx(codec, 0x6f, 0x0);
2838 /* IO power down directly */
2839 val = alc_read_coef_idx(codec, 0x0c);
2840 alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
2841 /* ANC */
2842 alc_write_coef_idx(codec, 0x34, 0xa0c0);
2843 /* AGC MUX */
2844 val = alc_read_coef_idx(codec, 0x16);
2845 alc_write_coef_idx(codec, 0x16, (val & ~0x0008) | 0x0);
2846 /* DAC simple content protection */
2847 val = alc_read_coef_idx(codec, 0x1d);
2848 alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
2849 /* ADC simple content protection */
2850 val = alc_read_coef_idx(codec, 0x1f);
2851 alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
2852 /* DAC ADC Zero Detection */
2853 alc_write_coef_idx(codec, 0x21, 0x8804);
2854 /* PLL */
2855 alc_write_coef_idx(codec, 0x63, 0x2902);
2856 /* capless control 2 */
2857 alc_write_coef_idx(codec, 0x68, 0xa080);
2858 /* capless control 3 */
2859 alc_write_coef_idx(codec, 0x69, 0x3400);
2860 /* capless control 4 */
2861 alc_write_coef_idx(codec, 0x6a, 0x2f3e);
2862 /* capless control 5 */
2863 alc_write_coef_idx(codec, 0x6b, 0x0);
2864 /* class D test 2 */
2865 val = alc_read_coef_idx(codec, 0x6d);
2866 alc_write_coef_idx(codec, 0x6d, (val & ~0x0fff) | 0x0900);
2867 /* class D test 3 */
2868 alc_write_coef_idx(codec, 0x6e, 0x110a);
2869 /* class D test 5 */
2870 val = alc_read_coef_idx(codec, 0x70);
2871 alc_write_coef_idx(codec, 0x70, (val & ~0x00f8) | 0x00d8);
2872 /* class D test 6 */
2873 alc_write_coef_idx(codec, 0x71, 0x0014);
2874 /* classD OCP */
2875 alc_write_coef_idx(codec, 0x72, 0xc2ba);
2876 /* classD pure DC test */
2877 val = alc_read_coef_idx(codec, 0x77);
2878 alc_write_coef_idx(codec, 0x77, (val & ~0x0f80) | 0x0);
2879 /* Class D amp control */
2880 alc_write_coef_idx(codec, 0x6c, 0xfc06);
2881}
2882
Kailang Yang7b5c7a02014-03-18 16:15:54 +08002883static void alc282_init(struct hda_codec *codec)
2884{
2885 struct alc_spec *spec = codec->spec;
2886 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2887 bool hp_pin_sense;
2888 int coef78;
2889
Kailang Yangcb149cb2014-03-18 16:45:32 +08002890 alc282_restore_default_value(codec);
2891
Kailang Yang7b5c7a02014-03-18 16:15:54 +08002892 if (!hp_pin)
2893 return;
2894 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2895 coef78 = alc_read_coef_idx(codec, 0x78);
2896
2897 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2898 /* Headphone capless set to high power mode */
2899 alc_write_coef_idx(codec, 0x78, 0x9004);
2900
2901 if (hp_pin_sense)
2902 msleep(2);
2903
2904 snd_hda_codec_write(codec, hp_pin, 0,
2905 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2906
2907 if (hp_pin_sense)
2908 msleep(85);
2909
2910 snd_hda_codec_write(codec, hp_pin, 0,
2911 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2912
2913 if (hp_pin_sense)
2914 msleep(100);
2915
2916 /* Headphone capless set to normal mode */
2917 alc_write_coef_idx(codec, 0x78, coef78);
2918}
2919
2920static void alc282_shutup(struct hda_codec *codec)
2921{
2922 struct alc_spec *spec = codec->spec;
2923 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2924 bool hp_pin_sense;
2925 int coef78;
2926
2927 if (!hp_pin) {
2928 alc269_shutup(codec);
2929 return;
2930 }
2931
2932 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2933 coef78 = alc_read_coef_idx(codec, 0x78);
2934 alc_write_coef_idx(codec, 0x78, 0x9004);
2935
2936 if (hp_pin_sense)
2937 msleep(2);
2938
2939 snd_hda_codec_write(codec, hp_pin, 0,
2940 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2941
2942 if (hp_pin_sense)
2943 msleep(85);
2944
2945 snd_hda_codec_write(codec, hp_pin, 0,
2946 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2947
2948 if (hp_pin_sense)
2949 msleep(100);
2950
2951 alc_auto_setup_eapd(codec, false);
2952 snd_hda_shutup_pins(codec);
2953 alc_write_coef_idx(codec, 0x78, coef78);
2954}
2955
Kailang Yang6bd55b02014-03-17 13:51:27 +08002956static void alc283_restore_default_value(struct hda_codec *codec)
2957{
2958 int val;
2959
2960 /* Power Down Control */
2961 alc_write_coef_idx(codec, 0x03, 0x0002);
2962 /* FIFO and filter clock */
2963 alc_write_coef_idx(codec, 0x05, 0x0700);
2964 /* DMIC control */
2965 alc_write_coef_idx(codec, 0x07, 0x0200);
2966 /* Analog clock */
2967 val = alc_read_coef_idx(codec, 0x06);
2968 alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
2969 /* JD */
2970 val = alc_read_coef_idx(codec, 0x08);
2971 alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
2972 /* JD offset1 */
2973 alc_write_coef_idx(codec, 0x0a, 0xcccc);
2974 /* JD offset2 */
2975 alc_write_coef_idx(codec, 0x0b, 0xcccc);
2976 /* LDO1/2/3, DAC/ADC */
2977 alc_write_coef_idx(codec, 0x0e, 0x6fc0);
2978 /* JD */
2979 val = alc_read_coef_idx(codec, 0x0f);
2980 alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
2981 /* Capless */
2982 val = alc_read_coef_idx(codec, 0x10);
2983 alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
2984 /* Class D test 4 */
2985 alc_write_coef_idx(codec, 0x3a, 0x0);
2986 /* IO power down directly */
2987 val = alc_read_coef_idx(codec, 0x0c);
2988 alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
2989 /* ANC */
2990 alc_write_coef_idx(codec, 0x22, 0xa0c0);
2991 /* AGC MUX */
2992 val = alc_read_coefex_idx(codec, 0x53, 0x01);
2993 alc_write_coefex_idx(codec, 0x53, 0x01, (val & ~0x000f) | 0x0008);
2994 /* DAC simple content protection */
2995 val = alc_read_coef_idx(codec, 0x1d);
2996 alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
2997 /* ADC simple content protection */
2998 val = alc_read_coef_idx(codec, 0x1f);
2999 alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
3000 /* DAC ADC Zero Detection */
3001 alc_write_coef_idx(codec, 0x21, 0x8804);
3002 /* PLL */
3003 alc_write_coef_idx(codec, 0x2e, 0x2902);
3004 /* capless control 2 */
3005 alc_write_coef_idx(codec, 0x33, 0xa080);
3006 /* capless control 3 */
3007 alc_write_coef_idx(codec, 0x34, 0x3400);
3008 /* capless control 4 */
3009 alc_write_coef_idx(codec, 0x35, 0x2f3e);
3010 /* capless control 5 */
3011 alc_write_coef_idx(codec, 0x36, 0x0);
3012 /* class D test 2 */
3013 val = alc_read_coef_idx(codec, 0x38);
3014 alc_write_coef_idx(codec, 0x38, (val & ~0x0fff) | 0x0900);
3015 /* class D test 3 */
3016 alc_write_coef_idx(codec, 0x39, 0x110a);
3017 /* class D test 5 */
3018 val = alc_read_coef_idx(codec, 0x3b);
3019 alc_write_coef_idx(codec, 0x3b, (val & ~0x00f8) | 0x00d8);
3020 /* class D test 6 */
3021 alc_write_coef_idx(codec, 0x3c, 0x0014);
3022 /* classD OCP */
3023 alc_write_coef_idx(codec, 0x3d, 0xc2ba);
3024 /* classD pure DC test */
3025 val = alc_read_coef_idx(codec, 0x42);
3026 alc_write_coef_idx(codec, 0x42, (val & ~0x0f80) | 0x0);
3027 /* test mode */
3028 alc_write_coef_idx(codec, 0x49, 0x0);
3029 /* Class D DC enable */
3030 val = alc_read_coef_idx(codec, 0x40);
3031 alc_write_coef_idx(codec, 0x40, (val & ~0xf800) | 0x9800);
3032 /* DC offset */
3033 val = alc_read_coef_idx(codec, 0x42);
3034 alc_write_coef_idx(codec, 0x42, (val & ~0xf000) | 0x2000);
3035 /* Class D amp control */
3036 alc_write_coef_idx(codec, 0x37, 0xfc06);
3037}
3038
Kailang Yang2af02be2013-08-22 10:03:50 +02003039static void alc283_init(struct hda_codec *codec)
3040{
3041 struct alc_spec *spec = codec->spec;
3042 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3043 bool hp_pin_sense;
3044 int val;
3045
Kailang Yang8314f222014-04-03 17:28:39 +08003046 if (!spec->gen.autocfg.hp_outs) {
3047 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3048 hp_pin = spec->gen.autocfg.line_out_pins[0];
3049 }
3050
Kailang Yang6bd55b02014-03-17 13:51:27 +08003051 alc283_restore_default_value(codec);
3052
Kailang Yang2af02be2013-08-22 10:03:50 +02003053 if (!hp_pin)
3054 return;
3055 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3056
3057 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3058 /* Headphone capless set to high power mode */
3059 alc_write_coef_idx(codec, 0x43, 0x9004);
3060
3061 snd_hda_codec_write(codec, hp_pin, 0,
3062 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3063
3064 if (hp_pin_sense)
3065 msleep(85);
3066
3067 snd_hda_codec_write(codec, hp_pin, 0,
3068 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3069
3070 if (hp_pin_sense)
3071 msleep(85);
3072 /* Index 0x46 Combo jack auto switch control 2 */
3073 /* 3k pull low control for Headset jack. */
3074 val = alc_read_coef_idx(codec, 0x46);
3075 alc_write_coef_idx(codec, 0x46, val & ~(3 << 12));
3076 /* Headphone capless set to normal mode */
3077 alc_write_coef_idx(codec, 0x43, 0x9614);
3078}
3079
3080static void alc283_shutup(struct hda_codec *codec)
3081{
3082 struct alc_spec *spec = codec->spec;
3083 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3084 bool hp_pin_sense;
3085 int val;
3086
Kailang Yang8314f222014-04-03 17:28:39 +08003087 if (!spec->gen.autocfg.hp_outs) {
3088 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3089 hp_pin = spec->gen.autocfg.line_out_pins[0];
3090 }
3091
Kailang Yang2af02be2013-08-22 10:03:50 +02003092 if (!hp_pin) {
3093 alc269_shutup(codec);
3094 return;
3095 }
3096
3097 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3098
3099 alc_write_coef_idx(codec, 0x43, 0x9004);
3100
3101 snd_hda_codec_write(codec, hp_pin, 0,
3102 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3103
3104 if (hp_pin_sense)
Kailang Yang88011c092013-10-24 15:45:24 +02003105 msleep(100);
Kailang Yang2af02be2013-08-22 10:03:50 +02003106
3107 snd_hda_codec_write(codec, hp_pin, 0,
3108 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3109
3110 val = alc_read_coef_idx(codec, 0x46);
3111 alc_write_coef_idx(codec, 0x46, val | (3 << 12));
3112
3113 if (hp_pin_sense)
Kailang Yang88011c092013-10-24 15:45:24 +02003114 msleep(100);
Kailang Yang0435b3f2014-04-08 17:14:14 +08003115 alc_auto_setup_eapd(codec, false);
Kailang Yang2af02be2013-08-22 10:03:50 +02003116 snd_hda_shutup_pins(codec);
3117 alc_write_coef_idx(codec, 0x43, 0x9614);
3118}
3119
Kailang Yangad60d502013-06-28 12:03:01 +02003120static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3121 unsigned int val)
3122{
3123 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3124 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3125 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3126}
3127
3128static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3129{
3130 unsigned int val;
3131
3132 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3133 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3134 & 0xffff;
3135 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3136 << 16;
3137 return val;
3138}
3139
3140static void alc5505_dsp_halt(struct hda_codec *codec)
3141{
3142 unsigned int val;
3143
3144 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3145 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3146 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3147 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3148 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3149 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3150 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3151 val = alc5505_coef_get(codec, 0x6220);
3152 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3153}
3154
3155static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3156{
3157 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3158 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3159 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3160 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3161 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3162 alc5505_coef_set(codec, 0x880c, 0x00000004);
3163}
3164
3165static void alc5505_dsp_init(struct hda_codec *codec)
3166{
3167 unsigned int val;
3168
3169 alc5505_dsp_halt(codec);
3170 alc5505_dsp_back_from_halt(codec);
3171 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3172 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3173 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3174 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3175 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3176 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3177 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3178 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3179 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3180 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3181 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3182 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3183 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3184
3185 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3186 if (val <= 3)
3187 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3188 else
3189 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3190
3191 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3192 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3193 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3194 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3195 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3196 alc5505_coef_set(codec, 0x880c, 0x00000003);
3197 alc5505_coef_set(codec, 0x880c, 0x00000010);
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003198
3199#ifdef HALT_REALTEK_ALC5505
3200 alc5505_dsp_halt(codec);
3201#endif
Kailang Yangad60d502013-06-28 12:03:01 +02003202}
3203
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003204#ifdef HALT_REALTEK_ALC5505
3205#define alc5505_dsp_suspend(codec) /* NOP */
3206#define alc5505_dsp_resume(codec) /* NOP */
3207#else
3208#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3209#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3210#endif
3211
Takashi Iwai2a439522011-07-26 09:52:50 +02003212#ifdef CONFIG_PM
Kailang Yangad60d502013-06-28 12:03:01 +02003213static int alc269_suspend(struct hda_codec *codec)
3214{
3215 struct alc_spec *spec = codec->spec;
3216
3217 if (spec->has_alc5505_dsp)
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003218 alc5505_dsp_suspend(codec);
Kailang Yangad60d502013-06-28 12:03:01 +02003219 return alc_suspend(codec);
3220}
3221
Takashi Iwai1d045db2011-07-07 18:23:21 +02003222static int alc269_resume(struct hda_codec *codec)
3223{
Kailang Yangadcc70b2012-05-25 08:08:38 +02003224 struct alc_spec *spec = codec->spec;
3225
Kailang Yang1387e2d2012-11-08 10:23:18 +01003226 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3227 alc269vb_toggle_power_output(codec, 0);
3228 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02003229 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003230 msleep(150);
3231 }
3232
3233 codec->patch_ops.init(codec);
3234
Kailang Yang1387e2d2012-11-08 10:23:18 +01003235 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3236 alc269vb_toggle_power_output(codec, 1);
3237 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02003238 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003239 msleep(200);
3240 }
3241
Takashi Iwai1d045db2011-07-07 18:23:21 +02003242 snd_hda_codec_resume_amp(codec);
3243 snd_hda_codec_resume_cache(codec);
Takashi Iwai0623a882013-06-25 09:28:40 +02003244 alc_inv_dmic_sync(codec, true);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003245 hda_call_check_power_status(codec, 0x01);
Kailang Yangad60d502013-06-28 12:03:01 +02003246 if (spec->has_alc5505_dsp)
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003247 alc5505_dsp_resume(codec);
Kailang Yangc5177c82013-07-24 14:39:49 +02003248
Takashi Iwai1d045db2011-07-07 18:23:21 +02003249 return 0;
3250}
Takashi Iwai2a439522011-07-26 09:52:50 +02003251#endif /* CONFIG_PM */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003252
David Henningsson108cc102012-07-20 10:37:25 +02003253static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003254 const struct hda_fixup *fix, int action)
David Henningsson108cc102012-07-20 10:37:25 +02003255{
3256 struct alc_spec *spec = codec->spec;
3257
Takashi Iwai1727a772013-01-10 09:52:52 +01003258 if (action == HDA_FIXUP_ACT_PRE_PROBE)
David Henningsson108cc102012-07-20 10:37:25 +02003259 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3260}
3261
Takashi Iwai1d045db2011-07-07 18:23:21 +02003262static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003263 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003264{
3265 int coef;
3266
Takashi Iwai1727a772013-01-10 09:52:52 +01003267 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003268 return;
3269 coef = alc_read_coef_idx(codec, 0x1e);
3270 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
3271}
3272
David Henningsson7c478f02013-10-11 10:18:46 +02003273static void alc269_fixup_headset_mic(struct hda_codec *codec,
3274 const struct hda_fixup *fix, int action)
3275{
3276 struct alc_spec *spec = codec->spec;
3277
3278 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3279 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3280}
3281
Takashi Iwai1d045db2011-07-07 18:23:21 +02003282static void alc271_fixup_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003283 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003284{
3285 static const struct hda_verb verbs[] = {
3286 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3287 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3288 {}
3289 };
3290 unsigned int cfg;
3291
Dylan Reid42397002013-04-05 14:58:22 -07003292 if (strcmp(codec->chip_name, "ALC271X") &&
3293 strcmp(codec->chip_name, "ALC269VB"))
Takashi Iwai1d045db2011-07-07 18:23:21 +02003294 return;
3295 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3296 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3297 snd_hda_sequence_write(codec, verbs);
3298}
3299
Takashi Iwai017f2a12011-07-09 14:42:25 +02003300static void alc269_fixup_pcm_44k(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003301 const struct hda_fixup *fix, int action)
Takashi Iwai017f2a12011-07-09 14:42:25 +02003302{
3303 struct alc_spec *spec = codec->spec;
3304
Takashi Iwai1727a772013-01-10 09:52:52 +01003305 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai017f2a12011-07-09 14:42:25 +02003306 return;
3307
3308 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3309 * fix the sample rate of analog I/O to 44.1kHz
3310 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01003311 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3312 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai017f2a12011-07-09 14:42:25 +02003313}
3314
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003315static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003316 const struct hda_fixup *fix, int action)
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003317{
3318 int coef;
3319
Takashi Iwai1727a772013-01-10 09:52:52 +01003320 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003321 return;
3322 /* The digital-mic unit sends PDM (differential signal) instead of
3323 * the standard PCM, thus you can't record a valid mono stream as is.
3324 * Below is a workaround specific to ALC269 to control the dmic
3325 * signal source as mono.
3326 */
3327 coef = alc_read_coef_idx(codec, 0x07);
3328 alc_write_coef_idx(codec, 0x07, coef | 0x80);
3329}
3330
Takashi Iwai24519912011-08-16 15:08:49 +02003331static void alc269_quanta_automute(struct hda_codec *codec)
3332{
Takashi Iwai08c189f2012-12-19 15:22:24 +01003333 snd_hda_gen_update_outputs(codec);
Takashi Iwai24519912011-08-16 15:08:49 +02003334
3335 snd_hda_codec_write(codec, 0x20, 0,
3336 AC_VERB_SET_COEF_INDEX, 0x0c);
3337 snd_hda_codec_write(codec, 0x20, 0,
3338 AC_VERB_SET_PROC_COEF, 0x680);
3339
3340 snd_hda_codec_write(codec, 0x20, 0,
3341 AC_VERB_SET_COEF_INDEX, 0x0c);
3342 snd_hda_codec_write(codec, 0x20, 0,
3343 AC_VERB_SET_PROC_COEF, 0x480);
3344}
3345
3346static void alc269_fixup_quanta_mute(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003347 const struct hda_fixup *fix, int action)
Takashi Iwai24519912011-08-16 15:08:49 +02003348{
3349 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01003350 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai24519912011-08-16 15:08:49 +02003351 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +01003352 spec->gen.automute_hook = alc269_quanta_automute;
Takashi Iwai24519912011-08-16 15:08:49 +02003353}
3354
David Henningssond240d1d2013-04-15 12:50:02 +02003355static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3356 struct hda_jack_tbl *jack)
3357{
3358 struct alc_spec *spec = codec->spec;
3359 int vref;
3360 msleep(200);
3361 snd_hda_gen_hp_automute(codec, jack);
3362
3363 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3364 msleep(100);
3365 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3366 vref);
3367 msleep(500);
3368 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3369 vref);
3370}
3371
3372static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3373 const struct hda_fixup *fix, int action)
3374{
3375 struct alc_spec *spec = codec->spec;
3376 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3377 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3378 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3379 }
3380}
3381
3382
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003383/* update mute-LED according to the speaker mute state via mic VREF pin */
3384static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003385{
3386 struct hda_codec *codec = private_data;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003387 struct alc_spec *spec = codec->spec;
3388 unsigned int pinval;
3389
3390 if (spec->mute_led_polarity)
3391 enabled = !enabled;
Takashi Iwai415d5552014-04-03 11:51:21 +02003392 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3393 pinval &= ~AC_PINCTL_VREFEN;
3394 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003395 if (spec->mute_led_nid)
3396 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003397}
3398
David Henningssond5b6b652013-11-06 10:50:44 +01003399/* Make sure the led works even in runtime suspend */
3400static unsigned int led_power_filter(struct hda_codec *codec,
3401 hda_nid_t nid,
3402 unsigned int power_state)
3403{
3404 struct alc_spec *spec = codec->spec;
3405
Hui Wang50dd9052014-07-08 17:56:15 +08003406 if (power_state != AC_PWRST_D3 || nid == 0 ||
3407 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
David Henningssond5b6b652013-11-06 10:50:44 +01003408 return power_state;
3409
3410 /* Set pin ctl again, it might have just been set to 0 */
3411 snd_hda_set_pin_ctl(codec, nid,
3412 snd_hda_codec_get_pin_target(codec, nid));
3413
3414 return AC_PWRST_D0;
3415}
3416
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003417static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3418 const struct hda_fixup *fix, int action)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003419{
3420 struct alc_spec *spec = codec->spec;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003421 const struct dmi_device *dev = NULL;
3422
3423 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3424 return;
3425
3426 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3427 int pol, pin;
3428 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3429 continue;
3430 if (pin < 0x0a || pin >= 0x10)
3431 break;
3432 spec->mute_led_polarity = pol;
3433 spec->mute_led_nid = pin - 0x0a + 0x18;
3434 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01003435 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003436 codec->power_filter = led_power_filter;
Takashi Iwai4e76a882014-02-25 12:21:03 +01003437 codec_dbg(codec,
3438 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003439 spec->mute_led_polarity);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003440 break;
3441 }
3442}
3443
David Henningssond06ac142013-02-18 11:41:55 +01003444static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3445 const struct hda_fixup *fix, int action)
3446{
3447 struct alc_spec *spec = codec->spec;
3448 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3449 spec->mute_led_polarity = 0;
3450 spec->mute_led_nid = 0x18;
3451 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3452 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003453 codec->power_filter = led_power_filter;
David Henningssond06ac142013-02-18 11:41:55 +01003454 }
3455}
3456
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003457static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3458 const struct hda_fixup *fix, int action)
Takashi Iwai420b0fe2012-03-12 12:35:27 +01003459{
3460 struct alc_spec *spec = codec->spec;
Takashi Iwai9bb1f062013-01-10 17:14:29 +01003461 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003462 spec->mute_led_polarity = 0;
3463 spec->mute_led_nid = 0x19;
3464 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01003465 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003466 codec->power_filter = led_power_filter;
Takashi Iwai420b0fe2012-03-12 12:35:27 +01003467 }
3468}
3469
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003470/* turn on/off mute LED per vmaster hook */
3471static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
3472{
3473 struct hda_codec *codec = private_data;
3474 struct alc_spec *spec = codec->spec;
3475 unsigned int oldval = spec->gpio_led;
3476
3477 if (enabled)
3478 spec->gpio_led &= ~0x08;
3479 else
3480 spec->gpio_led |= 0x08;
3481 if (spec->gpio_led != oldval)
3482 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3483 spec->gpio_led);
3484}
3485
3486/* turn on/off mic-mute LED per capture hook */
3487static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +01003488 struct snd_kcontrol *kcontrol,
3489 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003490{
3491 struct alc_spec *spec = codec->spec;
3492 unsigned int oldval = spec->gpio_led;
3493
3494 if (!ucontrol)
3495 return;
3496
3497 if (ucontrol->value.integer.value[0] ||
3498 ucontrol->value.integer.value[1])
3499 spec->gpio_led &= ~0x10;
3500 else
3501 spec->gpio_led |= 0x10;
3502 if (spec->gpio_led != oldval)
3503 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3504 spec->gpio_led);
3505}
3506
3507static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3508 const struct hda_fixup *fix, int action)
3509{
3510 struct alc_spec *spec = codec->spec;
3511 static const struct hda_verb gpio_init[] = {
3512 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3513 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3514 {}
3515 };
3516
3517 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3518 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3519 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
3520 spec->gpio_led = 0;
3521 snd_hda_add_verbs(codec, gpio_init);
3522 }
3523}
3524
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003525/* turn on/off mic-mute LED per capture hook */
3526static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3527 struct snd_kcontrol *kcontrol,
3528 struct snd_ctl_elem_value *ucontrol)
3529{
3530 struct alc_spec *spec = codec->spec;
3531 unsigned int pinval, enable, disable;
3532
Hui Wangfc1fad92014-07-08 17:56:14 +08003533 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003534 pinval &= ~AC_PINCTL_VREFEN;
3535 enable = pinval | AC_PINCTL_VREF_80;
3536 disable = pinval | AC_PINCTL_VREF_HIZ;
3537
3538 if (!ucontrol)
3539 return;
3540
3541 if (ucontrol->value.integer.value[0] ||
3542 ucontrol->value.integer.value[1])
3543 pinval = disable;
3544 else
3545 pinval = enable;
3546
3547 if (spec->cap_mute_led_nid)
3548 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3549}
3550
3551static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3552 const struct hda_fixup *fix, int action)
3553{
3554 struct alc_spec *spec = codec->spec;
3555 static const struct hda_verb gpio_init[] = {
3556 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3557 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3558 {}
3559 };
3560
3561 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3562 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3563 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3564 spec->gpio_led = 0;
3565 spec->cap_mute_led_nid = 0x18;
3566 snd_hda_add_verbs(codec, gpio_init);
Hui Wang50dd9052014-07-08 17:56:15 +08003567 codec->power_filter = led_power_filter;
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003568 }
3569}
3570
3571static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3572 const struct hda_fixup *fix, int action)
3573{
3574 struct alc_spec *spec = codec->spec;
3575
3576 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3577 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3578 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3579 spec->mute_led_polarity = 0;
3580 spec->mute_led_nid = 0x1a;
3581 spec->cap_mute_led_nid = 0x18;
3582 spec->gen.vmaster_mute_enum = 1;
3583 codec->power_filter = led_power_filter;
3584 }
3585}
3586
David Henningsson73bdd592013-04-15 15:44:14 +02003587static void alc_headset_mode_unplugged(struct hda_codec *codec)
3588{
3589 int val;
3590
3591 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003592 case 0x10ec0255:
3593 /* LDO and MISC control */
3594 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3595 /* UAJ function set to menual mode */
3596 alc_write_coef_idx(codec, 0x45, 0xd089);
3597 /* Direct Drive HP Amp control(Set to verb control)*/
3598 val = alc_read_coefex_idx(codec, 0x57, 0x05);
3599 alc_write_coefex_idx(codec, 0x57, 0x05, val & ~(1<<14));
3600 /* Set MIC2 Vref gate with HP */
3601 alc_write_coef_idx(codec, 0x06, 0x6104);
3602 /* Direct Drive HP Amp control */
3603 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3604 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003605 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003606 case 0x10ec0283:
3607 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3608 alc_write_coef_idx(codec, 0x45, 0xc429);
3609 val = alc_read_coef_idx(codec, 0x35);
3610 alc_write_coef_idx(codec, 0x35, val & 0xbfff);
3611 alc_write_coef_idx(codec, 0x06, 0x2104);
3612 alc_write_coef_idx(codec, 0x1a, 0x0001);
3613 alc_write_coef_idx(codec, 0x26, 0x0004);
3614 alc_write_coef_idx(codec, 0x32, 0x42a3);
3615 break;
3616 case 0x10ec0292:
3617 alc_write_coef_idx(codec, 0x76, 0x000e);
3618 alc_write_coef_idx(codec, 0x6c, 0x2400);
3619 alc_write_coef_idx(codec, 0x18, 0x7308);
3620 alc_write_coef_idx(codec, 0x6b, 0xc429);
3621 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003622 case 0x10ec0293:
3623 /* SET Line1 JD to 0 */
3624 val = alc_read_coef_idx(codec, 0x10);
3625 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 6<<8);
3626 /* SET charge pump by verb */
3627 val = alc_read_coefex_idx(codec, 0x57, 0x05);
3628 alc_write_coefex_idx(codec, 0x57, 0x05, (val & ~(1<<15|1<<13)) | 0x0);
3629 /* SET EN_OSW to 1 */
3630 val = alc_read_coefex_idx(codec, 0x57, 0x03);
3631 alc_write_coefex_idx(codec, 0x57, 0x03, (val & ~(1<<10)) | (1<<10) );
3632 /* Combo JD gating with LINE1-VREFO */
3633 val = alc_read_coef_idx(codec, 0x1a);
3634 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | (1<<3));
3635 /* Set to TRS type */
3636 alc_write_coef_idx(codec, 0x45, 0xc429);
3637 /* Combo Jack auto detect */
3638 val = alc_read_coef_idx(codec, 0x4a);
3639 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x000e);
3640 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003641 case 0x10ec0668:
3642 alc_write_coef_idx(codec, 0x15, 0x0d40);
3643 alc_write_coef_idx(codec, 0xb7, 0x802b);
3644 break;
3645 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003646 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003647}
3648
3649
3650static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3651 hda_nid_t mic_pin)
3652{
3653 int val;
3654
3655 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003656 case 0x10ec0255:
3657 alc_write_coef_idx(codec, 0x45, 0xc489);
3658 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3659 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3660 /* Set MIC2 Vref gate to normal */
3661 alc_write_coef_idx(codec, 0x06, 0x6100);
3662 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3663 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003664 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003665 case 0x10ec0283:
3666 alc_write_coef_idx(codec, 0x45, 0xc429);
3667 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3668 val = alc_read_coef_idx(codec, 0x35);
3669 alc_write_coef_idx(codec, 0x35, val | 1<<14);
3670 alc_write_coef_idx(codec, 0x06, 0x2100);
3671 alc_write_coef_idx(codec, 0x1a, 0x0021);
3672 alc_write_coef_idx(codec, 0x26, 0x008c);
3673 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3674 break;
3675 case 0x10ec0292:
3676 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3677 alc_write_coef_idx(codec, 0x19, 0xa208);
3678 alc_write_coef_idx(codec, 0x2e, 0xacf0);
3679 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003680 case 0x10ec0293:
3681 /* Set to TRS mode */
3682 alc_write_coef_idx(codec, 0x45, 0xc429);
3683 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3684 /* SET charge pump by verb */
3685 val = alc_read_coefex_idx(codec, 0x57, 0x05);
3686 alc_write_coefex_idx(codec, 0x57, 0x05, (val & ~(1<<15|1<<13)) | (1<<15|1<<13));
3687 /* SET EN_OSW to 0 */
3688 val = alc_read_coefex_idx(codec, 0x57, 0x03);
3689 alc_write_coefex_idx(codec, 0x57, 0x03, (val & ~(1<<10)) | 0x0);
3690 /* Combo JD gating without LINE1-VREFO */
3691 val = alc_read_coef_idx(codec, 0x1a);
3692 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | 0x0);
3693 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3694 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003695 case 0x10ec0668:
3696 alc_write_coef_idx(codec, 0x11, 0x0001);
3697 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3698 alc_write_coef_idx(codec, 0xb7, 0x802b);
3699 alc_write_coef_idx(codec, 0xb5, 0x1040);
3700 val = alc_read_coef_idx(codec, 0xc3);
3701 alc_write_coef_idx(codec, 0xc3, val | 1<<12);
3702 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3703 break;
3704 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003705 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003706}
3707
3708static void alc_headset_mode_default(struct hda_codec *codec)
3709{
Kailang Yanga22aa262014-04-23 17:34:28 +08003710 int val;
3711
David Henningsson73bdd592013-04-15 15:44:14 +02003712 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003713 case 0x10ec0255:
3714 alc_write_coef_idx(codec, 0x45, 0xc089);
3715 alc_write_coef_idx(codec, 0x45, 0xc489);
3716 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3717 alc_write_coef_idx(codec, 0x49, 0x0049);
3718 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003719 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003720 case 0x10ec0283:
3721 alc_write_coef_idx(codec, 0x06, 0x2100);
3722 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3723 break;
3724 case 0x10ec0292:
3725 alc_write_coef_idx(codec, 0x76, 0x000e);
3726 alc_write_coef_idx(codec, 0x6c, 0x2400);
3727 alc_write_coef_idx(codec, 0x6b, 0xc429);
3728 alc_write_coef_idx(codec, 0x18, 0x7308);
3729 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003730 case 0x10ec0293:
3731 /* Combo Jack auto detect */
3732 val = alc_read_coef_idx(codec, 0x4a);
3733 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x000e);
3734 /* Set to TRS type */
3735 alc_write_coef_idx(codec, 0x45, 0xC429);
3736 /* Combo JD gating without LINE1-VREFO */
3737 val = alc_read_coef_idx(codec, 0x1a);
3738 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | 0x0);
3739 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003740 case 0x10ec0668:
3741 alc_write_coef_idx(codec, 0x11, 0x0041);
3742 alc_write_coef_idx(codec, 0x15, 0x0d40);
3743 alc_write_coef_idx(codec, 0xb7, 0x802b);
3744 break;
3745 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003746 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003747}
3748
3749/* Iphone type */
3750static void alc_headset_mode_ctia(struct hda_codec *codec)
3751{
Kailang Yanga22aa262014-04-23 17:34:28 +08003752 int val;
3753
David Henningsson73bdd592013-04-15 15:44:14 +02003754 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003755 case 0x10ec0255:
3756 /* Set to CTIA type */
3757 alc_write_coef_idx(codec, 0x45, 0xd489);
3758 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3759 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3760 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003761 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003762 case 0x10ec0283:
3763 alc_write_coef_idx(codec, 0x45, 0xd429);
3764 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3765 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3766 break;
3767 case 0x10ec0292:
3768 alc_write_coef_idx(codec, 0x6b, 0xd429);
3769 alc_write_coef_idx(codec, 0x76, 0x0008);
3770 alc_write_coef_idx(codec, 0x18, 0x7388);
3771 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003772 case 0x10ec0293:
3773 /* Set to ctia type */
3774 alc_write_coef_idx(codec, 0x45, 0xd429);
3775 /* SET Line1 JD to 1 */
3776 val = alc_read_coef_idx(codec, 0x10);
3777 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 7<<8);
3778 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003779 case 0x10ec0668:
David Henningssond59915d2013-12-02 18:06:20 +08003780 alc_write_coef_idx(codec, 0x11, 0x0001);
David Henningsson73bdd592013-04-15 15:44:14 +02003781 alc_write_coef_idx(codec, 0x15, 0x0d60);
3782 alc_write_coef_idx(codec, 0xc3, 0x0000);
3783 break;
3784 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003785 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003786}
3787
3788/* Nokia type */
3789static void alc_headset_mode_omtp(struct hda_codec *codec)
3790{
Kailang Yanga22aa262014-04-23 17:34:28 +08003791 int val;
3792
David Henningsson73bdd592013-04-15 15:44:14 +02003793 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003794 case 0x10ec0255:
3795 /* Set to OMTP Type */
3796 alc_write_coef_idx(codec, 0x45, 0xe489);
3797 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3798 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3799 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003800 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003801 case 0x10ec0283:
3802 alc_write_coef_idx(codec, 0x45, 0xe429);
3803 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3804 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3805 break;
3806 case 0x10ec0292:
3807 alc_write_coef_idx(codec, 0x6b, 0xe429);
3808 alc_write_coef_idx(codec, 0x76, 0x0008);
3809 alc_write_coef_idx(codec, 0x18, 0x7388);
3810 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003811 case 0x10ec0293:
3812 /* Set to omtp type */
3813 alc_write_coef_idx(codec, 0x45, 0xe429);
3814 /* SET Line1 JD to 1 */
3815 val = alc_read_coef_idx(codec, 0x10);
3816 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 7<<8);
3817 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003818 case 0x10ec0668:
David Henningssond59915d2013-12-02 18:06:20 +08003819 alc_write_coef_idx(codec, 0x11, 0x0001);
David Henningsson73bdd592013-04-15 15:44:14 +02003820 alc_write_coef_idx(codec, 0x15, 0x0d50);
3821 alc_write_coef_idx(codec, 0xc3, 0x0000);
3822 break;
3823 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003824 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003825}
3826
3827static void alc_determine_headset_type(struct hda_codec *codec)
3828{
3829 int val;
3830 bool is_ctia = false;
3831 struct alc_spec *spec = codec->spec;
3832
3833 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003834 case 0x10ec0255:
3835 /* combo jack auto switch control(Check type)*/
3836 alc_write_coef_idx(codec, 0x45, 0xd089);
3837 /* combo jack auto switch control(Vref conteol) */
3838 alc_write_coef_idx(codec, 0x49, 0x0149);
3839 msleep(300);
3840 val = alc_read_coef_idx(codec, 0x46);
3841 is_ctia = (val & 0x0070) == 0x0070;
3842 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003843 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003844 case 0x10ec0283:
3845 alc_write_coef_idx(codec, 0x45, 0xd029);
3846 msleep(300);
3847 val = alc_read_coef_idx(codec, 0x46);
3848 is_ctia = (val & 0x0070) == 0x0070;
3849 break;
3850 case 0x10ec0292:
3851 alc_write_coef_idx(codec, 0x6b, 0xd429);
3852 msleep(300);
3853 val = alc_read_coef_idx(codec, 0x6c);
3854 is_ctia = (val & 0x001c) == 0x001c;
3855 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003856 case 0x10ec0293:
3857 /* Combo Jack auto detect */
3858 val = alc_read_coef_idx(codec, 0x4a);
3859 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x0008);
3860 /* Set to ctia type */
3861 alc_write_coef_idx(codec, 0x45, 0xD429);
3862 msleep(300);
3863 val = alc_read_coef_idx(codec, 0x46);
3864 is_ctia = (val & 0x0070) == 0x0070;
3865 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003866 case 0x10ec0668:
3867 alc_write_coef_idx(codec, 0x11, 0x0001);
3868 alc_write_coef_idx(codec, 0xb7, 0x802b);
3869 alc_write_coef_idx(codec, 0x15, 0x0d60);
3870 alc_write_coef_idx(codec, 0xc3, 0x0c00);
3871 msleep(300);
3872 val = alc_read_coef_idx(codec, 0xbe);
3873 is_ctia = (val & 0x1c02) == 0x1c02;
3874 break;
3875 }
3876
Takashi Iwai4e76a882014-02-25 12:21:03 +01003877 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
David Henningsson73bdd592013-04-15 15:44:14 +02003878 is_ctia ? "yes" : "no");
3879 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3880}
3881
3882static void alc_update_headset_mode(struct hda_codec *codec)
3883{
3884 struct alc_spec *spec = codec->spec;
3885
3886 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
3887 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3888
3889 int new_headset_mode;
3890
3891 if (!snd_hda_jack_detect(codec, hp_pin))
3892 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
3893 else if (mux_pin == spec->headset_mic_pin)
3894 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
3895 else if (mux_pin == spec->headphone_mic_pin)
3896 new_headset_mode = ALC_HEADSET_MODE_MIC;
3897 else
3898 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
3899
David Henningsson5959a6b2013-11-12 11:10:57 +01003900 if (new_headset_mode == spec->current_headset_mode) {
3901 snd_hda_gen_update_outputs(codec);
David Henningsson73bdd592013-04-15 15:44:14 +02003902 return;
David Henningsson5959a6b2013-11-12 11:10:57 +01003903 }
David Henningsson73bdd592013-04-15 15:44:14 +02003904
3905 switch (new_headset_mode) {
3906 case ALC_HEADSET_MODE_UNPLUGGED:
3907 alc_headset_mode_unplugged(codec);
3908 spec->gen.hp_jack_present = false;
3909 break;
3910 case ALC_HEADSET_MODE_HEADSET:
3911 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
3912 alc_determine_headset_type(codec);
3913 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
3914 alc_headset_mode_ctia(codec);
3915 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
3916 alc_headset_mode_omtp(codec);
3917 spec->gen.hp_jack_present = true;
3918 break;
3919 case ALC_HEADSET_MODE_MIC:
3920 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
3921 spec->gen.hp_jack_present = false;
3922 break;
3923 case ALC_HEADSET_MODE_HEADPHONE:
3924 alc_headset_mode_default(codec);
3925 spec->gen.hp_jack_present = true;
3926 break;
3927 }
3928 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
3929 snd_hda_set_pin_ctl_cache(codec, hp_pin,
3930 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3931 if (spec->headphone_mic_pin)
3932 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
3933 PIN_VREFHIZ);
3934 }
3935 spec->current_headset_mode = new_headset_mode;
3936
3937 snd_hda_gen_update_outputs(codec);
3938}
3939
3940static void alc_update_headset_mode_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +01003941 struct snd_kcontrol *kcontrol,
3942 struct snd_ctl_elem_value *ucontrol)
David Henningsson73bdd592013-04-15 15:44:14 +02003943{
3944 alc_update_headset_mode(codec);
3945}
3946
3947static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack)
3948{
3949 struct alc_spec *spec = codec->spec;
David Henningsson5db4d342013-11-22 12:17:06 +01003950 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
David Henningsson73bdd592013-04-15 15:44:14 +02003951 snd_hda_gen_hp_automute(codec, jack);
3952}
3953
3954static void alc_probe_headset_mode(struct hda_codec *codec)
3955{
3956 int i;
3957 struct alc_spec *spec = codec->spec;
3958 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3959
3960 /* Find mic pins */
3961 for (i = 0; i < cfg->num_inputs; i++) {
3962 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
3963 spec->headset_mic_pin = cfg->inputs[i].pin;
3964 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
3965 spec->headphone_mic_pin = cfg->inputs[i].pin;
3966 }
3967
3968 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
3969 spec->gen.automute_hook = alc_update_headset_mode;
3970 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
3971}
3972
3973static void alc_fixup_headset_mode(struct hda_codec *codec,
3974 const struct hda_fixup *fix, int action)
3975{
3976 struct alc_spec *spec = codec->spec;
3977
3978 switch (action) {
3979 case HDA_FIXUP_ACT_PRE_PROBE:
3980 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
3981 break;
3982 case HDA_FIXUP_ACT_PROBE:
3983 alc_probe_headset_mode(codec);
3984 break;
3985 case HDA_FIXUP_ACT_INIT:
3986 spec->current_headset_mode = 0;
3987 alc_update_headset_mode(codec);
3988 break;
3989 }
3990}
3991
3992static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
3993 const struct hda_fixup *fix, int action)
3994{
3995 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3996 struct alc_spec *spec = codec->spec;
3997 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3998 }
3999 else
4000 alc_fixup_headset_mode(codec, fix, action);
4001}
4002
Kailang Yang31278992014-03-03 15:27:22 +08004003static void alc255_set_default_jack_type(struct hda_codec *codec)
4004{
4005 /* Set to iphone type */
4006 alc_write_coef_idx(codec, 0x1b, 0x880b);
4007 alc_write_coef_idx(codec, 0x45, 0xd089);
4008 alc_write_coef_idx(codec, 0x1b, 0x080b);
4009 alc_write_coef_idx(codec, 0x46, 0x0004);
4010 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
4011 msleep(30);
4012}
4013
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004014static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
4015 const struct hda_fixup *fix, int action)
4016{
4017 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Kailang Yang31278992014-03-03 15:27:22 +08004018 alc255_set_default_jack_type(codec);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004019 }
4020 alc_fixup_headset_mode(codec, fix, action);
4021}
4022
Kailang Yang31278992014-03-03 15:27:22 +08004023static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
4024 const struct hda_fixup *fix, int action)
4025{
4026 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4027 struct alc_spec *spec = codec->spec;
4028 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4029 alc255_set_default_jack_type(codec);
4030 }
4031 else
4032 alc_fixup_headset_mode(codec, fix, action);
4033}
4034
Hui Wang493a52a2014-01-14 14:07:36 +08004035static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
4036 const struct hda_fixup *fix, int action)
4037{
4038 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4039 struct alc_spec *spec = codec->spec;
4040 spec->gen.auto_mute_via_amp = 1;
4041 }
4042}
4043
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004044static void alc_no_shutup(struct hda_codec *codec)
4045{
4046}
4047
4048static void alc_fixup_no_shutup(struct hda_codec *codec,
4049 const struct hda_fixup *fix, int action)
4050{
4051 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4052 struct alc_spec *spec = codec->spec;
4053 spec->shutup = alc_no_shutup;
4054 }
4055}
4056
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02004057static void alc_fixup_disable_aamix(struct hda_codec *codec,
4058 const struct hda_fixup *fix, int action)
4059{
4060 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4061 struct alc_spec *spec = codec->spec;
4062 /* Disable AA-loopback as it causes white noise */
4063 spec->gen.mixer_nid = 0;
4064 }
4065}
4066
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004067static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
4068 hda_nid_t nid,
4069 unsigned int power_state)
4070{
4071 struct alc_spec *spec = codec->spec;
4072
4073 /* Avoid pop noises when headphones are plugged in */
4074 if (spec->gen.hp_jack_present)
4075 if (nid == codec->afg || nid == 0x02)
4076 return AC_PWRST_D0;
4077 return power_state;
4078}
4079
4080static void alc_fixup_dell_xps13(struct hda_codec *codec,
4081 const struct hda_fixup *fix, int action)
4082{
4083 if (action == HDA_FIXUP_ACT_PROBE) {
4084 struct alc_spec *spec = codec->spec;
4085 spec->shutup = alc_no_shutup;
4086 codec->power_filter = alc_power_filter_xps13;
4087 }
4088}
4089
David Henningsson73bdd592013-04-15 15:44:14 +02004090static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
4091 const struct hda_fixup *fix, int action)
4092{
4093 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4094 int val;
4095 alc_write_coef_idx(codec, 0xc4, 0x8000);
4096 val = alc_read_coef_idx(codec, 0xc2);
4097 alc_write_coef_idx(codec, 0xc2, val & 0xfe);
4098 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
4099 }
4100 alc_fixup_headset_mode(codec, fix, action);
4101}
4102
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004103/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
4104static int find_ext_mic_pin(struct hda_codec *codec)
4105{
4106 struct alc_spec *spec = codec->spec;
4107 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4108 hda_nid_t nid;
4109 unsigned int defcfg;
4110 int i;
4111
4112 for (i = 0; i < cfg->num_inputs; i++) {
4113 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4114 continue;
4115 nid = cfg->inputs[i].pin;
4116 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4117 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
4118 continue;
4119 return nid;
4120 }
4121
4122 return 0;
4123}
4124
Dylan Reid08a978d2012-11-18 22:56:40 -08004125static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01004126 const struct hda_fixup *fix,
Dylan Reid08a978d2012-11-18 22:56:40 -08004127 int action)
4128{
4129 struct alc_spec *spec = codec->spec;
4130
Takashi Iwai0db75792013-01-23 13:57:20 +01004131 if (action == HDA_FIXUP_ACT_PROBE) {
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004132 int mic_pin = find_ext_mic_pin(codec);
4133 int hp_pin = spec->gen.autocfg.hp_pins[0];
4134
4135 if (snd_BUG_ON(!mic_pin || !hp_pin))
Takashi Iwai0db75792013-01-23 13:57:20 +01004136 return;
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004137 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
Takashi Iwai0db75792013-01-23 13:57:20 +01004138 }
Dylan Reid08a978d2012-11-18 22:56:40 -08004139}
David Henningsson693b6132012-06-22 19:12:10 +02004140
David Henningsson3e0d6112013-04-22 14:30:14 +02004141static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
4142 const struct hda_fixup *fix,
4143 int action)
4144{
4145 struct alc_spec *spec = codec->spec;
4146 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4147 int i;
4148
4149 /* The mic boosts on level 2 and 3 are too noisy
4150 on the internal mic input.
4151 Therefore limit the boost to 0 or 1. */
4152
4153 if (action != HDA_FIXUP_ACT_PROBE)
4154 return;
4155
4156 for (i = 0; i < cfg->num_inputs; i++) {
4157 hda_nid_t nid = cfg->inputs[i].pin;
4158 unsigned int defcfg;
4159 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4160 continue;
4161 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4162 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
4163 continue;
4164
4165 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
4166 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
4167 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4168 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
4169 (0 << AC_AMPCAP_MUTE_SHIFT));
4170 }
4171}
4172
Kailang Yangcd217a62013-08-22 10:15:24 +02004173static void alc283_hp_automute_hook(struct hda_codec *codec,
4174 struct hda_jack_tbl *jack)
4175{
4176 struct alc_spec *spec = codec->spec;
4177 int vref;
4178
4179 msleep(200);
4180 snd_hda_gen_hp_automute(codec, jack);
4181
4182 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4183
4184 msleep(600);
4185 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4186 vref);
4187}
4188
Kailang Yangcd217a62013-08-22 10:15:24 +02004189static void alc283_fixup_chromebook(struct hda_codec *codec,
4190 const struct hda_fixup *fix, int action)
4191{
4192 struct alc_spec *spec = codec->spec;
4193 int val;
4194
4195 switch (action) {
4196 case HDA_FIXUP_ACT_PRE_PROBE:
Kailang Yang0202e992013-12-02 15:20:15 +08004197 snd_hda_override_wcaps(codec, 0x03, 0);
Takashi Iwaid2e92702013-10-30 07:50:53 +01004198 /* Disable AA-loopback as it causes white noise */
4199 spec->gen.mixer_nid = 0;
Kailang Yang38070212013-11-01 15:57:35 +08004200 break;
4201 case HDA_FIXUP_ACT_INIT:
Kailang Yangde9481c2014-04-07 16:41:52 +08004202 /* MIC2-VREF control */
4203 /* Set to manual mode */
4204 val = alc_read_coef_idx(codec, 0x06);
4205 alc_write_coef_idx(codec, 0x06, val & ~0x000c);
Kailang Yang0202e992013-12-02 15:20:15 +08004206 /* Enable Line1 input control by verb */
4207 val = alc_read_coef_idx(codec, 0x1a);
4208 alc_write_coef_idx(codec, 0x1a, val | (1 << 4));
4209 break;
4210 }
4211}
4212
4213static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
4214 const struct hda_fixup *fix, int action)
4215{
4216 struct alc_spec *spec = codec->spec;
4217 int val;
4218
4219 switch (action) {
4220 case HDA_FIXUP_ACT_PRE_PROBE:
Kailang Yangcd217a62013-08-22 10:15:24 +02004221 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
4222 break;
4223 case HDA_FIXUP_ACT_INIT:
4224 /* MIC2-VREF control */
4225 /* Set to manual mode */
Kailang Yang068fd3a2013-09-27 14:02:28 +02004226 val = alc_read_coef_idx(codec, 0x06);
4227 alc_write_coef_idx(codec, 0x06, val & ~0x000c);
Kailang Yangcd217a62013-08-22 10:15:24 +02004228 break;
4229 }
4230}
4231
Takashi Iwai7bba2152013-09-06 15:45:38 +02004232/* mute tablet speaker pin (0x14) via dock plugging in addition */
4233static void asus_tx300_automute(struct hda_codec *codec)
4234{
4235 struct alc_spec *spec = codec->spec;
4236 snd_hda_gen_update_outputs(codec);
4237 if (snd_hda_jack_detect(codec, 0x1b))
4238 spec->gen.mute_bits |= (1ULL << 0x14);
4239}
4240
4241static void alc282_fixup_asus_tx300(struct hda_codec *codec,
4242 const struct hda_fixup *fix, int action)
4243{
4244 struct alc_spec *spec = codec->spec;
4245 /* TX300 needs to set up GPIO2 for the speaker amp */
4246 static const struct hda_verb gpio2_verbs[] = {
4247 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4248 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4249 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
4250 {}
4251 };
4252 static const struct hda_pintbl dock_pins[] = {
4253 { 0x1b, 0x21114000 }, /* dock speaker pin */
4254 {}
4255 };
4256 struct snd_kcontrol *kctl;
4257
4258 switch (action) {
4259 case HDA_FIXUP_ACT_PRE_PROBE:
4260 snd_hda_add_verbs(codec, gpio2_verbs);
4261 snd_hda_apply_pincfgs(codec, dock_pins);
4262 spec->gen.auto_mute_via_amp = 1;
4263 spec->gen.automute_hook = asus_tx300_automute;
4264 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4265 HDA_GEN_HP_EVENT,
4266 snd_hda_gen_hp_automute);
4267 break;
4268 case HDA_FIXUP_ACT_BUILD:
4269 /* this is a bit tricky; give more sane names for the main
4270 * (tablet) speaker and the dock speaker, respectively
4271 */
4272 kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch");
4273 if (kctl)
4274 strcpy(kctl->id.name, "Dock Speaker Playback Switch");
4275 kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch");
4276 if (kctl)
4277 strcpy(kctl->id.name, "Speaker Playback Switch");
4278 break;
4279 }
4280}
4281
David Henningsson338cae52013-10-07 10:39:59 +02004282static void alc290_fixup_mono_speakers(struct hda_codec *codec,
4283 const struct hda_fixup *fix, int action)
4284{
David Henningsson0f4881d2013-12-20 16:08:13 +01004285 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4286 /* DAC node 0x03 is giving mono output. We therefore want to
4287 make sure 0x14 (front speaker) and 0x15 (headphones) use the
4288 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
4289 hda_nid_t conn1[2] = { 0x0c };
4290 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
4291 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
4292 }
David Henningsson338cae52013-10-07 10:39:59 +02004293}
4294
Takashi Iwaib317b032014-01-08 11:44:21 +01004295/* for hda_fixup_thinkpad_acpi() */
4296#include "thinkpad_helper.c"
David Henningssonb67ae3f2013-11-05 13:11:37 +01004297
Takashi Iwai1d045db2011-07-07 18:23:21 +02004298enum {
4299 ALC269_FIXUP_SONY_VAIO,
4300 ALC275_FIXUP_SONY_VAIO_GPIO2,
4301 ALC269_FIXUP_DELL_M101Z,
4302 ALC269_FIXUP_SKU_IGNORE,
4303 ALC269_FIXUP_ASUS_G73JW,
4304 ALC269_FIXUP_LENOVO_EAPD,
4305 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004306 ALC275_FIXUP_SONY_DISABLE_AAMIX,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004307 ALC271_FIXUP_DMIC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02004308 ALC269_FIXUP_PCM_44K,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004309 ALC269_FIXUP_STEREO_DMIC,
David Henningsson7c478f02013-10-11 10:18:46 +02004310 ALC269_FIXUP_HEADSET_MIC,
Takashi Iwai24519912011-08-16 15:08:49 +02004311 ALC269_FIXUP_QUANTA_MUTE,
4312 ALC269_FIXUP_LIFEBOOK,
David Henningsson2041d562014-06-13 11:15:44 +02004313 ALC269_FIXUP_LIFEBOOK_EXTMIC,
Takashi Iwaia4297b52011-08-23 18:40:12 +02004314 ALC269_FIXUP_AMIC,
4315 ALC269_FIXUP_DMIC,
4316 ALC269VB_FIXUP_AMIC,
4317 ALC269VB_FIXUP_DMIC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004318 ALC269_FIXUP_HP_MUTE_LED,
David Henningssond06ac142013-02-18 11:41:55 +01004319 ALC269_FIXUP_HP_MUTE_LED_MIC1,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004320 ALC269_FIXUP_HP_MUTE_LED_MIC2,
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004321 ALC269_FIXUP_HP_GPIO_LED,
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004322 ALC269_FIXUP_HP_GPIO_MIC1_LED,
4323 ALC269_FIXUP_HP_LINE1_MIC1_LED,
David Henningsson693b6132012-06-22 19:12:10 +02004324 ALC269_FIXUP_INV_DMIC,
David Henningsson108cc102012-07-20 10:37:25 +02004325 ALC269_FIXUP_LENOVO_DOCK,
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004326 ALC269_FIXUP_NO_SHUTUP,
David Henningsson88cfcf82013-10-11 10:18:45 +02004327 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
David Henningsson108cc102012-07-20 10:37:25 +02004328 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
David Henningsson73bdd592013-04-15 15:44:14 +02004329 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
4330 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
David Henningsson338cae52013-10-07 10:39:59 +02004331 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
David Henningsson73bdd592013-04-15 15:44:14 +02004332 ALC269_FIXUP_HEADSET_MODE,
4333 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
David Henningssond240d1d2013-04-15 12:50:02 +02004334 ALC269_FIXUP_ASUS_X101_FUNC,
4335 ALC269_FIXUP_ASUS_X101_VERB,
4336 ALC269_FIXUP_ASUS_X101,
Dylan Reid08a978d2012-11-18 22:56:40 -08004337 ALC271_FIXUP_AMIC_MIC2,
4338 ALC271_FIXUP_HP_GATE_MIC_JACK,
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004339 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
Dylan Reid42397002013-04-05 14:58:22 -07004340 ALC269_FIXUP_ACER_AC700,
David Henningsson3e0d6112013-04-22 14:30:14 +02004341 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
Oleksij Rempel2cede302013-11-27 17:12:03 +01004342 ALC269VB_FIXUP_ASUS_ZENBOOK,
Takashi Iwai23870832013-11-29 14:13:12 +01004343 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
David Henningsson8e35cd42013-11-06 11:20:01 +01004344 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
Anisse Astier02b504d2013-06-03 11:53:10 +02004345 ALC269VB_FIXUP_ORDISSIMO_EVE2,
Kailang Yangcd217a62013-08-22 10:15:24 +02004346 ALC283_FIXUP_CHROME_BOOK,
Kailang Yang0202e992013-12-02 15:20:15 +08004347 ALC283_FIXUP_SENSE_COMBO_JACK,
Takashi Iwai7bba2152013-09-06 15:45:38 +02004348 ALC282_FIXUP_ASUS_TX300,
Kailang Yang1bb3e062013-09-27 13:10:25 +02004349 ALC283_FIXUP_INT_MIC,
David Henningsson338cae52013-10-07 10:39:59 +02004350 ALC290_FIXUP_MONO_SPEAKERS,
David Henningsson0f4881d2013-12-20 16:08:13 +01004351 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4352 ALC290_FIXUP_SUBWOOFER,
4353 ALC290_FIXUP_SUBWOOFER_HSJACK,
David Henningssonb67ae3f2013-11-05 13:11:37 +01004354 ALC269_FIXUP_THINKPAD_ACPI,
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004355 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
Kailang Yang31278992014-03-03 15:27:22 +08004356 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004357 ALC255_FIXUP_HEADSET_MODE,
Kailang Yang31278992014-03-03 15:27:22 +08004358 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
Kailang Yanga22aa262014-04-23 17:34:28 +08004359 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
Takashi Iwai1c37c222014-05-06 17:34:42 +02004360 ALC292_FIXUP_TPT440_DOCK,
Daniel Drake9dc12862014-07-22 10:58:29 +01004361 ALC283_FIXUP_BXBT2807_MIC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004362};
4363
Takashi Iwai1727a772013-01-10 09:52:52 +01004364static const struct hda_fixup alc269_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02004365 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01004366 .type = HDA_FIXUP_PINCTLS,
4367 .v.pins = (const struct hda_pintbl[]) {
4368 {0x19, PIN_VREFGRD},
Takashi Iwai1d045db2011-07-07 18:23:21 +02004369 {}
4370 }
4371 },
4372 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004373 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004374 .v.verbs = (const struct hda_verb[]) {
4375 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
4376 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
4377 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4378 { }
4379 },
4380 .chained = true,
4381 .chain_id = ALC269_FIXUP_SONY_VAIO
4382 },
4383 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004384 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004385 .v.verbs = (const struct hda_verb[]) {
4386 /* Enables internal speaker */
4387 {0x20, AC_VERB_SET_COEF_INDEX, 13},
4388 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4389 {}
4390 }
4391 },
4392 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004393 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02004394 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004395 },
4396 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004397 .type = HDA_FIXUP_PINS,
4398 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02004399 { 0x17, 0x99130111 }, /* subwoofer */
4400 { }
4401 }
4402 },
4403 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004404 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004405 .v.verbs = (const struct hda_verb[]) {
4406 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4407 {}
4408 }
4409 },
4410 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004411 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004412 .v.func = alc269_fixup_hweq,
4413 .chained = true,
4414 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
4415 },
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004416 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
4417 .type = HDA_FIXUP_FUNC,
4418 .v.func = alc_fixup_disable_aamix,
4419 .chained = true,
4420 .chain_id = ALC269_FIXUP_SONY_VAIO
4421 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02004422 [ALC271_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004423 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004424 .v.func = alc271_fixup_dmic,
4425 },
Takashi Iwai017f2a12011-07-09 14:42:25 +02004426 [ALC269_FIXUP_PCM_44K] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004427 .type = HDA_FIXUP_FUNC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02004428 .v.func = alc269_fixup_pcm_44k,
David Henningsson012e7eb2012-08-08 08:43:37 +02004429 .chained = true,
4430 .chain_id = ALC269_FIXUP_QUANTA_MUTE
Takashi Iwai017f2a12011-07-09 14:42:25 +02004431 },
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004432 [ALC269_FIXUP_STEREO_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004433 .type = HDA_FIXUP_FUNC,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004434 .v.func = alc269_fixup_stereo_dmic,
4435 },
David Henningsson7c478f02013-10-11 10:18:46 +02004436 [ALC269_FIXUP_HEADSET_MIC] = {
4437 .type = HDA_FIXUP_FUNC,
4438 .v.func = alc269_fixup_headset_mic,
4439 },
Takashi Iwai24519912011-08-16 15:08:49 +02004440 [ALC269_FIXUP_QUANTA_MUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004441 .type = HDA_FIXUP_FUNC,
Takashi Iwai24519912011-08-16 15:08:49 +02004442 .v.func = alc269_fixup_quanta_mute,
4443 },
4444 [ALC269_FIXUP_LIFEBOOK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004445 .type = HDA_FIXUP_PINS,
4446 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai24519912011-08-16 15:08:49 +02004447 { 0x1a, 0x2101103f }, /* dock line-out */
4448 { 0x1b, 0x23a11040 }, /* dock mic-in */
4449 { }
4450 },
4451 .chained = true,
4452 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4453 },
David Henningsson2041d562014-06-13 11:15:44 +02004454 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
4455 .type = HDA_FIXUP_PINS,
4456 .v.pins = (const struct hda_pintbl[]) {
4457 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
4458 { }
4459 },
4460 },
Takashi Iwaia4297b52011-08-23 18:40:12 +02004461 [ALC269_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004462 .type = HDA_FIXUP_PINS,
4463 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004464 { 0x14, 0x99130110 }, /* speaker */
4465 { 0x15, 0x0121401f }, /* HP out */
4466 { 0x18, 0x01a19c20 }, /* mic */
4467 { 0x19, 0x99a3092f }, /* int-mic */
4468 { }
4469 },
4470 },
4471 [ALC269_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004472 .type = HDA_FIXUP_PINS,
4473 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004474 { 0x12, 0x99a3092f }, /* int-mic */
4475 { 0x14, 0x99130110 }, /* speaker */
4476 { 0x15, 0x0121401f }, /* HP out */
4477 { 0x18, 0x01a19c20 }, /* mic */
4478 { }
4479 },
4480 },
4481 [ALC269VB_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004482 .type = HDA_FIXUP_PINS,
4483 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004484 { 0x14, 0x99130110 }, /* speaker */
4485 { 0x18, 0x01a19c20 }, /* mic */
4486 { 0x19, 0x99a3092f }, /* int-mic */
4487 { 0x21, 0x0121401f }, /* HP out */
4488 { }
4489 },
4490 },
David Henningsson2267ea92012-01-03 08:45:56 +01004491 [ALC269VB_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004492 .type = HDA_FIXUP_PINS,
4493 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004494 { 0x12, 0x99a3092f }, /* int-mic */
4495 { 0x14, 0x99130110 }, /* speaker */
4496 { 0x18, 0x01a19c20 }, /* mic */
4497 { 0x21, 0x0121401f }, /* HP out */
4498 { }
4499 },
4500 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004501 [ALC269_FIXUP_HP_MUTE_LED] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004502 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004503 .v.func = alc269_fixup_hp_mute_led,
David Henningsson6d3cd5d2013-01-07 12:03:47 +01004504 },
David Henningssond06ac142013-02-18 11:41:55 +01004505 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
4506 .type = HDA_FIXUP_FUNC,
4507 .v.func = alc269_fixup_hp_mute_led_mic1,
4508 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004509 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004510 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004511 .v.func = alc269_fixup_hp_mute_led_mic2,
Takashi Iwai420b0fe2012-03-12 12:35:27 +01004512 },
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004513 [ALC269_FIXUP_HP_GPIO_LED] = {
4514 .type = HDA_FIXUP_FUNC,
4515 .v.func = alc269_fixup_hp_gpio_led,
4516 },
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004517 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
4518 .type = HDA_FIXUP_FUNC,
4519 .v.func = alc269_fixup_hp_gpio_mic1_led,
4520 },
4521 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
4522 .type = HDA_FIXUP_FUNC,
4523 .v.func = alc269_fixup_hp_line1_mic1_led,
4524 },
David Henningsson693b6132012-06-22 19:12:10 +02004525 [ALC269_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004526 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02004527 .v.func = alc_fixup_inv_dmic_0x12,
David Henningsson693b6132012-06-22 19:12:10 +02004528 },
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004529 [ALC269_FIXUP_NO_SHUTUP] = {
4530 .type = HDA_FIXUP_FUNC,
4531 .v.func = alc_fixup_no_shutup,
4532 },
David Henningsson108cc102012-07-20 10:37:25 +02004533 [ALC269_FIXUP_LENOVO_DOCK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004534 .type = HDA_FIXUP_PINS,
4535 .v.pins = (const struct hda_pintbl[]) {
David Henningsson108cc102012-07-20 10:37:25 +02004536 { 0x19, 0x23a11040 }, /* dock mic */
4537 { 0x1b, 0x2121103f }, /* dock headphone */
4538 { }
4539 },
4540 .chained = true,
4541 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
4542 },
4543 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004544 .type = HDA_FIXUP_FUNC,
David Henningsson108cc102012-07-20 10:37:25 +02004545 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
David Henningsson52129002013-11-19 10:25:53 +01004546 .chained = true,
4547 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
David Henningsson108cc102012-07-20 10:37:25 +02004548 },
David Henningsson73bdd592013-04-15 15:44:14 +02004549 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4550 .type = HDA_FIXUP_PINS,
4551 .v.pins = (const struct hda_pintbl[]) {
4552 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4553 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4554 { }
4555 },
4556 .chained = true,
4557 .chain_id = ALC269_FIXUP_HEADSET_MODE
4558 },
4559 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4560 .type = HDA_FIXUP_PINS,
4561 .v.pins = (const struct hda_pintbl[]) {
4562 { 0x16, 0x21014020 }, /* dock line out */
4563 { 0x19, 0x21a19030 }, /* dock mic */
4564 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4565 { }
4566 },
4567 .chained = true,
4568 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4569 },
David Henningsson338cae52013-10-07 10:39:59 +02004570 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
4571 .type = HDA_FIXUP_PINS,
4572 .v.pins = (const struct hda_pintbl[]) {
4573 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4574 { }
4575 },
4576 .chained = true,
4577 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4578 },
David Henningsson73bdd592013-04-15 15:44:14 +02004579 [ALC269_FIXUP_HEADSET_MODE] = {
4580 .type = HDA_FIXUP_FUNC,
4581 .v.func = alc_fixup_headset_mode,
4582 },
4583 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4584 .type = HDA_FIXUP_FUNC,
4585 .v.func = alc_fixup_headset_mode_no_hp_mic,
4586 },
David Henningsson88cfcf82013-10-11 10:18:45 +02004587 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
4588 .type = HDA_FIXUP_PINS,
4589 .v.pins = (const struct hda_pintbl[]) {
4590 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4591 { }
4592 },
David Henningssonfbc78ad2013-10-11 13:46:04 +02004593 .chained = true,
4594 .chain_id = ALC269_FIXUP_HEADSET_MIC
David Henningsson88cfcf82013-10-11 10:18:45 +02004595 },
David Henningssond240d1d2013-04-15 12:50:02 +02004596 [ALC269_FIXUP_ASUS_X101_FUNC] = {
4597 .type = HDA_FIXUP_FUNC,
4598 .v.func = alc269_fixup_x101_headset_mic,
4599 },
4600 [ALC269_FIXUP_ASUS_X101_VERB] = {
4601 .type = HDA_FIXUP_VERBS,
4602 .v.verbs = (const struct hda_verb[]) {
4603 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4604 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
4605 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
4606 { }
4607 },
4608 .chained = true,
4609 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
4610 },
4611 [ALC269_FIXUP_ASUS_X101] = {
4612 .type = HDA_FIXUP_PINS,
4613 .v.pins = (const struct hda_pintbl[]) {
4614 { 0x18, 0x04a1182c }, /* Headset mic */
4615 { }
4616 },
4617 .chained = true,
4618 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
4619 },
Dylan Reid08a978d2012-11-18 22:56:40 -08004620 [ALC271_FIXUP_AMIC_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004621 .type = HDA_FIXUP_PINS,
4622 .v.pins = (const struct hda_pintbl[]) {
Dylan Reid08a978d2012-11-18 22:56:40 -08004623 { 0x14, 0x99130110 }, /* speaker */
4624 { 0x19, 0x01a19c20 }, /* mic */
4625 { 0x1b, 0x99a7012f }, /* int-mic */
4626 { 0x21, 0x0121401f }, /* HP out */
4627 { }
4628 },
4629 },
4630 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004631 .type = HDA_FIXUP_FUNC,
Dylan Reid08a978d2012-11-18 22:56:40 -08004632 .v.func = alc271_hp_gate_mic_jack,
4633 .chained = true,
4634 .chain_id = ALC271_FIXUP_AMIC_MIC2,
4635 },
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004636 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
4637 .type = HDA_FIXUP_FUNC,
4638 .v.func = alc269_fixup_limit_int_mic_boost,
4639 .chained = true,
4640 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
4641 },
Dylan Reid42397002013-04-05 14:58:22 -07004642 [ALC269_FIXUP_ACER_AC700] = {
4643 .type = HDA_FIXUP_PINS,
4644 .v.pins = (const struct hda_pintbl[]) {
4645 { 0x12, 0x99a3092f }, /* int-mic */
4646 { 0x14, 0x99130110 }, /* speaker */
4647 { 0x18, 0x03a11c20 }, /* mic */
4648 { 0x1e, 0x0346101e }, /* SPDIF1 */
4649 { 0x21, 0x0321101f }, /* HP out */
4650 { }
4651 },
4652 .chained = true,
4653 .chain_id = ALC271_FIXUP_DMIC,
4654 },
David Henningsson3e0d6112013-04-22 14:30:14 +02004655 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
4656 .type = HDA_FIXUP_FUNC,
4657 .v.func = alc269_fixup_limit_int_mic_boost,
David Henningsson27937692013-11-18 11:51:47 +01004658 .chained = true,
4659 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
David Henningsson3e0d6112013-04-22 14:30:14 +02004660 },
Oleksij Rempel2cede302013-11-27 17:12:03 +01004661 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
4662 .type = HDA_FIXUP_FUNC,
4663 .v.func = alc269_fixup_limit_int_mic_boost,
4664 .chained = true,
4665 .chain_id = ALC269VB_FIXUP_DMIC,
4666 },
Takashi Iwai23870832013-11-29 14:13:12 +01004667 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
4668 .type = HDA_FIXUP_VERBS,
4669 .v.verbs = (const struct hda_verb[]) {
4670 /* class-D output amp +5dB */
4671 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
4672 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
4673 {}
4674 },
4675 .chained = true,
4676 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
4677 },
David Henningsson8e35cd42013-11-06 11:20:01 +01004678 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
4679 .type = HDA_FIXUP_FUNC,
4680 .v.func = alc269_fixup_limit_int_mic_boost,
4681 .chained = true,
4682 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
4683 },
Anisse Astier02b504d2013-06-03 11:53:10 +02004684 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
4685 .type = HDA_FIXUP_PINS,
4686 .v.pins = (const struct hda_pintbl[]) {
4687 { 0x12, 0x99a3092f }, /* int-mic */
4688 { 0x18, 0x03a11d20 }, /* mic */
4689 { 0x19, 0x411111f0 }, /* Unused bogus pin */
4690 { }
4691 },
4692 },
Kailang Yangcd217a62013-08-22 10:15:24 +02004693 [ALC283_FIXUP_CHROME_BOOK] = {
4694 .type = HDA_FIXUP_FUNC,
4695 .v.func = alc283_fixup_chromebook,
4696 },
Kailang Yang0202e992013-12-02 15:20:15 +08004697 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
4698 .type = HDA_FIXUP_FUNC,
4699 .v.func = alc283_fixup_sense_combo_jack,
4700 .chained = true,
4701 .chain_id = ALC283_FIXUP_CHROME_BOOK,
4702 },
Takashi Iwai7bba2152013-09-06 15:45:38 +02004703 [ALC282_FIXUP_ASUS_TX300] = {
4704 .type = HDA_FIXUP_FUNC,
4705 .v.func = alc282_fixup_asus_tx300,
4706 },
Kailang Yang1bb3e062013-09-27 13:10:25 +02004707 [ALC283_FIXUP_INT_MIC] = {
4708 .type = HDA_FIXUP_VERBS,
4709 .v.verbs = (const struct hda_verb[]) {
4710 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
4711 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
4712 { }
4713 },
4714 .chained = true,
4715 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4716 },
David Henningsson0f4881d2013-12-20 16:08:13 +01004717 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
4718 .type = HDA_FIXUP_PINS,
4719 .v.pins = (const struct hda_pintbl[]) {
4720 { 0x17, 0x90170112 }, /* subwoofer */
4721 { }
4722 },
4723 .chained = true,
4724 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4725 },
4726 [ALC290_FIXUP_SUBWOOFER] = {
4727 .type = HDA_FIXUP_PINS,
4728 .v.pins = (const struct hda_pintbl[]) {
4729 { 0x17, 0x90170112 }, /* subwoofer */
4730 { }
4731 },
4732 .chained = true,
4733 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
4734 },
David Henningsson338cae52013-10-07 10:39:59 +02004735 [ALC290_FIXUP_MONO_SPEAKERS] = {
4736 .type = HDA_FIXUP_FUNC,
4737 .v.func = alc290_fixup_mono_speakers,
David Henningsson0f4881d2013-12-20 16:08:13 +01004738 },
4739 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
4740 .type = HDA_FIXUP_FUNC,
4741 .v.func = alc290_fixup_mono_speakers,
David Henningsson338cae52013-10-07 10:39:59 +02004742 .chained = true,
4743 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
4744 },
David Henningssonb67ae3f2013-11-05 13:11:37 +01004745 [ALC269_FIXUP_THINKPAD_ACPI] = {
4746 .type = HDA_FIXUP_FUNC,
Takashi Iwaib317b032014-01-08 11:44:21 +01004747 .v.func = hda_fixup_thinkpad_acpi,
David Henningssonb67ae3f2013-11-05 13:11:37 +01004748 },
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004749 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4750 .type = HDA_FIXUP_PINS,
4751 .v.pins = (const struct hda_pintbl[]) {
4752 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4753 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4754 { }
4755 },
4756 .chained = true,
4757 .chain_id = ALC255_FIXUP_HEADSET_MODE
4758 },
Kailang Yang31278992014-03-03 15:27:22 +08004759 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4760 .type = HDA_FIXUP_PINS,
4761 .v.pins = (const struct hda_pintbl[]) {
4762 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4763 { }
4764 },
4765 .chained = true,
4766 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
4767 },
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004768 [ALC255_FIXUP_HEADSET_MODE] = {
4769 .type = HDA_FIXUP_FUNC,
4770 .v.func = alc_fixup_headset_mode_alc255,
4771 },
Kailang Yang31278992014-03-03 15:27:22 +08004772 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4773 .type = HDA_FIXUP_FUNC,
4774 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
4775 },
Kailang Yanga22aa262014-04-23 17:34:28 +08004776 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4777 .type = HDA_FIXUP_PINS,
4778 .v.pins = (const struct hda_pintbl[]) {
4779 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4780 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4781 { }
4782 },
4783 .chained = true,
4784 .chain_id = ALC269_FIXUP_HEADSET_MODE
4785 },
Takashi Iwai1c37c222014-05-06 17:34:42 +02004786 [ALC292_FIXUP_TPT440_DOCK] = {
4787 .type = HDA_FIXUP_PINS,
4788 .v.pins = (const struct hda_pintbl[]) {
4789 { 0x16, 0x21211010 }, /* dock headphone */
4790 { 0x19, 0x21a11010 }, /* dock mic */
4791 { }
4792 },
4793 .chained = true,
4794 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4795 },
Daniel Drake9dc12862014-07-22 10:58:29 +01004796 [ALC283_FIXUP_BXBT2807_MIC] = {
4797 .type = HDA_FIXUP_PINS,
4798 .v.pins = (const struct hda_pintbl[]) {
4799 { 0x19, 0x04a110f0 },
4800 { },
4801 },
4802 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02004803};
4804
4805static const struct snd_pci_quirk alc269_fixup_tbl[] = {
Marius Knausta6b92b62014-03-03 01:48:58 +01004806 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
David Henningsson693b6132012-06-22 19:12:10 +02004807 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
4808 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
David Henningssonaaedfb42013-08-16 14:09:02 +02004809 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
4810 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4811 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
4812 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004813 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
David Henningssonaaedfb42013-08-16 14:09:02 +02004814 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson73bdd592013-04-15 15:44:14 +02004815 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4816 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4817 SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4818 SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4819 SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4820 SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4821 SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4822 SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4823 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4824 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
Kailang Yang05843c02013-07-01 11:27:16 +02004825 SND_PCI_QUIRK(0x1028, 0x05cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4826 SND_PCI_QUIRK(0x1028, 0x05cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
David Henningsson0f4881d2013-12-20 16:08:13 +01004827 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
David Henningsson436c4a02013-05-15 13:56:00 +02004828 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
David Henningssond81bf8c2013-06-11 11:06:48 +02004829 SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
David Henningsson73bdd592013-04-15 15:44:14 +02004830 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4831 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4832 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4833 SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4834 SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4835 SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4836 SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4837 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4838 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4839 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningsson3ee21022013-05-31 10:41:04 +02004840 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningssoncd6fb6792013-06-28 11:09:56 +02004841 SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4842 SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningssond81bf8c2013-06-11 11:06:48 +02004843 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4844 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningsson3ee21022013-05-31 10:41:04 +02004845 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningsson6c29d682013-06-28 08:53:34 +02004846 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningssonb8362e72013-11-21 14:12:59 +01004847 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningsson0f4881d2013-12-20 16:08:13 +01004848 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4849 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
David Henningsson0f4881d2013-12-20 16:08:13 +01004850 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004851 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
Kailang Yanga22aa262014-04-23 17:34:28 +08004852 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4853 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
Kailang Yang31278992014-03-03 15:27:22 +08004854 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4855 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
Hui Wanga1f3b5f2014-05-09 11:12:58 +08004856 SND_PCI_QUIRK(0x1028, 0x0684, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
Kailang Yang05843c02013-07-01 11:27:16 +02004857 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4858 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
Kailang Yanga22aa262014-04-23 17:34:28 +08004859 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4860 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004861 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004862 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
David Henningssond06ac142013-02-18 11:41:55 +01004863 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4864 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
David Henningsson8e35cd42013-11-06 11:20:01 +01004865 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004866 /* ALC282 */
Hui Wang549d8782014-07-07 17:07:43 +08004867 SND_PCI_QUIRK(0x103c, 0x21f8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4868 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004869 SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4870 SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004871 SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004872 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4873 SND_PCI_QUIRK(0x103c, 0x2211, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4874 SND_PCI_QUIRK(0x103c, 0x2212, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004875 SND_PCI_QUIRK(0x103c, 0x2213, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004876 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004877 SND_PCI_QUIRK(0x103c, 0x2234, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4878 SND_PCI_QUIRK(0x103c, 0x2235, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4879 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4880 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4881 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4882 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4883 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4884 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4885 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4886 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4887 SND_PCI_QUIRK(0x103c, 0x224a, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4888 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4889 SND_PCI_QUIRK(0x103c, 0x224c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4890 SND_PCI_QUIRK(0x103c, 0x224d, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004891 SND_PCI_QUIRK(0x103c, 0x2266, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4892 SND_PCI_QUIRK(0x103c, 0x2267, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4893 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4894 SND_PCI_QUIRK(0x103c, 0x2269, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4895 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4896 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004897 SND_PCI_QUIRK(0x103c, 0x226c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4898 SND_PCI_QUIRK(0x103c, 0x226d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4899 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4900 SND_PCI_QUIRK(0x103c, 0x226f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004901 SND_PCI_QUIRK(0x103c, 0x227a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4902 SND_PCI_QUIRK(0x103c, 0x227b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4903 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4904 SND_PCI_QUIRK(0x103c, 0x22a0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4905 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4906 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4907 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4908 SND_PCI_QUIRK(0x103c, 0x22c0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4909 SND_PCI_QUIRK(0x103c, 0x22c1, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4910 SND_PCI_QUIRK(0x103c, 0x22c2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4911 SND_PCI_QUIRK(0x103c, 0x22cd, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4912 SND_PCI_QUIRK(0x103c, 0x22ce, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4913 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4914 SND_PCI_QUIRK(0x103c, 0x22d0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004915 SND_PCI_QUIRK(0x103c, 0x22da, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4916 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4917 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4918 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4919 SND_PCI_QUIRK(0x103c, 0x8004, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004920 /* ALC290 */
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004921 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Hui Wang549d8782014-07-07 17:07:43 +08004922 SND_PCI_QUIRK(0x103c, 0x221c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4923 SND_PCI_QUIRK(0x103c, 0x221d, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004924 SND_PCI_QUIRK(0x103c, 0x2220, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4925 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4926 SND_PCI_QUIRK(0x103c, 0x2222, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4927 SND_PCI_QUIRK(0x103c, 0x2223, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4928 SND_PCI_QUIRK(0x103c, 0x2224, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4929 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4930 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4931 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4932 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4933 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4934 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4935 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4936 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4937 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4938 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4939 SND_PCI_QUIRK(0x103c, 0x2258, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4940 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4941 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004942 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4943 SND_PCI_QUIRK(0x103c, 0x2261, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4944 SND_PCI_QUIRK(0x103c, 0x2262, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4945 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4946 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4947 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004948 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4949 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4950 SND_PCI_QUIRK(0x103c, 0x2277, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4951 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004952 SND_PCI_QUIRK(0x103c, 0x227d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4953 SND_PCI_QUIRK(0x103c, 0x227e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4954 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4955 SND_PCI_QUIRK(0x103c, 0x2280, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4956 SND_PCI_QUIRK(0x103c, 0x2281, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4957 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4958 SND_PCI_QUIRK(0x103c, 0x2289, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4959 SND_PCI_QUIRK(0x103c, 0x228a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4960 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4961 SND_PCI_QUIRK(0x103c, 0x228c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangfce0a0c2014-02-26 15:23:19 +08004962 SND_PCI_QUIRK(0x103c, 0x228d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004963 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4964 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4965 SND_PCI_QUIRK(0x103c, 0x22c6, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4966 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4967 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4968 SND_PCI_QUIRK(0x103c, 0x22c3, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4969 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004970 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4971 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4972 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4973 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004974 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
Takashi Iwai7bba2152013-09-06 15:45:38 +02004975 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
David Henningsson3e0d6112013-04-22 14:30:14 +02004976 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4977 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Oleksij Rempel2cede302013-11-27 17:12:03 +01004978 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
Takashi Iwai23870832013-11-29 14:13:12 +01004979 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
David Henningsson3e0d6112013-04-22 14:30:14 +02004980 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
Takashi Iwai017f2a12011-07-09 14:42:25 +02004981 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
David Henningsson693b6132012-06-22 19:12:10 +02004982 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
David Henningsson3e0d6112013-04-22 14:30:14 +02004983 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004984 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
4985 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
4986 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
4987 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
David Henningssond240d1d2013-04-15 12:50:02 +02004988 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
Takashi Iwaif88abaa2014-02-07 12:07:59 +01004989 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
David Henningsson88cfcf82013-10-11 10:18:45 +02004990 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004991 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
4992 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
4993 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004994 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004995 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwai24519912011-08-16 15:08:49 +02004996 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
David Henningsson2041d562014-06-13 11:15:44 +02004997 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
Daniel Drake9dc12862014-07-22 10:58:29 +01004998 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004999 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
5000 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
5001 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
5002 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
5003 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
Takashi Iwai707fba32012-08-02 09:04:39 +02005004 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
Felix Kaechelec8415a42012-08-06 23:02:01 +02005005 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
Stefán Freyr84f98fd2012-10-19 22:46:00 +02005006 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
Philipp A. Mohrenweiser4407be62012-08-06 13:14:18 +02005007 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
David Henningsson108cc102012-07-20 10:37:25 +02005008 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
David Henningssonaaedfb42013-08-16 14:09:02 +02005009 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
Takashi Iwai1c37c222014-05-06 17:34:42 +02005010 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
5011 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
Takashi Iwaia12137e2014-06-27 12:14:35 +02005012 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
David Henningssoncd5302c2013-08-19 12:22:33 +02005013 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningsson27937692013-11-18 11:51:47 +01005014 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningssona4a9e082013-08-16 14:09:01 +02005015 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Takashi Iwai9b745ab2014-03-07 08:37:19 +01005016 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
David Henningssona4a9e082013-08-16 14:09:01 +02005017 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Kailang Yang1bb3e062013-09-27 13:10:25 +02005018 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
David Henningssoncd5302c2013-08-19 12:22:33 +02005019 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5020 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningsson012e7eb2012-08-08 08:43:37 +02005021 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005022 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
David Henningsson27937692013-11-18 11:51:47 +01005023 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
Anisse Astier02b504d2013-06-03 11:53:10 +02005024 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02005025
Takashi Iwaia7f3eed2012-02-16 13:03:18 +01005026#if 0
Takashi Iwaia4297b52011-08-23 18:40:12 +02005027 /* Below is a quirk table taken from the old code.
5028 * Basically the device should work as is without the fixup table.
5029 * If BIOS doesn't give a proper info, enable the corresponding
5030 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02005031 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02005032 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
5033 ALC269_FIXUP_AMIC),
5034 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
Takashi Iwaia4297b52011-08-23 18:40:12 +02005035 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
5036 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
5037 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
5038 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
5039 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
5040 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
5041 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
5042 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
5043 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
5044 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
5045 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
5046 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
5047 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
5048 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
5049 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
5050 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
5051 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
5052 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
5053 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
5054 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
5055 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
5056 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
5057 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
5058 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
5059 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
5060 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
5061 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
5062 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
5063 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
5064 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
5065 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
5066 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
5067 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
5068 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
5069 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
5070 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
5071 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
5072 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
5073#endif
5074 {}
5075};
5076
Takashi Iwai1727a772013-01-10 09:52:52 +01005077static const struct hda_model_fixup alc269_fixup_models[] = {
Takashi Iwaia4297b52011-08-23 18:40:12 +02005078 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5079 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02005080 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
5081 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
5082 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningsson7c478f02013-10-11 10:18:46 +02005083 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
David Henningsson108cc102012-07-20 10:37:25 +02005084 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01005085 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
David Henningssone32aa852013-06-17 11:04:02 +02005086 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
5087 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
Kailang Yangbe8ef162014-04-08 15:19:49 +08005088 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
Kailang Yang0202e992013-12-02 15:20:15 +08005089 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
Takashi Iwai1c37c222014-05-06 17:34:42 +02005090 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
Takashi Iwai1d045db2011-07-07 18:23:21 +02005091 {}
5092};
5093
Hui Wange1918932014-05-26 16:22:44 +08005094static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
David Henningsson76c21322014-06-24 14:46:54 +02005095 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5096 {0x12, 0x90a60140},
5097 {0x14, 0x90170110},
5098 {0x17, 0x40000000},
5099 {0x18, 0x411111f0},
5100 {0x19, 0x411111f0},
5101 {0x1a, 0x411111f0},
5102 {0x1b, 0x411111f0},
5103 {0x1d, 0x40700001},
5104 {0x1e, 0x411111f0},
5105 {0x21, 0x02211020}),
5106 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5107 {0x12, 0x90a60160},
5108 {0x14, 0x90170120},
5109 {0x17, 0x40000000},
5110 {0x18, 0x411111f0},
5111 {0x19, 0x411111f0},
5112 {0x1a, 0x411111f0},
5113 {0x1b, 0x411111f0},
5114 {0x1d, 0x40700001},
5115 {0x1e, 0x411111f0},
5116 {0x21, 0x02211030}),
5117 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5118 {0x12, 0x90a60160},
5119 {0x14, 0x90170120},
5120 {0x17, 0x90170140},
5121 {0x18, 0x40000000},
5122 {0x19, 0x411111f0},
5123 {0x1a, 0x411111f0},
5124 {0x1b, 0x411111f0},
5125 {0x1d, 0x41163b05},
5126 {0x1e, 0x411111f0},
5127 {0x21, 0x0321102f}),
5128 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5129 {0x12, 0x90a60160},
5130 {0x14, 0x90170130},
5131 {0x17, 0x40000000},
5132 {0x18, 0x411111f0},
5133 {0x19, 0x411111f0},
5134 {0x1a, 0x411111f0},
5135 {0x1b, 0x411111f0},
5136 {0x1d, 0x40700001},
5137 {0x1e, 0x411111f0},
5138 {0x21, 0x02211040}),
5139 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5140 {0x12, 0x90a60160},
5141 {0x14, 0x90170140},
5142 {0x17, 0x40000000},
5143 {0x18, 0x411111f0},
5144 {0x19, 0x411111f0},
5145 {0x1a, 0x411111f0},
5146 {0x1b, 0x411111f0},
5147 {0x1d, 0x40700001},
5148 {0x1e, 0x411111f0},
5149 {0x21, 0x02211050}),
5150 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5151 {0x12, 0x90a60170},
5152 {0x14, 0x90170120},
5153 {0x17, 0x40000000},
5154 {0x18, 0x411111f0},
5155 {0x19, 0x411111f0},
5156 {0x1a, 0x411111f0},
5157 {0x1b, 0x411111f0},
5158 {0x1d, 0x40700001},
5159 {0x1e, 0x411111f0},
5160 {0x21, 0x02211030}),
5161 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5162 {0x12, 0x90a60170},
5163 {0x14, 0x90170130},
5164 {0x17, 0x40000000},
5165 {0x18, 0x411111f0},
5166 {0x19, 0x411111f0},
5167 {0x1a, 0x411111f0},
5168 {0x1b, 0x411111f0},
5169 {0x1d, 0x40700001},
5170 {0x1e, 0x411111f0},
5171 {0x21, 0x02211040}),
David Henningsson42304472014-07-22 11:42:17 +02005172 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5173 {0x12, 0x99a30130},
5174 {0x14, 0x90170110},
5175 {0x17, 0x40000000},
5176 {0x18, 0x411111f0},
5177 {0x19, 0x03a11020},
5178 {0x1a, 0x411111f0},
5179 {0x1b, 0x411111f0},
5180 {0x1d, 0x40f41905},
5181 {0x1e, 0x411111f0},
5182 {0x21, 0x0321101f}),
David Henningsson76c21322014-06-24 14:46:54 +02005183 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5184 {0x12, 0x90a60130},
5185 {0x14, 0x90170110},
5186 {0x17, 0x40020008},
5187 {0x18, 0x411111f0},
5188 {0x19, 0x411111f0},
5189 {0x1a, 0x411111f0},
5190 {0x1b, 0x411111f0},
5191 {0x1d, 0x40e00001},
5192 {0x1e, 0x411111f0},
5193 {0x21, 0x0321101f}),
5194 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5195 {0x12, 0x90a60160},
5196 {0x14, 0x90170120},
5197 {0x17, 0x40000000},
5198 {0x18, 0x411111f0},
5199 {0x19, 0x411111f0},
5200 {0x1a, 0x411111f0},
5201 {0x1b, 0x411111f0},
5202 {0x1d, 0x40700001},
5203 {0x1e, 0x411111f0},
5204 {0x21, 0x02211030}),
5205 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5206 {0x12, 0x90a60140},
5207 {0x13, 0x411111f0},
5208 {0x14, 0x90170110},
5209 {0x15, 0x0221401f},
5210 {0x16, 0x411111f0},
5211 {0x18, 0x411111f0},
5212 {0x19, 0x411111f0},
5213 {0x1a, 0x411111f0},
5214 {0x1b, 0x411111f0},
5215 {0x1d, 0x40700001},
5216 {0x1e, 0x411111f0}),
5217 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5218 {0x12, 0x40000000},
5219 {0x13, 0x90a60140},
5220 {0x14, 0x90170110},
5221 {0x15, 0x0221401f},
5222 {0x16, 0x21014020},
5223 {0x18, 0x411111f0},
5224 {0x19, 0x21a19030},
5225 {0x1a, 0x411111f0},
5226 {0x1b, 0x411111f0},
5227 {0x1d, 0x40700001},
5228 {0x1e, 0x411111f0}),
David Henningssone03fdbd2014-06-27 08:41:59 +02005229 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5230 {0x12, 0x40000000},
5231 {0x13, 0x90a60140},
5232 {0x14, 0x90170110},
5233 {0x15, 0x0221401f},
5234 {0x16, 0x411111f0},
5235 {0x18, 0x411111f0},
5236 {0x19, 0x411111f0},
5237 {0x1a, 0x411111f0},
5238 {0x1b, 0x411111f0},
5239 {0x1d, 0x40700001},
5240 {0x1e, 0x411111f0}),
Hui Wange1918932014-05-26 16:22:44 +08005241 {}
5242};
Takashi Iwai1d045db2011-07-07 18:23:21 +02005243
Takashi Iwai546bb672012-03-07 08:37:19 +01005244static void alc269_fill_coef(struct hda_codec *codec)
Takashi Iwai1d045db2011-07-07 18:23:21 +02005245{
Kailang Yang526af6e2012-03-07 08:25:20 +01005246 struct alc_spec *spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005247 int val;
5248
Kailang Yang526af6e2012-03-07 08:25:20 +01005249 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
Takashi Iwai546bb672012-03-07 08:37:19 +01005250 return;
Kailang Yang526af6e2012-03-07 08:25:20 +01005251
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005252 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005253 alc_write_coef_idx(codec, 0xf, 0x960b);
5254 alc_write_coef_idx(codec, 0xe, 0x8817);
5255 }
5256
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005257 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005258 alc_write_coef_idx(codec, 0xf, 0x960b);
5259 alc_write_coef_idx(codec, 0xe, 0x8814);
5260 }
5261
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005262 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005263 val = alc_read_coef_idx(codec, 0x04);
5264 /* Power up output pin */
5265 alc_write_coef_idx(codec, 0x04, val | (1<<11));
5266 }
5267
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005268 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005269 val = alc_read_coef_idx(codec, 0xd);
5270 if ((val & 0x0c00) >> 10 != 0x1) {
5271 /* Capless ramp up clock control */
5272 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5273 }
5274 val = alc_read_coef_idx(codec, 0x17);
5275 if ((val & 0x01c0) >> 6 != 0x4) {
5276 /* Class D power on reset */
5277 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5278 }
5279 }
5280
5281 val = alc_read_coef_idx(codec, 0xd); /* Class D */
5282 alc_write_coef_idx(codec, 0xd, val | (1<<14));
5283
5284 val = alc_read_coef_idx(codec, 0x4); /* HP */
5285 alc_write_coef_idx(codec, 0x4, val | (1<<11));
Takashi Iwai1d045db2011-07-07 18:23:21 +02005286}
5287
5288/*
5289 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005290static int patch_alc269(struct hda_codec *codec)
5291{
5292 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02005293 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005294
Takashi Iwai3de95172012-05-07 18:03:15 +02005295 err = alc_alloc_spec(codec, 0x0b);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005296 if (err < 0)
Takashi Iwai3de95172012-05-07 18:03:15 +02005297 return err;
5298
5299 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01005300 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005301
Takashi Iwai1727a772013-01-10 09:52:52 +01005302 snd_hda_pick_fixup(codec, alc269_fixup_models,
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03005303 alc269_fixup_tbl, alc269_fixups);
Hui Wange1918932014-05-26 16:22:44 +08005304 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01005305 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03005306
5307 alc_auto_parse_customize_define(codec);
5308
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005309 if (has_cdefine_beep(codec))
5310 spec->gen.beep_nid = 0x01;
5311
Kailang Yang065380f2013-01-10 10:25:48 +01005312 switch (codec->vendor_id) {
5313 case 0x10ec0269:
Takashi Iwai1d045db2011-07-07 18:23:21 +02005314 spec->codec_variant = ALC269_TYPE_ALC269VA;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005315 switch (alc_get_coef0(codec) & 0x00f0) {
5316 case 0x0010:
Takashi Iwai5100cd02014-02-15 10:03:19 +01005317 if (codec->bus->pci &&
5318 codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005319 spec->cdefine.platform_type == 1)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02005320 err = alc_codec_rename(codec, "ALC271X");
Takashi Iwai1d045db2011-07-07 18:23:21 +02005321 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005322 break;
5323 case 0x0020:
Takashi Iwai5100cd02014-02-15 10:03:19 +01005324 if (codec->bus->pci &&
5325 codec->bus->pci->subsystem_vendor == 0x17aa &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005326 codec->bus->pci->subsystem_device == 0x21f3)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02005327 err = alc_codec_rename(codec, "ALC3202");
Takashi Iwai1d045db2011-07-07 18:23:21 +02005328 spec->codec_variant = ALC269_TYPE_ALC269VC;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005329 break;
Kailang Yangadcc70b2012-05-25 08:08:38 +02005330 case 0x0030:
5331 spec->codec_variant = ALC269_TYPE_ALC269VD;
5332 break;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005333 default:
Takashi Iwai1d045db2011-07-07 18:23:21 +02005334 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005335 }
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005336 if (err < 0)
5337 goto error;
Takashi Iwai546bb672012-03-07 08:37:19 +01005338 spec->init_hook = alc269_fill_coef;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005339 alc269_fill_coef(codec);
Kailang Yang065380f2013-01-10 10:25:48 +01005340 break;
5341
5342 case 0x10ec0280:
5343 case 0x10ec0290:
5344 spec->codec_variant = ALC269_TYPE_ALC280;
5345 break;
5346 case 0x10ec0282:
Kailang Yang065380f2013-01-10 10:25:48 +01005347 spec->codec_variant = ALC269_TYPE_ALC282;
Kailang Yang7b5c7a02014-03-18 16:15:54 +08005348 spec->shutup = alc282_shutup;
5349 spec->init_hook = alc282_init;
Kailang Yang065380f2013-01-10 10:25:48 +01005350 break;
Kailang Yang2af02be2013-08-22 10:03:50 +02005351 case 0x10ec0233:
5352 case 0x10ec0283:
5353 spec->codec_variant = ALC269_TYPE_ALC283;
5354 spec->shutup = alc283_shutup;
5355 spec->init_hook = alc283_init;
5356 break;
Kailang Yang065380f2013-01-10 10:25:48 +01005357 case 0x10ec0284:
5358 case 0x10ec0292:
5359 spec->codec_variant = ALC269_TYPE_ALC284;
5360 break;
Kailang Yang161ebf22013-10-24 11:36:33 +02005361 case 0x10ec0285:
5362 case 0x10ec0293:
5363 spec->codec_variant = ALC269_TYPE_ALC285;
5364 break;
Kailang Yang7fc7d042013-04-25 11:04:43 +02005365 case 0x10ec0286:
Kailang Yang7c665932014-04-14 15:09:44 +08005366 case 0x10ec0288:
Kailang Yang7fc7d042013-04-25 11:04:43 +02005367 spec->codec_variant = ALC269_TYPE_ALC286;
5368 break;
Kailang Yang1d04c9d2013-10-24 11:35:18 +02005369 case 0x10ec0255:
5370 spec->codec_variant = ALC269_TYPE_ALC255;
5371 break;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005372 }
5373
Kailang Yangad60d502013-06-28 12:03:01 +02005374 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
Kailang Yang97a26572013-11-29 00:35:26 -05005375 spec->has_alc5505_dsp = 1;
Kailang Yangad60d502013-06-28 12:03:01 +02005376 spec->init_hook = alc5505_dsp_init;
5377 }
5378
Takashi Iwaia4297b52011-08-23 18:40:12 +02005379 /* automatic parse from the BIOS config */
5380 err = alc269_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005381 if (err < 0)
5382 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005383
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005384 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02005385 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5386
Takashi Iwai1d045db2011-07-07 18:23:21 +02005387 codec->patch_ops = alc_patch_ops;
Takashi Iwai2a439522011-07-26 09:52:50 +02005388#ifdef CONFIG_PM
Kailang Yangad60d502013-06-28 12:03:01 +02005389 codec->patch_ops.suspend = alc269_suspend;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005390 codec->patch_ops.resume = alc269_resume;
5391#endif
Kailang Yangc5177c82013-07-24 14:39:49 +02005392 if (!spec->shutup)
5393 spec->shutup = alc269_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005394
Takashi Iwai1727a772013-01-10 09:52:52 +01005395 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005396
Takashi Iwai1d045db2011-07-07 18:23:21 +02005397 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005398
5399 error:
5400 alc_free(codec);
5401 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005402}
5403
5404/*
5405 * ALC861
5406 */
5407
Takashi Iwai1d045db2011-07-07 18:23:21 +02005408static int alc861_parse_auto_config(struct hda_codec *codec)
5409{
Takashi Iwai1d045db2011-07-07 18:23:21 +02005410 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005411 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5412 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005413}
5414
Takashi Iwai1d045db2011-07-07 18:23:21 +02005415/* Pin config fixes */
5416enum {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005417 ALC861_FIXUP_FSC_AMILO_PI1505,
5418 ALC861_FIXUP_AMP_VREF_0F,
5419 ALC861_FIXUP_NO_JACK_DETECT,
5420 ALC861_FIXUP_ASUS_A6RP,
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005421 ALC660_FIXUP_ASUS_W7J,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005422};
5423
Takashi Iwai31150f22012-01-30 10:54:08 +01005424/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
5425static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005426 const struct hda_fixup *fix, int action)
Takashi Iwai31150f22012-01-30 10:54:08 +01005427{
5428 struct alc_spec *spec = codec->spec;
5429 unsigned int val;
5430
Takashi Iwai1727a772013-01-10 09:52:52 +01005431 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai31150f22012-01-30 10:54:08 +01005432 return;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01005433 val = snd_hda_codec_get_pin_target(codec, 0x0f);
Takashi Iwai31150f22012-01-30 10:54:08 +01005434 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
5435 val |= AC_PINCTL_IN_EN;
5436 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005437 snd_hda_set_pin_ctl(codec, 0x0f, val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01005438 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai31150f22012-01-30 10:54:08 +01005439}
5440
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005441/* suppress the jack-detection */
5442static void alc_fixup_no_jack_detect(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005443 const struct hda_fixup *fix, int action)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005444{
Takashi Iwai1727a772013-01-10 09:52:52 +01005445 if (action == HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005446 codec->no_jack_detect = 1;
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02005447}
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005448
Takashi Iwai1727a772013-01-10 09:52:52 +01005449static const struct hda_fixup alc861_fixups[] = {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005450 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005451 .type = HDA_FIXUP_PINS,
5452 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005453 { 0x0b, 0x0221101f }, /* HP */
5454 { 0x0f, 0x90170310 }, /* speaker */
5455 { }
5456 }
5457 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005458 [ALC861_FIXUP_AMP_VREF_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005459 .type = HDA_FIXUP_FUNC,
Takashi Iwai31150f22012-01-30 10:54:08 +01005460 .v.func = alc861_fixup_asus_amp_vref_0f,
Takashi Iwai3b25eb62012-01-25 09:55:46 +01005461 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005462 [ALC861_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005463 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005464 .v.func = alc_fixup_no_jack_detect,
5465 },
5466 [ALC861_FIXUP_ASUS_A6RP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005467 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005468 .v.func = alc861_fixup_asus_amp_vref_0f,
5469 .chained = true,
5470 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005471 },
5472 [ALC660_FIXUP_ASUS_W7J] = {
5473 .type = HDA_FIXUP_VERBS,
5474 .v.verbs = (const struct hda_verb[]) {
5475 /* ASUS W7J needs a magic pin setup on unused NID 0x10
5476 * for enabling outputs
5477 */
5478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5479 { }
5480 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005481 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02005482};
5483
5484static const struct snd_pci_quirk alc861_fixup_tbl[] = {
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005485 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
Takashi Iwaie7ca2372013-12-02 15:27:19 +01005486 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005487 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
5488 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
5489 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
5490 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
5491 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
5492 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005493 {}
5494};
5495
5496/*
5497 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005498static int patch_alc861(struct hda_codec *codec)
5499{
5500 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005501 int err;
5502
Takashi Iwai3de95172012-05-07 18:03:15 +02005503 err = alc_alloc_spec(codec, 0x15);
5504 if (err < 0)
5505 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005506
Takashi Iwai3de95172012-05-07 18:03:15 +02005507 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005508 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005509
Takashi Iwai1727a772013-01-10 09:52:52 +01005510 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5511 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005512
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005513 /* automatic parse from the BIOS config */
5514 err = alc861_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005515 if (err < 0)
5516 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005517
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005518 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005519 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005520
Takashi Iwai1d045db2011-07-07 18:23:21 +02005521 codec->patch_ops = alc_patch_ops;
Takashi Iwai83012a72012-08-24 18:38:08 +02005522#ifdef CONFIG_PM
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005523 spec->power_hook = alc_power_eapd;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005524#endif
5525
Takashi Iwai1727a772013-01-10 09:52:52 +01005526 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005527
Takashi Iwai1d045db2011-07-07 18:23:21 +02005528 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005529
5530 error:
5531 alc_free(codec);
5532 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005533}
5534
5535/*
5536 * ALC861-VD support
5537 *
5538 * Based on ALC882
5539 *
5540 * In addition, an independent DAC
5541 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005542static int alc861vd_parse_auto_config(struct hda_codec *codec)
5543{
Takashi Iwai1d045db2011-07-07 18:23:21 +02005544 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005545 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5546 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005547}
5548
Takashi Iwai1d045db2011-07-07 18:23:21 +02005549enum {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005550 ALC660VD_FIX_ASUS_GPIO1,
5551 ALC861VD_FIX_DALLAS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005552};
5553
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005554/* exclude VREF80 */
5555static void alc861vd_fixup_dallas(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005556 const struct hda_fixup *fix, int action)
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005557{
Takashi Iwai1727a772013-01-10 09:52:52 +01005558 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaib78562b2012-12-17 20:06:49 +01005559 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
5560 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005561 }
5562}
5563
Takashi Iwai1727a772013-01-10 09:52:52 +01005564static const struct hda_fixup alc861vd_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005565 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005566 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005567 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005568 /* reset GPIO1 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005569 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5570 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5571 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5572 { }
5573 }
5574 },
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005575 [ALC861VD_FIX_DALLAS] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005576 .type = HDA_FIXUP_FUNC,
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005577 .v.func = alc861vd_fixup_dallas,
5578 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02005579};
5580
5581static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005582 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005583 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005584 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005585 {}
5586};
5587
Takashi Iwai1d045db2011-07-07 18:23:21 +02005588/*
5589 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005590static int patch_alc861vd(struct hda_codec *codec)
5591{
5592 struct alc_spec *spec;
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005593 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005594
Takashi Iwai3de95172012-05-07 18:03:15 +02005595 err = alc_alloc_spec(codec, 0x0b);
5596 if (err < 0)
5597 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005598
Takashi Iwai3de95172012-05-07 18:03:15 +02005599 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005600 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005601
Takashi Iwai1727a772013-01-10 09:52:52 +01005602 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5603 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005604
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005605 /* automatic parse from the BIOS config */
5606 err = alc861vd_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005607 if (err < 0)
5608 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005609
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005610 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005611 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005612
Takashi Iwai1d045db2011-07-07 18:23:21 +02005613 codec->patch_ops = alc_patch_ops;
5614
Takashi Iwai1d045db2011-07-07 18:23:21 +02005615 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005616
Takashi Iwai1727a772013-01-10 09:52:52 +01005617 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005618
Takashi Iwai1d045db2011-07-07 18:23:21 +02005619 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005620
5621 error:
5622 alc_free(codec);
5623 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005624}
5625
5626/*
5627 * ALC662 support
5628 *
5629 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5630 * configuration. Each pin widget can choose any input DACs and a mixer.
5631 * Each ADC is connected from a mixer of all inputs. This makes possible
5632 * 6-channel independent captures.
5633 *
5634 * In addition, an independent DAC for the multi-playback (not used in this
5635 * driver yet).
5636 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005637
5638/*
5639 * BIOS auto configuration
5640 */
5641
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005642static int alc662_parse_auto_config(struct hda_codec *codec)
5643{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005644 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005645 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5646 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5647 const hda_nid_t *ssids;
Takashi Iwaiee979a142008-09-02 15:42:20 +02005648
Kailang Yang6227cdc2010-02-25 08:36:52 +01005649 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Rainer Koenig1d87caa2013-04-04 08:40:38 +02005650 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
5651 codec->vendor_id == 0x10ec0671)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005652 ssids = alc663_ssids;
Kailang Yang6227cdc2010-02-25 08:36:52 +01005653 else
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005654 ssids = alc662_ssids;
5655 return alc_parse_auto_config(codec, alc662_ignore, ssids);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005656}
5657
Todd Broch6be79482010-12-07 16:51:05 -08005658static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005659 const struct hda_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01005660{
Takashi Iwai9bb1f062013-01-10 17:14:29 +01005661 if (action != HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01005662 return;
Todd Broch6be79482010-12-07 16:51:05 -08005663 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5664 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5665 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5666 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5667 (0 << AC_AMPCAP_MUTE_SHIFT)))
Takashi Iwai4e76a882014-02-25 12:21:03 +01005668 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
Todd Broch6be79482010-12-07 16:51:05 -08005669}
5670
Takashi Iwai8e383952013-10-30 17:41:12 +01005671static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
5672 { .channels = 2,
5673 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
5674 { .channels = 4,
5675 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
5676 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
5677 { }
5678};
5679
5680/* override the 2.1 chmap */
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01005681static void alc_fixup_bass_chmap(struct hda_codec *codec,
Takashi Iwai8e383952013-10-30 17:41:12 +01005682 const struct hda_fixup *fix, int action)
5683{
5684 if (action == HDA_FIXUP_ACT_BUILD) {
5685 struct alc_spec *spec = codec->spec;
5686 spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps;
5687 }
5688}
5689
Takashi Iwai3e887f32014-01-10 17:50:58 +01005690/* turn on/off mute LED per vmaster hook */
5691static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
5692{
5693 struct hda_codec *codec = private_data;
5694 struct alc_spec *spec = codec->spec;
5695 unsigned int oldval = spec->gpio_led;
5696
5697 if (enabled)
5698 spec->gpio_led &= ~0x01;
5699 else
5700 spec->gpio_led |= 0x01;
5701 if (spec->gpio_led != oldval)
5702 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5703 spec->gpio_led);
5704}
5705
Takashi Iwaibf686652014-01-13 16:18:25 +01005706/* avoid D3 for keeping GPIO up */
5707static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5708 hda_nid_t nid,
5709 unsigned int power_state)
5710{
5711 struct alc_spec *spec = codec->spec;
5712 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5713 return AC_PWRST_D0;
5714 return power_state;
5715}
5716
Takashi Iwai3e887f32014-01-10 17:50:58 +01005717static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5718 const struct hda_fixup *fix, int action)
5719{
5720 struct alc_spec *spec = codec->spec;
5721 static const struct hda_verb gpio_init[] = {
5722 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
5723 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
5724 {}
5725 };
5726
5727 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5728 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
5729 spec->gpio_led = 0;
5730 snd_hda_add_verbs(codec, gpio_init);
Takashi Iwaibf686652014-01-13 16:18:25 +01005731 codec->power_filter = gpio_led_power_filter;
Takashi Iwai3e887f32014-01-10 17:50:58 +01005732 }
5733}
5734
David Henningsson6cb3b702010-09-09 08:51:44 +02005735enum {
Daniel T Chen2df03512010-10-10 22:39:28 -04005736 ALC662_FIXUP_ASPIRE,
Takashi Iwai3e887f32014-01-10 17:50:58 +01005737 ALC662_FIXUP_LED_GPIO1,
David Henningsson6cb3b702010-09-09 08:51:44 +02005738 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -08005739 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005740 ALC662_FIXUP_CZC_P10T,
David Henningsson94024cd2011-04-29 14:10:55 +02005741 ALC662_FIXUP_SKU_IGNORE,
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005742 ALC662_FIXUP_HP_RP5800,
Takashi Iwai53c334a2011-08-23 18:27:14 +02005743 ALC662_FIXUP_ASUS_MODE1,
5744 ALC662_FIXUP_ASUS_MODE2,
5745 ALC662_FIXUP_ASUS_MODE3,
5746 ALC662_FIXUP_ASUS_MODE4,
5747 ALC662_FIXUP_ASUS_MODE5,
5748 ALC662_FIXUP_ASUS_MODE6,
5749 ALC662_FIXUP_ASUS_MODE7,
5750 ALC662_FIXUP_ASUS_MODE8,
Takashi Iwai1565cc32012-02-13 12:03:25 +01005751 ALC662_FIXUP_NO_JACK_DETECT,
David Henningssonedfe3bf2012-06-12 13:15:12 +02005752 ALC662_FIXUP_ZOTAC_Z68,
Takashi Iwai125821a2012-06-22 14:30:29 +02005753 ALC662_FIXUP_INV_DMIC,
David Henningsson73bdd592013-04-15 15:44:14 +02005754 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
5755 ALC668_FIXUP_HEADSET_MODE,
David Henningsson8e54b4a2014-02-07 09:31:07 +01005756 ALC662_FIXUP_BASS_MODE4_CHMAP,
David Henningsson61a75f12014-02-07 09:31:08 +01005757 ALC662_FIXUP_BASS_16,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005758 ALC662_FIXUP_BASS_1A,
David Henningsson8e54b4a2014-02-07 09:31:07 +01005759 ALC662_FIXUP_BASS_CHMAP,
Hui Wang493a52a2014-01-14 14:07:36 +08005760 ALC668_FIXUP_AUTO_MUTE,
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02005761 ALC668_FIXUP_DELL_DISABLE_AAMIX,
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02005762 ALC668_FIXUP_DELL_XPS13,
David Henningsson6cb3b702010-09-09 08:51:44 +02005763};
5764
Takashi Iwai1727a772013-01-10 09:52:52 +01005765static const struct hda_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -04005766 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005767 .type = HDA_FIXUP_PINS,
5768 .v.pins = (const struct hda_pintbl[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -04005769 { 0x15, 0x99130112 }, /* subwoofer */
5770 { }
5771 }
5772 },
Takashi Iwai3e887f32014-01-10 17:50:58 +01005773 [ALC662_FIXUP_LED_GPIO1] = {
5774 .type = HDA_FIXUP_FUNC,
5775 .v.func = alc662_fixup_led_gpio1,
5776 },
David Henningsson6cb3b702010-09-09 08:51:44 +02005777 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005778 .type = HDA_FIXUP_PINS,
5779 .v.pins = (const struct hda_pintbl[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +02005780 { 0x17, 0x99130112 }, /* subwoofer */
5781 { }
Takashi Iwai3e887f32014-01-10 17:50:58 +01005782 },
5783 .chained = true,
5784 .chain_id = ALC662_FIXUP_LED_GPIO1,
David Henningsson6cb3b702010-09-09 08:51:44 +02005785 },
Todd Broch6be79482010-12-07 16:51:05 -08005786 [ALC272_FIXUP_MARIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005787 .type = HDA_FIXUP_FUNC,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01005788 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005789 },
5790 [ALC662_FIXUP_CZC_P10T] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005791 .type = HDA_FIXUP_VERBS,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005792 .v.verbs = (const struct hda_verb[]) {
5793 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5794 {}
5795 }
5796 },
David Henningsson94024cd2011-04-29 14:10:55 +02005797 [ALC662_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005798 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02005799 .v.func = alc_fixup_sku_ignore,
Takashi Iwaic6b35872011-03-28 12:05:31 +02005800 },
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005801 [ALC662_FIXUP_HP_RP5800] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005802 .type = HDA_FIXUP_PINS,
5803 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005804 { 0x14, 0x0221201f }, /* HP out */
5805 { }
5806 },
5807 .chained = true,
5808 .chain_id = ALC662_FIXUP_SKU_IGNORE
5809 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02005810 [ALC662_FIXUP_ASUS_MODE1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005811 .type = HDA_FIXUP_PINS,
5812 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005813 { 0x14, 0x99130110 }, /* speaker */
5814 { 0x18, 0x01a19c20 }, /* mic */
5815 { 0x19, 0x99a3092f }, /* int-mic */
5816 { 0x21, 0x0121401f }, /* HP out */
5817 { }
5818 },
5819 .chained = true,
5820 .chain_id = ALC662_FIXUP_SKU_IGNORE
5821 },
5822 [ALC662_FIXUP_ASUS_MODE2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005823 .type = HDA_FIXUP_PINS,
5824 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai2996bdb2011-08-18 16:02:24 +02005825 { 0x14, 0x99130110 }, /* speaker */
5826 { 0x18, 0x01a19820 }, /* mic */
5827 { 0x19, 0x99a3092f }, /* int-mic */
5828 { 0x1b, 0x0121401f }, /* HP out */
5829 { }
5830 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02005831 .chained = true,
5832 .chain_id = ALC662_FIXUP_SKU_IGNORE
5833 },
5834 [ALC662_FIXUP_ASUS_MODE3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005835 .type = HDA_FIXUP_PINS,
5836 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005837 { 0x14, 0x99130110 }, /* speaker */
5838 { 0x15, 0x0121441f }, /* HP */
5839 { 0x18, 0x01a19840 }, /* mic */
5840 { 0x19, 0x99a3094f }, /* int-mic */
5841 { 0x21, 0x01211420 }, /* HP2 */
5842 { }
5843 },
5844 .chained = true,
5845 .chain_id = ALC662_FIXUP_SKU_IGNORE
5846 },
5847 [ALC662_FIXUP_ASUS_MODE4] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005848 .type = HDA_FIXUP_PINS,
5849 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005850 { 0x14, 0x99130110 }, /* speaker */
5851 { 0x16, 0x99130111 }, /* speaker */
5852 { 0x18, 0x01a19840 }, /* mic */
5853 { 0x19, 0x99a3094f }, /* int-mic */
5854 { 0x21, 0x0121441f }, /* HP */
5855 { }
5856 },
5857 .chained = true,
5858 .chain_id = ALC662_FIXUP_SKU_IGNORE
5859 },
5860 [ALC662_FIXUP_ASUS_MODE5] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005861 .type = HDA_FIXUP_PINS,
5862 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005863 { 0x14, 0x99130110 }, /* speaker */
5864 { 0x15, 0x0121441f }, /* HP */
5865 { 0x16, 0x99130111 }, /* speaker */
5866 { 0x18, 0x01a19840 }, /* mic */
5867 { 0x19, 0x99a3094f }, /* int-mic */
5868 { }
5869 },
5870 .chained = true,
5871 .chain_id = ALC662_FIXUP_SKU_IGNORE
5872 },
5873 [ALC662_FIXUP_ASUS_MODE6] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005874 .type = HDA_FIXUP_PINS,
5875 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005876 { 0x14, 0x99130110 }, /* speaker */
5877 { 0x15, 0x01211420 }, /* HP2 */
5878 { 0x18, 0x01a19840 }, /* mic */
5879 { 0x19, 0x99a3094f }, /* int-mic */
5880 { 0x1b, 0x0121441f }, /* HP */
5881 { }
5882 },
5883 .chained = true,
5884 .chain_id = ALC662_FIXUP_SKU_IGNORE
5885 },
5886 [ALC662_FIXUP_ASUS_MODE7] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005887 .type = HDA_FIXUP_PINS,
5888 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005889 { 0x14, 0x99130110 }, /* speaker */
5890 { 0x17, 0x99130111 }, /* speaker */
5891 { 0x18, 0x01a19840 }, /* mic */
5892 { 0x19, 0x99a3094f }, /* int-mic */
5893 { 0x1b, 0x01214020 }, /* HP */
5894 { 0x21, 0x0121401f }, /* HP */
5895 { }
5896 },
5897 .chained = true,
5898 .chain_id = ALC662_FIXUP_SKU_IGNORE
5899 },
5900 [ALC662_FIXUP_ASUS_MODE8] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005901 .type = HDA_FIXUP_PINS,
5902 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005903 { 0x14, 0x99130110 }, /* speaker */
5904 { 0x12, 0x99a30970 }, /* int-mic */
5905 { 0x15, 0x01214020 }, /* HP */
5906 { 0x17, 0x99130111 }, /* speaker */
5907 { 0x18, 0x01a19840 }, /* mic */
5908 { 0x21, 0x0121401f }, /* HP */
5909 { }
5910 },
5911 .chained = true,
5912 .chain_id = ALC662_FIXUP_SKU_IGNORE
Takashi Iwai2996bdb2011-08-18 16:02:24 +02005913 },
Takashi Iwai1565cc32012-02-13 12:03:25 +01005914 [ALC662_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005915 .type = HDA_FIXUP_FUNC,
Takashi Iwai1565cc32012-02-13 12:03:25 +01005916 .v.func = alc_fixup_no_jack_detect,
5917 },
David Henningssonedfe3bf2012-06-12 13:15:12 +02005918 [ALC662_FIXUP_ZOTAC_Z68] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005919 .type = HDA_FIXUP_PINS,
5920 .v.pins = (const struct hda_pintbl[]) {
David Henningssonedfe3bf2012-06-12 13:15:12 +02005921 { 0x1b, 0x02214020 }, /* Front HP */
5922 { }
5923 }
5924 },
Takashi Iwai125821a2012-06-22 14:30:29 +02005925 [ALC662_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005926 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02005927 .v.func = alc_fixup_inv_dmic_0x12,
Takashi Iwai125821a2012-06-22 14:30:29 +02005928 },
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02005929 [ALC668_FIXUP_DELL_XPS13] = {
5930 .type = HDA_FIXUP_FUNC,
5931 .v.func = alc_fixup_dell_xps13,
5932 .chained = true,
5933 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
5934 },
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02005935 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
5936 .type = HDA_FIXUP_FUNC,
5937 .v.func = alc_fixup_disable_aamix,
5938 .chained = true,
5939 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5940 },
Hui Wang493a52a2014-01-14 14:07:36 +08005941 [ALC668_FIXUP_AUTO_MUTE] = {
5942 .type = HDA_FIXUP_FUNC,
5943 .v.func = alc_fixup_auto_mute_via_amp,
5944 .chained = true,
5945 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5946 },
David Henningsson73bdd592013-04-15 15:44:14 +02005947 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
5948 .type = HDA_FIXUP_PINS,
5949 .v.pins = (const struct hda_pintbl[]) {
5950 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
5951 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
5952 { }
5953 },
5954 .chained = true,
5955 .chain_id = ALC668_FIXUP_HEADSET_MODE
5956 },
5957 [ALC668_FIXUP_HEADSET_MODE] = {
5958 .type = HDA_FIXUP_FUNC,
5959 .v.func = alc_fixup_headset_mode_alc668,
5960 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01005961 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
Takashi Iwai8e383952013-10-30 17:41:12 +01005962 .type = HDA_FIXUP_FUNC,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01005963 .v.func = alc_fixup_bass_chmap,
Takashi Iwai8e383952013-10-30 17:41:12 +01005964 .chained = true,
5965 .chain_id = ALC662_FIXUP_ASUS_MODE4
5966 },
David Henningsson61a75f12014-02-07 09:31:08 +01005967 [ALC662_FIXUP_BASS_16] = {
5968 .type = HDA_FIXUP_PINS,
5969 .v.pins = (const struct hda_pintbl[]) {
5970 {0x16, 0x80106111}, /* bass speaker */
5971 {}
5972 },
5973 .chained = true,
5974 .chain_id = ALC662_FIXUP_BASS_CHMAP,
5975 },
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005976 [ALC662_FIXUP_BASS_1A] = {
5977 .type = HDA_FIXUP_PINS,
5978 .v.pins = (const struct hda_pintbl[]) {
5979 {0x1a, 0x80106111}, /* bass speaker */
5980 {}
5981 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01005982 .chained = true,
5983 .chain_id = ALC662_FIXUP_BASS_CHMAP,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005984 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01005985 [ALC662_FIXUP_BASS_CHMAP] = {
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005986 .type = HDA_FIXUP_FUNC,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01005987 .v.func = alc_fixup_bass_chmap,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005988 },
David Henningsson6cb3b702010-09-09 08:51:44 +02005989};
5990
Takashi Iwaia9111322011-05-02 11:30:18 +02005991static const struct snd_pci_quirk alc662_fixup_tbl[] = {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005992 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
Takashi Iwaid3d38352013-08-19 20:05:50 +02005993 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
David Henningssona6c47a82011-02-10 15:39:19 +01005994 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
David Henningsson94024cd2011-04-29 14:10:55 +02005995 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
Takashi Iwai125821a2012-06-22 14:30:29 +02005996 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
Takashi Iwai18019282013-08-16 08:17:05 +02005997 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
Daniel T Chen2df03512010-10-10 22:39:28 -04005998 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
David Henningsson73bdd592013-04-15 15:44:14 +02005999 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6000 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02006001 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
David Henningsson09d20142013-11-20 11:43:30 +01006002 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
David Henningssonad8ff99e2013-11-07 09:28:59 +01006003 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Kailang Yang8dc9abb2014-04-16 15:53:12 +08006004 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6005 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02006006 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
David Henningsson8e54b4a2014-02-07 09:31:07 +01006007 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
6008 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
David Henningsson61a75f12014-02-07 09:31:08 +01006009 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
6010 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
David Henningsson8e54b4a2014-02-07 09:31:07 +01006011 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
Takashi Iwai1565cc32012-02-13 12:03:25 +01006012 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
Takashi Iwai53c334a2011-08-23 18:27:14 +02006013 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
Daniel T Chena0e90ac2010-11-20 10:20:35 -05006014 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +06006015 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +02006016 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
David Henningssonedfe3bf2012-06-12 13:15:12 +02006017 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
Anisse Astierd2ebd472011-01-20 12:36:21 +01006018 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
Takashi Iwai53c334a2011-08-23 18:27:14 +02006019
6020#if 0
6021 /* Below is a quirk table taken from the old code.
6022 * Basically the device should work as is without the fixup table.
6023 * If BIOS doesn't give a proper info, enable the corresponding
6024 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02006025 */
Takashi Iwai53c334a2011-08-23 18:27:14 +02006026 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6027 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6028 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6029 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6030 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6031 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6032 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6033 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6034 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6035 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6036 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6037 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6038 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6039 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6040 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6041 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6042 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6043 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6044 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6045 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6046 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6047 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6048 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6049 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6050 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6051 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6052 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6053 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6054 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6055 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6056 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6057 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6058 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6059 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6060 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6061 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6062 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6063 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6064 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6065 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6066 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6067 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6068 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6069 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6070 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6071 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6072 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6073 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6074 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6075 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6076#endif
David Henningsson6cb3b702010-09-09 08:51:44 +02006077 {}
6078};
6079
Takashi Iwai1727a772013-01-10 09:52:52 +01006080static const struct hda_model_fixup alc662_fixup_models[] = {
Todd Broch6be79482010-12-07 16:51:05 -08006081 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
Takashi Iwai53c334a2011-08-23 18:27:14 +02006082 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6083 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6084 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6085 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6086 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6087 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6088 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6089 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02006090 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningssone32aa852013-06-17 11:04:02 +02006091 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
Todd Broch6be79482010-12-07 16:51:05 -08006092 {}
6093};
David Henningsson6cb3b702010-09-09 08:51:44 +02006094
Hui Wang532895c2014-05-29 15:59:19 +08006095static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
David Henningsson76c21322014-06-24 14:46:54 +02006096 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6097 {0x12, 0x99a30130},
6098 {0x14, 0x90170110},
6099 {0x15, 0x0321101f},
6100 {0x16, 0x03011020},
6101 {0x18, 0x40000008},
6102 {0x19, 0x411111f0},
6103 {0x1a, 0x411111f0},
6104 {0x1b, 0x411111f0},
6105 {0x1d, 0x41000001},
6106 {0x1e, 0x411111f0},
6107 {0x1f, 0x411111f0}),
6108 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6109 {0x12, 0x99a30140},
6110 {0x14, 0x90170110},
6111 {0x15, 0x0321101f},
6112 {0x16, 0x03011020},
6113 {0x18, 0x40000008},
6114 {0x19, 0x411111f0},
6115 {0x1a, 0x411111f0},
6116 {0x1b, 0x411111f0},
6117 {0x1d, 0x41000001},
6118 {0x1e, 0x411111f0},
6119 {0x1f, 0x411111f0}),
6120 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6121 {0x12, 0x99a30150},
6122 {0x14, 0x90170110},
6123 {0x15, 0x0321101f},
6124 {0x16, 0x03011020},
6125 {0x18, 0x40000008},
6126 {0x19, 0x411111f0},
6127 {0x1a, 0x411111f0},
6128 {0x1b, 0x411111f0},
6129 {0x1d, 0x41000001},
6130 {0x1e, 0x411111f0},
6131 {0x1f, 0x411111f0}),
6132 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6133 {0x12, 0x411111f0},
6134 {0x14, 0x90170110},
6135 {0x15, 0x0321101f},
6136 {0x16, 0x03011020},
6137 {0x18, 0x40000008},
6138 {0x19, 0x411111f0},
6139 {0x1a, 0x411111f0},
6140 {0x1b, 0x411111f0},
6141 {0x1d, 0x41000001},
6142 {0x1e, 0x411111f0},
6143 {0x1f, 0x411111f0}),
6144 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
6145 {0x12, 0x90a60130},
6146 {0x14, 0x90170110},
6147 {0x15, 0x0321101f},
6148 {0x16, 0x40000000},
6149 {0x18, 0x411111f0},
6150 {0x19, 0x411111f0},
6151 {0x1a, 0x411111f0},
6152 {0x1b, 0x411111f0},
6153 {0x1d, 0x40d6832d},
6154 {0x1e, 0x411111f0},
6155 {0x1f, 0x411111f0}),
Hui Wang532895c2014-05-29 15:59:19 +08006156 {}
6157};
6158
Kailang Yang8663ff72012-06-29 09:35:52 +02006159static void alc662_fill_coef(struct hda_codec *codec)
6160{
6161 int val, coef;
6162
6163 coef = alc_get_coef0(codec);
6164
6165 switch (codec->vendor_id) {
6166 case 0x10ec0662:
6167 if ((coef & 0x00f0) == 0x0030) {
6168 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
6169 alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
6170 }
6171 break;
6172 case 0x10ec0272:
6173 case 0x10ec0273:
6174 case 0x10ec0663:
6175 case 0x10ec0665:
6176 case 0x10ec0670:
6177 case 0x10ec0671:
6178 case 0x10ec0672:
6179 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
6180 alc_write_coef_idx(codec, 0xd, val | (1<<14));
6181 break;
6182 }
6183}
David Henningsson6cb3b702010-09-09 08:51:44 +02006184
Takashi Iwai1d045db2011-07-07 18:23:21 +02006185/*
6186 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006187static int patch_alc662(struct hda_codec *codec)
6188{
6189 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02006190 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006191
Takashi Iwai3de95172012-05-07 18:03:15 +02006192 err = alc_alloc_spec(codec, 0x0b);
6193 if (err < 0)
6194 return err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006195
Takashi Iwai3de95172012-05-07 18:03:15 +02006196 spec = codec->spec;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006197
Takashi Iwai53c334a2011-08-23 18:27:14 +02006198 /* handle multiple HPs as is */
6199 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6200
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02006201 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6202
Kailang Yang8663ff72012-06-29 09:35:52 +02006203 spec->init_hook = alc662_fill_coef;
6204 alc662_fill_coef(codec);
6205
Takashi Iwai1727a772013-01-10 09:52:52 +01006206 snd_hda_pick_fixup(codec, alc662_fixup_models,
Takashi Iwai8e5a0502012-06-21 15:49:33 +02006207 alc662_fixup_tbl, alc662_fixups);
Hui Wang532895c2014-05-29 15:59:19 +08006208 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01006209 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai8e5a0502012-06-21 15:49:33 +02006210
6211 alc_auto_parse_customize_define(codec);
6212
Takashi Iwai7504b6c2013-03-18 11:25:51 +01006213 if (has_cdefine_beep(codec))
6214 spec->gen.beep_nid = 0x01;
6215
Takashi Iwai1bb7e432011-10-17 16:50:59 +02006216 if ((alc_get_coef0(codec) & (1 << 14)) &&
Takashi Iwai5100cd02014-02-15 10:03:19 +01006217 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006218 spec->cdefine.platform_type == 1) {
Wei Yongjun6134b1a2013-04-18 11:12:59 +08006219 err = alc_codec_rename(codec, "ALC272X");
6220 if (err < 0)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006221 goto error;
Takashi Iwai20ca0c32011-10-17 16:00:35 +02006222 }
Kailang Yang274693f2009-12-03 10:07:50 +01006223
Takashi Iwaib9c51062011-08-24 18:08:07 +02006224 /* automatic parse from the BIOS config */
6225 err = alc662_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006226 if (err < 0)
6227 goto error;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006228
Takashi Iwai7504b6c2013-03-18 11:25:51 +01006229 if (!spec->gen.no_analog && spec->gen.beep_nid) {
Kailang Yangda00c242010-03-19 11:23:45 +01006230 switch (codec->vendor_id) {
6231 case 0x10ec0662:
6232 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6233 break;
6234 case 0x10ec0272:
6235 case 0x10ec0663:
6236 case 0x10ec0665:
Kailang Yang9ad54542013-11-26 15:41:40 +08006237 case 0x10ec0668:
Kailang Yangda00c242010-03-19 11:23:45 +01006238 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6239 break;
6240 case 0x10ec0273:
6241 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6242 break;
6243 }
Kailang Yangcec27c82010-02-04 14:18:18 +01006244 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01006245
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006246 codec->patch_ops = alc_patch_ops;
Takashi Iwai1c7161532011-04-07 10:37:16 +02006247 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +02006248
Takashi Iwai1727a772013-01-10 09:52:52 +01006249 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01006250
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006251 return 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006252
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006253 error:
6254 alc_free(codec);
6255 return err;
Kailang Yangb478b992011-05-18 11:51:15 +02006256}
6257
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006258/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006259 * ALC680 support
6260 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006261
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006262static int alc680_parse_auto_config(struct hda_codec *codec)
6263{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02006264 return alc_parse_auto_config(codec, NULL, NULL);
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006265}
6266
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006267/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006268 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006269static int patch_alc680(struct hda_codec *codec)
6270{
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006271 int err;
6272
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006273 /* ALC680 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02006274 err = alc_alloc_spec(codec, 0);
6275 if (err < 0)
6276 return err;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006277
Takashi Iwai1ebec5f2011-08-15 13:21:48 +02006278 /* automatic parse from the BIOS config */
6279 err = alc680_parse_auto_config(codec);
6280 if (err < 0) {
6281 alc_free(codec);
6282 return err;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006283 }
6284
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006285 codec->patch_ops = alc_patch_ops;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006286
6287 return 0;
6288}
6289
6290/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006291 * patch entries
6292 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006293static const struct hda_codec_preset snd_hda_preset_realtek[] = {
Kailang Yang296f0332011-05-18 11:52:36 +02006294 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
Kailang Yangba4c4d02013-11-26 15:17:50 +08006295 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
Kailang Yang84dfd0a2013-03-07 09:19:38 +01006296 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
Kailang Yang92f974d2014-06-06 17:05:33 +08006297 { .id = 0x10ec0235, .name = "ALC233", .patch = patch_alc269 },
Kailang Yang1d04c9d2013-10-24 11:35:18 +02006298 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006299 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006300 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +01006301 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +02006302 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +01006303 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01006304 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +02006305 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01006306 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Kailang Yang296f0332011-05-18 11:52:36 +02006307 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
David Henningssonbefae822012-06-25 19:49:28 +02006308 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
David Henningsson4e01ec62012-07-18 07:38:46 +02006309 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02006310 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
Kailang Yang065380f2013-01-10 10:25:48 +01006311 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
Kailang Yang161ebf22013-10-24 11:36:33 +02006312 { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
Kailang Yang7fc7d042013-04-25 11:04:43 +02006313 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
Kailang Yang7c665932014-04-14 15:09:44 +08006314 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02006315 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
David Henningssonaf02dde2012-11-21 08:57:58 +01006316 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
Kailang Yang161ebf22013-10-24 11:36:33 +02006317 { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006318 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006319 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006320 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6321 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6322 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006323 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006324 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006325 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6326 .patch = patch_alc662 },
David Henningssoncc667a72011-10-18 14:07:51 +02006327 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6328 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +02006329 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +01006330 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang72009432014-06-06 16:51:18 +08006331 { .id = 0x10ec0667, .name = "ALC667", .patch = patch_alc662 },
Kailang Yang19a62822012-11-08 10:25:37 +01006332 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +01006333 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Rainer Koenig1d87caa2013-04-04 08:40:38 +02006334 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006335 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Kailang Yangb6c5fba2014-06-05 11:13:44 +08006336 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006337 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006338 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006339 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +02006340 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006341 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +02006342 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006343 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006345 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +02006346 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006347 .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006348 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006349 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +01006350 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006351 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
Kailang Yang19a62822012-11-08 10:25:37 +01006352 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006353 {} /* terminator */
6354};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006355
6356MODULE_ALIAS("snd-hda-codec-id:10ec*");
6357
6358MODULE_LICENSE("GPL");
6359MODULE_DESCRIPTION("Realtek HD-audio codec");
6360
6361static struct hda_codec_preset_list realtek_list = {
6362 .preset = snd_hda_preset_realtek,
6363 .owner = THIS_MODULE,
6364};
6365
6366static int __init patch_realtek_init(void)
6367{
6368 return snd_hda_add_codec_preset(&realtek_list);
6369}
6370
6371static void __exit patch_realtek_exit(void)
6372{
6373 snd_hda_delete_codec_preset(&realtek_list);
6374}
6375
6376module_init(patch_realtek_init)
6377module_exit(patch_realtek_exit)