blob: edb0fe1b8f1b248d518ff22a34c731a02f809335 [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 Iwaif2a227c2014-08-18 13:35:22 +0200132 * COEF access helper functions
133 */
134
135static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
136 unsigned int coef_idx)
137{
138 unsigned int val;
139
140 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
141 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
142 return val;
143}
144
145#define alc_read_coef_idx(codec, coef_idx) \
146 alc_read_coefex_idx(codec, 0x20, coef_idx)
147
148static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
149 unsigned int coef_idx, unsigned int coef_val)
150{
151 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
152 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
153}
154
155#define alc_write_coef_idx(codec, coef_idx, coef_val) \
156 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
157
Takashi Iwai98b24882014-08-18 13:47:50 +0200158static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
159 unsigned int coef_idx, unsigned int mask,
160 unsigned int bits_set)
161{
162 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
163
164 if (val != -1)
165 alc_write_coefex_idx(codec, nid, coef_idx,
166 (val & ~mask) | bits_set);
167}
168
169#define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
170 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
171
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200172/* a special bypass for COEF 0; read the cached value at the second time */
173static unsigned int alc_get_coef0(struct hda_codec *codec)
174{
175 struct alc_spec *spec = codec->spec;
176
177 if (!spec->coef0)
178 spec->coef0 = alc_read_coef_idx(codec, 0);
179 return spec->coef0;
180}
181
Takashi Iwai54db6c32014-08-18 15:11:19 +0200182/* coef writes/updates batch */
183struct coef_fw {
184 unsigned char nid;
185 unsigned char idx;
186 unsigned short mask;
187 unsigned short val;
188};
189
190#define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
191 { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
192#define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
193#define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
194#define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
195
196static void alc_process_coef_fw(struct hda_codec *codec,
197 const struct coef_fw *fw)
198{
199 for (; fw->nid; fw++) {
200 if (fw->mask == (unsigned short)-1)
201 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
202 else
203 alc_update_coefex_idx(codec, fw->nid, fw->idx,
204 fw->mask, fw->val);
205 }
206}
207
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200208/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200209 * Append the given mixer and verb elements for the later use
210 * The mixer array is referred in build_controls(), and init_verbs are
211 * called in init().
Takashi Iwaid88897e2008-10-31 15:01:37 +0100212 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200213static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100214{
215 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
216 return;
217 spec->mixers[spec->num_mixers++] = mix;
218}
219
Takashi Iwaid88897e2008-10-31 15:01:37 +0100220/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200221 * GPIO setup tables, used in initialization
Kailang Yangdf694da2005-12-05 19:42:22 +0100222 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200223/* Enable GPIO mask and set output */
Takashi Iwaia9111322011-05-02 11:30:18 +0200224static const struct hda_verb alc_gpio1_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200225 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
226 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
227 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
228 { }
229};
230
Takashi Iwaia9111322011-05-02 11:30:18 +0200231static const struct hda_verb alc_gpio2_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200232 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
233 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
234 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
235 { }
236};
237
Takashi Iwaia9111322011-05-02 11:30:18 +0200238static const struct hda_verb alc_gpio3_init_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +0200239 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
240 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
241 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
242 { }
243};
244
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200245/*
246 * Fix hardware PLL issue
247 * On some codecs, the analog PLL gating control must be off while
248 * the default value is 1.
249 */
250static void alc_fix_pll(struct hda_codec *codec)
251{
252 struct alc_spec *spec = codec->spec;
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200253
Takashi Iwai98b24882014-08-18 13:47:50 +0200254 if (spec->pll_nid)
255 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
256 1 << spec->pll_coef_bit, 0);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200257}
258
259static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
260 unsigned int coef_idx, unsigned int coef_bit)
261{
262 struct alc_spec *spec = codec->spec;
263 spec->pll_nid = nid;
264 spec->pll_coef_idx = coef_idx;
265 spec->pll_coef_bit = coef_bit;
266 alc_fix_pll(codec);
267}
268
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100269/* update the master volume per volume-knob's unsol event */
David Henningsson29adc4b2012-09-25 11:31:00 +0200270static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100271{
272 unsigned int val;
273 struct snd_kcontrol *kctl;
274 struct snd_ctl_elem_value *uctl;
275
276 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
277 if (!kctl)
278 return;
279 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
280 if (!uctl)
281 return;
David Henningsson29adc4b2012-09-25 11:31:00 +0200282 val = snd_hda_codec_read(codec, jack->nid, 0,
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100283 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
284 val &= HDA_AMP_VOLMASK;
285 uctl->value.integer.value[0] = val;
286 uctl->value.integer.value[1] = val;
287 kctl->put(kctl, uctl);
288 kfree(uctl);
289}
290
David Henningsson29adc4b2012-09-25 11:31:00 +0200291static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100292{
David Henningsson29adc4b2012-09-25 11:31:00 +0200293 /* For some reason, the res given from ALC880 is broken.
294 Here we adjust it properly. */
295 snd_hda_jack_unsol_event(codec, res >> 2);
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100296}
297
Kailang Yangf9423e72008-05-27 12:32:25 +0200298/* additional initialization for ALC888 variants */
299static void alc888_coef_init(struct hda_codec *codec)
300{
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200301 if (alc_get_coef0(codec) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +0200302 /* alc888S-VC */
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200303 alc_write_coef_idx(codec, 7, 0x830);
Kailang Yangf9423e72008-05-27 12:32:25 +0200304 else
305 /* alc888-VB */
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200306 alc_write_coef_idx(codec, 7, 0x3030);
Kailang Yangf9423e72008-05-27 12:32:25 +0200307}
308
Takashi Iwai1d045db2011-07-07 18:23:21 +0200309/* additional initialization for ALC889 variants */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200310static void alc889_coef_init(struct hda_codec *codec)
311{
Takashi Iwai98b24882014-08-18 13:47:50 +0200312 alc_update_coef_idx(codec, 7, 0, 0x2010);
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200313}
314
Takashi Iwai3fb4a502010-01-19 15:46:37 +0100315/* turn on/off EAPD control (only if available) */
316static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
317{
318 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
319 return;
320 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
321 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
322 on ? 2 : 0);
323}
324
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200325/* turn on/off EAPD controls of the codec */
326static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
327{
328 /* We currently only handle front, HP */
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200329 static hda_nid_t pins[] = {
330 0x0f, 0x10, 0x14, 0x15, 0
331 };
332 hda_nid_t *p;
333 for (p = pins; *p; p++)
334 set_eapd(codec, *p, on);
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200335}
336
Takashi Iwai1c7161532011-04-07 10:37:16 +0200337/* generic shutup callback;
338 * just turning off EPAD and a little pause for avoiding pop-noise
339 */
340static void alc_eapd_shutup(struct hda_codec *codec)
341{
Kailang Yang97a26572013-11-29 00:35:26 -0500342 struct alc_spec *spec = codec->spec;
343
Takashi Iwai1c7161532011-04-07 10:37:16 +0200344 alc_auto_setup_eapd(codec, false);
Kailang Yang97a26572013-11-29 00:35:26 -0500345 if (!spec->no_depop_delay)
346 msleep(200);
Takashi Iwai9bfb2842013-07-24 14:31:50 +0200347 snd_hda_shutup_pins(codec);
Takashi Iwai1c7161532011-04-07 10:37:16 +0200348}
349
Takashi Iwai1d045db2011-07-07 18:23:21 +0200350/* generic EAPD initialization */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200351static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200352{
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200353 alc_auto_setup_eapd(codec, true);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200354 switch (type) {
355 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200356 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
357 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200358 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200359 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
360 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200361 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200362 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
363 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200364 case ALC_INIT_DEFAULT:
Kailang Yangc9b58002007-10-16 14:30:01 +0200365 switch (codec->vendor_id) {
366 case 0x10ec0260:
Takashi Iwai98b24882014-08-18 13:47:50 +0200367 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
Kailang Yangc9b58002007-10-16 14:30:01 +0200368 break;
369 case 0x10ec0262:
370 case 0x10ec0880:
371 case 0x10ec0882:
372 case 0x10ec0883:
373 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +0100374 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +0100375 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200376 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200377 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200378 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200379 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +0200380 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +0100381#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +0200382 case 0x10ec0267:
383 case 0x10ec0268:
Takashi Iwai98b24882014-08-18 13:47:50 +0200384 alc_update_coef_idx(codec, 7, 0, 0x3000);
Kailang Yangc9b58002007-10-16 14:30:01 +0200385 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +0100386#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200387 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200388 break;
389 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200390}
Kailang Yangea1fb292008-08-26 12:58:38 +0200391
Takashi Iwai1d045db2011-07-07 18:23:21 +0200392
393/*
394 * Realtek SSID verification
395 */
396
David Henningsson90622912010-10-14 14:50:18 +0200397/* Could be any non-zero and even value. When used as fixup, tells
398 * the driver to ignore any present sku defines.
399 */
400#define ALC_FIXUP_SKU_IGNORE (2)
401
Takashi Iwai23d30f22012-05-07 17:17:32 +0200402static void alc_fixup_sku_ignore(struct hda_codec *codec,
403 const struct hda_fixup *fix, int action)
404{
405 struct alc_spec *spec = codec->spec;
406 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
407 spec->cdefine.fixup = 1;
408 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
409 }
410}
411
Mengdong Linb5c66112013-11-29 00:35:35 -0500412static void alc_fixup_no_depop_delay(struct hda_codec *codec,
413 const struct hda_fixup *fix, int action)
414{
415 struct alc_spec *spec = codec->spec;
416
Mengdong Lin84d2dc32013-12-02 22:26:03 -0500417 if (action == HDA_FIXUP_ACT_PROBE) {
Mengdong Linb5c66112013-11-29 00:35:35 -0500418 spec->no_depop_delay = 1;
Mengdong Lin84d2dc32013-12-02 22:26:03 -0500419 codec->depop_delay = 0;
420 }
Mengdong Linb5c66112013-11-29 00:35:35 -0500421}
422
Kailang Yangda00c242010-03-19 11:23:45 +0100423static int alc_auto_parse_customize_define(struct hda_codec *codec)
424{
425 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +0100426 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +0100427 struct alc_spec *spec = codec->spec;
428
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200429 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
430
David Henningsson90622912010-10-14 14:50:18 +0200431 if (spec->cdefine.fixup) {
432 ass = spec->cdefine.sku_cfg;
433 if (ass == ALC_FIXUP_SKU_IGNORE)
434 return -1;
435 goto do_sku;
436 }
437
Takashi Iwai5100cd02014-02-15 10:03:19 +0100438 if (!codec->bus->pci)
439 return -1;
Kailang Yangda00c242010-03-19 11:23:45 +0100440 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200441 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +0100442 goto do_sku;
443
444 nid = 0x1d;
445 if (codec->vendor_id == 0x10ec0260)
446 nid = 0x17;
447 ass = snd_hda_codec_get_pincfg(codec, nid);
448
449 if (!(ass & 1)) {
Takashi Iwai4e76a882014-02-25 12:21:03 +0100450 codec_info(codec, "%s: SKU not ready 0x%08x\n",
451 codec->chip_name, ass);
Kailang Yangda00c242010-03-19 11:23:45 +0100452 return -1;
453 }
454
455 /* check sum */
456 tmp = 0;
457 for (i = 1; i < 16; i++) {
458 if ((ass >> i) & 1)
459 tmp++;
460 }
461 if (((ass >> 16) & 0xf) != tmp)
462 return -1;
463
464 spec->cdefine.port_connectivity = ass >> 30;
465 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
466 spec->cdefine.check_sum = (ass >> 16) & 0xf;
467 spec->cdefine.customization = ass >> 8;
468do_sku:
469 spec->cdefine.sku_cfg = ass;
470 spec->cdefine.external_amp = (ass & 0x38) >> 3;
471 spec->cdefine.platform_type = (ass & 0x4) >> 2;
472 spec->cdefine.swap = (ass & 0x2) >> 1;
473 spec->cdefine.override = ass & 0x1;
474
Takashi Iwai4e76a882014-02-25 12:21:03 +0100475 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
Kailang Yangda00c242010-03-19 11:23:45 +0100476 nid, spec->cdefine.sku_cfg);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100477 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
Kailang Yangda00c242010-03-19 11:23:45 +0100478 spec->cdefine.port_connectivity);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100479 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
480 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
481 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
482 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
483 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
484 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
485 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
Kailang Yangda00c242010-03-19 11:23:45 +0100486
487 return 0;
488}
489
Takashi Iwai08c189f2012-12-19 15:22:24 +0100490/* return the position of NID in the list, or -1 if not found */
491static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
492{
493 int i;
494 for (i = 0; i < nums; i++)
495 if (list[i] == nid)
496 return i;
497 return -1;
498}
Takashi Iwai1d045db2011-07-07 18:23:21 +0200499/* return true if the given NID is found in the list */
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200500static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
501{
Takashi Iwai21268962011-07-07 15:01:13 +0200502 return find_idx_in_nid_list(nid, list, nums) >= 0;
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200503}
504
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200505/* check subsystem ID and set up device-specific initialization;
506 * return 1 if initialized, 0 if invalid SSID
507 */
508/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
509 * 31 ~ 16 : Manufacture ID
510 * 15 ~ 8 : SKU ID
511 * 7 ~ 0 : Assembly ID
512 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
513 */
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100514static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200515{
516 unsigned int ass, tmp, i;
517 unsigned nid;
518 struct alc_spec *spec = codec->spec;
519
David Henningsson90622912010-10-14 14:50:18 +0200520 if (spec->cdefine.fixup) {
521 ass = spec->cdefine.sku_cfg;
522 if (ass == ALC_FIXUP_SKU_IGNORE)
523 return 0;
524 goto do_sku;
525 }
526
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200527 ass = codec->subsystem_id & 0xffff;
Takashi Iwai5100cd02014-02-15 10:03:19 +0100528 if (codec->bus->pci &&
529 ass != codec->bus->pci->subsystem_device && (ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200530 goto do_sku;
531
532 /* invalid SSID, check the special NID pin defcfg instead */
533 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400534 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200535 * 29~21 : reserve
536 * 20 : PCBEEP input
537 * 19~16 : Check sum (15:1)
538 * 15~1 : Custom
539 * 0 : override
540 */
541 nid = 0x1d;
542 if (codec->vendor_id == 0x10ec0260)
543 nid = 0x17;
544 ass = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100545 codec_dbg(codec,
546 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +0200547 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +0100548 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200549 return 0;
550 if ((ass >> 30) != 1) /* no physical connection */
551 return 0;
552
553 /* check sum */
554 tmp = 0;
555 for (i = 1; i < 16; i++) {
556 if ((ass >> i) & 1)
557 tmp++;
558 }
559 if (((ass >> 16) & 0xf) != tmp)
560 return 0;
561do_sku:
Takashi Iwai4e76a882014-02-25 12:21:03 +0100562 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200563 ass & 0xffff, codec->vendor_id);
564 /*
565 * 0 : override
566 * 1 : Swap Jack
567 * 2 : 0 --> Desktop, 1 --> Laptop
568 * 3~5 : External Amplifier control
569 * 7~6 : Reserved
570 */
571 tmp = (ass & 0x38) >> 3; /* external Amp control */
572 switch (tmp) {
573 case 1:
574 spec->init_amp = ALC_INIT_GPIO1;
575 break;
576 case 3:
577 spec->init_amp = ALC_INIT_GPIO2;
578 break;
579 case 7:
580 spec->init_amp = ALC_INIT_GPIO3;
581 break;
582 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +0100583 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200584 spec->init_amp = ALC_INIT_DEFAULT;
585 break;
586 }
587
588 /* is laptop or Desktop and enable the function "Mute internal speaker
589 * when the external headphone out jack is plugged"
590 */
591 if (!(ass & 0x8000))
592 return 1;
593 /*
594 * 10~8 : Jack location
595 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
596 * 14~13: Resvered
597 * 15 : 1 --> enable the function "Mute internal speaker
598 * when the external headphone out jack is plugged"
599 */
Takashi Iwai08c189f2012-12-19 15:22:24 +0100600 if (!spec->gen.autocfg.hp_pins[0] &&
601 !(spec->gen.autocfg.line_out_pins[0] &&
602 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
Takashi Iwai01d48252009-10-06 13:21:54 +0200603 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200604 tmp = (ass >> 11) & 0x3; /* HP to chassis */
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100605 nid = ports[tmp];
Takashi Iwai08c189f2012-12-19 15:22:24 +0100606 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
607 spec->gen.autocfg.line_outs))
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200608 return 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100609 spec->gen.autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200610 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200611 return 1;
612}
Kailang Yangea1fb292008-08-26 12:58:38 +0200613
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200614/* Check the validity of ALC subsystem-id
615 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
616static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200617{
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100618 if (!alc_subsystem_id(codec, ports)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200619 struct alc_spec *spec = codec->spec;
Takashi Iwai4e76a882014-02-25 12:21:03 +0100620 codec_dbg(codec,
621 "realtek: Enable default setup for auto mode as fallback\n");
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200622 spec->init_amp = ALC_INIT_DEFAULT;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200623 }
Takashi Iwai21268962011-07-07 15:01:13 +0200624}
Takashi Iwai1a1455d2011-04-28 17:36:18 +0200625
Takashi Iwai41e41f12005-06-08 14:48:49 +0200626/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200627 */
628
Takashi Iwai08c189f2012-12-19 15:22:24 +0100629static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
Takashi Iwai757899a2010-07-30 10:48:14 +0200630{
Takashi Iwai08c189f2012-12-19 15:22:24 +0100631 struct hda_gen_spec *spec = codec->spec;
632 if (spec->dyn_adc_switch)
633 adc_idx = spec->dyn_adc_idx[imux_idx];
634 return spec->adc_nids[adc_idx];
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100635}
636
Takashi Iwai666a70d2012-12-17 20:29:29 +0100637static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200638{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100640 struct hda_input_mux *imux = &spec->gen.input_mux;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100641 struct nid_path *path;
642 hda_nid_t nid;
643 int i, dir, parm;
644 unsigned int val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200645
Takashi Iwai666a70d2012-12-17 20:29:29 +0100646 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai08c189f2012-12-19 15:22:24 +0100647 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
Takashi Iwai666a70d2012-12-17 20:29:29 +0100648 break;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200649 }
Takashi Iwai666a70d2012-12-17 20:29:29 +0100650 if (i >= imux->num_items)
651 return;
Takashi Iwaia23b6882009-03-23 15:21:36 +0100652
Takashi Iwai08c189f2012-12-19 15:22:24 +0100653 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
654 get_adc_nid(codec, adc_idx, i));
Takashi Iwai666a70d2012-12-17 20:29:29 +0100655 val = path->ctls[NID_PATH_MUTE_CTL];
656 if (!val)
657 return;
658 nid = get_amp_nid_(val);
659 dir = get_amp_direction_(val);
660 parm = AC_AMP_SET_RIGHT |
661 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
Takashi Iwaia23b6882009-03-23 15:21:36 +0100662
Takashi Iwaic4f3ebe2012-12-20 11:33:20 +0100663 /* flush all cached amps at first */
Takashi Iwaidc870f32013-01-22 15:24:30 +0100664 snd_hda_codec_flush_cache(codec);
Takashi Iwaic4f3ebe2012-12-20 11:33:20 +0100665
Takashi Iwai666a70d2012-12-17 20:29:29 +0100666 /* we care only right channel */
667 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
668 if (val & 0x80) /* if already muted, we don't need to touch */
669 return;
670 val |= 0x80;
671 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
672 parm | val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200673}
674
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200675/*
Takashi Iwai125821a2012-06-22 14:30:29 +0200676 * Inverted digital-mic handling
677 *
678 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
679 * gives the additional mute only to the right channel of the digital mic
680 * capture stream. This is a workaround for avoiding the almost silence
681 * by summing the stereo stream from some (known to be ForteMedia)
682 * digital mic unit.
683 *
684 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
685 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
686 * without caching so that the cache can still keep the original value.
687 * The cached value is then restored when the flag is set off or any other
688 * than d-mic is used as the current input source.
689 */
690static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
691{
692 struct alc_spec *spec = codec->spec;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100693 int src, nums;
Takashi Iwai125821a2012-06-22 14:30:29 +0200694
695 if (!spec->inv_dmic_fixup)
696 return;
697 if (!spec->inv_dmic_muted && !force)
698 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100699 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100700 for (src = 0; src < nums; src++) {
Takashi Iwai125821a2012-06-22 14:30:29 +0200701 bool dmic_fixup = false;
Takashi Iwai125821a2012-06-22 14:30:29 +0200702
703 if (spec->inv_dmic_muted &&
Takashi Iwai08c189f2012-12-19 15:22:24 +0100704 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
Takashi Iwai125821a2012-06-22 14:30:29 +0200705 dmic_fixup = true;
706 if (!dmic_fixup && !force)
707 continue;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100708 alc_inv_dmic_sync_adc(codec, src);
Takashi Iwai125821a2012-06-22 14:30:29 +0200709 }
710}
711
Takashi Iwaia90229e2013-01-18 14:10:00 +0100712static void alc_inv_dmic_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +0100713 struct snd_kcontrol *kcontrol,
714 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai08c189f2012-12-19 15:22:24 +0100715{
716 alc_inv_dmic_sync(codec, false);
717}
718
Takashi Iwai125821a2012-06-22 14:30:29 +0200719static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
720 struct snd_ctl_elem_value *ucontrol)
721{
722 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
723 struct alc_spec *spec = codec->spec;
724
725 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
726 return 0;
727}
728
729static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
730 struct snd_ctl_elem_value *ucontrol)
731{
732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
733 struct alc_spec *spec = codec->spec;
734 unsigned int val = !ucontrol->value.integer.value[0];
735
736 if (val == spec->inv_dmic_muted)
737 return 0;
738 spec->inv_dmic_muted = val;
739 alc_inv_dmic_sync(codec, true);
740 return 0;
741}
742
743static const struct snd_kcontrol_new alc_inv_dmic_sw = {
744 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Takashi Iwaibc549762012-12-18 15:35:11 +0100745 .name = "Inverted Internal Mic Capture Switch",
Takashi Iwai125821a2012-06-22 14:30:29 +0200746 .info = snd_ctl_boolean_mono_info,
747 .get = alc_inv_dmic_sw_get,
748 .put = alc_inv_dmic_sw_put,
749};
750
751static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
752{
753 struct alc_spec *spec = codec->spec;
Takashi Iwai668d1e92012-11-29 14:10:17 +0100754
Takashi Iwai08c189f2012-12-19 15:22:24 +0100755 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
Takashi Iwai125821a2012-06-22 14:30:29 +0200756 return -ENOMEM;
757 spec->inv_dmic_fixup = 1;
758 spec->inv_dmic_muted = 0;
759 spec->inv_dmic_pin = nid;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100760 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
Takashi Iwai125821a2012-06-22 14:30:29 +0200761 return 0;
762}
763
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200764/* typically the digital mic is put at node 0x12 */
765static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +0100766 const struct hda_fixup *fix, int action)
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200767{
Takashi Iwai1727a772013-01-10 09:52:52 +0100768 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200769 alc_add_inv_dmic_mixer(codec, 0x12);
770}
771
Takashi Iwai603c4012008-07-30 15:01:44 +0200772
Takashi Iwai67d634c2009-11-16 15:35:59 +0100773#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100774/* additional beep mixers; the actual parameters are overwritten at build */
Takashi Iwaia9111322011-05-02 11:30:18 +0200775static const struct snd_kcontrol_new alc_beep_mixer[] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100776 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +0200777 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100778 { } /* end */
779};
Takashi Iwai67d634c2009-11-16 15:35:59 +0100780#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100781
Takashi Iwai2eab6942012-12-18 15:30:41 +0100782static int alc_build_controls(struct hda_codec *codec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783{
784 struct alc_spec *spec = codec->spec;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100785 int i, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786
Takashi Iwai08c189f2012-12-19 15:22:24 +0100787 err = snd_hda_gen_build_controls(codec);
788 if (err < 0)
789 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790
791 for (i = 0; i < spec->num_mixers; i++) {
792 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
793 if (err < 0)
794 return err;
795 }
Takashi Iwai2134ea42008-01-10 16:53:55 +0100796
Takashi Iwai67d634c2009-11-16 15:35:59 +0100797#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100798 /* create beep controls if needed */
799 if (spec->beep_amp) {
Takashi Iwaia9111322011-05-02 11:30:18 +0200800 const struct snd_kcontrol_new *knew;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100801 for (knew = alc_beep_mixer; knew->name; knew++) {
802 struct snd_kcontrol *kctl;
803 kctl = snd_ctl_new1(knew, codec);
804 if (!kctl)
805 return -ENOMEM;
806 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +0100807 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100808 if (err < 0)
809 return err;
810 }
811 }
Takashi Iwai67d634c2009-11-16 15:35:59 +0100812#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100813
Takashi Iwai1727a772013-01-10 09:52:52 +0100814 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
Takashi Iwai420b0fe2012-03-12 12:35:27 +0100815 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816}
817
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200818
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100820 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200821 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200822
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823static int alc_init(struct hda_codec *codec)
824{
825 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200826
Takashi Iwai546bb672012-03-07 08:37:19 +0100827 if (spec->init_hook)
828 spec->init_hook(codec);
Kailang Yang526af6e2012-03-07 08:25:20 +0100829
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200830 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200831 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200832
Takashi Iwai08c189f2012-12-19 15:22:24 +0100833 snd_hda_gen_init(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100834
Takashi Iwai1727a772013-01-10 09:52:52 +0100835 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
Takashi Iwaie08a0072006-09-07 17:52:14 +0200836
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 return 0;
838}
839
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100840static inline void alc_shutup(struct hda_codec *codec)
841{
Takashi Iwai1c7161532011-04-07 10:37:16 +0200842 struct alc_spec *spec = codec->spec;
843
844 if (spec && spec->shutup)
845 spec->shutup(codec);
Takashi Iwai9bfb2842013-07-24 14:31:50 +0200846 else
847 snd_hda_shutup_pins(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100848}
849
Takashi Iwai8a02c0c2014-02-10 18:09:45 +0100850#define alc_free snd_hda_gen_free
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851
Takashi Iwai83012a72012-08-24 18:38:08 +0200852#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -0500853static void alc_power_eapd(struct hda_codec *codec)
854{
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200855 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -0500856}
857
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200858static int alc_suspend(struct hda_codec *codec)
Hector Martinf5de24b2009-12-20 22:51:31 +0100859{
860 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100861 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100862 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -0500863 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100864 return 0;
865}
866#endif
867
Takashi Iwai2a439522011-07-26 09:52:50 +0200868#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100869static int alc_resume(struct hda_codec *codec)
870{
Kailang Yang97a26572013-11-29 00:35:26 -0500871 struct alc_spec *spec = codec->spec;
872
873 if (!spec->no_depop_delay)
874 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +0100875 codec->patch_ops.init(codec);
876 snd_hda_codec_resume_amp(codec);
877 snd_hda_codec_resume_cache(codec);
Takashi Iwai125821a2012-06-22 14:30:29 +0200878 alc_inv_dmic_sync(codec, true);
Takashi Iwai9e5341b2010-09-21 09:57:06 +0200879 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +0100880 return 0;
881}
Takashi Iwaie044c392008-10-27 16:56:24 +0100882#endif
883
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884/*
885 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200886static const struct hda_codec_ops alc_patch_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 .build_controls = alc_build_controls,
Takashi Iwai08c189f2012-12-19 15:22:24 +0100888 .build_pcms = snd_hda_gen_build_pcms,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 .init = alc_init,
890 .free = alc_free,
David Henningsson29adc4b2012-09-25 11:31:00 +0200891 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +0200892#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100893 .resume = alc_resume,
Hector Martinf5de24b2009-12-20 22:51:31 +0100894 .suspend = alc_suspend,
Takashi Iwaifce52a32013-01-07 12:42:48 +0100895 .check_power_status = snd_hda_gen_check_power_status,
Takashi Iwaicb53c622007-08-10 17:21:45 +0200896#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -0500897 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898};
899
David Henningsson29adc4b2012-09-25 11:31:00 +0200900
Kailang Yangc027ddc2010-03-19 11:33:06 +0100901/* replace the codec chip_name with the given string */
902static int alc_codec_rename(struct hda_codec *codec, const char *name)
903{
904 kfree(codec->chip_name);
905 codec->chip_name = kstrdup(name, GFP_KERNEL);
906 if (!codec->chip_name) {
907 alc_free(codec);
908 return -ENOMEM;
909 }
910 return 0;
911}
912
Takashi Iwai2fa522b2005-05-12 14:51:12 +0200913/*
Kailang Yang4b016932013-11-28 11:55:09 +0100914 * Rename codecs appropriately from COEF value or subvendor id
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200915 */
916struct alc_codec_rename_table {
917 unsigned int vendor_id;
918 unsigned short coef_mask;
919 unsigned short coef_bits;
920 const char *name;
921};
922
Kailang Yang4b016932013-11-28 11:55:09 +0100923struct alc_codec_rename_pci_table {
924 unsigned int codec_vendor_id;
925 unsigned short pci_subvendor;
926 unsigned short pci_subdevice;
927 const char *name;
928};
929
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200930static struct alc_codec_rename_table rename_tbl[] = {
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800931 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200932 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
933 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
934 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
935 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
936 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
937 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
938 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
Kailang Yangadcc70b2012-05-25 08:08:38 +0200939 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800940 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200941 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
942 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
943 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
944 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
945 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
946 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
947 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
948 { } /* terminator */
949};
950
Kailang Yang4b016932013-11-28 11:55:09 +0100951static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
952 { 0x10ec0280, 0x1028, 0, "ALC3220" },
953 { 0x10ec0282, 0x1028, 0, "ALC3221" },
954 { 0x10ec0283, 0x1028, 0, "ALC3223" },
Kailang Yang193177d2014-04-23 16:06:13 +0800955 { 0x10ec0288, 0x1028, 0, "ALC3263" },
Kailang Yang4b016932013-11-28 11:55:09 +0100956 { 0x10ec0292, 0x1028, 0, "ALC3226" },
Kailang Yang193177d2014-04-23 16:06:13 +0800957 { 0x10ec0293, 0x1028, 0, "ALC3235" },
Kailang Yang4b016932013-11-28 11:55:09 +0100958 { 0x10ec0255, 0x1028, 0, "ALC3234" },
959 { 0x10ec0668, 0x1028, 0, "ALC3661" },
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800960 { 0x10ec0275, 0x1028, 0, "ALC3260" },
961 { 0x10ec0899, 0x1028, 0, "ALC3861" },
962 { 0x10ec0670, 0x1025, 0, "ALC669X" },
963 { 0x10ec0676, 0x1025, 0, "ALC679X" },
964 { 0x10ec0282, 0x1043, 0, "ALC3229" },
965 { 0x10ec0233, 0x1043, 0, "ALC3236" },
966 { 0x10ec0280, 0x103c, 0, "ALC3228" },
967 { 0x10ec0282, 0x103c, 0, "ALC3227" },
968 { 0x10ec0286, 0x103c, 0, "ALC3242" },
969 { 0x10ec0290, 0x103c, 0, "ALC3241" },
970 { 0x10ec0668, 0x103c, 0, "ALC3662" },
971 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
972 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
Kailang Yang4b016932013-11-28 11:55:09 +0100973 { } /* terminator */
974};
975
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200976static int alc_codec_rename_from_preset(struct hda_codec *codec)
977{
978 const struct alc_codec_rename_table *p;
Kailang Yang4b016932013-11-28 11:55:09 +0100979 const struct alc_codec_rename_pci_table *q;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200980
981 for (p = rename_tbl; p->vendor_id; p++) {
982 if (p->vendor_id != codec->vendor_id)
983 continue;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200984 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200985 return alc_codec_rename(codec, p->name);
986 }
Kailang Yang4b016932013-11-28 11:55:09 +0100987
Takashi Iwai5100cd02014-02-15 10:03:19 +0100988 if (!codec->bus->pci)
989 return 0;
Kailang Yang4b016932013-11-28 11:55:09 +0100990 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
991 if (q->codec_vendor_id != codec->vendor_id)
992 continue;
993 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
994 continue;
995 if (!q->pci_subdevice ||
996 q->pci_subdevice == codec->bus->pci->subsystem_device)
997 return alc_codec_rename(codec, q->name);
998 }
999
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001000 return 0;
1001}
1002
Takashi Iwaie4770622011-07-08 11:11:35 +02001003
1004/*
Takashi Iwai1d045db2011-07-07 18:23:21 +02001005 * Digital-beep handlers
1006 */
1007#ifdef CONFIG_SND_HDA_INPUT_BEEP
1008#define set_beep_amp(spec, nid, idx, dir) \
1009 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
1010
1011static const struct snd_pci_quirk beep_white_list[] = {
Duncan Roe71100052012-10-10 14:19:50 +02001012 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
W. Trevor Kinga4b7f21d2014-03-29 17:47:24 -07001013 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001014 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai8554ee42013-02-25 09:54:43 +01001015 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001016 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1017 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1018 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
Takashi Iwai78f8baf2012-03-06 14:02:32 +01001019 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001020 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1021 {}
1022};
1023
1024static inline int has_cdefine_beep(struct hda_codec *codec)
1025{
1026 struct alc_spec *spec = codec->spec;
1027 const struct snd_pci_quirk *q;
1028 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1029 if (q)
1030 return q->value;
1031 return spec->cdefine.enable_pcbeep;
1032}
1033#else
1034#define set_beep_amp(spec, nid, idx, dir) /* NOP */
1035#define has_cdefine_beep(codec) 0
1036#endif
1037
1038/* parse the BIOS configuration and set up the alc_spec */
1039/* return 1 if successful, 0 if the proper config is not found,
1040 * or a negative error code
1041 */
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001042static int alc_parse_auto_config(struct hda_codec *codec,
1043 const hda_nid_t *ignore_nids,
1044 const hda_nid_t *ssid_nids)
Takashi Iwai1d045db2011-07-07 18:23:21 +02001045{
1046 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001047 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001048 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001049
Takashi Iwai53c334a2011-08-23 18:27:14 +02001050 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1051 spec->parse_flags);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001052 if (err < 0)
1053 return err;
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001054
1055 if (ssid_nids)
1056 alc_ssid_check(codec, ssid_nids);
1057
Takashi Iwai08c189f2012-12-19 15:22:24 +01001058 err = snd_hda_gen_parse_auto_config(codec, cfg);
1059 if (err < 0)
1060 return err;
Takashi Iwai070cff42012-02-21 12:54:17 +01001061
Takashi Iwai1d045db2011-07-07 18:23:21 +02001062 return 1;
1063}
1064
Takashi Iwai3de95172012-05-07 18:03:15 +02001065/* common preparation job for alc_spec */
1066static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1067{
1068 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1069 int err;
1070
1071 if (!spec)
1072 return -ENOMEM;
1073 codec->spec = spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001074 snd_hda_gen_spec_init(&spec->gen);
1075 spec->gen.mixer_nid = mixer_nid;
1076 spec->gen.own_eapd_ctl = 1;
Takashi Iwai1098b7c2012-12-17 20:03:15 +01001077 codec->single_adc_amp = 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001078 /* FIXME: do we need this for all Realtek codec models? */
1079 codec->spdif_status_reset = 1;
Takashi Iwai3de95172012-05-07 18:03:15 +02001080
1081 err = alc_codec_rename_from_preset(codec);
1082 if (err < 0) {
1083 kfree(spec);
1084 return err;
1085 }
1086 return 0;
1087}
1088
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001089static int alc880_parse_auto_config(struct hda_codec *codec)
1090{
1091 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02001092 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001093 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1094}
1095
Takashi Iwai1d045db2011-07-07 18:23:21 +02001096/*
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001097 * ALC880 fix-ups
1098 */
1099enum {
Takashi Iwai411225a2012-02-20 17:48:19 +01001100 ALC880_FIXUP_GPIO1,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001101 ALC880_FIXUP_GPIO2,
1102 ALC880_FIXUP_MEDION_RIM,
Takashi Iwaidc6af522012-02-17 16:18:59 +01001103 ALC880_FIXUP_LG,
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001104 ALC880_FIXUP_LG_LW25,
Takashi Iwaif02aab52012-02-17 16:33:56 +01001105 ALC880_FIXUP_W810,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001106 ALC880_FIXUP_EAPD_COEF,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001107 ALC880_FIXUP_TCL_S700,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001108 ALC880_FIXUP_VOL_KNOB,
1109 ALC880_FIXUP_FUJITSU,
Takashi Iwaiba533812012-02-20 16:36:52 +01001110 ALC880_FIXUP_F1734,
Takashi Iwai817de922012-02-20 17:20:48 +01001111 ALC880_FIXUP_UNIWILL,
Takashi Iwai967b88c2012-02-20 17:31:02 +01001112 ALC880_FIXUP_UNIWILL_DIG,
Takashi Iwai96e225f2012-02-20 17:41:51 +01001113 ALC880_FIXUP_Z71V,
Takashi Iwai487a5882013-11-07 07:29:30 +01001114 ALC880_FIXUP_ASUS_W5A,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001115 ALC880_FIXUP_3ST_BASE,
1116 ALC880_FIXUP_3ST,
1117 ALC880_FIXUP_3ST_DIG,
1118 ALC880_FIXUP_5ST_BASE,
1119 ALC880_FIXUP_5ST,
1120 ALC880_FIXUP_5ST_DIG,
1121 ALC880_FIXUP_6ST_BASE,
1122 ALC880_FIXUP_6ST,
1123 ALC880_FIXUP_6ST_DIG,
Takashi Iwai53971452013-01-23 18:21:37 +01001124 ALC880_FIXUP_6ST_AUTOMUTE,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001125};
1126
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001127/* enable the volume-knob widget support on NID 0x21 */
1128static void alc880_fixup_vol_knob(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001129 const struct hda_fixup *fix, int action)
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001130{
Takashi Iwai1727a772013-01-10 09:52:52 +01001131 if (action == HDA_FIXUP_ACT_PROBE)
David Henningsson29adc4b2012-09-25 11:31:00 +02001132 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001133}
1134
Takashi Iwai1727a772013-01-10 09:52:52 +01001135static const struct hda_fixup alc880_fixups[] = {
Takashi Iwai411225a2012-02-20 17:48:19 +01001136 [ALC880_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001137 .type = HDA_FIXUP_VERBS,
Takashi Iwai411225a2012-02-20 17:48:19 +01001138 .v.verbs = alc_gpio1_init_verbs,
1139 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001140 [ALC880_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001141 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001142 .v.verbs = alc_gpio2_init_verbs,
1143 },
1144 [ALC880_FIXUP_MEDION_RIM] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001145 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001146 .v.verbs = (const struct hda_verb[]) {
1147 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1148 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1149 { }
1150 },
1151 .chained = true,
1152 .chain_id = ALC880_FIXUP_GPIO2,
1153 },
Takashi Iwaidc6af522012-02-17 16:18:59 +01001154 [ALC880_FIXUP_LG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001155 .type = HDA_FIXUP_PINS,
1156 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaidc6af522012-02-17 16:18:59 +01001157 /* disable bogus unused pins */
1158 { 0x16, 0x411111f0 },
1159 { 0x18, 0x411111f0 },
1160 { 0x1a, 0x411111f0 },
1161 { }
1162 }
1163 },
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001164 [ALC880_FIXUP_LG_LW25] = {
1165 .type = HDA_FIXUP_PINS,
1166 .v.pins = (const struct hda_pintbl[]) {
1167 { 0x1a, 0x0181344f }, /* line-in */
1168 { 0x1b, 0x0321403f }, /* headphone */
1169 { }
1170 }
1171 },
Takashi Iwaif02aab52012-02-17 16:33:56 +01001172 [ALC880_FIXUP_W810] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001173 .type = HDA_FIXUP_PINS,
1174 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001175 /* disable bogus unused pins */
1176 { 0x17, 0x411111f0 },
1177 { }
1178 },
1179 .chained = true,
1180 .chain_id = ALC880_FIXUP_GPIO2,
1181 },
Takashi Iwai27e917f2012-02-17 17:49:54 +01001182 [ALC880_FIXUP_EAPD_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001183 .type = HDA_FIXUP_VERBS,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001184 .v.verbs = (const struct hda_verb[]) {
1185 /* change to EAPD mode */
1186 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1187 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1188 {}
1189 },
1190 },
Takashi Iwaib9368f52012-02-17 17:54:44 +01001191 [ALC880_FIXUP_TCL_S700] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001192 .type = HDA_FIXUP_VERBS,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001193 .v.verbs = (const struct hda_verb[]) {
1194 /* change to EAPD mode */
1195 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1196 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1197 {}
1198 },
1199 .chained = true,
1200 .chain_id = ALC880_FIXUP_GPIO2,
1201 },
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001202 [ALC880_FIXUP_VOL_KNOB] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001203 .type = HDA_FIXUP_FUNC,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001204 .v.func = alc880_fixup_vol_knob,
1205 },
1206 [ALC880_FIXUP_FUJITSU] = {
1207 /* override all pins as BIOS on old Amilo is broken */
Takashi Iwai1727a772013-01-10 09:52:52 +01001208 .type = HDA_FIXUP_PINS,
1209 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001210 { 0x14, 0x0121411f }, /* HP */
1211 { 0x15, 0x99030120 }, /* speaker */
1212 { 0x16, 0x99030130 }, /* bass speaker */
1213 { 0x17, 0x411111f0 }, /* N/A */
1214 { 0x18, 0x411111f0 }, /* N/A */
1215 { 0x19, 0x01a19950 }, /* mic-in */
1216 { 0x1a, 0x411111f0 }, /* N/A */
1217 { 0x1b, 0x411111f0 }, /* N/A */
1218 { 0x1c, 0x411111f0 }, /* N/A */
1219 { 0x1d, 0x411111f0 }, /* N/A */
1220 { 0x1e, 0x01454140 }, /* SPDIF out */
1221 { }
1222 },
1223 .chained = true,
1224 .chain_id = ALC880_FIXUP_VOL_KNOB,
1225 },
Takashi Iwaiba533812012-02-20 16:36:52 +01001226 [ALC880_FIXUP_F1734] = {
1227 /* almost compatible with FUJITSU, but no bass and SPDIF */
Takashi Iwai1727a772013-01-10 09:52:52 +01001228 .type = HDA_FIXUP_PINS,
1229 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiba533812012-02-20 16:36:52 +01001230 { 0x14, 0x0121411f }, /* HP */
1231 { 0x15, 0x99030120 }, /* speaker */
1232 { 0x16, 0x411111f0 }, /* N/A */
1233 { 0x17, 0x411111f0 }, /* N/A */
1234 { 0x18, 0x411111f0 }, /* N/A */
1235 { 0x19, 0x01a19950 }, /* mic-in */
1236 { 0x1a, 0x411111f0 }, /* N/A */
1237 { 0x1b, 0x411111f0 }, /* N/A */
1238 { 0x1c, 0x411111f0 }, /* N/A */
1239 { 0x1d, 0x411111f0 }, /* N/A */
1240 { 0x1e, 0x411111f0 }, /* N/A */
1241 { }
1242 },
1243 .chained = true,
1244 .chain_id = ALC880_FIXUP_VOL_KNOB,
1245 },
Takashi Iwai817de922012-02-20 17:20:48 +01001246 [ALC880_FIXUP_UNIWILL] = {
1247 /* need to fix HP and speaker pins to be parsed correctly */
Takashi Iwai1727a772013-01-10 09:52:52 +01001248 .type = HDA_FIXUP_PINS,
1249 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai817de922012-02-20 17:20:48 +01001250 { 0x14, 0x0121411f }, /* HP */
1251 { 0x15, 0x99030120 }, /* speaker */
1252 { 0x16, 0x99030130 }, /* bass speaker */
1253 { }
1254 },
1255 },
Takashi Iwai967b88c2012-02-20 17:31:02 +01001256 [ALC880_FIXUP_UNIWILL_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001257 .type = HDA_FIXUP_PINS,
1258 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai967b88c2012-02-20 17:31:02 +01001259 /* disable bogus unused pins */
1260 { 0x17, 0x411111f0 },
1261 { 0x19, 0x411111f0 },
1262 { 0x1b, 0x411111f0 },
1263 { 0x1f, 0x411111f0 },
1264 { }
1265 }
1266 },
Takashi Iwai96e225f2012-02-20 17:41:51 +01001267 [ALC880_FIXUP_Z71V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001268 .type = HDA_FIXUP_PINS,
1269 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai96e225f2012-02-20 17:41:51 +01001270 /* set up the whole pins as BIOS is utterly broken */
1271 { 0x14, 0x99030120 }, /* speaker */
1272 { 0x15, 0x0121411f }, /* HP */
1273 { 0x16, 0x411111f0 }, /* N/A */
1274 { 0x17, 0x411111f0 }, /* N/A */
1275 { 0x18, 0x01a19950 }, /* mic-in */
1276 { 0x19, 0x411111f0 }, /* N/A */
1277 { 0x1a, 0x01813031 }, /* line-in */
1278 { 0x1b, 0x411111f0 }, /* N/A */
1279 { 0x1c, 0x411111f0 }, /* N/A */
1280 { 0x1d, 0x411111f0 }, /* N/A */
1281 { 0x1e, 0x0144111e }, /* SPDIF */
1282 { }
1283 }
1284 },
Takashi Iwai487a5882013-11-07 07:29:30 +01001285 [ALC880_FIXUP_ASUS_W5A] = {
1286 .type = HDA_FIXUP_PINS,
1287 .v.pins = (const struct hda_pintbl[]) {
1288 /* set up the whole pins as BIOS is utterly broken */
1289 { 0x14, 0x0121411f }, /* HP */
1290 { 0x15, 0x411111f0 }, /* N/A */
1291 { 0x16, 0x411111f0 }, /* N/A */
1292 { 0x17, 0x411111f0 }, /* N/A */
1293 { 0x18, 0x90a60160 }, /* mic */
1294 { 0x19, 0x411111f0 }, /* N/A */
1295 { 0x1a, 0x411111f0 }, /* N/A */
1296 { 0x1b, 0x411111f0 }, /* N/A */
1297 { 0x1c, 0x411111f0 }, /* N/A */
1298 { 0x1d, 0x411111f0 }, /* N/A */
1299 { 0x1e, 0xb743111e }, /* SPDIF out */
1300 { }
1301 },
1302 .chained = true,
1303 .chain_id = ALC880_FIXUP_GPIO1,
1304 },
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001305 [ALC880_FIXUP_3ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001306 .type = HDA_FIXUP_PINS,
1307 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001308 { 0x14, 0x01014010 }, /* line-out */
1309 { 0x15, 0x411111f0 }, /* N/A */
1310 { 0x16, 0x411111f0 }, /* N/A */
1311 { 0x17, 0x411111f0 }, /* N/A */
1312 { 0x18, 0x01a19c30 }, /* mic-in */
1313 { 0x19, 0x0121411f }, /* HP */
1314 { 0x1a, 0x01813031 }, /* line-in */
1315 { 0x1b, 0x02a19c40 }, /* front-mic */
1316 { 0x1c, 0x411111f0 }, /* N/A */
1317 { 0x1d, 0x411111f0 }, /* N/A */
1318 /* 0x1e is filled in below */
1319 { 0x1f, 0x411111f0 }, /* N/A */
1320 { }
1321 }
1322 },
1323 [ALC880_FIXUP_3ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001324 .type = HDA_FIXUP_PINS,
1325 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001326 { 0x1e, 0x411111f0 }, /* N/A */
1327 { }
1328 },
1329 .chained = true,
1330 .chain_id = ALC880_FIXUP_3ST_BASE,
1331 },
1332 [ALC880_FIXUP_3ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001333 .type = HDA_FIXUP_PINS,
1334 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001335 { 0x1e, 0x0144111e }, /* SPDIF */
1336 { }
1337 },
1338 .chained = true,
1339 .chain_id = ALC880_FIXUP_3ST_BASE,
1340 },
1341 [ALC880_FIXUP_5ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001342 .type = HDA_FIXUP_PINS,
1343 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001344 { 0x14, 0x01014010 }, /* front */
1345 { 0x15, 0x411111f0 }, /* N/A */
1346 { 0x16, 0x01011411 }, /* CLFE */
1347 { 0x17, 0x01016412 }, /* surr */
1348 { 0x18, 0x01a19c30 }, /* mic-in */
1349 { 0x19, 0x0121411f }, /* HP */
1350 { 0x1a, 0x01813031 }, /* line-in */
1351 { 0x1b, 0x02a19c40 }, /* front-mic */
1352 { 0x1c, 0x411111f0 }, /* N/A */
1353 { 0x1d, 0x411111f0 }, /* N/A */
1354 /* 0x1e is filled in below */
1355 { 0x1f, 0x411111f0 }, /* N/A */
1356 { }
1357 }
1358 },
1359 [ALC880_FIXUP_5ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001360 .type = HDA_FIXUP_PINS,
1361 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001362 { 0x1e, 0x411111f0 }, /* N/A */
1363 { }
1364 },
1365 .chained = true,
1366 .chain_id = ALC880_FIXUP_5ST_BASE,
1367 },
1368 [ALC880_FIXUP_5ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001369 .type = HDA_FIXUP_PINS,
1370 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001371 { 0x1e, 0x0144111e }, /* SPDIF */
1372 { }
1373 },
1374 .chained = true,
1375 .chain_id = ALC880_FIXUP_5ST_BASE,
1376 },
1377 [ALC880_FIXUP_6ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001378 .type = HDA_FIXUP_PINS,
1379 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001380 { 0x14, 0x01014010 }, /* front */
1381 { 0x15, 0x01016412 }, /* surr */
1382 { 0x16, 0x01011411 }, /* CLFE */
1383 { 0x17, 0x01012414 }, /* side */
1384 { 0x18, 0x01a19c30 }, /* mic-in */
1385 { 0x19, 0x02a19c40 }, /* front-mic */
1386 { 0x1a, 0x01813031 }, /* line-in */
1387 { 0x1b, 0x0121411f }, /* HP */
1388 { 0x1c, 0x411111f0 }, /* N/A */
1389 { 0x1d, 0x411111f0 }, /* N/A */
1390 /* 0x1e is filled in below */
1391 { 0x1f, 0x411111f0 }, /* N/A */
1392 { }
1393 }
1394 },
1395 [ALC880_FIXUP_6ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001396 .type = HDA_FIXUP_PINS,
1397 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001398 { 0x1e, 0x411111f0 }, /* N/A */
1399 { }
1400 },
1401 .chained = true,
1402 .chain_id = ALC880_FIXUP_6ST_BASE,
1403 },
1404 [ALC880_FIXUP_6ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001405 .type = HDA_FIXUP_PINS,
1406 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001407 { 0x1e, 0x0144111e }, /* SPDIF */
1408 { }
1409 },
1410 .chained = true,
1411 .chain_id = ALC880_FIXUP_6ST_BASE,
1412 },
Takashi Iwai53971452013-01-23 18:21:37 +01001413 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1414 .type = HDA_FIXUP_PINS,
1415 .v.pins = (const struct hda_pintbl[]) {
1416 { 0x1b, 0x0121401f }, /* HP with jack detect */
1417 { }
1418 },
1419 .chained_before = true,
1420 .chain_id = ALC880_FIXUP_6ST_BASE,
1421 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001422};
1423
1424static const struct snd_pci_quirk alc880_fixup_tbl[] = {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001425 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
Takashi Iwai487a5882013-11-07 07:29:30 +01001426 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
Takashi Iwai96e225f2012-02-20 17:41:51 +01001427 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001428 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
David Henningsson6538de02014-06-10 10:52:50 +02001429 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001430 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
Takashi Iwai27e917f2012-02-17 17:49:54 +01001431 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
Takashi Iwai967b88c2012-02-20 17:31:02 +01001432 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
Takashi Iwaiba533812012-02-20 16:36:52 +01001433 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
Takashi Iwai817de922012-02-20 17:20:48 +01001434 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
Takashi Iwai7833c7e2012-02-20 17:11:38 +01001435 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
Takashi Iwaif02aab52012-02-17 16:33:56 +01001436 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001437 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
Takashi Iwai53971452013-01-23 18:21:37 +01001438 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwaiba533812012-02-20 16:36:52 +01001439 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001440 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
Takashi Iwaiba533812012-02-20 16:36:52 +01001441 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001442 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
Takashi Iwaidc6af522012-02-17 16:18:59 +01001443 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1444 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1445 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001446 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
Takashi Iwaib9368f52012-02-17 17:54:44 +01001447 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001448
1449 /* Below is the copied entries from alc880_quirks.c.
1450 * It's not quite sure whether BIOS sets the correct pin-config table
1451 * on these machines, thus they are kept to be compatible with
1452 * the old static quirks. Once when it's confirmed to work without
1453 * these overrides, it'd be better to remove.
1454 */
1455 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1456 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1457 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1458 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1459 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1460 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1461 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1462 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1463 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1464 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1465 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1466 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1467 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1468 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1469 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1470 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1471 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1472 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1473 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1474 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1475 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1476 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1477 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1478 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1479 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1480 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1481 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1482 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1483 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1484 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1485 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1486 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1487 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1488 /* default Intel */
1489 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1490 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1491 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1492 {}
1493};
1494
Takashi Iwai1727a772013-01-10 09:52:52 +01001495static const struct hda_model_fixup alc880_fixup_models[] = {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001496 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1497 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1498 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1499 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1500 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1501 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
Takashi Iwai53971452013-01-23 18:21:37 +01001502 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001503 {}
1504};
1505
1506
1507/*
Takashi Iwai1d045db2011-07-07 18:23:21 +02001508 * OK, here we have finally the patch for ALC880
1509 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001510static int patch_alc880(struct hda_codec *codec)
1511{
1512 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001513 int err;
1514
Takashi Iwai3de95172012-05-07 18:03:15 +02001515 err = alc_alloc_spec(codec, 0x0b);
1516 if (err < 0)
1517 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001518
Takashi Iwai3de95172012-05-07 18:03:15 +02001519 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001520 spec->gen.need_dac_fix = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001521 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001522
Takashi Iwai1727a772013-01-10 09:52:52 +01001523 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001524 alc880_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001525 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001526
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001527 /* automatic parse from the BIOS config */
1528 err = alc880_parse_auto_config(codec);
1529 if (err < 0)
1530 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001531
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001532 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001533 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001534
Takashi Iwai1d045db2011-07-07 18:23:21 +02001535 codec->patch_ops = alc_patch_ops;
David Henningsson29adc4b2012-09-25 11:31:00 +02001536 codec->patch_ops.unsol_event = alc880_unsol_event;
1537
Takashi Iwai1d045db2011-07-07 18:23:21 +02001538
Takashi Iwai1727a772013-01-10 09:52:52 +01001539 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001540
Takashi Iwai1d045db2011-07-07 18:23:21 +02001541 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001542
1543 error:
1544 alc_free(codec);
1545 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001546}
1547
1548
1549/*
1550 * ALC260 support
1551 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001552static int alc260_parse_auto_config(struct hda_codec *codec)
1553{
Takashi Iwai1d045db2011-07-07 18:23:21 +02001554 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001555 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1556 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001557}
1558
Takashi Iwai1d045db2011-07-07 18:23:21 +02001559/*
1560 * Pin config fixes
1561 */
1562enum {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001563 ALC260_FIXUP_HP_DC5750,
1564 ALC260_FIXUP_HP_PIN_0F,
1565 ALC260_FIXUP_COEF,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001566 ALC260_FIXUP_GPIO1,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001567 ALC260_FIXUP_GPIO1_TOGGLE,
1568 ALC260_FIXUP_REPLACER,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001569 ALC260_FIXUP_HP_B1900,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001570 ALC260_FIXUP_KN1,
Takashi Iwai39aedee2013-01-10 17:10:40 +01001571 ALC260_FIXUP_FSC_S7020,
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001572 ALC260_FIXUP_FSC_S7020_JWSE,
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001573 ALC260_FIXUP_VAIO_PINS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001574};
1575
Takashi Iwai20f7d922012-02-16 12:35:16 +01001576static void alc260_gpio1_automute(struct hda_codec *codec)
1577{
1578 struct alc_spec *spec = codec->spec;
1579 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwai08c189f2012-12-19 15:22:24 +01001580 spec->gen.hp_jack_present);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001581}
1582
1583static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001584 const struct hda_fixup *fix, int action)
Takashi Iwai20f7d922012-02-16 12:35:16 +01001585{
1586 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001587 if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwai20f7d922012-02-16 12:35:16 +01001588 /* although the machine has only one output pin, we need to
1589 * toggle GPIO1 according to the jack state
1590 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01001591 spec->gen.automute_hook = alc260_gpio1_automute;
1592 spec->gen.detect_hp = 1;
1593 spec->gen.automute_speaker = 1;
1594 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1595 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
1596 snd_hda_gen_hp_automute);
Takashi Iwaic9ce6b22012-12-18 18:12:44 +01001597 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001598 }
1599}
1600
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001601static void alc260_fixup_kn1(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001602 const struct hda_fixup *fix, int action)
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001603{
1604 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001605 static const struct hda_pintbl pincfgs[] = {
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001606 { 0x0f, 0x02214000 }, /* HP/speaker */
1607 { 0x12, 0x90a60160 }, /* int mic */
1608 { 0x13, 0x02a19000 }, /* ext mic */
1609 { 0x18, 0x01446000 }, /* SPDIF out */
1610 /* disable bogus I/O pins */
1611 { 0x10, 0x411111f0 },
1612 { 0x11, 0x411111f0 },
1613 { 0x14, 0x411111f0 },
1614 { 0x15, 0x411111f0 },
1615 { 0x16, 0x411111f0 },
1616 { 0x17, 0x411111f0 },
1617 { 0x19, 0x411111f0 },
1618 { }
1619 };
1620
1621 switch (action) {
Takashi Iwai1727a772013-01-10 09:52:52 +01001622 case HDA_FIXUP_ACT_PRE_PROBE:
1623 snd_hda_apply_pincfgs(codec, pincfgs);
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001624 break;
Takashi Iwai1727a772013-01-10 09:52:52 +01001625 case HDA_FIXUP_ACT_PROBE:
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001626 spec->init_amp = ALC_INIT_NONE;
1627 break;
1628 }
1629}
1630
Takashi Iwai39aedee2013-01-10 17:10:40 +01001631static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1632 const struct hda_fixup *fix, int action)
1633{
1634 struct alc_spec *spec = codec->spec;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001635 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001636 spec->init_amp = ALC_INIT_NONE;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001637}
1638
1639static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1640 const struct hda_fixup *fix, int action)
1641{
1642 struct alc_spec *spec = codec->spec;
1643 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaif811c3c2013-03-07 18:32:59 +01001644 spec->gen.add_jack_modes = 1;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001645 spec->gen.hp_mic = 1;
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001646 }
Takashi Iwai39aedee2013-01-10 17:10:40 +01001647}
1648
Takashi Iwai1727a772013-01-10 09:52:52 +01001649static const struct hda_fixup alc260_fixups[] = {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001650 [ALC260_FIXUP_HP_DC5750] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001651 .type = HDA_FIXUP_PINS,
1652 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001653 { 0x11, 0x90130110 }, /* speaker */
1654 { }
1655 }
1656 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001657 [ALC260_FIXUP_HP_PIN_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001658 .type = HDA_FIXUP_PINS,
1659 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001660 { 0x0f, 0x01214000 }, /* HP */
1661 { }
1662 }
1663 },
1664 [ALC260_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001665 .type = HDA_FIXUP_VERBS,
Takashi Iwaica8f0422012-02-16 11:51:19 +01001666 .v.verbs = (const struct hda_verb[]) {
Ronan Marquete30cf2d2014-06-01 18:38:53 +02001667 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1668 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001669 { }
1670 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001671 },
Takashi Iwai15317ab2012-02-16 12:02:53 +01001672 [ALC260_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001673 .type = HDA_FIXUP_VERBS,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001674 .v.verbs = alc_gpio1_init_verbs,
1675 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001676 [ALC260_FIXUP_GPIO1_TOGGLE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001677 .type = HDA_FIXUP_FUNC,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001678 .v.func = alc260_fixup_gpio1_toggle,
1679 .chained = true,
1680 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1681 },
1682 [ALC260_FIXUP_REPLACER] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001683 .type = HDA_FIXUP_VERBS,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001684 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai192a98e2014-06-02 15:16:07 +02001685 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1686 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001687 { }
1688 },
1689 .chained = true,
1690 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1691 },
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001692 [ALC260_FIXUP_HP_B1900] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001693 .type = HDA_FIXUP_FUNC,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001694 .v.func = alc260_fixup_gpio1_toggle,
1695 .chained = true,
1696 .chain_id = ALC260_FIXUP_COEF,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001697 },
1698 [ALC260_FIXUP_KN1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001699 .type = HDA_FIXUP_FUNC,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001700 .v.func = alc260_fixup_kn1,
1701 },
Takashi Iwai39aedee2013-01-10 17:10:40 +01001702 [ALC260_FIXUP_FSC_S7020] = {
1703 .type = HDA_FIXUP_FUNC,
1704 .v.func = alc260_fixup_fsc_s7020,
1705 },
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001706 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1707 .type = HDA_FIXUP_FUNC,
1708 .v.func = alc260_fixup_fsc_s7020_jwse,
1709 .chained = true,
1710 .chain_id = ALC260_FIXUP_FSC_S7020,
1711 },
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001712 [ALC260_FIXUP_VAIO_PINS] = {
1713 .type = HDA_FIXUP_PINS,
1714 .v.pins = (const struct hda_pintbl[]) {
1715 /* Pin configs are missing completely on some VAIOs */
1716 { 0x0f, 0x01211020 },
1717 { 0x10, 0x0001003f },
1718 { 0x11, 0x411111f0 },
1719 { 0x12, 0x01a15930 },
1720 { 0x13, 0x411111f0 },
1721 { 0x14, 0x411111f0 },
1722 { 0x15, 0x411111f0 },
1723 { 0x16, 0x411111f0 },
1724 { 0x17, 0x411111f0 },
1725 { 0x18, 0x411111f0 },
1726 { 0x19, 0x411111f0 },
1727 { }
1728 }
1729 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02001730};
1731
1732static const struct snd_pci_quirk alc260_fixup_tbl[] = {
Takashi Iwai15317ab2012-02-16 12:02:53 +01001733 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001734 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
Takashi Iwai15317ab2012-02-16 12:02:53 +01001735 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001736 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001737 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001738 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
Takashi Iwai0f5a5b82013-11-21 09:12:52 +01001739 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
Takashi Iwai39aedee2013-01-10 17:10:40 +01001740 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
Takashi Iwaib1f58082012-02-16 12:45:03 +01001741 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001742 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
Takashi Iwai20f7d922012-02-16 12:35:16 +01001743 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001744 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001745 {}
1746};
1747
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001748static const struct hda_model_fixup alc260_fixup_models[] = {
1749 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1750 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1751 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1752 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1753 {}
1754};
1755
Takashi Iwai1d045db2011-07-07 18:23:21 +02001756/*
1757 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001758static int patch_alc260(struct hda_codec *codec)
1759{
1760 struct alc_spec *spec;
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001761 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001762
Takashi Iwai3de95172012-05-07 18:03:15 +02001763 err = alc_alloc_spec(codec, 0x07);
1764 if (err < 0)
1765 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001766
Takashi Iwai3de95172012-05-07 18:03:15 +02001767 spec = codec->spec;
Takashi Iwaiea46c3c2013-01-15 18:45:53 +01001768 /* as quite a few machines require HP amp for speaker outputs,
1769 * it's easier to enable it unconditionally; even if it's unneeded,
1770 * it's almost harmless.
1771 */
1772 spec->gen.prefer_hp_amp = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001773 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001774
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001775 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1776 alc260_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001777 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001778
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001779 /* automatic parse from the BIOS config */
1780 err = alc260_parse_auto_config(codec);
1781 if (err < 0)
1782 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001783
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001784 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001785 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001786
Takashi Iwai1d045db2011-07-07 18:23:21 +02001787 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001788 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001789
Takashi Iwai1727a772013-01-10 09:52:52 +01001790 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001791
Takashi Iwai1d045db2011-07-07 18:23:21 +02001792 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001793
1794 error:
1795 alc_free(codec);
1796 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001797}
1798
1799
1800/*
1801 * ALC882/883/885/888/889 support
1802 *
1803 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1804 * configuration. Each pin widget can choose any input DACs and a mixer.
1805 * Each ADC is connected from a mixer of all inputs. This makes possible
1806 * 6-channel independent captures.
1807 *
1808 * In addition, an independent DAC for the multi-playback (not used in this
1809 * driver yet).
1810 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001811
1812/*
1813 * Pin config fixes
1814 */
1815enum {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001816 ALC882_FIXUP_ABIT_AW9D_MAX,
1817 ALC882_FIXUP_LENOVO_Y530,
1818 ALC882_FIXUP_PB_M5210,
1819 ALC882_FIXUP_ACER_ASPIRE_7736,
1820 ALC882_FIXUP_ASUS_W90V,
Marton Balint8f239212012-03-05 21:33:23 +01001821 ALC889_FIXUP_CD,
David Henningssonb2c53e22014-01-01 14:01:34 +01001822 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001823 ALC889_FIXUP_VAIO_TT,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001824 ALC888_FIXUP_EEE1601,
Takashi Iwai177943a32011-11-09 12:55:18 +01001825 ALC882_FIXUP_EAPD,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01001826 ALC883_FIXUP_EAPD,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01001827 ALC883_FIXUP_ACER_EAPD,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001828 ALC882_FIXUP_GPIO1,
1829 ALC882_FIXUP_GPIO2,
Takashi Iwaieb844d52011-11-09 18:03:07 +01001830 ALC882_FIXUP_GPIO3,
Takashi Iwai68ef0562011-11-09 18:24:44 +01001831 ALC889_FIXUP_COEF,
1832 ALC882_FIXUP_ASUS_W2JC,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001833 ALC882_FIXUP_ACER_ASPIRE_4930G,
1834 ALC882_FIXUP_ACER_ASPIRE_8930G,
1835 ALC882_FIXUP_ASPIRE_8930G_VERBS,
Takashi Iwai56710872011-11-14 17:42:11 +01001836 ALC885_FIXUP_MACPRO_GPIO,
Takashi Iwai02a237b2012-02-13 15:25:07 +01001837 ALC889_FIXUP_DAC_ROUTE,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001838 ALC889_FIXUP_MBP_VREF,
1839 ALC889_FIXUP_IMAC91_VREF,
Adrien Vergée7729a42014-01-24 14:56:14 -05001840 ALC889_FIXUP_MBA11_VREF,
Takashi Iwai0756f092013-12-04 13:59:45 +01001841 ALC889_FIXUP_MBA21_VREF,
Takashi Iwaic20f31e2014-02-03 11:02:10 +01001842 ALC889_FIXUP_MP11_VREF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02001843 ALC882_FIXUP_INV_DMIC,
Takashi Iwaie427c232012-07-29 10:04:08 +02001844 ALC882_FIXUP_NO_PRIMARY_HP,
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01001845 ALC887_FIXUP_ASUS_BASS,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01001846 ALC887_FIXUP_BASS_CHMAP,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001847};
1848
Takashi Iwai68ef0562011-11-09 18:24:44 +01001849static void alc889_fixup_coef(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001850 const struct hda_fixup *fix, int action)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001851{
Takashi Iwai1727a772013-01-10 09:52:52 +01001852 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001853 return;
1854 alc889_coef_init(codec);
1855}
1856
Takashi Iwai56710872011-11-14 17:42:11 +01001857/* toggle speaker-output according to the hp-jack state */
1858static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1859{
1860 unsigned int gpiostate, gpiomask, gpiodir;
1861
1862 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1863 AC_VERB_GET_GPIO_DATA, 0);
1864
1865 if (!muted)
1866 gpiostate |= (1 << pin);
1867 else
1868 gpiostate &= ~(1 << pin);
1869
1870 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1871 AC_VERB_GET_GPIO_MASK, 0);
1872 gpiomask |= (1 << pin);
1873
1874 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1875 AC_VERB_GET_GPIO_DIRECTION, 0);
1876 gpiodir |= (1 << pin);
1877
1878
1879 snd_hda_codec_write(codec, codec->afg, 0,
1880 AC_VERB_SET_GPIO_MASK, gpiomask);
1881 snd_hda_codec_write(codec, codec->afg, 0,
1882 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1883
1884 msleep(1);
1885
1886 snd_hda_codec_write(codec, codec->afg, 0,
1887 AC_VERB_SET_GPIO_DATA, gpiostate);
1888}
1889
1890/* set up GPIO at initialization */
1891static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001892 const struct hda_fixup *fix, int action)
Takashi Iwai56710872011-11-14 17:42:11 +01001893{
Takashi Iwai1727a772013-01-10 09:52:52 +01001894 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai56710872011-11-14 17:42:11 +01001895 return;
1896 alc882_gpio_mute(codec, 0, 0);
1897 alc882_gpio_mute(codec, 1, 0);
1898}
1899
Takashi Iwai02a237b2012-02-13 15:25:07 +01001900/* Fix the connection of some pins for ALC889:
1901 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1902 * work correctly (bko#42740)
1903 */
1904static void alc889_fixup_dac_route(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001905 const struct hda_fixup *fix, int action)
Takashi Iwai02a237b2012-02-13 15:25:07 +01001906{
Takashi Iwai1727a772013-01-10 09:52:52 +01001907 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001908 /* fake the connections during parsing the tree */
Takashi Iwai02a237b2012-02-13 15:25:07 +01001909 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1910 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1911 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1912 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1913 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1914 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
Takashi Iwai1727a772013-01-10 09:52:52 +01001915 } else if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001916 /* restore the connections */
1917 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1918 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1919 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1920 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1921 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
Takashi Iwai02a237b2012-02-13 15:25:07 +01001922 }
1923}
1924
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001925/* Set VREF on HP pin */
1926static void alc889_fixup_mbp_vref(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001927 const struct hda_fixup *fix, int action)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001928{
1929 struct alc_spec *spec = codec->spec;
1930 static hda_nid_t nids[2] = { 0x14, 0x15 };
1931 int i;
1932
Takashi Iwai1727a772013-01-10 09:52:52 +01001933 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001934 return;
1935 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1936 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1937 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1938 continue;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001939 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001940 val |= AC_PINCTL_VREF_80;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001941 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01001942 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001943 break;
1944 }
1945}
1946
Takashi Iwai0756f092013-12-04 13:59:45 +01001947static void alc889_fixup_mac_pins(struct hda_codec *codec,
1948 const hda_nid_t *nids, int num_nids)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001949{
1950 struct alc_spec *spec = codec->spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001951 int i;
1952
Takashi Iwai0756f092013-12-04 13:59:45 +01001953 for (i = 0; i < num_nids; i++) {
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001954 unsigned int val;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001955 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001956 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001957 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001958 }
Takashi Iwai08c189f2012-12-19 15:22:24 +01001959 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001960}
1961
Takashi Iwai0756f092013-12-04 13:59:45 +01001962/* Set VREF on speaker pins on imac91 */
1963static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1964 const struct hda_fixup *fix, int action)
1965{
1966 static hda_nid_t nids[2] = { 0x18, 0x1a };
1967
1968 if (action == HDA_FIXUP_ACT_INIT)
1969 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1970}
1971
Adrien Vergée7729a42014-01-24 14:56:14 -05001972/* Set VREF on speaker pins on mba11 */
1973static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1974 const struct hda_fixup *fix, int action)
1975{
1976 static hda_nid_t nids[1] = { 0x18 };
1977
1978 if (action == HDA_FIXUP_ACT_INIT)
1979 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1980}
1981
Takashi Iwai0756f092013-12-04 13:59:45 +01001982/* Set VREF on speaker pins on mba21 */
1983static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1984 const struct hda_fixup *fix, int action)
1985{
1986 static hda_nid_t nids[2] = { 0x18, 0x19 };
1987
1988 if (action == HDA_FIXUP_ACT_INIT)
1989 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1990}
1991
Takashi Iwaie427c232012-07-29 10:04:08 +02001992/* Don't take HP output as primary
Fernando Luis Vázquez Caod9111492013-02-12 16:49:46 +09001993 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1994 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
Takashi Iwaie427c232012-07-29 10:04:08 +02001995 */
1996static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001997 const struct hda_fixup *fix, int action)
Takashi Iwaie427c232012-07-29 10:04:08 +02001998{
1999 struct alc_spec *spec = codec->spec;
Takashi Iwaida96fb52013-07-29 16:54:36 +02002000 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08c189f2012-12-19 15:22:24 +01002001 spec->gen.no_primary_hp = 1;
Takashi Iwaida96fb52013-07-29 16:54:36 +02002002 spec->gen.no_multi_io = 1;
2003 }
Takashi Iwaie427c232012-07-29 10:04:08 +02002004}
2005
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01002006static void alc_fixup_bass_chmap(struct hda_codec *codec,
2007 const struct hda_fixup *fix, int action);
2008
Takashi Iwai1727a772013-01-10 09:52:52 +01002009static const struct hda_fixup alc882_fixups[] = {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002010 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002011 .type = HDA_FIXUP_PINS,
2012 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002013 { 0x15, 0x01080104 }, /* side */
2014 { 0x16, 0x01011012 }, /* rear */
2015 { 0x17, 0x01016011 }, /* clfe */
2016 { }
2017 }
2018 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002019 [ALC882_FIXUP_LENOVO_Y530] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002020 .type = HDA_FIXUP_PINS,
2021 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002022 { 0x15, 0x99130112 }, /* rear int speakers */
2023 { 0x16, 0x99130111 }, /* subwoofer */
2024 { }
2025 }
2026 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002027 [ALC882_FIXUP_PB_M5210] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002028 .type = HDA_FIXUP_PINCTLS,
2029 .v.pins = (const struct hda_pintbl[]) {
2030 { 0x19, PIN_VREF50 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002031 {}
2032 }
2033 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002034 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002035 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02002036 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002037 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002038 [ALC882_FIXUP_ASUS_W90V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002039 .type = HDA_FIXUP_PINS,
2040 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5cdf7452011-10-26 23:04:08 +02002041 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2042 { }
2043 }
2044 },
Marton Balint8f239212012-03-05 21:33:23 +01002045 [ALC889_FIXUP_CD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002046 .type = HDA_FIXUP_PINS,
2047 .v.pins = (const struct hda_pintbl[]) {
Marton Balint8f239212012-03-05 21:33:23 +01002048 { 0x1c, 0x993301f0 }, /* CD */
2049 { }
2050 }
2051 },
David Henningssonb2c53e22014-01-01 14:01:34 +01002052 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2053 .type = HDA_FIXUP_PINS,
2054 .v.pins = (const struct hda_pintbl[]) {
2055 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2056 { }
2057 },
2058 .chained = true,
2059 .chain_id = ALC889_FIXUP_CD,
2060 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002061 [ALC889_FIXUP_VAIO_TT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002062 .type = HDA_FIXUP_PINS,
2063 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002064 { 0x17, 0x90170111 }, /* hidden surround speaker */
2065 { }
2066 }
2067 },
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002068 [ALC888_FIXUP_EEE1601] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002069 .type = HDA_FIXUP_VERBS,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002070 .v.verbs = (const struct hda_verb[]) {
2071 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2072 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2073 { }
2074 }
Takashi Iwai177943a32011-11-09 12:55:18 +01002075 },
2076 [ALC882_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002077 .type = HDA_FIXUP_VERBS,
Takashi Iwai177943a32011-11-09 12:55:18 +01002078 .v.verbs = (const struct hda_verb[]) {
2079 /* change to EAPD mode */
2080 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2081 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2082 { }
2083 }
2084 },
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002085 [ALC883_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002086 .type = HDA_FIXUP_VERBS,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002087 .v.verbs = (const struct hda_verb[]) {
2088 /* change to EAPD mode */
2089 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2090 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2091 { }
2092 }
2093 },
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002094 [ALC883_FIXUP_ACER_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002095 .type = HDA_FIXUP_VERBS,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002096 .v.verbs = (const struct hda_verb[]) {
2097 /* eanable EAPD on Acer laptops */
2098 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2099 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2100 { }
2101 }
2102 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002103 [ALC882_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002104 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002105 .v.verbs = alc_gpio1_init_verbs,
2106 },
2107 [ALC882_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002108 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002109 .v.verbs = alc_gpio2_init_verbs,
2110 },
Takashi Iwaieb844d52011-11-09 18:03:07 +01002111 [ALC882_FIXUP_GPIO3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002112 .type = HDA_FIXUP_VERBS,
Takashi Iwaieb844d52011-11-09 18:03:07 +01002113 .v.verbs = alc_gpio3_init_verbs,
2114 },
Takashi Iwai68ef0562011-11-09 18:24:44 +01002115 [ALC882_FIXUP_ASUS_W2JC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002116 .type = HDA_FIXUP_VERBS,
Takashi Iwai68ef0562011-11-09 18:24:44 +01002117 .v.verbs = alc_gpio1_init_verbs,
2118 .chained = true,
2119 .chain_id = ALC882_FIXUP_EAPD,
2120 },
2121 [ALC889_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002122 .type = HDA_FIXUP_FUNC,
Takashi Iwai68ef0562011-11-09 18:24:44 +01002123 .v.func = alc889_fixup_coef,
2124 },
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002125 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002126 .type = HDA_FIXUP_PINS,
2127 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002128 { 0x16, 0x99130111 }, /* CLFE speaker */
2129 { 0x17, 0x99130112 }, /* surround speaker */
2130 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02002131 },
2132 .chained = true,
2133 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002134 },
2135 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002136 .type = HDA_FIXUP_PINS,
2137 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002138 { 0x16, 0x99130111 }, /* CLFE speaker */
2139 { 0x1b, 0x99130112 }, /* surround speaker */
2140 { }
2141 },
2142 .chained = true,
2143 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2144 },
2145 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2146 /* additional init verbs for Acer Aspire 8930G */
Takashi Iwai1727a772013-01-10 09:52:52 +01002147 .type = HDA_FIXUP_VERBS,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002148 .v.verbs = (const struct hda_verb[]) {
2149 /* Enable all DACs */
2150 /* DAC DISABLE/MUTE 1? */
2151 /* setting bits 1-5 disables DAC nids 0x02-0x06
2152 * apparently. Init=0x38 */
2153 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2154 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2155 /* DAC DISABLE/MUTE 2? */
2156 /* some bit here disables the other DACs.
2157 * Init=0x4900 */
2158 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2159 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2160 /* DMIC fix
2161 * This laptop has a stereo digital microphone.
2162 * The mics are only 1cm apart which makes the stereo
2163 * useless. However, either the mic or the ALC889
2164 * makes the signal become a difference/sum signal
2165 * instead of standard stereo, which is annoying.
2166 * So instead we flip this bit which makes the
2167 * codec replicate the sum signal to both channels,
2168 * turning it into a normal mono mic.
2169 */
2170 /* DMIC_CONTROL? Init value = 0x0001 */
2171 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2172 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2173 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2174 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2175 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02002176 },
2177 .chained = true,
2178 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002179 },
Takashi Iwai56710872011-11-14 17:42:11 +01002180 [ALC885_FIXUP_MACPRO_GPIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002181 .type = HDA_FIXUP_FUNC,
Takashi Iwai56710872011-11-14 17:42:11 +01002182 .v.func = alc885_fixup_macpro_gpio,
2183 },
Takashi Iwai02a237b2012-02-13 15:25:07 +01002184 [ALC889_FIXUP_DAC_ROUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002185 .type = HDA_FIXUP_FUNC,
Takashi Iwai02a237b2012-02-13 15:25:07 +01002186 .v.func = alc889_fixup_dac_route,
2187 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002188 [ALC889_FIXUP_MBP_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002189 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002190 .v.func = alc889_fixup_mbp_vref,
2191 .chained = true,
2192 .chain_id = ALC882_FIXUP_GPIO1,
2193 },
2194 [ALC889_FIXUP_IMAC91_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002195 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002196 .v.func = alc889_fixup_imac91_vref,
2197 .chained = true,
2198 .chain_id = ALC882_FIXUP_GPIO1,
2199 },
Adrien Vergée7729a42014-01-24 14:56:14 -05002200 [ALC889_FIXUP_MBA11_VREF] = {
2201 .type = HDA_FIXUP_FUNC,
2202 .v.func = alc889_fixup_mba11_vref,
2203 .chained = true,
2204 .chain_id = ALC889_FIXUP_MBP_VREF,
2205 },
Takashi Iwai0756f092013-12-04 13:59:45 +01002206 [ALC889_FIXUP_MBA21_VREF] = {
2207 .type = HDA_FIXUP_FUNC,
2208 .v.func = alc889_fixup_mba21_vref,
2209 .chained = true,
2210 .chain_id = ALC889_FIXUP_MBP_VREF,
2211 },
Takashi Iwaic20f31e2014-02-03 11:02:10 +01002212 [ALC889_FIXUP_MP11_VREF] = {
2213 .type = HDA_FIXUP_FUNC,
2214 .v.func = alc889_fixup_mba11_vref,
2215 .chained = true,
2216 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2217 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002218 [ALC882_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002219 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002220 .v.func = alc_fixup_inv_dmic_0x12,
2221 },
Takashi Iwaie427c232012-07-29 10:04:08 +02002222 [ALC882_FIXUP_NO_PRIMARY_HP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002223 .type = HDA_FIXUP_FUNC,
Takashi Iwaie427c232012-07-29 10:04:08 +02002224 .v.func = alc882_fixup_no_primary_hp,
2225 },
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002226 [ALC887_FIXUP_ASUS_BASS] = {
2227 .type = HDA_FIXUP_PINS,
2228 .v.pins = (const struct hda_pintbl[]) {
2229 {0x16, 0x99130130}, /* bass speaker */
2230 {}
2231 },
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01002232 .chained = true,
2233 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2234 },
2235 [ALC887_FIXUP_BASS_CHMAP] = {
2236 .type = HDA_FIXUP_FUNC,
2237 .v.func = alc_fixup_bass_chmap,
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002238 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002239};
2240
2241static const struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002242 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2243 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2244 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2245 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2246 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2247 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002248 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2249 ALC882_FIXUP_ACER_ASPIRE_4930G),
2250 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2251 ALC882_FIXUP_ACER_ASPIRE_4930G),
2252 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2253 ALC882_FIXUP_ACER_ASPIRE_8930G),
2254 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2255 ALC882_FIXUP_ACER_ASPIRE_8930G),
2256 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2257 ALC882_FIXUP_ACER_ASPIRE_4930G),
2258 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2259 ALC882_FIXUP_ACER_ASPIRE_4930G),
2260 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2261 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002262 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
Takashi Iwaif5c53d82012-05-07 10:07:33 +02002263 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2264 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai02a237b2012-02-13 15:25:07 +01002265 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
Takashi Iwaife97da12012-04-12 08:00:19 +02002266 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002267 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
Takashi Iwai177943a32011-11-09 12:55:18 +01002268 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002269 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002270 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002271 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002272 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002273 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
Takashi Iwaie427c232012-07-29 10:04:08 +02002274 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
Fernando Luis Vázquez Cao12e31a72013-02-12 16:47:44 +09002275 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
Takashi Iwai56710872011-11-14 17:42:11 +01002276
2277 /* All Apple entries are in codec SSIDs */
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002278 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2279 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2280 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
Takashi Iwaic20f31e2014-02-03 11:02:10 +01002281 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002282 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2283 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002284 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2285 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002286 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
Adrien Vergée7729a42014-01-24 14:56:14 -05002287 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
Takashi Iwai0756f092013-12-04 13:59:45 +01002288 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002289 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2290 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002291 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002292 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2293 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2294 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
Josh Boyer29ebe402012-04-12 13:55:36 -04002295 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai05193632012-11-12 10:07:36 +01002296 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002297 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2298 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2299 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002300
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002301 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
Takashi Iwaibca40132012-05-07 11:13:14 +02002302 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Takashi Iwaieb844d52011-11-09 18:03:07 +01002303 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
David Henningssonb2c53e22014-01-01 14:01:34 +01002304 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002305 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002306 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2307 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002308 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002309 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002310 {}
2311};
2312
Takashi Iwai1727a772013-01-10 09:52:52 +01002313static const struct hda_model_fixup alc882_fixup_models[] = {
Takashi Iwai912093b2012-04-11 14:03:41 +02002314 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2315 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2316 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002317 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaie427c232012-07-29 10:04:08 +02002318 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
Takashi Iwai912093b2012-04-11 14:03:41 +02002319 {}
2320};
2321
Takashi Iwai1d045db2011-07-07 18:23:21 +02002322/*
2323 * BIOS auto configuration
2324 */
2325/* almost identical with ALC880 parser... */
2326static int alc882_parse_auto_config(struct hda_codec *codec)
2327{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002328 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002329 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2330 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002331}
2332
Takashi Iwai1d045db2011-07-07 18:23:21 +02002333/*
2334 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002335static int patch_alc882(struct hda_codec *codec)
2336{
2337 struct alc_spec *spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002338 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002339
Takashi Iwai3de95172012-05-07 18:03:15 +02002340 err = alc_alloc_spec(codec, 0x0b);
2341 if (err < 0)
2342 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002343
Takashi Iwai3de95172012-05-07 18:03:15 +02002344 spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002345
2346 switch (codec->vendor_id) {
2347 case 0x10ec0882:
2348 case 0x10ec0885:
2349 break;
2350 default:
2351 /* ALC883 and variants */
2352 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2353 break;
2354 }
2355
Takashi Iwai1727a772013-01-10 09:52:52 +01002356 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
Takashi Iwai912093b2012-04-11 14:03:41 +02002357 alc882_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002358 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002359
2360 alc_auto_parse_customize_define(codec);
2361
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002362 if (has_cdefine_beep(codec))
2363 spec->gen.beep_nid = 0x01;
2364
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002365 /* automatic parse from the BIOS config */
2366 err = alc882_parse_auto_config(codec);
2367 if (err < 0)
2368 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002369
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002370 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002371 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2372
Takashi Iwai1d045db2011-07-07 18:23:21 +02002373 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002374
Takashi Iwai1727a772013-01-10 09:52:52 +01002375 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002376
Takashi Iwai1d045db2011-07-07 18:23:21 +02002377 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002378
2379 error:
2380 alc_free(codec);
2381 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002382}
2383
2384
2385/*
2386 * ALC262 support
2387 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002388static int alc262_parse_auto_config(struct hda_codec *codec)
2389{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002390 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002391 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2392 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002393}
2394
2395/*
2396 * Pin config fixes
2397 */
2398enum {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002399 ALC262_FIXUP_FSC_H270,
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002400 ALC262_FIXUP_FSC_S7110,
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002401 ALC262_FIXUP_HP_Z200,
2402 ALC262_FIXUP_TYAN,
Takashi Iwaic4701502011-11-07 14:20:07 +01002403 ALC262_FIXUP_LENOVO_3000,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002404 ALC262_FIXUP_BENQ,
2405 ALC262_FIXUP_BENQ_T31,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002406 ALC262_FIXUP_INV_DMIC,
Mengdong Linb5c66112013-11-29 00:35:35 -05002407 ALC262_FIXUP_INTEL_BAYLEYBAY,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002408};
2409
Takashi Iwai1727a772013-01-10 09:52:52 +01002410static const struct hda_fixup alc262_fixups[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002411 [ALC262_FIXUP_FSC_H270] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002412 .type = HDA_FIXUP_PINS,
2413 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002414 { 0x14, 0x99130110 }, /* speaker */
2415 { 0x15, 0x0221142f }, /* front HP */
2416 { 0x1b, 0x0121141f }, /* rear HP */
2417 { }
2418 }
2419 },
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002420 [ALC262_FIXUP_FSC_S7110] = {
2421 .type = HDA_FIXUP_PINS,
2422 .v.pins = (const struct hda_pintbl[]) {
2423 { 0x15, 0x90170110 }, /* speaker */
2424 { }
2425 },
2426 .chained = true,
2427 .chain_id = ALC262_FIXUP_BENQ,
2428 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002429 [ALC262_FIXUP_HP_Z200] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002430 .type = HDA_FIXUP_PINS,
2431 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002432 { 0x16, 0x99130120 }, /* internal speaker */
2433 { }
2434 }
2435 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002436 [ALC262_FIXUP_TYAN] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002437 .type = HDA_FIXUP_PINS,
2438 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002439 { 0x14, 0x1993e1f0 }, /* int AUX */
2440 { }
2441 }
2442 },
Takashi Iwaic4701502011-11-07 14:20:07 +01002443 [ALC262_FIXUP_LENOVO_3000] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002444 .type = HDA_FIXUP_PINCTLS,
2445 .v.pins = (const struct hda_pintbl[]) {
2446 { 0x19, PIN_VREF50 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002447 {}
2448 },
2449 .chained = true,
2450 .chain_id = ALC262_FIXUP_BENQ,
2451 },
2452 [ALC262_FIXUP_BENQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002453 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002454 .v.verbs = (const struct hda_verb[]) {
Takashi Iwaic4701502011-11-07 14:20:07 +01002455 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2456 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2457 {}
2458 }
2459 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002460 [ALC262_FIXUP_BENQ_T31] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002461 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002462 .v.verbs = (const struct hda_verb[]) {
2463 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2464 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2465 {}
2466 }
2467 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002468 [ALC262_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002469 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002470 .v.func = alc_fixup_inv_dmic_0x12,
2471 },
Mengdong Linb5c66112013-11-29 00:35:35 -05002472 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2473 .type = HDA_FIXUP_FUNC,
2474 .v.func = alc_fixup_no_depop_delay,
2475 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002476};
2477
2478static const struct snd_pci_quirk alc262_fixup_tbl[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002479 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002480 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
Takashi Iwai3dcd3be2011-11-07 14:59:40 +01002481 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002482 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2483 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
Takashi Iwaic4701502011-11-07 14:20:07 +01002484 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
Takashi Iwaib42590b2011-11-07 14:41:01 +01002485 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2486 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
Mengdong Linb5c66112013-11-29 00:35:35 -05002487 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002488 {}
2489};
2490
Takashi Iwai1727a772013-01-10 09:52:52 +01002491static const struct hda_model_fixup alc262_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002492 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2493 {}
2494};
Takashi Iwai1d045db2011-07-07 18:23:21 +02002495
Takashi Iwai1d045db2011-07-07 18:23:21 +02002496/*
2497 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002498static int patch_alc262(struct hda_codec *codec)
2499{
2500 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002501 int err;
2502
Takashi Iwai3de95172012-05-07 18:03:15 +02002503 err = alc_alloc_spec(codec, 0x0b);
2504 if (err < 0)
2505 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002506
Takashi Iwai3de95172012-05-07 18:03:15 +02002507 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01002508 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002509
2510#if 0
2511 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2512 * under-run
2513 */
Takashi Iwai98b24882014-08-18 13:47:50 +02002514 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002515#endif
Takashi Iwai1d045db2011-07-07 18:23:21 +02002516 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2517
Takashi Iwai1727a772013-01-10 09:52:52 +01002518 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002519 alc262_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002520 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002521
Takashi Iwaiaf741c12012-05-07 18:09:48 +02002522 alc_auto_parse_customize_define(codec);
2523
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002524 if (has_cdefine_beep(codec))
2525 spec->gen.beep_nid = 0x01;
2526
Takashi Iwai42399f72011-11-07 17:18:44 +01002527 /* automatic parse from the BIOS config */
2528 err = alc262_parse_auto_config(codec);
2529 if (err < 0)
2530 goto error;
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002531
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002532 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002533 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2534
Takashi Iwai1d045db2011-07-07 18:23:21 +02002535 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002536 spec->shutup = alc_eapd_shutup;
2537
Takashi Iwai1727a772013-01-10 09:52:52 +01002538 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002539
Takashi Iwai1d045db2011-07-07 18:23:21 +02002540 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002541
2542 error:
2543 alc_free(codec);
2544 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002545}
2546
2547/*
2548 * ALC268
2549 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002550/* bind Beep switches of both NID 0x0f and 0x10 */
2551static const struct hda_bind_ctls alc268_bind_beep_sw = {
2552 .ops = &snd_hda_bind_sw,
2553 .values = {
2554 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2555 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2556 0
2557 },
2558};
2559
2560static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2561 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2562 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2563 { }
2564};
2565
2566/* set PCBEEP vol = 0, mute connections */
2567static const struct hda_verb alc268_beep_init_verbs[] = {
2568 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2569 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2570 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2571 { }
2572};
2573
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002574enum {
2575 ALC268_FIXUP_INV_DMIC,
Takashi Iwaicb766402012-10-20 10:55:21 +02002576 ALC268_FIXUP_HP_EAPD,
Takashi Iwai24eff322013-11-04 18:21:08 +01002577 ALC268_FIXUP_SPDIF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002578};
2579
Takashi Iwai1727a772013-01-10 09:52:52 +01002580static const struct hda_fixup alc268_fixups[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002581 [ALC268_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002582 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002583 .v.func = alc_fixup_inv_dmic_0x12,
2584 },
Takashi Iwaicb766402012-10-20 10:55:21 +02002585 [ALC268_FIXUP_HP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002586 .type = HDA_FIXUP_VERBS,
Takashi Iwaicb766402012-10-20 10:55:21 +02002587 .v.verbs = (const struct hda_verb[]) {
2588 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2589 {}
2590 }
2591 },
Takashi Iwai24eff322013-11-04 18:21:08 +01002592 [ALC268_FIXUP_SPDIF] = {
2593 .type = HDA_FIXUP_PINS,
2594 .v.pins = (const struct hda_pintbl[]) {
2595 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2596 {}
2597 }
2598 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002599};
2600
Takashi Iwai1727a772013-01-10 09:52:52 +01002601static const struct hda_model_fixup alc268_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002602 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaicb766402012-10-20 10:55:21 +02002603 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2604 {}
2605};
2606
2607static const struct snd_pci_quirk alc268_fixup_tbl[] = {
Takashi Iwai24eff322013-11-04 18:21:08 +01002608 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
David Henningssonfcd8f3b2013-01-28 05:45:47 +01002609 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
Takashi Iwaicb766402012-10-20 10:55:21 +02002610 /* below is codec SSID since multiple Toshiba laptops have the
2611 * same PCI SSID 1179:ff00
2612 */
2613 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002614 {}
2615};
2616
Takashi Iwai1d045db2011-07-07 18:23:21 +02002617/*
2618 * BIOS auto configuration
2619 */
2620static int alc268_parse_auto_config(struct hda_codec *codec)
2621{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002622 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002623 return alc_parse_auto_config(codec, NULL, alc268_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002624}
2625
Takashi Iwai1d045db2011-07-07 18:23:21 +02002626/*
2627 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002628static int patch_alc268(struct hda_codec *codec)
2629{
2630 struct alc_spec *spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002631 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002632
Takashi Iwai1d045db2011-07-07 18:23:21 +02002633 /* ALC268 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02002634 err = alc_alloc_spec(codec, 0);
2635 if (err < 0)
2636 return err;
2637
2638 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002639 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002640
Takashi Iwai1727a772013-01-10 09:52:52 +01002641 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2642 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002643
Takashi Iwai6ebb8052011-08-16 15:15:40 +02002644 /* automatic parse from the BIOS config */
2645 err = alc268_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002646 if (err < 0)
2647 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002648
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002649 if (err > 0 && !spec->gen.no_analog &&
2650 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2651 add_mixer(spec, alc268_beep_mixer);
2652 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002653 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2654 /* override the amp caps for beep generator */
2655 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2656 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2657 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2658 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2659 (0 << AC_AMPCAP_MUTE_SHIFT));
2660 }
2661
Takashi Iwai1d045db2011-07-07 18:23:21 +02002662 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002663 spec->shutup = alc_eapd_shutup;
2664
Takashi Iwai1727a772013-01-10 09:52:52 +01002665 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002666
Takashi Iwai1d045db2011-07-07 18:23:21 +02002667 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002668
2669 error:
2670 alc_free(codec);
2671 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002672}
2673
2674/*
2675 * ALC269
2676 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01002677
2678static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2679 struct hda_codec *codec,
2680 struct snd_pcm_substream *substream)
2681{
2682 struct hda_gen_spec *spec = codec->spec;
2683 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2684 hinfo);
2685}
2686
2687static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2688 struct hda_codec *codec,
2689 unsigned int stream_tag,
2690 unsigned int format,
2691 struct snd_pcm_substream *substream)
2692{
2693 struct hda_gen_spec *spec = codec->spec;
2694 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2695 stream_tag, format, substream);
2696}
2697
2698static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2699 struct hda_codec *codec,
2700 struct snd_pcm_substream *substream)
2701{
2702 struct hda_gen_spec *spec = codec->spec;
2703 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2704}
2705
Takashi Iwai1d045db2011-07-07 18:23:21 +02002706static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2707 .substreams = 1,
2708 .channels_min = 2,
2709 .channels_max = 8,
2710 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2711 /* NID is set in alc_build_pcms */
2712 .ops = {
Takashi Iwai08c189f2012-12-19 15:22:24 +01002713 .open = playback_pcm_open,
2714 .prepare = playback_pcm_prepare,
2715 .cleanup = playback_pcm_cleanup
Takashi Iwai1d045db2011-07-07 18:23:21 +02002716 },
2717};
2718
2719static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2720 .substreams = 1,
2721 .channels_min = 2,
2722 .channels_max = 2,
2723 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2724 /* NID is set in alc_build_pcms */
2725};
2726
Takashi Iwai1d045db2011-07-07 18:23:21 +02002727/* different alc269-variants */
2728enum {
2729 ALC269_TYPE_ALC269VA,
2730 ALC269_TYPE_ALC269VB,
2731 ALC269_TYPE_ALC269VC,
Kailang Yangadcc70b2012-05-25 08:08:38 +02002732 ALC269_TYPE_ALC269VD,
Kailang Yang065380f2013-01-10 10:25:48 +01002733 ALC269_TYPE_ALC280,
2734 ALC269_TYPE_ALC282,
Kailang Yang2af02be2013-08-22 10:03:50 +02002735 ALC269_TYPE_ALC283,
Kailang Yang065380f2013-01-10 10:25:48 +01002736 ALC269_TYPE_ALC284,
Kailang Yang161ebf22013-10-24 11:36:33 +02002737 ALC269_TYPE_ALC285,
Kailang Yang7fc7d042013-04-25 11:04:43 +02002738 ALC269_TYPE_ALC286,
Kailang Yang1d04c9d2013-10-24 11:35:18 +02002739 ALC269_TYPE_ALC255,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002740};
2741
2742/*
2743 * BIOS auto configuration
2744 */
2745static int alc269_parse_auto_config(struct hda_codec *codec)
2746{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002747 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002748 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2749 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2750 struct alc_spec *spec = codec->spec;
Kailang Yangadcc70b2012-05-25 08:08:38 +02002751 const hda_nid_t *ssids;
2752
2753 switch (spec->codec_variant) {
2754 case ALC269_TYPE_ALC269VA:
2755 case ALC269_TYPE_ALC269VC:
Kailang Yang065380f2013-01-10 10:25:48 +01002756 case ALC269_TYPE_ALC280:
2757 case ALC269_TYPE_ALC284:
Kailang Yang161ebf22013-10-24 11:36:33 +02002758 case ALC269_TYPE_ALC285:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002759 ssids = alc269va_ssids;
2760 break;
2761 case ALC269_TYPE_ALC269VB:
2762 case ALC269_TYPE_ALC269VD:
Kailang Yang065380f2013-01-10 10:25:48 +01002763 case ALC269_TYPE_ALC282:
Kailang Yang2af02be2013-08-22 10:03:50 +02002764 case ALC269_TYPE_ALC283:
Kailang Yang7fc7d042013-04-25 11:04:43 +02002765 case ALC269_TYPE_ALC286:
Kailang Yang1d04c9d2013-10-24 11:35:18 +02002766 case ALC269_TYPE_ALC255:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002767 ssids = alc269_ssids;
2768 break;
2769 default:
2770 ssids = alc269_ssids;
2771 break;
2772 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02002773
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002774 return alc_parse_auto_config(codec, alc269_ignore, ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002775}
2776
Kailang Yangf7ae9ba2014-06-30 16:10:37 +08002777static int find_ext_mic_pin(struct hda_codec *codec);
2778
2779static void alc286_shutup(struct hda_codec *codec)
2780{
2781 int i;
2782 int mic_pin = find_ext_mic_pin(codec);
2783 /* don't shut up pins when unloading the driver; otherwise it breaks
2784 * the default pin setup at the next load of the driver
2785 */
2786 if (codec->bus->shutdown)
2787 return;
2788 for (i = 0; i < codec->init_pins.used; i++) {
2789 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
2790 /* use read here for syncing after issuing each verb */
2791 if (pin->nid != mic_pin)
2792 snd_hda_codec_read(codec, pin->nid, 0,
2793 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2794 }
2795 codec->pins_shutup = 1;
2796}
2797
Kailang Yang1387e2d2012-11-08 10:23:18 +01002798static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002799{
Takashi Iwai98b24882014-08-18 13:47:50 +02002800 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002801}
2802
2803static void alc269_shutup(struct hda_codec *codec)
2804{
Kailang Yangadcc70b2012-05-25 08:08:38 +02002805 struct alc_spec *spec = codec->spec;
2806
Kailang Yang1387e2d2012-11-08 10:23:18 +01002807 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2808 alc269vb_toggle_power_output(codec, 0);
2809 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2810 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002811 msleep(150);
2812 }
Takashi Iwai9bfb2842013-07-24 14:31:50 +02002813 snd_hda_shutup_pins(codec);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002814}
2815
Takashi Iwai54db6c32014-08-18 15:11:19 +02002816static struct coef_fw alc282_coefs[] = {
2817 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2818 WRITE_COEF(0x05, 0x0700), /* FIFO and filter clock */
2819 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2820 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2821 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2822 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2823 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2824 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2825 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2826 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2827 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2828 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2829 WRITE_COEF(0x34, 0xa0c0), /* ANC */
2830 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2831 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2832 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2833 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2834 WRITE_COEF(0x63, 0x2902), /* PLL */
2835 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2836 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2837 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2838 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2839 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2840 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2841 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2842 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2843 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2844 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2845 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2846 {}
2847};
2848
Kailang Yangcb149cb2014-03-18 16:45:32 +08002849static void alc282_restore_default_value(struct hda_codec *codec)
2850{
Takashi Iwai54db6c32014-08-18 15:11:19 +02002851 alc_process_coef_fw(codec, alc282_coefs);
Kailang Yangcb149cb2014-03-18 16:45:32 +08002852}
2853
Kailang Yang7b5c7a02014-03-18 16:15:54 +08002854static void alc282_init(struct hda_codec *codec)
2855{
2856 struct alc_spec *spec = codec->spec;
2857 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2858 bool hp_pin_sense;
2859 int coef78;
2860
Kailang Yangcb149cb2014-03-18 16:45:32 +08002861 alc282_restore_default_value(codec);
2862
Kailang Yang7b5c7a02014-03-18 16:15:54 +08002863 if (!hp_pin)
2864 return;
2865 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2866 coef78 = alc_read_coef_idx(codec, 0x78);
2867
2868 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2869 /* Headphone capless set to high power mode */
2870 alc_write_coef_idx(codec, 0x78, 0x9004);
2871
2872 if (hp_pin_sense)
2873 msleep(2);
2874
2875 snd_hda_codec_write(codec, hp_pin, 0,
2876 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2877
2878 if (hp_pin_sense)
2879 msleep(85);
2880
2881 snd_hda_codec_write(codec, hp_pin, 0,
2882 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2883
2884 if (hp_pin_sense)
2885 msleep(100);
2886
2887 /* Headphone capless set to normal mode */
2888 alc_write_coef_idx(codec, 0x78, coef78);
2889}
2890
2891static void alc282_shutup(struct hda_codec *codec)
2892{
2893 struct alc_spec *spec = codec->spec;
2894 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2895 bool hp_pin_sense;
2896 int coef78;
2897
2898 if (!hp_pin) {
2899 alc269_shutup(codec);
2900 return;
2901 }
2902
2903 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2904 coef78 = alc_read_coef_idx(codec, 0x78);
2905 alc_write_coef_idx(codec, 0x78, 0x9004);
2906
2907 if (hp_pin_sense)
2908 msleep(2);
2909
2910 snd_hda_codec_write(codec, hp_pin, 0,
2911 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2912
2913 if (hp_pin_sense)
2914 msleep(85);
2915
2916 snd_hda_codec_write(codec, hp_pin, 0,
2917 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2918
2919 if (hp_pin_sense)
2920 msleep(100);
2921
2922 alc_auto_setup_eapd(codec, false);
2923 snd_hda_shutup_pins(codec);
2924 alc_write_coef_idx(codec, 0x78, coef78);
2925}
2926
Takashi Iwai54db6c32014-08-18 15:11:19 +02002927static struct coef_fw alc283_coefs[] = {
2928 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2929 WRITE_COEF(0x05, 0x0700), /* FIFO and filter clock */
2930 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2931 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2932 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2933 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2934 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2935 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
2936 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2937 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2938 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
2939 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
2940 WRITE_COEF(0x22, 0xa0c0), /* ANC */
2941 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
2942 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2943 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2944 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2945 WRITE_COEF(0x2e, 0x2902), /* PLL */
2946 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
2947 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
2948 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
2949 WRITE_COEF(0x36, 0x0), /* capless control 5 */
2950 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
2951 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
2952 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
2953 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
2954 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
2955 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
2956 WRITE_COEF(0x49, 0x0), /* test mode */
2957 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
2958 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
2959 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
2960 {}
2961};
2962
Kailang Yang6bd55b02014-03-17 13:51:27 +08002963static void alc283_restore_default_value(struct hda_codec *codec)
2964{
Takashi Iwai54db6c32014-08-18 15:11:19 +02002965 alc_process_coef_fw(codec, alc283_coefs);
Kailang Yang6bd55b02014-03-17 13:51:27 +08002966}
2967
Kailang Yang2af02be2013-08-22 10:03:50 +02002968static void alc283_init(struct hda_codec *codec)
2969{
2970 struct alc_spec *spec = codec->spec;
2971 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2972 bool hp_pin_sense;
Kailang Yang2af02be2013-08-22 10:03:50 +02002973
Kailang Yang8314f222014-04-03 17:28:39 +08002974 if (!spec->gen.autocfg.hp_outs) {
2975 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
2976 hp_pin = spec->gen.autocfg.line_out_pins[0];
2977 }
2978
Kailang Yang6bd55b02014-03-17 13:51:27 +08002979 alc283_restore_default_value(codec);
2980
Kailang Yang2af02be2013-08-22 10:03:50 +02002981 if (!hp_pin)
2982 return;
2983 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2984
2985 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
2986 /* Headphone capless set to high power mode */
2987 alc_write_coef_idx(codec, 0x43, 0x9004);
2988
2989 snd_hda_codec_write(codec, hp_pin, 0,
2990 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2991
2992 if (hp_pin_sense)
2993 msleep(85);
2994
2995 snd_hda_codec_write(codec, hp_pin, 0,
2996 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2997
2998 if (hp_pin_sense)
2999 msleep(85);
3000 /* Index 0x46 Combo jack auto switch control 2 */
3001 /* 3k pull low control for Headset jack. */
Takashi Iwai98b24882014-08-18 13:47:50 +02003002 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
Kailang Yang2af02be2013-08-22 10:03:50 +02003003 /* Headphone capless set to normal mode */
3004 alc_write_coef_idx(codec, 0x43, 0x9614);
3005}
3006
3007static void alc283_shutup(struct hda_codec *codec)
3008{
3009 struct alc_spec *spec = codec->spec;
3010 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3011 bool hp_pin_sense;
Kailang Yang2af02be2013-08-22 10:03:50 +02003012
Kailang Yang8314f222014-04-03 17:28:39 +08003013 if (!spec->gen.autocfg.hp_outs) {
3014 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3015 hp_pin = spec->gen.autocfg.line_out_pins[0];
3016 }
3017
Kailang Yang2af02be2013-08-22 10:03:50 +02003018 if (!hp_pin) {
3019 alc269_shutup(codec);
3020 return;
3021 }
3022
3023 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3024
3025 alc_write_coef_idx(codec, 0x43, 0x9004);
3026
3027 snd_hda_codec_write(codec, hp_pin, 0,
3028 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3029
3030 if (hp_pin_sense)
Kailang Yang88011c092013-10-24 15:45:24 +02003031 msleep(100);
Kailang Yang2af02be2013-08-22 10:03:50 +02003032
3033 snd_hda_codec_write(codec, hp_pin, 0,
3034 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3035
Takashi Iwai98b24882014-08-18 13:47:50 +02003036 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
Kailang Yang2af02be2013-08-22 10:03:50 +02003037
3038 if (hp_pin_sense)
Kailang Yang88011c092013-10-24 15:45:24 +02003039 msleep(100);
Kailang Yang0435b3f2014-04-08 17:14:14 +08003040 alc_auto_setup_eapd(codec, false);
Kailang Yang2af02be2013-08-22 10:03:50 +02003041 snd_hda_shutup_pins(codec);
3042 alc_write_coef_idx(codec, 0x43, 0x9614);
3043}
3044
Kailang Yangad60d502013-06-28 12:03:01 +02003045static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3046 unsigned int val)
3047{
3048 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3049 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3050 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3051}
3052
3053static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3054{
3055 unsigned int val;
3056
3057 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3058 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3059 & 0xffff;
3060 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3061 << 16;
3062 return val;
3063}
3064
3065static void alc5505_dsp_halt(struct hda_codec *codec)
3066{
3067 unsigned int val;
3068
3069 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3070 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3071 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3072 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3073 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3074 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3075 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3076 val = alc5505_coef_get(codec, 0x6220);
3077 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3078}
3079
3080static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3081{
3082 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3083 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3084 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3085 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3086 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3087 alc5505_coef_set(codec, 0x880c, 0x00000004);
3088}
3089
3090static void alc5505_dsp_init(struct hda_codec *codec)
3091{
3092 unsigned int val;
3093
3094 alc5505_dsp_halt(codec);
3095 alc5505_dsp_back_from_halt(codec);
3096 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3097 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3098 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3099 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3100 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3101 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3102 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3103 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3104 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3105 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3106 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3107 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3108 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3109
3110 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3111 if (val <= 3)
3112 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3113 else
3114 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3115
3116 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3117 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3118 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3119 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3120 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3121 alc5505_coef_set(codec, 0x880c, 0x00000003);
3122 alc5505_coef_set(codec, 0x880c, 0x00000010);
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003123
3124#ifdef HALT_REALTEK_ALC5505
3125 alc5505_dsp_halt(codec);
3126#endif
Kailang Yangad60d502013-06-28 12:03:01 +02003127}
3128
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003129#ifdef HALT_REALTEK_ALC5505
3130#define alc5505_dsp_suspend(codec) /* NOP */
3131#define alc5505_dsp_resume(codec) /* NOP */
3132#else
3133#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3134#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3135#endif
3136
Takashi Iwai2a439522011-07-26 09:52:50 +02003137#ifdef CONFIG_PM
Kailang Yangad60d502013-06-28 12:03:01 +02003138static int alc269_suspend(struct hda_codec *codec)
3139{
3140 struct alc_spec *spec = codec->spec;
3141
3142 if (spec->has_alc5505_dsp)
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003143 alc5505_dsp_suspend(codec);
Kailang Yangad60d502013-06-28 12:03:01 +02003144 return alc_suspend(codec);
3145}
3146
Takashi Iwai1d045db2011-07-07 18:23:21 +02003147static int alc269_resume(struct hda_codec *codec)
3148{
Kailang Yangadcc70b2012-05-25 08:08:38 +02003149 struct alc_spec *spec = codec->spec;
3150
Kailang Yang1387e2d2012-11-08 10:23:18 +01003151 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3152 alc269vb_toggle_power_output(codec, 0);
3153 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02003154 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003155 msleep(150);
3156 }
3157
3158 codec->patch_ops.init(codec);
3159
Kailang Yang1387e2d2012-11-08 10:23:18 +01003160 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3161 alc269vb_toggle_power_output(codec, 1);
3162 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02003163 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003164 msleep(200);
3165 }
3166
Takashi Iwai1d045db2011-07-07 18:23:21 +02003167 snd_hda_codec_resume_amp(codec);
3168 snd_hda_codec_resume_cache(codec);
Takashi Iwai0623a882013-06-25 09:28:40 +02003169 alc_inv_dmic_sync(codec, true);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003170 hda_call_check_power_status(codec, 0x01);
Hui Wangf4753712014-08-19 12:07:03 +08003171
3172 /* on some machine, the BIOS will clear the codec gpio data when enter
3173 * suspend, and won't restore the data after resume, so we restore it
3174 * in the driver.
3175 */
3176 if (spec->gpio_led)
3177 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA,
3178 spec->gpio_led);
3179
Kailang Yangad60d502013-06-28 12:03:01 +02003180 if (spec->has_alc5505_dsp)
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003181 alc5505_dsp_resume(codec);
Kailang Yangc5177c82013-07-24 14:39:49 +02003182
Takashi Iwai1d045db2011-07-07 18:23:21 +02003183 return 0;
3184}
Takashi Iwai2a439522011-07-26 09:52:50 +02003185#endif /* CONFIG_PM */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003186
David Henningsson108cc102012-07-20 10:37:25 +02003187static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003188 const struct hda_fixup *fix, int action)
David Henningsson108cc102012-07-20 10:37:25 +02003189{
3190 struct alc_spec *spec = codec->spec;
3191
Takashi Iwai1727a772013-01-10 09:52:52 +01003192 if (action == HDA_FIXUP_ACT_PRE_PROBE)
David Henningsson108cc102012-07-20 10:37:25 +02003193 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3194}
3195
Takashi Iwai1d045db2011-07-07 18:23:21 +02003196static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003197 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003198{
Takashi Iwai98b24882014-08-18 13:47:50 +02003199 if (action == HDA_FIXUP_ACT_INIT)
3200 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003201}
3202
David Henningsson7c478f02013-10-11 10:18:46 +02003203static void alc269_fixup_headset_mic(struct hda_codec *codec,
3204 const struct hda_fixup *fix, int action)
3205{
3206 struct alc_spec *spec = codec->spec;
3207
3208 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3209 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3210}
3211
Takashi Iwai1d045db2011-07-07 18:23:21 +02003212static void alc271_fixup_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003213 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003214{
3215 static const struct hda_verb verbs[] = {
3216 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3217 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3218 {}
3219 };
3220 unsigned int cfg;
3221
Dylan Reid42397002013-04-05 14:58:22 -07003222 if (strcmp(codec->chip_name, "ALC271X") &&
3223 strcmp(codec->chip_name, "ALC269VB"))
Takashi Iwai1d045db2011-07-07 18:23:21 +02003224 return;
3225 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3226 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3227 snd_hda_sequence_write(codec, verbs);
3228}
3229
Takashi Iwai017f2a12011-07-09 14:42:25 +02003230static void alc269_fixup_pcm_44k(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003231 const struct hda_fixup *fix, int action)
Takashi Iwai017f2a12011-07-09 14:42:25 +02003232{
3233 struct alc_spec *spec = codec->spec;
3234
Takashi Iwai1727a772013-01-10 09:52:52 +01003235 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai017f2a12011-07-09 14:42:25 +02003236 return;
3237
3238 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3239 * fix the sample rate of analog I/O to 44.1kHz
3240 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01003241 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3242 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai017f2a12011-07-09 14:42:25 +02003243}
3244
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003245static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003246 const struct hda_fixup *fix, int action)
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003247{
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003248 /* The digital-mic unit sends PDM (differential signal) instead of
3249 * the standard PCM, thus you can't record a valid mono stream as is.
3250 * Below is a workaround specific to ALC269 to control the dmic
3251 * signal source as mono.
3252 */
Takashi Iwai98b24882014-08-18 13:47:50 +02003253 if (action == HDA_FIXUP_ACT_INIT)
3254 alc_update_coef_idx(codec, 0x07, 0, 0x80);
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003255}
3256
Takashi Iwai24519912011-08-16 15:08:49 +02003257static void alc269_quanta_automute(struct hda_codec *codec)
3258{
Takashi Iwai08c189f2012-12-19 15:22:24 +01003259 snd_hda_gen_update_outputs(codec);
Takashi Iwai24519912011-08-16 15:08:49 +02003260
Takashi Iwai1687ccc2014-08-18 13:49:35 +02003261 alc_write_coef_idx(codec, 0x0c, 0x680);
3262 alc_write_coef_idx(codec, 0x0c, 0x480);
Takashi Iwai24519912011-08-16 15:08:49 +02003263}
3264
3265static void alc269_fixup_quanta_mute(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003266 const struct hda_fixup *fix, int action)
Takashi Iwai24519912011-08-16 15:08:49 +02003267{
3268 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01003269 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai24519912011-08-16 15:08:49 +02003270 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +01003271 spec->gen.automute_hook = alc269_quanta_automute;
Takashi Iwai24519912011-08-16 15:08:49 +02003272}
3273
David Henningssond240d1d2013-04-15 12:50:02 +02003274static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3275 struct hda_jack_tbl *jack)
3276{
3277 struct alc_spec *spec = codec->spec;
3278 int vref;
3279 msleep(200);
3280 snd_hda_gen_hp_automute(codec, jack);
3281
3282 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3283 msleep(100);
3284 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3285 vref);
3286 msleep(500);
3287 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3288 vref);
3289}
3290
3291static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3292 const struct hda_fixup *fix, int action)
3293{
3294 struct alc_spec *spec = codec->spec;
3295 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3296 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3297 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3298 }
3299}
3300
3301
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003302/* update mute-LED according to the speaker mute state via mic VREF pin */
3303static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003304{
3305 struct hda_codec *codec = private_data;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003306 struct alc_spec *spec = codec->spec;
3307 unsigned int pinval;
3308
3309 if (spec->mute_led_polarity)
3310 enabled = !enabled;
Takashi Iwai415d5552014-04-03 11:51:21 +02003311 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3312 pinval &= ~AC_PINCTL_VREFEN;
3313 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003314 if (spec->mute_led_nid)
3315 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003316}
3317
David Henningssond5b6b652013-11-06 10:50:44 +01003318/* Make sure the led works even in runtime suspend */
3319static unsigned int led_power_filter(struct hda_codec *codec,
3320 hda_nid_t nid,
3321 unsigned int power_state)
3322{
3323 struct alc_spec *spec = codec->spec;
3324
Hui Wang50dd9052014-07-08 17:56:15 +08003325 if (power_state != AC_PWRST_D3 || nid == 0 ||
3326 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
David Henningssond5b6b652013-11-06 10:50:44 +01003327 return power_state;
3328
3329 /* Set pin ctl again, it might have just been set to 0 */
3330 snd_hda_set_pin_ctl(codec, nid,
3331 snd_hda_codec_get_pin_target(codec, nid));
3332
3333 return AC_PWRST_D0;
3334}
3335
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003336static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3337 const struct hda_fixup *fix, int action)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003338{
3339 struct alc_spec *spec = codec->spec;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003340 const struct dmi_device *dev = NULL;
3341
3342 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3343 return;
3344
3345 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3346 int pol, pin;
3347 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3348 continue;
3349 if (pin < 0x0a || pin >= 0x10)
3350 break;
3351 spec->mute_led_polarity = pol;
3352 spec->mute_led_nid = pin - 0x0a + 0x18;
3353 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01003354 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003355 codec->power_filter = led_power_filter;
Takashi Iwai4e76a882014-02-25 12:21:03 +01003356 codec_dbg(codec,
3357 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003358 spec->mute_led_polarity);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003359 break;
3360 }
3361}
3362
David Henningssond06ac142013-02-18 11:41:55 +01003363static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3364 const struct hda_fixup *fix, int action)
3365{
3366 struct alc_spec *spec = codec->spec;
3367 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3368 spec->mute_led_polarity = 0;
3369 spec->mute_led_nid = 0x18;
3370 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3371 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003372 codec->power_filter = led_power_filter;
David Henningssond06ac142013-02-18 11:41:55 +01003373 }
3374}
3375
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003376static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3377 const struct hda_fixup *fix, int action)
Takashi Iwai420b0fe2012-03-12 12:35:27 +01003378{
3379 struct alc_spec *spec = codec->spec;
Takashi Iwai9bb1f062013-01-10 17:14:29 +01003380 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003381 spec->mute_led_polarity = 0;
3382 spec->mute_led_nid = 0x19;
3383 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01003384 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003385 codec->power_filter = led_power_filter;
Takashi Iwai420b0fe2012-03-12 12:35:27 +01003386 }
3387}
3388
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003389/* turn on/off mute LED per vmaster hook */
3390static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
3391{
3392 struct hda_codec *codec = private_data;
3393 struct alc_spec *spec = codec->spec;
3394 unsigned int oldval = spec->gpio_led;
3395
3396 if (enabled)
3397 spec->gpio_led &= ~0x08;
3398 else
3399 spec->gpio_led |= 0x08;
3400 if (spec->gpio_led != oldval)
3401 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3402 spec->gpio_led);
3403}
3404
3405/* turn on/off mic-mute LED per capture hook */
3406static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +01003407 struct snd_kcontrol *kcontrol,
3408 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003409{
3410 struct alc_spec *spec = codec->spec;
3411 unsigned int oldval = spec->gpio_led;
3412
3413 if (!ucontrol)
3414 return;
3415
3416 if (ucontrol->value.integer.value[0] ||
3417 ucontrol->value.integer.value[1])
3418 spec->gpio_led &= ~0x10;
3419 else
3420 spec->gpio_led |= 0x10;
3421 if (spec->gpio_led != oldval)
3422 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3423 spec->gpio_led);
3424}
3425
3426static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3427 const struct hda_fixup *fix, int action)
3428{
3429 struct alc_spec *spec = codec->spec;
3430 static const struct hda_verb gpio_init[] = {
3431 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3432 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3433 {}
3434 };
3435
3436 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3437 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3438 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
3439 spec->gpio_led = 0;
3440 snd_hda_add_verbs(codec, gpio_init);
3441 }
3442}
3443
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003444/* turn on/off mic-mute LED per capture hook */
3445static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3446 struct snd_kcontrol *kcontrol,
3447 struct snd_ctl_elem_value *ucontrol)
3448{
3449 struct alc_spec *spec = codec->spec;
3450 unsigned int pinval, enable, disable;
3451
Hui Wangfc1fad92014-07-08 17:56:14 +08003452 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003453 pinval &= ~AC_PINCTL_VREFEN;
3454 enable = pinval | AC_PINCTL_VREF_80;
3455 disable = pinval | AC_PINCTL_VREF_HIZ;
3456
3457 if (!ucontrol)
3458 return;
3459
3460 if (ucontrol->value.integer.value[0] ||
3461 ucontrol->value.integer.value[1])
3462 pinval = disable;
3463 else
3464 pinval = enable;
3465
3466 if (spec->cap_mute_led_nid)
3467 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3468}
3469
3470static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3471 const struct hda_fixup *fix, int action)
3472{
3473 struct alc_spec *spec = codec->spec;
3474 static const struct hda_verb gpio_init[] = {
3475 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3476 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3477 {}
3478 };
3479
3480 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3481 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3482 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3483 spec->gpio_led = 0;
3484 spec->cap_mute_led_nid = 0x18;
3485 snd_hda_add_verbs(codec, gpio_init);
Hui Wang50dd9052014-07-08 17:56:15 +08003486 codec->power_filter = led_power_filter;
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003487 }
3488}
3489
3490static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3491 const struct hda_fixup *fix, int action)
3492{
3493 struct alc_spec *spec = codec->spec;
3494
3495 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3496 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3497 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3498 spec->mute_led_polarity = 0;
3499 spec->mute_led_nid = 0x1a;
3500 spec->cap_mute_led_nid = 0x18;
3501 spec->gen.vmaster_mute_enum = 1;
3502 codec->power_filter = led_power_filter;
3503 }
3504}
3505
David Henningsson73bdd592013-04-15 15:44:14 +02003506static void alc_headset_mode_unplugged(struct hda_codec *codec)
3507{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003508 static struct coef_fw coef0255[] = {
3509 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
3510 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
3511 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
3512 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
3513 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
3514 {}
3515 };
3516 static struct coef_fw coef0233[] = {
3517 WRITE_COEF(0x1b, 0x0c0b),
3518 WRITE_COEF(0x45, 0xc429),
3519 UPDATE_COEF(0x35, 0x4000, 0),
3520 WRITE_COEF(0x06, 0x2104),
3521 WRITE_COEF(0x1a, 0x0001),
3522 WRITE_COEF(0x26, 0x0004),
3523 WRITE_COEF(0x32, 0x42a3),
3524 {}
3525 };
3526 static struct coef_fw coef0292[] = {
3527 WRITE_COEF(0x76, 0x000e),
3528 WRITE_COEF(0x6c, 0x2400),
3529 WRITE_COEF(0x18, 0x7308),
3530 WRITE_COEF(0x6b, 0xc429),
3531 {}
3532 };
3533 static struct coef_fw coef0293[] = {
3534 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
3535 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
3536 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
3537 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
3538 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
3539 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
3540 {}
3541 };
3542 static struct coef_fw coef0668[] = {
3543 WRITE_COEF(0x15, 0x0d40),
3544 WRITE_COEF(0xb7, 0x802b),
3545 {}
3546 };
3547
David Henningsson73bdd592013-04-15 15:44:14 +02003548 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003549 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003550 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003551 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003552 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003553 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003554 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003555 break;
3556 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003557 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003558 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003559 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003560 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003561 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003562 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003563 alc_process_coef_fw(codec, coef0668);
David Henningsson73bdd592013-04-15 15:44:14 +02003564 break;
3565 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003566 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003567}
3568
3569
3570static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3571 hda_nid_t mic_pin)
3572{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003573 static struct coef_fw coef0255[] = {
3574 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
3575 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
3576 {}
3577 };
3578 static struct coef_fw coef0233[] = {
3579 UPDATE_COEF(0x35, 0, 1<<14),
3580 WRITE_COEF(0x06, 0x2100),
3581 WRITE_COEF(0x1a, 0x0021),
3582 WRITE_COEF(0x26, 0x008c),
3583 {}
3584 };
3585 static struct coef_fw coef0292[] = {
3586 WRITE_COEF(0x19, 0xa208),
3587 WRITE_COEF(0x2e, 0xacf0),
3588 {}
3589 };
3590 static struct coef_fw coef0293[] = {
3591 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
3592 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
3593 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
3594 {}
3595 };
3596 static struct coef_fw coef0688[] = {
3597 WRITE_COEF(0xb7, 0x802b),
3598 WRITE_COEF(0xb5, 0x1040),
3599 UPDATE_COEF(0xc3, 0, 1<<12),
3600 {}
3601 };
3602
David Henningsson73bdd592013-04-15 15:44:14 +02003603 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003604 case 0x10ec0255:
3605 alc_write_coef_idx(codec, 0x45, 0xc489);
3606 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003607 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003608 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3609 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003610 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003611 case 0x10ec0283:
3612 alc_write_coef_idx(codec, 0x45, 0xc429);
3613 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003614 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003615 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3616 break;
3617 case 0x10ec0292:
3618 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003619 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003620 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003621 case 0x10ec0293:
3622 /* Set to TRS mode */
3623 alc_write_coef_idx(codec, 0x45, 0xc429);
3624 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003625 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003626 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3627 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003628 case 0x10ec0668:
3629 alc_write_coef_idx(codec, 0x11, 0x0001);
3630 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003631 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003632 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3633 break;
3634 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003635 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003636}
3637
3638static void alc_headset_mode_default(struct hda_codec *codec)
3639{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003640 static struct coef_fw coef0255[] = {
3641 WRITE_COEF(0x45, 0xc089),
3642 WRITE_COEF(0x45, 0xc489),
3643 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
3644 WRITE_COEF(0x49, 0x0049),
3645 {}
3646 };
3647 static struct coef_fw coef0233[] = {
3648 WRITE_COEF(0x06, 0x2100),
3649 WRITE_COEF(0x32, 0x4ea3),
3650 {}
3651 };
3652 static struct coef_fw coef0292[] = {
3653 WRITE_COEF(0x76, 0x000e),
3654 WRITE_COEF(0x6c, 0x2400),
3655 WRITE_COEF(0x6b, 0xc429),
3656 WRITE_COEF(0x18, 0x7308),
3657 {}
3658 };
3659 static struct coef_fw coef0293[] = {
3660 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
3661 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
3662 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
3663 {}
3664 };
3665 static struct coef_fw coef0688[] = {
3666 WRITE_COEF(0x11, 0x0041),
3667 WRITE_COEF(0x15, 0x0d40),
3668 WRITE_COEF(0xb7, 0x802b),
3669 {}
3670 };
3671
David Henningsson73bdd592013-04-15 15:44:14 +02003672 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003673 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003674 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003675 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003676 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003677 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003678 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003679 break;
3680 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003681 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003682 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003683 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003684 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003685 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003686 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003687 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003688 break;
3689 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003690 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003691}
3692
3693/* Iphone type */
3694static void alc_headset_mode_ctia(struct hda_codec *codec)
3695{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003696 static struct coef_fw coef0255[] = {
3697 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
3698 WRITE_COEF(0x1b, 0x0c2b),
3699 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
3700 {}
3701 };
3702 static struct coef_fw coef0233[] = {
3703 WRITE_COEF(0x45, 0xd429),
3704 WRITE_COEF(0x1b, 0x0c2b),
3705 WRITE_COEF(0x32, 0x4ea3),
3706 {}
3707 };
3708 static struct coef_fw coef0292[] = {
3709 WRITE_COEF(0x6b, 0xd429),
3710 WRITE_COEF(0x76, 0x0008),
3711 WRITE_COEF(0x18, 0x7388),
3712 {}
3713 };
3714 static struct coef_fw coef0293[] = {
3715 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
3716 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
3717 {}
3718 };
3719 static struct coef_fw coef0688[] = {
3720 WRITE_COEF(0x11, 0x0001),
3721 WRITE_COEF(0x15, 0x0d60),
3722 WRITE_COEF(0xc3, 0x0000),
3723 {}
3724 };
3725
David Henningsson73bdd592013-04-15 15:44:14 +02003726 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003727 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003728 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003729 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003730 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003731 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003732 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003733 break;
3734 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003735 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003736 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003737 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003738 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003739 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003740 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003741 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003742 break;
3743 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003744 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003745}
3746
3747/* Nokia type */
3748static void alc_headset_mode_omtp(struct hda_codec *codec)
3749{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003750 static struct coef_fw coef0255[] = {
3751 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
3752 WRITE_COEF(0x1b, 0x0c2b),
3753 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
3754 {}
3755 };
3756 static struct coef_fw coef0233[] = {
3757 WRITE_COEF(0x45, 0xe429),
3758 WRITE_COEF(0x1b, 0x0c2b),
3759 WRITE_COEF(0x32, 0x4ea3),
3760 {}
3761 };
3762 static struct coef_fw coef0292[] = {
3763 WRITE_COEF(0x6b, 0xe429),
3764 WRITE_COEF(0x76, 0x0008),
3765 WRITE_COEF(0x18, 0x7388),
3766 {}
3767 };
3768 static struct coef_fw coef0293[] = {
3769 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
3770 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
3771 {}
3772 };
3773 static struct coef_fw coef0688[] = {
3774 WRITE_COEF(0x11, 0x0001),
3775 WRITE_COEF(0x15, 0x0d50),
3776 WRITE_COEF(0xc3, 0x0000),
3777 {}
3778 };
3779
David Henningsson73bdd592013-04-15 15:44:14 +02003780 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003781 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003782 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003783 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003784 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003785 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003786 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003787 break;
3788 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003789 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003790 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003791 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003792 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003793 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003794 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003795 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003796 break;
3797 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003798 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003799}
3800
3801static void alc_determine_headset_type(struct hda_codec *codec)
3802{
3803 int val;
3804 bool is_ctia = false;
3805 struct alc_spec *spec = codec->spec;
Takashi Iwai54db6c32014-08-18 15:11:19 +02003806 static struct coef_fw coef0255[] = {
3807 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
3808 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
3809 conteol) */
3810 {}
3811 };
3812 static struct coef_fw coef0293[] = {
3813 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
3814 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
3815 {}
3816 };
3817 static struct coef_fw coef0688[] = {
3818 WRITE_COEF(0x11, 0x0001),
3819 WRITE_COEF(0xb7, 0x802b),
3820 WRITE_COEF(0x15, 0x0d60),
3821 WRITE_COEF(0xc3, 0x0c00),
3822 {}
3823 };
David Henningsson73bdd592013-04-15 15:44:14 +02003824
3825 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003826 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003827 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003828 msleep(300);
3829 val = alc_read_coef_idx(codec, 0x46);
3830 is_ctia = (val & 0x0070) == 0x0070;
3831 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003832 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003833 case 0x10ec0283:
3834 alc_write_coef_idx(codec, 0x45, 0xd029);
3835 msleep(300);
3836 val = alc_read_coef_idx(codec, 0x46);
3837 is_ctia = (val & 0x0070) == 0x0070;
3838 break;
3839 case 0x10ec0292:
3840 alc_write_coef_idx(codec, 0x6b, 0xd429);
3841 msleep(300);
3842 val = alc_read_coef_idx(codec, 0x6c);
3843 is_ctia = (val & 0x001c) == 0x001c;
3844 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003845 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003846 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003847 msleep(300);
3848 val = alc_read_coef_idx(codec, 0x46);
3849 is_ctia = (val & 0x0070) == 0x0070;
3850 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003851 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003852 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003853 msleep(300);
3854 val = alc_read_coef_idx(codec, 0xbe);
3855 is_ctia = (val & 0x1c02) == 0x1c02;
3856 break;
3857 }
3858
Takashi Iwai4e76a882014-02-25 12:21:03 +01003859 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
David Henningsson73bdd592013-04-15 15:44:14 +02003860 is_ctia ? "yes" : "no");
3861 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3862}
3863
3864static void alc_update_headset_mode(struct hda_codec *codec)
3865{
3866 struct alc_spec *spec = codec->spec;
3867
3868 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
3869 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3870
3871 int new_headset_mode;
3872
3873 if (!snd_hda_jack_detect(codec, hp_pin))
3874 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
3875 else if (mux_pin == spec->headset_mic_pin)
3876 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
3877 else if (mux_pin == spec->headphone_mic_pin)
3878 new_headset_mode = ALC_HEADSET_MODE_MIC;
3879 else
3880 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
3881
David Henningsson5959a6b2013-11-12 11:10:57 +01003882 if (new_headset_mode == spec->current_headset_mode) {
3883 snd_hda_gen_update_outputs(codec);
David Henningsson73bdd592013-04-15 15:44:14 +02003884 return;
David Henningsson5959a6b2013-11-12 11:10:57 +01003885 }
David Henningsson73bdd592013-04-15 15:44:14 +02003886
3887 switch (new_headset_mode) {
3888 case ALC_HEADSET_MODE_UNPLUGGED:
3889 alc_headset_mode_unplugged(codec);
3890 spec->gen.hp_jack_present = false;
3891 break;
3892 case ALC_HEADSET_MODE_HEADSET:
3893 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
3894 alc_determine_headset_type(codec);
3895 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
3896 alc_headset_mode_ctia(codec);
3897 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
3898 alc_headset_mode_omtp(codec);
3899 spec->gen.hp_jack_present = true;
3900 break;
3901 case ALC_HEADSET_MODE_MIC:
3902 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
3903 spec->gen.hp_jack_present = false;
3904 break;
3905 case ALC_HEADSET_MODE_HEADPHONE:
3906 alc_headset_mode_default(codec);
3907 spec->gen.hp_jack_present = true;
3908 break;
3909 }
3910 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
3911 snd_hda_set_pin_ctl_cache(codec, hp_pin,
3912 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3913 if (spec->headphone_mic_pin)
3914 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
3915 PIN_VREFHIZ);
3916 }
3917 spec->current_headset_mode = new_headset_mode;
3918
3919 snd_hda_gen_update_outputs(codec);
3920}
3921
3922static void alc_update_headset_mode_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +01003923 struct snd_kcontrol *kcontrol,
3924 struct snd_ctl_elem_value *ucontrol)
David Henningsson73bdd592013-04-15 15:44:14 +02003925{
3926 alc_update_headset_mode(codec);
3927}
3928
3929static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack)
3930{
3931 struct alc_spec *spec = codec->spec;
David Henningsson5db4d342013-11-22 12:17:06 +01003932 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
David Henningsson73bdd592013-04-15 15:44:14 +02003933 snd_hda_gen_hp_automute(codec, jack);
3934}
3935
3936static void alc_probe_headset_mode(struct hda_codec *codec)
3937{
3938 int i;
3939 struct alc_spec *spec = codec->spec;
3940 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3941
3942 /* Find mic pins */
3943 for (i = 0; i < cfg->num_inputs; i++) {
3944 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
3945 spec->headset_mic_pin = cfg->inputs[i].pin;
3946 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
3947 spec->headphone_mic_pin = cfg->inputs[i].pin;
3948 }
3949
3950 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
3951 spec->gen.automute_hook = alc_update_headset_mode;
3952 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
3953}
3954
3955static void alc_fixup_headset_mode(struct hda_codec *codec,
3956 const struct hda_fixup *fix, int action)
3957{
3958 struct alc_spec *spec = codec->spec;
3959
3960 switch (action) {
3961 case HDA_FIXUP_ACT_PRE_PROBE:
3962 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
3963 break;
3964 case HDA_FIXUP_ACT_PROBE:
3965 alc_probe_headset_mode(codec);
3966 break;
3967 case HDA_FIXUP_ACT_INIT:
3968 spec->current_headset_mode = 0;
3969 alc_update_headset_mode(codec);
3970 break;
3971 }
3972}
3973
3974static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
3975 const struct hda_fixup *fix, int action)
3976{
3977 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3978 struct alc_spec *spec = codec->spec;
3979 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3980 }
3981 else
3982 alc_fixup_headset_mode(codec, fix, action);
3983}
3984
Kailang Yang31278992014-03-03 15:27:22 +08003985static void alc255_set_default_jack_type(struct hda_codec *codec)
3986{
3987 /* Set to iphone type */
Takashi Iwai54db6c32014-08-18 15:11:19 +02003988 static struct coef_fw fw[] = {
3989 WRITE_COEF(0x1b, 0x880b),
3990 WRITE_COEF(0x45, 0xd089),
3991 WRITE_COEF(0x1b, 0x080b),
3992 WRITE_COEF(0x46, 0x0004),
3993 WRITE_COEF(0x1b, 0x0c0b),
3994 {}
3995 };
3996 alc_process_coef_fw(codec, fw);
Kailang Yang31278992014-03-03 15:27:22 +08003997 msleep(30);
3998}
3999
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004000static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
4001 const struct hda_fixup *fix, int action)
4002{
4003 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Kailang Yang31278992014-03-03 15:27:22 +08004004 alc255_set_default_jack_type(codec);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004005 }
4006 alc_fixup_headset_mode(codec, fix, action);
4007}
4008
Kailang Yang31278992014-03-03 15:27:22 +08004009static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
4010 const struct hda_fixup *fix, int action)
4011{
4012 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4013 struct alc_spec *spec = codec->spec;
4014 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4015 alc255_set_default_jack_type(codec);
4016 }
4017 else
4018 alc_fixup_headset_mode(codec, fix, action);
4019}
4020
Hui Wang493a52a2014-01-14 14:07:36 +08004021static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
4022 const struct hda_fixup *fix, int action)
4023{
4024 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4025 struct alc_spec *spec = codec->spec;
4026 spec->gen.auto_mute_via_amp = 1;
4027 }
4028}
4029
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004030static void alc_no_shutup(struct hda_codec *codec)
4031{
4032}
4033
4034static void alc_fixup_no_shutup(struct hda_codec *codec,
4035 const struct hda_fixup *fix, int action)
4036{
4037 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4038 struct alc_spec *spec = codec->spec;
4039 spec->shutup = alc_no_shutup;
4040 }
4041}
4042
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02004043static void alc_fixup_disable_aamix(struct hda_codec *codec,
4044 const struct hda_fixup *fix, int action)
4045{
4046 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4047 struct alc_spec *spec = codec->spec;
4048 /* Disable AA-loopback as it causes white noise */
4049 spec->gen.mixer_nid = 0;
4050 }
4051}
4052
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004053static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
4054 hda_nid_t nid,
4055 unsigned int power_state)
4056{
4057 struct alc_spec *spec = codec->spec;
4058
4059 /* Avoid pop noises when headphones are plugged in */
4060 if (spec->gen.hp_jack_present)
Gabriele Mazzottade3da4f2014-08-08 19:34:41 +02004061 if (nid == codec->afg || nid == 0x02 || nid == 0x15)
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004062 return AC_PWRST_D0;
4063 return power_state;
4064}
4065
4066static void alc_fixup_dell_xps13(struct hda_codec *codec,
4067 const struct hda_fixup *fix, int action)
4068{
4069 if (action == HDA_FIXUP_ACT_PROBE) {
4070 struct alc_spec *spec = codec->spec;
Gabriele Mazzottaf38663a2014-08-08 19:34:40 +02004071 struct hda_input_mux *imux = &spec->gen.input_mux;
4072 int i;
4073
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004074 spec->shutup = alc_no_shutup;
4075 codec->power_filter = alc_power_filter_xps13;
Gabriele Mazzottaf38663a2014-08-08 19:34:40 +02004076
4077 /* Make the internal mic the default input source. */
4078 for (i = 0; i < imux->num_items; i++) {
4079 if (spec->gen.imux_pins[i] == 0x12) {
4080 spec->gen.cur_mux[0] = i;
4081 break;
4082 }
4083 }
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004084 }
4085}
4086
David Henningsson73bdd592013-04-15 15:44:14 +02004087static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
4088 const struct hda_fixup *fix, int action)
4089{
4090 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
David Henningsson73bdd592013-04-15 15:44:14 +02004091 alc_write_coef_idx(codec, 0xc4, 0x8000);
Takashi Iwai98b24882014-08-18 13:47:50 +02004092 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
David Henningsson73bdd592013-04-15 15:44:14 +02004093 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
4094 }
4095 alc_fixup_headset_mode(codec, fix, action);
4096}
4097
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004098/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
4099static int find_ext_mic_pin(struct hda_codec *codec)
4100{
4101 struct alc_spec *spec = codec->spec;
4102 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4103 hda_nid_t nid;
4104 unsigned int defcfg;
4105 int i;
4106
4107 for (i = 0; i < cfg->num_inputs; i++) {
4108 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4109 continue;
4110 nid = cfg->inputs[i].pin;
4111 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4112 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
4113 continue;
4114 return nid;
4115 }
4116
4117 return 0;
4118}
4119
Dylan Reid08a978d2012-11-18 22:56:40 -08004120static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01004121 const struct hda_fixup *fix,
Dylan Reid08a978d2012-11-18 22:56:40 -08004122 int action)
4123{
4124 struct alc_spec *spec = codec->spec;
4125
Takashi Iwai0db75792013-01-23 13:57:20 +01004126 if (action == HDA_FIXUP_ACT_PROBE) {
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004127 int mic_pin = find_ext_mic_pin(codec);
4128 int hp_pin = spec->gen.autocfg.hp_pins[0];
4129
4130 if (snd_BUG_ON(!mic_pin || !hp_pin))
Takashi Iwai0db75792013-01-23 13:57:20 +01004131 return;
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004132 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
Takashi Iwai0db75792013-01-23 13:57:20 +01004133 }
Dylan Reid08a978d2012-11-18 22:56:40 -08004134}
David Henningsson693b6132012-06-22 19:12:10 +02004135
David Henningsson3e0d6112013-04-22 14:30:14 +02004136static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
4137 const struct hda_fixup *fix,
4138 int action)
4139{
4140 struct alc_spec *spec = codec->spec;
4141 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4142 int i;
4143
4144 /* The mic boosts on level 2 and 3 are too noisy
4145 on the internal mic input.
4146 Therefore limit the boost to 0 or 1. */
4147
4148 if (action != HDA_FIXUP_ACT_PROBE)
4149 return;
4150
4151 for (i = 0; i < cfg->num_inputs; i++) {
4152 hda_nid_t nid = cfg->inputs[i].pin;
4153 unsigned int defcfg;
4154 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4155 continue;
4156 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4157 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
4158 continue;
4159
4160 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
4161 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
4162 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4163 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
4164 (0 << AC_AMPCAP_MUTE_SHIFT));
4165 }
4166}
4167
Kailang Yangcd217a62013-08-22 10:15:24 +02004168static void alc283_hp_automute_hook(struct hda_codec *codec,
4169 struct hda_jack_tbl *jack)
4170{
4171 struct alc_spec *spec = codec->spec;
4172 int vref;
4173
4174 msleep(200);
4175 snd_hda_gen_hp_automute(codec, jack);
4176
4177 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4178
4179 msleep(600);
4180 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4181 vref);
4182}
4183
Kailang Yangcd217a62013-08-22 10:15:24 +02004184static void alc283_fixup_chromebook(struct hda_codec *codec,
4185 const struct hda_fixup *fix, int action)
4186{
4187 struct alc_spec *spec = codec->spec;
Kailang Yangcd217a62013-08-22 10:15:24 +02004188
4189 switch (action) {
4190 case HDA_FIXUP_ACT_PRE_PROBE:
Kailang Yang0202e992013-12-02 15:20:15 +08004191 snd_hda_override_wcaps(codec, 0x03, 0);
Takashi Iwaid2e92702013-10-30 07:50:53 +01004192 /* Disable AA-loopback as it causes white noise */
4193 spec->gen.mixer_nid = 0;
Kailang Yang38070212013-11-01 15:57:35 +08004194 break;
4195 case HDA_FIXUP_ACT_INIT:
Kailang Yangde9481c2014-04-07 16:41:52 +08004196 /* MIC2-VREF control */
4197 /* Set to manual mode */
Takashi Iwai98b24882014-08-18 13:47:50 +02004198 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
Kailang Yang0202e992013-12-02 15:20:15 +08004199 /* Enable Line1 input control by verb */
Takashi Iwai98b24882014-08-18 13:47:50 +02004200 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
Kailang Yang0202e992013-12-02 15:20:15 +08004201 break;
4202 }
4203}
4204
4205static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
4206 const struct hda_fixup *fix, int action)
4207{
4208 struct alc_spec *spec = codec->spec;
Kailang Yang0202e992013-12-02 15:20:15 +08004209
4210 switch (action) {
4211 case HDA_FIXUP_ACT_PRE_PROBE:
Kailang Yangcd217a62013-08-22 10:15:24 +02004212 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
4213 break;
4214 case HDA_FIXUP_ACT_INIT:
4215 /* MIC2-VREF control */
4216 /* Set to manual mode */
Takashi Iwai98b24882014-08-18 13:47:50 +02004217 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
Kailang Yangcd217a62013-08-22 10:15:24 +02004218 break;
4219 }
4220}
4221
Takashi Iwai7bba2152013-09-06 15:45:38 +02004222/* mute tablet speaker pin (0x14) via dock plugging in addition */
4223static void asus_tx300_automute(struct hda_codec *codec)
4224{
4225 struct alc_spec *spec = codec->spec;
4226 snd_hda_gen_update_outputs(codec);
4227 if (snd_hda_jack_detect(codec, 0x1b))
4228 spec->gen.mute_bits |= (1ULL << 0x14);
4229}
4230
4231static void alc282_fixup_asus_tx300(struct hda_codec *codec,
4232 const struct hda_fixup *fix, int action)
4233{
4234 struct alc_spec *spec = codec->spec;
4235 /* TX300 needs to set up GPIO2 for the speaker amp */
4236 static const struct hda_verb gpio2_verbs[] = {
4237 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4238 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4239 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
4240 {}
4241 };
4242 static const struct hda_pintbl dock_pins[] = {
4243 { 0x1b, 0x21114000 }, /* dock speaker pin */
4244 {}
4245 };
4246 struct snd_kcontrol *kctl;
4247
4248 switch (action) {
4249 case HDA_FIXUP_ACT_PRE_PROBE:
4250 snd_hda_add_verbs(codec, gpio2_verbs);
4251 snd_hda_apply_pincfgs(codec, dock_pins);
4252 spec->gen.auto_mute_via_amp = 1;
4253 spec->gen.automute_hook = asus_tx300_automute;
4254 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4255 HDA_GEN_HP_EVENT,
4256 snd_hda_gen_hp_automute);
4257 break;
4258 case HDA_FIXUP_ACT_BUILD:
4259 /* this is a bit tricky; give more sane names for the main
4260 * (tablet) speaker and the dock speaker, respectively
4261 */
4262 kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch");
4263 if (kctl)
4264 strcpy(kctl->id.name, "Dock Speaker Playback Switch");
4265 kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch");
4266 if (kctl)
4267 strcpy(kctl->id.name, "Speaker Playback Switch");
4268 break;
4269 }
4270}
4271
David Henningsson338cae52013-10-07 10:39:59 +02004272static void alc290_fixup_mono_speakers(struct hda_codec *codec,
4273 const struct hda_fixup *fix, int action)
4274{
David Henningsson0f4881d2013-12-20 16:08:13 +01004275 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4276 /* DAC node 0x03 is giving mono output. We therefore want to
4277 make sure 0x14 (front speaker) and 0x15 (headphones) use the
4278 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
4279 hda_nid_t conn1[2] = { 0x0c };
4280 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
4281 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
4282 }
David Henningsson338cae52013-10-07 10:39:59 +02004283}
4284
Takashi Iwaib317b032014-01-08 11:44:21 +01004285/* for hda_fixup_thinkpad_acpi() */
4286#include "thinkpad_helper.c"
David Henningssonb67ae3f2013-11-05 13:11:37 +01004287
Hui Wang00ef9942014-07-31 11:52:38 +08004288/* for dell wmi mic mute led */
4289#include "dell_wmi_helper.c"
4290
Takashi Iwai1d045db2011-07-07 18:23:21 +02004291enum {
4292 ALC269_FIXUP_SONY_VAIO,
4293 ALC275_FIXUP_SONY_VAIO_GPIO2,
4294 ALC269_FIXUP_DELL_M101Z,
4295 ALC269_FIXUP_SKU_IGNORE,
4296 ALC269_FIXUP_ASUS_G73JW,
4297 ALC269_FIXUP_LENOVO_EAPD,
4298 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004299 ALC275_FIXUP_SONY_DISABLE_AAMIX,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004300 ALC271_FIXUP_DMIC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02004301 ALC269_FIXUP_PCM_44K,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004302 ALC269_FIXUP_STEREO_DMIC,
David Henningsson7c478f02013-10-11 10:18:46 +02004303 ALC269_FIXUP_HEADSET_MIC,
Takashi Iwai24519912011-08-16 15:08:49 +02004304 ALC269_FIXUP_QUANTA_MUTE,
4305 ALC269_FIXUP_LIFEBOOK,
David Henningsson2041d562014-06-13 11:15:44 +02004306 ALC269_FIXUP_LIFEBOOK_EXTMIC,
Takashi Iwaia4297b52011-08-23 18:40:12 +02004307 ALC269_FIXUP_AMIC,
4308 ALC269_FIXUP_DMIC,
4309 ALC269VB_FIXUP_AMIC,
4310 ALC269VB_FIXUP_DMIC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004311 ALC269_FIXUP_HP_MUTE_LED,
David Henningssond06ac142013-02-18 11:41:55 +01004312 ALC269_FIXUP_HP_MUTE_LED_MIC1,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004313 ALC269_FIXUP_HP_MUTE_LED_MIC2,
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004314 ALC269_FIXUP_HP_GPIO_LED,
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004315 ALC269_FIXUP_HP_GPIO_MIC1_LED,
4316 ALC269_FIXUP_HP_LINE1_MIC1_LED,
David Henningsson693b6132012-06-22 19:12:10 +02004317 ALC269_FIXUP_INV_DMIC,
David Henningsson108cc102012-07-20 10:37:25 +02004318 ALC269_FIXUP_LENOVO_DOCK,
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004319 ALC269_FIXUP_NO_SHUTUP,
David Henningsson88cfcf82013-10-11 10:18:45 +02004320 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
David Henningsson108cc102012-07-20 10:37:25 +02004321 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
David Henningsson73bdd592013-04-15 15:44:14 +02004322 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
4323 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
David Henningsson338cae52013-10-07 10:39:59 +02004324 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
David Henningsson73bdd592013-04-15 15:44:14 +02004325 ALC269_FIXUP_HEADSET_MODE,
4326 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
David Henningssond240d1d2013-04-15 12:50:02 +02004327 ALC269_FIXUP_ASUS_X101_FUNC,
4328 ALC269_FIXUP_ASUS_X101_VERB,
4329 ALC269_FIXUP_ASUS_X101,
Dylan Reid08a978d2012-11-18 22:56:40 -08004330 ALC271_FIXUP_AMIC_MIC2,
4331 ALC271_FIXUP_HP_GATE_MIC_JACK,
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004332 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
Dylan Reid42397002013-04-05 14:58:22 -07004333 ALC269_FIXUP_ACER_AC700,
David Henningsson3e0d6112013-04-22 14:30:14 +02004334 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
Oleksij Rempel2cede302013-11-27 17:12:03 +01004335 ALC269VB_FIXUP_ASUS_ZENBOOK,
Takashi Iwai23870832013-11-29 14:13:12 +01004336 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
David Henningsson8e35cd42013-11-06 11:20:01 +01004337 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
Anisse Astier02b504d2013-06-03 11:53:10 +02004338 ALC269VB_FIXUP_ORDISSIMO_EVE2,
Kailang Yangcd217a62013-08-22 10:15:24 +02004339 ALC283_FIXUP_CHROME_BOOK,
Kailang Yang0202e992013-12-02 15:20:15 +08004340 ALC283_FIXUP_SENSE_COMBO_JACK,
Takashi Iwai7bba2152013-09-06 15:45:38 +02004341 ALC282_FIXUP_ASUS_TX300,
Kailang Yang1bb3e062013-09-27 13:10:25 +02004342 ALC283_FIXUP_INT_MIC,
David Henningsson338cae52013-10-07 10:39:59 +02004343 ALC290_FIXUP_MONO_SPEAKERS,
David Henningsson0f4881d2013-12-20 16:08:13 +01004344 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4345 ALC290_FIXUP_SUBWOOFER,
4346 ALC290_FIXUP_SUBWOOFER_HSJACK,
David Henningssonb67ae3f2013-11-05 13:11:37 +01004347 ALC269_FIXUP_THINKPAD_ACPI,
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004348 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
Kailang Yang31278992014-03-03 15:27:22 +08004349 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004350 ALC255_FIXUP_HEADSET_MODE,
Kailang Yang31278992014-03-03 15:27:22 +08004351 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
Kailang Yanga22aa262014-04-23 17:34:28 +08004352 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
Takashi Iwai1c37c222014-05-06 17:34:42 +02004353 ALC292_FIXUP_TPT440_DOCK,
Daniel Drake9dc12862014-07-22 10:58:29 +01004354 ALC283_FIXUP_BXBT2807_MIC,
Hui Wang00ef9942014-07-31 11:52:38 +08004355 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004356};
4357
Takashi Iwai1727a772013-01-10 09:52:52 +01004358static const struct hda_fixup alc269_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02004359 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01004360 .type = HDA_FIXUP_PINCTLS,
4361 .v.pins = (const struct hda_pintbl[]) {
4362 {0x19, PIN_VREFGRD},
Takashi Iwai1d045db2011-07-07 18:23:21 +02004363 {}
4364 }
4365 },
4366 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004367 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004368 .v.verbs = (const struct hda_verb[]) {
4369 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
4370 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
4371 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4372 { }
4373 },
4374 .chained = true,
4375 .chain_id = ALC269_FIXUP_SONY_VAIO
4376 },
4377 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004378 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004379 .v.verbs = (const struct hda_verb[]) {
4380 /* Enables internal speaker */
4381 {0x20, AC_VERB_SET_COEF_INDEX, 13},
4382 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4383 {}
4384 }
4385 },
4386 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004387 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02004388 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004389 },
4390 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004391 .type = HDA_FIXUP_PINS,
4392 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02004393 { 0x17, 0x99130111 }, /* subwoofer */
4394 { }
4395 }
4396 },
4397 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004398 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004399 .v.verbs = (const struct hda_verb[]) {
4400 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4401 {}
4402 }
4403 },
4404 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004405 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004406 .v.func = alc269_fixup_hweq,
4407 .chained = true,
4408 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
4409 },
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004410 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
4411 .type = HDA_FIXUP_FUNC,
4412 .v.func = alc_fixup_disable_aamix,
4413 .chained = true,
4414 .chain_id = ALC269_FIXUP_SONY_VAIO
4415 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02004416 [ALC271_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004417 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004418 .v.func = alc271_fixup_dmic,
4419 },
Takashi Iwai017f2a12011-07-09 14:42:25 +02004420 [ALC269_FIXUP_PCM_44K] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004421 .type = HDA_FIXUP_FUNC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02004422 .v.func = alc269_fixup_pcm_44k,
David Henningsson012e7eb2012-08-08 08:43:37 +02004423 .chained = true,
4424 .chain_id = ALC269_FIXUP_QUANTA_MUTE
Takashi Iwai017f2a12011-07-09 14:42:25 +02004425 },
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004426 [ALC269_FIXUP_STEREO_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004427 .type = HDA_FIXUP_FUNC,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004428 .v.func = alc269_fixup_stereo_dmic,
4429 },
David Henningsson7c478f02013-10-11 10:18:46 +02004430 [ALC269_FIXUP_HEADSET_MIC] = {
4431 .type = HDA_FIXUP_FUNC,
4432 .v.func = alc269_fixup_headset_mic,
4433 },
Takashi Iwai24519912011-08-16 15:08:49 +02004434 [ALC269_FIXUP_QUANTA_MUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004435 .type = HDA_FIXUP_FUNC,
Takashi Iwai24519912011-08-16 15:08:49 +02004436 .v.func = alc269_fixup_quanta_mute,
4437 },
4438 [ALC269_FIXUP_LIFEBOOK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004439 .type = HDA_FIXUP_PINS,
4440 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai24519912011-08-16 15:08:49 +02004441 { 0x1a, 0x2101103f }, /* dock line-out */
4442 { 0x1b, 0x23a11040 }, /* dock mic-in */
4443 { }
4444 },
4445 .chained = true,
4446 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4447 },
David Henningsson2041d562014-06-13 11:15:44 +02004448 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
4449 .type = HDA_FIXUP_PINS,
4450 .v.pins = (const struct hda_pintbl[]) {
4451 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
4452 { }
4453 },
4454 },
Takashi Iwaia4297b52011-08-23 18:40:12 +02004455 [ALC269_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004456 .type = HDA_FIXUP_PINS,
4457 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004458 { 0x14, 0x99130110 }, /* speaker */
4459 { 0x15, 0x0121401f }, /* HP out */
4460 { 0x18, 0x01a19c20 }, /* mic */
4461 { 0x19, 0x99a3092f }, /* int-mic */
4462 { }
4463 },
4464 },
4465 [ALC269_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004466 .type = HDA_FIXUP_PINS,
4467 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004468 { 0x12, 0x99a3092f }, /* int-mic */
4469 { 0x14, 0x99130110 }, /* speaker */
4470 { 0x15, 0x0121401f }, /* HP out */
4471 { 0x18, 0x01a19c20 }, /* mic */
4472 { }
4473 },
4474 },
4475 [ALC269VB_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004476 .type = HDA_FIXUP_PINS,
4477 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004478 { 0x14, 0x99130110 }, /* speaker */
4479 { 0x18, 0x01a19c20 }, /* mic */
4480 { 0x19, 0x99a3092f }, /* int-mic */
4481 { 0x21, 0x0121401f }, /* HP out */
4482 { }
4483 },
4484 },
David Henningsson2267ea92012-01-03 08:45:56 +01004485 [ALC269VB_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004486 .type = HDA_FIXUP_PINS,
4487 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004488 { 0x12, 0x99a3092f }, /* int-mic */
4489 { 0x14, 0x99130110 }, /* speaker */
4490 { 0x18, 0x01a19c20 }, /* mic */
4491 { 0x21, 0x0121401f }, /* HP out */
4492 { }
4493 },
4494 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004495 [ALC269_FIXUP_HP_MUTE_LED] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004496 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004497 .v.func = alc269_fixup_hp_mute_led,
David Henningsson6d3cd5d2013-01-07 12:03:47 +01004498 },
David Henningssond06ac142013-02-18 11:41:55 +01004499 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
4500 .type = HDA_FIXUP_FUNC,
4501 .v.func = alc269_fixup_hp_mute_led_mic1,
4502 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004503 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004504 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004505 .v.func = alc269_fixup_hp_mute_led_mic2,
Takashi Iwai420b0fe2012-03-12 12:35:27 +01004506 },
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004507 [ALC269_FIXUP_HP_GPIO_LED] = {
4508 .type = HDA_FIXUP_FUNC,
4509 .v.func = alc269_fixup_hp_gpio_led,
4510 },
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004511 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
4512 .type = HDA_FIXUP_FUNC,
4513 .v.func = alc269_fixup_hp_gpio_mic1_led,
4514 },
4515 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
4516 .type = HDA_FIXUP_FUNC,
4517 .v.func = alc269_fixup_hp_line1_mic1_led,
4518 },
David Henningsson693b6132012-06-22 19:12:10 +02004519 [ALC269_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004520 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02004521 .v.func = alc_fixup_inv_dmic_0x12,
David Henningsson693b6132012-06-22 19:12:10 +02004522 },
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004523 [ALC269_FIXUP_NO_SHUTUP] = {
4524 .type = HDA_FIXUP_FUNC,
4525 .v.func = alc_fixup_no_shutup,
4526 },
David Henningsson108cc102012-07-20 10:37:25 +02004527 [ALC269_FIXUP_LENOVO_DOCK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004528 .type = HDA_FIXUP_PINS,
4529 .v.pins = (const struct hda_pintbl[]) {
David Henningsson108cc102012-07-20 10:37:25 +02004530 { 0x19, 0x23a11040 }, /* dock mic */
4531 { 0x1b, 0x2121103f }, /* dock headphone */
4532 { }
4533 },
4534 .chained = true,
4535 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
4536 },
4537 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004538 .type = HDA_FIXUP_FUNC,
David Henningsson108cc102012-07-20 10:37:25 +02004539 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
David Henningsson52129002013-11-19 10:25:53 +01004540 .chained = true,
4541 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
David Henningsson108cc102012-07-20 10:37:25 +02004542 },
David Henningsson73bdd592013-04-15 15:44:14 +02004543 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4544 .type = HDA_FIXUP_PINS,
4545 .v.pins = (const struct hda_pintbl[]) {
4546 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4547 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4548 { }
4549 },
4550 .chained = true,
4551 .chain_id = ALC269_FIXUP_HEADSET_MODE
4552 },
4553 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4554 .type = HDA_FIXUP_PINS,
4555 .v.pins = (const struct hda_pintbl[]) {
4556 { 0x16, 0x21014020 }, /* dock line out */
4557 { 0x19, 0x21a19030 }, /* dock mic */
4558 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4559 { }
4560 },
4561 .chained = true,
4562 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4563 },
David Henningsson338cae52013-10-07 10:39:59 +02004564 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
4565 .type = HDA_FIXUP_PINS,
4566 .v.pins = (const struct hda_pintbl[]) {
4567 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4568 { }
4569 },
4570 .chained = true,
4571 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4572 },
David Henningsson73bdd592013-04-15 15:44:14 +02004573 [ALC269_FIXUP_HEADSET_MODE] = {
4574 .type = HDA_FIXUP_FUNC,
4575 .v.func = alc_fixup_headset_mode,
4576 },
4577 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4578 .type = HDA_FIXUP_FUNC,
4579 .v.func = alc_fixup_headset_mode_no_hp_mic,
4580 },
David Henningsson88cfcf82013-10-11 10:18:45 +02004581 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
4582 .type = HDA_FIXUP_PINS,
4583 .v.pins = (const struct hda_pintbl[]) {
4584 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4585 { }
4586 },
David Henningssonfbc78ad2013-10-11 13:46:04 +02004587 .chained = true,
4588 .chain_id = ALC269_FIXUP_HEADSET_MIC
David Henningsson88cfcf82013-10-11 10:18:45 +02004589 },
David Henningssond240d1d2013-04-15 12:50:02 +02004590 [ALC269_FIXUP_ASUS_X101_FUNC] = {
4591 .type = HDA_FIXUP_FUNC,
4592 .v.func = alc269_fixup_x101_headset_mic,
4593 },
4594 [ALC269_FIXUP_ASUS_X101_VERB] = {
4595 .type = HDA_FIXUP_VERBS,
4596 .v.verbs = (const struct hda_verb[]) {
4597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4598 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
4599 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
4600 { }
4601 },
4602 .chained = true,
4603 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
4604 },
4605 [ALC269_FIXUP_ASUS_X101] = {
4606 .type = HDA_FIXUP_PINS,
4607 .v.pins = (const struct hda_pintbl[]) {
4608 { 0x18, 0x04a1182c }, /* Headset mic */
4609 { }
4610 },
4611 .chained = true,
4612 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
4613 },
Dylan Reid08a978d2012-11-18 22:56:40 -08004614 [ALC271_FIXUP_AMIC_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004615 .type = HDA_FIXUP_PINS,
4616 .v.pins = (const struct hda_pintbl[]) {
Dylan Reid08a978d2012-11-18 22:56:40 -08004617 { 0x14, 0x99130110 }, /* speaker */
4618 { 0x19, 0x01a19c20 }, /* mic */
4619 { 0x1b, 0x99a7012f }, /* int-mic */
4620 { 0x21, 0x0121401f }, /* HP out */
4621 { }
4622 },
4623 },
4624 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004625 .type = HDA_FIXUP_FUNC,
Dylan Reid08a978d2012-11-18 22:56:40 -08004626 .v.func = alc271_hp_gate_mic_jack,
4627 .chained = true,
4628 .chain_id = ALC271_FIXUP_AMIC_MIC2,
4629 },
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004630 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
4631 .type = HDA_FIXUP_FUNC,
4632 .v.func = alc269_fixup_limit_int_mic_boost,
4633 .chained = true,
4634 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
4635 },
Dylan Reid42397002013-04-05 14:58:22 -07004636 [ALC269_FIXUP_ACER_AC700] = {
4637 .type = HDA_FIXUP_PINS,
4638 .v.pins = (const struct hda_pintbl[]) {
4639 { 0x12, 0x99a3092f }, /* int-mic */
4640 { 0x14, 0x99130110 }, /* speaker */
4641 { 0x18, 0x03a11c20 }, /* mic */
4642 { 0x1e, 0x0346101e }, /* SPDIF1 */
4643 { 0x21, 0x0321101f }, /* HP out */
4644 { }
4645 },
4646 .chained = true,
4647 .chain_id = ALC271_FIXUP_DMIC,
4648 },
David Henningsson3e0d6112013-04-22 14:30:14 +02004649 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
4650 .type = HDA_FIXUP_FUNC,
4651 .v.func = alc269_fixup_limit_int_mic_boost,
David Henningsson27937692013-11-18 11:51:47 +01004652 .chained = true,
4653 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
David Henningsson3e0d6112013-04-22 14:30:14 +02004654 },
Oleksij Rempel2cede302013-11-27 17:12:03 +01004655 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
4656 .type = HDA_FIXUP_FUNC,
4657 .v.func = alc269_fixup_limit_int_mic_boost,
4658 .chained = true,
4659 .chain_id = ALC269VB_FIXUP_DMIC,
4660 },
Takashi Iwai23870832013-11-29 14:13:12 +01004661 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
4662 .type = HDA_FIXUP_VERBS,
4663 .v.verbs = (const struct hda_verb[]) {
4664 /* class-D output amp +5dB */
4665 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
4666 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
4667 {}
4668 },
4669 .chained = true,
4670 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
4671 },
David Henningsson8e35cd42013-11-06 11:20:01 +01004672 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
4673 .type = HDA_FIXUP_FUNC,
4674 .v.func = alc269_fixup_limit_int_mic_boost,
4675 .chained = true,
4676 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
4677 },
Anisse Astier02b504d2013-06-03 11:53:10 +02004678 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
4679 .type = HDA_FIXUP_PINS,
4680 .v.pins = (const struct hda_pintbl[]) {
4681 { 0x12, 0x99a3092f }, /* int-mic */
4682 { 0x18, 0x03a11d20 }, /* mic */
4683 { 0x19, 0x411111f0 }, /* Unused bogus pin */
4684 { }
4685 },
4686 },
Kailang Yangcd217a62013-08-22 10:15:24 +02004687 [ALC283_FIXUP_CHROME_BOOK] = {
4688 .type = HDA_FIXUP_FUNC,
4689 .v.func = alc283_fixup_chromebook,
4690 },
Kailang Yang0202e992013-12-02 15:20:15 +08004691 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
4692 .type = HDA_FIXUP_FUNC,
4693 .v.func = alc283_fixup_sense_combo_jack,
4694 .chained = true,
4695 .chain_id = ALC283_FIXUP_CHROME_BOOK,
4696 },
Takashi Iwai7bba2152013-09-06 15:45:38 +02004697 [ALC282_FIXUP_ASUS_TX300] = {
4698 .type = HDA_FIXUP_FUNC,
4699 .v.func = alc282_fixup_asus_tx300,
4700 },
Kailang Yang1bb3e062013-09-27 13:10:25 +02004701 [ALC283_FIXUP_INT_MIC] = {
4702 .type = HDA_FIXUP_VERBS,
4703 .v.verbs = (const struct hda_verb[]) {
4704 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
4705 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
4706 { }
4707 },
4708 .chained = true,
4709 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4710 },
David Henningsson0f4881d2013-12-20 16:08:13 +01004711 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
4712 .type = HDA_FIXUP_PINS,
4713 .v.pins = (const struct hda_pintbl[]) {
4714 { 0x17, 0x90170112 }, /* subwoofer */
4715 { }
4716 },
4717 .chained = true,
4718 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4719 },
4720 [ALC290_FIXUP_SUBWOOFER] = {
4721 .type = HDA_FIXUP_PINS,
4722 .v.pins = (const struct hda_pintbl[]) {
4723 { 0x17, 0x90170112 }, /* subwoofer */
4724 { }
4725 },
4726 .chained = true,
4727 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
4728 },
David Henningsson338cae52013-10-07 10:39:59 +02004729 [ALC290_FIXUP_MONO_SPEAKERS] = {
4730 .type = HDA_FIXUP_FUNC,
4731 .v.func = alc290_fixup_mono_speakers,
David Henningsson0f4881d2013-12-20 16:08:13 +01004732 },
4733 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
4734 .type = HDA_FIXUP_FUNC,
4735 .v.func = alc290_fixup_mono_speakers,
David Henningsson338cae52013-10-07 10:39:59 +02004736 .chained = true,
4737 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
4738 },
David Henningssonb67ae3f2013-11-05 13:11:37 +01004739 [ALC269_FIXUP_THINKPAD_ACPI] = {
4740 .type = HDA_FIXUP_FUNC,
Takashi Iwaib317b032014-01-08 11:44:21 +01004741 .v.func = hda_fixup_thinkpad_acpi,
David Henningssonb67ae3f2013-11-05 13:11:37 +01004742 },
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004743 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4744 .type = HDA_FIXUP_PINS,
4745 .v.pins = (const struct hda_pintbl[]) {
4746 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4747 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4748 { }
4749 },
4750 .chained = true,
4751 .chain_id = ALC255_FIXUP_HEADSET_MODE
4752 },
Kailang Yang31278992014-03-03 15:27:22 +08004753 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4754 .type = HDA_FIXUP_PINS,
4755 .v.pins = (const struct hda_pintbl[]) {
4756 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4757 { }
4758 },
4759 .chained = true,
4760 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
4761 },
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004762 [ALC255_FIXUP_HEADSET_MODE] = {
4763 .type = HDA_FIXUP_FUNC,
4764 .v.func = alc_fixup_headset_mode_alc255,
4765 },
Kailang Yang31278992014-03-03 15:27:22 +08004766 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4767 .type = HDA_FIXUP_FUNC,
4768 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
4769 },
Kailang Yanga22aa262014-04-23 17:34:28 +08004770 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4771 .type = HDA_FIXUP_PINS,
4772 .v.pins = (const struct hda_pintbl[]) {
4773 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4774 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4775 { }
4776 },
4777 .chained = true,
4778 .chain_id = ALC269_FIXUP_HEADSET_MODE
4779 },
Takashi Iwai1c37c222014-05-06 17:34:42 +02004780 [ALC292_FIXUP_TPT440_DOCK] = {
4781 .type = HDA_FIXUP_PINS,
4782 .v.pins = (const struct hda_pintbl[]) {
4783 { 0x16, 0x21211010 }, /* dock headphone */
4784 { 0x19, 0x21a11010 }, /* dock mic */
4785 { }
4786 },
4787 .chained = true,
4788 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4789 },
Daniel Drake9dc12862014-07-22 10:58:29 +01004790 [ALC283_FIXUP_BXBT2807_MIC] = {
4791 .type = HDA_FIXUP_PINS,
4792 .v.pins = (const struct hda_pintbl[]) {
4793 { 0x19, 0x04a110f0 },
4794 { },
4795 },
4796 },
Hui Wang00ef9942014-07-31 11:52:38 +08004797 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
4798 .type = HDA_FIXUP_FUNC,
4799 .v.func = alc_fixup_dell_wmi,
4800 .chained_before = true,
4801 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
4802 },
4803
Takashi Iwai1d045db2011-07-07 18:23:21 +02004804};
4805
4806static const struct snd_pci_quirk alc269_fixup_tbl[] = {
Marius Knausta6b92b62014-03-03 01:48:58 +01004807 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
David Henningsson693b6132012-06-22 19:12:10 +02004808 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
4809 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
David Henningssonaaedfb42013-08-16 14:09:02 +02004810 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
4811 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4812 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
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 Henningsson0f4881d2013-12-20 16:08:13 +01004815 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
David Henningsson73bdd592013-04-15 15:44:14 +02004816 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4817 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4818 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
Hui Wang00ef9942014-07-31 11:52:38 +08004819 SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
David Henningsson0f4881d2013-12-20 16:08:13 +01004820 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4821 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
Hui Wang00ef9942014-07-31 11:52:38 +08004822 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
David Henningsson0f4881d2013-12-20 16:08:13 +01004823 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
Kailang Yanga22aa262014-04-23 17:34:28 +08004824 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4825 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
Kailang Yanga22aa262014-04-23 17:34:28 +08004826 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4827 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004828 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004829 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
David Henningsson8e35cd42013-11-06 11:20:01 +01004830 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004831 /* ALC282 */
Kailang Yang8a02b162014-06-13 17:16:31 +08004832 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004833 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004834 SND_PCI_QUIRK(0x103c, 0x2234, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4835 SND_PCI_QUIRK(0x103c, 0x2235, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4836 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4837 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4838 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4839 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4840 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4841 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4842 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4843 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4844 SND_PCI_QUIRK(0x103c, 0x224a, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4845 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4846 SND_PCI_QUIRK(0x103c, 0x224c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4847 SND_PCI_QUIRK(0x103c, 0x224d, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004848 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004849 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4850 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004851 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004852 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004853 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4854 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4855 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004856 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004857 SND_PCI_QUIRK(0x103c, 0x22da, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4858 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4859 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4860 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4861 SND_PCI_QUIRK(0x103c, 0x8004, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004862 /* ALC290 */
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004863 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Hui Wang549d8782014-07-07 17:07:43 +08004864 SND_PCI_QUIRK(0x103c, 0x221c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4865 SND_PCI_QUIRK(0x103c, 0x221d, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004866 SND_PCI_QUIRK(0x103c, 0x2220, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4867 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4868 SND_PCI_QUIRK(0x103c, 0x2222, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4869 SND_PCI_QUIRK(0x103c, 0x2223, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4870 SND_PCI_QUIRK(0x103c, 0x2224, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4871 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4872 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4873 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4874 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4875 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4876 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4877 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4878 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4879 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4880 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4881 SND_PCI_QUIRK(0x103c, 0x2258, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4882 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4883 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004884 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004885 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4886 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4887 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004888 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4889 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4890 SND_PCI_QUIRK(0x103c, 0x2277, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4891 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004892 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004893 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004894 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004895 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4896 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004897 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4898 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004899 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004900 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4901 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4902 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4903 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Takashi Iwai7bba2152013-09-06 15:45:38 +02004904 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
David Henningsson3e0d6112013-04-22 14:30:14 +02004905 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4906 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Oleksij Rempel2cede302013-11-27 17:12:03 +01004907 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
Takashi Iwai23870832013-11-29 14:13:12 +01004908 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
David Henningsson3e0d6112013-04-22 14:30:14 +02004909 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
Takashi Iwai017f2a12011-07-09 14:42:25 +02004910 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
David Henningsson693b6132012-06-22 19:12:10 +02004911 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
David Henningsson3e0d6112013-04-22 14:30:14 +02004912 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004913 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
4914 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
4915 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
4916 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
David Henningssond240d1d2013-04-15 12:50:02 +02004917 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
Takashi Iwaif88abaa2014-02-07 12:07:59 +01004918 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
David Henningsson88cfcf82013-10-11 10:18:45 +02004919 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004920 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
4921 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
4922 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004923 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
Takashi Iwai24519912011-08-16 15:08:49 +02004924 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
David Henningsson2041d562014-06-13 11:15:44 +02004925 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
Daniel Drake9dc12862014-07-22 10:58:29 +01004926 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004927 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
4928 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
4929 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
4930 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
4931 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
Takashi Iwai707fba32012-08-02 09:04:39 +02004932 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
Felix Kaechelec8415a42012-08-06 23:02:01 +02004933 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
Stefán Freyr84f98fd2012-10-19 22:46:00 +02004934 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
Philipp A. Mohrenweiser4407be62012-08-06 13:14:18 +02004935 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
David Henningsson108cc102012-07-20 10:37:25 +02004936 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
David Henningssonaaedfb42013-08-16 14:09:02 +02004937 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
Takashi Iwai1c37c222014-05-06 17:34:42 +02004938 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
4939 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
Takashi Iwaia12137e2014-06-27 12:14:35 +02004940 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
David Henningssoncd5302c2013-08-19 12:22:33 +02004941 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningsson27937692013-11-18 11:51:47 +01004942 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningssona4a9e082013-08-16 14:09:01 +02004943 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004944 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
David Henningssona4a9e082013-08-16 14:09:01 +02004945 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Kailang Yang1bb3e062013-09-27 13:10:25 +02004946 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
David Henningssoncd5302c2013-08-19 12:22:33 +02004947 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4948 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningsson012e7eb2012-08-08 08:43:37 +02004949 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004950 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Anisse Astier02b504d2013-06-03 11:53:10 +02004951 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02004952
Takashi Iwaia7f3eed2012-02-16 13:03:18 +01004953#if 0
Takashi Iwaia4297b52011-08-23 18:40:12 +02004954 /* Below is a quirk table taken from the old code.
4955 * Basically the device should work as is without the fixup table.
4956 * If BIOS doesn't give a proper info, enable the corresponding
4957 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02004958 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02004959 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
4960 ALC269_FIXUP_AMIC),
4961 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
Takashi Iwaia4297b52011-08-23 18:40:12 +02004962 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
4963 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
4964 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
4965 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
4966 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
4967 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
4968 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
4969 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
4970 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
4971 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
4972 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
4973 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
4974 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
4975 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
4976 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
4977 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
4978 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
4979 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
4980 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
4981 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
4982 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
4983 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
4984 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
4985 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
4986 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
4987 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
4988 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
4989 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
4990 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
4991 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
4992 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
4993 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
4994 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
4995 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
4996 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
4997 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
4998 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
4999 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
5000#endif
5001 {}
5002};
5003
David Henningsson214eef72014-07-22 14:09:35 +02005004static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
5005 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
5006 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
5007 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
5008 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
5009 {}
5010};
5011
Takashi Iwai1727a772013-01-10 09:52:52 +01005012static const struct hda_model_fixup alc269_fixup_models[] = {
Takashi Iwaia4297b52011-08-23 18:40:12 +02005013 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5014 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02005015 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
5016 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
5017 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningsson7c478f02013-10-11 10:18:46 +02005018 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
David Henningsson108cc102012-07-20 10:37:25 +02005019 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01005020 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
David Henningssone32aa852013-06-17 11:04:02 +02005021 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
5022 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
Kailang Yangbe8ef162014-04-08 15:19:49 +08005023 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
Kailang Yang0202e992013-12-02 15:20:15 +08005024 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
Takashi Iwai1c37c222014-05-06 17:34:42 +02005025 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
Takashi Iwai1d045db2011-07-07 18:23:21 +02005026 {}
5027};
5028
Hui Wange1918932014-05-26 16:22:44 +08005029static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
Hui Wangc77900e2014-09-03 11:31:07 +08005030 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
5031 {0x12, 0x40300000},
5032 {0x14, 0x90170110},
5033 {0x17, 0x411111f0},
5034 {0x18, 0x411111f0},
5035 {0x19, 0x411111f0},
5036 {0x1a, 0x411111f0},
5037 {0x1b, 0x02a11030},
5038 {0x1d, 0x40538029},
5039 {0x1e, 0x411111f0},
5040 {0x21, 0x02211020}),
David Henningsson76c21322014-06-24 14:46:54 +02005041 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5042 {0x12, 0x90a60140},
5043 {0x14, 0x90170110},
5044 {0x17, 0x40000000},
5045 {0x18, 0x411111f0},
5046 {0x19, 0x411111f0},
5047 {0x1a, 0x411111f0},
5048 {0x1b, 0x411111f0},
5049 {0x1d, 0x40700001},
5050 {0x1e, 0x411111f0},
5051 {0x21, 0x02211020}),
5052 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5053 {0x12, 0x90a60160},
5054 {0x14, 0x90170120},
5055 {0x17, 0x40000000},
5056 {0x18, 0x411111f0},
5057 {0x19, 0x411111f0},
5058 {0x1a, 0x411111f0},
5059 {0x1b, 0x411111f0},
5060 {0x1d, 0x40700001},
5061 {0x1e, 0x411111f0},
5062 {0x21, 0x02211030}),
5063 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5064 {0x12, 0x90a60160},
5065 {0x14, 0x90170120},
5066 {0x17, 0x90170140},
5067 {0x18, 0x40000000},
5068 {0x19, 0x411111f0},
5069 {0x1a, 0x411111f0},
5070 {0x1b, 0x411111f0},
5071 {0x1d, 0x41163b05},
5072 {0x1e, 0x411111f0},
5073 {0x21, 0x0321102f}),
5074 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5075 {0x12, 0x90a60160},
5076 {0x14, 0x90170130},
5077 {0x17, 0x40000000},
5078 {0x18, 0x411111f0},
5079 {0x19, 0x411111f0},
5080 {0x1a, 0x411111f0},
5081 {0x1b, 0x411111f0},
5082 {0x1d, 0x40700001},
5083 {0x1e, 0x411111f0},
5084 {0x21, 0x02211040}),
5085 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5086 {0x12, 0x90a60160},
5087 {0x14, 0x90170140},
5088 {0x17, 0x40000000},
5089 {0x18, 0x411111f0},
5090 {0x19, 0x411111f0},
5091 {0x1a, 0x411111f0},
5092 {0x1b, 0x411111f0},
5093 {0x1d, 0x40700001},
5094 {0x1e, 0x411111f0},
5095 {0x21, 0x02211050}),
5096 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5097 {0x12, 0x90a60170},
5098 {0x14, 0x90170120},
5099 {0x17, 0x40000000},
5100 {0x18, 0x411111f0},
5101 {0x19, 0x411111f0},
5102 {0x1a, 0x411111f0},
5103 {0x1b, 0x411111f0},
5104 {0x1d, 0x40700001},
5105 {0x1e, 0x411111f0},
5106 {0x21, 0x02211030}),
5107 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5108 {0x12, 0x90a60170},
5109 {0x14, 0x90170130},
5110 {0x17, 0x40000000},
5111 {0x18, 0x411111f0},
5112 {0x19, 0x411111f0},
5113 {0x1a, 0x411111f0},
5114 {0x1b, 0x411111f0},
5115 {0x1d, 0x40700001},
5116 {0x1e, 0x411111f0},
5117 {0x21, 0x02211040}),
David Henningsson42304472014-07-22 11:42:17 +02005118 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5119 {0x12, 0x99a30130},
5120 {0x14, 0x90170110},
5121 {0x17, 0x40000000},
5122 {0x18, 0x411111f0},
5123 {0x19, 0x03a11020},
5124 {0x1a, 0x411111f0},
5125 {0x1b, 0x411111f0},
5126 {0x1d, 0x40f41905},
5127 {0x1e, 0x411111f0},
5128 {0x21, 0x0321101f}),
Hui Wang2c609992014-09-03 11:31:08 +08005129 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5130 {0x12, 0x99a30130},
5131 {0x14, 0x90170110},
5132 {0x17, 0x40020008},
5133 {0x18, 0x411111f0},
5134 {0x19, 0x03a11020},
5135 {0x1a, 0x411111f0},
5136 {0x1b, 0x411111f0},
5137 {0x1d, 0x40e00001},
5138 {0x1e, 0x411111f0},
5139 {0x21, 0x03211040}),
5140 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5141 {0x12, 0x99a30130},
5142 {0x14, 0x90170110},
5143 {0x17, 0x40000000},
5144 {0x18, 0x411111f0},
5145 {0x19, 0x03a11030},
5146 {0x1a, 0x411111f0},
5147 {0x1b, 0x411111f0},
5148 {0x1d, 0x40e00001},
5149 {0x1e, 0x411111f0},
5150 {0x21, 0x03211020}),
5151 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5152 {0x12, 0x99a30130},
5153 {0x14, 0x90170110},
5154 {0x17, 0x40000000},
5155 {0x18, 0x411111f0},
5156 {0x19, 0x03a11030},
5157 {0x1a, 0x411111f0},
5158 {0x1b, 0x411111f0},
5159 {0x1d, 0x40f00001},
5160 {0x1e, 0x411111f0},
5161 {0x21, 0x03211020}),
5162 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5163 {0x12, 0x99a30130},
5164 {0x14, 0x90170110},
5165 {0x17, 0x40000000},
5166 {0x18, 0x411111f0},
5167 {0x19, 0x04a11020},
5168 {0x1a, 0x411111f0},
5169 {0x1b, 0x411111f0},
5170 {0x1d, 0x40f00001},
5171 {0x1e, 0x411111f0},
5172 {0x21, 0x0421101f}),
5173 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5174 {0x12, 0x99a30130},
5175 {0x14, 0x90170110},
5176 {0x17, 0x40000000},
5177 {0x18, 0x411111f0},
5178 {0x19, 0x03a11030},
5179 {0x1a, 0x411111f0},
5180 {0x1b, 0x411111f0},
5181 {0x1d, 0x40f00001},
5182 {0x1e, 0x411111f0},
5183 {0x21, 0x04211020}),
David Henningsson76c21322014-06-24 14:46:54 +02005184 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5185 {0x12, 0x90a60130},
5186 {0x14, 0x90170110},
5187 {0x17, 0x40020008},
5188 {0x18, 0x411111f0},
5189 {0x19, 0x411111f0},
5190 {0x1a, 0x411111f0},
5191 {0x1b, 0x411111f0},
5192 {0x1d, 0x40e00001},
5193 {0x1e, 0x411111f0},
5194 {0x21, 0x0321101f}),
5195 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5196 {0x12, 0x90a60160},
5197 {0x14, 0x90170120},
5198 {0x17, 0x40000000},
5199 {0x18, 0x411111f0},
5200 {0x19, 0x411111f0},
5201 {0x1a, 0x411111f0},
5202 {0x1b, 0x411111f0},
5203 {0x1d, 0x40700001},
5204 {0x1e, 0x411111f0},
5205 {0x21, 0x02211030}),
Hui Wangbc262172014-09-03 11:31:05 +08005206 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5207 {0x12, 0x90a60130},
5208 {0x14, 0x90170110},
5209 {0x17, 0x40020008},
5210 {0x18, 0x411111f0},
5211 {0x19, 0x03a11020},
5212 {0x1a, 0x411111f0},
5213 {0x1b, 0x411111f0},
5214 {0x1d, 0x40e00001},
5215 {0x1e, 0x411111f0},
5216 {0x21, 0x0321101f}),
Hui Wange4442bc2014-09-03 11:31:09 +08005217 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5218 {0x12, 0x99a30130},
5219 {0x13, 0x40000000},
5220 {0x14, 0x411111f0},
5221 {0x15, 0x04211040},
5222 {0x16, 0x411111f0},
5223 {0x17, 0x411111f0},
5224 {0x18, 0x90170112},
5225 {0x19, 0x411111f0},
5226 {0x1a, 0x04a11020},
5227 {0x1b, 0x411111f0},
5228 {0x1d, 0x4075812d},
5229 {0x1e, 0x411111f0}),
5230 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5231 {0x12, 0x99a30130},
5232 {0x13, 0x40000000},
5233 {0x14, 0x411111f0},
5234 {0x15, 0x04211040},
5235 {0x16, 0x411111f0},
5236 {0x17, 0x411111f0},
5237 {0x18, 0x90170110},
5238 {0x19, 0x411111f0},
5239 {0x1a, 0x04a11020},
5240 {0x1b, 0x411111f0},
5241 {0x1d, 0x4075812d},
5242 {0x1e, 0x411111f0}),
5243 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5244 {0x12, 0x99a30130},
5245 {0x13, 0x40000000},
5246 {0x14, 0x411111f0},
5247 {0x15, 0x0421101f},
5248 {0x16, 0x411111f0},
5249 {0x17, 0x411111f0},
5250 {0x18, 0x411111f0},
5251 {0x19, 0x411111f0},
5252 {0x1a, 0x04a11020},
5253 {0x1b, 0x411111f0},
5254 {0x1d, 0x4075812d},
5255 {0x1e, 0x411111f0}),
5256 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5257 {0x12, 0x99a30130},
5258 {0x13, 0x40000000},
5259 {0x14, 0x411111f0},
5260 {0x15, 0x04211020},
5261 {0x16, 0x411111f0},
5262 {0x17, 0x411111f0},
5263 {0x18, 0x411111f0},
5264 {0x19, 0x411111f0},
5265 {0x1a, 0x04a11040},
5266 {0x1b, 0x411111f0},
5267 {0x1d, 0x4076a12d},
5268 {0x1e, 0x411111f0}),
5269 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5270 {0x12, 0x99a30130},
5271 {0x13, 0x40000000},
5272 {0x14, 0x90170110},
5273 {0x15, 0x04211020},
5274 {0x16, 0x411111f0},
5275 {0x17, 0x411111f0},
5276 {0x18, 0x411111f0},
5277 {0x19, 0x411111f0},
5278 {0x1a, 0x04a11040},
5279 {0x1b, 0x411111f0},
5280 {0x1d, 0x4076a12d},
5281 {0x1e, 0x411111f0}),
5282 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5283 {0x12, 0x99a30130},
5284 {0x13, 0x40000000},
5285 {0x14, 0x90170110},
5286 {0x15, 0x04211020},
5287 {0x16, 0x411111f0},
5288 {0x17, 0x411111f0},
5289 {0x18, 0x411111f0},
5290 {0x19, 0x411111f0},
5291 {0x1a, 0x04a11020},
5292 {0x1b, 0x411111f0},
5293 {0x1d, 0x4076a12d},
5294 {0x1e, 0x411111f0}),
5295 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
5296 {0x12, 0x99a30130},
5297 {0x13, 0x40000000},
5298 {0x14, 0x90170110},
5299 {0x15, 0x0421101f},
5300 {0x16, 0x411111f0},
5301 {0x17, 0x411111f0},
5302 {0x18, 0x411111f0},
5303 {0x19, 0x411111f0},
5304 {0x1a, 0x04a11020},
5305 {0x1b, 0x411111f0},
5306 {0x1d, 0x4075812d},
5307 {0x1e, 0x411111f0}),
Hui Wange8818fa2014-09-03 11:31:04 +08005308 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
5309 {0x12, 0x90a60140},
5310 {0x13, 0x411111f0},
5311 {0x14, 0x90170110},
5312 {0x15, 0x0221401f},
5313 {0x16, 0x01014020},
5314 {0x18, 0x411111f0},
5315 {0x19, 0x01a19030},
5316 {0x1a, 0x411111f0},
5317 {0x1b, 0x411111f0},
5318 {0x1d, 0x40700001},
5319 {0x1e, 0x411111f0}),
5320 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
5321 {0x12, 0x90a60140},
5322 {0x13, 0x411111f0},
5323 {0x14, 0x90170110},
5324 {0x15, 0x0221401f},
5325 {0x16, 0x01014020},
5326 {0x18, 0x02a19031},
5327 {0x19, 0x01a1903e},
5328 {0x1a, 0x411111f0},
5329 {0x1b, 0x411111f0},
5330 {0x1d, 0x40700001},
5331 {0x1e, 0x411111f0}),
David Henningsson76c21322014-06-24 14:46:54 +02005332 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5333 {0x12, 0x90a60140},
5334 {0x13, 0x411111f0},
5335 {0x14, 0x90170110},
5336 {0x15, 0x0221401f},
5337 {0x16, 0x411111f0},
5338 {0x18, 0x411111f0},
5339 {0x19, 0x411111f0},
5340 {0x1a, 0x411111f0},
5341 {0x1b, 0x411111f0},
5342 {0x1d, 0x40700001},
5343 {0x1e, 0x411111f0}),
5344 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5345 {0x12, 0x40000000},
5346 {0x13, 0x90a60140},
5347 {0x14, 0x90170110},
5348 {0x15, 0x0221401f},
5349 {0x16, 0x21014020},
5350 {0x18, 0x411111f0},
5351 {0x19, 0x21a19030},
5352 {0x1a, 0x411111f0},
5353 {0x1b, 0x411111f0},
5354 {0x1d, 0x40700001},
5355 {0x1e, 0x411111f0}),
David Henningssone03fdbd2014-06-27 08:41:59 +02005356 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5357 {0x12, 0x40000000},
5358 {0x13, 0x90a60140},
5359 {0x14, 0x90170110},
5360 {0x15, 0x0221401f},
5361 {0x16, 0x411111f0},
5362 {0x18, 0x411111f0},
5363 {0x19, 0x411111f0},
5364 {0x1a, 0x411111f0},
5365 {0x1b, 0x411111f0},
5366 {0x1d, 0x40700001},
5367 {0x1e, 0x411111f0}),
Hui Wange1918932014-05-26 16:22:44 +08005368 {}
5369};
Takashi Iwai1d045db2011-07-07 18:23:21 +02005370
Takashi Iwai546bb672012-03-07 08:37:19 +01005371static void alc269_fill_coef(struct hda_codec *codec)
Takashi Iwai1d045db2011-07-07 18:23:21 +02005372{
Kailang Yang526af6e2012-03-07 08:25:20 +01005373 struct alc_spec *spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005374 int val;
5375
Kailang Yang526af6e2012-03-07 08:25:20 +01005376 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
Takashi Iwai546bb672012-03-07 08:37:19 +01005377 return;
Kailang Yang526af6e2012-03-07 08:25:20 +01005378
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005379 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005380 alc_write_coef_idx(codec, 0xf, 0x960b);
5381 alc_write_coef_idx(codec, 0xe, 0x8817);
5382 }
5383
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005384 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005385 alc_write_coef_idx(codec, 0xf, 0x960b);
5386 alc_write_coef_idx(codec, 0xe, 0x8814);
5387 }
5388
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005389 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005390 /* Power up output pin */
Takashi Iwai98b24882014-08-18 13:47:50 +02005391 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005392 }
5393
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005394 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005395 val = alc_read_coef_idx(codec, 0xd);
Takashi Iwaif3ee07d2014-08-15 17:35:00 +02005396 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005397 /* Capless ramp up clock control */
5398 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5399 }
5400 val = alc_read_coef_idx(codec, 0x17);
Takashi Iwaif3ee07d2014-08-15 17:35:00 +02005401 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005402 /* Class D power on reset */
5403 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5404 }
5405 }
5406
Takashi Iwai98b24882014-08-18 13:47:50 +02005407 /* Class D */
5408 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005409
Takashi Iwai98b24882014-08-18 13:47:50 +02005410 /* HP */
5411 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005412}
5413
5414/*
5415 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005416static int patch_alc269(struct hda_codec *codec)
5417{
5418 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02005419 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005420
Takashi Iwai3de95172012-05-07 18:03:15 +02005421 err = alc_alloc_spec(codec, 0x0b);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005422 if (err < 0)
Takashi Iwai3de95172012-05-07 18:03:15 +02005423 return err;
5424
5425 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01005426 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005427
Takashi Iwai1727a772013-01-10 09:52:52 +01005428 snd_hda_pick_fixup(codec, alc269_fixup_models,
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03005429 alc269_fixup_tbl, alc269_fixups);
Hui Wange1918932014-05-26 16:22:44 +08005430 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
David Henningsson214eef72014-07-22 14:09:35 +02005431 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
5432 alc269_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01005433 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03005434
5435 alc_auto_parse_customize_define(codec);
5436
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005437 if (has_cdefine_beep(codec))
5438 spec->gen.beep_nid = 0x01;
5439
Kailang Yang065380f2013-01-10 10:25:48 +01005440 switch (codec->vendor_id) {
5441 case 0x10ec0269:
Takashi Iwai1d045db2011-07-07 18:23:21 +02005442 spec->codec_variant = ALC269_TYPE_ALC269VA;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005443 switch (alc_get_coef0(codec) & 0x00f0) {
5444 case 0x0010:
Takashi Iwai5100cd02014-02-15 10:03:19 +01005445 if (codec->bus->pci &&
5446 codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005447 spec->cdefine.platform_type == 1)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02005448 err = alc_codec_rename(codec, "ALC271X");
Takashi Iwai1d045db2011-07-07 18:23:21 +02005449 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005450 break;
5451 case 0x0020:
Takashi Iwai5100cd02014-02-15 10:03:19 +01005452 if (codec->bus->pci &&
5453 codec->bus->pci->subsystem_vendor == 0x17aa &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005454 codec->bus->pci->subsystem_device == 0x21f3)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02005455 err = alc_codec_rename(codec, "ALC3202");
Takashi Iwai1d045db2011-07-07 18:23:21 +02005456 spec->codec_variant = ALC269_TYPE_ALC269VC;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005457 break;
Kailang Yangadcc70b2012-05-25 08:08:38 +02005458 case 0x0030:
5459 spec->codec_variant = ALC269_TYPE_ALC269VD;
5460 break;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005461 default:
Takashi Iwai1d045db2011-07-07 18:23:21 +02005462 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005463 }
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005464 if (err < 0)
5465 goto error;
Takashi Iwai546bb672012-03-07 08:37:19 +01005466 spec->init_hook = alc269_fill_coef;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005467 alc269_fill_coef(codec);
Kailang Yang065380f2013-01-10 10:25:48 +01005468 break;
5469
5470 case 0x10ec0280:
5471 case 0x10ec0290:
5472 spec->codec_variant = ALC269_TYPE_ALC280;
5473 break;
5474 case 0x10ec0282:
Kailang Yang065380f2013-01-10 10:25:48 +01005475 spec->codec_variant = ALC269_TYPE_ALC282;
Kailang Yang7b5c7a02014-03-18 16:15:54 +08005476 spec->shutup = alc282_shutup;
5477 spec->init_hook = alc282_init;
Kailang Yang065380f2013-01-10 10:25:48 +01005478 break;
Kailang Yang2af02be2013-08-22 10:03:50 +02005479 case 0x10ec0233:
5480 case 0x10ec0283:
5481 spec->codec_variant = ALC269_TYPE_ALC283;
5482 spec->shutup = alc283_shutup;
5483 spec->init_hook = alc283_init;
5484 break;
Kailang Yang065380f2013-01-10 10:25:48 +01005485 case 0x10ec0284:
5486 case 0x10ec0292:
5487 spec->codec_variant = ALC269_TYPE_ALC284;
5488 break;
Kailang Yang161ebf22013-10-24 11:36:33 +02005489 case 0x10ec0285:
5490 case 0x10ec0293:
5491 spec->codec_variant = ALC269_TYPE_ALC285;
5492 break;
Kailang Yang7fc7d042013-04-25 11:04:43 +02005493 case 0x10ec0286:
Kailang Yang7c665932014-04-14 15:09:44 +08005494 case 0x10ec0288:
Kailang Yang7fc7d042013-04-25 11:04:43 +02005495 spec->codec_variant = ALC269_TYPE_ALC286;
Kailang Yangf7ae9ba2014-06-30 16:10:37 +08005496 spec->shutup = alc286_shutup;
Kailang Yang7fc7d042013-04-25 11:04:43 +02005497 break;
Kailang Yang1d04c9d2013-10-24 11:35:18 +02005498 case 0x10ec0255:
5499 spec->codec_variant = ALC269_TYPE_ALC255;
5500 break;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005501 }
5502
Kailang Yangad60d502013-06-28 12:03:01 +02005503 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
Kailang Yang97a26572013-11-29 00:35:26 -05005504 spec->has_alc5505_dsp = 1;
Kailang Yangad60d502013-06-28 12:03:01 +02005505 spec->init_hook = alc5505_dsp_init;
5506 }
5507
Takashi Iwaia4297b52011-08-23 18:40:12 +02005508 /* automatic parse from the BIOS config */
5509 err = alc269_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005510 if (err < 0)
5511 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005512
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005513 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02005514 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5515
Takashi Iwai1d045db2011-07-07 18:23:21 +02005516 codec->patch_ops = alc_patch_ops;
Takashi Iwai2a439522011-07-26 09:52:50 +02005517#ifdef CONFIG_PM
Kailang Yangad60d502013-06-28 12:03:01 +02005518 codec->patch_ops.suspend = alc269_suspend;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005519 codec->patch_ops.resume = alc269_resume;
5520#endif
Kailang Yangc5177c82013-07-24 14:39:49 +02005521 if (!spec->shutup)
5522 spec->shutup = alc269_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005523
Takashi Iwai1727a772013-01-10 09:52:52 +01005524 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005525
Takashi Iwai1d045db2011-07-07 18:23:21 +02005526 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005527
5528 error:
5529 alc_free(codec);
5530 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005531}
5532
5533/*
5534 * ALC861
5535 */
5536
Takashi Iwai1d045db2011-07-07 18:23:21 +02005537static int alc861_parse_auto_config(struct hda_codec *codec)
5538{
Takashi Iwai1d045db2011-07-07 18:23:21 +02005539 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005540 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5541 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005542}
5543
Takashi Iwai1d045db2011-07-07 18:23:21 +02005544/* Pin config fixes */
5545enum {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005546 ALC861_FIXUP_FSC_AMILO_PI1505,
5547 ALC861_FIXUP_AMP_VREF_0F,
5548 ALC861_FIXUP_NO_JACK_DETECT,
5549 ALC861_FIXUP_ASUS_A6RP,
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005550 ALC660_FIXUP_ASUS_W7J,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005551};
5552
Takashi Iwai31150f22012-01-30 10:54:08 +01005553/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
5554static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005555 const struct hda_fixup *fix, int action)
Takashi Iwai31150f22012-01-30 10:54:08 +01005556{
5557 struct alc_spec *spec = codec->spec;
5558 unsigned int val;
5559
Takashi Iwai1727a772013-01-10 09:52:52 +01005560 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai31150f22012-01-30 10:54:08 +01005561 return;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01005562 val = snd_hda_codec_get_pin_target(codec, 0x0f);
Takashi Iwai31150f22012-01-30 10:54:08 +01005563 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
5564 val |= AC_PINCTL_IN_EN;
5565 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005566 snd_hda_set_pin_ctl(codec, 0x0f, val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01005567 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai31150f22012-01-30 10:54:08 +01005568}
5569
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005570/* suppress the jack-detection */
5571static void alc_fixup_no_jack_detect(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005572 const struct hda_fixup *fix, int action)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005573{
Takashi Iwai1727a772013-01-10 09:52:52 +01005574 if (action == HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005575 codec->no_jack_detect = 1;
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02005576}
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005577
Takashi Iwai1727a772013-01-10 09:52:52 +01005578static const struct hda_fixup alc861_fixups[] = {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005579 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005580 .type = HDA_FIXUP_PINS,
5581 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005582 { 0x0b, 0x0221101f }, /* HP */
5583 { 0x0f, 0x90170310 }, /* speaker */
5584 { }
5585 }
5586 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005587 [ALC861_FIXUP_AMP_VREF_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005588 .type = HDA_FIXUP_FUNC,
Takashi Iwai31150f22012-01-30 10:54:08 +01005589 .v.func = alc861_fixup_asus_amp_vref_0f,
Takashi Iwai3b25eb62012-01-25 09:55:46 +01005590 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005591 [ALC861_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005592 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005593 .v.func = alc_fixup_no_jack_detect,
5594 },
5595 [ALC861_FIXUP_ASUS_A6RP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005596 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005597 .v.func = alc861_fixup_asus_amp_vref_0f,
5598 .chained = true,
5599 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005600 },
5601 [ALC660_FIXUP_ASUS_W7J] = {
5602 .type = HDA_FIXUP_VERBS,
5603 .v.verbs = (const struct hda_verb[]) {
5604 /* ASUS W7J needs a magic pin setup on unused NID 0x10
5605 * for enabling outputs
5606 */
5607 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5608 { }
5609 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005610 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02005611};
5612
5613static const struct snd_pci_quirk alc861_fixup_tbl[] = {
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005614 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
Takashi Iwaie7ca2372013-12-02 15:27:19 +01005615 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005616 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
5617 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
5618 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
5619 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
5620 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
5621 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005622 {}
5623};
5624
5625/*
5626 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005627static int patch_alc861(struct hda_codec *codec)
5628{
5629 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005630 int err;
5631
Takashi Iwai3de95172012-05-07 18:03:15 +02005632 err = alc_alloc_spec(codec, 0x15);
5633 if (err < 0)
5634 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005635
Takashi Iwai3de95172012-05-07 18:03:15 +02005636 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005637 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005638
Takashi Iwai1727a772013-01-10 09:52:52 +01005639 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5640 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005641
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005642 /* automatic parse from the BIOS config */
5643 err = alc861_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005644 if (err < 0)
5645 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005646
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005647 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005648 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005649
Takashi Iwai1d045db2011-07-07 18:23:21 +02005650 codec->patch_ops = alc_patch_ops;
Takashi Iwai83012a72012-08-24 18:38:08 +02005651#ifdef CONFIG_PM
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005652 spec->power_hook = alc_power_eapd;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005653#endif
5654
Takashi Iwai1727a772013-01-10 09:52:52 +01005655 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005656
Takashi Iwai1d045db2011-07-07 18:23:21 +02005657 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005658
5659 error:
5660 alc_free(codec);
5661 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005662}
5663
5664/*
5665 * ALC861-VD support
5666 *
5667 * Based on ALC882
5668 *
5669 * In addition, an independent DAC
5670 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005671static int alc861vd_parse_auto_config(struct hda_codec *codec)
5672{
Takashi Iwai1d045db2011-07-07 18:23:21 +02005673 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005674 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5675 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005676}
5677
Takashi Iwai1d045db2011-07-07 18:23:21 +02005678enum {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005679 ALC660VD_FIX_ASUS_GPIO1,
5680 ALC861VD_FIX_DALLAS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005681};
5682
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005683/* exclude VREF80 */
5684static void alc861vd_fixup_dallas(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005685 const struct hda_fixup *fix, int action)
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005686{
Takashi Iwai1727a772013-01-10 09:52:52 +01005687 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaib78562b2012-12-17 20:06:49 +01005688 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
5689 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005690 }
5691}
5692
Takashi Iwai1727a772013-01-10 09:52:52 +01005693static const struct hda_fixup alc861vd_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005694 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005695 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005696 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005697 /* reset GPIO1 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005698 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5699 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5700 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5701 { }
5702 }
5703 },
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005704 [ALC861VD_FIX_DALLAS] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005705 .type = HDA_FIXUP_FUNC,
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005706 .v.func = alc861vd_fixup_dallas,
5707 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02005708};
5709
5710static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005711 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005712 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005713 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005714 {}
5715};
5716
Takashi Iwai1d045db2011-07-07 18:23:21 +02005717/*
5718 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005719static int patch_alc861vd(struct hda_codec *codec)
5720{
5721 struct alc_spec *spec;
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005722 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005723
Takashi Iwai3de95172012-05-07 18:03:15 +02005724 err = alc_alloc_spec(codec, 0x0b);
5725 if (err < 0)
5726 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005727
Takashi Iwai3de95172012-05-07 18:03:15 +02005728 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005729 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005730
Takashi Iwai1727a772013-01-10 09:52:52 +01005731 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5732 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005733
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005734 /* automatic parse from the BIOS config */
5735 err = alc861vd_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005736 if (err < 0)
5737 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005738
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005739 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005740 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005741
Takashi Iwai1d045db2011-07-07 18:23:21 +02005742 codec->patch_ops = alc_patch_ops;
5743
Takashi Iwai1d045db2011-07-07 18:23:21 +02005744 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005745
Takashi Iwai1727a772013-01-10 09:52:52 +01005746 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005747
Takashi Iwai1d045db2011-07-07 18:23:21 +02005748 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005749
5750 error:
5751 alc_free(codec);
5752 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005753}
5754
5755/*
5756 * ALC662 support
5757 *
5758 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5759 * configuration. Each pin widget can choose any input DACs and a mixer.
5760 * Each ADC is connected from a mixer of all inputs. This makes possible
5761 * 6-channel independent captures.
5762 *
5763 * In addition, an independent DAC for the multi-playback (not used in this
5764 * driver yet).
5765 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005766
5767/*
5768 * BIOS auto configuration
5769 */
5770
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005771static int alc662_parse_auto_config(struct hda_codec *codec)
5772{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005773 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005774 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5775 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5776 const hda_nid_t *ssids;
Takashi Iwaiee979a142008-09-02 15:42:20 +02005777
Kailang Yang6227cdc2010-02-25 08:36:52 +01005778 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Rainer Koenig1d87caa2013-04-04 08:40:38 +02005779 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
5780 codec->vendor_id == 0x10ec0671)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005781 ssids = alc663_ssids;
Kailang Yang6227cdc2010-02-25 08:36:52 +01005782 else
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005783 ssids = alc662_ssids;
5784 return alc_parse_auto_config(codec, alc662_ignore, ssids);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005785}
5786
Todd Broch6be79482010-12-07 16:51:05 -08005787static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005788 const struct hda_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01005789{
Takashi Iwai9bb1f062013-01-10 17:14:29 +01005790 if (action != HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01005791 return;
Todd Broch6be79482010-12-07 16:51:05 -08005792 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5793 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5794 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5795 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5796 (0 << AC_AMPCAP_MUTE_SHIFT)))
Takashi Iwai4e76a882014-02-25 12:21:03 +01005797 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
Todd Broch6be79482010-12-07 16:51:05 -08005798}
5799
Takashi Iwai8e383952013-10-30 17:41:12 +01005800static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
5801 { .channels = 2,
5802 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
5803 { .channels = 4,
5804 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
5805 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
5806 { }
5807};
5808
5809/* override the 2.1 chmap */
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01005810static void alc_fixup_bass_chmap(struct hda_codec *codec,
Takashi Iwai8e383952013-10-30 17:41:12 +01005811 const struct hda_fixup *fix, int action)
5812{
5813 if (action == HDA_FIXUP_ACT_BUILD) {
5814 struct alc_spec *spec = codec->spec;
5815 spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps;
5816 }
5817}
5818
Takashi Iwai3e887f32014-01-10 17:50:58 +01005819/* turn on/off mute LED per vmaster hook */
5820static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
5821{
5822 struct hda_codec *codec = private_data;
5823 struct alc_spec *spec = codec->spec;
5824 unsigned int oldval = spec->gpio_led;
5825
5826 if (enabled)
5827 spec->gpio_led &= ~0x01;
5828 else
5829 spec->gpio_led |= 0x01;
5830 if (spec->gpio_led != oldval)
5831 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5832 spec->gpio_led);
5833}
5834
Takashi Iwaibf686652014-01-13 16:18:25 +01005835/* avoid D3 for keeping GPIO up */
5836static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5837 hda_nid_t nid,
5838 unsigned int power_state)
5839{
5840 struct alc_spec *spec = codec->spec;
5841 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5842 return AC_PWRST_D0;
5843 return power_state;
5844}
5845
Takashi Iwai3e887f32014-01-10 17:50:58 +01005846static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5847 const struct hda_fixup *fix, int action)
5848{
5849 struct alc_spec *spec = codec->spec;
5850 static const struct hda_verb gpio_init[] = {
5851 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
5852 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
5853 {}
5854 };
5855
5856 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5857 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
5858 spec->gpio_led = 0;
5859 snd_hda_add_verbs(codec, gpio_init);
Takashi Iwaibf686652014-01-13 16:18:25 +01005860 codec->power_filter = gpio_led_power_filter;
Takashi Iwai3e887f32014-01-10 17:50:58 +01005861 }
5862}
5863
David Henningsson6cb3b702010-09-09 08:51:44 +02005864enum {
Daniel T Chen2df03512010-10-10 22:39:28 -04005865 ALC662_FIXUP_ASPIRE,
Takashi Iwai3e887f32014-01-10 17:50:58 +01005866 ALC662_FIXUP_LED_GPIO1,
David Henningsson6cb3b702010-09-09 08:51:44 +02005867 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -08005868 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005869 ALC662_FIXUP_CZC_P10T,
David Henningsson94024cd2011-04-29 14:10:55 +02005870 ALC662_FIXUP_SKU_IGNORE,
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005871 ALC662_FIXUP_HP_RP5800,
Takashi Iwai53c334a2011-08-23 18:27:14 +02005872 ALC662_FIXUP_ASUS_MODE1,
5873 ALC662_FIXUP_ASUS_MODE2,
5874 ALC662_FIXUP_ASUS_MODE3,
5875 ALC662_FIXUP_ASUS_MODE4,
5876 ALC662_FIXUP_ASUS_MODE5,
5877 ALC662_FIXUP_ASUS_MODE6,
5878 ALC662_FIXUP_ASUS_MODE7,
5879 ALC662_FIXUP_ASUS_MODE8,
Takashi Iwai1565cc32012-02-13 12:03:25 +01005880 ALC662_FIXUP_NO_JACK_DETECT,
David Henningssonedfe3bf2012-06-12 13:15:12 +02005881 ALC662_FIXUP_ZOTAC_Z68,
Takashi Iwai125821a2012-06-22 14:30:29 +02005882 ALC662_FIXUP_INV_DMIC,
David Henningsson73bdd592013-04-15 15:44:14 +02005883 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
5884 ALC668_FIXUP_HEADSET_MODE,
David Henningsson8e54b4a2014-02-07 09:31:07 +01005885 ALC662_FIXUP_BASS_MODE4_CHMAP,
David Henningsson61a75f12014-02-07 09:31:08 +01005886 ALC662_FIXUP_BASS_16,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005887 ALC662_FIXUP_BASS_1A,
David Henningsson8e54b4a2014-02-07 09:31:07 +01005888 ALC662_FIXUP_BASS_CHMAP,
Hui Wang493a52a2014-01-14 14:07:36 +08005889 ALC668_FIXUP_AUTO_MUTE,
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02005890 ALC668_FIXUP_DELL_DISABLE_AAMIX,
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02005891 ALC668_FIXUP_DELL_XPS13,
David Henningsson6cb3b702010-09-09 08:51:44 +02005892};
5893
Takashi Iwai1727a772013-01-10 09:52:52 +01005894static const struct hda_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -04005895 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005896 .type = HDA_FIXUP_PINS,
5897 .v.pins = (const struct hda_pintbl[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -04005898 { 0x15, 0x99130112 }, /* subwoofer */
5899 { }
5900 }
5901 },
Takashi Iwai3e887f32014-01-10 17:50:58 +01005902 [ALC662_FIXUP_LED_GPIO1] = {
5903 .type = HDA_FIXUP_FUNC,
5904 .v.func = alc662_fixup_led_gpio1,
5905 },
David Henningsson6cb3b702010-09-09 08:51:44 +02005906 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005907 .type = HDA_FIXUP_PINS,
5908 .v.pins = (const struct hda_pintbl[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +02005909 { 0x17, 0x99130112 }, /* subwoofer */
5910 { }
Takashi Iwai3e887f32014-01-10 17:50:58 +01005911 },
5912 .chained = true,
5913 .chain_id = ALC662_FIXUP_LED_GPIO1,
David Henningsson6cb3b702010-09-09 08:51:44 +02005914 },
Todd Broch6be79482010-12-07 16:51:05 -08005915 [ALC272_FIXUP_MARIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005916 .type = HDA_FIXUP_FUNC,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01005917 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005918 },
5919 [ALC662_FIXUP_CZC_P10T] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005920 .type = HDA_FIXUP_VERBS,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005921 .v.verbs = (const struct hda_verb[]) {
5922 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5923 {}
5924 }
5925 },
David Henningsson94024cd2011-04-29 14:10:55 +02005926 [ALC662_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005927 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02005928 .v.func = alc_fixup_sku_ignore,
Takashi Iwaic6b35872011-03-28 12:05:31 +02005929 },
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005930 [ALC662_FIXUP_HP_RP5800] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005931 .type = HDA_FIXUP_PINS,
5932 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005933 { 0x14, 0x0221201f }, /* HP out */
5934 { }
5935 },
5936 .chained = true,
5937 .chain_id = ALC662_FIXUP_SKU_IGNORE
5938 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02005939 [ALC662_FIXUP_ASUS_MODE1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005940 .type = HDA_FIXUP_PINS,
5941 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005942 { 0x14, 0x99130110 }, /* speaker */
5943 { 0x18, 0x01a19c20 }, /* mic */
5944 { 0x19, 0x99a3092f }, /* int-mic */
5945 { 0x21, 0x0121401f }, /* HP out */
5946 { }
5947 },
5948 .chained = true,
5949 .chain_id = ALC662_FIXUP_SKU_IGNORE
5950 },
5951 [ALC662_FIXUP_ASUS_MODE2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005952 .type = HDA_FIXUP_PINS,
5953 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai2996bdb2011-08-18 16:02:24 +02005954 { 0x14, 0x99130110 }, /* speaker */
5955 { 0x18, 0x01a19820 }, /* mic */
5956 { 0x19, 0x99a3092f }, /* int-mic */
5957 { 0x1b, 0x0121401f }, /* HP out */
5958 { }
5959 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02005960 .chained = true,
5961 .chain_id = ALC662_FIXUP_SKU_IGNORE
5962 },
5963 [ALC662_FIXUP_ASUS_MODE3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005964 .type = HDA_FIXUP_PINS,
5965 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005966 { 0x14, 0x99130110 }, /* speaker */
5967 { 0x15, 0x0121441f }, /* HP */
5968 { 0x18, 0x01a19840 }, /* mic */
5969 { 0x19, 0x99a3094f }, /* int-mic */
5970 { 0x21, 0x01211420 }, /* HP2 */
5971 { }
5972 },
5973 .chained = true,
5974 .chain_id = ALC662_FIXUP_SKU_IGNORE
5975 },
5976 [ALC662_FIXUP_ASUS_MODE4] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005977 .type = HDA_FIXUP_PINS,
5978 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005979 { 0x14, 0x99130110 }, /* speaker */
5980 { 0x16, 0x99130111 }, /* speaker */
5981 { 0x18, 0x01a19840 }, /* mic */
5982 { 0x19, 0x99a3094f }, /* int-mic */
5983 { 0x21, 0x0121441f }, /* HP */
5984 { }
5985 },
5986 .chained = true,
5987 .chain_id = ALC662_FIXUP_SKU_IGNORE
5988 },
5989 [ALC662_FIXUP_ASUS_MODE5] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005990 .type = HDA_FIXUP_PINS,
5991 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005992 { 0x14, 0x99130110 }, /* speaker */
5993 { 0x15, 0x0121441f }, /* HP */
5994 { 0x16, 0x99130111 }, /* speaker */
5995 { 0x18, 0x01a19840 }, /* mic */
5996 { 0x19, 0x99a3094f }, /* int-mic */
5997 { }
5998 },
5999 .chained = true,
6000 .chain_id = ALC662_FIXUP_SKU_IGNORE
6001 },
6002 [ALC662_FIXUP_ASUS_MODE6] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01006003 .type = HDA_FIXUP_PINS,
6004 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02006005 { 0x14, 0x99130110 }, /* speaker */
6006 { 0x15, 0x01211420 }, /* HP2 */
6007 { 0x18, 0x01a19840 }, /* mic */
6008 { 0x19, 0x99a3094f }, /* int-mic */
6009 { 0x1b, 0x0121441f }, /* HP */
6010 { }
6011 },
6012 .chained = true,
6013 .chain_id = ALC662_FIXUP_SKU_IGNORE
6014 },
6015 [ALC662_FIXUP_ASUS_MODE7] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01006016 .type = HDA_FIXUP_PINS,
6017 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02006018 { 0x14, 0x99130110 }, /* speaker */
6019 { 0x17, 0x99130111 }, /* speaker */
6020 { 0x18, 0x01a19840 }, /* mic */
6021 { 0x19, 0x99a3094f }, /* int-mic */
6022 { 0x1b, 0x01214020 }, /* HP */
6023 { 0x21, 0x0121401f }, /* HP */
6024 { }
6025 },
6026 .chained = true,
6027 .chain_id = ALC662_FIXUP_SKU_IGNORE
6028 },
6029 [ALC662_FIXUP_ASUS_MODE8] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01006030 .type = HDA_FIXUP_PINS,
6031 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02006032 { 0x14, 0x99130110 }, /* speaker */
6033 { 0x12, 0x99a30970 }, /* int-mic */
6034 { 0x15, 0x01214020 }, /* HP */
6035 { 0x17, 0x99130111 }, /* speaker */
6036 { 0x18, 0x01a19840 }, /* mic */
6037 { 0x21, 0x0121401f }, /* HP */
6038 { }
6039 },
6040 .chained = true,
6041 .chain_id = ALC662_FIXUP_SKU_IGNORE
Takashi Iwai2996bdb2011-08-18 16:02:24 +02006042 },
Takashi Iwai1565cc32012-02-13 12:03:25 +01006043 [ALC662_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01006044 .type = HDA_FIXUP_FUNC,
Takashi Iwai1565cc32012-02-13 12:03:25 +01006045 .v.func = alc_fixup_no_jack_detect,
6046 },
David Henningssonedfe3bf2012-06-12 13:15:12 +02006047 [ALC662_FIXUP_ZOTAC_Z68] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01006048 .type = HDA_FIXUP_PINS,
6049 .v.pins = (const struct hda_pintbl[]) {
David Henningssonedfe3bf2012-06-12 13:15:12 +02006050 { 0x1b, 0x02214020 }, /* Front HP */
6051 { }
6052 }
6053 },
Takashi Iwai125821a2012-06-22 14:30:29 +02006054 [ALC662_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01006055 .type = HDA_FIXUP_FUNC,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02006056 .v.func = alc_fixup_inv_dmic_0x12,
Takashi Iwai125821a2012-06-22 14:30:29 +02006057 },
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02006058 [ALC668_FIXUP_DELL_XPS13] = {
6059 .type = HDA_FIXUP_FUNC,
6060 .v.func = alc_fixup_dell_xps13,
6061 .chained = true,
6062 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
6063 },
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02006064 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
6065 .type = HDA_FIXUP_FUNC,
6066 .v.func = alc_fixup_disable_aamix,
6067 .chained = true,
6068 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
6069 },
Hui Wang493a52a2014-01-14 14:07:36 +08006070 [ALC668_FIXUP_AUTO_MUTE] = {
6071 .type = HDA_FIXUP_FUNC,
6072 .v.func = alc_fixup_auto_mute_via_amp,
6073 .chained = true,
6074 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
6075 },
David Henningsson73bdd592013-04-15 15:44:14 +02006076 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
6077 .type = HDA_FIXUP_PINS,
6078 .v.pins = (const struct hda_pintbl[]) {
6079 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
6080 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
6081 { }
6082 },
6083 .chained = true,
6084 .chain_id = ALC668_FIXUP_HEADSET_MODE
6085 },
6086 [ALC668_FIXUP_HEADSET_MODE] = {
6087 .type = HDA_FIXUP_FUNC,
6088 .v.func = alc_fixup_headset_mode_alc668,
6089 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01006090 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
Takashi Iwai8e383952013-10-30 17:41:12 +01006091 .type = HDA_FIXUP_FUNC,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01006092 .v.func = alc_fixup_bass_chmap,
Takashi Iwai8e383952013-10-30 17:41:12 +01006093 .chained = true,
6094 .chain_id = ALC662_FIXUP_ASUS_MODE4
6095 },
David Henningsson61a75f12014-02-07 09:31:08 +01006096 [ALC662_FIXUP_BASS_16] = {
6097 .type = HDA_FIXUP_PINS,
6098 .v.pins = (const struct hda_pintbl[]) {
6099 {0x16, 0x80106111}, /* bass speaker */
6100 {}
6101 },
6102 .chained = true,
6103 .chain_id = ALC662_FIXUP_BASS_CHMAP,
6104 },
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006105 [ALC662_FIXUP_BASS_1A] = {
6106 .type = HDA_FIXUP_PINS,
6107 .v.pins = (const struct hda_pintbl[]) {
6108 {0x1a, 0x80106111}, /* bass speaker */
6109 {}
6110 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01006111 .chained = true,
6112 .chain_id = ALC662_FIXUP_BASS_CHMAP,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006113 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01006114 [ALC662_FIXUP_BASS_CHMAP] = {
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006115 .type = HDA_FIXUP_FUNC,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01006116 .v.func = alc_fixup_bass_chmap,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006117 },
David Henningsson6cb3b702010-09-09 08:51:44 +02006118};
6119
Takashi Iwaia9111322011-05-02 11:30:18 +02006120static const struct snd_pci_quirk alc662_fixup_tbl[] = {
Takashi Iwai53c334a2011-08-23 18:27:14 +02006121 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
Takashi Iwaid3d38352013-08-19 20:05:50 +02006122 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
David Henningssona6c47a82011-02-10 15:39:19 +01006123 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
David Henningsson94024cd2011-04-29 14:10:55 +02006124 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
Takashi Iwai125821a2012-06-22 14:30:29 +02006125 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
Takashi Iwai18019282013-08-16 08:17:05 +02006126 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
Daniel T Chen2df03512010-10-10 22:39:28 -04006127 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
David Henningsson73bdd592013-04-15 15:44:14 +02006128 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6129 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Takashi Iwaic5d019c2014-07-22 17:33:32 +02006130 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02006131 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
David Henningsson09d20142013-11-20 11:43:30 +01006132 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
David Henningssonad8ff99e2013-11-07 09:28:59 +01006133 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Kailang Yang8dc9abb2014-04-16 15:53:12 +08006134 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6135 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02006136 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
David Henningsson8e54b4a2014-02-07 09:31:07 +01006137 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
6138 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
David Henningsson61a75f12014-02-07 09:31:08 +01006139 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
6140 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
David Henningsson8e54b4a2014-02-07 09:31:07 +01006141 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
Takashi Iwai1565cc32012-02-13 12:03:25 +01006142 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
Takashi Iwai53c334a2011-08-23 18:27:14 +02006143 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
Daniel T Chena0e90ac2010-11-20 10:20:35 -05006144 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +06006145 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +02006146 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
David Henningssonedfe3bf2012-06-12 13:15:12 +02006147 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
Anisse Astierd2ebd472011-01-20 12:36:21 +01006148 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
Takashi Iwai53c334a2011-08-23 18:27:14 +02006149
6150#if 0
6151 /* Below is a quirk table taken from the old code.
6152 * Basically the device should work as is without the fixup table.
6153 * If BIOS doesn't give a proper info, enable the corresponding
6154 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02006155 */
Takashi Iwai53c334a2011-08-23 18:27:14 +02006156 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6157 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6158 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6159 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6160 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6161 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6162 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6163 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6164 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6165 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6166 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6167 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6168 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6169 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6170 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6171 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6172 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6173 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6174 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6175 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6176 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6177 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6178 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6179 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6180 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6181 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6182 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6183 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6184 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6185 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6186 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6187 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6188 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6189 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6190 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6191 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6192 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6193 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6194 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6195 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6196 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6197 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6198 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6199 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6200 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6201 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6202 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6203 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6204 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6205 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6206#endif
David Henningsson6cb3b702010-09-09 08:51:44 +02006207 {}
6208};
6209
Takashi Iwai1727a772013-01-10 09:52:52 +01006210static const struct hda_model_fixup alc662_fixup_models[] = {
Todd Broch6be79482010-12-07 16:51:05 -08006211 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
Takashi Iwai53c334a2011-08-23 18:27:14 +02006212 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6213 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6214 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6215 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6216 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6217 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6218 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6219 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02006220 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningssone32aa852013-06-17 11:04:02 +02006221 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
Todd Broch6be79482010-12-07 16:51:05 -08006222 {}
6223};
David Henningsson6cb3b702010-09-09 08:51:44 +02006224
Hui Wang532895c2014-05-29 15:59:19 +08006225static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
David Henningsson76c21322014-06-24 14:46:54 +02006226 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6227 {0x12, 0x99a30130},
6228 {0x14, 0x90170110},
6229 {0x15, 0x0321101f},
6230 {0x16, 0x03011020},
6231 {0x18, 0x40000008},
6232 {0x19, 0x411111f0},
6233 {0x1a, 0x411111f0},
6234 {0x1b, 0x411111f0},
6235 {0x1d, 0x41000001},
6236 {0x1e, 0x411111f0},
6237 {0x1f, 0x411111f0}),
6238 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6239 {0x12, 0x99a30140},
6240 {0x14, 0x90170110},
6241 {0x15, 0x0321101f},
6242 {0x16, 0x03011020},
6243 {0x18, 0x40000008},
6244 {0x19, 0x411111f0},
6245 {0x1a, 0x411111f0},
6246 {0x1b, 0x411111f0},
6247 {0x1d, 0x41000001},
6248 {0x1e, 0x411111f0},
6249 {0x1f, 0x411111f0}),
6250 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6251 {0x12, 0x99a30150},
6252 {0x14, 0x90170110},
6253 {0x15, 0x0321101f},
6254 {0x16, 0x03011020},
6255 {0x18, 0x40000008},
6256 {0x19, 0x411111f0},
6257 {0x1a, 0x411111f0},
6258 {0x1b, 0x411111f0},
6259 {0x1d, 0x41000001},
6260 {0x1e, 0x411111f0},
6261 {0x1f, 0x411111f0}),
6262 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6263 {0x12, 0x411111f0},
6264 {0x14, 0x90170110},
6265 {0x15, 0x0321101f},
6266 {0x16, 0x03011020},
6267 {0x18, 0x40000008},
6268 {0x19, 0x411111f0},
6269 {0x1a, 0x411111f0},
6270 {0x1b, 0x411111f0},
6271 {0x1d, 0x41000001},
6272 {0x1e, 0x411111f0},
6273 {0x1f, 0x411111f0}),
6274 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
6275 {0x12, 0x90a60130},
6276 {0x14, 0x90170110},
6277 {0x15, 0x0321101f},
6278 {0x16, 0x40000000},
6279 {0x18, 0x411111f0},
6280 {0x19, 0x411111f0},
6281 {0x1a, 0x411111f0},
6282 {0x1b, 0x411111f0},
6283 {0x1d, 0x40d6832d},
6284 {0x1e, 0x411111f0},
6285 {0x1f, 0x411111f0}),
Hui Wang532895c2014-05-29 15:59:19 +08006286 {}
6287};
6288
Kailang Yang8663ff72012-06-29 09:35:52 +02006289static void alc662_fill_coef(struct hda_codec *codec)
6290{
Takashi Iwai98b24882014-08-18 13:47:50 +02006291 int coef;
Kailang Yang8663ff72012-06-29 09:35:52 +02006292
6293 coef = alc_get_coef0(codec);
6294
6295 switch (codec->vendor_id) {
6296 case 0x10ec0662:
Takashi Iwai98b24882014-08-18 13:47:50 +02006297 if ((coef & 0x00f0) == 0x0030)
6298 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
Kailang Yang8663ff72012-06-29 09:35:52 +02006299 break;
6300 case 0x10ec0272:
6301 case 0x10ec0273:
6302 case 0x10ec0663:
6303 case 0x10ec0665:
6304 case 0x10ec0670:
6305 case 0x10ec0671:
6306 case 0x10ec0672:
Takashi Iwai98b24882014-08-18 13:47:50 +02006307 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
Kailang Yang8663ff72012-06-29 09:35:52 +02006308 break;
6309 }
6310}
David Henningsson6cb3b702010-09-09 08:51:44 +02006311
Takashi Iwai1d045db2011-07-07 18:23:21 +02006312/*
6313 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006314static int patch_alc662(struct hda_codec *codec)
6315{
6316 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02006317 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006318
Takashi Iwai3de95172012-05-07 18:03:15 +02006319 err = alc_alloc_spec(codec, 0x0b);
6320 if (err < 0)
6321 return err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006322
Takashi Iwai3de95172012-05-07 18:03:15 +02006323 spec = codec->spec;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006324
Takashi Iwai53c334a2011-08-23 18:27:14 +02006325 /* handle multiple HPs as is */
6326 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6327
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02006328 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6329
Kailang Yang8663ff72012-06-29 09:35:52 +02006330 spec->init_hook = alc662_fill_coef;
6331 alc662_fill_coef(codec);
6332
Takashi Iwai1727a772013-01-10 09:52:52 +01006333 snd_hda_pick_fixup(codec, alc662_fixup_models,
Takashi Iwai8e5a0502012-06-21 15:49:33 +02006334 alc662_fixup_tbl, alc662_fixups);
Hui Wang532895c2014-05-29 15:59:19 +08006335 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01006336 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai8e5a0502012-06-21 15:49:33 +02006337
6338 alc_auto_parse_customize_define(codec);
6339
Takashi Iwai7504b6c2013-03-18 11:25:51 +01006340 if (has_cdefine_beep(codec))
6341 spec->gen.beep_nid = 0x01;
6342
Takashi Iwai1bb7e432011-10-17 16:50:59 +02006343 if ((alc_get_coef0(codec) & (1 << 14)) &&
Takashi Iwai5100cd02014-02-15 10:03:19 +01006344 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006345 spec->cdefine.platform_type == 1) {
Wei Yongjun6134b1a2013-04-18 11:12:59 +08006346 err = alc_codec_rename(codec, "ALC272X");
6347 if (err < 0)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006348 goto error;
Takashi Iwai20ca0c32011-10-17 16:00:35 +02006349 }
Kailang Yang274693f2009-12-03 10:07:50 +01006350
Takashi Iwaib9c51062011-08-24 18:08:07 +02006351 /* automatic parse from the BIOS config */
6352 err = alc662_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006353 if (err < 0)
6354 goto error;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006355
Takashi Iwai7504b6c2013-03-18 11:25:51 +01006356 if (!spec->gen.no_analog && spec->gen.beep_nid) {
Kailang Yangda00c242010-03-19 11:23:45 +01006357 switch (codec->vendor_id) {
6358 case 0x10ec0662:
6359 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6360 break;
6361 case 0x10ec0272:
6362 case 0x10ec0663:
6363 case 0x10ec0665:
Kailang Yang9ad54542013-11-26 15:41:40 +08006364 case 0x10ec0668:
Kailang Yangda00c242010-03-19 11:23:45 +01006365 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6366 break;
6367 case 0x10ec0273:
6368 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6369 break;
6370 }
Kailang Yangcec27c82010-02-04 14:18:18 +01006371 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01006372
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006373 codec->patch_ops = alc_patch_ops;
Takashi Iwai1c7161532011-04-07 10:37:16 +02006374 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +02006375
Takashi Iwai1727a772013-01-10 09:52:52 +01006376 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01006377
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006378 return 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006379
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006380 error:
6381 alc_free(codec);
6382 return err;
Kailang Yangb478b992011-05-18 11:51:15 +02006383}
6384
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006385/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006386 * ALC680 support
6387 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006388
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006389static int alc680_parse_auto_config(struct hda_codec *codec)
6390{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02006391 return alc_parse_auto_config(codec, NULL, NULL);
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006392}
6393
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006394/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006395 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006396static int patch_alc680(struct hda_codec *codec)
6397{
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006398 int err;
6399
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006400 /* ALC680 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02006401 err = alc_alloc_spec(codec, 0);
6402 if (err < 0)
6403 return err;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006404
Takashi Iwai1ebec5f2011-08-15 13:21:48 +02006405 /* automatic parse from the BIOS config */
6406 err = alc680_parse_auto_config(codec);
6407 if (err < 0) {
6408 alc_free(codec);
6409 return err;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006410 }
6411
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006412 codec->patch_ops = alc_patch_ops;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006413
6414 return 0;
6415}
6416
6417/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006418 * patch entries
6419 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006420static const struct hda_codec_preset snd_hda_preset_realtek[] = {
Kailang Yang296f0332011-05-18 11:52:36 +02006421 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
Kailang Yangba4c4d02013-11-26 15:17:50 +08006422 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
Kailang Yang84dfd0a2013-03-07 09:19:38 +01006423 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
Kailang Yang92f974d2014-06-06 17:05:33 +08006424 { .id = 0x10ec0235, .name = "ALC233", .patch = patch_alc269 },
Kailang Yang1d04c9d2013-10-24 11:35:18 +02006425 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006426 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +01006428 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +02006429 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +01006430 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01006431 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +02006432 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01006433 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Kailang Yang296f0332011-05-18 11:52:36 +02006434 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
David Henningssonbefae822012-06-25 19:49:28 +02006435 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
David Henningsson4e01ec62012-07-18 07:38:46 +02006436 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02006437 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
Kailang Yang065380f2013-01-10 10:25:48 +01006438 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
Kailang Yang161ebf22013-10-24 11:36:33 +02006439 { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
Kailang Yang7fc7d042013-04-25 11:04:43 +02006440 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
Kailang Yang7c665932014-04-14 15:09:44 +08006441 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02006442 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
David Henningssonaf02dde2012-11-21 08:57:58 +01006443 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
Kailang Yang161ebf22013-10-24 11:36:33 +02006444 { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006445 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006446 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006447 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6448 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6449 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006450 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006451 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006452 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6453 .patch = patch_alc662 },
David Henningssoncc667a72011-10-18 14:07:51 +02006454 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6455 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +02006456 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +01006457 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang72009432014-06-06 16:51:18 +08006458 { .id = 0x10ec0667, .name = "ALC667", .patch = patch_alc662 },
Kailang Yang19a62822012-11-08 10:25:37 +01006459 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +01006460 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Rainer Koenig1d87caa2013-04-04 08:40:38 +02006461 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006462 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Kailang Yangb6c5fba2014-06-05 11:13:44 +08006463 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006464 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006465 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006466 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +02006467 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006468 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +02006469 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006470 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006471 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006472 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +02006473 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006474 .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006475 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006476 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +01006477 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006478 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
Kailang Yang19a62822012-11-08 10:25:37 +01006479 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006480 {} /* terminator */
6481};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006482
6483MODULE_ALIAS("snd-hda-codec-id:10ec*");
6484
6485MODULE_LICENSE("GPL");
6486MODULE_DESCRIPTION("Realtek HD-audio codec");
6487
6488static struct hda_codec_preset_list realtek_list = {
6489 .preset = snd_hda_preset_realtek,
6490 .owner = THIS_MODULE,
6491};
6492
6493static int __init patch_realtek_init(void)
6494{
6495 return snd_hda_add_codec_preset(&realtek_list);
6496}
6497
6498static void __exit patch_realtek_exit(void)
6499{
6500 snd_hda_delete_codec_preset(&realtek_list);
6501}
6502
6503module_init(patch_realtek_init)
6504module_exit(patch_realtek_exit)