blob: 8fea1b86df25ebe5e66ea56bfb9babdae031a117 [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
Kailang Yangdf694da2005-12-05 19:42:22 +010043/* for GPIO Poll */
44#define GPIO_MASK 0x03
45
Takashi Iwai4a79ba32009-04-22 16:31:35 +020046/* extra amp-initialization sequence types */
47enum {
48 ALC_INIT_NONE,
49 ALC_INIT_DEFAULT,
50 ALC_INIT_GPIO1,
51 ALC_INIT_GPIO2,
52 ALC_INIT_GPIO3,
53};
54
David Henningsson73bdd592013-04-15 15:44:14 +020055enum {
56 ALC_HEADSET_MODE_UNKNOWN,
57 ALC_HEADSET_MODE_UNPLUGGED,
58 ALC_HEADSET_MODE_HEADSET,
59 ALC_HEADSET_MODE_MIC,
60 ALC_HEADSET_MODE_HEADPHONE,
61};
62
63enum {
64 ALC_HEADSET_TYPE_UNKNOWN,
65 ALC_HEADSET_TYPE_CTIA,
66 ALC_HEADSET_TYPE_OMTP,
67};
68
Kailang Yangda00c242010-03-19 11:23:45 +010069struct alc_customize_define {
70 unsigned int sku_cfg;
71 unsigned char port_connectivity;
72 unsigned char check_sum;
73 unsigned char customization;
74 unsigned char external_amp;
75 unsigned int enable_pcbeep:1;
76 unsigned int platform_type:1;
77 unsigned int swap:1;
78 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +020079 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +010080};
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082struct alc_spec {
Takashi Iwai08c189f2012-12-19 15:22:24 +010083 struct hda_gen_spec gen; /* must be at head */
Takashi Iwai23d30f22012-05-07 17:17:32 +020084
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 /* codec parameterization */
Takashi Iwaia9111322011-05-02 11:30:18 +020086 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 unsigned int num_mixers;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010088 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Kailang Yangda00c242010-03-19 11:23:45 +010090 struct alc_customize_define cdefine;
Takashi Iwai08c189f2012-12-19 15:22:24 +010091 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
92
Takashi Iwai08fb0d02013-01-10 17:33:58 +010093 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
94 int mute_led_polarity;
95 hda_nid_t mute_led_nid;
Kailang Yang9c5dc3b2014-06-19 16:11:36 +080096 hda_nid_t cap_mute_led_nid;
Takashi Iwai08fb0d02013-01-10 17:33:58 +010097
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +010098 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
99
David Henningsson73bdd592013-04-15 15:44:14 +0200100 hda_nid_t headset_mic_pin;
101 hda_nid_t headphone_mic_pin;
102 int current_headset_mode;
103 int current_headset_type;
104
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100105 /* hooks */
106 void (*init_hook)(struct hda_codec *codec);
Takashi Iwai83012a72012-08-24 18:38:08 +0200107#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -0500108 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100109#endif
Takashi Iwai1c7161532011-04-07 10:37:16 +0200110 void (*shutup)(struct hda_codec *codec);
Takashi Iwaid922b512011-04-28 12:18:53 +0200111
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200112 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200113 int codec_variant; /* flag for other variants */
Kailang Yang97a26572013-11-29 00:35:26 -0500114 unsigned int has_alc5505_dsp:1;
115 unsigned int no_depop_delay:1;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100116
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200117 /* for PLL fix */
118 hda_nid_t pll_nid;
119 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200120 unsigned int coef0;
Kailang Yangdf694da2005-12-05 19:42:22 +0100121};
122
Takashi Iwai23f0c042009-02-26 13:03:58 +0100123/*
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200124 * COEF access helper functions
125 */
126
127static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
128 unsigned int coef_idx)
129{
130 unsigned int val;
131
132 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
133 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
134 return val;
135}
136
137#define alc_read_coef_idx(codec, coef_idx) \
138 alc_read_coefex_idx(codec, 0x20, coef_idx)
139
140static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
141 unsigned int coef_idx, unsigned int coef_val)
142{
143 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
144 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
145}
146
147#define alc_write_coef_idx(codec, coef_idx, coef_val) \
148 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
149
Takashi Iwai98b24882014-08-18 13:47:50 +0200150static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
151 unsigned int coef_idx, unsigned int mask,
152 unsigned int bits_set)
153{
154 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
155
156 if (val != -1)
157 alc_write_coefex_idx(codec, nid, coef_idx,
158 (val & ~mask) | bits_set);
159}
160
161#define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
162 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
163
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200164/* a special bypass for COEF 0; read the cached value at the second time */
165static unsigned int alc_get_coef0(struct hda_codec *codec)
166{
167 struct alc_spec *spec = codec->spec;
168
169 if (!spec->coef0)
170 spec->coef0 = alc_read_coef_idx(codec, 0);
171 return spec->coef0;
172}
173
Takashi Iwai54db6c32014-08-18 15:11:19 +0200174/* coef writes/updates batch */
175struct coef_fw {
176 unsigned char nid;
177 unsigned char idx;
178 unsigned short mask;
179 unsigned short val;
180};
181
182#define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
183 { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
184#define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
185#define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
186#define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
187
188static void alc_process_coef_fw(struct hda_codec *codec,
189 const struct coef_fw *fw)
190{
191 for (; fw->nid; fw++) {
192 if (fw->mask == (unsigned short)-1)
193 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
194 else
195 alc_update_coefex_idx(codec, fw->nid, fw->idx,
196 fw->mask, fw->val);
197 }
198}
199
Takashi Iwaif2a227c2014-08-18 13:35:22 +0200200/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200201 * Append the given mixer and verb elements for the later use
202 * The mixer array is referred in build_controls(), and init_verbs are
203 * called in init().
Takashi Iwaid88897e2008-10-31 15:01:37 +0100204 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200205static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100206{
207 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
208 return;
209 spec->mixers[spec->num_mixers++] = mix;
210}
211
Takashi Iwaid88897e2008-10-31 15:01:37 +0100212/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200213 * GPIO setup tables, used in initialization
Kailang Yangdf694da2005-12-05 19:42:22 +0100214 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200215/* Enable GPIO mask and set output */
Takashi Iwaia9111322011-05-02 11:30:18 +0200216static const struct hda_verb alc_gpio1_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200217 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
218 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
219 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
220 { }
221};
222
Takashi Iwaia9111322011-05-02 11:30:18 +0200223static const struct hda_verb alc_gpio2_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200224 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
225 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
226 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
227 { }
228};
229
Takashi Iwaia9111322011-05-02 11:30:18 +0200230static const struct hda_verb alc_gpio3_init_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +0200231 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
232 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
233 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
234 { }
235};
236
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200237/*
238 * Fix hardware PLL issue
239 * On some codecs, the analog PLL gating control must be off while
240 * the default value is 1.
241 */
242static void alc_fix_pll(struct hda_codec *codec)
243{
244 struct alc_spec *spec = codec->spec;
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200245
Takashi Iwai98b24882014-08-18 13:47:50 +0200246 if (spec->pll_nid)
247 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
248 1 << spec->pll_coef_bit, 0);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200249}
250
251static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
252 unsigned int coef_idx, unsigned int coef_bit)
253{
254 struct alc_spec *spec = codec->spec;
255 spec->pll_nid = nid;
256 spec->pll_coef_idx = coef_idx;
257 spec->pll_coef_bit = coef_bit;
258 alc_fix_pll(codec);
259}
260
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100261/* update the master volume per volume-knob's unsol event */
Takashi Iwai1a4f69d2014-09-11 15:22:46 +0200262static void alc_update_knob_master(struct hda_codec *codec,
263 struct hda_jack_callback *jack)
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100264{
265 unsigned int val;
266 struct snd_kcontrol *kctl;
267 struct snd_ctl_elem_value *uctl;
268
269 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
270 if (!kctl)
271 return;
272 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
273 if (!uctl)
274 return;
Takashi Iwai1a4f69d2014-09-11 15:22:46 +0200275 val = snd_hda_codec_read(codec, jack->tbl->nid, 0,
Takashi Iwaicf5a2272012-02-20 16:31:07 +0100276 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
277 val &= HDA_AMP_VOLMASK;
278 uctl->value.integer.value[0] = val;
279 uctl->value.integer.value[1] = val;
280 kctl->put(kctl, uctl);
281 kfree(uctl);
282}
283
David Henningsson29adc4b2012-09-25 11:31:00 +0200284static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100285{
David Henningsson29adc4b2012-09-25 11:31:00 +0200286 /* For some reason, the res given from ALC880 is broken.
287 Here we adjust it properly. */
288 snd_hda_jack_unsol_event(codec, res >> 2);
Takashi Iwaif21d78e2012-01-19 12:10:29 +0100289}
290
Kailang Yang394c97f2014-11-12 17:38:08 +0800291/* Change EAPD to verb control */
292static void alc_fill_eapd_coef(struct hda_codec *codec)
293{
294 int coef;
295
296 coef = alc_get_coef0(codec);
297
298 switch (codec->vendor_id) {
299 case 0x10ec0262:
300 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
301 break;
302 case 0x10ec0267:
303 case 0x10ec0268:
304 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
305 break;
306 case 0x10ec0269:
307 if ((coef & 0x00f0) == 0x0010)
308 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
309 if ((coef & 0x00f0) == 0x0020)
310 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
311 if ((coef & 0x00f0) == 0x0030)
312 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
313 break;
314 case 0x10ec0280:
315 case 0x10ec0284:
316 case 0x10ec0290:
317 case 0x10ec0292:
318 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
319 break;
320 case 0x10ec0233:
321 case 0x10ec0255:
322 case 0x10ec0282:
323 case 0x10ec0283:
324 case 0x10ec0286:
325 case 0x10ec0288:
326 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
327 break;
328 case 0x10ec0285:
329 case 0x10ec0293:
330 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
331 break;
332 case 0x10ec0662:
333 if ((coef & 0x00f0) == 0x0030)
334 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
335 break;
336 case 0x10ec0272:
337 case 0x10ec0273:
338 case 0x10ec0663:
339 case 0x10ec0665:
340 case 0x10ec0670:
341 case 0x10ec0671:
342 case 0x10ec0672:
343 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
344 break;
345 case 0x10ec0668:
346 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
347 break;
348 case 0x10ec0867:
349 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
350 break;
351 case 0x10ec0888:
352 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
353 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
354 break;
355 case 0x10ec0892:
356 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
357 break;
358 case 0x10ec0899:
359 case 0x10ec0900:
360 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
361 break;
362 }
363}
364
Kailang Yangf9423e72008-05-27 12:32:25 +0200365/* additional initialization for ALC888 variants */
366static void alc888_coef_init(struct hda_codec *codec)
367{
Kailang Yang1df88742014-10-29 16:10:13 +0800368 switch (alc_get_coef0(codec) & 0x00f0) {
369 /* alc888-VA */
370 case 0x00:
371 /* alc888-VB */
372 case 0x10:
373 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
374 break;
375 }
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200376}
377
Takashi Iwai3fb4a502010-01-19 15:46:37 +0100378/* turn on/off EAPD control (only if available) */
379static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
380{
381 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
382 return;
383 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
384 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
385 on ? 2 : 0);
386}
387
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200388/* turn on/off EAPD controls of the codec */
389static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
390{
391 /* We currently only handle front, HP */
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200392 static hda_nid_t pins[] = {
393 0x0f, 0x10, 0x14, 0x15, 0
394 };
395 hda_nid_t *p;
396 for (p = pins; *p; p++)
397 set_eapd(codec, *p, on);
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200398}
399
Takashi Iwai1c7161532011-04-07 10:37:16 +0200400/* generic shutup callback;
401 * just turning off EPAD and a little pause for avoiding pop-noise
402 */
403static void alc_eapd_shutup(struct hda_codec *codec)
404{
Kailang Yang97a26572013-11-29 00:35:26 -0500405 struct alc_spec *spec = codec->spec;
406
Takashi Iwai1c7161532011-04-07 10:37:16 +0200407 alc_auto_setup_eapd(codec, false);
Kailang Yang97a26572013-11-29 00:35:26 -0500408 if (!spec->no_depop_delay)
409 msleep(200);
Takashi Iwai9bfb2842013-07-24 14:31:50 +0200410 snd_hda_shutup_pins(codec);
Takashi Iwai1c7161532011-04-07 10:37:16 +0200411}
412
Takashi Iwai1d045db2011-07-07 18:23:21 +0200413/* generic EAPD initialization */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200414static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200415{
Kailang Yang394c97f2014-11-12 17:38:08 +0800416 alc_fill_eapd_coef(codec);
Takashi Iwai39fa84e2011-06-27 15:28:57 +0200417 alc_auto_setup_eapd(codec, true);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200418 switch (type) {
419 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200420 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
421 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200422 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200423 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
424 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200425 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200426 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
427 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200428 case ALC_INIT_DEFAULT:
Kailang Yangc9b58002007-10-16 14:30:01 +0200429 switch (codec->vendor_id) {
430 case 0x10ec0260:
Takashi Iwai98b24882014-08-18 13:47:50 +0200431 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
Kailang Yangc9b58002007-10-16 14:30:01 +0200432 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200433 case 0x10ec0880:
434 case 0x10ec0882:
435 case 0x10ec0883:
436 case 0x10ec0885:
Kailang Yang1df88742014-10-29 16:10:13 +0800437 alc_update_coef_idx(codec, 7, 0, 0x2030);
Kailang Yangc9b58002007-10-16 14:30:01 +0200438 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200439 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200440 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +0200441 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200442 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200443 break;
444 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200445}
Kailang Yangea1fb292008-08-26 12:58:38 +0200446
Takashi Iwai1d045db2011-07-07 18:23:21 +0200447
448/*
449 * Realtek SSID verification
450 */
451
David Henningsson90622912010-10-14 14:50:18 +0200452/* Could be any non-zero and even value. When used as fixup, tells
453 * the driver to ignore any present sku defines.
454 */
455#define ALC_FIXUP_SKU_IGNORE (2)
456
Takashi Iwai23d30f22012-05-07 17:17:32 +0200457static void alc_fixup_sku_ignore(struct hda_codec *codec,
458 const struct hda_fixup *fix, int action)
459{
460 struct alc_spec *spec = codec->spec;
461 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
462 spec->cdefine.fixup = 1;
463 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
464 }
465}
466
Mengdong Linb5c66112013-11-29 00:35:35 -0500467static void alc_fixup_no_depop_delay(struct hda_codec *codec,
468 const struct hda_fixup *fix, int action)
469{
470 struct alc_spec *spec = codec->spec;
471
Mengdong Lin84d2dc32013-12-02 22:26:03 -0500472 if (action == HDA_FIXUP_ACT_PROBE) {
Mengdong Linb5c66112013-11-29 00:35:35 -0500473 spec->no_depop_delay = 1;
Mengdong Lin84d2dc32013-12-02 22:26:03 -0500474 codec->depop_delay = 0;
475 }
Mengdong Linb5c66112013-11-29 00:35:35 -0500476}
477
Kailang Yangda00c242010-03-19 11:23:45 +0100478static int alc_auto_parse_customize_define(struct hda_codec *codec)
479{
480 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +0100481 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +0100482 struct alc_spec *spec = codec->spec;
483
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200484 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
485
David Henningsson90622912010-10-14 14:50:18 +0200486 if (spec->cdefine.fixup) {
487 ass = spec->cdefine.sku_cfg;
488 if (ass == ALC_FIXUP_SKU_IGNORE)
489 return -1;
490 goto do_sku;
491 }
492
Takashi Iwai5100cd02014-02-15 10:03:19 +0100493 if (!codec->bus->pci)
494 return -1;
Kailang Yangda00c242010-03-19 11:23:45 +0100495 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +0200496 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +0100497 goto do_sku;
498
499 nid = 0x1d;
500 if (codec->vendor_id == 0x10ec0260)
501 nid = 0x17;
502 ass = snd_hda_codec_get_pincfg(codec, nid);
503
504 if (!(ass & 1)) {
Takashi Iwai4e76a882014-02-25 12:21:03 +0100505 codec_info(codec, "%s: SKU not ready 0x%08x\n",
506 codec->chip_name, ass);
Kailang Yangda00c242010-03-19 11:23:45 +0100507 return -1;
508 }
509
510 /* check sum */
511 tmp = 0;
512 for (i = 1; i < 16; i++) {
513 if ((ass >> i) & 1)
514 tmp++;
515 }
516 if (((ass >> 16) & 0xf) != tmp)
517 return -1;
518
519 spec->cdefine.port_connectivity = ass >> 30;
520 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
521 spec->cdefine.check_sum = (ass >> 16) & 0xf;
522 spec->cdefine.customization = ass >> 8;
523do_sku:
524 spec->cdefine.sku_cfg = ass;
525 spec->cdefine.external_amp = (ass & 0x38) >> 3;
526 spec->cdefine.platform_type = (ass & 0x4) >> 2;
527 spec->cdefine.swap = (ass & 0x2) >> 1;
528 spec->cdefine.override = ass & 0x1;
529
Takashi Iwai4e76a882014-02-25 12:21:03 +0100530 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
Kailang Yangda00c242010-03-19 11:23:45 +0100531 nid, spec->cdefine.sku_cfg);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100532 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
Kailang Yangda00c242010-03-19 11:23:45 +0100533 spec->cdefine.port_connectivity);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100534 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
535 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
536 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
537 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
538 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
539 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
540 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
Kailang Yangda00c242010-03-19 11:23:45 +0100541
542 return 0;
543}
544
Takashi Iwai08c189f2012-12-19 15:22:24 +0100545/* return the position of NID in the list, or -1 if not found */
546static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
547{
548 int i;
549 for (i = 0; i < nums; i++)
550 if (list[i] == nid)
551 return i;
552 return -1;
553}
Takashi Iwai1d045db2011-07-07 18:23:21 +0200554/* return true if the given NID is found in the list */
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200555static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
556{
Takashi Iwai21268962011-07-07 15:01:13 +0200557 return find_idx_in_nid_list(nid, list, nums) >= 0;
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200558}
559
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200560/* check subsystem ID and set up device-specific initialization;
561 * return 1 if initialized, 0 if invalid SSID
562 */
563/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
564 * 31 ~ 16 : Manufacture ID
565 * 15 ~ 8 : SKU ID
566 * 7 ~ 0 : Assembly ID
567 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
568 */
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100569static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200570{
571 unsigned int ass, tmp, i;
572 unsigned nid;
573 struct alc_spec *spec = codec->spec;
574
David Henningsson90622912010-10-14 14:50:18 +0200575 if (spec->cdefine.fixup) {
576 ass = spec->cdefine.sku_cfg;
577 if (ass == ALC_FIXUP_SKU_IGNORE)
578 return 0;
579 goto do_sku;
580 }
581
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200582 ass = codec->subsystem_id & 0xffff;
Takashi Iwai5100cd02014-02-15 10:03:19 +0100583 if (codec->bus->pci &&
584 ass != codec->bus->pci->subsystem_device && (ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200585 goto do_sku;
586
587 /* invalid SSID, check the special NID pin defcfg instead */
588 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400589 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200590 * 29~21 : reserve
591 * 20 : PCBEEP input
592 * 19~16 : Check sum (15:1)
593 * 15~1 : Custom
594 * 0 : override
595 */
596 nid = 0x1d;
597 if (codec->vendor_id == 0x10ec0260)
598 nid = 0x17;
599 ass = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai4e76a882014-02-25 12:21:03 +0100600 codec_dbg(codec,
601 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +0200602 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +0100603 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200604 return 0;
605 if ((ass >> 30) != 1) /* no physical connection */
606 return 0;
607
608 /* check sum */
609 tmp = 0;
610 for (i = 1; i < 16; i++) {
611 if ((ass >> i) & 1)
612 tmp++;
613 }
614 if (((ass >> 16) & 0xf) != tmp)
615 return 0;
616do_sku:
Takashi Iwai4e76a882014-02-25 12:21:03 +0100617 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200618 ass & 0xffff, codec->vendor_id);
619 /*
620 * 0 : override
621 * 1 : Swap Jack
622 * 2 : 0 --> Desktop, 1 --> Laptop
623 * 3~5 : External Amplifier control
624 * 7~6 : Reserved
625 */
626 tmp = (ass & 0x38) >> 3; /* external Amp control */
627 switch (tmp) {
628 case 1:
629 spec->init_amp = ALC_INIT_GPIO1;
630 break;
631 case 3:
632 spec->init_amp = ALC_INIT_GPIO2;
633 break;
634 case 7:
635 spec->init_amp = ALC_INIT_GPIO3;
636 break;
637 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +0100638 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200639 spec->init_amp = ALC_INIT_DEFAULT;
640 break;
641 }
642
643 /* is laptop or Desktop and enable the function "Mute internal speaker
644 * when the external headphone out jack is plugged"
645 */
646 if (!(ass & 0x8000))
647 return 1;
648 /*
649 * 10~8 : Jack location
650 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
651 * 14~13: Resvered
652 * 15 : 1 --> enable the function "Mute internal speaker
653 * when the external headphone out jack is plugged"
654 */
Takashi Iwai08c189f2012-12-19 15:22:24 +0100655 if (!spec->gen.autocfg.hp_pins[0] &&
656 !(spec->gen.autocfg.line_out_pins[0] &&
657 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
Takashi Iwai01d48252009-10-06 13:21:54 +0200658 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200659 tmp = (ass >> 11) & 0x3; /* HP to chassis */
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100660 nid = ports[tmp];
Takashi Iwai08c189f2012-12-19 15:22:24 +0100661 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
662 spec->gen.autocfg.line_outs))
Takashi Iwai3af9ee62011-06-27 12:34:01 +0200663 return 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100664 spec->gen.autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +0200665 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200666 return 1;
667}
Kailang Yangea1fb292008-08-26 12:58:38 +0200668
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200669/* Check the validity of ALC subsystem-id
670 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
671static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200672{
Takashi Iwai58c57cf2014-01-07 18:22:49 +0100673 if (!alc_subsystem_id(codec, ports)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200674 struct alc_spec *spec = codec->spec;
Takashi Iwai4e76a882014-02-25 12:21:03 +0100675 codec_dbg(codec,
676 "realtek: Enable default setup for auto mode as fallback\n");
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200677 spec->init_amp = ALC_INIT_DEFAULT;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200678 }
Takashi Iwai21268962011-07-07 15:01:13 +0200679}
Takashi Iwai1a1455d2011-04-28 17:36:18 +0200680
Takashi Iwai41e41f12005-06-08 14:48:49 +0200681/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200682 */
683
David Henningsson9d36a7d2014-10-07 10:18:42 +0200684static void alc_fixup_inv_dmic(struct hda_codec *codec,
685 const struct hda_fixup *fix, int action)
Takashi Iwai125821a2012-06-22 14:30:29 +0200686{
687 struct alc_spec *spec = codec->spec;
Takashi Iwai668d1e92012-11-29 14:10:17 +0100688
David Henningsson9d36a7d2014-10-07 10:18:42 +0200689 spec->gen.inv_dmic_split = 1;
Takashi Iwai6e72aa52012-06-25 10:52:25 +0200690}
691
Takashi Iwai603c4012008-07-30 15:01:44 +0200692
Takashi Iwai67d634c2009-11-16 15:35:59 +0100693#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100694/* additional beep mixers; the actual parameters are overwritten at build */
Takashi Iwaia9111322011-05-02 11:30:18 +0200695static const struct snd_kcontrol_new alc_beep_mixer[] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100696 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +0200697 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100698 { } /* end */
699};
Takashi Iwai67d634c2009-11-16 15:35:59 +0100700#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100701
Takashi Iwai2eab6942012-12-18 15:30:41 +0100702static int alc_build_controls(struct hda_codec *codec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703{
704 struct alc_spec *spec = codec->spec;
Takashi Iwai666a70d2012-12-17 20:29:29 +0100705 int i, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706
Takashi Iwai08c189f2012-12-19 15:22:24 +0100707 err = snd_hda_gen_build_controls(codec);
708 if (err < 0)
709 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
711 for (i = 0; i < spec->num_mixers; i++) {
712 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
713 if (err < 0)
714 return err;
715 }
Takashi Iwai2134ea42008-01-10 16:53:55 +0100716
Takashi Iwai67d634c2009-11-16 15:35:59 +0100717#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100718 /* create beep controls if needed */
719 if (spec->beep_amp) {
Takashi Iwaia9111322011-05-02 11:30:18 +0200720 const struct snd_kcontrol_new *knew;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100721 for (knew = alc_beep_mixer; knew->name; knew++) {
722 struct snd_kcontrol *kctl;
723 kctl = snd_ctl_new1(knew, codec);
724 if (!kctl)
725 return -ENOMEM;
726 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +0100727 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100728 if (err < 0)
729 return err;
730 }
731 }
Takashi Iwai67d634c2009-11-16 15:35:59 +0100732#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100733
Takashi Iwai1727a772013-01-10 09:52:52 +0100734 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
Takashi Iwai420b0fe2012-03-12 12:35:27 +0100735 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736}
737
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200738
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100740 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200741 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200742
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743static int alc_init(struct hda_codec *codec)
744{
745 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200746
Takashi Iwai546bb672012-03-07 08:37:19 +0100747 if (spec->init_hook)
748 spec->init_hook(codec);
Kailang Yang526af6e2012-03-07 08:25:20 +0100749
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200750 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200751 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200752
Takashi Iwai08c189f2012-12-19 15:22:24 +0100753 snd_hda_gen_init(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100754
Takashi Iwai1727a772013-01-10 09:52:52 +0100755 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
Takashi Iwaie08a0072006-09-07 17:52:14 +0200756
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 return 0;
758}
759
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100760static inline void alc_shutup(struct hda_codec *codec)
761{
Takashi Iwai1c7161532011-04-07 10:37:16 +0200762 struct alc_spec *spec = codec->spec;
763
764 if (spec && spec->shutup)
765 spec->shutup(codec);
Takashi Iwai9bfb2842013-07-24 14:31:50 +0200766 else
767 snd_hda_shutup_pins(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100768}
769
Takashi Iwai8a02c0c2014-02-10 18:09:45 +0100770#define alc_free snd_hda_gen_free
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771
Takashi Iwai83012a72012-08-24 18:38:08 +0200772#ifdef CONFIG_PM
Daniel T Chenc97259d2009-12-27 18:52:08 -0500773static void alc_power_eapd(struct hda_codec *codec)
774{
Takashi Iwai691f1fc2011-04-07 10:31:43 +0200775 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -0500776}
777
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200778static int alc_suspend(struct hda_codec *codec)
Hector Martinf5de24b2009-12-20 22:51:31 +0100779{
780 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +0100781 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100782 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -0500783 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100784 return 0;
785}
786#endif
787
Takashi Iwai2a439522011-07-26 09:52:50 +0200788#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100789static int alc_resume(struct hda_codec *codec)
790{
Kailang Yang97a26572013-11-29 00:35:26 -0500791 struct alc_spec *spec = codec->spec;
792
793 if (!spec->no_depop_delay)
794 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +0100795 codec->patch_ops.init(codec);
796 snd_hda_codec_resume_amp(codec);
797 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +0200798 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +0100799 return 0;
800}
Takashi Iwaie044c392008-10-27 16:56:24 +0100801#endif
802
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803/*
804 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200805static const struct hda_codec_ops alc_patch_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 .build_controls = alc_build_controls,
Takashi Iwai08c189f2012-12-19 15:22:24 +0100807 .build_pcms = snd_hda_gen_build_pcms,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 .init = alc_init,
809 .free = alc_free,
David Henningsson29adc4b2012-09-25 11:31:00 +0200810 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +0200811#ifdef CONFIG_PM
Takashi Iwaie044c392008-10-27 16:56:24 +0100812 .resume = alc_resume,
Hector Martinf5de24b2009-12-20 22:51:31 +0100813 .suspend = alc_suspend,
Takashi Iwaifce52a32013-01-07 12:42:48 +0100814 .check_power_status = snd_hda_gen_check_power_status,
Takashi Iwaicb53c622007-08-10 17:21:45 +0200815#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -0500816 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817};
818
David Henningsson29adc4b2012-09-25 11:31:00 +0200819
Kailang Yangc027ddc2010-03-19 11:33:06 +0100820/* replace the codec chip_name with the given string */
821static int alc_codec_rename(struct hda_codec *codec, const char *name)
822{
823 kfree(codec->chip_name);
824 codec->chip_name = kstrdup(name, GFP_KERNEL);
825 if (!codec->chip_name) {
826 alc_free(codec);
827 return -ENOMEM;
828 }
829 return 0;
830}
831
Takashi Iwai2fa522b2005-05-12 14:51:12 +0200832/*
Kailang Yang4b016932013-11-28 11:55:09 +0100833 * Rename codecs appropriately from COEF value or subvendor id
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200834 */
835struct alc_codec_rename_table {
836 unsigned int vendor_id;
837 unsigned short coef_mask;
838 unsigned short coef_bits;
839 const char *name;
840};
841
Kailang Yang4b016932013-11-28 11:55:09 +0100842struct alc_codec_rename_pci_table {
843 unsigned int codec_vendor_id;
844 unsigned short pci_subvendor;
845 unsigned short pci_subdevice;
846 const char *name;
847};
848
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200849static struct alc_codec_rename_table rename_tbl[] = {
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800850 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200851 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
852 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
853 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
854 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
855 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
856 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
857 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
Kailang Yangadcc70b2012-05-25 08:08:38 +0200858 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800859 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200860 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
861 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
862 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
863 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
864 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
865 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
866 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
867 { } /* terminator */
868};
869
Kailang Yang4b016932013-11-28 11:55:09 +0100870static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
871 { 0x10ec0280, 0x1028, 0, "ALC3220" },
872 { 0x10ec0282, 0x1028, 0, "ALC3221" },
873 { 0x10ec0283, 0x1028, 0, "ALC3223" },
Kailang Yang193177d2014-04-23 16:06:13 +0800874 { 0x10ec0288, 0x1028, 0, "ALC3263" },
Kailang Yang4b016932013-11-28 11:55:09 +0100875 { 0x10ec0292, 0x1028, 0, "ALC3226" },
Kailang Yang193177d2014-04-23 16:06:13 +0800876 { 0x10ec0293, 0x1028, 0, "ALC3235" },
Kailang Yang4b016932013-11-28 11:55:09 +0100877 { 0x10ec0255, 0x1028, 0, "ALC3234" },
878 { 0x10ec0668, 0x1028, 0, "ALC3661" },
Kailang Yange6e5f7a2014-06-06 16:46:43 +0800879 { 0x10ec0275, 0x1028, 0, "ALC3260" },
880 { 0x10ec0899, 0x1028, 0, "ALC3861" },
881 { 0x10ec0670, 0x1025, 0, "ALC669X" },
882 { 0x10ec0676, 0x1025, 0, "ALC679X" },
883 { 0x10ec0282, 0x1043, 0, "ALC3229" },
884 { 0x10ec0233, 0x1043, 0, "ALC3236" },
885 { 0x10ec0280, 0x103c, 0, "ALC3228" },
886 { 0x10ec0282, 0x103c, 0, "ALC3227" },
887 { 0x10ec0286, 0x103c, 0, "ALC3242" },
888 { 0x10ec0290, 0x103c, 0, "ALC3241" },
889 { 0x10ec0668, 0x103c, 0, "ALC3662" },
890 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
891 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
Kailang Yang4b016932013-11-28 11:55:09 +0100892 { } /* terminator */
893};
894
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200895static int alc_codec_rename_from_preset(struct hda_codec *codec)
896{
897 const struct alc_codec_rename_table *p;
Kailang Yang4b016932013-11-28 11:55:09 +0100898 const struct alc_codec_rename_pci_table *q;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200899
900 for (p = rename_tbl; p->vendor_id; p++) {
901 if (p->vendor_id != codec->vendor_id)
902 continue;
Takashi Iwai1bb7e432011-10-17 16:50:59 +0200903 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200904 return alc_codec_rename(codec, p->name);
905 }
Kailang Yang4b016932013-11-28 11:55:09 +0100906
Takashi Iwai5100cd02014-02-15 10:03:19 +0100907 if (!codec->bus->pci)
908 return 0;
Kailang Yang4b016932013-11-28 11:55:09 +0100909 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
910 if (q->codec_vendor_id != codec->vendor_id)
911 continue;
912 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
913 continue;
914 if (!q->pci_subdevice ||
915 q->pci_subdevice == codec->bus->pci->subsystem_device)
916 return alc_codec_rename(codec, q->name);
917 }
918
Takashi Iwaie16fb6d2011-10-17 16:39:09 +0200919 return 0;
920}
921
Takashi Iwaie4770622011-07-08 11:11:35 +0200922
923/*
Takashi Iwai1d045db2011-07-07 18:23:21 +0200924 * Digital-beep handlers
925 */
926#ifdef CONFIG_SND_HDA_INPUT_BEEP
927#define set_beep_amp(spec, nid, idx, dir) \
928 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
929
930static const struct snd_pci_quirk beep_white_list[] = {
Duncan Roe71100052012-10-10 14:19:50 +0200931 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
W. Trevor Kinga4b7f21d2014-03-29 17:47:24 -0700932 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +0200933 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai8554ee42013-02-25 09:54:43 +0100934 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +0200935 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
936 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
937 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
Takashi Iwai78f8baf2012-03-06 14:02:32 +0100938 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
Takashi Iwai1d045db2011-07-07 18:23:21 +0200939 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
940 {}
941};
942
943static inline int has_cdefine_beep(struct hda_codec *codec)
944{
945 struct alc_spec *spec = codec->spec;
946 const struct snd_pci_quirk *q;
947 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
948 if (q)
949 return q->value;
950 return spec->cdefine.enable_pcbeep;
951}
952#else
953#define set_beep_amp(spec, nid, idx, dir) /* NOP */
954#define has_cdefine_beep(codec) 0
955#endif
956
957/* parse the BIOS configuration and set up the alc_spec */
958/* return 1 if successful, 0 if the proper config is not found,
959 * or a negative error code
960 */
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200961static int alc_parse_auto_config(struct hda_codec *codec,
962 const hda_nid_t *ignore_nids,
963 const hda_nid_t *ssid_nids)
Takashi Iwai1d045db2011-07-07 18:23:21 +0200964{
965 struct alc_spec *spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100966 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
Takashi Iwai1d045db2011-07-07 18:23:21 +0200967 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +0200968
Takashi Iwai53c334a2011-08-23 18:27:14 +0200969 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
970 spec->parse_flags);
Takashi Iwai1d045db2011-07-07 18:23:21 +0200971 if (err < 0)
972 return err;
Takashi Iwai3e6179b2011-07-08 16:55:13 +0200973
974 if (ssid_nids)
975 alc_ssid_check(codec, ssid_nids);
976
Takashi Iwai08c189f2012-12-19 15:22:24 +0100977 err = snd_hda_gen_parse_auto_config(codec, cfg);
978 if (err < 0)
979 return err;
Takashi Iwai070cff42012-02-21 12:54:17 +0100980
Takashi Iwai1d045db2011-07-07 18:23:21 +0200981 return 1;
982}
983
Takashi Iwai3de95172012-05-07 18:03:15 +0200984/* common preparation job for alc_spec */
985static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
986{
987 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
988 int err;
989
990 if (!spec)
991 return -ENOMEM;
992 codec->spec = spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100993 snd_hda_gen_spec_init(&spec->gen);
994 spec->gen.mixer_nid = mixer_nid;
995 spec->gen.own_eapd_ctl = 1;
Takashi Iwai1098b7c2012-12-17 20:03:15 +0100996 codec->single_adc_amp = 1;
Takashi Iwai08c189f2012-12-19 15:22:24 +0100997 /* FIXME: do we need this for all Realtek codec models? */
998 codec->spdif_status_reset = 1;
Takashi Iwai3de95172012-05-07 18:03:15 +0200999
1000 err = alc_codec_rename_from_preset(codec);
1001 if (err < 0) {
1002 kfree(spec);
1003 return err;
1004 }
1005 return 0;
1006}
1007
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001008static int alc880_parse_auto_config(struct hda_codec *codec)
1009{
1010 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02001011 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001012 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1013}
1014
Takashi Iwai1d045db2011-07-07 18:23:21 +02001015/*
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001016 * ALC880 fix-ups
1017 */
1018enum {
Takashi Iwai411225a2012-02-20 17:48:19 +01001019 ALC880_FIXUP_GPIO1,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001020 ALC880_FIXUP_GPIO2,
1021 ALC880_FIXUP_MEDION_RIM,
Takashi Iwaidc6af522012-02-17 16:18:59 +01001022 ALC880_FIXUP_LG,
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001023 ALC880_FIXUP_LG_LW25,
Takashi Iwaif02aab52012-02-17 16:33:56 +01001024 ALC880_FIXUP_W810,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001025 ALC880_FIXUP_EAPD_COEF,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001026 ALC880_FIXUP_TCL_S700,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001027 ALC880_FIXUP_VOL_KNOB,
1028 ALC880_FIXUP_FUJITSU,
Takashi Iwaiba533812012-02-20 16:36:52 +01001029 ALC880_FIXUP_F1734,
Takashi Iwai817de922012-02-20 17:20:48 +01001030 ALC880_FIXUP_UNIWILL,
Takashi Iwai967b88c2012-02-20 17:31:02 +01001031 ALC880_FIXUP_UNIWILL_DIG,
Takashi Iwai96e225f2012-02-20 17:41:51 +01001032 ALC880_FIXUP_Z71V,
Takashi Iwai487a5882013-11-07 07:29:30 +01001033 ALC880_FIXUP_ASUS_W5A,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001034 ALC880_FIXUP_3ST_BASE,
1035 ALC880_FIXUP_3ST,
1036 ALC880_FIXUP_3ST_DIG,
1037 ALC880_FIXUP_5ST_BASE,
1038 ALC880_FIXUP_5ST,
1039 ALC880_FIXUP_5ST_DIG,
1040 ALC880_FIXUP_6ST_BASE,
1041 ALC880_FIXUP_6ST,
1042 ALC880_FIXUP_6ST_DIG,
Takashi Iwai53971452013-01-23 18:21:37 +01001043 ALC880_FIXUP_6ST_AUTOMUTE,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001044};
1045
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001046/* enable the volume-knob widget support on NID 0x21 */
1047static void alc880_fixup_vol_knob(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001048 const struct hda_fixup *fix, int action)
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001049{
Takashi Iwai1727a772013-01-10 09:52:52 +01001050 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwai62f949b2014-09-11 14:06:53 +02001051 snd_hda_jack_detect_enable_callback(codec, 0x21,
1052 alc_update_knob_master);
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001053}
1054
Takashi Iwai1727a772013-01-10 09:52:52 +01001055static const struct hda_fixup alc880_fixups[] = {
Takashi Iwai411225a2012-02-20 17:48:19 +01001056 [ALC880_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001057 .type = HDA_FIXUP_VERBS,
Takashi Iwai411225a2012-02-20 17:48:19 +01001058 .v.verbs = alc_gpio1_init_verbs,
1059 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001060 [ALC880_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001061 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001062 .v.verbs = alc_gpio2_init_verbs,
1063 },
1064 [ALC880_FIXUP_MEDION_RIM] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001065 .type = HDA_FIXUP_VERBS,
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001066 .v.verbs = (const struct hda_verb[]) {
1067 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1068 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1069 { }
1070 },
1071 .chained = true,
1072 .chain_id = ALC880_FIXUP_GPIO2,
1073 },
Takashi Iwaidc6af522012-02-17 16:18:59 +01001074 [ALC880_FIXUP_LG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001075 .type = HDA_FIXUP_PINS,
1076 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaidc6af522012-02-17 16:18:59 +01001077 /* disable bogus unused pins */
1078 { 0x16, 0x411111f0 },
1079 { 0x18, 0x411111f0 },
1080 { 0x1a, 0x411111f0 },
1081 { }
1082 }
1083 },
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001084 [ALC880_FIXUP_LG_LW25] = {
1085 .type = HDA_FIXUP_PINS,
1086 .v.pins = (const struct hda_pintbl[]) {
1087 { 0x1a, 0x0181344f }, /* line-in */
1088 { 0x1b, 0x0321403f }, /* headphone */
1089 { }
1090 }
1091 },
Takashi Iwaif02aab52012-02-17 16:33:56 +01001092 [ALC880_FIXUP_W810] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001093 .type = HDA_FIXUP_PINS,
1094 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001095 /* disable bogus unused pins */
1096 { 0x17, 0x411111f0 },
1097 { }
1098 },
1099 .chained = true,
1100 .chain_id = ALC880_FIXUP_GPIO2,
1101 },
Takashi Iwai27e917f2012-02-17 17:49:54 +01001102 [ALC880_FIXUP_EAPD_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001103 .type = HDA_FIXUP_VERBS,
Takashi Iwai27e917f2012-02-17 17:49:54 +01001104 .v.verbs = (const struct hda_verb[]) {
1105 /* change to EAPD mode */
1106 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1107 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1108 {}
1109 },
1110 },
Takashi Iwaib9368f52012-02-17 17:54:44 +01001111 [ALC880_FIXUP_TCL_S700] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001112 .type = HDA_FIXUP_VERBS,
Takashi Iwaib9368f52012-02-17 17:54:44 +01001113 .v.verbs = (const struct hda_verb[]) {
1114 /* change to EAPD mode */
1115 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1116 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1117 {}
1118 },
1119 .chained = true,
1120 .chain_id = ALC880_FIXUP_GPIO2,
1121 },
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001122 [ALC880_FIXUP_VOL_KNOB] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001123 .type = HDA_FIXUP_FUNC,
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001124 .v.func = alc880_fixup_vol_knob,
1125 },
1126 [ALC880_FIXUP_FUJITSU] = {
1127 /* override all pins as BIOS on old Amilo is broken */
Takashi Iwai1727a772013-01-10 09:52:52 +01001128 .type = HDA_FIXUP_PINS,
1129 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001130 { 0x14, 0x0121411f }, /* HP */
1131 { 0x15, 0x99030120 }, /* speaker */
1132 { 0x16, 0x99030130 }, /* bass speaker */
1133 { 0x17, 0x411111f0 }, /* N/A */
1134 { 0x18, 0x411111f0 }, /* N/A */
1135 { 0x19, 0x01a19950 }, /* mic-in */
1136 { 0x1a, 0x411111f0 }, /* N/A */
1137 { 0x1b, 0x411111f0 }, /* N/A */
1138 { 0x1c, 0x411111f0 }, /* N/A */
1139 { 0x1d, 0x411111f0 }, /* N/A */
1140 { 0x1e, 0x01454140 }, /* SPDIF out */
1141 { }
1142 },
1143 .chained = true,
1144 .chain_id = ALC880_FIXUP_VOL_KNOB,
1145 },
Takashi Iwaiba533812012-02-20 16:36:52 +01001146 [ALC880_FIXUP_F1734] = {
1147 /* almost compatible with FUJITSU, but no bass and SPDIF */
Takashi Iwai1727a772013-01-10 09:52:52 +01001148 .type = HDA_FIXUP_PINS,
1149 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiba533812012-02-20 16:36:52 +01001150 { 0x14, 0x0121411f }, /* HP */
1151 { 0x15, 0x99030120 }, /* speaker */
1152 { 0x16, 0x411111f0 }, /* N/A */
1153 { 0x17, 0x411111f0 }, /* N/A */
1154 { 0x18, 0x411111f0 }, /* N/A */
1155 { 0x19, 0x01a19950 }, /* mic-in */
1156 { 0x1a, 0x411111f0 }, /* N/A */
1157 { 0x1b, 0x411111f0 }, /* N/A */
1158 { 0x1c, 0x411111f0 }, /* N/A */
1159 { 0x1d, 0x411111f0 }, /* N/A */
1160 { 0x1e, 0x411111f0 }, /* N/A */
1161 { }
1162 },
1163 .chained = true,
1164 .chain_id = ALC880_FIXUP_VOL_KNOB,
1165 },
Takashi Iwai817de922012-02-20 17:20:48 +01001166 [ALC880_FIXUP_UNIWILL] = {
1167 /* need to fix HP and speaker pins to be parsed correctly */
Takashi Iwai1727a772013-01-10 09:52:52 +01001168 .type = HDA_FIXUP_PINS,
1169 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai817de922012-02-20 17:20:48 +01001170 { 0x14, 0x0121411f }, /* HP */
1171 { 0x15, 0x99030120 }, /* speaker */
1172 { 0x16, 0x99030130 }, /* bass speaker */
1173 { }
1174 },
1175 },
Takashi Iwai967b88c2012-02-20 17:31:02 +01001176 [ALC880_FIXUP_UNIWILL_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001177 .type = HDA_FIXUP_PINS,
1178 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai967b88c2012-02-20 17:31:02 +01001179 /* disable bogus unused pins */
1180 { 0x17, 0x411111f0 },
1181 { 0x19, 0x411111f0 },
1182 { 0x1b, 0x411111f0 },
1183 { 0x1f, 0x411111f0 },
1184 { }
1185 }
1186 },
Takashi Iwai96e225f2012-02-20 17:41:51 +01001187 [ALC880_FIXUP_Z71V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001188 .type = HDA_FIXUP_PINS,
1189 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai96e225f2012-02-20 17:41:51 +01001190 /* set up the whole pins as BIOS is utterly broken */
1191 { 0x14, 0x99030120 }, /* speaker */
1192 { 0x15, 0x0121411f }, /* HP */
1193 { 0x16, 0x411111f0 }, /* N/A */
1194 { 0x17, 0x411111f0 }, /* N/A */
1195 { 0x18, 0x01a19950 }, /* mic-in */
1196 { 0x19, 0x411111f0 }, /* N/A */
1197 { 0x1a, 0x01813031 }, /* line-in */
1198 { 0x1b, 0x411111f0 }, /* N/A */
1199 { 0x1c, 0x411111f0 }, /* N/A */
1200 { 0x1d, 0x411111f0 }, /* N/A */
1201 { 0x1e, 0x0144111e }, /* SPDIF */
1202 { }
1203 }
1204 },
Takashi Iwai487a5882013-11-07 07:29:30 +01001205 [ALC880_FIXUP_ASUS_W5A] = {
1206 .type = HDA_FIXUP_PINS,
1207 .v.pins = (const struct hda_pintbl[]) {
1208 /* set up the whole pins as BIOS is utterly broken */
1209 { 0x14, 0x0121411f }, /* HP */
1210 { 0x15, 0x411111f0 }, /* N/A */
1211 { 0x16, 0x411111f0 }, /* N/A */
1212 { 0x17, 0x411111f0 }, /* N/A */
1213 { 0x18, 0x90a60160 }, /* mic */
1214 { 0x19, 0x411111f0 }, /* N/A */
1215 { 0x1a, 0x411111f0 }, /* N/A */
1216 { 0x1b, 0x411111f0 }, /* N/A */
1217 { 0x1c, 0x411111f0 }, /* N/A */
1218 { 0x1d, 0x411111f0 }, /* N/A */
1219 { 0x1e, 0xb743111e }, /* SPDIF out */
1220 { }
1221 },
1222 .chained = true,
1223 .chain_id = ALC880_FIXUP_GPIO1,
1224 },
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001225 [ALC880_FIXUP_3ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001226 .type = HDA_FIXUP_PINS,
1227 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001228 { 0x14, 0x01014010 }, /* line-out */
1229 { 0x15, 0x411111f0 }, /* N/A */
1230 { 0x16, 0x411111f0 }, /* N/A */
1231 { 0x17, 0x411111f0 }, /* N/A */
1232 { 0x18, 0x01a19c30 }, /* mic-in */
1233 { 0x19, 0x0121411f }, /* HP */
1234 { 0x1a, 0x01813031 }, /* line-in */
1235 { 0x1b, 0x02a19c40 }, /* front-mic */
1236 { 0x1c, 0x411111f0 }, /* N/A */
1237 { 0x1d, 0x411111f0 }, /* N/A */
1238 /* 0x1e is filled in below */
1239 { 0x1f, 0x411111f0 }, /* N/A */
1240 { }
1241 }
1242 },
1243 [ALC880_FIXUP_3ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001244 .type = HDA_FIXUP_PINS,
1245 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001246 { 0x1e, 0x411111f0 }, /* N/A */
1247 { }
1248 },
1249 .chained = true,
1250 .chain_id = ALC880_FIXUP_3ST_BASE,
1251 },
1252 [ALC880_FIXUP_3ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001253 .type = HDA_FIXUP_PINS,
1254 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001255 { 0x1e, 0x0144111e }, /* SPDIF */
1256 { }
1257 },
1258 .chained = true,
1259 .chain_id = ALC880_FIXUP_3ST_BASE,
1260 },
1261 [ALC880_FIXUP_5ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001262 .type = HDA_FIXUP_PINS,
1263 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001264 { 0x14, 0x01014010 }, /* front */
1265 { 0x15, 0x411111f0 }, /* N/A */
1266 { 0x16, 0x01011411 }, /* CLFE */
1267 { 0x17, 0x01016412 }, /* surr */
1268 { 0x18, 0x01a19c30 }, /* mic-in */
1269 { 0x19, 0x0121411f }, /* HP */
1270 { 0x1a, 0x01813031 }, /* line-in */
1271 { 0x1b, 0x02a19c40 }, /* front-mic */
1272 { 0x1c, 0x411111f0 }, /* N/A */
1273 { 0x1d, 0x411111f0 }, /* N/A */
1274 /* 0x1e is filled in below */
1275 { 0x1f, 0x411111f0 }, /* N/A */
1276 { }
1277 }
1278 },
1279 [ALC880_FIXUP_5ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001280 .type = HDA_FIXUP_PINS,
1281 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001282 { 0x1e, 0x411111f0 }, /* N/A */
1283 { }
1284 },
1285 .chained = true,
1286 .chain_id = ALC880_FIXUP_5ST_BASE,
1287 },
1288 [ALC880_FIXUP_5ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001289 .type = HDA_FIXUP_PINS,
1290 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001291 { 0x1e, 0x0144111e }, /* SPDIF */
1292 { }
1293 },
1294 .chained = true,
1295 .chain_id = ALC880_FIXUP_5ST_BASE,
1296 },
1297 [ALC880_FIXUP_6ST_BASE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001298 .type = HDA_FIXUP_PINS,
1299 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001300 { 0x14, 0x01014010 }, /* front */
1301 { 0x15, 0x01016412 }, /* surr */
1302 { 0x16, 0x01011411 }, /* CLFE */
1303 { 0x17, 0x01012414 }, /* side */
1304 { 0x18, 0x01a19c30 }, /* mic-in */
1305 { 0x19, 0x02a19c40 }, /* front-mic */
1306 { 0x1a, 0x01813031 }, /* line-in */
1307 { 0x1b, 0x0121411f }, /* HP */
1308 { 0x1c, 0x411111f0 }, /* N/A */
1309 { 0x1d, 0x411111f0 }, /* N/A */
1310 /* 0x1e is filled in below */
1311 { 0x1f, 0x411111f0 }, /* N/A */
1312 { }
1313 }
1314 },
1315 [ALC880_FIXUP_6ST] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001316 .type = HDA_FIXUP_PINS,
1317 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001318 { 0x1e, 0x411111f0 }, /* N/A */
1319 { }
1320 },
1321 .chained = true,
1322 .chain_id = ALC880_FIXUP_6ST_BASE,
1323 },
1324 [ALC880_FIXUP_6ST_DIG] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001325 .type = HDA_FIXUP_PINS,
1326 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001327 { 0x1e, 0x0144111e }, /* SPDIF */
1328 { }
1329 },
1330 .chained = true,
1331 .chain_id = ALC880_FIXUP_6ST_BASE,
1332 },
Takashi Iwai53971452013-01-23 18:21:37 +01001333 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1334 .type = HDA_FIXUP_PINS,
1335 .v.pins = (const struct hda_pintbl[]) {
1336 { 0x1b, 0x0121401f }, /* HP with jack detect */
1337 { }
1338 },
1339 .chained_before = true,
1340 .chain_id = ALC880_FIXUP_6ST_BASE,
1341 },
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001342};
1343
1344static const struct snd_pci_quirk alc880_fixup_tbl[] = {
Takashi Iwaif02aab52012-02-17 16:33:56 +01001345 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
Takashi Iwai487a5882013-11-07 07:29:30 +01001346 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
Takashi Iwai96e225f2012-02-20 17:41:51 +01001347 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001348 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
David Henningsson6538de02014-06-10 10:52:50 +02001349 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwai29e3fdc2012-02-20 17:56:57 +01001350 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
Takashi Iwai27e917f2012-02-17 17:49:54 +01001351 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
Takashi Iwai967b88c2012-02-20 17:31:02 +01001352 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
Takashi Iwaiba533812012-02-20 16:36:52 +01001353 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
Takashi Iwai817de922012-02-20 17:20:48 +01001354 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
Takashi Iwai7833c7e2012-02-20 17:11:38 +01001355 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
Takashi Iwaif02aab52012-02-17 16:33:56 +01001356 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001357 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
Takashi Iwai53971452013-01-23 18:21:37 +01001358 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
Takashi Iwaiba533812012-02-20 16:36:52 +01001359 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001360 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
Takashi Iwaiba533812012-02-20 16:36:52 +01001361 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
Takashi Iwaicf5a2272012-02-20 16:31:07 +01001362 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
Takashi Iwaidc6af522012-02-17 16:18:59 +01001363 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1364 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1365 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
Takashi Iwaidb8a38e2013-08-09 12:34:42 +02001366 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
Takashi Iwaib9368f52012-02-17 17:54:44 +01001367 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001368
1369 /* Below is the copied entries from alc880_quirks.c.
1370 * It's not quite sure whether BIOS sets the correct pin-config table
1371 * on these machines, thus they are kept to be compatible with
1372 * the old static quirks. Once when it's confirmed to work without
1373 * these overrides, it'd be better to remove.
1374 */
1375 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1376 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1377 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1378 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1379 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1380 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1381 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1382 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1383 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1384 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1385 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1386 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1387 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1388 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1389 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1390 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1391 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1392 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1393 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1394 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1395 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1396 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1397 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1398 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1399 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1400 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1401 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1402 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1403 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1404 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1405 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1406 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1407 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1408 /* default Intel */
1409 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1410 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1411 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1412 {}
1413};
1414
Takashi Iwai1727a772013-01-10 09:52:52 +01001415static const struct hda_model_fixup alc880_fixup_models[] = {
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001416 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1417 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1418 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1419 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1420 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1421 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
Takashi Iwai53971452013-01-23 18:21:37 +01001422 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
Takashi Iwaiee3b2962011-11-15 14:26:54 +01001423 {}
1424};
1425
1426
1427/*
Takashi Iwai1d045db2011-07-07 18:23:21 +02001428 * OK, here we have finally the patch for ALC880
1429 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001430static int patch_alc880(struct hda_codec *codec)
1431{
1432 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001433 int err;
1434
Takashi Iwai3de95172012-05-07 18:03:15 +02001435 err = alc_alloc_spec(codec, 0x0b);
1436 if (err < 0)
1437 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001438
Takashi Iwai3de95172012-05-07 18:03:15 +02001439 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01001440 spec->gen.need_dac_fix = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001441 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001442
Takashi Iwai1727a772013-01-10 09:52:52 +01001443 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001444 alc880_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001445 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001446
Takashi Iwai67b6ec32012-02-20 18:20:42 +01001447 /* automatic parse from the BIOS config */
1448 err = alc880_parse_auto_config(codec);
1449 if (err < 0)
1450 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001451
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001452 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001453 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001454
Takashi Iwai1d045db2011-07-07 18:23:21 +02001455 codec->patch_ops = alc_patch_ops;
David Henningsson29adc4b2012-09-25 11:31:00 +02001456 codec->patch_ops.unsol_event = alc880_unsol_event;
1457
Takashi Iwai1d045db2011-07-07 18:23:21 +02001458
Takashi Iwai1727a772013-01-10 09:52:52 +01001459 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001460
Takashi Iwai1d045db2011-07-07 18:23:21 +02001461 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001462
1463 error:
1464 alc_free(codec);
1465 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001466}
1467
1468
1469/*
1470 * ALC260 support
1471 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001472static int alc260_parse_auto_config(struct hda_codec *codec)
1473{
Takashi Iwai1d045db2011-07-07 18:23:21 +02001474 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001475 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1476 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001477}
1478
Takashi Iwai1d045db2011-07-07 18:23:21 +02001479/*
1480 * Pin config fixes
1481 */
1482enum {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001483 ALC260_FIXUP_HP_DC5750,
1484 ALC260_FIXUP_HP_PIN_0F,
1485 ALC260_FIXUP_COEF,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001486 ALC260_FIXUP_GPIO1,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001487 ALC260_FIXUP_GPIO1_TOGGLE,
1488 ALC260_FIXUP_REPLACER,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001489 ALC260_FIXUP_HP_B1900,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001490 ALC260_FIXUP_KN1,
Takashi Iwai39aedee2013-01-10 17:10:40 +01001491 ALC260_FIXUP_FSC_S7020,
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001492 ALC260_FIXUP_FSC_S7020_JWSE,
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001493 ALC260_FIXUP_VAIO_PINS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001494};
1495
Takashi Iwai20f7d922012-02-16 12:35:16 +01001496static void alc260_gpio1_automute(struct hda_codec *codec)
1497{
1498 struct alc_spec *spec = codec->spec;
1499 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwai08c189f2012-12-19 15:22:24 +01001500 spec->gen.hp_jack_present);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001501}
1502
1503static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001504 const struct hda_fixup *fix, int action)
Takashi Iwai20f7d922012-02-16 12:35:16 +01001505{
1506 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001507 if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwai20f7d922012-02-16 12:35:16 +01001508 /* although the machine has only one output pin, we need to
1509 * toggle GPIO1 according to the jack state
1510 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01001511 spec->gen.automute_hook = alc260_gpio1_automute;
1512 spec->gen.detect_hp = 1;
1513 spec->gen.automute_speaker = 1;
1514 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
Takashi Iwai62f949b2014-09-11 14:06:53 +02001515 snd_hda_jack_detect_enable_callback(codec, 0x0f,
Takashi Iwai08c189f2012-12-19 15:22:24 +01001516 snd_hda_gen_hp_automute);
Takashi Iwaic9ce6b22012-12-18 18:12:44 +01001517 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
Takashi Iwai20f7d922012-02-16 12:35:16 +01001518 }
1519}
1520
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001521static void alc260_fixup_kn1(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001522 const struct hda_fixup *fix, int action)
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001523{
1524 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01001525 static const struct hda_pintbl pincfgs[] = {
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001526 { 0x0f, 0x02214000 }, /* HP/speaker */
1527 { 0x12, 0x90a60160 }, /* int mic */
1528 { 0x13, 0x02a19000 }, /* ext mic */
1529 { 0x18, 0x01446000 }, /* SPDIF out */
1530 /* disable bogus I/O pins */
1531 { 0x10, 0x411111f0 },
1532 { 0x11, 0x411111f0 },
1533 { 0x14, 0x411111f0 },
1534 { 0x15, 0x411111f0 },
1535 { 0x16, 0x411111f0 },
1536 { 0x17, 0x411111f0 },
1537 { 0x19, 0x411111f0 },
1538 { }
1539 };
1540
1541 switch (action) {
Takashi Iwai1727a772013-01-10 09:52:52 +01001542 case HDA_FIXUP_ACT_PRE_PROBE:
1543 snd_hda_apply_pincfgs(codec, pincfgs);
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001544 break;
Takashi Iwai1727a772013-01-10 09:52:52 +01001545 case HDA_FIXUP_ACT_PROBE:
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001546 spec->init_amp = ALC_INIT_NONE;
1547 break;
1548 }
1549}
1550
Takashi Iwai39aedee2013-01-10 17:10:40 +01001551static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1552 const struct hda_fixup *fix, int action)
1553{
1554 struct alc_spec *spec = codec->spec;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001555 if (action == HDA_FIXUP_ACT_PROBE)
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001556 spec->init_amp = ALC_INIT_NONE;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001557}
1558
1559static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1560 const struct hda_fixup *fix, int action)
1561{
1562 struct alc_spec *spec = codec->spec;
1563 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaif811c3c2013-03-07 18:32:59 +01001564 spec->gen.add_jack_modes = 1;
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001565 spec->gen.hp_mic = 1;
Takashi Iwaie6e0ee52013-02-18 17:04:20 +01001566 }
Takashi Iwai39aedee2013-01-10 17:10:40 +01001567}
1568
Takashi Iwai1727a772013-01-10 09:52:52 +01001569static const struct hda_fixup alc260_fixups[] = {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001570 [ALC260_FIXUP_HP_DC5750] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001571 .type = HDA_FIXUP_PINS,
1572 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001573 { 0x11, 0x90130110 }, /* speaker */
1574 { }
1575 }
1576 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001577 [ALC260_FIXUP_HP_PIN_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001578 .type = HDA_FIXUP_PINS,
1579 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaica8f0422012-02-16 11:51:19 +01001580 { 0x0f, 0x01214000 }, /* HP */
1581 { }
1582 }
1583 },
1584 [ALC260_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001585 .type = HDA_FIXUP_VERBS,
Takashi Iwaica8f0422012-02-16 11:51:19 +01001586 .v.verbs = (const struct hda_verb[]) {
Ronan Marquete30cf2d2014-06-01 18:38:53 +02001587 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1588 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001589 { }
1590 },
Takashi Iwaica8f0422012-02-16 11:51:19 +01001591 },
Takashi Iwai15317ab2012-02-16 12:02:53 +01001592 [ALC260_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001593 .type = HDA_FIXUP_VERBS,
Takashi Iwai15317ab2012-02-16 12:02:53 +01001594 .v.verbs = alc_gpio1_init_verbs,
1595 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001596 [ALC260_FIXUP_GPIO1_TOGGLE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001597 .type = HDA_FIXUP_FUNC,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001598 .v.func = alc260_fixup_gpio1_toggle,
1599 .chained = true,
1600 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1601 },
1602 [ALC260_FIXUP_REPLACER] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001603 .type = HDA_FIXUP_VERBS,
Takashi Iwai20f7d922012-02-16 12:35:16 +01001604 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai192a98e2014-06-02 15:16:07 +02001605 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1606 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
Takashi Iwai20f7d922012-02-16 12:35:16 +01001607 { }
1608 },
1609 .chained = true,
1610 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1611 },
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001612 [ALC260_FIXUP_HP_B1900] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001613 .type = HDA_FIXUP_FUNC,
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001614 .v.func = alc260_fixup_gpio1_toggle,
1615 .chained = true,
1616 .chain_id = ALC260_FIXUP_COEF,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001617 },
1618 [ALC260_FIXUP_KN1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001619 .type = HDA_FIXUP_FUNC,
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001620 .v.func = alc260_fixup_kn1,
1621 },
Takashi Iwai39aedee2013-01-10 17:10:40 +01001622 [ALC260_FIXUP_FSC_S7020] = {
1623 .type = HDA_FIXUP_FUNC,
1624 .v.func = alc260_fixup_fsc_s7020,
1625 },
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001626 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1627 .type = HDA_FIXUP_FUNC,
1628 .v.func = alc260_fixup_fsc_s7020_jwse,
1629 .chained = true,
1630 .chain_id = ALC260_FIXUP_FSC_S7020,
1631 },
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001632 [ALC260_FIXUP_VAIO_PINS] = {
1633 .type = HDA_FIXUP_PINS,
1634 .v.pins = (const struct hda_pintbl[]) {
1635 /* Pin configs are missing completely on some VAIOs */
1636 { 0x0f, 0x01211020 },
1637 { 0x10, 0x0001003f },
1638 { 0x11, 0x411111f0 },
1639 { 0x12, 0x01a15930 },
1640 { 0x13, 0x411111f0 },
1641 { 0x14, 0x411111f0 },
1642 { 0x15, 0x411111f0 },
1643 { 0x16, 0x411111f0 },
1644 { 0x17, 0x411111f0 },
1645 { 0x18, 0x411111f0 },
1646 { 0x19, 0x411111f0 },
1647 { }
1648 }
1649 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02001650};
1651
1652static const struct snd_pci_quirk alc260_fixup_tbl[] = {
Takashi Iwai15317ab2012-02-16 12:02:53 +01001653 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001654 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
Takashi Iwai15317ab2012-02-16 12:02:53 +01001655 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001656 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
Takashi Iwai0a1c4fa2012-02-16 12:42:30 +01001657 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
Takashi Iwaid08c5ef2013-11-22 08:06:36 +01001658 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
Takashi Iwai0f5a5b82013-11-21 09:12:52 +01001659 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
Takashi Iwai39aedee2013-01-10 17:10:40 +01001660 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
Takashi Iwaib1f58082012-02-16 12:45:03 +01001661 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
Takashi Iwai118cb4a2012-04-19 07:33:27 +02001662 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
Takashi Iwai20f7d922012-02-16 12:35:16 +01001663 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
Takashi Iwaica8f0422012-02-16 11:51:19 +01001664 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02001665 {}
1666};
1667
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001668static const struct hda_model_fixup alc260_fixup_models[] = {
1669 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1670 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1671 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1672 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1673 {}
1674};
1675
Takashi Iwai1d045db2011-07-07 18:23:21 +02001676/*
1677 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001678static int patch_alc260(struct hda_codec *codec)
1679{
1680 struct alc_spec *spec;
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001681 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001682
Takashi Iwai3de95172012-05-07 18:03:15 +02001683 err = alc_alloc_spec(codec, 0x07);
1684 if (err < 0)
1685 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001686
Takashi Iwai3de95172012-05-07 18:03:15 +02001687 spec = codec->spec;
Takashi Iwaiea46c3c2013-01-15 18:45:53 +01001688 /* as quite a few machines require HP amp for speaker outputs,
1689 * it's easier to enable it unconditionally; even if it's unneeded,
1690 * it's almost harmless.
1691 */
1692 spec->gen.prefer_hp_amp = 1;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001693 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001694
Takashi Iwai5ebd3bb2013-02-19 18:23:31 +01001695 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1696 alc260_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01001697 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001698
Takashi Iwaic3c2c9e2012-02-16 12:59:55 +01001699 /* automatic parse from the BIOS config */
1700 err = alc260_parse_auto_config(codec);
1701 if (err < 0)
1702 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001703
Takashi Iwai7504b6c2013-03-18 11:25:51 +01001704 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02001705 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02001706
Takashi Iwai1d045db2011-07-07 18:23:21 +02001707 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001708 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001709
Takashi Iwai1727a772013-01-10 09:52:52 +01001710 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01001711
Takashi Iwai1d045db2011-07-07 18:23:21 +02001712 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02001713
1714 error:
1715 alc_free(codec);
1716 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02001717}
1718
1719
1720/*
1721 * ALC882/883/885/888/889 support
1722 *
1723 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1724 * configuration. Each pin widget can choose any input DACs and a mixer.
1725 * Each ADC is connected from a mixer of all inputs. This makes possible
1726 * 6-channel independent captures.
1727 *
1728 * In addition, an independent DAC for the multi-playback (not used in this
1729 * driver yet).
1730 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02001731
1732/*
1733 * Pin config fixes
1734 */
1735enum {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001736 ALC882_FIXUP_ABIT_AW9D_MAX,
1737 ALC882_FIXUP_LENOVO_Y530,
1738 ALC882_FIXUP_PB_M5210,
1739 ALC882_FIXUP_ACER_ASPIRE_7736,
1740 ALC882_FIXUP_ASUS_W90V,
Marton Balint8f239212012-03-05 21:33:23 +01001741 ALC889_FIXUP_CD,
David Henningssonb2c53e22014-01-01 14:01:34 +01001742 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001743 ALC889_FIXUP_VAIO_TT,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001744 ALC888_FIXUP_EEE1601,
Takashi Iwai177943a32011-11-09 12:55:18 +01001745 ALC882_FIXUP_EAPD,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01001746 ALC883_FIXUP_EAPD,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01001747 ALC883_FIXUP_ACER_EAPD,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001748 ALC882_FIXUP_GPIO1,
1749 ALC882_FIXUP_GPIO2,
Takashi Iwaieb844d52011-11-09 18:03:07 +01001750 ALC882_FIXUP_GPIO3,
Takashi Iwai68ef0562011-11-09 18:24:44 +01001751 ALC889_FIXUP_COEF,
1752 ALC882_FIXUP_ASUS_W2JC,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01001753 ALC882_FIXUP_ACER_ASPIRE_4930G,
1754 ALC882_FIXUP_ACER_ASPIRE_8930G,
1755 ALC882_FIXUP_ASPIRE_8930G_VERBS,
Takashi Iwai56710872011-11-14 17:42:11 +01001756 ALC885_FIXUP_MACPRO_GPIO,
Takashi Iwai02a237b2012-02-13 15:25:07 +01001757 ALC889_FIXUP_DAC_ROUTE,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001758 ALC889_FIXUP_MBP_VREF,
1759 ALC889_FIXUP_IMAC91_VREF,
Adrien Vergée7729a42014-01-24 14:56:14 -05001760 ALC889_FIXUP_MBA11_VREF,
Takashi Iwai0756f092013-12-04 13:59:45 +01001761 ALC889_FIXUP_MBA21_VREF,
Takashi Iwaic20f31e2014-02-03 11:02:10 +01001762 ALC889_FIXUP_MP11_VREF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02001763 ALC882_FIXUP_INV_DMIC,
Takashi Iwaie427c232012-07-29 10:04:08 +02001764 ALC882_FIXUP_NO_PRIMARY_HP,
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01001765 ALC887_FIXUP_ASUS_BASS,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01001766 ALC887_FIXUP_BASS_CHMAP,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001767};
1768
Takashi Iwai68ef0562011-11-09 18:24:44 +01001769static void alc889_fixup_coef(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001770 const struct hda_fixup *fix, int action)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001771{
Takashi Iwai1727a772013-01-10 09:52:52 +01001772 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai68ef0562011-11-09 18:24:44 +01001773 return;
Kailang Yang1df88742014-10-29 16:10:13 +08001774 alc_update_coef_idx(codec, 7, 0, 0x2030);
Takashi Iwai68ef0562011-11-09 18:24:44 +01001775}
1776
Takashi Iwai56710872011-11-14 17:42:11 +01001777/* toggle speaker-output according to the hp-jack state */
1778static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1779{
1780 unsigned int gpiostate, gpiomask, gpiodir;
1781
1782 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1783 AC_VERB_GET_GPIO_DATA, 0);
1784
1785 if (!muted)
1786 gpiostate |= (1 << pin);
1787 else
1788 gpiostate &= ~(1 << pin);
1789
1790 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1791 AC_VERB_GET_GPIO_MASK, 0);
1792 gpiomask |= (1 << pin);
1793
1794 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1795 AC_VERB_GET_GPIO_DIRECTION, 0);
1796 gpiodir |= (1 << pin);
1797
1798
1799 snd_hda_codec_write(codec, codec->afg, 0,
1800 AC_VERB_SET_GPIO_MASK, gpiomask);
1801 snd_hda_codec_write(codec, codec->afg, 0,
1802 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1803
1804 msleep(1);
1805
1806 snd_hda_codec_write(codec, codec->afg, 0,
1807 AC_VERB_SET_GPIO_DATA, gpiostate);
1808}
1809
1810/* set up GPIO at initialization */
1811static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001812 const struct hda_fixup *fix, int action)
Takashi Iwai56710872011-11-14 17:42:11 +01001813{
Takashi Iwai1727a772013-01-10 09:52:52 +01001814 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai56710872011-11-14 17:42:11 +01001815 return;
1816 alc882_gpio_mute(codec, 0, 0);
1817 alc882_gpio_mute(codec, 1, 0);
1818}
1819
Takashi Iwai02a237b2012-02-13 15:25:07 +01001820/* Fix the connection of some pins for ALC889:
1821 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1822 * work correctly (bko#42740)
1823 */
1824static void alc889_fixup_dac_route(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001825 const struct hda_fixup *fix, int action)
Takashi Iwai02a237b2012-02-13 15:25:07 +01001826{
Takashi Iwai1727a772013-01-10 09:52:52 +01001827 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001828 /* fake the connections during parsing the tree */
Takashi Iwai02a237b2012-02-13 15:25:07 +01001829 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1830 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1831 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1832 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1833 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1834 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
Takashi Iwai1727a772013-01-10 09:52:52 +01001835 } else if (action == HDA_FIXUP_ACT_PROBE) {
Takashi Iwaief8d60f2012-02-17 10:12:38 +01001836 /* restore the connections */
1837 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1838 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1839 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1840 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1841 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
Takashi Iwai02a237b2012-02-13 15:25:07 +01001842 }
1843}
1844
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001845/* Set VREF on HP pin */
1846static void alc889_fixup_mbp_vref(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001847 const struct hda_fixup *fix, int action)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001848{
1849 struct alc_spec *spec = codec->spec;
1850 static hda_nid_t nids[2] = { 0x14, 0x15 };
1851 int i;
1852
Takashi Iwai1727a772013-01-10 09:52:52 +01001853 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001854 return;
1855 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1856 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1857 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1858 continue;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001859 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001860 val |= AC_PINCTL_VREF_80;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001861 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01001862 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001863 break;
1864 }
1865}
1866
Takashi Iwai0756f092013-12-04 13:59:45 +01001867static void alc889_fixup_mac_pins(struct hda_codec *codec,
1868 const hda_nid_t *nids, int num_nids)
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001869{
1870 struct alc_spec *spec = codec->spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001871 int i;
1872
Takashi Iwai0756f092013-12-04 13:59:45 +01001873 for (i = 0; i < num_nids; i++) {
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001874 unsigned int val;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01001875 val = snd_hda_codec_get_pin_target(codec, nids[i]);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001876 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02001877 snd_hda_set_pin_ctl(codec, nids[i], val);
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001878 }
Takashi Iwai08c189f2012-12-19 15:22:24 +01001879 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01001880}
1881
Takashi Iwai0756f092013-12-04 13:59:45 +01001882/* Set VREF on speaker pins on imac91 */
1883static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1884 const struct hda_fixup *fix, int action)
1885{
1886 static hda_nid_t nids[2] = { 0x18, 0x1a };
1887
1888 if (action == HDA_FIXUP_ACT_INIT)
1889 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1890}
1891
Adrien Vergée7729a42014-01-24 14:56:14 -05001892/* Set VREF on speaker pins on mba11 */
1893static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1894 const struct hda_fixup *fix, int action)
1895{
1896 static hda_nid_t nids[1] = { 0x18 };
1897
1898 if (action == HDA_FIXUP_ACT_INIT)
1899 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1900}
1901
Takashi Iwai0756f092013-12-04 13:59:45 +01001902/* Set VREF on speaker pins on mba21 */
1903static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1904 const struct hda_fixup *fix, int action)
1905{
1906 static hda_nid_t nids[2] = { 0x18, 0x19 };
1907
1908 if (action == HDA_FIXUP_ACT_INIT)
1909 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1910}
1911
Takashi Iwaie427c232012-07-29 10:04:08 +02001912/* Don't take HP output as primary
Fernando Luis Vázquez Caod9111492013-02-12 16:49:46 +09001913 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1914 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
Takashi Iwaie427c232012-07-29 10:04:08 +02001915 */
1916static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01001917 const struct hda_fixup *fix, int action)
Takashi Iwaie427c232012-07-29 10:04:08 +02001918{
1919 struct alc_spec *spec = codec->spec;
Takashi Iwaida96fb52013-07-29 16:54:36 +02001920 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08c189f2012-12-19 15:22:24 +01001921 spec->gen.no_primary_hp = 1;
Takashi Iwaida96fb52013-07-29 16:54:36 +02001922 spec->gen.no_multi_io = 1;
1923 }
Takashi Iwaie427c232012-07-29 10:04:08 +02001924}
1925
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01001926static void alc_fixup_bass_chmap(struct hda_codec *codec,
1927 const struct hda_fixup *fix, int action);
1928
Takashi Iwai1727a772013-01-10 09:52:52 +01001929static const struct hda_fixup alc882_fixups[] = {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001930 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001931 .type = HDA_FIXUP_PINS,
1932 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001933 { 0x15, 0x01080104 }, /* side */
1934 { 0x16, 0x01011012 }, /* rear */
1935 { 0x17, 0x01016011 }, /* clfe */
1936 { }
1937 }
1938 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001939 [ALC882_FIXUP_LENOVO_Y530] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001940 .type = HDA_FIXUP_PINS,
1941 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02001942 { 0x15, 0x99130112 }, /* rear int speakers */
1943 { 0x16, 0x99130111 }, /* subwoofer */
1944 { }
1945 }
1946 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001947 [ALC882_FIXUP_PB_M5210] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01001948 .type = HDA_FIXUP_PINCTLS,
1949 .v.pins = (const struct hda_pintbl[]) {
1950 { 0x19, PIN_VREF50 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02001951 {}
1952 }
1953 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001954 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001955 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02001956 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02001957 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001958 [ALC882_FIXUP_ASUS_W90V] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001959 .type = HDA_FIXUP_PINS,
1960 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5cdf7452011-10-26 23:04:08 +02001961 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
1962 { }
1963 }
1964 },
Marton Balint8f239212012-03-05 21:33:23 +01001965 [ALC889_FIXUP_CD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001966 .type = HDA_FIXUP_PINS,
1967 .v.pins = (const struct hda_pintbl[]) {
Marton Balint8f239212012-03-05 21:33:23 +01001968 { 0x1c, 0x993301f0 }, /* CD */
1969 { }
1970 }
1971 },
David Henningssonb2c53e22014-01-01 14:01:34 +01001972 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
1973 .type = HDA_FIXUP_PINS,
1974 .v.pins = (const struct hda_pintbl[]) {
1975 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
1976 { }
1977 },
1978 .chained = true,
1979 .chain_id = ALC889_FIXUP_CD,
1980 },
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001981 [ALC889_FIXUP_VAIO_TT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001982 .type = HDA_FIXUP_PINS,
1983 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01001984 { 0x17, 0x90170111 }, /* hidden surround speaker */
1985 { }
1986 }
1987 },
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001988 [ALC888_FIXUP_EEE1601] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001989 .type = HDA_FIXUP_VERBS,
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01001990 .v.verbs = (const struct hda_verb[]) {
1991 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1992 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
1993 { }
1994 }
Takashi Iwai177943a32011-11-09 12:55:18 +01001995 },
1996 [ALC882_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01001997 .type = HDA_FIXUP_VERBS,
Takashi Iwai177943a32011-11-09 12:55:18 +01001998 .v.verbs = (const struct hda_verb[]) {
1999 /* change to EAPD mode */
2000 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2001 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2002 { }
2003 }
2004 },
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002005 [ALC883_FIXUP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002006 .type = HDA_FIXUP_VERBS,
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002007 .v.verbs = (const struct hda_verb[]) {
2008 /* change to EAPD mode */
2009 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2010 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2011 { }
2012 }
2013 },
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002014 [ALC883_FIXUP_ACER_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002015 .type = HDA_FIXUP_VERBS,
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002016 .v.verbs = (const struct hda_verb[]) {
2017 /* eanable EAPD on Acer laptops */
2018 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2019 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2020 { }
2021 }
2022 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002023 [ALC882_FIXUP_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002024 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002025 .v.verbs = alc_gpio1_init_verbs,
2026 },
2027 [ALC882_FIXUP_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002028 .type = HDA_FIXUP_VERBS,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002029 .v.verbs = alc_gpio2_init_verbs,
2030 },
Takashi Iwaieb844d52011-11-09 18:03:07 +01002031 [ALC882_FIXUP_GPIO3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002032 .type = HDA_FIXUP_VERBS,
Takashi Iwaieb844d52011-11-09 18:03:07 +01002033 .v.verbs = alc_gpio3_init_verbs,
2034 },
Takashi Iwai68ef0562011-11-09 18:24:44 +01002035 [ALC882_FIXUP_ASUS_W2JC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002036 .type = HDA_FIXUP_VERBS,
Takashi Iwai68ef0562011-11-09 18:24:44 +01002037 .v.verbs = alc_gpio1_init_verbs,
2038 .chained = true,
2039 .chain_id = ALC882_FIXUP_EAPD,
2040 },
2041 [ALC889_FIXUP_COEF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002042 .type = HDA_FIXUP_FUNC,
Takashi Iwai68ef0562011-11-09 18:24:44 +01002043 .v.func = alc889_fixup_coef,
2044 },
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002045 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002046 .type = HDA_FIXUP_PINS,
2047 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002048 { 0x16, 0x99130111 }, /* CLFE speaker */
2049 { 0x17, 0x99130112 }, /* surround speaker */
2050 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02002051 },
2052 .chained = true,
2053 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002054 },
2055 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002056 .type = HDA_FIXUP_PINS,
2057 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002058 { 0x16, 0x99130111 }, /* CLFE speaker */
2059 { 0x1b, 0x99130112 }, /* surround speaker */
2060 { }
2061 },
2062 .chained = true,
2063 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2064 },
2065 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2066 /* additional init verbs for Acer Aspire 8930G */
Takashi Iwai1727a772013-01-10 09:52:52 +01002067 .type = HDA_FIXUP_VERBS,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002068 .v.verbs = (const struct hda_verb[]) {
2069 /* Enable all DACs */
2070 /* DAC DISABLE/MUTE 1? */
2071 /* setting bits 1-5 disables DAC nids 0x02-0x06
2072 * apparently. Init=0x38 */
2073 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2074 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2075 /* DAC DISABLE/MUTE 2? */
2076 /* some bit here disables the other DACs.
2077 * Init=0x4900 */
2078 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2079 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2080 /* DMIC fix
2081 * This laptop has a stereo digital microphone.
2082 * The mics are only 1cm apart which makes the stereo
2083 * useless. However, either the mic or the ALC889
2084 * makes the signal become a difference/sum signal
2085 * instead of standard stereo, which is annoying.
2086 * So instead we flip this bit which makes the
2087 * codec replicate the sum signal to both channels,
2088 * turning it into a normal mono mic.
2089 */
2090 /* DMIC_CONTROL? Init value = 0x0001 */
2091 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2092 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2093 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2094 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2095 { }
Takashi Iwai038d4fe2012-04-11 17:18:12 +02002096 },
2097 .chained = true,
2098 .chain_id = ALC882_FIXUP_GPIO1,
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002099 },
Takashi Iwai56710872011-11-14 17:42:11 +01002100 [ALC885_FIXUP_MACPRO_GPIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002101 .type = HDA_FIXUP_FUNC,
Takashi Iwai56710872011-11-14 17:42:11 +01002102 .v.func = alc885_fixup_macpro_gpio,
2103 },
Takashi Iwai02a237b2012-02-13 15:25:07 +01002104 [ALC889_FIXUP_DAC_ROUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002105 .type = HDA_FIXUP_FUNC,
Takashi Iwai02a237b2012-02-13 15:25:07 +01002106 .v.func = alc889_fixup_dac_route,
2107 },
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002108 [ALC889_FIXUP_MBP_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002109 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002110 .v.func = alc889_fixup_mbp_vref,
2111 .chained = true,
2112 .chain_id = ALC882_FIXUP_GPIO1,
2113 },
2114 [ALC889_FIXUP_IMAC91_VREF] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002115 .type = HDA_FIXUP_FUNC,
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002116 .v.func = alc889_fixup_imac91_vref,
2117 .chained = true,
2118 .chain_id = ALC882_FIXUP_GPIO1,
2119 },
Adrien Vergée7729a42014-01-24 14:56:14 -05002120 [ALC889_FIXUP_MBA11_VREF] = {
2121 .type = HDA_FIXUP_FUNC,
2122 .v.func = alc889_fixup_mba11_vref,
2123 .chained = true,
2124 .chain_id = ALC889_FIXUP_MBP_VREF,
2125 },
Takashi Iwai0756f092013-12-04 13:59:45 +01002126 [ALC889_FIXUP_MBA21_VREF] = {
2127 .type = HDA_FIXUP_FUNC,
2128 .v.func = alc889_fixup_mba21_vref,
2129 .chained = true,
2130 .chain_id = ALC889_FIXUP_MBP_VREF,
2131 },
Takashi Iwaic20f31e2014-02-03 11:02:10 +01002132 [ALC889_FIXUP_MP11_VREF] = {
2133 .type = HDA_FIXUP_FUNC,
2134 .v.func = alc889_fixup_mba11_vref,
2135 .chained = true,
2136 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2137 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002138 [ALC882_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002139 .type = HDA_FIXUP_FUNC,
David Henningsson9d36a7d2014-10-07 10:18:42 +02002140 .v.func = alc_fixup_inv_dmic,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002141 },
Takashi Iwaie427c232012-07-29 10:04:08 +02002142 [ALC882_FIXUP_NO_PRIMARY_HP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002143 .type = HDA_FIXUP_FUNC,
Takashi Iwaie427c232012-07-29 10:04:08 +02002144 .v.func = alc882_fixup_no_primary_hp,
2145 },
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002146 [ALC887_FIXUP_ASUS_BASS] = {
2147 .type = HDA_FIXUP_PINS,
2148 .v.pins = (const struct hda_pintbl[]) {
2149 {0x16, 0x99130130}, /* bass speaker */
2150 {}
2151 },
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01002152 .chained = true,
2153 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2154 },
2155 [ALC887_FIXUP_BASS_CHMAP] = {
2156 .type = HDA_FIXUP_FUNC,
2157 .v.func = alc_fixup_bass_chmap,
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002158 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002159};
2160
2161static const struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai8812c4f2011-11-09 17:39:15 +01002162 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2163 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2164 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2165 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2166 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2167 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
Takashi Iwaic3e837b2011-11-10 16:01:47 +01002168 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2169 ALC882_FIXUP_ACER_ASPIRE_4930G),
2170 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2171 ALC882_FIXUP_ACER_ASPIRE_4930G),
2172 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2173 ALC882_FIXUP_ACER_ASPIRE_8930G),
2174 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2175 ALC882_FIXUP_ACER_ASPIRE_8930G),
2176 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2177 ALC882_FIXUP_ACER_ASPIRE_4930G),
2178 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2179 ALC882_FIXUP_ACER_ASPIRE_4930G),
2180 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2181 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002182 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
Takashi Iwaif5c53d82012-05-07 10:07:33 +02002183 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2184 ALC882_FIXUP_ACER_ASPIRE_4930G),
Takashi Iwai02a237b2012-02-13 15:25:07 +01002185 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
Takashi Iwaife97da12012-04-12 08:00:19 +02002186 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002187 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
Takashi Iwai177943a32011-11-09 12:55:18 +01002188 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002189 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002190 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
Takashi Iwai0e7cc2e2011-11-09 12:42:48 +01002191 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
Takashi Iwai1f0bbf02013-11-28 15:21:21 +01002192 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002193 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
Takashi Iwaie427c232012-07-29 10:04:08 +02002194 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
Fernando Luis Vázquez Cao12e31a72013-02-12 16:47:44 +09002195 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
Takashi Iwai56710872011-11-14 17:42:11 +01002196
2197 /* All Apple entries are in codec SSIDs */
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002198 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2199 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2200 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
Takashi Iwaic20f31e2014-02-03 11:02:10 +01002201 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002202 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2203 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002204 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2205 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002206 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
Adrien Vergée7729a42014-01-24 14:56:14 -05002207 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
Takashi Iwai0756f092013-12-04 13:59:45 +01002208 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002209 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2210 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002211 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002212 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2213 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2214 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
Josh Boyer29ebe402012-04-12 13:55:36 -04002215 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
Takashi Iwai05193632012-11-12 10:07:36 +01002216 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002217 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2218 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2219 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
Takashi Iwai56710872011-11-14 17:42:11 +01002220
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002221 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
Takashi Iwaibca40132012-05-07 11:13:14 +02002222 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Takashi Iwaieb844d52011-11-09 18:03:07 +01002223 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
David Henningssonb2c53e22014-01-01 14:01:34 +01002224 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
Takashi Iwai5c0ebfb2011-11-07 17:59:13 +01002225 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
Takashi Iwai7a6069b2011-11-09 15:22:01 +01002226 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2227 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
Takashi Iwaiac9b1cd2011-11-09 17:45:55 +01002228 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
Takashi Iwai68ef0562011-11-09 18:24:44 +01002229 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002230 {}
2231};
2232
Takashi Iwai1727a772013-01-10 09:52:52 +01002233static const struct hda_model_fixup alc882_fixup_models[] = {
Takashi Iwai912093b2012-04-11 14:03:41 +02002234 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2235 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2236 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002237 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaie427c232012-07-29 10:04:08 +02002238 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
Takashi Iwai912093b2012-04-11 14:03:41 +02002239 {}
2240};
2241
Takashi Iwai1d045db2011-07-07 18:23:21 +02002242/*
2243 * BIOS auto configuration
2244 */
2245/* almost identical with ALC880 parser... */
2246static int alc882_parse_auto_config(struct hda_codec *codec)
2247{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002248 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002249 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2250 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002251}
2252
Takashi Iwai1d045db2011-07-07 18:23:21 +02002253/*
2254 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002255static int patch_alc882(struct hda_codec *codec)
2256{
2257 struct alc_spec *spec;
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002258 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002259
Takashi Iwai3de95172012-05-07 18:03:15 +02002260 err = alc_alloc_spec(codec, 0x0b);
2261 if (err < 0)
2262 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002263
Takashi Iwai3de95172012-05-07 18:03:15 +02002264 spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002265
2266 switch (codec->vendor_id) {
2267 case 0x10ec0882:
2268 case 0x10ec0885:
Takashi Iwaiacf08082014-09-02 07:21:56 +02002269 case 0x10ec0900:
Takashi Iwai1d045db2011-07-07 18:23:21 +02002270 break;
2271 default:
2272 /* ALC883 and variants */
2273 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2274 break;
2275 }
2276
Takashi Iwai1727a772013-01-10 09:52:52 +01002277 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
Takashi Iwai912093b2012-04-11 14:03:41 +02002278 alc882_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002279 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002280
2281 alc_auto_parse_customize_define(codec);
2282
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002283 if (has_cdefine_beep(codec))
2284 spec->gen.beep_nid = 0x01;
2285
Takashi Iwai1a97b7f2012-02-21 11:11:48 +01002286 /* automatic parse from the BIOS config */
2287 err = alc882_parse_auto_config(codec);
2288 if (err < 0)
2289 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002290
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002291 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002292 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2293
Takashi Iwai1d045db2011-07-07 18:23:21 +02002294 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002295
Takashi Iwai1727a772013-01-10 09:52:52 +01002296 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002297
Takashi Iwai1d045db2011-07-07 18:23:21 +02002298 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002299
2300 error:
2301 alc_free(codec);
2302 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002303}
2304
2305
2306/*
2307 * ALC262 support
2308 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002309static int alc262_parse_auto_config(struct hda_codec *codec)
2310{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002311 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002312 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2313 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002314}
2315
2316/*
2317 * Pin config fixes
2318 */
2319enum {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002320 ALC262_FIXUP_FSC_H270,
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002321 ALC262_FIXUP_FSC_S7110,
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002322 ALC262_FIXUP_HP_Z200,
2323 ALC262_FIXUP_TYAN,
Takashi Iwaic4701502011-11-07 14:20:07 +01002324 ALC262_FIXUP_LENOVO_3000,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002325 ALC262_FIXUP_BENQ,
2326 ALC262_FIXUP_BENQ_T31,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002327 ALC262_FIXUP_INV_DMIC,
Mengdong Linb5c66112013-11-29 00:35:35 -05002328 ALC262_FIXUP_INTEL_BAYLEYBAY,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002329};
2330
Takashi Iwai1727a772013-01-10 09:52:52 +01002331static const struct hda_fixup alc262_fixups[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002332 [ALC262_FIXUP_FSC_H270] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002333 .type = HDA_FIXUP_PINS,
2334 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002335 { 0x14, 0x99130110 }, /* speaker */
2336 { 0x15, 0x0221142f }, /* front HP */
2337 { 0x1b, 0x0121141f }, /* rear HP */
2338 { }
2339 }
2340 },
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002341 [ALC262_FIXUP_FSC_S7110] = {
2342 .type = HDA_FIXUP_PINS,
2343 .v.pins = (const struct hda_pintbl[]) {
2344 { 0x15, 0x90170110 }, /* speaker */
2345 { }
2346 },
2347 .chained = true,
2348 .chain_id = ALC262_FIXUP_BENQ,
2349 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002350 [ALC262_FIXUP_HP_Z200] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002351 .type = HDA_FIXUP_PINS,
2352 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002353 { 0x16, 0x99130120 }, /* internal speaker */
2354 { }
2355 }
2356 },
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002357 [ALC262_FIXUP_TYAN] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002358 .type = HDA_FIXUP_PINS,
2359 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002360 { 0x14, 0x1993e1f0 }, /* int AUX */
2361 { }
2362 }
2363 },
Takashi Iwaic4701502011-11-07 14:20:07 +01002364 [ALC262_FIXUP_LENOVO_3000] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01002365 .type = HDA_FIXUP_PINCTLS,
2366 .v.pins = (const struct hda_pintbl[]) {
2367 { 0x19, PIN_VREF50 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002368 {}
2369 },
2370 .chained = true,
2371 .chain_id = ALC262_FIXUP_BENQ,
2372 },
2373 [ALC262_FIXUP_BENQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002374 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002375 .v.verbs = (const struct hda_verb[]) {
Takashi Iwaic4701502011-11-07 14:20:07 +01002376 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2377 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2378 {}
2379 }
2380 },
Takashi Iwaib42590b2011-11-07 14:41:01 +01002381 [ALC262_FIXUP_BENQ_T31] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002382 .type = HDA_FIXUP_VERBS,
Takashi Iwaib42590b2011-11-07 14:41:01 +01002383 .v.verbs = (const struct hda_verb[]) {
2384 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2385 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2386 {}
2387 }
2388 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002389 [ALC262_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002390 .type = HDA_FIXUP_FUNC,
David Henningsson9d36a7d2014-10-07 10:18:42 +02002391 .v.func = alc_fixup_inv_dmic,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002392 },
Mengdong Linb5c66112013-11-29 00:35:35 -05002393 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2394 .type = HDA_FIXUP_FUNC,
2395 .v.func = alc_fixup_no_depop_delay,
2396 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02002397};
2398
2399static const struct snd_pci_quirk alc262_fixup_tbl[] = {
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002400 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
Takashi Iwai7513e6d2013-01-18 15:41:34 +01002401 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
Takashi Iwai3dcd3be2011-11-07 14:59:40 +01002402 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
Takashi Iwaiea4e7af2011-11-07 12:23:55 +01002403 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2404 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
Takashi Iwaic4701502011-11-07 14:20:07 +01002405 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
Takashi Iwaib42590b2011-11-07 14:41:01 +01002406 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2407 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
Mengdong Linb5c66112013-11-29 00:35:35 -05002408 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
Takashi Iwai1d045db2011-07-07 18:23:21 +02002409 {}
2410};
2411
Takashi Iwai1727a772013-01-10 09:52:52 +01002412static const struct hda_model_fixup alc262_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002413 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2414 {}
2415};
Takashi Iwai1d045db2011-07-07 18:23:21 +02002416
Takashi Iwai1d045db2011-07-07 18:23:21 +02002417/*
2418 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002419static int patch_alc262(struct hda_codec *codec)
2420{
2421 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002422 int err;
2423
Takashi Iwai3de95172012-05-07 18:03:15 +02002424 err = alc_alloc_spec(codec, 0x0b);
2425 if (err < 0)
2426 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002427
Takashi Iwai3de95172012-05-07 18:03:15 +02002428 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01002429 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002430
2431#if 0
2432 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2433 * under-run
2434 */
Takashi Iwai98b24882014-08-18 13:47:50 +02002435 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002436#endif
Takashi Iwai1d045db2011-07-07 18:23:21 +02002437 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2438
Takashi Iwai1727a772013-01-10 09:52:52 +01002439 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002440 alc262_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01002441 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002442
Takashi Iwaiaf741c12012-05-07 18:09:48 +02002443 alc_auto_parse_customize_define(codec);
2444
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002445 if (has_cdefine_beep(codec))
2446 spec->gen.beep_nid = 0x01;
2447
Takashi Iwai42399f72011-11-07 17:18:44 +01002448 /* automatic parse from the BIOS config */
2449 err = alc262_parse_auto_config(codec);
2450 if (err < 0)
2451 goto error;
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002452
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002453 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002454 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2455
Takashi Iwai1d045db2011-07-07 18:23:21 +02002456 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002457 spec->shutup = alc_eapd_shutup;
2458
Takashi Iwai1727a772013-01-10 09:52:52 +01002459 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01002460
Takashi Iwai1d045db2011-07-07 18:23:21 +02002461 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002462
2463 error:
2464 alc_free(codec);
2465 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002466}
2467
2468/*
2469 * ALC268
2470 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002471/* bind Beep switches of both NID 0x0f and 0x10 */
2472static const struct hda_bind_ctls alc268_bind_beep_sw = {
2473 .ops = &snd_hda_bind_sw,
2474 .values = {
2475 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2476 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2477 0
2478 },
2479};
2480
2481static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2482 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2483 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2484 { }
2485};
2486
2487/* set PCBEEP vol = 0, mute connections */
2488static const struct hda_verb alc268_beep_init_verbs[] = {
2489 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2490 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2491 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2492 { }
2493};
2494
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002495enum {
2496 ALC268_FIXUP_INV_DMIC,
Takashi Iwaicb766402012-10-20 10:55:21 +02002497 ALC268_FIXUP_HP_EAPD,
Takashi Iwai24eff322013-11-04 18:21:08 +01002498 ALC268_FIXUP_SPDIF,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002499};
2500
Takashi Iwai1727a772013-01-10 09:52:52 +01002501static const struct hda_fixup alc268_fixups[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002502 [ALC268_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002503 .type = HDA_FIXUP_FUNC,
David Henningsson9d36a7d2014-10-07 10:18:42 +02002504 .v.func = alc_fixup_inv_dmic,
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002505 },
Takashi Iwaicb766402012-10-20 10:55:21 +02002506 [ALC268_FIXUP_HP_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01002507 .type = HDA_FIXUP_VERBS,
Takashi Iwaicb766402012-10-20 10:55:21 +02002508 .v.verbs = (const struct hda_verb[]) {
2509 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2510 {}
2511 }
2512 },
Takashi Iwai24eff322013-11-04 18:21:08 +01002513 [ALC268_FIXUP_SPDIF] = {
2514 .type = HDA_FIXUP_PINS,
2515 .v.pins = (const struct hda_pintbl[]) {
2516 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2517 {}
2518 }
2519 },
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002520};
2521
Takashi Iwai1727a772013-01-10 09:52:52 +01002522static const struct hda_model_fixup alc268_fixup_models[] = {
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002523 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
Takashi Iwaicb766402012-10-20 10:55:21 +02002524 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2525 {}
2526};
2527
2528static const struct snd_pci_quirk alc268_fixup_tbl[] = {
Takashi Iwai24eff322013-11-04 18:21:08 +01002529 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
David Henningssonfcd8f3b2013-01-28 05:45:47 +01002530 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
Takashi Iwaicb766402012-10-20 10:55:21 +02002531 /* below is codec SSID since multiple Toshiba laptops have the
2532 * same PCI SSID 1179:ff00
2533 */
2534 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002535 {}
2536};
2537
Takashi Iwai1d045db2011-07-07 18:23:21 +02002538/*
2539 * BIOS auto configuration
2540 */
2541static int alc268_parse_auto_config(struct hda_codec *codec)
2542{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002543 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002544 return alc_parse_auto_config(codec, NULL, alc268_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002545}
2546
Takashi Iwai1d045db2011-07-07 18:23:21 +02002547/*
2548 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02002549static int patch_alc268(struct hda_codec *codec)
2550{
2551 struct alc_spec *spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002552 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002553
Takashi Iwai1d045db2011-07-07 18:23:21 +02002554 /* ALC268 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02002555 err = alc_alloc_spec(codec, 0);
2556 if (err < 0)
2557 return err;
2558
2559 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002560 spec->gen.beep_nid = 0x01;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002561
Takashi Iwai1727a772013-01-10 09:52:52 +01002562 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2563 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002564
Takashi Iwai6ebb8052011-08-16 15:15:40 +02002565 /* automatic parse from the BIOS config */
2566 err = alc268_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002567 if (err < 0)
2568 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002569
Takashi Iwai7504b6c2013-03-18 11:25:51 +01002570 if (err > 0 && !spec->gen.no_analog &&
2571 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2572 add_mixer(spec, alc268_beep_mixer);
2573 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002574 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2575 /* override the amp caps for beep generator */
2576 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2577 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2578 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2579 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2580 (0 << AC_AMPCAP_MUTE_SHIFT));
2581 }
2582
Takashi Iwai1d045db2011-07-07 18:23:21 +02002583 codec->patch_ops = alc_patch_ops;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002584 spec->shutup = alc_eapd_shutup;
2585
Takashi Iwai1727a772013-01-10 09:52:52 +01002586 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai6e72aa52012-06-25 10:52:25 +02002587
Takashi Iwai1d045db2011-07-07 18:23:21 +02002588 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02002589
2590 error:
2591 alc_free(codec);
2592 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02002593}
2594
2595/*
2596 * ALC269
2597 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01002598
2599static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2600 struct hda_codec *codec,
2601 struct snd_pcm_substream *substream)
2602{
2603 struct hda_gen_spec *spec = codec->spec;
2604 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2605 hinfo);
2606}
2607
2608static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2609 struct hda_codec *codec,
2610 unsigned int stream_tag,
2611 unsigned int format,
2612 struct snd_pcm_substream *substream)
2613{
2614 struct hda_gen_spec *spec = codec->spec;
2615 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2616 stream_tag, format, substream);
2617}
2618
2619static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2620 struct hda_codec *codec,
2621 struct snd_pcm_substream *substream)
2622{
2623 struct hda_gen_spec *spec = codec->spec;
2624 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2625}
2626
Takashi Iwai1d045db2011-07-07 18:23:21 +02002627static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2628 .substreams = 1,
2629 .channels_min = 2,
2630 .channels_max = 8,
2631 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2632 /* NID is set in alc_build_pcms */
2633 .ops = {
Takashi Iwai08c189f2012-12-19 15:22:24 +01002634 .open = playback_pcm_open,
2635 .prepare = playback_pcm_prepare,
2636 .cleanup = playback_pcm_cleanup
Takashi Iwai1d045db2011-07-07 18:23:21 +02002637 },
2638};
2639
2640static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2641 .substreams = 1,
2642 .channels_min = 2,
2643 .channels_max = 2,
2644 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2645 /* NID is set in alc_build_pcms */
2646};
2647
Takashi Iwai1d045db2011-07-07 18:23:21 +02002648/* different alc269-variants */
2649enum {
2650 ALC269_TYPE_ALC269VA,
2651 ALC269_TYPE_ALC269VB,
2652 ALC269_TYPE_ALC269VC,
Kailang Yangadcc70b2012-05-25 08:08:38 +02002653 ALC269_TYPE_ALC269VD,
Kailang Yang065380f2013-01-10 10:25:48 +01002654 ALC269_TYPE_ALC280,
2655 ALC269_TYPE_ALC282,
Kailang Yang2af02be2013-08-22 10:03:50 +02002656 ALC269_TYPE_ALC283,
Kailang Yang065380f2013-01-10 10:25:48 +01002657 ALC269_TYPE_ALC284,
Kailang Yang161ebf22013-10-24 11:36:33 +02002658 ALC269_TYPE_ALC285,
Kailang Yang7fc7d042013-04-25 11:04:43 +02002659 ALC269_TYPE_ALC286,
Kailang Yang1d04c9d2013-10-24 11:35:18 +02002660 ALC269_TYPE_ALC255,
Takashi Iwai1d045db2011-07-07 18:23:21 +02002661};
2662
2663/*
2664 * BIOS auto configuration
2665 */
2666static int alc269_parse_auto_config(struct hda_codec *codec)
2667{
Takashi Iwai1d045db2011-07-07 18:23:21 +02002668 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002669 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2670 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2671 struct alc_spec *spec = codec->spec;
Kailang Yangadcc70b2012-05-25 08:08:38 +02002672 const hda_nid_t *ssids;
2673
2674 switch (spec->codec_variant) {
2675 case ALC269_TYPE_ALC269VA:
2676 case ALC269_TYPE_ALC269VC:
Kailang Yang065380f2013-01-10 10:25:48 +01002677 case ALC269_TYPE_ALC280:
2678 case ALC269_TYPE_ALC284:
Kailang Yang161ebf22013-10-24 11:36:33 +02002679 case ALC269_TYPE_ALC285:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002680 ssids = alc269va_ssids;
2681 break;
2682 case ALC269_TYPE_ALC269VB:
2683 case ALC269_TYPE_ALC269VD:
Kailang Yang065380f2013-01-10 10:25:48 +01002684 case ALC269_TYPE_ALC282:
Kailang Yang2af02be2013-08-22 10:03:50 +02002685 case ALC269_TYPE_ALC283:
Kailang Yang7fc7d042013-04-25 11:04:43 +02002686 case ALC269_TYPE_ALC286:
Kailang Yang1d04c9d2013-10-24 11:35:18 +02002687 case ALC269_TYPE_ALC255:
Kailang Yangadcc70b2012-05-25 08:08:38 +02002688 ssids = alc269_ssids;
2689 break;
2690 default:
2691 ssids = alc269_ssids;
2692 break;
2693 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02002694
Takashi Iwai3e6179b2011-07-08 16:55:13 +02002695 return alc_parse_auto_config(codec, alc269_ignore, ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002696}
2697
Kailang Yangf7ae9ba2014-06-30 16:10:37 +08002698static int find_ext_mic_pin(struct hda_codec *codec);
2699
2700static void alc286_shutup(struct hda_codec *codec)
2701{
2702 int i;
2703 int mic_pin = find_ext_mic_pin(codec);
2704 /* don't shut up pins when unloading the driver; otherwise it breaks
2705 * the default pin setup at the next load of the driver
2706 */
2707 if (codec->bus->shutdown)
2708 return;
2709 for (i = 0; i < codec->init_pins.used; i++) {
2710 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
2711 /* use read here for syncing after issuing each verb */
2712 if (pin->nid != mic_pin)
2713 snd_hda_codec_read(codec, pin->nid, 0,
2714 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2715 }
2716 codec->pins_shutup = 1;
2717}
2718
Kailang Yang1387e2d2012-11-08 10:23:18 +01002719static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
Takashi Iwai1d045db2011-07-07 18:23:21 +02002720{
Takashi Iwai98b24882014-08-18 13:47:50 +02002721 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002722}
2723
2724static void alc269_shutup(struct hda_codec *codec)
2725{
Kailang Yangadcc70b2012-05-25 08:08:38 +02002726 struct alc_spec *spec = codec->spec;
2727
Kailang Yang1387e2d2012-11-08 10:23:18 +01002728 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2729 alc269vb_toggle_power_output(codec, 0);
2730 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2731 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02002732 msleep(150);
2733 }
Takashi Iwai9bfb2842013-07-24 14:31:50 +02002734 snd_hda_shutup_pins(codec);
Takashi Iwai1d045db2011-07-07 18:23:21 +02002735}
2736
Takashi Iwai54db6c32014-08-18 15:11:19 +02002737static struct coef_fw alc282_coefs[] = {
2738 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
Kailang Yang32fa7e42014-10-24 16:26:01 +08002739 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
Takashi Iwai54db6c32014-08-18 15:11:19 +02002740 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2741 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2742 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2743 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2744 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2745 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2746 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2747 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2748 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2749 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2750 WRITE_COEF(0x34, 0xa0c0), /* ANC */
2751 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2752 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2753 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2754 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2755 WRITE_COEF(0x63, 0x2902), /* PLL */
2756 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2757 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2758 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2759 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2760 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2761 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2762 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2763 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2764 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2765 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2766 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2767 {}
2768};
2769
Kailang Yangcb149cb2014-03-18 16:45:32 +08002770static void alc282_restore_default_value(struct hda_codec *codec)
2771{
Takashi Iwai54db6c32014-08-18 15:11:19 +02002772 alc_process_coef_fw(codec, alc282_coefs);
Kailang Yangcb149cb2014-03-18 16:45:32 +08002773}
2774
Kailang Yang7b5c7a02014-03-18 16:15:54 +08002775static void alc282_init(struct hda_codec *codec)
2776{
2777 struct alc_spec *spec = codec->spec;
2778 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2779 bool hp_pin_sense;
2780 int coef78;
2781
Kailang Yangcb149cb2014-03-18 16:45:32 +08002782 alc282_restore_default_value(codec);
2783
Kailang Yang7b5c7a02014-03-18 16:15:54 +08002784 if (!hp_pin)
2785 return;
2786 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2787 coef78 = alc_read_coef_idx(codec, 0x78);
2788
2789 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2790 /* Headphone capless set to high power mode */
2791 alc_write_coef_idx(codec, 0x78, 0x9004);
2792
2793 if (hp_pin_sense)
2794 msleep(2);
2795
2796 snd_hda_codec_write(codec, hp_pin, 0,
2797 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2798
2799 if (hp_pin_sense)
2800 msleep(85);
2801
2802 snd_hda_codec_write(codec, hp_pin, 0,
2803 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2804
2805 if (hp_pin_sense)
2806 msleep(100);
2807
2808 /* Headphone capless set to normal mode */
2809 alc_write_coef_idx(codec, 0x78, coef78);
2810}
2811
2812static void alc282_shutup(struct hda_codec *codec)
2813{
2814 struct alc_spec *spec = codec->spec;
2815 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2816 bool hp_pin_sense;
2817 int coef78;
2818
2819 if (!hp_pin) {
2820 alc269_shutup(codec);
2821 return;
2822 }
2823
2824 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2825 coef78 = alc_read_coef_idx(codec, 0x78);
2826 alc_write_coef_idx(codec, 0x78, 0x9004);
2827
2828 if (hp_pin_sense)
2829 msleep(2);
2830
2831 snd_hda_codec_write(codec, hp_pin, 0,
2832 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2833
2834 if (hp_pin_sense)
2835 msleep(85);
2836
2837 snd_hda_codec_write(codec, hp_pin, 0,
2838 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2839
2840 if (hp_pin_sense)
2841 msleep(100);
2842
2843 alc_auto_setup_eapd(codec, false);
2844 snd_hda_shutup_pins(codec);
2845 alc_write_coef_idx(codec, 0x78, coef78);
2846}
2847
Takashi Iwai54db6c32014-08-18 15:11:19 +02002848static struct coef_fw alc283_coefs[] = {
2849 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
Kailang Yang56779862014-10-24 16:17:51 +08002850 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
Takashi Iwai54db6c32014-08-18 15:11:19 +02002851 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2852 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2853 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2854 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2855 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2856 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
2857 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2858 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2859 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
2860 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
2861 WRITE_COEF(0x22, 0xa0c0), /* ANC */
2862 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
2863 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2864 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2865 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2866 WRITE_COEF(0x2e, 0x2902), /* PLL */
2867 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
2868 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
2869 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
2870 WRITE_COEF(0x36, 0x0), /* capless control 5 */
2871 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
2872 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
2873 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
2874 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
2875 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
2876 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
2877 WRITE_COEF(0x49, 0x0), /* test mode */
2878 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
2879 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
2880 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
Kailang Yang56779862014-10-24 16:17:51 +08002881 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
Takashi Iwai54db6c32014-08-18 15:11:19 +02002882 {}
2883};
2884
Kailang Yang6bd55b02014-03-17 13:51:27 +08002885static void alc283_restore_default_value(struct hda_codec *codec)
2886{
Takashi Iwai54db6c32014-08-18 15:11:19 +02002887 alc_process_coef_fw(codec, alc283_coefs);
Kailang Yang6bd55b02014-03-17 13:51:27 +08002888}
2889
Kailang Yang2af02be2013-08-22 10:03:50 +02002890static void alc283_init(struct hda_codec *codec)
2891{
2892 struct alc_spec *spec = codec->spec;
2893 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2894 bool hp_pin_sense;
Kailang Yang2af02be2013-08-22 10:03:50 +02002895
Kailang Yang8314f222014-04-03 17:28:39 +08002896 if (!spec->gen.autocfg.hp_outs) {
2897 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
2898 hp_pin = spec->gen.autocfg.line_out_pins[0];
2899 }
2900
Kailang Yang6bd55b02014-03-17 13:51:27 +08002901 alc283_restore_default_value(codec);
2902
Kailang Yang2af02be2013-08-22 10:03:50 +02002903 if (!hp_pin)
2904 return;
2905 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2906
2907 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
2908 /* Headphone capless set to high power mode */
2909 alc_write_coef_idx(codec, 0x43, 0x9004);
2910
2911 snd_hda_codec_write(codec, hp_pin, 0,
2912 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2913
2914 if (hp_pin_sense)
2915 msleep(85);
2916
2917 snd_hda_codec_write(codec, hp_pin, 0,
2918 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2919
2920 if (hp_pin_sense)
2921 msleep(85);
2922 /* Index 0x46 Combo jack auto switch control 2 */
2923 /* 3k pull low control for Headset jack. */
Takashi Iwai98b24882014-08-18 13:47:50 +02002924 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
Kailang Yang2af02be2013-08-22 10:03:50 +02002925 /* Headphone capless set to normal mode */
2926 alc_write_coef_idx(codec, 0x43, 0x9614);
2927}
2928
2929static void alc283_shutup(struct hda_codec *codec)
2930{
2931 struct alc_spec *spec = codec->spec;
2932 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2933 bool hp_pin_sense;
Kailang Yang2af02be2013-08-22 10:03:50 +02002934
Kailang Yang8314f222014-04-03 17:28:39 +08002935 if (!spec->gen.autocfg.hp_outs) {
2936 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
2937 hp_pin = spec->gen.autocfg.line_out_pins[0];
2938 }
2939
Kailang Yang2af02be2013-08-22 10:03:50 +02002940 if (!hp_pin) {
2941 alc269_shutup(codec);
2942 return;
2943 }
2944
2945 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2946
2947 alc_write_coef_idx(codec, 0x43, 0x9004);
2948
Harsha Priyab450b172014-10-09 11:04:56 +00002949 /*depop hp during suspend*/
2950 alc_write_coef_idx(codec, 0x06, 0x2100);
2951
Kailang Yang2af02be2013-08-22 10:03:50 +02002952 snd_hda_codec_write(codec, hp_pin, 0,
2953 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2954
2955 if (hp_pin_sense)
Kailang Yang88011c092013-10-24 15:45:24 +02002956 msleep(100);
Kailang Yang2af02be2013-08-22 10:03:50 +02002957
2958 snd_hda_codec_write(codec, hp_pin, 0,
2959 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2960
Takashi Iwai98b24882014-08-18 13:47:50 +02002961 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
Kailang Yang2af02be2013-08-22 10:03:50 +02002962
2963 if (hp_pin_sense)
Kailang Yang88011c092013-10-24 15:45:24 +02002964 msleep(100);
Kailang Yang0435b3f2014-04-08 17:14:14 +08002965 alc_auto_setup_eapd(codec, false);
Kailang Yang2af02be2013-08-22 10:03:50 +02002966 snd_hda_shutup_pins(codec);
2967 alc_write_coef_idx(codec, 0x43, 0x9614);
2968}
2969
Kailang Yangad60d502013-06-28 12:03:01 +02002970static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
2971 unsigned int val)
2972{
2973 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
2974 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
2975 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
2976}
2977
2978static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
2979{
2980 unsigned int val;
2981
2982 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
2983 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
2984 & 0xffff;
2985 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
2986 << 16;
2987 return val;
2988}
2989
2990static void alc5505_dsp_halt(struct hda_codec *codec)
2991{
2992 unsigned int val;
2993
2994 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
2995 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
2996 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
2997 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
2998 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
2999 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3000 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3001 val = alc5505_coef_get(codec, 0x6220);
3002 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3003}
3004
3005static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3006{
3007 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3008 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3009 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3010 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3011 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3012 alc5505_coef_set(codec, 0x880c, 0x00000004);
3013}
3014
3015static void alc5505_dsp_init(struct hda_codec *codec)
3016{
3017 unsigned int val;
3018
3019 alc5505_dsp_halt(codec);
3020 alc5505_dsp_back_from_halt(codec);
3021 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3022 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3023 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3024 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3025 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3026 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3027 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3028 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3029 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3030 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3031 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3032 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3033 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3034
3035 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3036 if (val <= 3)
3037 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3038 else
3039 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3040
3041 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3042 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3043 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3044 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3045 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3046 alc5505_coef_set(codec, 0x880c, 0x00000003);
3047 alc5505_coef_set(codec, 0x880c, 0x00000010);
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003048
3049#ifdef HALT_REALTEK_ALC5505
3050 alc5505_dsp_halt(codec);
3051#endif
Kailang Yangad60d502013-06-28 12:03:01 +02003052}
3053
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003054#ifdef HALT_REALTEK_ALC5505
3055#define alc5505_dsp_suspend(codec) /* NOP */
3056#define alc5505_dsp_resume(codec) /* NOP */
3057#else
3058#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3059#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3060#endif
3061
Takashi Iwai2a439522011-07-26 09:52:50 +02003062#ifdef CONFIG_PM
Kailang Yangad60d502013-06-28 12:03:01 +02003063static int alc269_suspend(struct hda_codec *codec)
3064{
3065 struct alc_spec *spec = codec->spec;
3066
3067 if (spec->has_alc5505_dsp)
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003068 alc5505_dsp_suspend(codec);
Kailang Yangad60d502013-06-28 12:03:01 +02003069 return alc_suspend(codec);
3070}
3071
Takashi Iwai1d045db2011-07-07 18:23:21 +02003072static int alc269_resume(struct hda_codec *codec)
3073{
Kailang Yangadcc70b2012-05-25 08:08:38 +02003074 struct alc_spec *spec = codec->spec;
3075
Kailang Yang1387e2d2012-11-08 10:23:18 +01003076 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3077 alc269vb_toggle_power_output(codec, 0);
3078 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02003079 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003080 msleep(150);
3081 }
3082
3083 codec->patch_ops.init(codec);
3084
Kailang Yang1387e2d2012-11-08 10:23:18 +01003085 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3086 alc269vb_toggle_power_output(codec, 1);
3087 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
Kailang Yangadcc70b2012-05-25 08:08:38 +02003088 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02003089 msleep(200);
3090 }
3091
Takashi Iwai1d045db2011-07-07 18:23:21 +02003092 snd_hda_codec_resume_amp(codec);
3093 snd_hda_codec_resume_cache(codec);
3094 hda_call_check_power_status(codec, 0x01);
Hui Wangf4753712014-08-19 12:07:03 +08003095
3096 /* on some machine, the BIOS will clear the codec gpio data when enter
3097 * suspend, and won't restore the data after resume, so we restore it
3098 * in the driver.
3099 */
3100 if (spec->gpio_led)
3101 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA,
3102 spec->gpio_led);
3103
Kailang Yangad60d502013-06-28 12:03:01 +02003104 if (spec->has_alc5505_dsp)
Takashi Iwaicd63a5f2013-07-05 12:13:59 +02003105 alc5505_dsp_resume(codec);
Kailang Yangc5177c82013-07-24 14:39:49 +02003106
Takashi Iwai1d045db2011-07-07 18:23:21 +02003107 return 0;
3108}
Takashi Iwai2a439522011-07-26 09:52:50 +02003109#endif /* CONFIG_PM */
Takashi Iwai1d045db2011-07-07 18:23:21 +02003110
David Henningsson108cc102012-07-20 10:37:25 +02003111static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003112 const struct hda_fixup *fix, int action)
David Henningsson108cc102012-07-20 10:37:25 +02003113{
3114 struct alc_spec *spec = codec->spec;
3115
Takashi Iwai1727a772013-01-10 09:52:52 +01003116 if (action == HDA_FIXUP_ACT_PRE_PROBE)
David Henningsson108cc102012-07-20 10:37:25 +02003117 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3118}
3119
Takashi Iwai1d045db2011-07-07 18:23:21 +02003120static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003121 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003122{
Takashi Iwai98b24882014-08-18 13:47:50 +02003123 if (action == HDA_FIXUP_ACT_INIT)
3124 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
Takashi Iwai1d045db2011-07-07 18:23:21 +02003125}
3126
David Henningsson7c478f02013-10-11 10:18:46 +02003127static void alc269_fixup_headset_mic(struct hda_codec *codec,
3128 const struct hda_fixup *fix, int action)
3129{
3130 struct alc_spec *spec = codec->spec;
3131
3132 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3133 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3134}
3135
Takashi Iwai1d045db2011-07-07 18:23:21 +02003136static void alc271_fixup_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003137 const struct hda_fixup *fix, int action)
Takashi Iwai1d045db2011-07-07 18:23:21 +02003138{
3139 static const struct hda_verb verbs[] = {
3140 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3141 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3142 {}
3143 };
3144 unsigned int cfg;
3145
Dylan Reid42397002013-04-05 14:58:22 -07003146 if (strcmp(codec->chip_name, "ALC271X") &&
3147 strcmp(codec->chip_name, "ALC269VB"))
Takashi Iwai1d045db2011-07-07 18:23:21 +02003148 return;
3149 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3150 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3151 snd_hda_sequence_write(codec, verbs);
3152}
3153
Takashi Iwai017f2a12011-07-09 14:42:25 +02003154static void alc269_fixup_pcm_44k(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003155 const struct hda_fixup *fix, int action)
Takashi Iwai017f2a12011-07-09 14:42:25 +02003156{
3157 struct alc_spec *spec = codec->spec;
3158
Takashi Iwai1727a772013-01-10 09:52:52 +01003159 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai017f2a12011-07-09 14:42:25 +02003160 return;
3161
3162 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3163 * fix the sample rate of analog I/O to 44.1kHz
3164 */
Takashi Iwai08c189f2012-12-19 15:22:24 +01003165 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3166 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai017f2a12011-07-09 14:42:25 +02003167}
3168
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003169static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003170 const struct hda_fixup *fix, int action)
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003171{
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003172 /* The digital-mic unit sends PDM (differential signal) instead of
3173 * the standard PCM, thus you can't record a valid mono stream as is.
3174 * Below is a workaround specific to ALC269 to control the dmic
3175 * signal source as mono.
3176 */
Takashi Iwai98b24882014-08-18 13:47:50 +02003177 if (action == HDA_FIXUP_ACT_INIT)
3178 alc_update_coef_idx(codec, 0x07, 0, 0x80);
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02003179}
3180
Takashi Iwai24519912011-08-16 15:08:49 +02003181static void alc269_quanta_automute(struct hda_codec *codec)
3182{
Takashi Iwai08c189f2012-12-19 15:22:24 +01003183 snd_hda_gen_update_outputs(codec);
Takashi Iwai24519912011-08-16 15:08:49 +02003184
Takashi Iwai1687ccc2014-08-18 13:49:35 +02003185 alc_write_coef_idx(codec, 0x0c, 0x680);
3186 alc_write_coef_idx(codec, 0x0c, 0x480);
Takashi Iwai24519912011-08-16 15:08:49 +02003187}
3188
3189static void alc269_fixup_quanta_mute(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01003190 const struct hda_fixup *fix, int action)
Takashi Iwai24519912011-08-16 15:08:49 +02003191{
3192 struct alc_spec *spec = codec->spec;
Takashi Iwai1727a772013-01-10 09:52:52 +01003193 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai24519912011-08-16 15:08:49 +02003194 return;
Takashi Iwai08c189f2012-12-19 15:22:24 +01003195 spec->gen.automute_hook = alc269_quanta_automute;
Takashi Iwai24519912011-08-16 15:08:49 +02003196}
3197
David Henningssond240d1d2013-04-15 12:50:02 +02003198static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
Takashi Iwai1a4f69d2014-09-11 15:22:46 +02003199 struct hda_jack_callback *jack)
David Henningssond240d1d2013-04-15 12:50:02 +02003200{
3201 struct alc_spec *spec = codec->spec;
3202 int vref;
3203 msleep(200);
3204 snd_hda_gen_hp_automute(codec, jack);
3205
3206 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3207 msleep(100);
3208 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3209 vref);
3210 msleep(500);
3211 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3212 vref);
3213}
3214
3215static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3216 const struct hda_fixup *fix, int action)
3217{
3218 struct alc_spec *spec = codec->spec;
3219 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3220 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3221 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3222 }
3223}
3224
3225
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003226/* update mute-LED according to the speaker mute state via mic VREF pin */
3227static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003228{
3229 struct hda_codec *codec = private_data;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003230 struct alc_spec *spec = codec->spec;
3231 unsigned int pinval;
3232
3233 if (spec->mute_led_polarity)
3234 enabled = !enabled;
Takashi Iwai415d5552014-04-03 11:51:21 +02003235 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3236 pinval &= ~AC_PINCTL_VREFEN;
3237 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003238 if (spec->mute_led_nid)
3239 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003240}
3241
David Henningssond5b6b652013-11-06 10:50:44 +01003242/* Make sure the led works even in runtime suspend */
3243static unsigned int led_power_filter(struct hda_codec *codec,
3244 hda_nid_t nid,
3245 unsigned int power_state)
3246{
3247 struct alc_spec *spec = codec->spec;
3248
Hui Wang50dd9052014-07-08 17:56:15 +08003249 if (power_state != AC_PWRST_D3 || nid == 0 ||
3250 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
David Henningssond5b6b652013-11-06 10:50:44 +01003251 return power_state;
3252
3253 /* Set pin ctl again, it might have just been set to 0 */
3254 snd_hda_set_pin_ctl(codec, nid,
3255 snd_hda_codec_get_pin_target(codec, nid));
3256
3257 return AC_PWRST_D0;
3258}
3259
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003260static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3261 const struct hda_fixup *fix, int action)
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003262{
3263 struct alc_spec *spec = codec->spec;
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003264 const struct dmi_device *dev = NULL;
3265
3266 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3267 return;
3268
3269 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3270 int pol, pin;
3271 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3272 continue;
3273 if (pin < 0x0a || pin >= 0x10)
3274 break;
3275 spec->mute_led_polarity = pol;
3276 spec->mute_led_nid = pin - 0x0a + 0x18;
3277 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01003278 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003279 codec->power_filter = led_power_filter;
Takashi Iwai4e76a882014-02-25 12:21:03 +01003280 codec_dbg(codec,
3281 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003282 spec->mute_led_polarity);
David Henningsson6d3cd5d2013-01-07 12:03:47 +01003283 break;
3284 }
3285}
3286
David Henningssond06ac142013-02-18 11:41:55 +01003287static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3288 const struct hda_fixup *fix, int action)
3289{
3290 struct alc_spec *spec = codec->spec;
3291 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3292 spec->mute_led_polarity = 0;
3293 spec->mute_led_nid = 0x18;
3294 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3295 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003296 codec->power_filter = led_power_filter;
David Henningssond06ac142013-02-18 11:41:55 +01003297 }
3298}
3299
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003300static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3301 const struct hda_fixup *fix, int action)
Takashi Iwai420b0fe2012-03-12 12:35:27 +01003302{
3303 struct alc_spec *spec = codec->spec;
Takashi Iwai9bb1f062013-01-10 17:14:29 +01003304 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwai08fb0d02013-01-10 17:33:58 +01003305 spec->mute_led_polarity = 0;
3306 spec->mute_led_nid = 0x19;
3307 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
Takashi Iwaifd25a972012-12-20 14:57:18 +01003308 spec->gen.vmaster_mute_enum = 1;
David Henningssond5b6b652013-11-06 10:50:44 +01003309 codec->power_filter = led_power_filter;
Takashi Iwai420b0fe2012-03-12 12:35:27 +01003310 }
3311}
3312
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003313/* turn on/off mute LED per vmaster hook */
3314static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
3315{
3316 struct hda_codec *codec = private_data;
3317 struct alc_spec *spec = codec->spec;
3318 unsigned int oldval = spec->gpio_led;
3319
3320 if (enabled)
3321 spec->gpio_led &= ~0x08;
3322 else
3323 spec->gpio_led |= 0x08;
3324 if (spec->gpio_led != oldval)
3325 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3326 spec->gpio_led);
3327}
3328
3329/* turn on/off mic-mute LED per capture hook */
3330static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +01003331 struct snd_kcontrol *kcontrol,
3332 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01003333{
3334 struct alc_spec *spec = codec->spec;
3335 unsigned int oldval = spec->gpio_led;
3336
3337 if (!ucontrol)
3338 return;
3339
3340 if (ucontrol->value.integer.value[0] ||
3341 ucontrol->value.integer.value[1])
3342 spec->gpio_led &= ~0x10;
3343 else
3344 spec->gpio_led |= 0x10;
3345 if (spec->gpio_led != oldval)
3346 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3347 spec->gpio_led);
3348}
3349
3350static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3351 const struct hda_fixup *fix, int action)
3352{
3353 struct alc_spec *spec = codec->spec;
3354 static const struct hda_verb gpio_init[] = {
3355 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3356 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3357 {}
3358 };
3359
3360 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3361 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3362 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
3363 spec->gpio_led = 0;
3364 snd_hda_add_verbs(codec, gpio_init);
3365 }
3366}
3367
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003368/* turn on/off mic-mute LED per capture hook */
3369static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3370 struct snd_kcontrol *kcontrol,
3371 struct snd_ctl_elem_value *ucontrol)
3372{
3373 struct alc_spec *spec = codec->spec;
3374 unsigned int pinval, enable, disable;
3375
Hui Wangfc1fad92014-07-08 17:56:14 +08003376 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003377 pinval &= ~AC_PINCTL_VREFEN;
3378 enable = pinval | AC_PINCTL_VREF_80;
3379 disable = pinval | AC_PINCTL_VREF_HIZ;
3380
3381 if (!ucontrol)
3382 return;
3383
3384 if (ucontrol->value.integer.value[0] ||
3385 ucontrol->value.integer.value[1])
3386 pinval = disable;
3387 else
3388 pinval = enable;
3389
3390 if (spec->cap_mute_led_nid)
3391 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3392}
3393
3394static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3395 const struct hda_fixup *fix, int action)
3396{
3397 struct alc_spec *spec = codec->spec;
3398 static const struct hda_verb gpio_init[] = {
3399 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3400 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3401 {}
3402 };
3403
3404 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3405 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3406 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3407 spec->gpio_led = 0;
3408 spec->cap_mute_led_nid = 0x18;
3409 snd_hda_add_verbs(codec, gpio_init);
Hui Wang50dd9052014-07-08 17:56:15 +08003410 codec->power_filter = led_power_filter;
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003411 }
3412}
3413
David Henningsson7a5255f2014-10-30 08:26:01 +01003414static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3415 const struct hda_fixup *fix, int action)
3416{
3417 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to enable headphone amp */
3418 struct alc_spec *spec = codec->spec;
3419 static const struct hda_verb gpio_init[] = {
3420 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3421 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3422 {}
3423 };
3424
3425 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3426 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3427 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3428 spec->gpio_led = 0;
3429 spec->cap_mute_led_nid = 0x18;
3430 snd_hda_add_verbs(codec, gpio_init);
3431 codec->power_filter = led_power_filter;
3432 }
3433}
3434
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08003435static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3436 const struct hda_fixup *fix, int action)
3437{
3438 struct alc_spec *spec = codec->spec;
3439
3440 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3441 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3442 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3443 spec->mute_led_polarity = 0;
3444 spec->mute_led_nid = 0x1a;
3445 spec->cap_mute_led_nid = 0x18;
3446 spec->gen.vmaster_mute_enum = 1;
3447 codec->power_filter = led_power_filter;
3448 }
3449}
3450
David Henningsson73bdd592013-04-15 15:44:14 +02003451static void alc_headset_mode_unplugged(struct hda_codec *codec)
3452{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003453 static struct coef_fw coef0255[] = {
3454 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
3455 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
3456 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
3457 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
3458 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
3459 {}
3460 };
3461 static struct coef_fw coef0233[] = {
3462 WRITE_COEF(0x1b, 0x0c0b),
3463 WRITE_COEF(0x45, 0xc429),
3464 UPDATE_COEF(0x35, 0x4000, 0),
3465 WRITE_COEF(0x06, 0x2104),
3466 WRITE_COEF(0x1a, 0x0001),
3467 WRITE_COEF(0x26, 0x0004),
3468 WRITE_COEF(0x32, 0x42a3),
3469 {}
3470 };
3471 static struct coef_fw coef0292[] = {
3472 WRITE_COEF(0x76, 0x000e),
3473 WRITE_COEF(0x6c, 0x2400),
3474 WRITE_COEF(0x18, 0x7308),
3475 WRITE_COEF(0x6b, 0xc429),
3476 {}
3477 };
3478 static struct coef_fw coef0293[] = {
3479 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
3480 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
3481 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
3482 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
3483 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
3484 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
3485 {}
3486 };
3487 static struct coef_fw coef0668[] = {
3488 WRITE_COEF(0x15, 0x0d40),
3489 WRITE_COEF(0xb7, 0x802b),
3490 {}
3491 };
3492
David Henningsson73bdd592013-04-15 15:44:14 +02003493 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003494 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003495 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003496 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003497 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003498 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003499 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003500 break;
3501 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003502 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003503 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003504 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003505 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003506 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003507 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003508 alc_process_coef_fw(codec, coef0668);
David Henningsson73bdd592013-04-15 15:44:14 +02003509 break;
3510 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003511 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003512}
3513
3514
3515static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3516 hda_nid_t mic_pin)
3517{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003518 static struct coef_fw coef0255[] = {
3519 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
3520 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
3521 {}
3522 };
3523 static struct coef_fw coef0233[] = {
3524 UPDATE_COEF(0x35, 0, 1<<14),
3525 WRITE_COEF(0x06, 0x2100),
3526 WRITE_COEF(0x1a, 0x0021),
3527 WRITE_COEF(0x26, 0x008c),
3528 {}
3529 };
3530 static struct coef_fw coef0292[] = {
3531 WRITE_COEF(0x19, 0xa208),
3532 WRITE_COEF(0x2e, 0xacf0),
3533 {}
3534 };
3535 static struct coef_fw coef0293[] = {
3536 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
3537 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
3538 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
3539 {}
3540 };
3541 static struct coef_fw coef0688[] = {
3542 WRITE_COEF(0xb7, 0x802b),
3543 WRITE_COEF(0xb5, 0x1040),
3544 UPDATE_COEF(0xc3, 0, 1<<12),
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:
3550 alc_write_coef_idx(codec, 0x45, 0xc489);
3551 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003552 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003553 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3554 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003555 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003556 case 0x10ec0283:
3557 alc_write_coef_idx(codec, 0x45, 0xc429);
3558 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003559 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003560 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3561 break;
3562 case 0x10ec0292:
3563 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003564 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003565 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003566 case 0x10ec0293:
3567 /* Set to TRS mode */
3568 alc_write_coef_idx(codec, 0x45, 0xc429);
3569 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003570 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003571 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3572 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003573 case 0x10ec0668:
3574 alc_write_coef_idx(codec, 0x11, 0x0001);
3575 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
Takashi Iwai54db6c32014-08-18 15:11:19 +02003576 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003577 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3578 break;
3579 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003580 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003581}
3582
3583static void alc_headset_mode_default(struct hda_codec *codec)
3584{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003585 static struct coef_fw coef0255[] = {
3586 WRITE_COEF(0x45, 0xc089),
3587 WRITE_COEF(0x45, 0xc489),
3588 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
3589 WRITE_COEF(0x49, 0x0049),
3590 {}
3591 };
3592 static struct coef_fw coef0233[] = {
3593 WRITE_COEF(0x06, 0x2100),
3594 WRITE_COEF(0x32, 0x4ea3),
3595 {}
3596 };
3597 static struct coef_fw coef0292[] = {
3598 WRITE_COEF(0x76, 0x000e),
3599 WRITE_COEF(0x6c, 0x2400),
3600 WRITE_COEF(0x6b, 0xc429),
3601 WRITE_COEF(0x18, 0x7308),
3602 {}
3603 };
3604 static struct coef_fw coef0293[] = {
3605 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
3606 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
3607 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
3608 {}
3609 };
3610 static struct coef_fw coef0688[] = {
3611 WRITE_COEF(0x11, 0x0041),
3612 WRITE_COEF(0x15, 0x0d40),
3613 WRITE_COEF(0xb7, 0x802b),
3614 {}
3615 };
3616
David Henningsson73bdd592013-04-15 15:44:14 +02003617 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003618 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003619 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003620 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003621 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003622 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003623 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003624 break;
3625 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003626 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003627 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003628 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003629 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003630 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003631 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003632 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003633 break;
3634 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003635 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003636}
3637
3638/* Iphone type */
3639static void alc_headset_mode_ctia(struct hda_codec *codec)
3640{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003641 static struct coef_fw coef0255[] = {
3642 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
3643 WRITE_COEF(0x1b, 0x0c2b),
3644 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
3645 {}
3646 };
3647 static struct coef_fw coef0233[] = {
3648 WRITE_COEF(0x45, 0xd429),
3649 WRITE_COEF(0x1b, 0x0c2b),
3650 WRITE_COEF(0x32, 0x4ea3),
3651 {}
3652 };
3653 static struct coef_fw coef0292[] = {
3654 WRITE_COEF(0x6b, 0xd429),
3655 WRITE_COEF(0x76, 0x0008),
3656 WRITE_COEF(0x18, 0x7388),
3657 {}
3658 };
3659 static struct coef_fw coef0293[] = {
3660 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
3661 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
3662 {}
3663 };
3664 static struct coef_fw coef0688[] = {
3665 WRITE_COEF(0x11, 0x0001),
3666 WRITE_COEF(0x15, 0x0d60),
3667 WRITE_COEF(0xc3, 0x0000),
3668 {}
3669 };
3670
David Henningsson73bdd592013-04-15 15:44:14 +02003671 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003672 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003673 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003674 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003675 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003676 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003677 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003678 break;
3679 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003680 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003681 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003682 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003683 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003684 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003685 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003686 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003687 break;
3688 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003689 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003690}
3691
3692/* Nokia type */
3693static void alc_headset_mode_omtp(struct hda_codec *codec)
3694{
Takashi Iwai54db6c32014-08-18 15:11:19 +02003695 static struct coef_fw coef0255[] = {
3696 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
3697 WRITE_COEF(0x1b, 0x0c2b),
3698 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
3699 {}
3700 };
3701 static struct coef_fw coef0233[] = {
3702 WRITE_COEF(0x45, 0xe429),
3703 WRITE_COEF(0x1b, 0x0c2b),
3704 WRITE_COEF(0x32, 0x4ea3),
3705 {}
3706 };
3707 static struct coef_fw coef0292[] = {
3708 WRITE_COEF(0x6b, 0xe429),
3709 WRITE_COEF(0x76, 0x0008),
3710 WRITE_COEF(0x18, 0x7388),
3711 {}
3712 };
3713 static struct coef_fw coef0293[] = {
3714 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
3715 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
3716 {}
3717 };
3718 static struct coef_fw coef0688[] = {
3719 WRITE_COEF(0x11, 0x0001),
3720 WRITE_COEF(0x15, 0x0d50),
3721 WRITE_COEF(0xc3, 0x0000),
3722 {}
3723 };
3724
David Henningsson73bdd592013-04-15 15:44:14 +02003725 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003726 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003727 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003728 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003729 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003730 case 0x10ec0283:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003731 alc_process_coef_fw(codec, coef0233);
David Henningsson73bdd592013-04-15 15:44:14 +02003732 break;
3733 case 0x10ec0292:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003734 alc_process_coef_fw(codec, coef0292);
David Henningsson73bdd592013-04-15 15:44:14 +02003735 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003736 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003737 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003738 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003739 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003740 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003741 break;
3742 }
Takashi Iwai4e76a882014-02-25 12:21:03 +01003743 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
David Henningsson73bdd592013-04-15 15:44:14 +02003744}
3745
3746static void alc_determine_headset_type(struct hda_codec *codec)
3747{
3748 int val;
3749 bool is_ctia = false;
3750 struct alc_spec *spec = codec->spec;
Takashi Iwai54db6c32014-08-18 15:11:19 +02003751 static struct coef_fw coef0255[] = {
3752 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
3753 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
3754 conteol) */
3755 {}
3756 };
3757 static struct coef_fw coef0293[] = {
3758 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
3759 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
3760 {}
3761 };
3762 static struct coef_fw coef0688[] = {
3763 WRITE_COEF(0x11, 0x0001),
3764 WRITE_COEF(0xb7, 0x802b),
3765 WRITE_COEF(0x15, 0x0d60),
3766 WRITE_COEF(0xc3, 0x0c00),
3767 {}
3768 };
David Henningsson73bdd592013-04-15 15:44:14 +02003769
3770 switch (codec->vendor_id) {
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003771 case 0x10ec0255:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003772 alc_process_coef_fw(codec, coef0255);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003773 msleep(300);
3774 val = alc_read_coef_idx(codec, 0x46);
3775 is_ctia = (val & 0x0070) == 0x0070;
3776 break;
Kailang Yang13fd08a2014-05-21 16:49:48 +08003777 case 0x10ec0233:
David Henningsson73bdd592013-04-15 15:44:14 +02003778 case 0x10ec0283:
3779 alc_write_coef_idx(codec, 0x45, 0xd029);
3780 msleep(300);
3781 val = alc_read_coef_idx(codec, 0x46);
3782 is_ctia = (val & 0x0070) == 0x0070;
3783 break;
3784 case 0x10ec0292:
3785 alc_write_coef_idx(codec, 0x6b, 0xd429);
3786 msleep(300);
3787 val = alc_read_coef_idx(codec, 0x6c);
3788 is_ctia = (val & 0x001c) == 0x001c;
3789 break;
Kailang Yanga22aa262014-04-23 17:34:28 +08003790 case 0x10ec0293:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003791 alc_process_coef_fw(codec, coef0293);
Kailang Yanga22aa262014-04-23 17:34:28 +08003792 msleep(300);
3793 val = alc_read_coef_idx(codec, 0x46);
3794 is_ctia = (val & 0x0070) == 0x0070;
3795 break;
David Henningsson73bdd592013-04-15 15:44:14 +02003796 case 0x10ec0668:
Takashi Iwai54db6c32014-08-18 15:11:19 +02003797 alc_process_coef_fw(codec, coef0688);
David Henningsson73bdd592013-04-15 15:44:14 +02003798 msleep(300);
3799 val = alc_read_coef_idx(codec, 0xbe);
3800 is_ctia = (val & 0x1c02) == 0x1c02;
3801 break;
3802 }
3803
Takashi Iwai4e76a882014-02-25 12:21:03 +01003804 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
David Henningsson73bdd592013-04-15 15:44:14 +02003805 is_ctia ? "yes" : "no");
3806 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3807}
3808
3809static void alc_update_headset_mode(struct hda_codec *codec)
3810{
3811 struct alc_spec *spec = codec->spec;
3812
3813 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
3814 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3815
3816 int new_headset_mode;
3817
3818 if (!snd_hda_jack_detect(codec, hp_pin))
3819 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
3820 else if (mux_pin == spec->headset_mic_pin)
3821 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
3822 else if (mux_pin == spec->headphone_mic_pin)
3823 new_headset_mode = ALC_HEADSET_MODE_MIC;
3824 else
3825 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
3826
David Henningsson5959a6b2013-11-12 11:10:57 +01003827 if (new_headset_mode == spec->current_headset_mode) {
3828 snd_hda_gen_update_outputs(codec);
David Henningsson73bdd592013-04-15 15:44:14 +02003829 return;
David Henningsson5959a6b2013-11-12 11:10:57 +01003830 }
David Henningsson73bdd592013-04-15 15:44:14 +02003831
3832 switch (new_headset_mode) {
3833 case ALC_HEADSET_MODE_UNPLUGGED:
3834 alc_headset_mode_unplugged(codec);
3835 spec->gen.hp_jack_present = false;
3836 break;
3837 case ALC_HEADSET_MODE_HEADSET:
3838 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
3839 alc_determine_headset_type(codec);
3840 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
3841 alc_headset_mode_ctia(codec);
3842 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
3843 alc_headset_mode_omtp(codec);
3844 spec->gen.hp_jack_present = true;
3845 break;
3846 case ALC_HEADSET_MODE_MIC:
3847 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
3848 spec->gen.hp_jack_present = false;
3849 break;
3850 case ALC_HEADSET_MODE_HEADPHONE:
3851 alc_headset_mode_default(codec);
3852 spec->gen.hp_jack_present = true;
3853 break;
3854 }
3855 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
3856 snd_hda_set_pin_ctl_cache(codec, hp_pin,
3857 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3858 if (spec->headphone_mic_pin)
3859 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
3860 PIN_VREFHIZ);
3861 }
3862 spec->current_headset_mode = new_headset_mode;
3863
3864 snd_hda_gen_update_outputs(codec);
3865}
3866
3867static void alc_update_headset_mode_hook(struct hda_codec *codec,
Takashi Iwai7fe30712014-01-30 17:59:02 +01003868 struct snd_kcontrol *kcontrol,
3869 struct snd_ctl_elem_value *ucontrol)
David Henningsson73bdd592013-04-15 15:44:14 +02003870{
3871 alc_update_headset_mode(codec);
3872}
3873
Takashi Iwai1a4f69d2014-09-11 15:22:46 +02003874static void alc_update_headset_jack_cb(struct hda_codec *codec,
3875 struct hda_jack_callback *jack)
David Henningsson73bdd592013-04-15 15:44:14 +02003876{
3877 struct alc_spec *spec = codec->spec;
David Henningsson5db4d342013-11-22 12:17:06 +01003878 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
David Henningsson73bdd592013-04-15 15:44:14 +02003879 snd_hda_gen_hp_automute(codec, jack);
3880}
3881
3882static void alc_probe_headset_mode(struct hda_codec *codec)
3883{
3884 int i;
3885 struct alc_spec *spec = codec->spec;
3886 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3887
3888 /* Find mic pins */
3889 for (i = 0; i < cfg->num_inputs; i++) {
3890 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
3891 spec->headset_mic_pin = cfg->inputs[i].pin;
3892 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
3893 spec->headphone_mic_pin = cfg->inputs[i].pin;
3894 }
3895
3896 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
3897 spec->gen.automute_hook = alc_update_headset_mode;
3898 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
3899}
3900
3901static void alc_fixup_headset_mode(struct hda_codec *codec,
3902 const struct hda_fixup *fix, int action)
3903{
3904 struct alc_spec *spec = codec->spec;
3905
3906 switch (action) {
3907 case HDA_FIXUP_ACT_PRE_PROBE:
3908 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
3909 break;
3910 case HDA_FIXUP_ACT_PROBE:
3911 alc_probe_headset_mode(codec);
3912 break;
3913 case HDA_FIXUP_ACT_INIT:
3914 spec->current_headset_mode = 0;
3915 alc_update_headset_mode(codec);
3916 break;
3917 }
3918}
3919
3920static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
3921 const struct hda_fixup *fix, int action)
3922{
3923 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3924 struct alc_spec *spec = codec->spec;
3925 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3926 }
3927 else
3928 alc_fixup_headset_mode(codec, fix, action);
3929}
3930
Kailang Yang31278992014-03-03 15:27:22 +08003931static void alc255_set_default_jack_type(struct hda_codec *codec)
3932{
3933 /* Set to iphone type */
Takashi Iwai54db6c32014-08-18 15:11:19 +02003934 static struct coef_fw fw[] = {
3935 WRITE_COEF(0x1b, 0x880b),
3936 WRITE_COEF(0x45, 0xd089),
3937 WRITE_COEF(0x1b, 0x080b),
3938 WRITE_COEF(0x46, 0x0004),
3939 WRITE_COEF(0x1b, 0x0c0b),
3940 {}
3941 };
3942 alc_process_coef_fw(codec, fw);
Kailang Yang31278992014-03-03 15:27:22 +08003943 msleep(30);
3944}
3945
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003946static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
3947 const struct hda_fixup *fix, int action)
3948{
3949 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Kailang Yang31278992014-03-03 15:27:22 +08003950 alc255_set_default_jack_type(codec);
Kailang Yang9a22a8f52013-11-08 15:54:49 +08003951 }
3952 alc_fixup_headset_mode(codec, fix, action);
3953}
3954
Kailang Yang31278992014-03-03 15:27:22 +08003955static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
3956 const struct hda_fixup *fix, int action)
3957{
3958 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3959 struct alc_spec *spec = codec->spec;
3960 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3961 alc255_set_default_jack_type(codec);
3962 }
3963 else
3964 alc_fixup_headset_mode(codec, fix, action);
3965}
3966
Hui Wang493a52a2014-01-14 14:07:36 +08003967static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
3968 const struct hda_fixup *fix, int action)
3969{
3970 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3971 struct alc_spec *spec = codec->spec;
3972 spec->gen.auto_mute_via_amp = 1;
3973 }
3974}
3975
Takashi Iwai9b745ab2014-03-07 08:37:19 +01003976static void alc_no_shutup(struct hda_codec *codec)
3977{
3978}
3979
3980static void alc_fixup_no_shutup(struct hda_codec *codec,
3981 const struct hda_fixup *fix, int action)
3982{
3983 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3984 struct alc_spec *spec = codec->spec;
3985 spec->shutup = alc_no_shutup;
3986 }
3987}
3988
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02003989static void alc_fixup_disable_aamix(struct hda_codec *codec,
3990 const struct hda_fixup *fix, int action)
3991{
3992 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3993 struct alc_spec *spec = codec->spec;
3994 /* Disable AA-loopback as it causes white noise */
3995 spec->gen.mixer_nid = 0;
3996 }
3997}
3998
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02003999static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
4000 hda_nid_t nid,
4001 unsigned int power_state)
4002{
4003 struct alc_spec *spec = codec->spec;
4004
4005 /* Avoid pop noises when headphones are plugged in */
4006 if (spec->gen.hp_jack_present)
Gabriele Mazzottade3da4f2014-08-08 19:34:41 +02004007 if (nid == codec->afg || nid == 0x02 || nid == 0x15)
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004008 return AC_PWRST_D0;
4009 return power_state;
4010}
4011
4012static void alc_fixup_dell_xps13(struct hda_codec *codec,
4013 const struct hda_fixup *fix, int action)
4014{
4015 if (action == HDA_FIXUP_ACT_PROBE) {
4016 struct alc_spec *spec = codec->spec;
Gabriele Mazzottaf38663a2014-08-08 19:34:40 +02004017 struct hda_input_mux *imux = &spec->gen.input_mux;
4018 int i;
4019
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004020 spec->shutup = alc_no_shutup;
4021 codec->power_filter = alc_power_filter_xps13;
Gabriele Mazzottaf38663a2014-08-08 19:34:40 +02004022
4023 /* Make the internal mic the default input source. */
4024 for (i = 0; i < imux->num_items; i++) {
4025 if (spec->gen.imux_pins[i] == 0x12) {
4026 spec->gen.cur_mux[0] = i;
4027 break;
4028 }
4029 }
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02004030 }
4031}
4032
David Henningsson73bdd592013-04-15 15:44:14 +02004033static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
4034 const struct hda_fixup *fix, int action)
4035{
4036 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
David Henningsson73bdd592013-04-15 15:44:14 +02004037 alc_write_coef_idx(codec, 0xc4, 0x8000);
Takashi Iwai98b24882014-08-18 13:47:50 +02004038 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
David Henningsson73bdd592013-04-15 15:44:14 +02004039 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
4040 }
4041 alc_fixup_headset_mode(codec, fix, action);
4042}
4043
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004044/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
4045static int find_ext_mic_pin(struct hda_codec *codec)
4046{
4047 struct alc_spec *spec = codec->spec;
4048 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4049 hda_nid_t nid;
4050 unsigned int defcfg;
4051 int i;
4052
4053 for (i = 0; i < cfg->num_inputs; i++) {
4054 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4055 continue;
4056 nid = cfg->inputs[i].pin;
4057 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4058 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
4059 continue;
4060 return nid;
4061 }
4062
4063 return 0;
4064}
4065
Dylan Reid08a978d2012-11-18 22:56:40 -08004066static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01004067 const struct hda_fixup *fix,
Dylan Reid08a978d2012-11-18 22:56:40 -08004068 int action)
4069{
4070 struct alc_spec *spec = codec->spec;
4071
Takashi Iwai0db75792013-01-23 13:57:20 +01004072 if (action == HDA_FIXUP_ACT_PROBE) {
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004073 int mic_pin = find_ext_mic_pin(codec);
4074 int hp_pin = spec->gen.autocfg.hp_pins[0];
4075
4076 if (snd_BUG_ON(!mic_pin || !hp_pin))
Takashi Iwai0db75792013-01-23 13:57:20 +01004077 return;
Chih-Chung Changbde7bc62013-08-05 16:38:42 +08004078 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
Takashi Iwai0db75792013-01-23 13:57:20 +01004079 }
Dylan Reid08a978d2012-11-18 22:56:40 -08004080}
David Henningsson693b6132012-06-22 19:12:10 +02004081
David Henningsson3e0d6112013-04-22 14:30:14 +02004082static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
4083 const struct hda_fixup *fix,
4084 int action)
4085{
4086 struct alc_spec *spec = codec->spec;
4087 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4088 int i;
4089
4090 /* The mic boosts on level 2 and 3 are too noisy
4091 on the internal mic input.
4092 Therefore limit the boost to 0 or 1. */
4093
4094 if (action != HDA_FIXUP_ACT_PROBE)
4095 return;
4096
4097 for (i = 0; i < cfg->num_inputs; i++) {
4098 hda_nid_t nid = cfg->inputs[i].pin;
4099 unsigned int defcfg;
4100 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4101 continue;
4102 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4103 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
4104 continue;
4105
4106 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
4107 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
4108 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4109 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
4110 (0 << AC_AMPCAP_MUTE_SHIFT));
4111 }
4112}
4113
Kailang Yangcd217a62013-08-22 10:15:24 +02004114static void alc283_hp_automute_hook(struct hda_codec *codec,
Takashi Iwai1a4f69d2014-09-11 15:22:46 +02004115 struct hda_jack_callback *jack)
Kailang Yangcd217a62013-08-22 10:15:24 +02004116{
4117 struct alc_spec *spec = codec->spec;
4118 int vref;
4119
4120 msleep(200);
4121 snd_hda_gen_hp_automute(codec, jack);
4122
4123 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4124
4125 msleep(600);
4126 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4127 vref);
4128}
4129
Kailang Yangcd217a62013-08-22 10:15:24 +02004130static void alc283_fixup_chromebook(struct hda_codec *codec,
4131 const struct hda_fixup *fix, int action)
4132{
4133 struct alc_spec *spec = codec->spec;
Kailang Yangcd217a62013-08-22 10:15:24 +02004134
4135 switch (action) {
4136 case HDA_FIXUP_ACT_PRE_PROBE:
Kailang Yang0202e992013-12-02 15:20:15 +08004137 snd_hda_override_wcaps(codec, 0x03, 0);
Takashi Iwaid2e92702013-10-30 07:50:53 +01004138 /* Disable AA-loopback as it causes white noise */
4139 spec->gen.mixer_nid = 0;
Kailang Yang38070212013-11-01 15:57:35 +08004140 break;
4141 case HDA_FIXUP_ACT_INIT:
Kailang Yangde9481c2014-04-07 16:41:52 +08004142 /* MIC2-VREF control */
4143 /* Set to manual mode */
Takashi Iwai98b24882014-08-18 13:47:50 +02004144 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
Kailang Yang0202e992013-12-02 15:20:15 +08004145 /* Enable Line1 input control by verb */
Takashi Iwai98b24882014-08-18 13:47:50 +02004146 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
Kailang Yang0202e992013-12-02 15:20:15 +08004147 break;
4148 }
4149}
4150
4151static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
4152 const struct hda_fixup *fix, int action)
4153{
4154 struct alc_spec *spec = codec->spec;
Kailang Yang0202e992013-12-02 15:20:15 +08004155
4156 switch (action) {
4157 case HDA_FIXUP_ACT_PRE_PROBE:
Kailang Yangcd217a62013-08-22 10:15:24 +02004158 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
4159 break;
4160 case HDA_FIXUP_ACT_INIT:
4161 /* MIC2-VREF control */
4162 /* Set to manual mode */
Takashi Iwai98b24882014-08-18 13:47:50 +02004163 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
Kailang Yangcd217a62013-08-22 10:15:24 +02004164 break;
4165 }
4166}
4167
Takashi Iwai7bba2152013-09-06 15:45:38 +02004168/* mute tablet speaker pin (0x14) via dock plugging in addition */
4169static void asus_tx300_automute(struct hda_codec *codec)
4170{
4171 struct alc_spec *spec = codec->spec;
4172 snd_hda_gen_update_outputs(codec);
4173 if (snd_hda_jack_detect(codec, 0x1b))
4174 spec->gen.mute_bits |= (1ULL << 0x14);
4175}
4176
4177static void alc282_fixup_asus_tx300(struct hda_codec *codec,
4178 const struct hda_fixup *fix, int action)
4179{
4180 struct alc_spec *spec = codec->spec;
4181 /* TX300 needs to set up GPIO2 for the speaker amp */
4182 static const struct hda_verb gpio2_verbs[] = {
4183 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
4184 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
4185 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
4186 {}
4187 };
4188 static const struct hda_pintbl dock_pins[] = {
4189 { 0x1b, 0x21114000 }, /* dock speaker pin */
4190 {}
4191 };
4192 struct snd_kcontrol *kctl;
4193
4194 switch (action) {
4195 case HDA_FIXUP_ACT_PRE_PROBE:
4196 snd_hda_add_verbs(codec, gpio2_verbs);
4197 snd_hda_apply_pincfgs(codec, dock_pins);
4198 spec->gen.auto_mute_via_amp = 1;
4199 spec->gen.automute_hook = asus_tx300_automute;
4200 snd_hda_jack_detect_enable_callback(codec, 0x1b,
Takashi Iwai7bba2152013-09-06 15:45:38 +02004201 snd_hda_gen_hp_automute);
4202 break;
4203 case HDA_FIXUP_ACT_BUILD:
4204 /* this is a bit tricky; give more sane names for the main
4205 * (tablet) speaker and the dock speaker, respectively
4206 */
4207 kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch");
4208 if (kctl)
4209 strcpy(kctl->id.name, "Dock Speaker Playback Switch");
4210 kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch");
4211 if (kctl)
4212 strcpy(kctl->id.name, "Speaker Playback Switch");
4213 break;
4214 }
4215}
4216
David Henningsson338cae52013-10-07 10:39:59 +02004217static void alc290_fixup_mono_speakers(struct hda_codec *codec,
4218 const struct hda_fixup *fix, int action)
4219{
David Henningsson0f4881d2013-12-20 16:08:13 +01004220 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4221 /* DAC node 0x03 is giving mono output. We therefore want to
4222 make sure 0x14 (front speaker) and 0x15 (headphones) use the
4223 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
4224 hda_nid_t conn1[2] = { 0x0c };
4225 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
4226 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
4227 }
David Henningsson338cae52013-10-07 10:39:59 +02004228}
4229
Takashi Iwaib317b032014-01-08 11:44:21 +01004230/* for hda_fixup_thinkpad_acpi() */
4231#include "thinkpad_helper.c"
David Henningssonb67ae3f2013-11-05 13:11:37 +01004232
Hui Wang00ef9942014-07-31 11:52:38 +08004233/* for dell wmi mic mute led */
4234#include "dell_wmi_helper.c"
4235
Takashi Iwai1d045db2011-07-07 18:23:21 +02004236enum {
4237 ALC269_FIXUP_SONY_VAIO,
4238 ALC275_FIXUP_SONY_VAIO_GPIO2,
4239 ALC269_FIXUP_DELL_M101Z,
4240 ALC269_FIXUP_SKU_IGNORE,
4241 ALC269_FIXUP_ASUS_G73JW,
4242 ALC269_FIXUP_LENOVO_EAPD,
4243 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004244 ALC275_FIXUP_SONY_DISABLE_AAMIX,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004245 ALC271_FIXUP_DMIC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02004246 ALC269_FIXUP_PCM_44K,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004247 ALC269_FIXUP_STEREO_DMIC,
David Henningsson7c478f02013-10-11 10:18:46 +02004248 ALC269_FIXUP_HEADSET_MIC,
Takashi Iwai24519912011-08-16 15:08:49 +02004249 ALC269_FIXUP_QUANTA_MUTE,
4250 ALC269_FIXUP_LIFEBOOK,
David Henningsson2041d562014-06-13 11:15:44 +02004251 ALC269_FIXUP_LIFEBOOK_EXTMIC,
Takashi Iwaia4297b52011-08-23 18:40:12 +02004252 ALC269_FIXUP_AMIC,
4253 ALC269_FIXUP_DMIC,
4254 ALC269VB_FIXUP_AMIC,
4255 ALC269VB_FIXUP_DMIC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004256 ALC269_FIXUP_HP_MUTE_LED,
David Henningssond06ac142013-02-18 11:41:55 +01004257 ALC269_FIXUP_HP_MUTE_LED_MIC1,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004258 ALC269_FIXUP_HP_MUTE_LED_MIC2,
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004259 ALC269_FIXUP_HP_GPIO_LED,
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004260 ALC269_FIXUP_HP_GPIO_MIC1_LED,
4261 ALC269_FIXUP_HP_LINE1_MIC1_LED,
David Henningsson693b6132012-06-22 19:12:10 +02004262 ALC269_FIXUP_INV_DMIC,
David Henningsson108cc102012-07-20 10:37:25 +02004263 ALC269_FIXUP_LENOVO_DOCK,
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004264 ALC269_FIXUP_NO_SHUTUP,
David Henningsson88cfcf82013-10-11 10:18:45 +02004265 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
David Henningsson108cc102012-07-20 10:37:25 +02004266 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
David Henningsson73bdd592013-04-15 15:44:14 +02004267 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
4268 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
David Henningsson338cae52013-10-07 10:39:59 +02004269 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
David Henningsson73bdd592013-04-15 15:44:14 +02004270 ALC269_FIXUP_HEADSET_MODE,
4271 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
David Henningssond240d1d2013-04-15 12:50:02 +02004272 ALC269_FIXUP_ASUS_X101_FUNC,
4273 ALC269_FIXUP_ASUS_X101_VERB,
4274 ALC269_FIXUP_ASUS_X101,
Dylan Reid08a978d2012-11-18 22:56:40 -08004275 ALC271_FIXUP_AMIC_MIC2,
4276 ALC271_FIXUP_HP_GATE_MIC_JACK,
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004277 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
Dylan Reid42397002013-04-05 14:58:22 -07004278 ALC269_FIXUP_ACER_AC700,
David Henningsson3e0d6112013-04-22 14:30:14 +02004279 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
Oleksij Rempel2cede302013-11-27 17:12:03 +01004280 ALC269VB_FIXUP_ASUS_ZENBOOK,
Takashi Iwai23870832013-11-29 14:13:12 +01004281 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
David Henningsson8e35cd42013-11-06 11:20:01 +01004282 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
Anisse Astier02b504d2013-06-03 11:53:10 +02004283 ALC269VB_FIXUP_ORDISSIMO_EVE2,
Kailang Yangcd217a62013-08-22 10:15:24 +02004284 ALC283_FIXUP_CHROME_BOOK,
Kailang Yang0202e992013-12-02 15:20:15 +08004285 ALC283_FIXUP_SENSE_COMBO_JACK,
Takashi Iwai7bba2152013-09-06 15:45:38 +02004286 ALC282_FIXUP_ASUS_TX300,
Kailang Yang1bb3e062013-09-27 13:10:25 +02004287 ALC283_FIXUP_INT_MIC,
David Henningsson338cae52013-10-07 10:39:59 +02004288 ALC290_FIXUP_MONO_SPEAKERS,
David Henningsson0f4881d2013-12-20 16:08:13 +01004289 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4290 ALC290_FIXUP_SUBWOOFER,
4291 ALC290_FIXUP_SUBWOOFER_HSJACK,
David Henningssonb67ae3f2013-11-05 13:11:37 +01004292 ALC269_FIXUP_THINKPAD_ACPI,
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004293 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
Kailang Yang31278992014-03-03 15:27:22 +08004294 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004295 ALC255_FIXUP_HEADSET_MODE,
Kailang Yang31278992014-03-03 15:27:22 +08004296 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
Kailang Yanga22aa262014-04-23 17:34:28 +08004297 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
Takashi Iwai1c37c222014-05-06 17:34:42 +02004298 ALC292_FIXUP_TPT440_DOCK,
Daniel Drake9dc12862014-07-22 10:58:29 +01004299 ALC283_FIXUP_BXBT2807_MIC,
Hui Wang00ef9942014-07-31 11:52:38 +08004300 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
Takashi Iwai1a22e772014-08-27 08:19:05 +02004301 ALC282_FIXUP_ASPIRE_V5_PINS,
David Henningsson7a5255f2014-10-30 08:26:01 +01004302 ALC280_FIXUP_HP_GPIO4,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004303};
4304
Takashi Iwai1727a772013-01-10 09:52:52 +01004305static const struct hda_fixup alc269_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02004306 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaifd108212013-01-10 10:18:14 +01004307 .type = HDA_FIXUP_PINCTLS,
4308 .v.pins = (const struct hda_pintbl[]) {
4309 {0x19, PIN_VREFGRD},
Takashi Iwai1d045db2011-07-07 18:23:21 +02004310 {}
4311 }
4312 },
4313 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004314 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004315 .v.verbs = (const struct hda_verb[]) {
4316 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
4317 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
4318 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4319 { }
4320 },
4321 .chained = true,
4322 .chain_id = ALC269_FIXUP_SONY_VAIO
4323 },
4324 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004325 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004326 .v.verbs = (const struct hda_verb[]) {
4327 /* Enables internal speaker */
4328 {0x20, AC_VERB_SET_COEF_INDEX, 13},
4329 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4330 {}
4331 }
4332 },
4333 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004334 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02004335 .v.func = alc_fixup_sku_ignore,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004336 },
4337 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004338 .type = HDA_FIXUP_PINS,
4339 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02004340 { 0x17, 0x99130111 }, /* subwoofer */
4341 { }
4342 }
4343 },
4344 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004345 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004346 .v.verbs = (const struct hda_verb[]) {
4347 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4348 {}
4349 }
4350 },
4351 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004352 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004353 .v.func = alc269_fixup_hweq,
4354 .chained = true,
4355 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
4356 },
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004357 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
4358 .type = HDA_FIXUP_FUNC,
4359 .v.func = alc_fixup_disable_aamix,
4360 .chained = true,
4361 .chain_id = ALC269_FIXUP_SONY_VAIO
4362 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02004363 [ALC271_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004364 .type = HDA_FIXUP_FUNC,
Takashi Iwai1d045db2011-07-07 18:23:21 +02004365 .v.func = alc271_fixup_dmic,
4366 },
Takashi Iwai017f2a12011-07-09 14:42:25 +02004367 [ALC269_FIXUP_PCM_44K] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004368 .type = HDA_FIXUP_FUNC,
Takashi Iwai017f2a12011-07-09 14:42:25 +02004369 .v.func = alc269_fixup_pcm_44k,
David Henningsson012e7eb2012-08-08 08:43:37 +02004370 .chained = true,
4371 .chain_id = ALC269_FIXUP_QUANTA_MUTE
Takashi Iwai017f2a12011-07-09 14:42:25 +02004372 },
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004373 [ALC269_FIXUP_STEREO_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004374 .type = HDA_FIXUP_FUNC,
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004375 .v.func = alc269_fixup_stereo_dmic,
4376 },
David Henningsson7c478f02013-10-11 10:18:46 +02004377 [ALC269_FIXUP_HEADSET_MIC] = {
4378 .type = HDA_FIXUP_FUNC,
4379 .v.func = alc269_fixup_headset_mic,
4380 },
Takashi Iwai24519912011-08-16 15:08:49 +02004381 [ALC269_FIXUP_QUANTA_MUTE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004382 .type = HDA_FIXUP_FUNC,
Takashi Iwai24519912011-08-16 15:08:49 +02004383 .v.func = alc269_fixup_quanta_mute,
4384 },
4385 [ALC269_FIXUP_LIFEBOOK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004386 .type = HDA_FIXUP_PINS,
4387 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai24519912011-08-16 15:08:49 +02004388 { 0x1a, 0x2101103f }, /* dock line-out */
4389 { 0x1b, 0x23a11040 }, /* dock mic-in */
4390 { }
4391 },
4392 .chained = true,
4393 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4394 },
David Henningsson2041d562014-06-13 11:15:44 +02004395 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
4396 .type = HDA_FIXUP_PINS,
4397 .v.pins = (const struct hda_pintbl[]) {
4398 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
4399 { }
4400 },
4401 },
Takashi Iwaia4297b52011-08-23 18:40:12 +02004402 [ALC269_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004403 .type = HDA_FIXUP_PINS,
4404 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004405 { 0x14, 0x99130110 }, /* speaker */
4406 { 0x15, 0x0121401f }, /* HP out */
4407 { 0x18, 0x01a19c20 }, /* mic */
4408 { 0x19, 0x99a3092f }, /* int-mic */
4409 { }
4410 },
4411 },
4412 [ALC269_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004413 .type = HDA_FIXUP_PINS,
4414 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004415 { 0x12, 0x99a3092f }, /* int-mic */
4416 { 0x14, 0x99130110 }, /* speaker */
4417 { 0x15, 0x0121401f }, /* HP out */
4418 { 0x18, 0x01a19c20 }, /* mic */
4419 { }
4420 },
4421 },
4422 [ALC269VB_FIXUP_AMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004423 .type = HDA_FIXUP_PINS,
4424 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004425 { 0x14, 0x99130110 }, /* speaker */
4426 { 0x18, 0x01a19c20 }, /* mic */
4427 { 0x19, 0x99a3092f }, /* int-mic */
4428 { 0x21, 0x0121401f }, /* HP out */
4429 { }
4430 },
4431 },
David Henningsson2267ea92012-01-03 08:45:56 +01004432 [ALC269VB_FIXUP_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004433 .type = HDA_FIXUP_PINS,
4434 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004435 { 0x12, 0x99a3092f }, /* int-mic */
4436 { 0x14, 0x99130110 }, /* speaker */
4437 { 0x18, 0x01a19c20 }, /* mic */
4438 { 0x21, 0x0121401f }, /* HP out */
4439 { }
4440 },
4441 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004442 [ALC269_FIXUP_HP_MUTE_LED] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004443 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004444 .v.func = alc269_fixup_hp_mute_led,
David Henningsson6d3cd5d2013-01-07 12:03:47 +01004445 },
David Henningssond06ac142013-02-18 11:41:55 +01004446 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
4447 .type = HDA_FIXUP_FUNC,
4448 .v.func = alc269_fixup_hp_mute_led_mic1,
4449 },
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004450 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004451 .type = HDA_FIXUP_FUNC,
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004452 .v.func = alc269_fixup_hp_mute_led_mic2,
Takashi Iwai420b0fe2012-03-12 12:35:27 +01004453 },
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004454 [ALC269_FIXUP_HP_GPIO_LED] = {
4455 .type = HDA_FIXUP_FUNC,
4456 .v.func = alc269_fixup_hp_gpio_led,
4457 },
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004458 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
4459 .type = HDA_FIXUP_FUNC,
4460 .v.func = alc269_fixup_hp_gpio_mic1_led,
4461 },
4462 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
4463 .type = HDA_FIXUP_FUNC,
4464 .v.func = alc269_fixup_hp_line1_mic1_led,
4465 },
David Henningsson693b6132012-06-22 19:12:10 +02004466 [ALC269_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004467 .type = HDA_FIXUP_FUNC,
David Henningsson9d36a7d2014-10-07 10:18:42 +02004468 .v.func = alc_fixup_inv_dmic,
David Henningsson693b6132012-06-22 19:12:10 +02004469 },
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004470 [ALC269_FIXUP_NO_SHUTUP] = {
4471 .type = HDA_FIXUP_FUNC,
4472 .v.func = alc_fixup_no_shutup,
4473 },
David Henningsson108cc102012-07-20 10:37:25 +02004474 [ALC269_FIXUP_LENOVO_DOCK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004475 .type = HDA_FIXUP_PINS,
4476 .v.pins = (const struct hda_pintbl[]) {
David Henningsson108cc102012-07-20 10:37:25 +02004477 { 0x19, 0x23a11040 }, /* dock mic */
4478 { 0x1b, 0x2121103f }, /* dock headphone */
4479 { }
4480 },
4481 .chained = true,
4482 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
4483 },
4484 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004485 .type = HDA_FIXUP_FUNC,
David Henningsson108cc102012-07-20 10:37:25 +02004486 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
David Henningsson52129002013-11-19 10:25:53 +01004487 .chained = true,
4488 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
David Henningsson108cc102012-07-20 10:37:25 +02004489 },
David Henningsson73bdd592013-04-15 15:44:14 +02004490 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4491 .type = HDA_FIXUP_PINS,
4492 .v.pins = (const struct hda_pintbl[]) {
4493 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4494 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4495 { }
4496 },
4497 .chained = true,
4498 .chain_id = ALC269_FIXUP_HEADSET_MODE
4499 },
4500 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4501 .type = HDA_FIXUP_PINS,
4502 .v.pins = (const struct hda_pintbl[]) {
4503 { 0x16, 0x21014020 }, /* dock line out */
4504 { 0x19, 0x21a19030 }, /* dock mic */
4505 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4506 { }
4507 },
4508 .chained = true,
4509 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4510 },
David Henningsson338cae52013-10-07 10:39:59 +02004511 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
4512 .type = HDA_FIXUP_PINS,
4513 .v.pins = (const struct hda_pintbl[]) {
4514 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4515 { }
4516 },
4517 .chained = true,
4518 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4519 },
David Henningsson73bdd592013-04-15 15:44:14 +02004520 [ALC269_FIXUP_HEADSET_MODE] = {
4521 .type = HDA_FIXUP_FUNC,
4522 .v.func = alc_fixup_headset_mode,
Hui Wang6676f302014-11-18 17:57:41 +08004523 .chained = true,
4524 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
David Henningsson73bdd592013-04-15 15:44:14 +02004525 },
4526 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4527 .type = HDA_FIXUP_FUNC,
4528 .v.func = alc_fixup_headset_mode_no_hp_mic,
4529 },
David Henningsson88cfcf82013-10-11 10:18:45 +02004530 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
4531 .type = HDA_FIXUP_PINS,
4532 .v.pins = (const struct hda_pintbl[]) {
4533 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4534 { }
4535 },
David Henningssonfbc78ad2013-10-11 13:46:04 +02004536 .chained = true,
4537 .chain_id = ALC269_FIXUP_HEADSET_MIC
David Henningsson88cfcf82013-10-11 10:18:45 +02004538 },
David Henningssond240d1d2013-04-15 12:50:02 +02004539 [ALC269_FIXUP_ASUS_X101_FUNC] = {
4540 .type = HDA_FIXUP_FUNC,
4541 .v.func = alc269_fixup_x101_headset_mic,
4542 },
4543 [ALC269_FIXUP_ASUS_X101_VERB] = {
4544 .type = HDA_FIXUP_VERBS,
4545 .v.verbs = (const struct hda_verb[]) {
4546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4547 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
4548 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
4549 { }
4550 },
4551 .chained = true,
4552 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
4553 },
4554 [ALC269_FIXUP_ASUS_X101] = {
4555 .type = HDA_FIXUP_PINS,
4556 .v.pins = (const struct hda_pintbl[]) {
4557 { 0x18, 0x04a1182c }, /* Headset mic */
4558 { }
4559 },
4560 .chained = true,
4561 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
4562 },
Dylan Reid08a978d2012-11-18 22:56:40 -08004563 [ALC271_FIXUP_AMIC_MIC2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004564 .type = HDA_FIXUP_PINS,
4565 .v.pins = (const struct hda_pintbl[]) {
Dylan Reid08a978d2012-11-18 22:56:40 -08004566 { 0x14, 0x99130110 }, /* speaker */
4567 { 0x19, 0x01a19c20 }, /* mic */
4568 { 0x1b, 0x99a7012f }, /* int-mic */
4569 { 0x21, 0x0121401f }, /* HP out */
4570 { }
4571 },
4572 },
4573 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01004574 .type = HDA_FIXUP_FUNC,
Dylan Reid08a978d2012-11-18 22:56:40 -08004575 .v.func = alc271_hp_gate_mic_jack,
4576 .chained = true,
4577 .chain_id = ALC271_FIXUP_AMIC_MIC2,
4578 },
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004579 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
4580 .type = HDA_FIXUP_FUNC,
4581 .v.func = alc269_fixup_limit_int_mic_boost,
4582 .chained = true,
4583 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
4584 },
Dylan Reid42397002013-04-05 14:58:22 -07004585 [ALC269_FIXUP_ACER_AC700] = {
4586 .type = HDA_FIXUP_PINS,
4587 .v.pins = (const struct hda_pintbl[]) {
4588 { 0x12, 0x99a3092f }, /* int-mic */
4589 { 0x14, 0x99130110 }, /* speaker */
4590 { 0x18, 0x03a11c20 }, /* mic */
4591 { 0x1e, 0x0346101e }, /* SPDIF1 */
4592 { 0x21, 0x0321101f }, /* HP out */
4593 { }
4594 },
4595 .chained = true,
4596 .chain_id = ALC271_FIXUP_DMIC,
4597 },
David Henningsson3e0d6112013-04-22 14:30:14 +02004598 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
4599 .type = HDA_FIXUP_FUNC,
4600 .v.func = alc269_fixup_limit_int_mic_boost,
David Henningsson27937692013-11-18 11:51:47 +01004601 .chained = true,
4602 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
David Henningsson3e0d6112013-04-22 14:30:14 +02004603 },
Oleksij Rempel2cede302013-11-27 17:12:03 +01004604 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
4605 .type = HDA_FIXUP_FUNC,
4606 .v.func = alc269_fixup_limit_int_mic_boost,
4607 .chained = true,
4608 .chain_id = ALC269VB_FIXUP_DMIC,
4609 },
Takashi Iwai23870832013-11-29 14:13:12 +01004610 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
4611 .type = HDA_FIXUP_VERBS,
4612 .v.verbs = (const struct hda_verb[]) {
4613 /* class-D output amp +5dB */
4614 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
4615 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
4616 {}
4617 },
4618 .chained = true,
4619 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
4620 },
David Henningsson8e35cd42013-11-06 11:20:01 +01004621 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
4622 .type = HDA_FIXUP_FUNC,
4623 .v.func = alc269_fixup_limit_int_mic_boost,
4624 .chained = true,
4625 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
4626 },
Anisse Astier02b504d2013-06-03 11:53:10 +02004627 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
4628 .type = HDA_FIXUP_PINS,
4629 .v.pins = (const struct hda_pintbl[]) {
4630 { 0x12, 0x99a3092f }, /* int-mic */
4631 { 0x18, 0x03a11d20 }, /* mic */
4632 { 0x19, 0x411111f0 }, /* Unused bogus pin */
4633 { }
4634 },
4635 },
Kailang Yangcd217a62013-08-22 10:15:24 +02004636 [ALC283_FIXUP_CHROME_BOOK] = {
4637 .type = HDA_FIXUP_FUNC,
4638 .v.func = alc283_fixup_chromebook,
4639 },
Kailang Yang0202e992013-12-02 15:20:15 +08004640 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
4641 .type = HDA_FIXUP_FUNC,
4642 .v.func = alc283_fixup_sense_combo_jack,
4643 .chained = true,
4644 .chain_id = ALC283_FIXUP_CHROME_BOOK,
4645 },
Takashi Iwai7bba2152013-09-06 15:45:38 +02004646 [ALC282_FIXUP_ASUS_TX300] = {
4647 .type = HDA_FIXUP_FUNC,
4648 .v.func = alc282_fixup_asus_tx300,
4649 },
Kailang Yang1bb3e062013-09-27 13:10:25 +02004650 [ALC283_FIXUP_INT_MIC] = {
4651 .type = HDA_FIXUP_VERBS,
4652 .v.verbs = (const struct hda_verb[]) {
4653 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
4654 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
4655 { }
4656 },
4657 .chained = true,
4658 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4659 },
David Henningsson0f4881d2013-12-20 16:08:13 +01004660 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
4661 .type = HDA_FIXUP_PINS,
4662 .v.pins = (const struct hda_pintbl[]) {
4663 { 0x17, 0x90170112 }, /* subwoofer */
4664 { }
4665 },
4666 .chained = true,
4667 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
4668 },
4669 [ALC290_FIXUP_SUBWOOFER] = {
4670 .type = HDA_FIXUP_PINS,
4671 .v.pins = (const struct hda_pintbl[]) {
4672 { 0x17, 0x90170112 }, /* subwoofer */
4673 { }
4674 },
4675 .chained = true,
4676 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
4677 },
David Henningsson338cae52013-10-07 10:39:59 +02004678 [ALC290_FIXUP_MONO_SPEAKERS] = {
4679 .type = HDA_FIXUP_FUNC,
4680 .v.func = alc290_fixup_mono_speakers,
David Henningsson0f4881d2013-12-20 16:08:13 +01004681 },
4682 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
4683 .type = HDA_FIXUP_FUNC,
4684 .v.func = alc290_fixup_mono_speakers,
David Henningsson338cae52013-10-07 10:39:59 +02004685 .chained = true,
4686 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
4687 },
David Henningssonb67ae3f2013-11-05 13:11:37 +01004688 [ALC269_FIXUP_THINKPAD_ACPI] = {
4689 .type = HDA_FIXUP_FUNC,
Takashi Iwaib317b032014-01-08 11:44:21 +01004690 .v.func = hda_fixup_thinkpad_acpi,
David Henningssonb67ae3f2013-11-05 13:11:37 +01004691 },
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004692 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4693 .type = HDA_FIXUP_PINS,
4694 .v.pins = (const struct hda_pintbl[]) {
4695 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4696 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4697 { }
4698 },
4699 .chained = true,
4700 .chain_id = ALC255_FIXUP_HEADSET_MODE
4701 },
Kailang Yang31278992014-03-03 15:27:22 +08004702 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4703 .type = HDA_FIXUP_PINS,
4704 .v.pins = (const struct hda_pintbl[]) {
4705 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4706 { }
4707 },
4708 .chained = true,
4709 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
4710 },
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004711 [ALC255_FIXUP_HEADSET_MODE] = {
4712 .type = HDA_FIXUP_FUNC,
4713 .v.func = alc_fixup_headset_mode_alc255,
Hui Wang4a83d422014-11-18 17:57:40 +08004714 .chained = true,
4715 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
Kailang Yang9a22a8f52013-11-08 15:54:49 +08004716 },
Kailang Yang31278992014-03-03 15:27:22 +08004717 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4718 .type = HDA_FIXUP_FUNC,
4719 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
4720 },
Kailang Yanga22aa262014-04-23 17:34:28 +08004721 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4722 .type = HDA_FIXUP_PINS,
4723 .v.pins = (const struct hda_pintbl[]) {
4724 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4725 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4726 { }
4727 },
4728 .chained = true,
4729 .chain_id = ALC269_FIXUP_HEADSET_MODE
4730 },
Takashi Iwai1c37c222014-05-06 17:34:42 +02004731 [ALC292_FIXUP_TPT440_DOCK] = {
4732 .type = HDA_FIXUP_PINS,
4733 .v.pins = (const struct hda_pintbl[]) {
4734 { 0x16, 0x21211010 }, /* dock headphone */
4735 { 0x19, 0x21a11010 }, /* dock mic */
4736 { }
4737 },
4738 .chained = true,
4739 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
4740 },
Daniel Drake9dc12862014-07-22 10:58:29 +01004741 [ALC283_FIXUP_BXBT2807_MIC] = {
4742 .type = HDA_FIXUP_PINS,
4743 .v.pins = (const struct hda_pintbl[]) {
4744 { 0x19, 0x04a110f0 },
4745 { },
4746 },
4747 },
Hui Wang00ef9942014-07-31 11:52:38 +08004748 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
4749 .type = HDA_FIXUP_FUNC,
4750 .v.func = alc_fixup_dell_wmi,
Hui Wang00ef9942014-07-31 11:52:38 +08004751 },
Takashi Iwai1a22e772014-08-27 08:19:05 +02004752 [ALC282_FIXUP_ASPIRE_V5_PINS] = {
4753 .type = HDA_FIXUP_PINS,
4754 .v.pins = (const struct hda_pintbl[]) {
4755 { 0x12, 0x90a60130 },
4756 { 0x14, 0x90170110 },
4757 { 0x17, 0x40000008 },
4758 { 0x18, 0x411111f0 },
4759 { 0x19, 0x411111f0 },
4760 { 0x1a, 0x411111f0 },
4761 { 0x1b, 0x411111f0 },
4762 { 0x1d, 0x40f89b2d },
4763 { 0x1e, 0x411111f0 },
4764 { 0x21, 0x0321101f },
4765 { },
4766 },
4767 },
David Henningsson7a5255f2014-10-30 08:26:01 +01004768 [ALC280_FIXUP_HP_GPIO4] = {
4769 .type = HDA_FIXUP_FUNC,
4770 .v.func = alc280_fixup_hp_gpio4,
4771 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02004772};
4773
4774static const struct snd_pci_quirk alc269_fixup_tbl[] = {
Marius Knausta6b92b62014-03-03 01:48:58 +01004775 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
David Henningsson693b6132012-06-22 19:12:10 +02004776 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
4777 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
David Henningssonaaedfb42013-08-16 14:09:02 +02004778 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
4779 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4780 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
Oleksij Rempelb1e89722013-12-04 20:50:53 +01004781 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
Takashi Iwai1a22e772014-08-27 08:19:05 +02004782 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
David Henningssonaaedfb42013-08-16 14:09:02 +02004783 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson0f4881d2013-12-20 16:08:13 +01004784 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
David Henningsson73bdd592013-04-15 15:44:14 +02004785 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4786 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4787 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
David Henningsson0f4881d2013-12-20 16:08:13 +01004788 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4789 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
David Henningsson0f4881d2013-12-20 16:08:13 +01004790 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
Kailang Yanga22aa262014-04-23 17:34:28 +08004791 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4792 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
Kailang Yanga22aa262014-04-23 17:34:28 +08004793 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4794 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
Takashi Iwai08fb0d02013-01-10 17:33:58 +01004795 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004796 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
David Henningsson8e35cd42013-11-06 11:20:01 +01004797 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004798 /* ALC282 */
Kailang Yang8a02b162014-06-13 17:16:31 +08004799 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004800 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004801 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4802 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4803 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
4804 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004805 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004806 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004807 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4808 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004809 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004810 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004811 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4812 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4813 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004814 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004815 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4816 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004817 /* ALC290 */
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004818 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004819 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004820 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4821 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004822 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4823 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4824 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4825 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4826 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004827 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4828 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004829 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004830 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4831 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4832 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004833 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4834 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yang9c5dc3b2014-06-19 16:11:36 +08004835 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Kailang Yangc60666b2014-02-21 16:23:35 +08004836 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004837 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004838 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004839 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4840 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004841 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4842 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yangc60666b2014-02-21 16:23:35 +08004843 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Kailang Yang8a02b162014-06-13 17:16:31 +08004844 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4845 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4846 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4847 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Takashi Iwai7bba2152013-09-06 15:45:38 +02004848 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
David Henningsson3e0d6112013-04-22 14:30:14 +02004849 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4850 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Oleksij Rempel2cede302013-11-27 17:12:03 +01004851 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
Takashi Iwai23870832013-11-29 14:13:12 +01004852 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
David Henningsson3e0d6112013-04-22 14:30:14 +02004853 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
Takashi Iwai017f2a12011-07-09 14:42:25 +02004854 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
David Henningsson693b6132012-06-22 19:12:10 +02004855 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
David Henningsson3e0d6112013-04-22 14:30:14 +02004856 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Takashi Iwaiadabb3e2011-08-03 07:48:37 +02004857 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
4858 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
4859 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
4860 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
David Henningssond240d1d2013-04-15 12:50:02 +02004861 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
Takashi Iwaif88abaa2014-02-07 12:07:59 +01004862 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
David Henningsson88cfcf82013-10-11 10:18:45 +02004863 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004864 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
4865 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
4866 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwaie9bd7d52014-05-21 11:06:49 +02004867 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
Takashi Iwai24519912011-08-16 15:08:49 +02004868 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
David Henningsson2041d562014-06-13 11:15:44 +02004869 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
David Henningssona33cc482014-10-07 10:18:41 +02004870 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
Daniel Drake9dc12862014-07-22 10:58:29 +01004871 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004872 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
4873 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
4874 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
4875 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
4876 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
Takashi Iwai707fba32012-08-02 09:04:39 +02004877 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
Felix Kaechelec8415a42012-08-06 23:02:01 +02004878 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
Stefán Freyr84f98fd2012-10-19 22:46:00 +02004879 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
Philipp A. Mohrenweiser4407be62012-08-06 13:14:18 +02004880 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
David Henningsson108cc102012-07-20 10:37:25 +02004881 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
David Henningssonaaedfb42013-08-16 14:09:02 +02004882 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
Takashi Iwai1c37c222014-05-06 17:34:42 +02004883 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
4884 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
Takashi Iwaia12137e2014-06-27 12:14:35 +02004885 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
Takashi Iwai6d169412014-10-07 17:27:02 +02004886 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
Lukas Bossard7c215392014-10-29 18:31:07 +01004887 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
David Henningssona4a9e082013-08-16 14:09:01 +02004888 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Takashi Iwai9b745ab2014-03-07 08:37:19 +01004889 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
David Henningssona4a9e082013-08-16 14:09:01 +02004890 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Kailang Yang1bb3e062013-09-27 13:10:25 +02004891 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
Takashi Iwaic497d9f2014-10-08 12:14:40 +02004892 SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
David Henningssoncd5302c2013-08-19 12:22:33 +02004893 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4894 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
David Henningsson012e7eb2012-08-08 08:43:37 +02004895 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
Takashi Iwai1d045db2011-07-07 18:23:21 +02004896 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Anisse Astier02b504d2013-06-03 11:53:10 +02004897 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02004898
Takashi Iwaia7f3eed2012-02-16 13:03:18 +01004899#if 0
Takashi Iwaia4297b52011-08-23 18:40:12 +02004900 /* Below is a quirk table taken from the old code.
4901 * Basically the device should work as is without the fixup table.
4902 * If BIOS doesn't give a proper info, enable the corresponding
4903 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02004904 */
Takashi Iwaia4297b52011-08-23 18:40:12 +02004905 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
4906 ALC269_FIXUP_AMIC),
4907 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
Takashi Iwaia4297b52011-08-23 18:40:12 +02004908 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
4909 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
4910 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
4911 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
4912 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
4913 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
4914 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
4915 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
4916 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
4917 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
4918 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
4919 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
4920 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
4921 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
4922 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
4923 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
4924 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
4925 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
4926 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
4927 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
4928 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
4929 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
4930 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
4931 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
4932 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
4933 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
4934 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
4935 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
4936 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
4937 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
4938 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
4939 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
4940 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
4941 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
4942 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
4943 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
4944 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
4945 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
4946#endif
4947 {}
4948};
4949
David Henningsson214eef72014-07-22 14:09:35 +02004950static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
4951 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
4952 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
4953 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
4954 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
4955 {}
4956};
4957
Takashi Iwai1727a772013-01-10 09:52:52 +01004958static const struct hda_model_fixup alc269_fixup_models[] = {
Takashi Iwaia4297b52011-08-23 18:40:12 +02004959 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
4960 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02004961 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
4962 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
4963 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningsson7c478f02013-10-11 10:18:46 +02004964 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
David Henningsson108cc102012-07-20 10:37:25 +02004965 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
Takashi Iwai9f5c6fa2013-03-18 14:15:58 +01004966 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
David Henningssone32aa852013-06-17 11:04:02 +02004967 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
4968 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
Kailang Yangbe8ef162014-04-08 15:19:49 +08004969 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
Kailang Yang0202e992013-12-02 15:20:15 +08004970 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
Takashi Iwai1c37c222014-05-06 17:34:42 +02004971 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
Takashi Iwai1d045db2011-07-07 18:23:21 +02004972 {}
4973};
4974
David Henningssonfea185e2014-09-03 10:23:04 +02004975#define ALC255_STANDARD_PINS \
4976 {0x18, 0x411111f0}, \
4977 {0x19, 0x411111f0}, \
4978 {0x1a, 0x411111f0}, \
4979 {0x1b, 0x411111f0}, \
4980 {0x1e, 0x411111f0}
4981
4982#define ALC282_STANDARD_PINS \
4983 {0x14, 0x90170110}, \
4984 {0x18, 0x411111f0}, \
4985 {0x1a, 0x411111f0}, \
4986 {0x1b, 0x411111f0}, \
4987 {0x1e, 0x411111f0}
4988
4989#define ALC290_STANDARD_PINS \
4990 {0x12, 0x99a30130}, \
4991 {0x13, 0x40000000}, \
4992 {0x16, 0x411111f0}, \
4993 {0x17, 0x411111f0}, \
4994 {0x19, 0x411111f0}, \
4995 {0x1b, 0x411111f0}, \
4996 {0x1e, 0x411111f0}
4997
4998#define ALC292_STANDARD_PINS \
4999 {0x14, 0x90170110}, \
5000 {0x15, 0x0221401f}, \
5001 {0x1a, 0x411111f0}, \
5002 {0x1b, 0x411111f0}, \
5003 {0x1d, 0x40700001}, \
5004 {0x1e, 0x411111f0}
5005
Hui Wange1918932014-05-26 16:22:44 +08005006static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
Hui Wangc77900e2014-09-03 11:31:07 +08005007 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005008 ALC255_STANDARD_PINS,
Hui Wangc77900e2014-09-03 11:31:07 +08005009 {0x12, 0x40300000},
5010 {0x14, 0x90170110},
5011 {0x17, 0x411111f0},
Hui Wangc77900e2014-09-03 11:31:07 +08005012 {0x1d, 0x40538029},
Hui Wangc77900e2014-09-03 11:31:07 +08005013 {0x21, 0x02211020}),
David Henningsson76c21322014-06-24 14:46:54 +02005014 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005015 ALC255_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005016 {0x12, 0x90a60140},
5017 {0x14, 0x90170110},
5018 {0x17, 0x40000000},
David Henningsson76c21322014-06-24 14:46:54 +02005019 {0x1d, 0x40700001},
David Henningsson76c21322014-06-24 14:46:54 +02005020 {0x21, 0x02211020}),
5021 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005022 ALC255_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005023 {0x12, 0x90a60160},
5024 {0x14, 0x90170120},
5025 {0x17, 0x40000000},
David Henningsson76c21322014-06-24 14:46:54 +02005026 {0x1d, 0x40700001},
David Henningsson76c21322014-06-24 14:46:54 +02005027 {0x21, 0x02211030}),
5028 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5029 {0x12, 0x90a60160},
5030 {0x14, 0x90170120},
5031 {0x17, 0x90170140},
5032 {0x18, 0x40000000},
5033 {0x19, 0x411111f0},
5034 {0x1a, 0x411111f0},
5035 {0x1b, 0x411111f0},
5036 {0x1d, 0x41163b05},
5037 {0x1e, 0x411111f0},
5038 {0x21, 0x0321102f}),
5039 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005040 ALC255_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005041 {0x12, 0x90a60160},
5042 {0x14, 0x90170130},
5043 {0x17, 0x40000000},
David Henningsson76c21322014-06-24 14:46:54 +02005044 {0x1d, 0x40700001},
David Henningsson76c21322014-06-24 14:46:54 +02005045 {0x21, 0x02211040}),
5046 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005047 ALC255_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005048 {0x12, 0x90a60160},
5049 {0x14, 0x90170140},
5050 {0x17, 0x40000000},
David Henningsson76c21322014-06-24 14:46:54 +02005051 {0x1d, 0x40700001},
David Henningsson76c21322014-06-24 14:46:54 +02005052 {0x21, 0x02211050}),
5053 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005054 ALC255_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005055 {0x12, 0x90a60170},
5056 {0x14, 0x90170120},
5057 {0x17, 0x40000000},
David Henningsson76c21322014-06-24 14:46:54 +02005058 {0x1d, 0x40700001},
David Henningsson76c21322014-06-24 14:46:54 +02005059 {0x21, 0x02211030}),
5060 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005061 ALC255_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005062 {0x12, 0x90a60170},
5063 {0x14, 0x90170130},
5064 {0x17, 0x40000000},
David Henningsson76c21322014-06-24 14:46:54 +02005065 {0x1d, 0x40700001},
David Henningsson76c21322014-06-24 14:46:54 +02005066 {0x21, 0x02211040}),
David Henningssoncf51eb92014-10-30 08:26:02 +01005067 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
5068 {0x12, 0x90a60130},
5069 {0x13, 0x40000000},
5070 {0x14, 0x90170110},
5071 {0x15, 0x0421101f},
5072 {0x16, 0x411111f0},
5073 {0x17, 0x411111f0},
5074 {0x18, 0x411111f0},
5075 {0x19, 0x411111f0},
5076 {0x1a, 0x04a11020},
5077 {0x1b, 0x411111f0},
5078 {0x1d, 0x40748605},
5079 {0x1e, 0x411111f0}),
Hui Wang02796612014-09-03 11:31:11 +08005080 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
5081 {0x12, 0x90a60140},
5082 {0x13, 0x40000000},
5083 {0x14, 0x90170110},
5084 {0x15, 0x0421101f},
5085 {0x16, 0x411111f0},
5086 {0x17, 0x411111f0},
5087 {0x18, 0x02811030},
5088 {0x19, 0x411111f0},
5089 {0x1a, 0x04a1103f},
5090 {0x1b, 0x02011020},
5091 {0x1d, 0x40700001},
5092 {0x1e, 0x411111f0}),
David Henningsson42304472014-07-22 11:42:17 +02005093 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005094 ALC282_STANDARD_PINS,
David Henningsson42304472014-07-22 11:42:17 +02005095 {0x12, 0x99a30130},
David Henningsson42304472014-07-22 11:42:17 +02005096 {0x17, 0x40000000},
David Henningsson42304472014-07-22 11:42:17 +02005097 {0x19, 0x03a11020},
David Henningsson42304472014-07-22 11:42:17 +02005098 {0x1d, 0x40f41905},
David Henningsson42304472014-07-22 11:42:17 +02005099 {0x21, 0x0321101f}),
Hui Wang2c609992014-09-03 11:31:08 +08005100 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005101 ALC282_STANDARD_PINS,
Hui Wang2c609992014-09-03 11:31:08 +08005102 {0x12, 0x99a30130},
Hui Wang2c609992014-09-03 11:31:08 +08005103 {0x17, 0x40020008},
Hui Wang2c609992014-09-03 11:31:08 +08005104 {0x19, 0x03a11020},
Hui Wang2c609992014-09-03 11:31:08 +08005105 {0x1d, 0x40e00001},
Hui Wang2c609992014-09-03 11:31:08 +08005106 {0x21, 0x03211040}),
5107 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005108 ALC282_STANDARD_PINS,
Hui Wang2c609992014-09-03 11:31:08 +08005109 {0x12, 0x99a30130},
Hui Wang2c609992014-09-03 11:31:08 +08005110 {0x17, 0x40000000},
Hui Wang2c609992014-09-03 11:31:08 +08005111 {0x19, 0x03a11030},
Hui Wang2c609992014-09-03 11:31:08 +08005112 {0x1d, 0x40e00001},
Hui Wang2c609992014-09-03 11:31:08 +08005113 {0x21, 0x03211020}),
5114 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005115 ALC282_STANDARD_PINS,
Hui Wang2c609992014-09-03 11:31:08 +08005116 {0x12, 0x99a30130},
Hui Wang2c609992014-09-03 11:31:08 +08005117 {0x17, 0x40000000},
Hui Wang2c609992014-09-03 11:31:08 +08005118 {0x19, 0x03a11030},
Hui Wang2c609992014-09-03 11:31:08 +08005119 {0x1d, 0x40f00001},
Hui Wang2c609992014-09-03 11:31:08 +08005120 {0x21, 0x03211020}),
5121 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005122 ALC282_STANDARD_PINS,
Hui Wang2c609992014-09-03 11:31:08 +08005123 {0x12, 0x99a30130},
Hui Wang2c609992014-09-03 11:31:08 +08005124 {0x17, 0x40000000},
Hui Wang2c609992014-09-03 11:31:08 +08005125 {0x19, 0x04a11020},
Hui Wang2c609992014-09-03 11:31:08 +08005126 {0x1d, 0x40f00001},
Hui Wang2c609992014-09-03 11:31:08 +08005127 {0x21, 0x0421101f}),
5128 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005129 ALC282_STANDARD_PINS,
Hui Wang2c609992014-09-03 11:31:08 +08005130 {0x12, 0x99a30130},
Hui Wang2c609992014-09-03 11:31:08 +08005131 {0x17, 0x40000000},
Hui Wang2c609992014-09-03 11:31:08 +08005132 {0x19, 0x03a11030},
Hui Wang2c609992014-09-03 11:31:08 +08005133 {0x1d, 0x40f00001},
Hui Wang2c609992014-09-03 11:31:08 +08005134 {0x21, 0x04211020}),
Hui Wang200afc02014-09-03 11:31:10 +08005135 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
David Henningssonaec856d2014-09-03 10:23:05 +02005136 ALC282_STANDARD_PINS,
Hui Wang200afc02014-09-03 11:31:10 +08005137 {0x12, 0x90a60140},
Hui Wang200afc02014-09-03 11:31:10 +08005138 {0x17, 0x40000000},
Hui Wang200afc02014-09-03 11:31:10 +08005139 {0x19, 0x04a11030},
Hui Wang200afc02014-09-03 11:31:10 +08005140 {0x1d, 0x40f00001},
Hui Wang200afc02014-09-03 11:31:10 +08005141 {0x21, 0x04211020}),
David Henningsson76c21322014-06-24 14:46:54 +02005142 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005143 ALC282_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005144 {0x12, 0x90a60130},
David Henningsson76c21322014-06-24 14:46:54 +02005145 {0x17, 0x40020008},
David Henningsson76c21322014-06-24 14:46:54 +02005146 {0x19, 0x411111f0},
David Henningsson76c21322014-06-24 14:46:54 +02005147 {0x1d, 0x40e00001},
David Henningsson76c21322014-06-24 14:46:54 +02005148 {0x21, 0x0321101f}),
5149 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5150 {0x12, 0x90a60160},
5151 {0x14, 0x90170120},
5152 {0x17, 0x40000000},
5153 {0x18, 0x411111f0},
5154 {0x19, 0x411111f0},
5155 {0x1a, 0x411111f0},
5156 {0x1b, 0x411111f0},
5157 {0x1d, 0x40700001},
5158 {0x1e, 0x411111f0},
5159 {0x21, 0x02211030}),
Hui Wangbc262172014-09-03 11:31:05 +08005160 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005161 ALC282_STANDARD_PINS,
Hui Wangbc262172014-09-03 11:31:05 +08005162 {0x12, 0x90a60130},
Hui Wangbc262172014-09-03 11:31:05 +08005163 {0x17, 0x40020008},
Hui Wangbc262172014-09-03 11:31:05 +08005164 {0x19, 0x03a11020},
Hui Wangbc262172014-09-03 11:31:05 +08005165 {0x1d, 0x40e00001},
Hui Wangbc262172014-09-03 11:31:05 +08005166 {0x21, 0x0321101f}),
Hui Wange4442bc2014-09-03 11:31:09 +08005167 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005168 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005169 {0x14, 0x411111f0},
5170 {0x15, 0x04211040},
Hui Wange4442bc2014-09-03 11:31:09 +08005171 {0x18, 0x90170112},
Hui Wange4442bc2014-09-03 11:31:09 +08005172 {0x1a, 0x04a11020},
David Henningssonaec856d2014-09-03 10:23:05 +02005173 {0x1d, 0x4075812d}),
Hui Wange4442bc2014-09-03 11:31:09 +08005174 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005175 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005176 {0x14, 0x411111f0},
5177 {0x15, 0x04211040},
Hui Wange4442bc2014-09-03 11:31:09 +08005178 {0x18, 0x90170110},
Hui Wange4442bc2014-09-03 11:31:09 +08005179 {0x1a, 0x04a11020},
David Henningssonaec856d2014-09-03 10:23:05 +02005180 {0x1d, 0x4075812d}),
Hui Wange4442bc2014-09-03 11:31:09 +08005181 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005182 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005183 {0x14, 0x411111f0},
5184 {0x15, 0x0421101f},
Hui Wange4442bc2014-09-03 11:31:09 +08005185 {0x18, 0x411111f0},
Hui Wange4442bc2014-09-03 11:31:09 +08005186 {0x1a, 0x04a11020},
David Henningssonaec856d2014-09-03 10:23:05 +02005187 {0x1d, 0x4075812d}),
Hui Wange4442bc2014-09-03 11:31:09 +08005188 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005189 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005190 {0x14, 0x411111f0},
5191 {0x15, 0x04211020},
Hui Wange4442bc2014-09-03 11:31:09 +08005192 {0x18, 0x411111f0},
Hui Wange4442bc2014-09-03 11:31:09 +08005193 {0x1a, 0x04a11040},
David Henningssonaec856d2014-09-03 10:23:05 +02005194 {0x1d, 0x4076a12d}),
Hui Wange4442bc2014-09-03 11:31:09 +08005195 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005196 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005197 {0x14, 0x90170110},
5198 {0x15, 0x04211020},
Hui Wange4442bc2014-09-03 11:31:09 +08005199 {0x18, 0x411111f0},
Hui Wange4442bc2014-09-03 11:31:09 +08005200 {0x1a, 0x04a11040},
David Henningssonaec856d2014-09-03 10:23:05 +02005201 {0x1d, 0x4076a12d}),
Hui Wange4442bc2014-09-03 11:31:09 +08005202 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005203 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005204 {0x14, 0x90170110},
5205 {0x15, 0x04211020},
Hui Wange4442bc2014-09-03 11:31:09 +08005206 {0x18, 0x411111f0},
Hui Wange4442bc2014-09-03 11:31:09 +08005207 {0x1a, 0x04a11020},
David Henningssonaec856d2014-09-03 10:23:05 +02005208 {0x1d, 0x4076a12d}),
Hui Wange4442bc2014-09-03 11:31:09 +08005209 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
David Henningssonaec856d2014-09-03 10:23:05 +02005210 ALC290_STANDARD_PINS,
Hui Wange4442bc2014-09-03 11:31:09 +08005211 {0x14, 0x90170110},
5212 {0x15, 0x0421101f},
Hui Wange4442bc2014-09-03 11:31:09 +08005213 {0x18, 0x411111f0},
Hui Wange4442bc2014-09-03 11:31:09 +08005214 {0x1a, 0x04a11020},
David Henningssonaec856d2014-09-03 10:23:05 +02005215 {0x1d, 0x4075812d}),
Hui Wange8818fa2014-09-03 11:31:04 +08005216 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005217 ALC292_STANDARD_PINS,
Hui Wange8818fa2014-09-03 11:31:04 +08005218 {0x12, 0x90a60140},
5219 {0x13, 0x411111f0},
Hui Wange8818fa2014-09-03 11:31:04 +08005220 {0x16, 0x01014020},
5221 {0x18, 0x411111f0},
David Henningssonaec856d2014-09-03 10:23:05 +02005222 {0x19, 0x01a19030}),
Hui Wange8818fa2014-09-03 11:31:04 +08005223 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005224 ALC292_STANDARD_PINS,
Hui Wange8818fa2014-09-03 11:31:04 +08005225 {0x12, 0x90a60140},
5226 {0x13, 0x411111f0},
Hui Wange8818fa2014-09-03 11:31:04 +08005227 {0x16, 0x01014020},
5228 {0x18, 0x02a19031},
David Henningssonaec856d2014-09-03 10:23:05 +02005229 {0x19, 0x01a1903e}),
David Henningsson76c21322014-06-24 14:46:54 +02005230 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005231 ALC292_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005232 {0x12, 0x90a60140},
5233 {0x13, 0x411111f0},
David Henningsson76c21322014-06-24 14:46:54 +02005234 {0x16, 0x411111f0},
5235 {0x18, 0x411111f0},
David Henningssonaec856d2014-09-03 10:23:05 +02005236 {0x19, 0x411111f0}),
David Henningsson76c21322014-06-24 14:46:54 +02005237 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005238 ALC292_STANDARD_PINS,
David Henningsson76c21322014-06-24 14:46:54 +02005239 {0x12, 0x40000000},
5240 {0x13, 0x90a60140},
David Henningsson76c21322014-06-24 14:46:54 +02005241 {0x16, 0x21014020},
5242 {0x18, 0x411111f0},
David Henningssonaec856d2014-09-03 10:23:05 +02005243 {0x19, 0x21a19030}),
David Henningssone03fdbd2014-06-27 08:41:59 +02005244 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
David Henningssonaec856d2014-09-03 10:23:05 +02005245 ALC292_STANDARD_PINS,
David Henningssone03fdbd2014-06-27 08:41:59 +02005246 {0x12, 0x40000000},
5247 {0x13, 0x90a60140},
David Henningssone03fdbd2014-06-27 08:41:59 +02005248 {0x16, 0x411111f0},
5249 {0x18, 0x411111f0},
David Henningssonaec856d2014-09-03 10:23:05 +02005250 {0x19, 0x411111f0}),
Hui Wange1918932014-05-26 16:22:44 +08005251 {}
5252};
Takashi Iwai1d045db2011-07-07 18:23:21 +02005253
Takashi Iwai546bb672012-03-07 08:37:19 +01005254static void alc269_fill_coef(struct hda_codec *codec)
Takashi Iwai1d045db2011-07-07 18:23:21 +02005255{
Kailang Yang526af6e2012-03-07 08:25:20 +01005256 struct alc_spec *spec = codec->spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005257 int val;
5258
Kailang Yang526af6e2012-03-07 08:25:20 +01005259 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
Takashi Iwai546bb672012-03-07 08:37:19 +01005260 return;
Kailang Yang526af6e2012-03-07 08:25:20 +01005261
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005262 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005263 alc_write_coef_idx(codec, 0xf, 0x960b);
5264 alc_write_coef_idx(codec, 0xe, 0x8817);
5265 }
5266
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005267 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005268 alc_write_coef_idx(codec, 0xf, 0x960b);
5269 alc_write_coef_idx(codec, 0xe, 0x8814);
5270 }
5271
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005272 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005273 /* Power up output pin */
Takashi Iwai98b24882014-08-18 13:47:50 +02005274 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005275 }
5276
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005277 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005278 val = alc_read_coef_idx(codec, 0xd);
Takashi Iwaif3ee07d2014-08-15 17:35:00 +02005279 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005280 /* Capless ramp up clock control */
5281 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5282 }
5283 val = alc_read_coef_idx(codec, 0x17);
Takashi Iwaif3ee07d2014-08-15 17:35:00 +02005284 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005285 /* Class D power on reset */
5286 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5287 }
5288 }
5289
Takashi Iwai98b24882014-08-18 13:47:50 +02005290 /* HP */
5291 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005292}
5293
5294/*
5295 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005296static int patch_alc269(struct hda_codec *codec)
5297{
5298 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02005299 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005300
Takashi Iwai3de95172012-05-07 18:03:15 +02005301 err = alc_alloc_spec(codec, 0x0b);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005302 if (err < 0)
Takashi Iwai3de95172012-05-07 18:03:15 +02005303 return err;
5304
5305 spec = codec->spec;
Takashi Iwai08c189f2012-12-19 15:22:24 +01005306 spec->gen.shared_mic_vref_pin = 0x18;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005307
Takashi Iwai1727a772013-01-10 09:52:52 +01005308 snd_hda_pick_fixup(codec, alc269_fixup_models,
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03005309 alc269_fixup_tbl, alc269_fixups);
Hui Wange1918932014-05-26 16:22:44 +08005310 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
David Henningsson214eef72014-07-22 14:09:35 +02005311 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
5312 alc269_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01005313 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Herton Ronaldo Krzesinski9f720bb92012-09-27 10:38:14 -03005314
5315 alc_auto_parse_customize_define(codec);
5316
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005317 if (has_cdefine_beep(codec))
5318 spec->gen.beep_nid = 0x01;
5319
Kailang Yang065380f2013-01-10 10:25:48 +01005320 switch (codec->vendor_id) {
5321 case 0x10ec0269:
Takashi Iwai1d045db2011-07-07 18:23:21 +02005322 spec->codec_variant = ALC269_TYPE_ALC269VA;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005323 switch (alc_get_coef0(codec) & 0x00f0) {
5324 case 0x0010:
Takashi Iwai5100cd02014-02-15 10:03:19 +01005325 if (codec->bus->pci &&
5326 codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005327 spec->cdefine.platform_type == 1)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02005328 err = alc_codec_rename(codec, "ALC271X");
Takashi Iwai1d045db2011-07-07 18:23:21 +02005329 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005330 break;
5331 case 0x0020:
Takashi Iwai5100cd02014-02-15 10:03:19 +01005332 if (codec->bus->pci &&
5333 codec->bus->pci->subsystem_vendor == 0x17aa &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005334 codec->bus->pci->subsystem_device == 0x21f3)
Takashi Iwai20ca0c32011-10-17 16:00:35 +02005335 err = alc_codec_rename(codec, "ALC3202");
Takashi Iwai1d045db2011-07-07 18:23:21 +02005336 spec->codec_variant = ALC269_TYPE_ALC269VC;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005337 break;
Kailang Yangadcc70b2012-05-25 08:08:38 +02005338 case 0x0030:
5339 spec->codec_variant = ALC269_TYPE_ALC269VD;
5340 break;
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005341 default:
Takashi Iwai1d045db2011-07-07 18:23:21 +02005342 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Takashi Iwai1bb7e432011-10-17 16:50:59 +02005343 }
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005344 if (err < 0)
5345 goto error;
Takashi Iwai546bb672012-03-07 08:37:19 +01005346 spec->init_hook = alc269_fill_coef;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005347 alc269_fill_coef(codec);
Kailang Yang065380f2013-01-10 10:25:48 +01005348 break;
5349
5350 case 0x10ec0280:
5351 case 0x10ec0290:
5352 spec->codec_variant = ALC269_TYPE_ALC280;
5353 break;
5354 case 0x10ec0282:
Kailang Yang065380f2013-01-10 10:25:48 +01005355 spec->codec_variant = ALC269_TYPE_ALC282;
Kailang Yang7b5c7a02014-03-18 16:15:54 +08005356 spec->shutup = alc282_shutup;
5357 spec->init_hook = alc282_init;
Kailang Yang065380f2013-01-10 10:25:48 +01005358 break;
Kailang Yang2af02be2013-08-22 10:03:50 +02005359 case 0x10ec0233:
5360 case 0x10ec0283:
5361 spec->codec_variant = ALC269_TYPE_ALC283;
5362 spec->shutup = alc283_shutup;
5363 spec->init_hook = alc283_init;
5364 break;
Kailang Yang065380f2013-01-10 10:25:48 +01005365 case 0x10ec0284:
5366 case 0x10ec0292:
5367 spec->codec_variant = ALC269_TYPE_ALC284;
5368 break;
Kailang Yang161ebf22013-10-24 11:36:33 +02005369 case 0x10ec0285:
5370 case 0x10ec0293:
5371 spec->codec_variant = ALC269_TYPE_ALC285;
5372 break;
Kailang Yang7fc7d042013-04-25 11:04:43 +02005373 case 0x10ec0286:
Kailang Yang7c665932014-04-14 15:09:44 +08005374 case 0x10ec0288:
Kailang Yang7fc7d042013-04-25 11:04:43 +02005375 spec->codec_variant = ALC269_TYPE_ALC286;
Kailang Yangf7ae9ba2014-06-30 16:10:37 +08005376 spec->shutup = alc286_shutup;
Kailang Yang7fc7d042013-04-25 11:04:43 +02005377 break;
Kailang Yang1d04c9d2013-10-24 11:35:18 +02005378 case 0x10ec0255:
5379 spec->codec_variant = ALC269_TYPE_ALC255;
5380 break;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005381 }
5382
Kailang Yangad60d502013-06-28 12:03:01 +02005383 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
Kailang Yang97a26572013-11-29 00:35:26 -05005384 spec->has_alc5505_dsp = 1;
Kailang Yangad60d502013-06-28 12:03:01 +02005385 spec->init_hook = alc5505_dsp_init;
5386 }
5387
Takashi Iwaia4297b52011-08-23 18:40:12 +02005388 /* automatic parse from the BIOS config */
5389 err = alc269_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005390 if (err < 0)
5391 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005392
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005393 if (!spec->gen.no_analog && spec->gen.beep_nid)
Takashi Iwai1d045db2011-07-07 18:23:21 +02005394 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5395
Takashi Iwai1d045db2011-07-07 18:23:21 +02005396 codec->patch_ops = alc_patch_ops;
Takashi Iwai2a439522011-07-26 09:52:50 +02005397#ifdef CONFIG_PM
Kailang Yangad60d502013-06-28 12:03:01 +02005398 codec->patch_ops.suspend = alc269_suspend;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005399 codec->patch_ops.resume = alc269_resume;
5400#endif
Kailang Yangc5177c82013-07-24 14:39:49 +02005401 if (!spec->shutup)
5402 spec->shutup = alc269_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005403
Takashi Iwai1727a772013-01-10 09:52:52 +01005404 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005405
Takashi Iwai1d045db2011-07-07 18:23:21 +02005406 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005407
5408 error:
5409 alc_free(codec);
5410 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005411}
5412
5413/*
5414 * ALC861
5415 */
5416
Takashi Iwai1d045db2011-07-07 18:23:21 +02005417static int alc861_parse_auto_config(struct hda_codec *codec)
5418{
Takashi Iwai1d045db2011-07-07 18:23:21 +02005419 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005420 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5421 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005422}
5423
Takashi Iwai1d045db2011-07-07 18:23:21 +02005424/* Pin config fixes */
5425enum {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005426 ALC861_FIXUP_FSC_AMILO_PI1505,
5427 ALC861_FIXUP_AMP_VREF_0F,
5428 ALC861_FIXUP_NO_JACK_DETECT,
5429 ALC861_FIXUP_ASUS_A6RP,
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005430 ALC660_FIXUP_ASUS_W7J,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005431};
5432
Takashi Iwai31150f22012-01-30 10:54:08 +01005433/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
5434static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005435 const struct hda_fixup *fix, int action)
Takashi Iwai31150f22012-01-30 10:54:08 +01005436{
5437 struct alc_spec *spec = codec->spec;
5438 unsigned int val;
5439
Takashi Iwai1727a772013-01-10 09:52:52 +01005440 if (action != HDA_FIXUP_ACT_INIT)
Takashi Iwai31150f22012-01-30 10:54:08 +01005441 return;
Takashi Iwaid3f02d62013-01-10 10:12:22 +01005442 val = snd_hda_codec_get_pin_target(codec, 0x0f);
Takashi Iwai31150f22012-01-30 10:54:08 +01005443 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
5444 val |= AC_PINCTL_IN_EN;
5445 val |= AC_PINCTL_VREF_50;
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005446 snd_hda_set_pin_ctl(codec, 0x0f, val);
Takashi Iwai08c189f2012-12-19 15:22:24 +01005447 spec->gen.keep_vref_in_automute = 1;
Takashi Iwai31150f22012-01-30 10:54:08 +01005448}
5449
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005450/* suppress the jack-detection */
5451static void alc_fixup_no_jack_detect(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005452 const struct hda_fixup *fix, int action)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005453{
Takashi Iwai1727a772013-01-10 09:52:52 +01005454 if (action == HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005455 codec->no_jack_detect = 1;
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02005456}
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005457
Takashi Iwai1727a772013-01-10 09:52:52 +01005458static const struct hda_fixup alc861_fixups[] = {
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005459 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005460 .type = HDA_FIXUP_PINS,
5461 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005462 { 0x0b, 0x0221101f }, /* HP */
5463 { 0x0f, 0x90170310 }, /* speaker */
5464 { }
5465 }
5466 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005467 [ALC861_FIXUP_AMP_VREF_0F] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005468 .type = HDA_FIXUP_FUNC,
Takashi Iwai31150f22012-01-30 10:54:08 +01005469 .v.func = alc861_fixup_asus_amp_vref_0f,
Takashi Iwai3b25eb62012-01-25 09:55:46 +01005470 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005471 [ALC861_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005472 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005473 .v.func = alc_fixup_no_jack_detect,
5474 },
5475 [ALC861_FIXUP_ASUS_A6RP] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005476 .type = HDA_FIXUP_FUNC,
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005477 .v.func = alc861_fixup_asus_amp_vref_0f,
5478 .chained = true,
5479 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005480 },
5481 [ALC660_FIXUP_ASUS_W7J] = {
5482 .type = HDA_FIXUP_VERBS,
5483 .v.verbs = (const struct hda_verb[]) {
5484 /* ASUS W7J needs a magic pin setup on unused NID 0x10
5485 * for enabling outputs
5486 */
5487 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5488 { }
5489 },
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005490 }
Takashi Iwai1d045db2011-07-07 18:23:21 +02005491};
5492
5493static const struct snd_pci_quirk alc861_fixup_tbl[] = {
Takashi Iwai6ddf0fd2013-11-29 12:47:34 +01005494 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
Takashi Iwaie7ca2372013-12-02 15:27:19 +01005495 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
Takashi Iwaie652f4c2012-02-13 11:56:25 +01005496 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
5497 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
5498 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
5499 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
5500 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
5501 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005502 {}
5503};
5504
5505/*
5506 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005507static int patch_alc861(struct hda_codec *codec)
5508{
5509 struct alc_spec *spec;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005510 int err;
5511
Takashi Iwai3de95172012-05-07 18:03:15 +02005512 err = alc_alloc_spec(codec, 0x15);
5513 if (err < 0)
5514 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005515
Takashi Iwai3de95172012-05-07 18:03:15 +02005516 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005517 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005518
Takashi Iwai1727a772013-01-10 09:52:52 +01005519 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5520 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005521
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005522 /* automatic parse from the BIOS config */
5523 err = alc861_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005524 if (err < 0)
5525 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005526
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005527 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005528 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005529
Takashi Iwai1d045db2011-07-07 18:23:21 +02005530 codec->patch_ops = alc_patch_ops;
Takashi Iwai83012a72012-08-24 18:38:08 +02005531#ifdef CONFIG_PM
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005532 spec->power_hook = alc_power_eapd;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005533#endif
5534
Takashi Iwai1727a772013-01-10 09:52:52 +01005535 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005536
Takashi Iwai1d045db2011-07-07 18:23:21 +02005537 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005538
5539 error:
5540 alc_free(codec);
5541 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005542}
5543
5544/*
5545 * ALC861-VD support
5546 *
5547 * Based on ALC882
5548 *
5549 * In addition, an independent DAC
5550 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005551static int alc861vd_parse_auto_config(struct hda_codec *codec)
5552{
Takashi Iwai1d045db2011-07-07 18:23:21 +02005553 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005554 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5555 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005556}
5557
Takashi Iwai1d045db2011-07-07 18:23:21 +02005558enum {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005559 ALC660VD_FIX_ASUS_GPIO1,
5560 ALC861VD_FIX_DALLAS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005561};
5562
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005563/* exclude VREF80 */
5564static void alc861vd_fixup_dallas(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005565 const struct hda_fixup *fix, int action)
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005566{
Takashi Iwai1727a772013-01-10 09:52:52 +01005567 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaib78562b2012-12-17 20:06:49 +01005568 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
5569 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005570 }
5571}
5572
Takashi Iwai1727a772013-01-10 09:52:52 +01005573static const struct hda_fixup alc861vd_fixups[] = {
Takashi Iwai1d045db2011-07-07 18:23:21 +02005574 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005575 .type = HDA_FIXUP_VERBS,
Takashi Iwai1d045db2011-07-07 18:23:21 +02005576 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005577 /* reset GPIO1 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005578 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5579 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5580 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5581 { }
5582 }
5583 },
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005584 [ALC861VD_FIX_DALLAS] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005585 .type = HDA_FIXUP_FUNC,
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005586 .v.func = alc861vd_fixup_dallas,
5587 },
Takashi Iwai1d045db2011-07-07 18:23:21 +02005588};
5589
5590static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005591 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005592 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
Takashi Iwai8fdcb6f2011-08-23 17:28:55 +02005593 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
Takashi Iwai1d045db2011-07-07 18:23:21 +02005594 {}
5595};
5596
Takashi Iwai1d045db2011-07-07 18:23:21 +02005597/*
5598 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005599static int patch_alc861vd(struct hda_codec *codec)
5600{
5601 struct alc_spec *spec;
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005602 int err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005603
Takashi Iwai3de95172012-05-07 18:03:15 +02005604 err = alc_alloc_spec(codec, 0x0b);
5605 if (err < 0)
5606 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005607
Takashi Iwai3de95172012-05-07 18:03:15 +02005608 spec = codec->spec;
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005609 spec->gen.beep_nid = 0x23;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005610
Takashi Iwai1727a772013-01-10 09:52:52 +01005611 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5612 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005613
Takashi Iwaicb4e4822011-08-23 17:34:25 +02005614 /* automatic parse from the BIOS config */
5615 err = alc861vd_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005616 if (err < 0)
5617 goto error;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005618
Takashi Iwai7504b6c2013-03-18 11:25:51 +01005619 if (!spec->gen.no_analog)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005620 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai1d045db2011-07-07 18:23:21 +02005621
Takashi Iwai1d045db2011-07-07 18:23:21 +02005622 codec->patch_ops = alc_patch_ops;
5623
Takashi Iwai1d045db2011-07-07 18:23:21 +02005624 spec->shutup = alc_eapd_shutup;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005625
Takashi Iwai1727a772013-01-10 09:52:52 +01005626 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01005627
Takashi Iwai1d045db2011-07-07 18:23:21 +02005628 return 0;
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02005629
5630 error:
5631 alc_free(codec);
5632 return err;
Takashi Iwai1d045db2011-07-07 18:23:21 +02005633}
5634
5635/*
5636 * ALC662 support
5637 *
5638 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5639 * configuration. Each pin widget can choose any input DACs and a mixer.
5640 * Each ADC is connected from a mixer of all inputs. This makes possible
5641 * 6-channel independent captures.
5642 *
5643 * In addition, an independent DAC for the multi-playback (not used in this
5644 * driver yet).
5645 */
Takashi Iwai1d045db2011-07-07 18:23:21 +02005646
5647/*
5648 * BIOS auto configuration
5649 */
5650
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005651static int alc662_parse_auto_config(struct hda_codec *codec)
5652{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005653 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005654 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5655 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5656 const hda_nid_t *ssids;
Takashi Iwaiee979a142008-09-02 15:42:20 +02005657
Kailang Yang6227cdc2010-02-25 08:36:52 +01005658 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Rainer Koenig1d87caa2013-04-04 08:40:38 +02005659 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
5660 codec->vendor_id == 0x10ec0671)
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005661 ssids = alc663_ssids;
Kailang Yang6227cdc2010-02-25 08:36:52 +01005662 else
Takashi Iwai3e6179b2011-07-08 16:55:13 +02005663 ssids = alc662_ssids;
5664 return alc_parse_auto_config(codec, alc662_ignore, ssids);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005665}
5666
Todd Broch6be79482010-12-07 16:51:05 -08005667static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwai1727a772013-01-10 09:52:52 +01005668 const struct hda_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01005669{
Takashi Iwai9bb1f062013-01-10 17:14:29 +01005670 if (action != HDA_FIXUP_ACT_PRE_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +01005671 return;
Todd Broch6be79482010-12-07 16:51:05 -08005672 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5673 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5674 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5675 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5676 (0 << AC_AMPCAP_MUTE_SHIFT)))
Takashi Iwai4e76a882014-02-25 12:21:03 +01005677 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
Todd Broch6be79482010-12-07 16:51:05 -08005678}
5679
Takashi Iwai8e383952013-10-30 17:41:12 +01005680static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
5681 { .channels = 2,
5682 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
5683 { .channels = 4,
5684 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
5685 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
5686 { }
5687};
5688
5689/* override the 2.1 chmap */
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01005690static void alc_fixup_bass_chmap(struct hda_codec *codec,
Takashi Iwai8e383952013-10-30 17:41:12 +01005691 const struct hda_fixup *fix, int action)
5692{
5693 if (action == HDA_FIXUP_ACT_BUILD) {
5694 struct alc_spec *spec = codec->spec;
5695 spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps;
5696 }
5697}
5698
Takashi Iwai3e887f32014-01-10 17:50:58 +01005699/* turn on/off mute LED per vmaster hook */
5700static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
5701{
5702 struct hda_codec *codec = private_data;
5703 struct alc_spec *spec = codec->spec;
5704 unsigned int oldval = spec->gpio_led;
5705
5706 if (enabled)
Takashi Iwai3e887f32014-01-10 17:50:58 +01005707 spec->gpio_led |= 0x01;
Takashi Iwaib1974f92014-10-20 11:26:57 +02005708 else
5709 spec->gpio_led &= ~0x01;
Takashi Iwai3e887f32014-01-10 17:50:58 +01005710 if (spec->gpio_led != oldval)
5711 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5712 spec->gpio_led);
5713}
5714
Takashi Iwaibf686652014-01-13 16:18:25 +01005715/* avoid D3 for keeping GPIO up */
5716static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5717 hda_nid_t nid,
5718 unsigned int power_state)
5719{
5720 struct alc_spec *spec = codec->spec;
5721 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5722 return AC_PWRST_D0;
5723 return power_state;
5724}
5725
Takashi Iwai3e887f32014-01-10 17:50:58 +01005726static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5727 const struct hda_fixup *fix, int action)
5728{
5729 struct alc_spec *spec = codec->spec;
5730 static const struct hda_verb gpio_init[] = {
5731 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
5732 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
5733 {}
5734 };
5735
5736 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5737 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
5738 spec->gpio_led = 0;
5739 snd_hda_add_verbs(codec, gpio_init);
Takashi Iwaibf686652014-01-13 16:18:25 +01005740 codec->power_filter = gpio_led_power_filter;
Takashi Iwai3e887f32014-01-10 17:50:58 +01005741 }
5742}
5743
Kailang Yangf3f91852014-10-24 15:43:46 +08005744static struct coef_fw alc668_coefs[] = {
5745 WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0),
5746 WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80),
5747 WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b, 0x0),
5748 WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
5749 WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
5750 WRITE_COEF(0x13, 0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
5751 WRITE_COEF(0x19, 0x0), WRITE_COEF(0x1a, 0x0), WRITE_COEF(0x1b, 0x0),
5752 WRITE_COEF(0x1c, 0x0), WRITE_COEF(0x1d, 0x0), WRITE_COEF(0x1e, 0x7418),
5753 WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
5754 WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
5755 WRITE_COEF(0x27, 0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
5756 WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
5757 WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac, 0x0),
5758 WRITE_COEF(0xad, 0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
5759 WRITE_COEF(0xb0, 0x0), WRITE_COEF(0xb1, 0x0), WRITE_COEF(0xb2, 0x0),
5760 WRITE_COEF(0xb3, 0x0), WRITE_COEF(0xb4, 0x0), WRITE_COEF(0xb5, 0x1040),
5761 WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
5762 WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
5763 WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
5764 WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
5765 {}
5766};
5767
5768static void alc668_restore_default_value(struct hda_codec *codec)
5769{
5770 alc_process_coef_fw(codec, alc668_coefs);
5771}
5772
David Henningsson6cb3b702010-09-09 08:51:44 +02005773enum {
Daniel T Chen2df03512010-10-10 22:39:28 -04005774 ALC662_FIXUP_ASPIRE,
Takashi Iwai3e887f32014-01-10 17:50:58 +01005775 ALC662_FIXUP_LED_GPIO1,
David Henningsson6cb3b702010-09-09 08:51:44 +02005776 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -08005777 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005778 ALC662_FIXUP_CZC_P10T,
David Henningsson94024cd2011-04-29 14:10:55 +02005779 ALC662_FIXUP_SKU_IGNORE,
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005780 ALC662_FIXUP_HP_RP5800,
Takashi Iwai53c334a2011-08-23 18:27:14 +02005781 ALC662_FIXUP_ASUS_MODE1,
5782 ALC662_FIXUP_ASUS_MODE2,
5783 ALC662_FIXUP_ASUS_MODE3,
5784 ALC662_FIXUP_ASUS_MODE4,
5785 ALC662_FIXUP_ASUS_MODE5,
5786 ALC662_FIXUP_ASUS_MODE6,
5787 ALC662_FIXUP_ASUS_MODE7,
5788 ALC662_FIXUP_ASUS_MODE8,
Takashi Iwai1565cc32012-02-13 12:03:25 +01005789 ALC662_FIXUP_NO_JACK_DETECT,
David Henningssonedfe3bf2012-06-12 13:15:12 +02005790 ALC662_FIXUP_ZOTAC_Z68,
Takashi Iwai125821a2012-06-22 14:30:29 +02005791 ALC662_FIXUP_INV_DMIC,
David Henningsson73bdd592013-04-15 15:44:14 +02005792 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
5793 ALC668_FIXUP_HEADSET_MODE,
David Henningsson8e54b4a2014-02-07 09:31:07 +01005794 ALC662_FIXUP_BASS_MODE4_CHMAP,
David Henningsson61a75f12014-02-07 09:31:08 +01005795 ALC662_FIXUP_BASS_16,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01005796 ALC662_FIXUP_BASS_1A,
David Henningsson8e54b4a2014-02-07 09:31:07 +01005797 ALC662_FIXUP_BASS_CHMAP,
Hui Wang493a52a2014-01-14 14:07:36 +08005798 ALC668_FIXUP_AUTO_MUTE,
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02005799 ALC668_FIXUP_DELL_DISABLE_AAMIX,
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02005800 ALC668_FIXUP_DELL_XPS13,
David Henningsson6cb3b702010-09-09 08:51:44 +02005801};
5802
Takashi Iwai1727a772013-01-10 09:52:52 +01005803static const struct hda_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -04005804 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005805 .type = HDA_FIXUP_PINS,
5806 .v.pins = (const struct hda_pintbl[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -04005807 { 0x15, 0x99130112 }, /* subwoofer */
5808 { }
5809 }
5810 },
Takashi Iwai3e887f32014-01-10 17:50:58 +01005811 [ALC662_FIXUP_LED_GPIO1] = {
5812 .type = HDA_FIXUP_FUNC,
5813 .v.func = alc662_fixup_led_gpio1,
5814 },
David Henningsson6cb3b702010-09-09 08:51:44 +02005815 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005816 .type = HDA_FIXUP_PINS,
5817 .v.pins = (const struct hda_pintbl[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +02005818 { 0x17, 0x99130112 }, /* subwoofer */
5819 { }
Takashi Iwai3e887f32014-01-10 17:50:58 +01005820 },
5821 .chained = true,
5822 .chain_id = ALC662_FIXUP_LED_GPIO1,
David Henningsson6cb3b702010-09-09 08:51:44 +02005823 },
Todd Broch6be79482010-12-07 16:51:05 -08005824 [ALC272_FIXUP_MARIO] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005825 .type = HDA_FIXUP_FUNC,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01005826 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005827 },
5828 [ALC662_FIXUP_CZC_P10T] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005829 .type = HDA_FIXUP_VERBS,
Anisse Astierd2ebd472011-01-20 12:36:21 +01005830 .v.verbs = (const struct hda_verb[]) {
5831 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5832 {}
5833 }
5834 },
David Henningsson94024cd2011-04-29 14:10:55 +02005835 [ALC662_FIXUP_SKU_IGNORE] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005836 .type = HDA_FIXUP_FUNC,
Takashi Iwai23d30f22012-05-07 17:17:32 +02005837 .v.func = alc_fixup_sku_ignore,
Takashi Iwaic6b35872011-03-28 12:05:31 +02005838 },
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005839 [ALC662_FIXUP_HP_RP5800] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005840 .type = HDA_FIXUP_PINS,
5841 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02005842 { 0x14, 0x0221201f }, /* HP out */
5843 { }
5844 },
5845 .chained = true,
5846 .chain_id = ALC662_FIXUP_SKU_IGNORE
5847 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02005848 [ALC662_FIXUP_ASUS_MODE1] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005849 .type = HDA_FIXUP_PINS,
5850 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005851 { 0x14, 0x99130110 }, /* speaker */
5852 { 0x18, 0x01a19c20 }, /* mic */
5853 { 0x19, 0x99a3092f }, /* int-mic */
5854 { 0x21, 0x0121401f }, /* HP out */
5855 { }
5856 },
5857 .chained = true,
5858 .chain_id = ALC662_FIXUP_SKU_IGNORE
5859 },
5860 [ALC662_FIXUP_ASUS_MODE2] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005861 .type = HDA_FIXUP_PINS,
5862 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai2996bdb2011-08-18 16:02:24 +02005863 { 0x14, 0x99130110 }, /* speaker */
5864 { 0x18, 0x01a19820 }, /* mic */
5865 { 0x19, 0x99a3092f }, /* int-mic */
5866 { 0x1b, 0x0121401f }, /* HP out */
5867 { }
5868 },
Takashi Iwai53c334a2011-08-23 18:27:14 +02005869 .chained = true,
5870 .chain_id = ALC662_FIXUP_SKU_IGNORE
5871 },
5872 [ALC662_FIXUP_ASUS_MODE3] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005873 .type = HDA_FIXUP_PINS,
5874 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005875 { 0x14, 0x99130110 }, /* speaker */
5876 { 0x15, 0x0121441f }, /* HP */
5877 { 0x18, 0x01a19840 }, /* mic */
5878 { 0x19, 0x99a3094f }, /* int-mic */
5879 { 0x21, 0x01211420 }, /* HP2 */
5880 { }
5881 },
5882 .chained = true,
5883 .chain_id = ALC662_FIXUP_SKU_IGNORE
5884 },
5885 [ALC662_FIXUP_ASUS_MODE4] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005886 .type = HDA_FIXUP_PINS,
5887 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005888 { 0x14, 0x99130110 }, /* speaker */
5889 { 0x16, 0x99130111 }, /* speaker */
5890 { 0x18, 0x01a19840 }, /* mic */
5891 { 0x19, 0x99a3094f }, /* int-mic */
5892 { 0x21, 0x0121441f }, /* HP */
5893 { }
5894 },
5895 .chained = true,
5896 .chain_id = ALC662_FIXUP_SKU_IGNORE
5897 },
5898 [ALC662_FIXUP_ASUS_MODE5] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005899 .type = HDA_FIXUP_PINS,
5900 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005901 { 0x14, 0x99130110 }, /* speaker */
5902 { 0x15, 0x0121441f }, /* HP */
5903 { 0x16, 0x99130111 }, /* speaker */
5904 { 0x18, 0x01a19840 }, /* mic */
5905 { 0x19, 0x99a3094f }, /* int-mic */
5906 { }
5907 },
5908 .chained = true,
5909 .chain_id = ALC662_FIXUP_SKU_IGNORE
5910 },
5911 [ALC662_FIXUP_ASUS_MODE6] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005912 .type = HDA_FIXUP_PINS,
5913 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005914 { 0x14, 0x99130110 }, /* speaker */
5915 { 0x15, 0x01211420 }, /* HP2 */
5916 { 0x18, 0x01a19840 }, /* mic */
5917 { 0x19, 0x99a3094f }, /* int-mic */
5918 { 0x1b, 0x0121441f }, /* HP */
5919 { }
5920 },
5921 .chained = true,
5922 .chain_id = ALC662_FIXUP_SKU_IGNORE
5923 },
5924 [ALC662_FIXUP_ASUS_MODE7] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005925 .type = HDA_FIXUP_PINS,
5926 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005927 { 0x14, 0x99130110 }, /* speaker */
5928 { 0x17, 0x99130111 }, /* speaker */
5929 { 0x18, 0x01a19840 }, /* mic */
5930 { 0x19, 0x99a3094f }, /* int-mic */
5931 { 0x1b, 0x01214020 }, /* HP */
5932 { 0x21, 0x0121401f }, /* HP */
5933 { }
5934 },
5935 .chained = true,
5936 .chain_id = ALC662_FIXUP_SKU_IGNORE
5937 },
5938 [ALC662_FIXUP_ASUS_MODE8] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005939 .type = HDA_FIXUP_PINS,
5940 .v.pins = (const struct hda_pintbl[]) {
Takashi Iwai53c334a2011-08-23 18:27:14 +02005941 { 0x14, 0x99130110 }, /* speaker */
5942 { 0x12, 0x99a30970 }, /* int-mic */
5943 { 0x15, 0x01214020 }, /* HP */
5944 { 0x17, 0x99130111 }, /* speaker */
5945 { 0x18, 0x01a19840 }, /* mic */
5946 { 0x21, 0x0121401f }, /* HP */
5947 { }
5948 },
5949 .chained = true,
5950 .chain_id = ALC662_FIXUP_SKU_IGNORE
Takashi Iwai2996bdb2011-08-18 16:02:24 +02005951 },
Takashi Iwai1565cc32012-02-13 12:03:25 +01005952 [ALC662_FIXUP_NO_JACK_DETECT] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005953 .type = HDA_FIXUP_FUNC,
Takashi Iwai1565cc32012-02-13 12:03:25 +01005954 .v.func = alc_fixup_no_jack_detect,
5955 },
David Henningssonedfe3bf2012-06-12 13:15:12 +02005956 [ALC662_FIXUP_ZOTAC_Z68] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005957 .type = HDA_FIXUP_PINS,
5958 .v.pins = (const struct hda_pintbl[]) {
David Henningssonedfe3bf2012-06-12 13:15:12 +02005959 { 0x1b, 0x02214020 }, /* Front HP */
5960 { }
5961 }
5962 },
Takashi Iwai125821a2012-06-22 14:30:29 +02005963 [ALC662_FIXUP_INV_DMIC] = {
Takashi Iwai1727a772013-01-10 09:52:52 +01005964 .type = HDA_FIXUP_FUNC,
David Henningsson9d36a7d2014-10-07 10:18:42 +02005965 .v.func = alc_fixup_inv_dmic,
Takashi Iwai125821a2012-06-22 14:30:29 +02005966 },
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02005967 [ALC668_FIXUP_DELL_XPS13] = {
5968 .type = HDA_FIXUP_FUNC,
5969 .v.func = alc_fixup_dell_xps13,
5970 .chained = true,
5971 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
5972 },
Gabriele Mazzotta5e6db662014-05-20 18:58:26 +02005973 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
5974 .type = HDA_FIXUP_FUNC,
5975 .v.func = alc_fixup_disable_aamix,
5976 .chained = true,
5977 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5978 },
Hui Wang493a52a2014-01-14 14:07:36 +08005979 [ALC668_FIXUP_AUTO_MUTE] = {
5980 .type = HDA_FIXUP_FUNC,
5981 .v.func = alc_fixup_auto_mute_via_amp,
5982 .chained = true,
5983 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5984 },
David Henningsson73bdd592013-04-15 15:44:14 +02005985 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
5986 .type = HDA_FIXUP_PINS,
5987 .v.pins = (const struct hda_pintbl[]) {
5988 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
5989 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
5990 { }
5991 },
5992 .chained = true,
5993 .chain_id = ALC668_FIXUP_HEADSET_MODE
5994 },
5995 [ALC668_FIXUP_HEADSET_MODE] = {
5996 .type = HDA_FIXUP_FUNC,
5997 .v.func = alc_fixup_headset_mode_alc668,
5998 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01005999 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
Takashi Iwai8e383952013-10-30 17:41:12 +01006000 .type = HDA_FIXUP_FUNC,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01006001 .v.func = alc_fixup_bass_chmap,
Takashi Iwai8e383952013-10-30 17:41:12 +01006002 .chained = true,
6003 .chain_id = ALC662_FIXUP_ASUS_MODE4
6004 },
David Henningsson61a75f12014-02-07 09:31:08 +01006005 [ALC662_FIXUP_BASS_16] = {
6006 .type = HDA_FIXUP_PINS,
6007 .v.pins = (const struct hda_pintbl[]) {
6008 {0x16, 0x80106111}, /* bass speaker */
6009 {}
6010 },
6011 .chained = true,
6012 .chain_id = ALC662_FIXUP_BASS_CHMAP,
6013 },
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006014 [ALC662_FIXUP_BASS_1A] = {
6015 .type = HDA_FIXUP_PINS,
6016 .v.pins = (const struct hda_pintbl[]) {
6017 {0x1a, 0x80106111}, /* bass speaker */
6018 {}
6019 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01006020 .chained = true,
6021 .chain_id = ALC662_FIXUP_BASS_CHMAP,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006022 },
David Henningsson8e54b4a2014-02-07 09:31:07 +01006023 [ALC662_FIXUP_BASS_CHMAP] = {
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006024 .type = HDA_FIXUP_FUNC,
Takashi Iwaieb9ca3a2013-11-28 15:24:34 +01006025 .v.func = alc_fixup_bass_chmap,
Takashi Iwaia30c9aa2013-11-21 08:00:20 +01006026 },
David Henningsson6cb3b702010-09-09 08:51:44 +02006027};
6028
Takashi Iwaia9111322011-05-02 11:30:18 +02006029static const struct snd_pci_quirk alc662_fixup_tbl[] = {
Takashi Iwai53c334a2011-08-23 18:27:14 +02006030 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
Takashi Iwaid3d38352013-08-19 20:05:50 +02006031 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
David Henningssona6c47a82011-02-10 15:39:19 +01006032 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
David Henningsson94024cd2011-04-29 14:10:55 +02006033 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
Takashi Iwai125821a2012-06-22 14:30:29 +02006034 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
Takashi Iwai18019282013-08-16 08:17:05 +02006035 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
Daniel T Chen2df03512010-10-10 22:39:28 -04006036 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
David Henningsson73bdd592013-04-15 15:44:14 +02006037 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6038 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Takashi Iwaic5d019c2014-07-22 17:33:32 +02006039 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
Gabriele Mazzotta033b0a72014-05-26 17:11:46 +02006040 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
David Henningsson09d20142013-11-20 11:43:30 +01006041 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
David Henningssonad8ff99e2013-11-07 09:28:59 +01006042 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Kailang Yang8dc9abb2014-04-16 15:53:12 +08006043 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6044 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Kailang Yang6a98e342014-10-27 16:20:30 +08006045 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
Takashi Iwaie59ea3e2011-06-29 17:21:00 +02006046 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
David Henningsson8e54b4a2014-02-07 09:31:07 +01006047 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
6048 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
David Henningsson61a75f12014-02-07 09:31:08 +01006049 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
6050 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
David Henningsson8e54b4a2014-02-07 09:31:07 +01006051 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
Takashi Iwai1565cc32012-02-13 12:03:25 +01006052 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
Takashi Iwai53c334a2011-08-23 18:27:14 +02006053 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
Daniel T Chena0e90ac2010-11-20 10:20:35 -05006054 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +06006055 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +02006056 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
David Henningssonedfe3bf2012-06-12 13:15:12 +02006057 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
Anisse Astierd2ebd472011-01-20 12:36:21 +01006058 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
Takashi Iwai53c334a2011-08-23 18:27:14 +02006059
6060#if 0
6061 /* Below is a quirk table taken from the old code.
6062 * Basically the device should work as is without the fixup table.
6063 * If BIOS doesn't give a proper info, enable the corresponding
6064 * fixup entry.
Jesper Juhl7d7eb9e2012-04-12 22:11:25 +02006065 */
Takashi Iwai53c334a2011-08-23 18:27:14 +02006066 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6067 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6068 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6069 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6070 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6071 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6072 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6073 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6074 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6075 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6076 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6077 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6078 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6079 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6080 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6081 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6082 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6083 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6084 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6085 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6086 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6087 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6088 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6089 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6090 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6091 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6092 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6093 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6094 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6095 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6096 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6097 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6098 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6099 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6100 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6101 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6102 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6103 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6104 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6105 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6106 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6107 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6108 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6109 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6110 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6111 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6112 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6113 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6114 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6115 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6116#endif
David Henningsson6cb3b702010-09-09 08:51:44 +02006117 {}
6118};
6119
Takashi Iwai1727a772013-01-10 09:52:52 +01006120static const struct hda_model_fixup alc662_fixup_models[] = {
Todd Broch6be79482010-12-07 16:51:05 -08006121 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
Takashi Iwai53c334a2011-08-23 18:27:14 +02006122 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6123 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6124 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6125 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6126 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6127 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6128 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6129 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
Takashi Iwai6e72aa52012-06-25 10:52:25 +02006130 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
David Henningssone32aa852013-06-17 11:04:02 +02006131 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
Todd Broch6be79482010-12-07 16:51:05 -08006132 {}
6133};
David Henningsson6cb3b702010-09-09 08:51:44 +02006134
Hui Wang532895c2014-05-29 15:59:19 +08006135static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
David Henningsson76c21322014-06-24 14:46:54 +02006136 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6137 {0x12, 0x99a30130},
6138 {0x14, 0x90170110},
6139 {0x15, 0x0321101f},
6140 {0x16, 0x03011020},
6141 {0x18, 0x40000008},
6142 {0x19, 0x411111f0},
6143 {0x1a, 0x411111f0},
6144 {0x1b, 0x411111f0},
6145 {0x1d, 0x41000001},
6146 {0x1e, 0x411111f0},
6147 {0x1f, 0x411111f0}),
6148 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6149 {0x12, 0x99a30140},
6150 {0x14, 0x90170110},
6151 {0x15, 0x0321101f},
6152 {0x16, 0x03011020},
6153 {0x18, 0x40000008},
6154 {0x19, 0x411111f0},
6155 {0x1a, 0x411111f0},
6156 {0x1b, 0x411111f0},
6157 {0x1d, 0x41000001},
6158 {0x1e, 0x411111f0},
6159 {0x1f, 0x411111f0}),
6160 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6161 {0x12, 0x99a30150},
6162 {0x14, 0x90170110},
6163 {0x15, 0x0321101f},
6164 {0x16, 0x03011020},
6165 {0x18, 0x40000008},
6166 {0x19, 0x411111f0},
6167 {0x1a, 0x411111f0},
6168 {0x1b, 0x411111f0},
6169 {0x1d, 0x41000001},
6170 {0x1e, 0x411111f0},
6171 {0x1f, 0x411111f0}),
6172 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
6173 {0x12, 0x411111f0},
6174 {0x14, 0x90170110},
6175 {0x15, 0x0321101f},
6176 {0x16, 0x03011020},
6177 {0x18, 0x40000008},
6178 {0x19, 0x411111f0},
6179 {0x1a, 0x411111f0},
6180 {0x1b, 0x411111f0},
6181 {0x1d, 0x41000001},
6182 {0x1e, 0x411111f0},
6183 {0x1f, 0x411111f0}),
6184 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
6185 {0x12, 0x90a60130},
6186 {0x14, 0x90170110},
6187 {0x15, 0x0321101f},
6188 {0x16, 0x40000000},
6189 {0x18, 0x411111f0},
6190 {0x19, 0x411111f0},
6191 {0x1a, 0x411111f0},
6192 {0x1b, 0x411111f0},
6193 {0x1d, 0x40d6832d},
6194 {0x1e, 0x411111f0},
6195 {0x1f, 0x411111f0}),
Hui Wang532895c2014-05-29 15:59:19 +08006196 {}
6197};
6198
Takashi Iwai1d045db2011-07-07 18:23:21 +02006199/*
6200 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006201static int patch_alc662(struct hda_codec *codec)
6202{
6203 struct alc_spec *spec;
Takashi Iwai3de95172012-05-07 18:03:15 +02006204 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006205
Takashi Iwai3de95172012-05-07 18:03:15 +02006206 err = alc_alloc_spec(codec, 0x0b);
6207 if (err < 0)
6208 return err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006209
Takashi Iwai3de95172012-05-07 18:03:15 +02006210 spec = codec->spec;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006211
Takashi Iwai53c334a2011-08-23 18:27:14 +02006212 /* handle multiple HPs as is */
6213 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6214
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02006215 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6216
Kailang Yangf3f91852014-10-24 15:43:46 +08006217 switch (codec->vendor_id) {
6218 case 0x10ec0668:
6219 spec->init_hook = alc668_restore_default_value;
6220 break;
Kailang Yangf3f91852014-10-24 15:43:46 +08006221 }
Kailang Yang8663ff72012-06-29 09:35:52 +02006222
Takashi Iwai1727a772013-01-10 09:52:52 +01006223 snd_hda_pick_fixup(codec, alc662_fixup_models,
Takashi Iwai8e5a0502012-06-21 15:49:33 +02006224 alc662_fixup_tbl, alc662_fixups);
Hui Wang532895c2014-05-29 15:59:19 +08006225 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
Takashi Iwai1727a772013-01-10 09:52:52 +01006226 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai8e5a0502012-06-21 15:49:33 +02006227
6228 alc_auto_parse_customize_define(codec);
6229
Takashi Iwai7504b6c2013-03-18 11:25:51 +01006230 if (has_cdefine_beep(codec))
6231 spec->gen.beep_nid = 0x01;
6232
Takashi Iwai1bb7e432011-10-17 16:50:59 +02006233 if ((alc_get_coef0(codec) & (1 << 14)) &&
Takashi Iwai5100cd02014-02-15 10:03:19 +01006234 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006235 spec->cdefine.platform_type == 1) {
Wei Yongjun6134b1a2013-04-18 11:12:59 +08006236 err = alc_codec_rename(codec, "ALC272X");
6237 if (err < 0)
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006238 goto error;
Takashi Iwai20ca0c32011-10-17 16:00:35 +02006239 }
Kailang Yang274693f2009-12-03 10:07:50 +01006240
Takashi Iwaib9c51062011-08-24 18:08:07 +02006241 /* automatic parse from the BIOS config */
6242 err = alc662_parse_auto_config(codec);
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006243 if (err < 0)
6244 goto error;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006245
Takashi Iwai7504b6c2013-03-18 11:25:51 +01006246 if (!spec->gen.no_analog && spec->gen.beep_nid) {
Kailang Yangda00c242010-03-19 11:23:45 +01006247 switch (codec->vendor_id) {
6248 case 0x10ec0662:
6249 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6250 break;
6251 case 0x10ec0272:
6252 case 0x10ec0663:
6253 case 0x10ec0665:
Kailang Yang9ad54542013-11-26 15:41:40 +08006254 case 0x10ec0668:
Kailang Yangda00c242010-03-19 11:23:45 +01006255 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6256 break;
6257 case 0x10ec0273:
6258 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6259 break;
6260 }
Kailang Yangcec27c82010-02-04 14:18:18 +01006261 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01006262
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006263 codec->patch_ops = alc_patch_ops;
Takashi Iwai1c7161532011-04-07 10:37:16 +02006264 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +02006265
Takashi Iwai1727a772013-01-10 09:52:52 +01006266 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwai589876e2012-02-20 15:47:55 +01006267
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006268 return 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006269
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006270 error:
6271 alc_free(codec);
6272 return err;
Kailang Yangb478b992011-05-18 11:51:15 +02006273}
6274
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006275/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006276 * ALC680 support
6277 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006278
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006279static int alc680_parse_auto_config(struct hda_codec *codec)
6280{
Takashi Iwai3e6179b2011-07-08 16:55:13 +02006281 return alc_parse_auto_config(codec, NULL, NULL);
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006282}
6283
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006284/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006285 */
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006286static int patch_alc680(struct hda_codec *codec)
6287{
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006288 int err;
6289
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006290 /* ALC680 has no aa-loopback mixer */
Takashi Iwai3de95172012-05-07 18:03:15 +02006291 err = alc_alloc_spec(codec, 0);
6292 if (err < 0)
6293 return err;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02006294
Takashi Iwai1ebec5f2011-08-15 13:21:48 +02006295 /* automatic parse from the BIOS config */
6296 err = alc680_parse_auto_config(codec);
6297 if (err < 0) {
6298 alc_free(codec);
6299 return err;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006300 }
6301
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006302 codec->patch_ops = alc_patch_ops;
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006303
6304 return 0;
6305}
6306
6307/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006308 * patch entries
6309 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006310static const struct hda_codec_preset snd_hda_preset_realtek[] = {
Kailang Yang296f0332011-05-18 11:52:36 +02006311 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
Kailang Yangba4c4d02013-11-26 15:17:50 +08006312 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
Kailang Yang84dfd0a2013-03-07 09:19:38 +01006313 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
Kailang Yang92f974d2014-06-06 17:05:33 +08006314 { .id = 0x10ec0235, .name = "ALC233", .patch = patch_alc269 },
Kailang Yang1d04c9d2013-10-24 11:35:18 +02006315 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006316 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006317 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +01006318 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +02006319 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +01006320 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01006321 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +02006322 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +01006323 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Kailang Yang296f0332011-05-18 11:52:36 +02006324 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
David Henningssonbefae822012-06-25 19:49:28 +02006325 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
David Henningsson4e01ec62012-07-18 07:38:46 +02006326 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02006327 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
Kailang Yang065380f2013-01-10 10:25:48 +01006328 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
Kailang Yang161ebf22013-10-24 11:36:33 +02006329 { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
Kailang Yang7fc7d042013-04-25 11:04:43 +02006330 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
Kailang Yang7c665932014-04-14 15:09:44 +08006331 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
Kailang Yang7ff34ad2012-10-06 17:02:30 +02006332 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
David Henningssonaf02dde2012-11-21 08:57:58 +01006333 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
Kailang Yang161ebf22013-10-24 11:36:33 +02006334 { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006335 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006336 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006337 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6338 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6339 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006340 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006341 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006342 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6343 .patch = patch_alc662 },
David Henningssoncc667a72011-10-18 14:07:51 +02006344 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6345 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +02006346 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +01006347 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang72009432014-06-06 16:51:18 +08006348 { .id = 0x10ec0667, .name = "ALC667", .patch = patch_alc662 },
Kailang Yang19a62822012-11-08 10:25:37 +01006349 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +01006350 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Rainer Koenig1d87caa2013-04-04 08:40:38 +02006351 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +02006352 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Kailang Yangb6c5fba2014-06-05 11:13:44 +08006353 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01006354 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006355 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006356 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +02006357 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006358 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +02006359 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006360 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006361 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006362 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +02006363 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +02006364 .patch = patch_alc882 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006365 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006366 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +01006367 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Takashi Iwaie16fb6d2011-10-17 16:39:09 +02006368 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
Kailang Yang19a62822012-11-08 10:25:37 +01006369 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006370 {} /* terminator */
6371};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006372
6373MODULE_ALIAS("snd-hda-codec-id:10ec*");
6374
6375MODULE_LICENSE("GPL");
6376MODULE_DESCRIPTION("Realtek HD-audio codec");
6377
6378static struct hda_codec_preset_list realtek_list = {
6379 .preset = snd_hda_preset_realtek,
6380 .owner = THIS_MODULE,
6381};
6382
6383static int __init patch_realtek_init(void)
6384{
6385 return snd_hda_add_codec_preset(&realtek_list);
6386}
6387
6388static void __exit patch_realtek_exit(void)
6389{
6390 snd_hda_delete_codec_preset(&realtek_list);
6391}
6392
6393module_init(patch_realtek_init)
6394module_exit(patch_realtek_exit)