blob: f1fa1d2493698da5796cb080654327cf0e5fcf0f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
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 Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
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>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020076 ALC260_WILL,
77 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010078#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020082 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Kailang Yangdf694da2005-12-05 19:42:22 +010085/* ALC262 models */
86enum {
87 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020088 ALC262_HIPPO,
89 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010090 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020091 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010092 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010094 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010095 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020096 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020097 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020098 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +020099 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
Kailang Yanga361d842007-06-05 12:30:55 +0200104/* ALC268 models */
105enum {
106 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200107 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200108 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100109 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100110 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100111#ifdef CONFIG_SND_DEBUG
112 ALC268_TEST,
113#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_AUTO,
115 ALC268_MODEL_LAST /* last tag */
116};
117
Kailang Yangf6a92242007-12-13 16:52:54 +0100118/* ALC269 models */
119enum {
120 ALC269_BASIC,
121 ALC269_AUTO,
122 ALC269_MODEL_LAST /* last tag */
123};
124
Kailang Yangdf694da2005-12-05 19:42:22 +0100125/* ALC861 models */
126enum {
127 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200128 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100129 ALC861_3ST_DIG,
130 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200131 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200132 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200133 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100134 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100135 ALC861_AUTO,
136 ALC861_MODEL_LAST,
137};
138
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100139/* ALC861-VD models */
140enum {
141 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200142 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100143 ALC861VD_3ST,
144 ALC861VD_3ST_DIG,
145 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200146 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200147 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200148 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100149 ALC861VD_AUTO,
150 ALC861VD_MODEL_LAST,
151};
152
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200153/* ALC662 models */
154enum {
155 ALC662_3ST_2ch_DIG,
156 ALC662_3ST_6ch_DIG,
157 ALC662_3ST_6ch,
158 ALC662_5ST_DIG,
159 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200160 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100161 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200162 ALC662_AUTO,
163 ALC662_MODEL_LAST,
164};
165
Kailang Yangdf694da2005-12-05 19:42:22 +0100166/* ALC882 models */
167enum {
168 ALC882_3ST_DIG,
169 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200170 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200171 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200172 ALC882_TARGA,
173 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200174 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100175 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200176 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200177 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200178 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100179 ALC882_MODEL_LAST,
180};
181
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200182/* ALC883 models */
183enum {
184 ALC883_3ST_2ch_DIG,
185 ALC883_3ST_6ch_DIG,
186 ALC883_3ST_6ch,
187 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200188 ALC883_TARGA_DIG,
189 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200190 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200191 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200192 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200193 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100194 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200195 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200196 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200197 ALC888_LENOVO_MS7195_DIG,
198 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200199 ALC888_6ST_HP,
200 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100201 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100202 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200203 ALC883_AUTO,
204 ALC883_MODEL_LAST,
205};
206
Kailang Yangdf694da2005-12-05 19:42:22 +0100207/* for GPIO Poll */
208#define GPIO_MASK 0x03
209
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210struct alc_spec {
211 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 unsigned int num_mixers;
214
Kailang Yangdf694da2005-12-05 19:42:22 +0100215 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200216 * don't forget NULL
217 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200218 */
219 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Takashi Iwai16ded522005-06-10 19:58:24 +0200221 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 struct hda_pcm_stream *stream_analog_playback;
223 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100224 struct hda_pcm_stream *stream_analog_alt_playback;
225 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200227 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 struct hda_pcm_stream *stream_digital_playback;
229 struct hda_pcm_stream *stream_digital_capture;
230
231 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200232 struct hda_multi_out multiout; /* playback set-up
233 * max_channels, dacs must be set
234 * dig_out_nid and hp_nid are optional
235 */
Takashi Iwai63300792008-01-24 15:31:36 +0100236 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 /* capture */
239 unsigned int num_adc_nids;
240 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100241 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200242 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200245 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 const struct hda_input_mux *input_mux;
247 unsigned int cur_mux[3];
248
249 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100250 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200252 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100255 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200256
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200257 /* dynamic controls, init_verbs and input_mux */
258 struct auto_pin_cfg autocfg;
259 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100260 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200261 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200262 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100263
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100264 /* hooks */
265 void (*init_hook)(struct hda_codec *codec);
266 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
267
Takashi Iwai834be882006-03-01 14:16:17 +0100268 /* for pin sensing */
269 unsigned int sense_updated: 1;
270 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100271 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200272
Takashi Iwai2134ea42008-01-10 16:53:55 +0100273 /* for virtual master */
274 hda_nid_t vmaster_nid;
275 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200276#ifdef CONFIG_SND_HDA_POWER_SAVE
277 struct hda_loopback_check loopback;
278#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100279};
280
281/*
282 * configuration template - to be copied to the spec instance
283 */
284struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200285 struct snd_kcontrol_new *mixers[5]; /* should be identical size
286 * with spec
287 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100288 const struct hda_verb *init_verbs[5];
289 unsigned int num_dacs;
290 hda_nid_t *dac_nids;
291 hda_nid_t dig_out_nid; /* optional */
292 hda_nid_t hp_nid; /* optional */
293 unsigned int num_adc_nids;
294 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100295 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100296 hda_nid_t dig_in_nid;
297 unsigned int num_channel_mode;
298 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200299 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200300 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100301 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100302 void (*unsol_event)(struct hda_codec *, unsigned int);
303 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200304#ifdef CONFIG_SND_HDA_POWER_SAVE
305 struct hda_amp_list *loopbacks;
306#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307};
308
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310/*
311 * input MUX handling
312 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200313static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
314 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315{
316 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
317 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200318 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
319 if (mux_idx >= spec->num_mux_defs)
320 mux_idx = 0;
321 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322}
323
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200324static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
325 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
328 struct alc_spec *spec = codec->spec;
329 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
330
331 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
332 return 0;
333}
334
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200335static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
336 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337{
338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
339 struct alc_spec *spec = codec->spec;
340 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200341 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100342 hda_nid_t nid = spec->capsrc_nids ?
343 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200344 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100345 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346}
347
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200348
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349/*
350 * channel mode setting
351 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
353 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
356 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100357 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
358 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359}
360
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200361static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
362 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363{
364 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
365 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100366 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200367 spec->num_channel_mode,
368 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200371static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373{
374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
375 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200376 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
377 spec->num_channel_mode,
378 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200379 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200380 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
381 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382}
383
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100385 * Control the mode of pin widget settings via the mixer. "pc" is used
386 * instead of "%" to avoid consequences of accidently treating the % as
387 * being part of a format specifier. Maximum allowed length of a value is
388 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100389 *
390 * Note: some retasking pin complexes seem to ignore requests for input
391 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
392 * are requested. Therefore order this list so that this behaviour will not
393 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200394 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
395 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200396 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100397static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100398 "Mic 50pc bias", "Mic 80pc bias",
399 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100400};
401static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100402 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100403};
404/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200405 * in the pin being assumed to be exclusively an input or an output pin. In
406 * addition, "input" pins may or may not process the mic bias option
407 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
408 * accept requests for bias as of chip versions up to March 2006) and/or
409 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100410 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411#define ALC_PIN_DIR_IN 0x00
412#define ALC_PIN_DIR_OUT 0x01
413#define ALC_PIN_DIR_INOUT 0x02
414#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
415#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200417/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 * For each direction the minimum and maximum values are given.
419 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200420static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421 { 0, 2 }, /* ALC_PIN_DIR_IN */
422 { 3, 4 }, /* ALC_PIN_DIR_OUT */
423 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200424 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
425 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426};
427#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
428#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
429#define alc_pin_mode_n_items(_dir) \
430 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
431
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200432static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200434{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435 unsigned int item_num = uinfo->value.enumerated.item;
436 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
437
438 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200439 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100440 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
441
442 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
443 item_num = alc_pin_mode_min(dir);
444 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200445 return 0;
446}
447
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200450{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100454 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200455 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
457 AC_VERB_GET_PIN_WIDGET_CONTROL,
458 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200459
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100460 /* Find enumerated value for current pinctl setting */
461 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100463 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465 return 0;
466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100470{
471 signed int change;
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 hda_nid_t nid = kcontrol->private_value & 0xffff;
474 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
475 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
477 AC_VERB_GET_PIN_WIDGET_CONTROL,
478 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200480 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 val = alc_pin_mode_min(dir);
482
483 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100484 if (change) {
485 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200486 snd_hda_codec_write_cache(codec, nid, 0,
487 AC_VERB_SET_PIN_WIDGET_CONTROL,
488 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100489
490 /* Also enable the retasking pin's input/output as required
491 * for the requested pin mode. Enum values of 2 or less are
492 * input modes.
493 *
494 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200495 * reduces noise slightly (particularly on input) so we'll
496 * do it. However, having both input and output buffers
497 * enabled simultaneously doesn't seem to be problematic if
498 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100499 */
500 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200501 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
502 HDA_AMP_MUTE, HDA_AMP_MUTE);
503 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
504 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100505 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200506 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
507 HDA_AMP_MUTE, HDA_AMP_MUTE);
508 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
509 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100510 }
511 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200512 return change;
513}
514
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 .info = alc_pin_mode_info, \
518 .get = alc_pin_mode_get, \
519 .put = alc_pin_mode_put, \
520 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100521
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100522/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
523 * together using a mask with more than one bit set. This control is
524 * currently used only by the ALC260 test model. At this stage they are not
525 * needed for any "production" models.
526 */
527#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200528#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200529
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100532{
533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
534 hda_nid_t nid = kcontrol->private_value & 0xffff;
535 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
536 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200537 unsigned int val = snd_hda_codec_read(codec, nid, 0,
538 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100539
540 *valp = (val & mask) != 0;
541 return 0;
542}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100545{
546 signed int change;
547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 hda_nid_t nid = kcontrol->private_value & 0xffff;
549 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
550 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
552 AC_VERB_GET_GPIO_DATA,
553 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100554
555 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
557 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100558 gpio_data &= ~mask;
559 else
560 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200561 snd_hda_codec_write_cache(codec, nid, 0,
562 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100563
564 return change;
565}
566#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
567 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
568 .info = alc_gpio_data_info, \
569 .get = alc_gpio_data_get, \
570 .put = alc_gpio_data_put, \
571 .private_value = nid | (mask<<16) }
572#endif /* CONFIG_SND_DEBUG */
573
Jonathan Woithe92621f12006-02-28 11:47:47 +0100574/* A switch control to allow the enabling of the digital IO pins on the
575 * ALC260. This is incredibly simplistic; the intention of this control is
576 * to provide something in the test model allowing digital outputs to be
577 * identified if present. If models are found which can utilise these
578 * outputs a more complete mixer control can be devised for those models if
579 * necessary.
580 */
581#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200582#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200583
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200584static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
585 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100586{
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 hda_nid_t nid = kcontrol->private_value & 0xffff;
589 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
590 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100592 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100593
594 *valp = (val & mask) != 0;
595 return 0;
596}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100599{
600 signed int change;
601 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
602 hda_nid_t nid = kcontrol->private_value & 0xffff;
603 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
604 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100606 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100608
609 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200610 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100611 if (val==0)
612 ctrl_data &= ~mask;
613 else
614 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200615 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
616 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100617
618 return change;
619}
620#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
621 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
622 .info = alc_spdif_ctrl_info, \
623 .get = alc_spdif_ctrl_get, \
624 .put = alc_spdif_ctrl_put, \
625 .private_value = nid | (mask<<16) }
626#endif /* CONFIG_SND_DEBUG */
627
Jonathan Woithef8225f62008-01-08 12:16:54 +0100628/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
629 * Again, this is only used in the ALC26x test models to help identify when
630 * the EAPD line must be asserted for features to work.
631 */
632#ifdef CONFIG_SND_DEBUG
633#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
634
635static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
637{
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 hda_nid_t nid = kcontrol->private_value & 0xffff;
640 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
641 long *valp = ucontrol->value.integer.value;
642 unsigned int val = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
644
645 *valp = (val & mask) != 0;
646 return 0;
647}
648
649static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_value *ucontrol)
651{
652 int change;
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 hda_nid_t nid = kcontrol->private_value & 0xffff;
655 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
656 long val = *ucontrol->value.integer.value;
657 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
658 AC_VERB_GET_EAPD_BTLENABLE,
659 0x00);
660
661 /* Set/unset the masked control bit(s) as needed */
662 change = (!val ? 0 : mask) != (ctrl_data & mask);
663 if (!val)
664 ctrl_data &= ~mask;
665 else
666 ctrl_data |= mask;
667 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
668 ctrl_data);
669
670 return change;
671}
672
673#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
674 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
675 .info = alc_eapd_ctrl_info, \
676 .get = alc_eapd_ctrl_get, \
677 .put = alc_eapd_ctrl_put, \
678 .private_value = nid | (mask<<16) }
679#endif /* CONFIG_SND_DEBUG */
680
Kailang Yangdf694da2005-12-05 19:42:22 +0100681/*
682 * set up from the preset table
683 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684static void setup_preset(struct alc_spec *spec,
685 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100686{
687 int i;
688
689 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
690 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200691 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
692 i++)
693 spec->init_verbs[spec->num_init_verbs++] =
694 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100695
696 spec->channel_mode = preset->channel_mode;
697 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200698 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100699
700 spec->multiout.max_channels = spec->channel_mode[0].channels;
701
702 spec->multiout.num_dacs = preset->num_dacs;
703 spec->multiout.dac_nids = preset->dac_nids;
704 spec->multiout.dig_out_nid = preset->dig_out_nid;
705 spec->multiout.hp_nid = preset->hp_nid;
706
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200707 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200708 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200709 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100710 spec->input_mux = preset->input_mux;
711
712 spec->num_adc_nids = preset->num_adc_nids;
713 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100714 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100715 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100716
717 spec->unsol_event = preset->unsol_event;
718 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200719#ifdef CONFIG_SND_HDA_POWER_SAVE
720 spec->loopback.amplist = preset->loopbacks;
721#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100722}
723
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200724/* Enable GPIO mask and set output */
725static struct hda_verb alc_gpio1_init_verbs[] = {
726 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
727 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
728 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
729 { }
730};
731
732static struct hda_verb alc_gpio2_init_verbs[] = {
733 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
734 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
735 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
736 { }
737};
738
Kailang Yangbdd148a2007-05-08 15:19:08 +0200739static struct hda_verb alc_gpio3_init_verbs[] = {
740 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
741 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
742 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
743 { }
744};
745
Kailang Yangc9b58002007-10-16 14:30:01 +0200746static void alc_sku_automute(struct hda_codec *codec)
747{
748 struct alc_spec *spec = codec->spec;
749 unsigned int mute;
750 unsigned int present;
751 unsigned int hp_nid = spec->autocfg.hp_pins[0];
752 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
753
754 /* need to execute and sync at first */
755 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
756 present = snd_hda_codec_read(codec, hp_nid, 0,
757 AC_VERB_GET_PIN_SENSE, 0);
758 spec->jack_present = (present & 0x80000000) != 0;
759 if (spec->jack_present) {
760 /* mute internal speaker */
761 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
762 HDA_AMP_MUTE, HDA_AMP_MUTE);
763 } else {
764 /* unmute internal speaker if necessary */
765 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
766 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
767 HDA_AMP_MUTE, mute);
768 }
769}
770
771/* unsolicited event for HP jack sensing */
772static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
773{
774 if (codec->vendor_id == 0x10ec0880)
775 res >>= 28;
776 else
777 res >>= 26;
778 if (res != ALC880_HP_EVENT)
779 return;
780
781 alc_sku_automute(codec);
782}
783
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200784/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
785 * 31 ~ 16 : Manufacture ID
786 * 15 ~ 8 : SKU ID
787 * 7 ~ 0 : Assembly ID
788 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
789 */
790static void alc_subsystem_id(struct hda_codec *codec,
791 unsigned int porta, unsigned int porte,
792 unsigned int portd)
793{
Kailang Yangc9b58002007-10-16 14:30:01 +0200794 unsigned int ass, tmp, i;
795 unsigned nid;
796 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200797
Kailang Yangc9b58002007-10-16 14:30:01 +0200798 ass = codec->subsystem_id & 0xffff;
799 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
800 goto do_sku;
801
802 /*
803 * 31~30 : port conetcivity
804 * 29~21 : reserve
805 * 20 : PCBEEP input
806 * 19~16 : Check sum (15:1)
807 * 15~1 : Custom
808 * 0 : override
809 */
810 nid = 0x1d;
811 if (codec->vendor_id == 0x10ec0260)
812 nid = 0x17;
813 ass = snd_hda_codec_read(codec, nid, 0,
814 AC_VERB_GET_CONFIG_DEFAULT, 0);
815 if (!(ass & 1) && !(ass & 0x100000))
816 return;
817 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200818 return;
819
Kailang Yangc9b58002007-10-16 14:30:01 +0200820 /* check sum */
821 tmp = 0;
822 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100823 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200824 tmp++;
825 }
826 if (((ass >> 16) & 0xf) != tmp)
827 return;
828do_sku:
829 /*
830 * 0 : override
831 * 1 : Swap Jack
832 * 2 : 0 --> Desktop, 1 --> Laptop
833 * 3~5 : External Amplifier control
834 * 7~6 : Reserved
835 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200836 tmp = (ass & 0x38) >> 3; /* external Amp control */
837 switch (tmp) {
838 case 1:
839 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
840 break;
841 case 3:
842 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
843 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200844 case 7:
845 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
846 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200847 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200848 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200849 case 0x10ec0260:
850 snd_hda_codec_write(codec, 0x0f, 0,
851 AC_VERB_SET_EAPD_BTLENABLE, 2);
852 snd_hda_codec_write(codec, 0x10, 0,
853 AC_VERB_SET_EAPD_BTLENABLE, 2);
854 break;
855 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200856 case 0x10ec0267:
857 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200858 case 0x10ec0269:
859 case 0x10ec0862:
860 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200861 snd_hda_codec_write(codec, 0x14, 0,
862 AC_VERB_SET_EAPD_BTLENABLE, 2);
863 snd_hda_codec_write(codec, 0x15, 0,
864 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200865 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200866 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200867 switch (codec->vendor_id) {
868 case 0x10ec0260:
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_COEF_INDEX, 7);
871 tmp = snd_hda_codec_read(codec, 0x1a, 0,
872 AC_VERB_GET_PROC_COEF, 0);
873 snd_hda_codec_write(codec, 0x1a, 0,
874 AC_VERB_SET_COEF_INDEX, 7);
875 snd_hda_codec_write(codec, 0x1a, 0,
876 AC_VERB_SET_PROC_COEF,
877 tmp | 0x2010);
878 break;
879 case 0x10ec0262:
880 case 0x10ec0880:
881 case 0x10ec0882:
882 case 0x10ec0883:
883 case 0x10ec0885:
884 case 0x10ec0888:
885 snd_hda_codec_write(codec, 0x20, 0,
886 AC_VERB_SET_COEF_INDEX, 7);
887 tmp = snd_hda_codec_read(codec, 0x20, 0,
888 AC_VERB_GET_PROC_COEF, 0);
889 snd_hda_codec_write(codec, 0x20, 0,
890 AC_VERB_SET_COEF_INDEX, 7);
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_PROC_COEF,
893 tmp | 0x2010);
894 break;
895 case 0x10ec0267:
896 case 0x10ec0268:
897 snd_hda_codec_write(codec, 0x20, 0,
898 AC_VERB_SET_COEF_INDEX, 7);
899 tmp = snd_hda_codec_read(codec, 0x20, 0,
900 AC_VERB_GET_PROC_COEF, 0);
901 snd_hda_codec_write(codec, 0x20, 0,
902 AC_VERB_SET_COEF_INDEX, 7);
903 snd_hda_codec_write(codec, 0x20, 0,
904 AC_VERB_SET_PROC_COEF,
905 tmp | 0x3000);
906 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200907 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200908 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200909 break;
910 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200911
Kailang Yang8c427222008-01-10 13:03:59 +0100912 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200913 * when the external headphone out jack is plugged"
914 */
Kailang Yang8c427222008-01-10 13:03:59 +0100915 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200916 return;
917 /*
918 * 10~8 : Jack location
919 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
920 * 14~13: Resvered
921 * 15 : 1 --> enable the function "Mute internal speaker
922 * when the external headphone out jack is plugged"
923 */
924 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100925 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200926 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100927 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200928 else
929 return;
930 }
931
932 if (!spec->autocfg.hp_pins[0]) {
933 tmp = (ass >> 11) & 0x3; /* HP to chassis */
934 if (tmp == 0)
935 spec->autocfg.hp_pins[0] = porta;
936 else if (tmp == 1)
937 spec->autocfg.hp_pins[0] = porte;
938 else if (tmp == 2)
939 spec->autocfg.hp_pins[0] = portd;
940 else
941 return;
942 }
943
944 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
945 AC_VERB_SET_UNSOLICITED_ENABLE,
946 AC_USRSP_EN | ALC880_HP_EVENT);
947 spec->unsol_event = alc_sku_unsol_event;
948 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200949}
950
Takashi Iwai41e41f12005-06-08 14:48:49 +0200951/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200952 * Fix-up pin default configurations
953 */
954
955struct alc_pincfg {
956 hda_nid_t nid;
957 u32 val;
958};
959
960static void alc_fix_pincfg(struct hda_codec *codec,
961 const struct snd_pci_quirk *quirk,
962 const struct alc_pincfg **pinfix)
963{
964 const struct alc_pincfg *cfg;
965
966 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
967 if (!quirk)
968 return;
969
970 cfg = pinfix[quirk->value];
971 for (; cfg->nid; cfg++) {
972 int i;
973 u32 val = cfg->val;
974 for (i = 0; i < 4; i++) {
975 snd_hda_codec_write(codec, cfg->nid, 0,
976 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
977 val & 0xff);
978 val >>= 8;
979 }
980 }
981}
982
983/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200984 * ALC880 3-stack model
985 *
986 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200987 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
988 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 */
990
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200991static hda_nid_t alc880_dac_nids[4] = {
992 /* front, rear, clfe, rear_surr */
993 0x02, 0x05, 0x04, 0x03
994};
995
996static hda_nid_t alc880_adc_nids[3] = {
997 /* ADC0-2 */
998 0x07, 0x08, 0x09,
999};
1000
1001/* The datasheet says the node 0x07 is connected from inputs,
1002 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001003 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001005static hda_nid_t alc880_adc_nids_alt[2] = {
1006 /* ADC1-2 */
1007 0x08, 0x09,
1008};
1009
1010#define ALC880_DIGOUT_NID 0x06
1011#define ALC880_DIGIN_NID 0x0a
1012
1013static struct hda_input_mux alc880_capture_source = {
1014 .num_items = 4,
1015 .items = {
1016 { "Mic", 0x0 },
1017 { "Front Mic", 0x3 },
1018 { "Line", 0x2 },
1019 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001021};
1022
1023/* channel source setting (2/6 channel selection for 3-stack) */
1024/* 2ch mode */
1025static struct hda_verb alc880_threestack_ch2_init[] = {
1026 /* set line-in to input, mute it */
1027 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1028 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1029 /* set mic-in to input vref 80%, mute it */
1030 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1031 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 { } /* end */
1033};
1034
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001035/* 6ch mode */
1036static struct hda_verb alc880_threestack_ch6_init[] = {
1037 /* set line-in to output, unmute it */
1038 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1039 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1040 /* set mic-in to output, unmute it */
1041 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1042 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1043 { } /* end */
1044};
1045
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001046static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001047 { 2, alc880_threestack_ch2_init },
1048 { 6, alc880_threestack_ch6_init },
1049};
1050
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001051static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001054 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001055 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001056 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1068 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1069 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 {
1072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1073 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001074 .info = alc_ch_mode_info,
1075 .get = alc_ch_mode_get,
1076 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077 },
1078 { } /* end */
1079};
1080
1081/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001082static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001083 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1084 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1085 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1086 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1087 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1088 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1089 {
1090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1091 /* The multiple "Capture Source" controls confuse alsamixer
1092 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001093 */
1094 /* .name = "Capture Source", */
1095 .name = "Input Source",
1096 .count = 3,
1097 .info = alc_mux_enum_info,
1098 .get = alc_mux_enum_get,
1099 .put = alc_mux_enum_put,
1100 },
1101 { } /* end */
1102};
1103
1104/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001105static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001106 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1107 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1108 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1109 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 {
1111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1112 /* The multiple "Capture Source" controls confuse alsamixer
1113 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 */
1115 /* .name = "Capture Source", */
1116 .name = "Input Source",
1117 .count = 2,
1118 .info = alc_mux_enum_info,
1119 .get = alc_mux_enum_get,
1120 .put = alc_mux_enum_put,
1121 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 { } /* end */
1123};
1124
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125
1126
1127/*
1128 * ALC880 5-stack model
1129 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001130 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1131 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001132 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1133 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1134 */
1135
1136/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001137static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001138 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001139 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 { } /* end */
1141};
1142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001143/* channel source setting (6/8 channel selection for 5-stack) */
1144/* 6ch mode */
1145static struct hda_verb alc880_fivestack_ch6_init[] = {
1146 /* set line-in to input, mute it */
1147 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1148 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001149 { } /* end */
1150};
1151
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001152/* 8ch mode */
1153static struct hda_verb alc880_fivestack_ch8_init[] = {
1154 /* set line-in to output, unmute it */
1155 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1156 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1157 { } /* end */
1158};
1159
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001160static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001161 { 6, alc880_fivestack_ch6_init },
1162 { 8, alc880_fivestack_ch8_init },
1163};
1164
1165
1166/*
1167 * ALC880 6-stack model
1168 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001169 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1170 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001171 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1172 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1173 */
1174
1175static hda_nid_t alc880_6st_dac_nids[4] = {
1176 /* front, rear, clfe, rear_surr */
1177 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001178};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001179
1180static struct hda_input_mux alc880_6stack_capture_source = {
1181 .num_items = 4,
1182 .items = {
1183 { "Mic", 0x0 },
1184 { "Front Mic", 0x1 },
1185 { "Line", 0x2 },
1186 { "CD", 0x4 },
1187 },
1188};
1189
1190/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001191static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001192 { 8, NULL },
1193};
1194
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001195static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001197 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001198 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001199 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001200 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1201 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001202 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1203 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001204 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001205 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1208 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1209 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1214 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1215 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001216 {
1217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1218 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001219 .info = alc_ch_mode_info,
1220 .get = alc_ch_mode_get,
1221 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001222 },
1223 { } /* end */
1224};
1225
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001226
1227/*
1228 * ALC880 W810 model
1229 *
1230 * W810 has rear IO for:
1231 * Front (DAC 02)
1232 * Surround (DAC 03)
1233 * Center/LFE (DAC 04)
1234 * Digital out (06)
1235 *
1236 * The system also has a pair of internal speakers, and a headphone jack.
1237 * These are both connected to Line2 on the codec, hence to DAC 02.
1238 *
1239 * There is a variable resistor to control the speaker or headphone
1240 * volume. This is a hardware-only device without a software API.
1241 *
1242 * Plugging headphones in will disable the internal speakers. This is
1243 * implemented in hardware, not via the driver using jack sense. In
1244 * a similar fashion, plugging into the rear socket marked "front" will
1245 * disable both the speakers and headphones.
1246 *
1247 * For input, there's a microphone jack, and an "audio in" jack.
1248 * These may not do anything useful with this driver yet, because I
1249 * haven't setup any initialization verbs for these yet...
1250 */
1251
1252static hda_nid_t alc880_w810_dac_nids[3] = {
1253 /* front, rear/surround, clfe */
1254 0x02, 0x03, 0x04
1255};
1256
1257/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001258static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 { 6, NULL }
1260};
1261
1262/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001263static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001265 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001267 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001268 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001270 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1273 { } /* end */
1274};
1275
1276
1277/*
1278 * Z710V model
1279 *
1280 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001281 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1282 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 */
1284
1285static hda_nid_t alc880_z71v_dac_nids[1] = {
1286 0x02
1287};
1288#define ALC880_Z71V_HP_DAC 0x03
1289
1290/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001291static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 { 2, NULL }
1293};
1294
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001295static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001299 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001300 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1301 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1304 { } /* end */
1305};
1306
1307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001308/*
1309 * ALC880 F1734 model
1310 *
1311 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1312 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1313 */
1314
1315static hda_nid_t alc880_f1734_dac_nids[1] = {
1316 0x03
1317};
1318#define ALC880_F1734_HP_DAC 0x02
1319
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001320static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001322 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001323 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1324 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001325 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1326 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001329 { } /* end */
1330};
1331
Takashi Iwai937b4162008-02-11 14:52:36 +01001332static struct hda_input_mux alc880_f1734_capture_source = {
1333 .num_items = 2,
1334 .items = {
1335 { "Mic", 0x1 },
1336 { "CD", 0x4 },
1337 },
1338};
1339
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001340
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001341/*
1342 * ALC880 ASUS model
1343 *
1344 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1345 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1346 * Mic = 0x18, Line = 0x1a
1347 */
1348
1349#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1350#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1351
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001352static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001354 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001355 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001356 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1358 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001359 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1360 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001361 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1362 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1363 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1364 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001367 {
1368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1369 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001370 .info = alc_ch_mode_info,
1371 .get = alc_ch_mode_get,
1372 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001373 },
1374 { } /* end */
1375};
1376
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001377/*
1378 * ALC880 ASUS W1V model
1379 *
1380 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1381 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1382 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1383 */
1384
1385/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001386static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001387 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1388 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001389 { } /* end */
1390};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001391
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001392/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001393static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001394 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1395 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1396 { } /* end */
1397};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001398
Kailang Yangdf694da2005-12-05 19:42:22 +01001399/* TCL S700 */
1400static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1401 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1402 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1404 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1405 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1407 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1408 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1409 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1410 {
1411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1412 /* The multiple "Capture Source" controls confuse alsamixer
1413 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001414 */
1415 /* .name = "Capture Source", */
1416 .name = "Input Source",
1417 .count = 1,
1418 .info = alc_mux_enum_info,
1419 .get = alc_mux_enum_get,
1420 .put = alc_mux_enum_put,
1421 },
1422 { } /* end */
1423};
1424
Kailang Yangccc656c2006-10-17 12:32:26 +02001425/* Uniwill */
1426static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001427 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1428 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1430 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001431 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1432 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1433 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1434 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1443 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1444 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1445 {
1446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1447 .name = "Channel Mode",
1448 .info = alc_ch_mode_info,
1449 .get = alc_ch_mode_get,
1450 .put = alc_ch_mode_put,
1451 },
1452 { } /* end */
1453};
1454
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001455static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1462 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1463 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1464 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1465 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1466 { } /* end */
1467};
1468
Kailang Yangccc656c2006-10-17 12:32:26 +02001469static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1471 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1472 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1473 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1475 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1476 { } /* end */
1477};
1478
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001480 * virtual master controls
1481 */
1482
1483/*
1484 * slave controls for virtual master
1485 */
1486static const char *alc_slave_vols[] = {
1487 "Front Playback Volume",
1488 "Surround Playback Volume",
1489 "Center Playback Volume",
1490 "LFE Playback Volume",
1491 "Side Playback Volume",
1492 "Headphone Playback Volume",
1493 "Speaker Playback Volume",
1494 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001495 "Line-Out Playback Volume",
1496 NULL,
1497};
1498
1499static const char *alc_slave_sws[] = {
1500 "Front Playback Switch",
1501 "Surround Playback Switch",
1502 "Center Playback Switch",
1503 "LFE Playback Switch",
1504 "Side Playback Switch",
1505 "Headphone Playback Switch",
1506 "Speaker Playback Switch",
1507 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001508 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001509 NULL,
1510};
1511
1512/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001513 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 */
1515static int alc_build_controls(struct hda_codec *codec)
1516{
1517 struct alc_spec *spec = codec->spec;
1518 int err;
1519 int i;
1520
1521 for (i = 0; i < spec->num_mixers; i++) {
1522 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1523 if (err < 0)
1524 return err;
1525 }
1526
1527 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001528 err = snd_hda_create_spdif_out_ctls(codec,
1529 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 if (err < 0)
1531 return err;
1532 }
1533 if (spec->dig_in_nid) {
1534 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1535 if (err < 0)
1536 return err;
1537 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001538
1539 /* if we have no master control, let's create it */
1540 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1541 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1542 HDA_OUTPUT, spec->vmaster_tlv);
1543 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1544 spec->vmaster_tlv, alc_slave_vols);
1545 if (err < 0)
1546 return err;
1547 }
1548 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1549 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1550 NULL, alc_slave_sws);
1551 if (err < 0)
1552 return err;
1553 }
1554
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 return 0;
1556}
1557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001558
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559/*
1560 * initialize the codec volumes, etc
1561 */
1562
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001563/*
1564 * generic initialization of ADC, input mixers and output mixers
1565 */
1566static struct hda_verb alc880_volume_init_verbs[] = {
1567 /*
1568 * Unmute ADC0-2 and set the default input to mic-in
1569 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001570 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001572 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001574 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001577 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1578 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001579 * Note: PASD motherboards uses the Line In 2 as the input for front
1580 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001582 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001590
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001591 /*
1592 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001594 /* set vol=0 to output mixers */
1595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1599 /* set up input amps for analog loopback */
1600 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1606 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001607 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1608 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001609
1610 { }
1611};
1612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001613/*
1614 * 3-stack pin configuration:
1615 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1616 */
1617static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1618 /*
1619 * preset connection lists of input pins
1620 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1621 */
1622 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1623 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1624 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1625
1626 /*
1627 * Set pin mode and muting
1628 */
1629 /* set front pin widgets 0x14 for output */
1630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1631 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1632 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1634 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1635 /* Mic2 (as headphone out) for HP output */
1636 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 /* Line In pin widget for input */
1639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1641 /* Line2 (as front mic) pin widget for input and vref at 80% */
1642 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1643 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1644 /* CD pin widget for input */
1645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1646
1647 { }
1648};
1649
1650/*
1651 * 5-stack pin configuration:
1652 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1653 * line-in/side = 0x1a, f-mic = 0x1b
1654 */
1655static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1656 /*
1657 * preset connection lists of input pins
1658 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1659 */
1660 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1661 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1662
1663 /*
1664 * Set pin mode and muting
1665 */
1666 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1670 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001671 /* unmute pins for output (no gain on this amp) */
1672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1674 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1675 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001678 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001679 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1680 /* Mic2 (as headphone out) for HP output */
1681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683 /* Line In pin widget for input */
1684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1685 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1686 /* Line2 (as front mic) pin widget for input and vref at 80% */
1687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1688 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1689 /* CD pin widget for input */
1690 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691
1692 { }
1693};
1694
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001695/*
1696 * W810 pin configuration:
1697 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1698 */
1699static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 /* hphone/speaker input selector: front DAC */
1701 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709
1710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 { }
1714};
1715
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001716/*
1717 * Z71V pin configuration:
1718 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1719 */
1720static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001725
Takashi Iwai16ded522005-06-10 19:58:24 +02001726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001727 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001728 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001729 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001730
1731 { }
1732};
1733
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734/*
1735 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001736 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1737 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001738 */
1739static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1740 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1741
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001746 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001748 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1750
Takashi Iwai16ded522005-06-10 19:58:24 +02001751 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001752 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001757 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001758 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001759 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1760
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001761 { }
1762};
Takashi Iwai16ded522005-06-10 19:58:24 +02001763
Kailang Yangccc656c2006-10-17 12:32:26 +02001764/*
1765 * Uniwill pin configuration:
1766 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1767 * line = 0x1a
1768 */
1769static struct hda_verb alc880_uniwill_init_verbs[] = {
1770 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1771
1772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1776 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1777 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1778 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1779 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1783 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1785 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1786
1787 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1789 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1790 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1792 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1793 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1794 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1795 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1796
1797 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1798 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1799
1800 { }
1801};
1802
1803/*
1804* Uniwill P53
1805* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1806 */
1807static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1808 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1809
1810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1814 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1818 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1820 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1822
1823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1825 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1827 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1829
1830 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1831 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1832
1833 { }
1834};
1835
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001836static struct hda_verb alc880_beep_init_verbs[] = {
1837 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1838 { }
1839};
1840
Kailang Yangccc656c2006-10-17 12:32:26 +02001841/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001842static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001843{
1844 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001845 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001846
1847 present = snd_hda_codec_read(codec, 0x14, 0,
1848 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001849 bits = present ? HDA_AMP_MUTE : 0;
1850 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1851 HDA_AMP_MUTE, bits);
1852 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1853 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001854}
1855
1856/* auto-toggle front mic */
1857static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1858{
1859 unsigned int present;
1860 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001861
1862 present = snd_hda_codec_read(codec, 0x18, 0,
1863 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001864 bits = present ? HDA_AMP_MUTE : 0;
1865 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001866}
1867
1868static void alc880_uniwill_automute(struct hda_codec *codec)
1869{
1870 alc880_uniwill_hp_automute(codec);
1871 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001872}
1873
1874static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1875 unsigned int res)
1876{
1877 /* Looks like the unsol event is incompatible with the standard
1878 * definition. 4bit tag is placed at 28 bit!
1879 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001880 switch (res >> 28) {
1881 case ALC880_HP_EVENT:
1882 alc880_uniwill_hp_automute(codec);
1883 break;
1884 case ALC880_MIC_EVENT:
1885 alc880_uniwill_mic_automute(codec);
1886 break;
1887 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001888}
1889
1890static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1891{
1892 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001893 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001894
1895 present = snd_hda_codec_read(codec, 0x14, 0,
1896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001897 bits = present ? HDA_AMP_MUTE : 0;
1898 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001899}
1900
1901static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1902{
1903 unsigned int present;
1904
1905 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001906 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1907 present &= HDA_AMP_VOLMASK;
1908 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1909 HDA_AMP_VOLMASK, present);
1910 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1911 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001912}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001913
Kailang Yangccc656c2006-10-17 12:32:26 +02001914static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1915 unsigned int res)
1916{
1917 /* Looks like the unsol event is incompatible with the standard
1918 * definition. 4bit tag is placed at 28 bit!
1919 */
1920 if ((res >> 28) == ALC880_HP_EVENT)
1921 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001922 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001923 alc880_uniwill_p53_dcvol_automute(codec);
1924}
1925
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001926/*
1927 * F1734 pin configuration:
1928 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1929 */
1930static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1931 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1932 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1933 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1934 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1935
1936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1937 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1940
1941 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1943 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1948 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1949 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001950
Takashi Iwai937b4162008-02-11 14:52:36 +01001951 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1952 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1953
Takashi Iwai16ded522005-06-10 19:58:24 +02001954 { }
1955};
1956
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001957/*
1958 * ASUS pin configuration:
1959 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1960 */
1961static struct hda_verb alc880_pin_asus_init_verbs[] = {
1962 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1963 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1964 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1965 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1966
1967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1973 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1975
1976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1980 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1985
1986 { }
1987};
1988
1989/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001990#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1991#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001992
Kailang Yangdf694da2005-12-05 19:42:22 +01001993/* Clevo m520g init */
1994static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1995 /* headphone output */
1996 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1997 /* line-out */
1998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1999 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2000 /* Line-in */
2001 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2003 /* CD */
2004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2005 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006 /* Mic1 (rear panel) */
2007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009 /* Mic2 (front panel) */
2010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2011 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 /* headphone */
2013 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 /* change to EAPD mode */
2016 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2017 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2018
2019 { }
2020};
2021
2022static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002023 /* change to EAPD mode */
2024 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2025 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2026
Kailang Yangdf694da2005-12-05 19:42:22 +01002027 /* Headphone output */
2028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2029 /* Front output*/
2030 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2032
2033 /* Line In pin widget for input */
2034 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2035 /* CD pin widget for input */
2036 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2037 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2039
2040 /* change to EAPD mode */
2041 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2042 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2043
2044 { }
2045};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002046
2047/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002048 * LG m1 express dual
2049 *
2050 * Pin assignment:
2051 * Rear Line-In/Out (blue): 0x14
2052 * Build-in Mic-In: 0x15
2053 * Speaker-out: 0x17
2054 * HP-Out (green): 0x1b
2055 * Mic-In/Out (red): 0x19
2056 * SPDIF-Out: 0x1e
2057 */
2058
2059/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2060static hda_nid_t alc880_lg_dac_nids[3] = {
2061 0x05, 0x02, 0x03
2062};
2063
2064/* seems analog CD is not working */
2065static struct hda_input_mux alc880_lg_capture_source = {
2066 .num_items = 3,
2067 .items = {
2068 { "Mic", 0x1 },
2069 { "Line", 0x5 },
2070 { "Internal Mic", 0x6 },
2071 },
2072};
2073
2074/* 2,4,6 channel modes */
2075static struct hda_verb alc880_lg_ch2_init[] = {
2076 /* set line-in and mic-in to input */
2077 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2078 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2079 { }
2080};
2081
2082static struct hda_verb alc880_lg_ch4_init[] = {
2083 /* set line-in to out and mic-in to input */
2084 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2085 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2086 { }
2087};
2088
2089static struct hda_verb alc880_lg_ch6_init[] = {
2090 /* set line-in and mic-in to output */
2091 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2092 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2093 { }
2094};
2095
2096static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2097 { 2, alc880_lg_ch2_init },
2098 { 4, alc880_lg_ch4_init },
2099 { 6, alc880_lg_ch6_init },
2100};
2101
2102static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2104 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002105 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2106 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2107 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2108 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2109 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2110 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2114 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2115 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2116 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2117 {
2118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2119 .name = "Channel Mode",
2120 .info = alc_ch_mode_info,
2121 .get = alc_ch_mode_get,
2122 .put = alc_ch_mode_put,
2123 },
2124 { } /* end */
2125};
2126
2127static struct hda_verb alc880_lg_init_verbs[] = {
2128 /* set capture source to mic-in */
2129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2130 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2132 /* mute all amp mixer inputs */
2133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002136 /* line-in to input */
2137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2139 /* built-in mic */
2140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2142 /* speaker-out */
2143 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2144 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2145 /* mic-in to input */
2146 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2147 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2149 /* HP-out */
2150 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2151 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2152 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2153 /* jack sense */
2154 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2155 { }
2156};
2157
2158/* toggle speaker-output according to the hp-jack state */
2159static void alc880_lg_automute(struct hda_codec *codec)
2160{
2161 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002162 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002163
2164 present = snd_hda_codec_read(codec, 0x1b, 0,
2165 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002166 bits = present ? HDA_AMP_MUTE : 0;
2167 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2168 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002169}
2170
2171static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2172{
2173 /* Looks like the unsol event is incompatible with the standard
2174 * definition. 4bit tag is placed at 28 bit!
2175 */
2176 if ((res >> 28) == 0x01)
2177 alc880_lg_automute(codec);
2178}
2179
2180/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002181 * LG LW20
2182 *
2183 * Pin assignment:
2184 * Speaker-out: 0x14
2185 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002186 * Built-in Mic-In: 0x19
2187 * Line-In: 0x1b
2188 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002189 * SPDIF-Out: 0x1e
2190 */
2191
Takashi Iwaid6815182006-03-23 16:06:23 +01002192static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002193 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002194 .items = {
2195 { "Mic", 0x0 },
2196 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002197 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002198 },
2199};
2200
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002201#define alc880_lg_lw_modes alc880_threestack_modes
2202
Takashi Iwaid6815182006-03-23 16:06:23 +01002203static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2205 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2206 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2209 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2210 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2211 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2216 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2217 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002218 {
2219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2220 .name = "Channel Mode",
2221 .info = alc_ch_mode_info,
2222 .get = alc_ch_mode_get,
2223 .put = alc_ch_mode_put,
2224 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002225 { } /* end */
2226};
2227
2228static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002229 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2230 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2231 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2232
Takashi Iwaid6815182006-03-23 16:06:23 +01002233 /* set capture source to mic-in */
2234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002238 /* speaker-out */
2239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2241 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2244 /* mic-in to input */
2245 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2246 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2247 /* built-in mic */
2248 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2250 /* jack sense */
2251 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2252 { }
2253};
2254
2255/* toggle speaker-output according to the hp-jack state */
2256static void alc880_lg_lw_automute(struct hda_codec *codec)
2257{
2258 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002259 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002260
2261 present = snd_hda_codec_read(codec, 0x1b, 0,
2262 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002263 bits = present ? HDA_AMP_MUTE : 0;
2264 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2265 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002266}
2267
2268static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2269{
2270 /* Looks like the unsol event is incompatible with the standard
2271 * definition. 4bit tag is placed at 28 bit!
2272 */
2273 if ((res >> 28) == 0x01)
2274 alc880_lg_lw_automute(codec);
2275}
2276
Takashi Iwaicb53c622007-08-10 17:21:45 +02002277#ifdef CONFIG_SND_HDA_POWER_SAVE
2278static struct hda_amp_list alc880_loopbacks[] = {
2279 { 0x0b, HDA_INPUT, 0 },
2280 { 0x0b, HDA_INPUT, 1 },
2281 { 0x0b, HDA_INPUT, 2 },
2282 { 0x0b, HDA_INPUT, 3 },
2283 { 0x0b, HDA_INPUT, 4 },
2284 { } /* end */
2285};
2286
2287static struct hda_amp_list alc880_lg_loopbacks[] = {
2288 { 0x0b, HDA_INPUT, 1 },
2289 { 0x0b, HDA_INPUT, 6 },
2290 { 0x0b, HDA_INPUT, 7 },
2291 { } /* end */
2292};
2293#endif
2294
Takashi Iwaid6815182006-03-23 16:06:23 +01002295/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002296 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002298
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299static int alc_init(struct hda_codec *codec)
2300{
2301 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002302 unsigned int i;
2303
2304 for (i = 0; i < spec->num_init_verbs; i++)
2305 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002306
2307 if (spec->init_hook)
2308 spec->init_hook(codec);
2309
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 return 0;
2311}
2312
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002313static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2314{
2315 struct alc_spec *spec = codec->spec;
2316
2317 if (spec->unsol_event)
2318 spec->unsol_event(codec, res);
2319}
2320
Takashi Iwaicb53c622007-08-10 17:21:45 +02002321#ifdef CONFIG_SND_HDA_POWER_SAVE
2322static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2323{
2324 struct alc_spec *spec = codec->spec;
2325 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2326}
2327#endif
2328
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329/*
2330 * Analog playback callbacks
2331 */
2332static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002334 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335{
2336 struct alc_spec *spec = codec->spec;
2337 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2338}
2339
2340static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
2342 unsigned int stream_tag,
2343 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002344 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345{
2346 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002347 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2348 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349}
2350
2351static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002353 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354{
2355 struct alc_spec *spec = codec->spec;
2356 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2357}
2358
2359/*
2360 * Digital out
2361 */
2362static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2363 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002364 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365{
2366 struct alc_spec *spec = codec->spec;
2367 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2368}
2369
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002370static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2371 struct hda_codec *codec,
2372 unsigned int stream_tag,
2373 unsigned int format,
2374 struct snd_pcm_substream *substream)
2375{
2376 struct alc_spec *spec = codec->spec;
2377 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2378 stream_tag, format, substream);
2379}
2380
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2382 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002383 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384{
2385 struct alc_spec *spec = codec->spec;
2386 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2387}
2388
2389/*
2390 * Analog capture
2391 */
Takashi Iwai63300792008-01-24 15:31:36 +01002392static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 struct hda_codec *codec,
2394 unsigned int stream_tag,
2395 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002396 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397{
2398 struct alc_spec *spec = codec->spec;
2399
Takashi Iwai63300792008-01-24 15:31:36 +01002400 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 stream_tag, 0, format);
2402 return 0;
2403}
2404
Takashi Iwai63300792008-01-24 15:31:36 +01002405static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002407 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408{
2409 struct alc_spec *spec = codec->spec;
2410
Takashi Iwai63300792008-01-24 15:31:36 +01002411 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002412 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 return 0;
2414}
2415
2416
2417/*
2418 */
2419static struct hda_pcm_stream alc880_pcm_analog_playback = {
2420 .substreams = 1,
2421 .channels_min = 2,
2422 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002423 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 .ops = {
2425 .open = alc880_playback_pcm_open,
2426 .prepare = alc880_playback_pcm_prepare,
2427 .cleanup = alc880_playback_pcm_cleanup
2428 },
2429};
2430
2431static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002432 .substreams = 1,
2433 .channels_min = 2,
2434 .channels_max = 2,
2435 /* NID is set in alc_build_pcms */
2436};
2437
2438static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2439 .substreams = 1,
2440 .channels_min = 2,
2441 .channels_max = 2,
2442 /* NID is set in alc_build_pcms */
2443};
2444
2445static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2446 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 .channels_min = 2,
2448 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002449 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002451 .prepare = alc880_alt_capture_pcm_prepare,
2452 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 },
2454};
2455
2456static struct hda_pcm_stream alc880_pcm_digital_playback = {
2457 .substreams = 1,
2458 .channels_min = 2,
2459 .channels_max = 2,
2460 /* NID is set in alc_build_pcms */
2461 .ops = {
2462 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002463 .close = alc880_dig_playback_pcm_close,
2464 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 },
2466};
2467
2468static struct hda_pcm_stream alc880_pcm_digital_capture = {
2469 .substreams = 1,
2470 .channels_min = 2,
2471 .channels_max = 2,
2472 /* NID is set in alc_build_pcms */
2473};
2474
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002475/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002476static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002477 .substreams = 0,
2478 .channels_min = 0,
2479 .channels_max = 0,
2480};
2481
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482static int alc_build_pcms(struct hda_codec *codec)
2483{
2484 struct alc_spec *spec = codec->spec;
2485 struct hda_pcm *info = spec->pcm_rec;
2486 int i;
2487
2488 codec->num_pcms = 1;
2489 codec->pcm_info = info;
2490
2491 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002492 if (spec->stream_analog_playback) {
2493 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2496 }
2497 if (spec->stream_analog_capture) {
2498 snd_assert(spec->adc_nids, return -EINVAL);
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2500 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2501 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502
Takashi Iwai4a471b72005-12-07 13:56:29 +01002503 if (spec->channel_mode) {
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2505 for (i = 0; i < spec->num_channel_mode; i++) {
2506 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2507 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2508 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 }
2510 }
2511
Takashi Iwaie08a0072006-09-07 17:52:14 +02002512 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002514 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002515 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002517 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002518 if (spec->multiout.dig_out_nid &&
2519 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002520 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2521 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2522 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002523 if (spec->dig_in_nid &&
2524 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2526 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2527 }
2528 }
2529
Takashi Iwaie08a0072006-09-07 17:52:14 +02002530 /* If the use of more than one ADC is requested for the current
2531 * model, configure a second analog capture-only PCM.
2532 */
2533 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002534 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2535 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002536 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002537 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002538 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002539 if (spec->alt_dac_nid) {
2540 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2541 *spec->stream_analog_alt_playback;
2542 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2543 spec->alt_dac_nid;
2544 } else {
2545 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2546 alc_pcm_null_stream;
2547 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2548 }
2549 if (spec->num_adc_nids > 1) {
2550 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2551 *spec->stream_analog_alt_capture;
2552 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2553 spec->adc_nids[1];
2554 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2555 spec->num_adc_nids - 1;
2556 } else {
2557 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2558 alc_pcm_null_stream;
2559 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002560 }
2561 }
2562
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 return 0;
2564}
2565
2566static void alc_free(struct hda_codec *codec)
2567{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 struct alc_spec *spec = codec->spec;
2569 unsigned int i;
2570
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002571 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002572 return;
2573
2574 if (spec->kctl_alloc) {
2575 for (i = 0; i < spec->num_kctl_used; i++)
2576 kfree(spec->kctl_alloc[i].name);
2577 kfree(spec->kctl_alloc);
2578 }
2579 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580}
2581
2582/*
2583 */
2584static struct hda_codec_ops alc_patch_ops = {
2585 .build_controls = alc_build_controls,
2586 .build_pcms = alc_build_pcms,
2587 .init = alc_init,
2588 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002589 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002590#ifdef CONFIG_SND_HDA_POWER_SAVE
2591 .check_power_status = alc_check_power_status,
2592#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593};
2594
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002595
2596/*
2597 * Test configuration for debugging
2598 *
2599 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2600 * enum controls.
2601 */
2602#ifdef CONFIG_SND_DEBUG
2603static hda_nid_t alc880_test_dac_nids[4] = {
2604 0x02, 0x03, 0x04, 0x05
2605};
2606
2607static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002608 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002609 .items = {
2610 { "In-1", 0x0 },
2611 { "In-2", 0x1 },
2612 { "In-3", 0x2 },
2613 { "In-4", 0x3 },
2614 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002615 { "Front", 0x5 },
2616 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002617 },
2618};
2619
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002620static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002621 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002622 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002623 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002624 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002625};
2626
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002627static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2628 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002629{
2630 static char *texts[] = {
2631 "N/A", "Line Out", "HP Out",
2632 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2633 };
2634 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2635 uinfo->count = 1;
2636 uinfo->value.enumerated.items = 8;
2637 if (uinfo->value.enumerated.item >= 8)
2638 uinfo->value.enumerated.item = 7;
2639 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2640 return 0;
2641}
2642
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002643static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2644 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002645{
2646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2647 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2648 unsigned int pin_ctl, item = 0;
2649
2650 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2651 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2652 if (pin_ctl & AC_PINCTL_OUT_EN) {
2653 if (pin_ctl & AC_PINCTL_HP_EN)
2654 item = 2;
2655 else
2656 item = 1;
2657 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2658 switch (pin_ctl & AC_PINCTL_VREFEN) {
2659 case AC_PINCTL_VREF_HIZ: item = 3; break;
2660 case AC_PINCTL_VREF_50: item = 4; break;
2661 case AC_PINCTL_VREF_GRD: item = 5; break;
2662 case AC_PINCTL_VREF_80: item = 6; break;
2663 case AC_PINCTL_VREF_100: item = 7; break;
2664 }
2665 }
2666 ucontrol->value.enumerated.item[0] = item;
2667 return 0;
2668}
2669
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002670static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2671 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002672{
2673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2674 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2675 static unsigned int ctls[] = {
2676 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2677 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2678 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2679 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2680 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2681 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2682 };
2683 unsigned int old_ctl, new_ctl;
2684
2685 old_ctl = snd_hda_codec_read(codec, nid, 0,
2686 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2687 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2688 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002689 int val;
2690 snd_hda_codec_write_cache(codec, nid, 0,
2691 AC_VERB_SET_PIN_WIDGET_CONTROL,
2692 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002693 val = ucontrol->value.enumerated.item[0] >= 3 ?
2694 HDA_AMP_MUTE : 0;
2695 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2696 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002697 return 1;
2698 }
2699 return 0;
2700}
2701
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002702static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2703 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002704{
2705 static char *texts[] = {
2706 "Front", "Surround", "CLFE", "Side"
2707 };
2708 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2709 uinfo->count = 1;
2710 uinfo->value.enumerated.items = 4;
2711 if (uinfo->value.enumerated.item >= 4)
2712 uinfo->value.enumerated.item = 3;
2713 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2714 return 0;
2715}
2716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002717static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2718 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002719{
2720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2721 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2722 unsigned int sel;
2723
2724 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2725 ucontrol->value.enumerated.item[0] = sel & 3;
2726 return 0;
2727}
2728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002729static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2730 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002731{
2732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2733 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2734 unsigned int sel;
2735
2736 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2737 if (ucontrol->value.enumerated.item[0] != sel) {
2738 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002739 snd_hda_codec_write_cache(codec, nid, 0,
2740 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002741 return 1;
2742 }
2743 return 0;
2744}
2745
2746#define PIN_CTL_TEST(xname,nid) { \
2747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2748 .name = xname, \
2749 .info = alc_test_pin_ctl_info, \
2750 .get = alc_test_pin_ctl_get, \
2751 .put = alc_test_pin_ctl_put, \
2752 .private_value = nid \
2753 }
2754
2755#define PIN_SRC_TEST(xname,nid) { \
2756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2757 .name = xname, \
2758 .info = alc_test_pin_src_info, \
2759 .get = alc_test_pin_src_get, \
2760 .put = alc_test_pin_src_put, \
2761 .private_value = nid \
2762 }
2763
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002764static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002765 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2766 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2767 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2768 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2770 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2771 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002773 PIN_CTL_TEST("Front Pin Mode", 0x14),
2774 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2775 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2776 PIN_CTL_TEST("Side Pin Mode", 0x17),
2777 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2778 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2779 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2780 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2781 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2782 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2783 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2784 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2785 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2786 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2787 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2788 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2789 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2790 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2791 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2792 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002795 {
2796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2797 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002798 .info = alc_ch_mode_info,
2799 .get = alc_ch_mode_get,
2800 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002801 },
2802 { } /* end */
2803};
2804
2805static struct hda_verb alc880_test_init_verbs[] = {
2806 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002815 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002820 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2823 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2824 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002825 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002826 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002830 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002831 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2832 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2834 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2835 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002836 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2840 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002841 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002843 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002845 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002847 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002848 /* Analog input/passthru */
2849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002854 { }
2855};
2856#endif
2857
Linus Torvalds1da177e2005-04-16 15:20:36 -07002858/*
2859 */
2860
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002861static const char *alc880_models[ALC880_MODEL_LAST] = {
2862 [ALC880_3ST] = "3stack",
2863 [ALC880_TCL_S700] = "tcl",
2864 [ALC880_3ST_DIG] = "3stack-digout",
2865 [ALC880_CLEVO] = "clevo",
2866 [ALC880_5ST] = "5stack",
2867 [ALC880_5ST_DIG] = "5stack-digout",
2868 [ALC880_W810] = "w810",
2869 [ALC880_Z71V] = "z71v",
2870 [ALC880_6ST] = "6stack",
2871 [ALC880_6ST_DIG] = "6stack-digout",
2872 [ALC880_ASUS] = "asus",
2873 [ALC880_ASUS_W1V] = "asus-w1v",
2874 [ALC880_ASUS_DIG] = "asus-dig",
2875 [ALC880_ASUS_DIG2] = "asus-dig2",
2876 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002877 [ALC880_UNIWILL_P53] = "uniwill-p53",
2878 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002879 [ALC880_F1734] = "F1734",
2880 [ALC880_LG] = "lg",
2881 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002882#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002883 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002884#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002885 [ALC880_AUTO] = "auto",
2886};
2887
2888static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002889 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002890 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2891 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2892 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2893 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2894 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2895 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2896 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2897 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002898 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2899 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002900 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2901 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2902 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2903 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2904 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2905 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2906 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2907 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2908 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2909 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002910 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002911 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2912 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2913 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002914 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002915 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002916 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2917 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002918 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2919 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002920 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2921 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2922 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2923 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002924 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2925 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002926 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002927 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002928 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002929 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002930 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2931 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002932 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2933 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002934 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002935 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002936 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002937 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002938 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002939 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2940 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002941 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002942 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2943 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2944 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2945 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002946 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2947 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002948 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002949 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002950 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2951 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002952 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2953 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2954 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002955 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2956 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2957 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 {}
2959};
2960
Takashi Iwai16ded522005-06-10 19:58:24 +02002961/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002962 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002963 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002964static struct alc_config_preset alc880_presets[] = {
2965 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002967 .init_verbs = { alc880_volume_init_verbs,
2968 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002969 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002971 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2972 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002973 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002974 .input_mux = &alc880_capture_source,
2975 },
2976 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002978 .init_verbs = { alc880_volume_init_verbs,
2979 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002980 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 .dac_nids = alc880_dac_nids,
2982 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2984 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002985 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002986 .input_mux = &alc880_capture_source,
2987 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002988 [ALC880_TCL_S700] = {
2989 .mixers = { alc880_tcl_s700_mixer },
2990 .init_verbs = { alc880_volume_init_verbs,
2991 alc880_pin_tcl_S700_init_verbs,
2992 alc880_gpio2_init_verbs },
2993 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2994 .dac_nids = alc880_dac_nids,
2995 .hp_nid = 0x03,
2996 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2997 .channel_mode = alc880_2_jack_modes,
2998 .input_mux = &alc880_capture_source,
2999 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003000 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003001 .mixers = { alc880_three_stack_mixer,
3002 alc880_five_stack_mixer},
3003 .init_verbs = { alc880_volume_init_verbs,
3004 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003005 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3006 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003007 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3008 .channel_mode = alc880_fivestack_modes,
3009 .input_mux = &alc880_capture_source,
3010 },
3011 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003012 .mixers = { alc880_three_stack_mixer,
3013 alc880_five_stack_mixer },
3014 .init_verbs = { alc880_volume_init_verbs,
3015 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003016 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3017 .dac_nids = alc880_dac_nids,
3018 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003019 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3020 .channel_mode = alc880_fivestack_modes,
3021 .input_mux = &alc880_capture_source,
3022 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003023 [ALC880_6ST] = {
3024 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003025 .init_verbs = { alc880_volume_init_verbs,
3026 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003027 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3028 .dac_nids = alc880_6st_dac_nids,
3029 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3030 .channel_mode = alc880_sixstack_modes,
3031 .input_mux = &alc880_6stack_capture_source,
3032 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003033 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003035 .init_verbs = { alc880_volume_init_verbs,
3036 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003037 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3038 .dac_nids = alc880_6st_dac_nids,
3039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003040 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3041 .channel_mode = alc880_sixstack_modes,
3042 .input_mux = &alc880_6stack_capture_source,
3043 },
3044 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003046 .init_verbs = { alc880_volume_init_verbs,
3047 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003048 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3050 .dac_nids = alc880_w810_dac_nids,
3051 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003052 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3053 .channel_mode = alc880_w810_modes,
3054 .input_mux = &alc880_capture_source,
3055 },
3056 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003058 .init_verbs = { alc880_volume_init_verbs,
3059 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003060 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3061 .dac_nids = alc880_z71v_dac_nids,
3062 .dig_out_nid = ALC880_DIGOUT_NID,
3063 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3065 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003066 .input_mux = &alc880_capture_source,
3067 },
3068 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003069 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003070 .init_verbs = { alc880_volume_init_verbs,
3071 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3073 .dac_nids = alc880_f1734_dac_nids,
3074 .hp_nid = 0x02,
3075 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3076 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003077 .input_mux = &alc880_f1734_capture_source,
3078 .unsol_event = alc880_uniwill_p53_unsol_event,
3079 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003080 },
3081 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003083 .init_verbs = { alc880_volume_init_verbs,
3084 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 alc880_gpio1_init_verbs },
3086 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3087 .dac_nids = alc880_asus_dac_nids,
3088 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3089 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003090 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003091 .input_mux = &alc880_capture_source,
3092 },
3093 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003095 .init_verbs = { alc880_volume_init_verbs,
3096 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 alc880_gpio1_init_verbs },
3098 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3099 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003100 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3102 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003103 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003104 .input_mux = &alc880_capture_source,
3105 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003106 [ALC880_ASUS_DIG2] = {
3107 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003108 .init_verbs = { alc880_volume_init_verbs,
3109 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003110 alc880_gpio2_init_verbs }, /* use GPIO2 */
3111 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3112 .dac_nids = alc880_asus_dac_nids,
3113 .dig_out_nid = ALC880_DIGOUT_NID,
3114 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3115 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003116 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003117 .input_mux = &alc880_capture_source,
3118 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003119 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003121 .init_verbs = { alc880_volume_init_verbs,
3122 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003123 alc880_gpio1_init_verbs },
3124 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3125 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003126 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3128 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003129 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003130 .input_mux = &alc880_capture_source,
3131 },
3132 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003133 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003134 .init_verbs = { alc880_volume_init_verbs,
3135 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3137 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003138 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3140 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003141 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003142 .input_mux = &alc880_capture_source,
3143 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003144 [ALC880_UNIWILL] = {
3145 .mixers = { alc880_uniwill_mixer },
3146 .init_verbs = { alc880_volume_init_verbs,
3147 alc880_uniwill_init_verbs },
3148 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3149 .dac_nids = alc880_asus_dac_nids,
3150 .dig_out_nid = ALC880_DIGOUT_NID,
3151 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3152 .channel_mode = alc880_threestack_modes,
3153 .need_dac_fix = 1,
3154 .input_mux = &alc880_capture_source,
3155 .unsol_event = alc880_uniwill_unsol_event,
3156 .init_hook = alc880_uniwill_automute,
3157 },
3158 [ALC880_UNIWILL_P53] = {
3159 .mixers = { alc880_uniwill_p53_mixer },
3160 .init_verbs = { alc880_volume_init_verbs,
3161 alc880_uniwill_p53_init_verbs },
3162 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3163 .dac_nids = alc880_asus_dac_nids,
3164 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003165 .channel_mode = alc880_threestack_modes,
3166 .input_mux = &alc880_capture_source,
3167 .unsol_event = alc880_uniwill_p53_unsol_event,
3168 .init_hook = alc880_uniwill_p53_hp_automute,
3169 },
3170 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003171 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003172 alc880_pcbeep_mixer, },
3173 .init_verbs = { alc880_volume_init_verbs,
3174 alc880_uniwill_p53_init_verbs,
3175 alc880_beep_init_verbs },
3176 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3177 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003178 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003179 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3180 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003181 .input_mux = &alc880_capture_source,
3182 .unsol_event = alc880_uniwill_p53_unsol_event,
3183 .init_hook = alc880_uniwill_p53_hp_automute,
3184 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003185 [ALC880_CLEVO] = {
3186 .mixers = { alc880_three_stack_mixer },
3187 .init_verbs = { alc880_volume_init_verbs,
3188 alc880_pin_clevo_init_verbs },
3189 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3190 .dac_nids = alc880_dac_nids,
3191 .hp_nid = 0x03,
3192 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3193 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003194 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003195 .input_mux = &alc880_capture_source,
3196 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003197 [ALC880_LG] = {
3198 .mixers = { alc880_lg_mixer },
3199 .init_verbs = { alc880_volume_init_verbs,
3200 alc880_lg_init_verbs },
3201 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3202 .dac_nids = alc880_lg_dac_nids,
3203 .dig_out_nid = ALC880_DIGOUT_NID,
3204 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3205 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003206 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003207 .input_mux = &alc880_lg_capture_source,
3208 .unsol_event = alc880_lg_unsol_event,
3209 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003210#ifdef CONFIG_SND_HDA_POWER_SAVE
3211 .loopbacks = alc880_lg_loopbacks,
3212#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003213 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003214 [ALC880_LG_LW] = {
3215 .mixers = { alc880_lg_lw_mixer },
3216 .init_verbs = { alc880_volume_init_verbs,
3217 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003218 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003219 .dac_nids = alc880_dac_nids,
3220 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003221 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3222 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003223 .input_mux = &alc880_lg_lw_capture_source,
3224 .unsol_event = alc880_lg_lw_unsol_event,
3225 .init_hook = alc880_lg_lw_automute,
3226 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003227#ifdef CONFIG_SND_DEBUG
3228 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229 .mixers = { alc880_test_mixer },
3230 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003231 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3232 .dac_nids = alc880_test_dac_nids,
3233 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003234 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3235 .channel_mode = alc880_test_modes,
3236 .input_mux = &alc880_test_capture_source,
3237 },
3238#endif
3239};
3240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241/*
3242 * Automatic parse of I/O pins from the BIOS configuration
3243 */
3244
3245#define NUM_CONTROL_ALLOC 32
3246#define NUM_VERB_ALLOC 32
3247
3248enum {
3249 ALC_CTL_WIDGET_VOL,
3250 ALC_CTL_WIDGET_MUTE,
3251 ALC_CTL_BIND_MUTE,
3252};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003253static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3255 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003256 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257};
3258
3259/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003260static int add_control(struct alc_spec *spec, int type, const char *name,
3261 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003263 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264
3265 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3266 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3267
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003268 /* array + terminator */
3269 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3270 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003271 return -ENOMEM;
3272 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003273 memcpy(knew, spec->kctl_alloc,
3274 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 kfree(spec->kctl_alloc);
3276 }
3277 spec->kctl_alloc = knew;
3278 spec->num_kctl_alloc = num;
3279 }
3280
3281 knew = &spec->kctl_alloc[spec->num_kctl_used];
3282 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003283 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003284 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285 return -ENOMEM;
3286 knew->private_value = val;
3287 spec->num_kctl_used++;
3288 return 0;
3289}
3290
3291#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3292#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3293#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3294#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3295#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3296#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3297#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3298#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3299#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3300#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3301#define ALC880_PIN_CD_NID 0x1c
3302
3303/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003304static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3305 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003306{
3307 hda_nid_t nid;
3308 int assigned[4];
3309 int i, j;
3310
3311 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003312 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313
3314 /* check the pins hardwired to audio widget */
3315 for (i = 0; i < cfg->line_outs; i++) {
3316 nid = cfg->line_out_pins[i];
3317 if (alc880_is_fixed_pin(nid)) {
3318 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003319 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 assigned[idx] = 1;
3321 }
3322 }
3323 /* left pins can be connect to any audio widget */
3324 for (i = 0; i < cfg->line_outs; i++) {
3325 nid = cfg->line_out_pins[i];
3326 if (alc880_is_fixed_pin(nid))
3327 continue;
3328 /* search for an empty channel */
3329 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003330 if (!assigned[j]) {
3331 spec->multiout.dac_nids[i] =
3332 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003333 assigned[j] = 1;
3334 break;
3335 }
3336 }
3337 }
3338 spec->multiout.num_dacs = cfg->line_outs;
3339 return 0;
3340}
3341
3342/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003343static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3344 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003345{
3346 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003347 static const char *chname[4] = {
3348 "Front", "Surround", NULL /*CLFE*/, "Side"
3349 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003350 hda_nid_t nid;
3351 int i, err;
3352
3353 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 continue;
3356 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3357 if (i == 2) {
3358 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003359 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3360 "Center Playback Volume",
3361 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3362 HDA_OUTPUT));
3363 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003365 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3366 "LFE Playback Volume",
3367 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003371 err = add_control(spec, ALC_CTL_BIND_MUTE,
3372 "Center Playback Switch",
3373 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3374 HDA_INPUT));
3375 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003377 err = add_control(spec, ALC_CTL_BIND_MUTE,
3378 "LFE Playback Switch",
3379 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3380 HDA_INPUT));
3381 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003382 return err;
3383 } else {
3384 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003385 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3386 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3387 HDA_OUTPUT));
3388 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 return err;
3390 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003391 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3392 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3393 HDA_INPUT));
3394 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 return err;
3396 }
3397 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 return 0;
3399}
3400
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003401/* add playback controls for speaker and HP outputs */
3402static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3403 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404{
3405 hda_nid_t nid;
3406 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003407 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003409 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003410 return 0;
3411
3412 if (alc880_is_fixed_pin(pin)) {
3413 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003414 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003415 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003417 else
3418 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419 /* control HP volume/switch on the output mixer amp */
3420 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003421 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003422 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3423 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3424 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003425 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003426 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003427 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3428 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3429 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 return err;
3431 } else if (alc880_is_multi_pin(pin)) {
3432 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003433 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003434 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003435 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3436 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3437 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 return err;
3439 }
3440 return 0;
3441}
3442
3443/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003444static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3445 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003446 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447{
3448 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003449 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003450
3451 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003452 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3453 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3454 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455 return err;
3456 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003457 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3458 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3459 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003460 return err;
3461 return 0;
3462}
3463
3464/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003465static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3466 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003467{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003469 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470
3471 for (i = 0; i < AUTO_PIN_LAST; i++) {
3472 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003473 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003474 err = new_analog_input(spec, cfg->input_pins[i],
3475 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003476 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003477 if (err < 0)
3478 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003479 imux->items[imux->num_items].label =
3480 auto_pin_cfg_labels[i];
3481 imux->items[imux->num_items].index =
3482 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483 imux->num_items++;
3484 }
3485 }
3486 return 0;
3487}
3488
Kailang Yangdf694da2005-12-05 19:42:22 +01003489static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3490 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003491 int dac_idx)
3492{
3493 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3495 pin_type);
3496 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3497 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498 /* need the manual connection? */
3499 if (alc880_is_multi_pin(nid)) {
3500 struct alc_spec *spec = codec->spec;
3501 int idx = alc880_multi_pin_idx(nid);
3502 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3503 AC_VERB_SET_CONNECT_SEL,
3504 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3505 }
3506}
3507
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003508static int get_pin_type(int line_out_type)
3509{
3510 if (line_out_type == AUTO_PIN_HP_OUT)
3511 return PIN_HP;
3512 else
3513 return PIN_OUT;
3514}
3515
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003516static void alc880_auto_init_multi_out(struct hda_codec *codec)
3517{
3518 struct alc_spec *spec = codec->spec;
3519 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003520
3521 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003522 for (i = 0; i < spec->autocfg.line_outs; i++) {
3523 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003524 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3525 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003526 }
3527}
3528
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003529static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003530{
3531 struct alc_spec *spec = codec->spec;
3532 hda_nid_t pin;
3533
Takashi Iwai82bc9552006-03-21 11:24:42 +01003534 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003535 if (pin) /* connect to front */
3536 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003537 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 if (pin) /* connect to front */
3539 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3540}
3541
3542static void alc880_auto_init_analog_input(struct hda_codec *codec)
3543{
3544 struct alc_spec *spec = codec->spec;
3545 int i;
3546
3547 for (i = 0; i < AUTO_PIN_LAST; i++) {
3548 hda_nid_t nid = spec->autocfg.input_pins[i];
3549 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003550 snd_hda_codec_write(codec, nid, 0,
3551 AC_VERB_SET_PIN_WIDGET_CONTROL,
3552 i <= AUTO_PIN_FRONT_MIC ?
3553 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003554 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003555 snd_hda_codec_write(codec, nid, 0,
3556 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 AMP_OUT_MUTE);
3558 }
3559 }
3560}
3561
3562/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003563/* return 1 if successful, 0 if the proper config is not found,
3564 * or a negative error code
3565 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003566static int alc880_parse_auto_config(struct hda_codec *codec)
3567{
3568 struct alc_spec *spec = codec->spec;
3569 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003570 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003572 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3573 alc880_ignore);
3574 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003576 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003579 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3580 if (err < 0)
3581 return err;
3582 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3583 if (err < 0)
3584 return err;
3585 err = alc880_auto_create_extra_out(spec,
3586 spec->autocfg.speaker_pins[0],
3587 "Speaker");
3588 if (err < 0)
3589 return err;
3590 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3591 "Headphone");
3592 if (err < 0)
3593 return err;
3594 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3595 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 return err;
3597
3598 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3599
3600 if (spec->autocfg.dig_out_pin)
3601 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3602 if (spec->autocfg.dig_in_pin)
3603 spec->dig_in_nid = ALC880_DIGIN_NID;
3604
3605 if (spec->kctl_alloc)
3606 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3607
3608 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3609
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003610 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003611 spec->input_mux = &spec->private_imux;
3612
3613 return 1;
3614}
3615
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003616/* additional initialization for auto-configuration model */
3617static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003619 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003620 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003621 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622}
3623
3624/*
3625 * OK, here we have finally the patch for ALC880
3626 */
3627
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628static int patch_alc880(struct hda_codec *codec)
3629{
3630 struct alc_spec *spec;
3631 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003632 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003633
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003634 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003635 if (spec == NULL)
3636 return -ENOMEM;
3637
3638 codec->spec = spec;
3639
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003640 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3641 alc880_models,
3642 alc880_cfg_tbl);
3643 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003644 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3645 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003646 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647 }
3648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003649 if (board_config == ALC880_AUTO) {
3650 /* automatic parse from the BIOS config */
3651 err = alc880_parse_auto_config(codec);
3652 if (err < 0) {
3653 alc_free(codec);
3654 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003655 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003656 printk(KERN_INFO
3657 "hda_codec: Cannot set up configuration "
3658 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659 board_config = ALC880_3ST;
3660 }
3661 }
3662
Kailang Yangdf694da2005-12-05 19:42:22 +01003663 if (board_config != ALC880_AUTO)
3664 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003665
3666 spec->stream_name_analog = "ALC880 Analog";
3667 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3668 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003669 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003670
3671 spec->stream_name_digital = "ALC880 Digital";
3672 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3673 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3674
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003675 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003676 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003677 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003678 /* get type */
3679 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003680 if (wcap != AC_WID_AUD_IN) {
3681 spec->adc_nids = alc880_adc_nids_alt;
3682 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003683 spec->mixers[spec->num_mixers] =
3684 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003685 spec->num_mixers++;
3686 } else {
3687 spec->adc_nids = alc880_adc_nids;
3688 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3689 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3690 spec->num_mixers++;
3691 }
3692 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693
Takashi Iwai2134ea42008-01-10 16:53:55 +01003694 spec->vmaster_nid = 0x0c;
3695
Linus Torvalds1da177e2005-04-16 15:20:36 -07003696 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003697 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003698 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003699#ifdef CONFIG_SND_HDA_POWER_SAVE
3700 if (!spec->loopback.amplist)
3701 spec->loopback.amplist = alc880_loopbacks;
3702#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703
3704 return 0;
3705}
3706
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708/*
3709 * ALC260 support
3710 */
3711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003712static hda_nid_t alc260_dac_nids[1] = {
3713 /* front */
3714 0x02,
3715};
3716
3717static hda_nid_t alc260_adc_nids[1] = {
3718 /* ADC0 */
3719 0x04,
3720};
3721
Kailang Yangdf694da2005-12-05 19:42:22 +01003722static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003723 /* ADC1 */
3724 0x05,
3725};
3726
Kailang Yangdf694da2005-12-05 19:42:22 +01003727static hda_nid_t alc260_hp_adc_nids[2] = {
3728 /* ADC1, 0 */
3729 0x05, 0x04
3730};
3731
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003732/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3733 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3734 */
3735static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003736 /* ADC0, ADC1 */
3737 0x04, 0x05
3738};
3739
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740#define ALC260_DIGOUT_NID 0x03
3741#define ALC260_DIGIN_NID 0x06
3742
3743static struct hda_input_mux alc260_capture_source = {
3744 .num_items = 4,
3745 .items = {
3746 { "Mic", 0x0 },
3747 { "Front Mic", 0x1 },
3748 { "Line", 0x2 },
3749 { "CD", 0x4 },
3750 },
3751};
3752
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003753/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003754 * headphone jack and the internal CD lines since these are the only pins at
3755 * which audio can appear. For flexibility, also allow the option of
3756 * recording the mixer output on the second ADC (ADC0 doesn't have a
3757 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003758 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003759static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3760 {
3761 .num_items = 3,
3762 .items = {
3763 { "Mic/Line", 0x0 },
3764 { "CD", 0x4 },
3765 { "Headphone", 0x2 },
3766 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003767 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003768 {
3769 .num_items = 4,
3770 .items = {
3771 { "Mic/Line", 0x0 },
3772 { "CD", 0x4 },
3773 { "Headphone", 0x2 },
3774 { "Mixer", 0x5 },
3775 },
3776 },
3777
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003778};
3779
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003780/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3781 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003782 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003783static struct hda_input_mux alc260_acer_capture_sources[2] = {
3784 {
3785 .num_items = 4,
3786 .items = {
3787 { "Mic", 0x0 },
3788 { "Line", 0x2 },
3789 { "CD", 0x4 },
3790 { "Headphone", 0x5 },
3791 },
3792 },
3793 {
3794 .num_items = 5,
3795 .items = {
3796 { "Mic", 0x0 },
3797 { "Line", 0x2 },
3798 { "CD", 0x4 },
3799 { "Headphone", 0x6 },
3800 { "Mixer", 0x5 },
3801 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003802 },
3803};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003804/*
3805 * This is just place-holder, so there's something for alc_build_pcms to look
3806 * at when it calculates the maximum number of channels. ALC260 has no mixer
3807 * element which allows changing the channel mode, so the verb list is
3808 * never used.
3809 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003810static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811 { 2, NULL },
3812};
3813
Kailang Yangdf694da2005-12-05 19:42:22 +01003814
3815/* Mixer combinations
3816 *
3817 * basic: base_output + input + pc_beep + capture
3818 * HP: base_output + input + capture_alt
3819 * HP_3013: hp_3013 + input + capture
3820 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003821 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003822 */
3823
3824static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003825 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003826 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3828 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3829 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3830 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3831 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003832};
Kailang Yangdf694da2005-12-05 19:42:22 +01003833
3834static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003835 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3836 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3837 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3838 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3840 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003843 { } /* end */
3844};
3845
Kailang Yangdf694da2005-12-05 19:42:22 +01003846static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3847 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3848 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3849 { } /* end */
3850};
3851
Takashi Iwaibec15c32008-01-28 18:16:30 +01003852/* update HP, line and mono out pins according to the master switch */
3853static void alc260_hp_master_update(struct hda_codec *codec,
3854 hda_nid_t hp, hda_nid_t line,
3855 hda_nid_t mono)
3856{
3857 struct alc_spec *spec = codec->spec;
3858 unsigned int val = spec->master_sw ? PIN_HP : 0;
3859 /* change HP and line-out pins */
3860 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3861 val);
3862 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3863 val);
3864 /* mono (speaker) depending on the HP jack sense */
3865 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3866 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3867 val);
3868}
3869
3870static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3871 struct snd_ctl_elem_value *ucontrol)
3872{
3873 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3874 struct alc_spec *spec = codec->spec;
3875 *ucontrol->value.integer.value = spec->master_sw;
3876 return 0;
3877}
3878
3879static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3880 struct snd_ctl_elem_value *ucontrol)
3881{
3882 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3883 struct alc_spec *spec = codec->spec;
3884 int val = !!*ucontrol->value.integer.value;
3885 hda_nid_t hp, line, mono;
3886
3887 if (val == spec->master_sw)
3888 return 0;
3889 spec->master_sw = val;
3890 hp = (kcontrol->private_value >> 16) & 0xff;
3891 line = (kcontrol->private_value >> 8) & 0xff;
3892 mono = kcontrol->private_value & 0xff;
3893 alc260_hp_master_update(codec, hp, line, mono);
3894 return 1;
3895}
3896
3897static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3898 {
3899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3900 .name = "Master Playback Switch",
3901 .info = snd_ctl_boolean_mono_info,
3902 .get = alc260_hp_master_sw_get,
3903 .put = alc260_hp_master_sw_put,
3904 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3905 },
3906 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3907 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3908 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3909 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3910 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3911 HDA_OUTPUT),
3912 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3913 { } /* end */
3914};
3915
3916static struct hda_verb alc260_hp_unsol_verbs[] = {
3917 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3918 {},
3919};
3920
3921static void alc260_hp_automute(struct hda_codec *codec)
3922{
3923 struct alc_spec *spec = codec->spec;
3924 unsigned int present;
3925
3926 present = snd_hda_codec_read(codec, 0x10, 0,
3927 AC_VERB_GET_PIN_SENSE, 0);
3928 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3929 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3930}
3931
3932static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3933{
3934 if ((res >> 26) == ALC880_HP_EVENT)
3935 alc260_hp_automute(codec);
3936}
3937
Kailang Yangdf694da2005-12-05 19:42:22 +01003938static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01003939 {
3940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3941 .name = "Master Playback Switch",
3942 .info = snd_ctl_boolean_mono_info,
3943 .get = alc260_hp_master_sw_get,
3944 .put = alc260_hp_master_sw_put,
3945 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3946 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003947 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3948 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3949 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3950 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3951 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003953 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3954 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003955 { } /* end */
3956};
3957
Takashi Iwaibec15c32008-01-28 18:16:30 +01003958static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3959 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3960 {},
3961};
3962
3963static void alc260_hp_3013_automute(struct hda_codec *codec)
3964{
3965 struct alc_spec *spec = codec->spec;
3966 unsigned int present;
3967
3968 present = snd_hda_codec_read(codec, 0x15, 0,
3969 AC_VERB_GET_PIN_SENSE, 0);
3970 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3971 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3972}
3973
3974static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3975 unsigned int res)
3976{
3977 if ((res >> 26) == ALC880_HP_EVENT)
3978 alc260_hp_3013_automute(codec);
3979}
3980
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003981/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3982 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3983 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003984static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003986 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003987 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003988 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3989 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3990 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3991 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003992 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003993 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3994 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01003995 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3996 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003997 { } /* end */
3998};
3999
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004000/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4001 * versions of the ALC260 don't act on requests to enable mic bias from NID
4002 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4003 * datasheet doesn't mention this restriction. At this stage it's not clear
4004 * whether this behaviour is intentional or is a hardware bug in chip
4005 * revisions available in early 2006. Therefore for now allow the
4006 * "Headphone Jack Mode" control to span all choices, but if it turns out
4007 * that the lack of mic bias for this NID is intentional we could change the
4008 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4009 *
4010 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4011 * don't appear to make the mic bias available from the "line" jack, even
4012 * though the NID used for this jack (0x14) can supply it. The theory is
4013 * that perhaps Acer have included blocking capacitors between the ALC260
4014 * and the output jack. If this turns out to be the case for all such
4015 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4016 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004017 *
4018 * The C20x Tablet series have a mono internal speaker which is controlled
4019 * via the chip's Mono sum widget and pin complex, so include the necessary
4020 * controls for such models. On models without a "mono speaker" the control
4021 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004022 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004023static struct snd_kcontrol_new alc260_acer_mixer[] = {
4024 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4025 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004026 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004027 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004028 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004029 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004030 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004031 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4032 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4034 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4035 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4036 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4037 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4038 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4039 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4040 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4041 { } /* end */
4042};
4043
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004044/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4045 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4046 */
4047static struct snd_kcontrol_new alc260_will_mixer[] = {
4048 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4049 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4051 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4052 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4053 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4054 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4055 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4056 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4057 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4058 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4059 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4060 { } /* end */
4061};
4062
4063/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4064 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4065 */
4066static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4067 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4068 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4070 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4071 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4072 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4073 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4074 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4075 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4076 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4077 { } /* end */
4078};
4079
Kailang Yangdf694da2005-12-05 19:42:22 +01004080/* capture mixer elements */
4081static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004082 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4083 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004084 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4085 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004086 {
4087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004088 /* The multiple "Capture Source" controls confuse alsamixer
4089 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004090 */
4091 /* .name = "Capture Source", */
4092 .name = "Input Source",
4093 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004094 .info = alc_mux_enum_info,
4095 .get = alc_mux_enum_get,
4096 .put = alc_mux_enum_put,
4097 },
4098 { } /* end */
4099};
4100
Kailang Yangdf694da2005-12-05 19:42:22 +01004101static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4102 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4103 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4104 {
4105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4106 /* The multiple "Capture Source" controls confuse alsamixer
4107 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004108 */
4109 /* .name = "Capture Source", */
4110 .name = "Input Source",
4111 .count = 1,
4112 .info = alc_mux_enum_info,
4113 .get = alc_mux_enum_get,
4114 .put = alc_mux_enum_put,
4115 },
4116 { } /* end */
4117};
4118
4119/*
4120 * initialization verbs
4121 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004122static struct hda_verb alc260_init_verbs[] = {
4123 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004125 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004126 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004127 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004128 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004129 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004130 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004133 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004134 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004135 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004136 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004137 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004138 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004140 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4141 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004142 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 /* set connection select to line in (default select for this ADC) */
4144 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 /* mute capture amp left and right */
4146 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4147 /* set connection select to line in (default select for this ADC) */
4148 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004149 /* set vol=0 Line-Out mixer amp left and right */
4150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4151 /* unmute pin widget amp left and right (no gain on this amp) */
4152 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4153 /* set vol=0 HP mixer amp left and right */
4154 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4155 /* unmute pin widget amp left and right (no gain on this amp) */
4156 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4157 /* set vol=0 Mono mixer amp left and right */
4158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4159 /* unmute pin widget amp left and right (no gain on this amp) */
4160 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4161 /* unmute LINE-2 out pin */
4162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004163 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4164 * Line In 2 = 0x03
4165 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004166 /* mute analog inputs */
4167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004172 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004173 /* mute Front out path */
4174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4176 /* mute Headphone out path */
4177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4179 /* mute Mono out path */
4180 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4181 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004182 { }
4183};
4184
Takashi Iwai474167d2006-05-17 17:17:43 +02004185#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004186static struct hda_verb alc260_hp_init_verbs[] = {
4187 /* Headphone and output */
4188 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4189 /* mono output */
4190 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4191 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4192 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4193 /* Mic2 (front panel) pin widget for input and vref at 80% */
4194 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4195 /* Line In pin widget for input */
4196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4197 /* Line-2 pin widget for output */
4198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4199 /* CD pin widget for input */
4200 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4201 /* unmute amp left and right */
4202 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4203 /* set connection select to line in (default select for this ADC) */
4204 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4205 /* unmute Line-Out mixer amp left and right (volume = 0) */
4206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4207 /* mute pin widget amp left and right (no gain on this amp) */
4208 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4209 /* unmute HP mixer amp left and right (volume = 0) */
4210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4211 /* mute pin widget amp left and right (no gain on this amp) */
4212 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004213 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4214 * Line In 2 = 0x03
4215 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004216 /* mute analog inputs */
4217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004222 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4223 /* Unmute Front out path */
4224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4226 /* Unmute Headphone out path */
4227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4228 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4229 /* Unmute Mono out path */
4230 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4231 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4232 { }
4233};
Takashi Iwai474167d2006-05-17 17:17:43 +02004234#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004235
4236static struct hda_verb alc260_hp_3013_init_verbs[] = {
4237 /* Line out and output */
4238 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4239 /* mono output */
4240 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4241 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4242 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4243 /* Mic2 (front panel) pin widget for input and vref at 80% */
4244 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4245 /* Line In pin widget for input */
4246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4247 /* Headphone pin widget for output */
4248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4249 /* CD pin widget for input */
4250 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4251 /* unmute amp left and right */
4252 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4253 /* set connection select to line in (default select for this ADC) */
4254 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4255 /* unmute Line-Out mixer amp left and right (volume = 0) */
4256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4257 /* mute pin widget amp left and right (no gain on this amp) */
4258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4259 /* unmute HP mixer amp left and right (volume = 0) */
4260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4261 /* mute pin widget amp left and right (no gain on this amp) */
4262 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004263 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4264 * Line In 2 = 0x03
4265 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004266 /* mute analog inputs */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4268 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004272 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4273 /* Unmute Front out path */
4274 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4275 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4276 /* Unmute Headphone out path */
4277 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4278 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4279 /* Unmute Mono out path */
4280 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4281 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4282 { }
4283};
4284
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004285/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004286 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4287 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004288 */
4289static struct hda_verb alc260_fujitsu_init_verbs[] = {
4290 /* Disable all GPIOs */
4291 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4292 /* Internal speaker is connected to headphone pin */
4293 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4294 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4295 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004296 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4297 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4298 /* Ensure all other unused pins are disabled and muted. */
4299 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4300 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004301 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004302 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004303 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004304 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4305 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004307
Jonathan Woithef7ace402006-02-28 11:46:14 +01004308 /* Disable digital (SPDIF) pins */
4309 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4310 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004311
Jonathan Woithef7ace402006-02-28 11:46:14 +01004312 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4313 * when acting as an output.
4314 */
4315 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4316
4317 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4324 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4325 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4326 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004327
Jonathan Woithef7ace402006-02-28 11:46:14 +01004328 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4329 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4330 /* Unmute Line1 pin widget output buffer since it starts as an output.
4331 * If the pin mode is changed by the user the pin mode control will
4332 * take care of enabling the pin's input/output buffers as needed.
4333 * Therefore there's no need to enable the input buffer at this
4334 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004335 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004337 /* Unmute input buffer of pin widget used for Line-in (no equiv
4338 * mixer ctrl)
4339 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004340 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004341
Jonathan Woithef7ace402006-02-28 11:46:14 +01004342 /* Mute capture amp left and right */
4343 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4344 /* Set ADC connection select to match default mixer setting - line
4345 * in (on mic1 pin)
4346 */
4347 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004348
Jonathan Woithef7ace402006-02-28 11:46:14 +01004349 /* Do the same for the second ADC: mute capture input amp and
4350 * set ADC connection to line in (on mic1 pin)
4351 */
4352 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4353 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004354
Jonathan Woithef7ace402006-02-28 11:46:14 +01004355 /* Mute all inputs to mixer widget (even unconnected ones) */
4356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004364
4365 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004366};
4367
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004368/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4369 * similar laptops (adapted from Fujitsu init verbs).
4370 */
4371static struct hda_verb alc260_acer_init_verbs[] = {
4372 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4373 * the headphone jack. Turn this on and rely on the standard mute
4374 * methods whenever the user wants to turn these outputs off.
4375 */
4376 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4377 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4378 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4379 /* Internal speaker/Headphone jack is connected to Line-out pin */
4380 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4381 /* Internal microphone/Mic jack is connected to Mic1 pin */
4382 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4383 /* Line In jack is connected to Line1 pin */
4384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004385 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4386 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004387 /* Ensure all other unused pins are disabled and muted. */
4388 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4389 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004390 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4391 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4392 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4394 /* Disable digital (SPDIF) pins */
4395 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4396 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4397
4398 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4399 * bus when acting as outputs.
4400 */
4401 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4402 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4403
4404 /* Start with output sum widgets muted and their output gains at min */
4405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4411 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4412 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4413 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004415 /* Unmute Line-out pin widget amp left and right
4416 * (no equiv mixer ctrl)
4417 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004418 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004419 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4420 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004421 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4422 * inputs. If the pin mode is changed by the user the pin mode control
4423 * will take care of enabling the pin's input/output buffers as needed.
4424 * Therefore there's no need to enable the input buffer at this
4425 * stage.
4426 */
4427 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4429
4430 /* Mute capture amp left and right */
4431 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4432 /* Set ADC connection select to match default mixer setting - mic
4433 * (on mic1 pin)
4434 */
4435 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4436
4437 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004438 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004439 */
4440 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004441 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004442
4443 /* Mute all inputs to mixer widget (even unconnected ones) */
4444 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4452
4453 { }
4454};
4455
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004456static struct hda_verb alc260_will_verbs[] = {
4457 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4458 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4459 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4460 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4461 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4462 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4463 {}
4464};
4465
4466static struct hda_verb alc260_replacer_672v_verbs[] = {
4467 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4468 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4469 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4470
4471 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4472 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4473 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4474
4475 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4476 {}
4477};
4478
4479/* toggle speaker-output according to the hp-jack state */
4480static void alc260_replacer_672v_automute(struct hda_codec *codec)
4481{
4482 unsigned int present;
4483
4484 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4485 present = snd_hda_codec_read(codec, 0x0f, 0,
4486 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4487 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004488 snd_hda_codec_write_cache(codec, 0x01, 0,
4489 AC_VERB_SET_GPIO_DATA, 1);
4490 snd_hda_codec_write_cache(codec, 0x0f, 0,
4491 AC_VERB_SET_PIN_WIDGET_CONTROL,
4492 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004493 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004494 snd_hda_codec_write_cache(codec, 0x01, 0,
4495 AC_VERB_SET_GPIO_DATA, 0);
4496 snd_hda_codec_write_cache(codec, 0x0f, 0,
4497 AC_VERB_SET_PIN_WIDGET_CONTROL,
4498 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004499 }
4500}
4501
4502static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4503 unsigned int res)
4504{
4505 if ((res >> 26) == ALC880_HP_EVENT)
4506 alc260_replacer_672v_automute(codec);
4507}
4508
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004509/* Test configuration for debugging, modelled after the ALC880 test
4510 * configuration.
4511 */
4512#ifdef CONFIG_SND_DEBUG
4513static hda_nid_t alc260_test_dac_nids[1] = {
4514 0x02,
4515};
4516static hda_nid_t alc260_test_adc_nids[2] = {
4517 0x04, 0x05,
4518};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004519/* For testing the ALC260, each input MUX needs its own definition since
4520 * the signal assignments are different. This assumes that the first ADC
4521 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004522 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004523static struct hda_input_mux alc260_test_capture_sources[2] = {
4524 {
4525 .num_items = 7,
4526 .items = {
4527 { "MIC1 pin", 0x0 },
4528 { "MIC2 pin", 0x1 },
4529 { "LINE1 pin", 0x2 },
4530 { "LINE2 pin", 0x3 },
4531 { "CD pin", 0x4 },
4532 { "LINE-OUT pin", 0x5 },
4533 { "HP-OUT pin", 0x6 },
4534 },
4535 },
4536 {
4537 .num_items = 8,
4538 .items = {
4539 { "MIC1 pin", 0x0 },
4540 { "MIC2 pin", 0x1 },
4541 { "LINE1 pin", 0x2 },
4542 { "LINE2 pin", 0x3 },
4543 { "CD pin", 0x4 },
4544 { "Mixer", 0x5 },
4545 { "LINE-OUT pin", 0x6 },
4546 { "HP-OUT pin", 0x7 },
4547 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004548 },
4549};
4550static struct snd_kcontrol_new alc260_test_mixer[] = {
4551 /* Output driver widgets */
4552 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4553 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4554 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4555 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4556 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4557 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4558
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004559 /* Modes for retasking pin widgets
4560 * Note: the ALC260 doesn't seem to act on requests to enable mic
4561 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4562 * mention this restriction. At this stage it's not clear whether
4563 * this behaviour is intentional or is a hardware bug in chip
4564 * revisions available at least up until early 2006. Therefore for
4565 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4566 * choices, but if it turns out that the lack of mic bias for these
4567 * NIDs is intentional we could change their modes from
4568 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4569 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004570 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4571 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4572 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4573 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4574 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4575 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4576
4577 /* Loopback mixer controls */
4578 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4579 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4580 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4581 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4582 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4583 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4584 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4585 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4586 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4587 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4588 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4589 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4590 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4591 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4592 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4593 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004594
4595 /* Controls for GPIO pins, assuming they are configured as outputs */
4596 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4597 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4598 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4599 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4600
Jonathan Woithe92621f12006-02-28 11:47:47 +01004601 /* Switches to allow the digital IO pins to be enabled. The datasheet
4602 * is ambigious as to which NID is which; testing on laptops which
4603 * make this output available should provide clarification.
4604 */
4605 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4606 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4607
Jonathan Woithef8225f62008-01-08 12:16:54 +01004608 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4609 * this output to turn on an external amplifier.
4610 */
4611 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4612 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4613
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004614 { } /* end */
4615};
4616static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004617 /* Enable all GPIOs as outputs with an initial value of 0 */
4618 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4619 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4620 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4621
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004622 /* Enable retasking pins as output, initially without power amp */
4623 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4624 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4627 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4628 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4629
Jonathan Woithe92621f12006-02-28 11:47:47 +01004630 /* Disable digital (SPDIF) pins initially, but users can enable
4631 * them via a mixer switch. In the case of SPDIF-out, this initverb
4632 * payload also sets the generation to 0, output to be in "consumer"
4633 * PCM format, copyright asserted, no pre-emphasis and no validity
4634 * control.
4635 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004636 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4637 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4638
Jonathan Woithef7ace402006-02-28 11:46:14 +01004639 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004640 * OUT1 sum bus when acting as an output.
4641 */
4642 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4643 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4644 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4645 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4646
4647 /* Start with output sum widgets muted and their output gains at min */
4648 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4649 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4651 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4652 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4654 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4655 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4656 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4657
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004658 /* Unmute retasking pin widget output buffers since the default
4659 * state appears to be output. As the pin mode is changed by the
4660 * user the pin mode control will take care of enabling the pin's
4661 * input/output buffers as needed.
4662 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004663 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4664 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4667 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4668 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4669 /* Also unmute the mono-out pin widget */
4670 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4671
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004672 /* Mute capture amp left and right */
4673 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004674 /* Set ADC connection select to match default mixer setting (mic1
4675 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004676 */
4677 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4678
4679 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004680 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004681 */
4682 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4683 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4684
4685 /* Mute all inputs to mixer widget (even unconnected ones) */
4686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4694
4695 { }
4696};
4697#endif
4698
Takashi Iwai63300792008-01-24 15:31:36 +01004699#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4700#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004701
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004702#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4703#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4704
Kailang Yangdf694da2005-12-05 19:42:22 +01004705/*
4706 * for BIOS auto-configuration
4707 */
4708
4709static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4710 const char *pfx)
4711{
4712 hda_nid_t nid_vol;
4713 unsigned long vol_val, sw_val;
4714 char name[32];
4715 int err;
4716
4717 if (nid >= 0x0f && nid < 0x11) {
4718 nid_vol = nid - 0x7;
4719 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4720 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4721 } else if (nid == 0x11) {
4722 nid_vol = nid - 0x7;
4723 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4724 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4725 } else if (nid >= 0x12 && nid <= 0x15) {
4726 nid_vol = 0x08;
4727 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4728 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4729 } else
4730 return 0; /* N/A */
4731
4732 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004733 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4734 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004735 return err;
4736 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004737 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4738 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004739 return err;
4740 return 1;
4741}
4742
4743/* add playback controls from the parsed DAC table */
4744static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4745 const struct auto_pin_cfg *cfg)
4746{
4747 hda_nid_t nid;
4748 int err;
4749
4750 spec->multiout.num_dacs = 1;
4751 spec->multiout.dac_nids = spec->private_dac_nids;
4752 spec->multiout.dac_nids[0] = 0x02;
4753
4754 nid = cfg->line_out_pins[0];
4755 if (nid) {
4756 err = alc260_add_playback_controls(spec, nid, "Front");
4757 if (err < 0)
4758 return err;
4759 }
4760
Takashi Iwai82bc9552006-03-21 11:24:42 +01004761 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004762 if (nid) {
4763 err = alc260_add_playback_controls(spec, nid, "Speaker");
4764 if (err < 0)
4765 return err;
4766 }
4767
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004768 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 if (nid) {
4770 err = alc260_add_playback_controls(spec, nid, "Headphone");
4771 if (err < 0)
4772 return err;
4773 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004774 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004775}
4776
4777/* create playback/capture controls for input pins */
4778static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4779 const struct auto_pin_cfg *cfg)
4780{
Kailang Yangdf694da2005-12-05 19:42:22 +01004781 struct hda_input_mux *imux = &spec->private_imux;
4782 int i, err, idx;
4783
4784 for (i = 0; i < AUTO_PIN_LAST; i++) {
4785 if (cfg->input_pins[i] >= 0x12) {
4786 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004787 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004788 auto_pin_cfg_labels[i], idx,
4789 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004790 if (err < 0)
4791 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004792 imux->items[imux->num_items].label =
4793 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004794 imux->items[imux->num_items].index = idx;
4795 imux->num_items++;
4796 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004797 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004798 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004799 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004800 auto_pin_cfg_labels[i], idx,
4801 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004802 if (err < 0)
4803 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004804 imux->items[imux->num_items].label =
4805 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004806 imux->items[imux->num_items].index = idx;
4807 imux->num_items++;
4808 }
4809 }
4810 return 0;
4811}
4812
4813static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4814 hda_nid_t nid, int pin_type,
4815 int sel_idx)
4816{
4817 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4819 pin_type);
4820 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4821 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 /* need the manual connection? */
4823 if (nid >= 0x12) {
4824 int idx = nid - 0x12;
4825 snd_hda_codec_write(codec, idx + 0x0b, 0,
4826 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004827 }
4828}
4829
4830static void alc260_auto_init_multi_out(struct hda_codec *codec)
4831{
4832 struct alc_spec *spec = codec->spec;
4833 hda_nid_t nid;
4834
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004835 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004836 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004837 if (nid) {
4838 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4839 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4840 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004841
Takashi Iwai82bc9552006-03-21 11:24:42 +01004842 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004843 if (nid)
4844 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4845
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004846 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004847 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004848 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004849}
Kailang Yangdf694da2005-12-05 19:42:22 +01004850
4851#define ALC260_PIN_CD_NID 0x16
4852static void alc260_auto_init_analog_input(struct hda_codec *codec)
4853{
4854 struct alc_spec *spec = codec->spec;
4855 int i;
4856
4857 for (i = 0; i < AUTO_PIN_LAST; i++) {
4858 hda_nid_t nid = spec->autocfg.input_pins[i];
4859 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004860 snd_hda_codec_write(codec, nid, 0,
4861 AC_VERB_SET_PIN_WIDGET_CONTROL,
4862 i <= AUTO_PIN_FRONT_MIC ?
4863 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004864 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004865 snd_hda_codec_write(codec, nid, 0,
4866 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004867 AMP_OUT_MUTE);
4868 }
4869 }
4870}
4871
4872/*
4873 * generic initialization of ADC, input mixers and output mixers
4874 */
4875static struct hda_verb alc260_volume_init_verbs[] = {
4876 /*
4877 * Unmute ADC0-1 and set the default input to mic-in
4878 */
4879 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4880 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4881 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4882 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4883
4884 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4885 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004886 * Note: PASD motherboards uses the Line In 2 as the input for
4887 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004888 */
4889 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004890 /* mute analog inputs */
4891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004896
4897 /*
4898 * Set up output mixers (0x08 - 0x0a)
4899 */
4900 /* set vol=0 to output mixers */
4901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4904 /* set up input amps for analog loopback */
4905 /* Amp Indices: DAC = 0, mixer = 1 */
4906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4909 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4911 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4912
4913 { }
4914};
4915
4916static int alc260_parse_auto_config(struct hda_codec *codec)
4917{
4918 struct alc_spec *spec = codec->spec;
4919 unsigned int wcap;
4920 int err;
4921 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4922
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004923 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4924 alc260_ignore);
4925 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004926 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004927 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4928 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004929 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004930 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004931 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004932 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4933 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004934 return err;
4935
4936 spec->multiout.max_channels = 2;
4937
4938 if (spec->autocfg.dig_out_pin)
4939 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4940 if (spec->kctl_alloc)
4941 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4942
4943 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4944
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004945 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 spec->input_mux = &spec->private_imux;
4947
4948 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004949 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004950 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4951 if (wcap != AC_WID_AUD_IN) {
4952 spec->adc_nids = alc260_adc_nids_alt;
4953 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4954 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004955 } else {
4956 spec->adc_nids = alc260_adc_nids;
4957 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4958 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004959 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004960 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004961
4962 return 1;
4963}
4964
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004965/* additional initialization for auto-configuration model */
4966static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004967{
Kailang Yangdf694da2005-12-05 19:42:22 +01004968 alc260_auto_init_multi_out(codec);
4969 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004970}
4971
Takashi Iwaicb53c622007-08-10 17:21:45 +02004972#ifdef CONFIG_SND_HDA_POWER_SAVE
4973static struct hda_amp_list alc260_loopbacks[] = {
4974 { 0x07, HDA_INPUT, 0 },
4975 { 0x07, HDA_INPUT, 1 },
4976 { 0x07, HDA_INPUT, 2 },
4977 { 0x07, HDA_INPUT, 3 },
4978 { 0x07, HDA_INPUT, 4 },
4979 { } /* end */
4980};
4981#endif
4982
Kailang Yangdf694da2005-12-05 19:42:22 +01004983/*
4984 * ALC260 configurations
4985 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004986static const char *alc260_models[ALC260_MODEL_LAST] = {
4987 [ALC260_BASIC] = "basic",
4988 [ALC260_HP] = "hp",
4989 [ALC260_HP_3013] = "hp-3013",
4990 [ALC260_FUJITSU_S702X] = "fujitsu",
4991 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004992 [ALC260_WILL] = "will",
4993 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004994#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004995 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004996#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004997 [ALC260_AUTO] = "auto",
4998};
4999
5000static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005001 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005002 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005003 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005004 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005005 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5006 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5007 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5008 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5009 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5010 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5011 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5012 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5013 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5014 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5015 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5016 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005017 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005018 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005019 {}
5020};
5021
Kailang Yangdf694da2005-12-05 19:42:22 +01005022static struct alc_config_preset alc260_presets[] = {
5023 [ALC260_BASIC] = {
5024 .mixers = { alc260_base_output_mixer,
5025 alc260_input_mixer,
5026 alc260_pc_beep_mixer,
5027 alc260_capture_mixer },
5028 .init_verbs = { alc260_init_verbs },
5029 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5030 .dac_nids = alc260_dac_nids,
5031 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5032 .adc_nids = alc260_adc_nids,
5033 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5034 .channel_mode = alc260_modes,
5035 .input_mux = &alc260_capture_source,
5036 },
5037 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005038 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005039 alc260_input_mixer,
5040 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005041 .init_verbs = { alc260_init_verbs,
5042 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005043 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5044 .dac_nids = alc260_dac_nids,
5045 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5046 .adc_nids = alc260_hp_adc_nids,
5047 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5048 .channel_mode = alc260_modes,
5049 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005050 .unsol_event = alc260_hp_unsol_event,
5051 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005052 },
5053 [ALC260_HP_3013] = {
5054 .mixers = { alc260_hp_3013_mixer,
5055 alc260_input_mixer,
5056 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005057 .init_verbs = { alc260_hp_3013_init_verbs,
5058 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005059 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5060 .dac_nids = alc260_dac_nids,
5061 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5062 .adc_nids = alc260_hp_adc_nids,
5063 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5064 .channel_mode = alc260_modes,
5065 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005066 .unsol_event = alc260_hp_3013_unsol_event,
5067 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005068 },
5069 [ALC260_FUJITSU_S702X] = {
5070 .mixers = { alc260_fujitsu_mixer,
5071 alc260_capture_mixer },
5072 .init_verbs = { alc260_fujitsu_init_verbs },
5073 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5074 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005075 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5076 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005077 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5078 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005079 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5080 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005081 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005082 [ALC260_ACER] = {
5083 .mixers = { alc260_acer_mixer,
5084 alc260_capture_mixer },
5085 .init_verbs = { alc260_acer_init_verbs },
5086 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5087 .dac_nids = alc260_dac_nids,
5088 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5089 .adc_nids = alc260_dual_adc_nids,
5090 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5091 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005092 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5093 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005094 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005095 [ALC260_WILL] = {
5096 .mixers = { alc260_will_mixer,
5097 alc260_capture_mixer },
5098 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5099 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5100 .dac_nids = alc260_dac_nids,
5101 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5102 .adc_nids = alc260_adc_nids,
5103 .dig_out_nid = ALC260_DIGOUT_NID,
5104 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5105 .channel_mode = alc260_modes,
5106 .input_mux = &alc260_capture_source,
5107 },
5108 [ALC260_REPLACER_672V] = {
5109 .mixers = { alc260_replacer_672v_mixer,
5110 alc260_capture_mixer },
5111 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5112 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5113 .dac_nids = alc260_dac_nids,
5114 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5115 .adc_nids = alc260_adc_nids,
5116 .dig_out_nid = ALC260_DIGOUT_NID,
5117 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5118 .channel_mode = alc260_modes,
5119 .input_mux = &alc260_capture_source,
5120 .unsol_event = alc260_replacer_672v_unsol_event,
5121 .init_hook = alc260_replacer_672v_automute,
5122 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005123#ifdef CONFIG_SND_DEBUG
5124 [ALC260_TEST] = {
5125 .mixers = { alc260_test_mixer,
5126 alc260_capture_mixer },
5127 .init_verbs = { alc260_test_init_verbs },
5128 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5129 .dac_nids = alc260_test_dac_nids,
5130 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5131 .adc_nids = alc260_test_adc_nids,
5132 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5133 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005134 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5135 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005136 },
5137#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005138};
5139
Linus Torvalds1da177e2005-04-16 15:20:36 -07005140static int patch_alc260(struct hda_codec *codec)
5141{
5142 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005143 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005144
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005145 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005146 if (spec == NULL)
5147 return -ENOMEM;
5148
5149 codec->spec = spec;
5150
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005151 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5152 alc260_models,
5153 alc260_cfg_tbl);
5154 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005155 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5156 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005157 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005158 }
5159
Kailang Yangdf694da2005-12-05 19:42:22 +01005160 if (board_config == ALC260_AUTO) {
5161 /* automatic parse from the BIOS config */
5162 err = alc260_parse_auto_config(codec);
5163 if (err < 0) {
5164 alc_free(codec);
5165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005166 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005167 printk(KERN_INFO
5168 "hda_codec: Cannot set up configuration "
5169 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 board_config = ALC260_BASIC;
5171 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005172 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005173
Kailang Yangdf694da2005-12-05 19:42:22 +01005174 if (board_config != ALC260_AUTO)
5175 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005176
5177 spec->stream_name_analog = "ALC260 Analog";
5178 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5179 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5180
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005181 spec->stream_name_digital = "ALC260 Digital";
5182 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5183 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5184
Takashi Iwai2134ea42008-01-10 16:53:55 +01005185 spec->vmaster_nid = 0x08;
5186
Linus Torvalds1da177e2005-04-16 15:20:36 -07005187 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005188 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005189 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005190#ifdef CONFIG_SND_HDA_POWER_SAVE
5191 if (!spec->loopback.amplist)
5192 spec->loopback.amplist = alc260_loopbacks;
5193#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005194
5195 return 0;
5196}
5197
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005198
Linus Torvalds1da177e2005-04-16 15:20:36 -07005199/*
5200 * ALC882 support
5201 *
5202 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5203 * configuration. Each pin widget can choose any input DACs and a mixer.
5204 * Each ADC is connected from a mixer of all inputs. This makes possible
5205 * 6-channel independent captures.
5206 *
5207 * In addition, an independent DAC for the multi-playback (not used in this
5208 * driver yet).
5209 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005210#define ALC882_DIGOUT_NID 0x06
5211#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005212
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005213static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005214 { 8, NULL }
5215};
5216
5217static hda_nid_t alc882_dac_nids[4] = {
5218 /* front, rear, clfe, rear_surr */
5219 0x02, 0x03, 0x04, 0x05
5220};
5221
Kailang Yangdf694da2005-12-05 19:42:22 +01005222/* identical with ALC880 */
5223#define alc882_adc_nids alc880_adc_nids
5224#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005225
Takashi Iwaie1406342008-02-11 18:32:32 +01005226static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5227static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5228
Linus Torvalds1da177e2005-04-16 15:20:36 -07005229/* input MUX */
5230/* FIXME: should be a matrix-type input source selection */
5231
5232static struct hda_input_mux alc882_capture_source = {
5233 .num_items = 4,
5234 .items = {
5235 { "Mic", 0x0 },
5236 { "Front Mic", 0x1 },
5237 { "Line", 0x2 },
5238 { "CD", 0x4 },
5239 },
5240};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005241#define alc882_mux_enum_info alc_mux_enum_info
5242#define alc882_mux_enum_get alc_mux_enum_get
5243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005244static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5245 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005246{
5247 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5248 struct alc_spec *spec = codec->spec;
5249 const struct hda_input_mux *imux = spec->input_mux;
5250 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaie1406342008-02-11 18:32:32 +01005251 hda_nid_t nid = spec->capsrc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005252 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5253 unsigned int i, idx;
5254
5255 idx = ucontrol->value.enumerated.item[0];
5256 if (idx >= imux->num_items)
5257 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005258 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005259 return 0;
5260 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005261 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5262 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005263 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005264 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005265 }
5266 *cur_val = idx;
5267 return 1;
5268}
5269
Kailang Yangdf694da2005-12-05 19:42:22 +01005270/*
Kailang Yang272a5272007-05-14 11:00:38 +02005271 * 2ch mode
5272 */
5273static struct hda_verb alc882_3ST_ch2_init[] = {
5274 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5275 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5276 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5277 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5278 { } /* end */
5279};
5280
5281/*
5282 * 6ch mode
5283 */
5284static struct hda_verb alc882_3ST_ch6_init[] = {
5285 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5286 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5287 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5288 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5289 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5290 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5291 { } /* end */
5292};
5293
5294static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5295 { 2, alc882_3ST_ch2_init },
5296 { 6, alc882_3ST_ch6_init },
5297};
5298
5299/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005300 * 6ch mode
5301 */
5302static struct hda_verb alc882_sixstack_ch6_init[] = {
5303 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5304 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5305 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5306 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5307 { } /* end */
5308};
5309
5310/*
5311 * 8ch mode
5312 */
5313static struct hda_verb alc882_sixstack_ch8_init[] = {
5314 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5315 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5316 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5317 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5318 { } /* end */
5319};
5320
5321static struct hda_channel_mode alc882_sixstack_modes[2] = {
5322 { 6, alc882_sixstack_ch6_init },
5323 { 8, alc882_sixstack_ch8_init },
5324};
5325
Takashi Iwai87350ad2007-08-16 18:19:38 +02005326/*
5327 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5328 */
5329
5330/*
5331 * 2ch mode
5332 */
5333static struct hda_verb alc885_mbp_ch2_init[] = {
5334 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5335 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5336 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5337 { } /* end */
5338};
5339
5340/*
5341 * 6ch mode
5342 */
5343static struct hda_verb alc885_mbp_ch6_init[] = {
5344 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5345 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5346 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5347 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5348 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5349 { } /* end */
5350};
5351
5352static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5353 { 2, alc885_mbp_ch2_init },
5354 { 6, alc885_mbp_ch6_init },
5355};
5356
5357
Linus Torvalds1da177e2005-04-16 15:20:36 -07005358/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5359 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5360 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005361static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005362 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005363 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005364 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005365 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005366 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5367 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005368 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5369 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005370 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005371 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5373 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5374 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5375 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5376 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5380 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005381 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005382 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5383 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5384 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005385 { } /* end */
5386};
5387
Takashi Iwai87350ad2007-08-16 18:19:38 +02005388static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005389 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5390 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5391 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5392 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5394 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5396 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005397 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005398 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5399 { } /* end */
5400};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005401static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5402 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5403 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5404 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5405 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5406 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5407 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5411 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5412 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5413 { } /* end */
5414};
5415
Kailang Yang272a5272007-05-14 11:00:38 +02005416static struct snd_kcontrol_new alc882_targa_mixer[] = {
5417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5419 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005426 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005429 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005430 { } /* end */
5431};
5432
5433/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5434 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5435 */
5436static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5438 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5440 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5443 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5444 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5445 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5446 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005449 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005450 { } /* end */
5451};
5452
Takashi Iwai914759b2007-09-06 14:52:04 +02005453static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5454 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5455 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5457 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5458 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5459 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5460 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5462 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5464 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5465 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5466 { } /* end */
5467};
5468
Kailang Yangdf694da2005-12-05 19:42:22 +01005469static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5470 {
5471 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5472 .name = "Channel Mode",
5473 .info = alc_ch_mode_info,
5474 .get = alc_ch_mode_get,
5475 .put = alc_ch_mode_put,
5476 },
5477 { } /* end */
5478};
5479
Linus Torvalds1da177e2005-04-16 15:20:36 -07005480static struct hda_verb alc882_init_verbs[] = {
5481 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005485 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005489 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005493 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005494 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5495 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5496 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005498 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005502 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005503 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005506 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005507 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005509 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005510 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005511 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005512 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005514 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005516 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5517 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005519 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5520 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005522 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5523 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5525 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5526 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005527 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005528 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005529
5530 /* FIXME: use matrix-type input source selection */
5531 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5532 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5535 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5536 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005537 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5539 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5541 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005542 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5547 /* ADC1: mute amp left and right */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005549 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005550 /* ADC2: mute amp left and right */
5551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005552 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005553 /* ADC3: mute amp left and right */
5554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005555 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005556
5557 { }
5558};
5559
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005560static struct hda_verb alc882_eapd_verbs[] = {
5561 /* change to EAPD mode */
5562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005563 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005564 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005565};
5566
Tobin Davis9102cd12006-12-15 10:02:12 +01005567/* Mac Pro test */
5568static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5569 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5570 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5574 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5575 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5576 { } /* end */
5577};
5578
5579static struct hda_verb alc882_macpro_init_verbs[] = {
5580 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5584 /* Front Pin: output 0 (0x0c) */
5585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5588 /* Front Mic pin: input vref at 80% */
5589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5591 /* Speaker: output */
5592 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5594 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5595 /* Headphone output (output 0 - 0x0c) */
5596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5598 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5599
5600 /* FIXME: use matrix-type input source selection */
5601 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5602 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5607 /* Input mixer2 */
5608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5609 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5612 /* Input mixer3 */
5613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5617 /* ADC1: mute amp left and right */
5618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5619 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5620 /* ADC2: mute amp left and right */
5621 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5622 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5623 /* ADC3: mute amp left and right */
5624 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5625 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5626
5627 { }
5628};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005629
Takashi Iwai87350ad2007-08-16 18:19:38 +02005630/* Macbook Pro rev3 */
5631static struct hda_verb alc885_mbp3_init_verbs[] = {
5632 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5633 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5636 /* Rear mixer */
5637 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5640 /* Front Pin: output 0 (0x0c) */
5641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5643 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5644 /* HP Pin: output 0 (0x0d) */
5645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5648 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5649 /* Mic (rear) pin: input vref at 80% */
5650 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5652 /* Front Mic pin: input vref at 80% */
5653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5655 /* Line In pin: use output 1 when in LineOut mode */
5656 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5657 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5658 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5659
5660 /* FIXME: use matrix-type input source selection */
5661 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5662 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5667 /* Input mixer2 */
5668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5672 /* Input mixer3 */
5673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5677 /* ADC1: mute amp left and right */
5678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5679 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5680 /* ADC2: mute amp left and right */
5681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5682 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5683 /* ADC3: mute amp left and right */
5684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5685 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5686
5687 { }
5688};
5689
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005690/* iMac 24 mixer. */
5691static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5692 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5693 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5694 { } /* end */
5695};
5696
5697/* iMac 24 init verbs. */
5698static struct hda_verb alc885_imac24_init_verbs[] = {
5699 /* Internal speakers: output 0 (0x0c) */
5700 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5701 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5702 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5703 /* Internal speakers: output 0 (0x0c) */
5704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5706 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5707 /* Headphone: output 0 (0x0c) */
5708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5710 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5711 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5712 /* Front Mic: input vref at 80% */
5713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5714 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5715 { }
5716};
5717
5718/* Toggle speaker-output according to the hp-jack state */
5719static void alc885_imac24_automute(struct hda_codec *codec)
5720{
5721 unsigned int present;
5722
5723 present = snd_hda_codec_read(codec, 0x14, 0,
5724 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005725 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5726 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5727 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5728 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005729}
5730
5731/* Processes unsolicited events. */
5732static void alc885_imac24_unsol_event(struct hda_codec *codec,
5733 unsigned int res)
5734{
5735 /* Headphone insertion or removal. */
5736 if ((res >> 26) == ALC880_HP_EVENT)
5737 alc885_imac24_automute(codec);
5738}
5739
Takashi Iwai87350ad2007-08-16 18:19:38 +02005740static void alc885_mbp3_automute(struct hda_codec *codec)
5741{
5742 unsigned int present;
5743
5744 present = snd_hda_codec_read(codec, 0x15, 0,
5745 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5746 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5747 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5748 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5749 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5750
5751}
5752static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5753 unsigned int res)
5754{
5755 /* Headphone insertion or removal. */
5756 if ((res >> 26) == ALC880_HP_EVENT)
5757 alc885_mbp3_automute(codec);
5758}
5759
5760
Kailang Yang272a5272007-05-14 11:00:38 +02005761static struct hda_verb alc882_targa_verbs[] = {
5762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5764
5765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5767
5768 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5769 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5770 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5771
5772 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5773 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5774 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5775 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5776 { } /* end */
5777};
5778
5779/* toggle speaker-output according to the hp-jack state */
5780static void alc882_targa_automute(struct hda_codec *codec)
5781{
5782 unsigned int present;
5783
5784 present = snd_hda_codec_read(codec, 0x14, 0,
5785 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005786 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5787 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005788 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5789 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005790}
5791
5792static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5793{
5794 /* Looks like the unsol event is incompatible with the standard
5795 * definition. 4bit tag is placed at 26 bit!
5796 */
5797 if (((res >> 26) == ALC880_HP_EVENT)) {
5798 alc882_targa_automute(codec);
5799 }
5800}
5801
5802static struct hda_verb alc882_asus_a7j_verbs[] = {
5803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5805
5806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5809
5810 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5812 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5813
5814 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5815 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5816 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5817 { } /* end */
5818};
5819
Takashi Iwai914759b2007-09-06 14:52:04 +02005820static struct hda_verb alc882_asus_a7m_verbs[] = {
5821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5823
5824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5827
5828 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5830 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5831
5832 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5833 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5834 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5835 { } /* end */
5836};
5837
Tobin Davis9102cd12006-12-15 10:02:12 +01005838static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5839{
5840 unsigned int gpiostate, gpiomask, gpiodir;
5841
5842 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5843 AC_VERB_GET_GPIO_DATA, 0);
5844
5845 if (!muted)
5846 gpiostate |= (1 << pin);
5847 else
5848 gpiostate &= ~(1 << pin);
5849
5850 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5851 AC_VERB_GET_GPIO_MASK, 0);
5852 gpiomask |= (1 << pin);
5853
5854 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5855 AC_VERB_GET_GPIO_DIRECTION, 0);
5856 gpiodir |= (1 << pin);
5857
5858
5859 snd_hda_codec_write(codec, codec->afg, 0,
5860 AC_VERB_SET_GPIO_MASK, gpiomask);
5861 snd_hda_codec_write(codec, codec->afg, 0,
5862 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5863
5864 msleep(1);
5865
5866 snd_hda_codec_write(codec, codec->afg, 0,
5867 AC_VERB_SET_GPIO_DATA, gpiostate);
5868}
5869
Takashi Iwai7debbe52007-08-16 15:01:03 +02005870/* set up GPIO at initialization */
5871static void alc885_macpro_init_hook(struct hda_codec *codec)
5872{
5873 alc882_gpio_mute(codec, 0, 0);
5874 alc882_gpio_mute(codec, 1, 0);
5875}
5876
5877/* set up GPIO and update auto-muting at initialization */
5878static void alc885_imac24_init_hook(struct hda_codec *codec)
5879{
5880 alc885_macpro_init_hook(codec);
5881 alc885_imac24_automute(codec);
5882}
5883
Kailang Yangdf694da2005-12-05 19:42:22 +01005884/*
5885 * generic initialization of ADC, input mixers and output mixers
5886 */
5887static struct hda_verb alc882_auto_init_verbs[] = {
5888 /*
5889 * Unmute ADC0-2 and set the default input to mic-in
5890 */
5891 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5893 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5894 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5895 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5897
Takashi Iwaicb53c622007-08-10 17:21:45 +02005898 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005899 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005900 * Note: PASD motherboards uses the Line In 2 as the input for
5901 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005902 */
5903 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005909
5910 /*
5911 * Set up output mixers (0x0c - 0x0f)
5912 */
5913 /* set vol=0 to output mixers */
5914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5917 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5918 /* set up input amps for analog loopback */
5919 /* Amp Indices: DAC = 0, mixer = 1 */
5920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5928 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5929 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5930
5931 /* FIXME: use matrix-type input source selection */
5932 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5933 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5936 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5938 /* Input mixer2 */
5939 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5943 /* Input mixer3 */
5944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5948
5949 { }
5950};
5951
5952/* capture mixer elements */
5953static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5954 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5955 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5956 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5957 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5958 {
5959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5960 /* The multiple "Capture Source" controls confuse alsamixer
5961 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005962 */
5963 /* .name = "Capture Source", */
5964 .name = "Input Source",
5965 .count = 2,
5966 .info = alc882_mux_enum_info,
5967 .get = alc882_mux_enum_get,
5968 .put = alc882_mux_enum_put,
5969 },
5970 { } /* end */
5971};
5972
5973static struct snd_kcontrol_new alc882_capture_mixer[] = {
5974 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5975 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5976 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5977 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5978 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5979 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5980 {
5981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5982 /* The multiple "Capture Source" controls confuse alsamixer
5983 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005984 */
5985 /* .name = "Capture Source", */
5986 .name = "Input Source",
5987 .count = 3,
5988 .info = alc882_mux_enum_info,
5989 .get = alc882_mux_enum_get,
5990 .put = alc882_mux_enum_put,
5991 },
5992 { } /* end */
5993};
5994
Takashi Iwaicb53c622007-08-10 17:21:45 +02005995#ifdef CONFIG_SND_HDA_POWER_SAVE
5996#define alc882_loopbacks alc880_loopbacks
5997#endif
5998
Kailang Yangdf694da2005-12-05 19:42:22 +01005999/* pcm configuration: identiacal with ALC880 */
6000#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6001#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6002#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6003#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6004
6005/*
6006 * configuration and preset
6007 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006008static const char *alc882_models[ALC882_MODEL_LAST] = {
6009 [ALC882_3ST_DIG] = "3stack-dig",
6010 [ALC882_6ST_DIG] = "6stack-dig",
6011 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006012 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006013 [ALC882_TARGA] = "targa",
6014 [ALC882_ASUS_A7J] = "asus-a7j",
6015 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006016 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006017 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006018 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006019 [ALC882_AUTO] = "auto",
6020};
6021
6022static struct snd_pci_quirk alc882_cfg_tbl[] = {
6023 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006024 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006025 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006026 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006027 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006028 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006029 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006030 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006031 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006032 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6033 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6034 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006035 {}
6036};
6037
6038static struct alc_config_preset alc882_presets[] = {
6039 [ALC882_3ST_DIG] = {
6040 .mixers = { alc882_base_mixer },
6041 .init_verbs = { alc882_init_verbs },
6042 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6043 .dac_nids = alc882_dac_nids,
6044 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 .dig_in_nid = ALC882_DIGIN_NID,
6046 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6047 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006048 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006049 .input_mux = &alc882_capture_source,
6050 },
6051 [ALC882_6ST_DIG] = {
6052 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6053 .init_verbs = { alc882_init_verbs },
6054 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6055 .dac_nids = alc882_dac_nids,
6056 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006057 .dig_in_nid = ALC882_DIGIN_NID,
6058 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6059 .channel_mode = alc882_sixstack_modes,
6060 .input_mux = &alc882_capture_source,
6061 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006062 [ALC882_ARIMA] = {
6063 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6064 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6065 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6066 .dac_nids = alc882_dac_nids,
6067 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6068 .channel_mode = alc882_sixstack_modes,
6069 .input_mux = &alc882_capture_source,
6070 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006071 [ALC882_W2JC] = {
6072 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6073 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6074 alc880_gpio1_init_verbs },
6075 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6076 .dac_nids = alc882_dac_nids,
6077 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6078 .channel_mode = alc880_threestack_modes,
6079 .need_dac_fix = 1,
6080 .input_mux = &alc882_capture_source,
6081 .dig_out_nid = ALC882_DIGOUT_NID,
6082 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006083 [ALC885_MBP3] = {
6084 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6085 .init_verbs = { alc885_mbp3_init_verbs,
6086 alc880_gpio1_init_verbs },
6087 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6088 .dac_nids = alc882_dac_nids,
6089 .channel_mode = alc885_mbp_6ch_modes,
6090 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6091 .input_mux = &alc882_capture_source,
6092 .dig_out_nid = ALC882_DIGOUT_NID,
6093 .dig_in_nid = ALC882_DIGIN_NID,
6094 .unsol_event = alc885_mbp3_unsol_event,
6095 .init_hook = alc885_mbp3_automute,
6096 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006097 [ALC885_MACPRO] = {
6098 .mixers = { alc882_macpro_mixer },
6099 .init_verbs = { alc882_macpro_init_verbs },
6100 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6101 .dac_nids = alc882_dac_nids,
6102 .dig_out_nid = ALC882_DIGOUT_NID,
6103 .dig_in_nid = ALC882_DIGIN_NID,
6104 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6105 .channel_mode = alc882_ch_modes,
6106 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006107 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006108 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006109 [ALC885_IMAC24] = {
6110 .mixers = { alc885_imac24_mixer },
6111 .init_verbs = { alc885_imac24_init_verbs },
6112 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6113 .dac_nids = alc882_dac_nids,
6114 .dig_out_nid = ALC882_DIGOUT_NID,
6115 .dig_in_nid = ALC882_DIGIN_NID,
6116 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6117 .channel_mode = alc882_ch_modes,
6118 .input_mux = &alc882_capture_source,
6119 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006120 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006121 },
Kailang Yang272a5272007-05-14 11:00:38 +02006122 [ALC882_TARGA] = {
6123 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6124 alc882_capture_mixer },
6125 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6127 .dac_nids = alc882_dac_nids,
6128 .dig_out_nid = ALC882_DIGOUT_NID,
6129 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6130 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006131 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006132 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6133 .channel_mode = alc882_3ST_6ch_modes,
6134 .need_dac_fix = 1,
6135 .input_mux = &alc882_capture_source,
6136 .unsol_event = alc882_targa_unsol_event,
6137 .init_hook = alc882_targa_automute,
6138 },
6139 [ALC882_ASUS_A7J] = {
6140 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6141 alc882_capture_mixer },
6142 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6143 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6144 .dac_nids = alc882_dac_nids,
6145 .dig_out_nid = ALC882_DIGOUT_NID,
6146 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6147 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006148 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006149 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6150 .channel_mode = alc882_3ST_6ch_modes,
6151 .need_dac_fix = 1,
6152 .input_mux = &alc882_capture_source,
6153 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006154 [ALC882_ASUS_A7M] = {
6155 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6156 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6157 alc880_gpio1_init_verbs,
6158 alc882_asus_a7m_verbs },
6159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6160 .dac_nids = alc882_dac_nids,
6161 .dig_out_nid = ALC882_DIGOUT_NID,
6162 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6163 .channel_mode = alc880_threestack_modes,
6164 .need_dac_fix = 1,
6165 .input_mux = &alc882_capture_source,
6166 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006167};
6168
6169
6170/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006171 * Pin config fixes
6172 */
6173enum {
6174 PINFIX_ABIT_AW9D_MAX
6175};
6176
6177static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6178 { 0x15, 0x01080104 }, /* side */
6179 { 0x16, 0x01011012 }, /* rear */
6180 { 0x17, 0x01016011 }, /* clfe */
6181 { }
6182};
6183
6184static const struct alc_pincfg *alc882_pin_fixes[] = {
6185 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6186};
6187
6188static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6189 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6190 {}
6191};
6192
6193/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006194 * BIOS auto configuration
6195 */
6196static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6197 hda_nid_t nid, int pin_type,
6198 int dac_idx)
6199{
6200 /* set as output */
6201 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006202 int idx;
6203
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6205 idx = 4;
6206 else
6207 idx = spec->multiout.dac_nids[dac_idx] - 2;
6208
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006209 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6210 pin_type);
6211 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6212 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6214
6215}
6216
6217static void alc882_auto_init_multi_out(struct hda_codec *codec)
6218{
6219 struct alc_spec *spec = codec->spec;
6220 int i;
6221
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006222 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006223 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006224 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006225 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006226 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006227 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006228 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006229 }
6230}
6231
6232static void alc882_auto_init_hp_out(struct hda_codec *codec)
6233{
6234 struct alc_spec *spec = codec->spec;
6235 hda_nid_t pin;
6236
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006237 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 /* use dac 0 */
6240 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006241}
6242
6243#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6244#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6245
6246static void alc882_auto_init_analog_input(struct hda_codec *codec)
6247{
6248 struct alc_spec *spec = codec->spec;
6249 int i;
6250
6251 for (i = 0; i < AUTO_PIN_LAST; i++) {
6252 hda_nid_t nid = spec->autocfg.input_pins[i];
6253 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006254 snd_hda_codec_write(codec, nid, 0,
6255 AC_VERB_SET_PIN_WIDGET_CONTROL,
6256 i <= AUTO_PIN_FRONT_MIC ?
6257 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006258 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 snd_hda_codec_write(codec, nid, 0,
6260 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 AMP_OUT_MUTE);
6262 }
6263 }
6264}
6265
Takashi Iwai776e1842007-08-29 15:07:11 +02006266/* add mic boosts if needed */
6267static int alc_auto_add_mic_boost(struct hda_codec *codec)
6268{
6269 struct alc_spec *spec = codec->spec;
6270 int err;
6271 hda_nid_t nid;
6272
6273 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006274 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006275 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6276 "Mic Boost",
6277 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6278 if (err < 0)
6279 return err;
6280 }
6281 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006282 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006283 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6284 "Front Mic Boost",
6285 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6286 if (err < 0)
6287 return err;
6288 }
6289 return 0;
6290}
6291
Kailang Yangdf694da2005-12-05 19:42:22 +01006292/* almost identical with ALC880 parser... */
6293static int alc882_parse_auto_config(struct hda_codec *codec)
6294{
6295 struct alc_spec *spec = codec->spec;
6296 int err = alc880_parse_auto_config(codec);
6297
6298 if (err < 0)
6299 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006300 else if (!err)
6301 return 0; /* no config found */
6302
6303 err = alc_auto_add_mic_boost(codec);
6304 if (err < 0)
6305 return err;
6306
6307 /* hack - override the init verbs */
6308 spec->init_verbs[0] = alc882_auto_init_verbs;
6309
6310 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006311}
6312
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006313/* additional initialization for auto-configuration model */
6314static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006315{
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 alc882_auto_init_multi_out(codec);
6317 alc882_auto_init_hp_out(codec);
6318 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006319}
6320
Linus Torvalds1da177e2005-04-16 15:20:36 -07006321static int patch_alc882(struct hda_codec *codec)
6322{
6323 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006324 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006325
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006326 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006327 if (spec == NULL)
6328 return -ENOMEM;
6329
Linus Torvalds1da177e2005-04-16 15:20:36 -07006330 codec->spec = spec;
6331
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006332 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6333 alc882_models,
6334 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006335
Kailang Yangdf694da2005-12-05 19:42:22 +01006336 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006337 /* Pick up systems that don't supply PCI SSID */
6338 switch (codec->subsystem_id) {
6339 case 0x106b0c00: /* Mac Pro */
6340 board_config = ALC885_MACPRO;
6341 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006342 case 0x106b1000: /* iMac 24 */
6343 board_config = ALC885_IMAC24;
6344 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006345 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006346 case 0x106b2c00: /* Macbook Pro rev3 */
6347 board_config = ALC885_MBP3;
6348 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006349 default:
6350 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6351 "trying auto-probe from BIOS...\n");
6352 board_config = ALC882_AUTO;
6353 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006354 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006355
Takashi Iwaif95474e2007-07-10 00:47:43 +02006356 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6357
Kailang Yangdf694da2005-12-05 19:42:22 +01006358 if (board_config == ALC882_AUTO) {
6359 /* automatic parse from the BIOS config */
6360 err = alc882_parse_auto_config(codec);
6361 if (err < 0) {
6362 alc_free(codec);
6363 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006364 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006365 printk(KERN_INFO
6366 "hda_codec: Cannot set up configuration "
6367 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006368 board_config = ALC882_3ST_DIG;
6369 }
6370 }
6371
6372 if (board_config != ALC882_AUTO)
6373 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006374
6375 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006376 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6377 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006378 /* FIXME: setup DAC5 */
6379 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6380 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006381
6382 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006383 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6384 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006385
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006386 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006387 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006388 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006389 /* get type */
6390 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006391 if (wcap != AC_WID_AUD_IN) {
6392 spec->adc_nids = alc882_adc_nids_alt;
6393 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006394 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006395 spec->mixers[spec->num_mixers] =
6396 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006397 spec->num_mixers++;
6398 } else {
6399 spec->adc_nids = alc882_adc_nids;
6400 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006401 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006402 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6403 spec->num_mixers++;
6404 }
6405 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006406
Takashi Iwai2134ea42008-01-10 16:53:55 +01006407 spec->vmaster_nid = 0x0c;
6408
Linus Torvalds1da177e2005-04-16 15:20:36 -07006409 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006410 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006411 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006412#ifdef CONFIG_SND_HDA_POWER_SAVE
6413 if (!spec->loopback.amplist)
6414 spec->loopback.amplist = alc882_loopbacks;
6415#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006416
6417 return 0;
6418}
6419
6420/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006421 * ALC883 support
6422 *
6423 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6424 * configuration. Each pin widget can choose any input DACs and a mixer.
6425 * Each ADC is connected from a mixer of all inputs. This makes possible
6426 * 6-channel independent captures.
6427 *
6428 * In addition, an independent DAC for the multi-playback (not used in this
6429 * driver yet).
6430 */
6431#define ALC883_DIGOUT_NID 0x06
6432#define ALC883_DIGIN_NID 0x0a
6433
6434static hda_nid_t alc883_dac_nids[4] = {
6435 /* front, rear, clfe, rear_surr */
6436 0x02, 0x04, 0x03, 0x05
6437};
6438
6439static hda_nid_t alc883_adc_nids[2] = {
6440 /* ADC1-2 */
6441 0x08, 0x09,
6442};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006443
Takashi Iwaie1406342008-02-11 18:32:32 +01006444static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6445
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006446/* input MUX */
6447/* FIXME: should be a matrix-type input source selection */
6448
6449static struct hda_input_mux alc883_capture_source = {
6450 .num_items = 4,
6451 .items = {
6452 { "Mic", 0x0 },
6453 { "Front Mic", 0x1 },
6454 { "Line", 0x2 },
6455 { "CD", 0x4 },
6456 },
6457};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006458
6459static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6460 .num_items = 2,
6461 .items = {
6462 { "Mic", 0x1 },
6463 { "Line", 0x2 },
6464 },
6465};
6466
Kailang Yang272a5272007-05-14 11:00:38 +02006467static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6468 .num_items = 4,
6469 .items = {
6470 { "Mic", 0x0 },
6471 { "iMic", 0x1 },
6472 { "Line", 0x2 },
6473 { "CD", 0x4 },
6474 },
6475};
6476
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006477#define alc883_mux_enum_info alc_mux_enum_info
6478#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006479/* ALC883 has the ALC882-type input selection */
6480#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006481
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006482/*
6483 * 2ch mode
6484 */
6485static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6486 { 2, NULL }
6487};
6488
6489/*
6490 * 2ch mode
6491 */
6492static struct hda_verb alc883_3ST_ch2_init[] = {
6493 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6494 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6495 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6496 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6497 { } /* end */
6498};
6499
6500/*
Tobin Davisb2011312007-09-17 12:45:11 +02006501 * 4ch mode
6502 */
6503static struct hda_verb alc883_3ST_ch4_init[] = {
6504 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6505 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6506 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6507 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6508 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6509 { } /* end */
6510};
6511
6512/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006513 * 6ch mode
6514 */
6515static struct hda_verb alc883_3ST_ch6_init[] = {
6516 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6517 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6518 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6519 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6520 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6521 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6522 { } /* end */
6523};
6524
Tobin Davisb2011312007-09-17 12:45:11 +02006525static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006526 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006527 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006528 { 6, alc883_3ST_ch6_init },
6529};
6530
6531/*
6532 * 6ch mode
6533 */
6534static struct hda_verb alc883_sixstack_ch6_init[] = {
6535 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6536 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6537 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6538 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6539 { } /* end */
6540};
6541
6542/*
6543 * 8ch mode
6544 */
6545static struct hda_verb alc883_sixstack_ch8_init[] = {
6546 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6547 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6548 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6549 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6550 { } /* end */
6551};
6552
6553static struct hda_channel_mode alc883_sixstack_modes[2] = {
6554 { 6, alc883_sixstack_ch6_init },
6555 { 8, alc883_sixstack_ch8_init },
6556};
6557
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006558static struct hda_verb alc883_medion_eapd_verbs[] = {
6559 /* eanable EAPD on medion laptop */
6560 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6561 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6562 { }
6563};
6564
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006565/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6566 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6567 */
6568
6569static struct snd_kcontrol_new alc883_base_mixer[] = {
6570 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6571 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6572 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6573 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6574 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6575 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6576 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6577 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6578 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6579 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6580 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6581 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6582 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6583 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6584 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006586 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6588 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006589 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006590 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6591 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6592 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6593 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6594 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6595 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6596 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6597 {
6598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6599 /* .name = "Capture Source", */
6600 .name = "Input Source",
6601 .count = 2,
6602 .info = alc883_mux_enum_info,
6603 .get = alc883_mux_enum_get,
6604 .put = alc883_mux_enum_put,
6605 },
6606 { } /* end */
6607};
6608
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006609static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6611 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6612 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6614 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6615 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6620 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6621 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6622 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6623 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6624 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6625 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6626 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6627 {
6628 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6629 /* .name = "Capture Source", */
6630 .name = "Input Source",
6631 .count = 2,
6632 .info = alc883_mux_enum_info,
6633 .get = alc883_mux_enum_get,
6634 .put = alc883_mux_enum_put,
6635 },
6636 { } /* end */
6637};
6638
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006639static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6640 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6641 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006648 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6650 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006651 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6653 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6654 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6655 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6656 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6657 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6658 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6659 {
6660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6661 /* .name = "Capture Source", */
6662 .name = "Input Source",
6663 .count = 2,
6664 .info = alc883_mux_enum_info,
6665 .get = alc883_mux_enum_get,
6666 .put = alc883_mux_enum_put,
6667 },
6668 { } /* end */
6669};
6670
6671static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6672 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6674 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6675 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6676 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6677 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6678 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6679 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6680 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6681 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6682 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6683 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6684 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6688 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006689 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006690 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6691 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6692 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6693 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6694 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6695 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6696 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6697 {
6698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6699 /* .name = "Capture Source", */
6700 .name = "Input Source",
6701 .count = 2,
6702 .info = alc883_mux_enum_info,
6703 .get = alc883_mux_enum_get,
6704 .put = alc883_mux_enum_put,
6705 },
6706 { } /* end */
6707};
6708
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006709static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006710 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6711 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6712 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6713 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6714 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6715 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6716 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6717 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6719 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6720 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006724 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006727 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6729 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6730 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6731 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6732 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6733
6734 {
6735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6736 /* .name = "Capture Source", */
6737 .name = "Input Source",
6738 .count = 1,
6739 .info = alc883_mux_enum_info,
6740 .get = alc883_mux_enum_get,
6741 .put = alc883_mux_enum_put,
6742 },
6743 { } /* end */
6744};
6745
Kailang Yangccc656c2006-10-17 12:32:26 +02006746static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6747 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6748 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6749 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6750 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6751 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6752 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6753 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6754 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6755 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6763 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6764 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6765 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6766 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6767 {
6768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6769 /* .name = "Capture Source", */
6770 .name = "Input Source",
6771 .count = 2,
6772 .info = alc883_mux_enum_info,
6773 .get = alc883_mux_enum_get,
6774 .put = alc883_mux_enum_put,
6775 },
6776 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006777};
Kailang Yangccc656c2006-10-17 12:32:26 +02006778
6779static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6780 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6782 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6783 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6784 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006786 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6788 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6789 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6790 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6791 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6792 {
6793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6794 /* .name = "Capture Source", */
6795 .name = "Input Source",
6796 .count = 2,
6797 .info = alc883_mux_enum_info,
6798 .get = alc883_mux_enum_get,
6799 .put = alc883_mux_enum_put,
6800 },
6801 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006802};
Kailang Yangccc656c2006-10-17 12:32:26 +02006803
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006804static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006807 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6808 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6813 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6814 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6815 {
6816 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6817 /* .name = "Capture Source", */
6818 .name = "Input Source",
6819 .count = 1,
6820 .info = alc883_mux_enum_info,
6821 .get = alc883_mux_enum_get,
6822 .put = alc883_mux_enum_put,
6823 },
6824 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006825};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006826
Kailang Yang272a5272007-05-14 11:00:38 +02006827static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6828 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6829 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6835 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6836 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6837 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6838 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6839 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6840 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6841 {
6842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6843 /* .name = "Capture Source", */
6844 .name = "Input Source",
6845 .count = 2,
6846 .info = alc883_mux_enum_info,
6847 .get = alc883_mux_enum_get,
6848 .put = alc883_mux_enum_put,
6849 },
6850 { } /* end */
6851};
6852
6853static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6856 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6863 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6864 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6865 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6866 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6867 {
6868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6869 /* .name = "Capture Source", */
6870 .name = "Input Source",
6871 .count = 2,
6872 .info = alc883_mux_enum_info,
6873 .get = alc883_mux_enum_get,
6874 .put = alc883_mux_enum_put,
6875 },
6876 { } /* end */
6877};
6878
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006879static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6883 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6888 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6889 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6890 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6891 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6892 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6893 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6894 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6897 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6899 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6900 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6901 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6902 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6903 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6904 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6905 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6906 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6907 {
6908 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6909 /* .name = "Capture Source", */
6910 .name = "Input Source",
6911 .count = 2,
6912 .info = alc883_mux_enum_info,
6913 .get = alc883_mux_enum_get,
6914 .put = alc883_mux_enum_put,
6915 },
6916 { } /* end */
6917};
6918
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006919static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6923 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6925 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6926 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6927 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6937 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6939 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6940 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6942 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6943 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6944 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6945 {
6946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6947 /* .name = "Capture Source", */
6948 .name = "Input Source",
6949 .count = 2,
6950 .info = alc883_mux_enum_info,
6951 .get = alc883_mux_enum_get,
6952 .put = alc883_mux_enum_put,
6953 },
6954 { } /* end */
6955};
6956
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006957static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6958 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6961 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6966 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6977 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6979 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6980 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6981 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6982 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6983 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6985 {
6986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6987 /* .name = "Capture Source", */
6988 .name = "Input Source",
6989 .count = 2,
6990 .info = alc883_mux_enum_info,
6991 .get = alc883_mux_enum_get,
6992 .put = alc883_mux_enum_put,
6993 },
6994 { } /* end */
6995};
6996
Tobin Davis2880a862007-08-07 11:50:26 +02006997static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7004 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7005 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007006 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7007 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7008 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7009 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7010 {
7011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7012 /* .name = "Capture Source", */
7013 .name = "Input Source",
7014 .count = 2,
7015 .info = alc883_mux_enum_info,
7016 .get = alc883_mux_enum_get,
7017 .put = alc883_mux_enum_put,
7018 },
7019 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007020};
Tobin Davis2880a862007-08-07 11:50:26 +02007021
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007022static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7023 {
7024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7025 .name = "Channel Mode",
7026 .info = alc_ch_mode_info,
7027 .get = alc_ch_mode_get,
7028 .put = alc_ch_mode_put,
7029 },
7030 { } /* end */
7031};
7032
7033static struct hda_verb alc883_init_verbs[] = {
7034 /* ADC1: mute amp left and right */
7035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7036 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7037 /* ADC2: mute amp left and right */
7038 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7039 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7040 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7044 /* Rear mixer */
7045 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7046 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7048 /* CLFE mixer */
7049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7052 /* Side mixer */
7053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7054 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7056
Takashi Iwaicb53c622007-08-10 17:21:45 +02007057 /* mute analog input loopbacks */
7058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007063
7064 /* Front Pin: output 0 (0x0c) */
7065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7067 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7068 /* Rear Pin: output 1 (0x0d) */
7069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7071 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7072 /* CLFE Pin: output 2 (0x0e) */
7073 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7074 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7075 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7076 /* Side Pin: output 3 (0x0f) */
7077 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7079 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7080 /* Mic (rear) pin: input vref at 80% */
7081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7083 /* Front Mic pin: input vref at 80% */
7084 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7085 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7086 /* Line In pin: input */
7087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7088 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7089 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7091 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7092 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7093 /* CD pin widget for input */
7094 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7095
7096 /* FIXME: use matrix-type input source selection */
7097 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7098 /* Input mixer2 */
7099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7103 /* Input mixer3 */
7104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7108 { }
7109};
7110
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007111/* toggle speaker-output according to the hp-jack state */
7112static void alc883_mitac_hp_automute(struct hda_codec *codec)
7113{
7114 unsigned int present;
7115
7116 present = snd_hda_codec_read(codec, 0x15, 0,
7117 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7118 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7119 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7120 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7121 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7122}
7123
7124/* auto-toggle front mic */
7125/*
7126static void alc883_mitac_mic_automute(struct hda_codec *codec)
7127{
7128 unsigned int present;
7129 unsigned char bits;
7130
7131 present = snd_hda_codec_read(codec, 0x18, 0,
7132 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7133 bits = present ? HDA_AMP_MUTE : 0;
7134 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7135}
7136*/
7137
7138static void alc883_mitac_automute(struct hda_codec *codec)
7139{
7140 alc883_mitac_hp_automute(codec);
7141 /* alc883_mitac_mic_automute(codec); */
7142}
7143
7144static void alc883_mitac_unsol_event(struct hda_codec *codec,
7145 unsigned int res)
7146{
7147 switch (res >> 26) {
7148 case ALC880_HP_EVENT:
7149 alc883_mitac_hp_automute(codec);
7150 break;
7151 case ALC880_MIC_EVENT:
7152 /* alc883_mitac_mic_automute(codec); */
7153 break;
7154 }
7155}
7156
7157static struct hda_verb alc883_mitac_verbs[] = {
7158 /* HP */
7159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7161 /* Subwoofer */
7162 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7163 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7164
7165 /* enable unsolicited event */
7166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7167 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7168
7169 { } /* end */
7170};
7171
Kailang Yangccc656c2006-10-17 12:32:26 +02007172static struct hda_verb alc883_tagra_verbs[] = {
7173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7175
7176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7177 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7178
7179 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7180 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7181 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7182
7183 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007184 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7185 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7186 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007187
7188 { } /* end */
7189};
7190
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007191static struct hda_verb alc883_lenovo_101e_verbs[] = {
7192 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7194 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7195 { } /* end */
7196};
7197
Kailang Yang272a5272007-05-14 11:00:38 +02007198static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7201 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7203 { } /* end */
7204};
7205
7206static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7210 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7211 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7212 { } /* end */
7213};
7214
Kailang Yang189609a2007-08-20 11:31:23 +02007215static struct hda_verb alc883_haier_w66_verbs[] = {
7216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7218
7219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7220
7221 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7222 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7225 { } /* end */
7226};
7227
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007228static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007229 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7230 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7231 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7232 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7233 { }
7234};
7235
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007236static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7238 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7239 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7240 { }
7241};
7242
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007243static struct hda_verb alc888_6st_dell_verbs[] = {
7244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7246 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7247 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7248 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7249 { }
7250};
7251
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007252static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007253 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7254 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7255 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7256 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7257 { }
7258};
7259
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007260static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007261 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7262 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7263 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7264 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7265 { }
7266};
7267
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007268static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7269 { 2, alc888_3st_hp_2ch_init },
7270 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007271};
7272
Kailang Yang272a5272007-05-14 11:00:38 +02007273/* toggle front-jack and RCA according to the hp-jack state */
7274static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7275{
7276 unsigned int present;
7277
7278 present = snd_hda_codec_read(codec, 0x1b, 0,
7279 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007280 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7281 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7282 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7283 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007284}
7285
7286/* toggle RCA according to the front-jack state */
7287static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7288{
7289 unsigned int present;
7290
7291 present = snd_hda_codec_read(codec, 0x14, 0,
7292 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007293 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7294 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007295}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007296
Kailang Yang272a5272007-05-14 11:00:38 +02007297static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7298 unsigned int res)
7299{
7300 if ((res >> 26) == ALC880_HP_EVENT)
7301 alc888_lenovo_ms7195_front_automute(codec);
7302 if ((res >> 26) == ALC880_FRONT_EVENT)
7303 alc888_lenovo_ms7195_rca_automute(codec);
7304}
7305
7306static struct hda_verb alc883_medion_md2_verbs[] = {
7307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7309
7310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7311
7312 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7313 { } /* end */
7314};
7315
7316/* toggle speaker-output according to the hp-jack state */
7317static void alc883_medion_md2_automute(struct hda_codec *codec)
7318{
7319 unsigned int present;
7320
7321 present = snd_hda_codec_read(codec, 0x14, 0,
7322 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007323 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7324 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007325}
7326
7327static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7328 unsigned int res)
7329{
7330 if ((res >> 26) == ALC880_HP_EVENT)
7331 alc883_medion_md2_automute(codec);
7332}
7333
Kailang Yangccc656c2006-10-17 12:32:26 +02007334/* toggle speaker-output according to the hp-jack state */
7335static void alc883_tagra_automute(struct hda_codec *codec)
7336{
7337 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007338 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007339
7340 present = snd_hda_codec_read(codec, 0x14, 0,
7341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007342 bits = present ? HDA_AMP_MUTE : 0;
7343 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7344 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007345 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7346 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007347}
7348
7349static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7350{
7351 if ((res >> 26) == ALC880_HP_EVENT)
7352 alc883_tagra_automute(codec);
7353}
7354
Kailang Yang189609a2007-08-20 11:31:23 +02007355static void alc883_haier_w66_automute(struct hda_codec *codec)
7356{
7357 unsigned int present;
7358 unsigned char bits;
7359
7360 present = snd_hda_codec_read(codec, 0x1b, 0,
7361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7362 bits = present ? 0x80 : 0;
7363 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7364 0x80, bits);
7365}
7366
7367static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7368 unsigned int res)
7369{
7370 if ((res >> 26) == ALC880_HP_EVENT)
7371 alc883_haier_w66_automute(codec);
7372}
7373
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007374static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7375{
7376 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007377 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007378
7379 present = snd_hda_codec_read(codec, 0x14, 0,
7380 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007381 bits = present ? HDA_AMP_MUTE : 0;
7382 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7383 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007384}
7385
7386static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7387{
7388 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007389 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007390
7391 present = snd_hda_codec_read(codec, 0x1b, 0,
7392 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007393 bits = present ? HDA_AMP_MUTE : 0;
7394 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7395 HDA_AMP_MUTE, bits);
7396 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7397 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007398}
7399
7400static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7401 unsigned int res)
7402{
7403 if ((res >> 26) == ALC880_HP_EVENT)
7404 alc883_lenovo_101e_all_automute(codec);
7405 if ((res >> 26) == ALC880_FRONT_EVENT)
7406 alc883_lenovo_101e_ispeaker_automute(codec);
7407}
7408
Takashi Iwai676a9b52007-08-16 15:23:35 +02007409/* toggle speaker-output according to the hp-jack state */
7410static void alc883_acer_aspire_automute(struct hda_codec *codec)
7411{
7412 unsigned int present;
7413
7414 present = snd_hda_codec_read(codec, 0x14, 0,
7415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7416 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7417 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7418 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7420}
7421
7422static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7423 unsigned int res)
7424{
7425 if ((res >> 26) == ALC880_HP_EVENT)
7426 alc883_acer_aspire_automute(codec);
7427}
7428
Kailang Yangd1a991a2007-08-15 16:21:59 +02007429static struct hda_verb alc883_acer_eapd_verbs[] = {
7430 /* HP Pin: output 0 (0x0c) */
7431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7432 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7433 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7434 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7436 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007437 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007438 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7439 /* eanable EAPD on medion laptop */
7440 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7441 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007442 /* enable unsolicited event */
7443 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007444 { }
7445};
7446
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007447static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7448{
7449 unsigned int present;
7450
7451 present = snd_hda_codec_read(codec, 0x1b, 0,
7452 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7453 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7454 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7455 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7456 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7457 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7459 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7460 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7461}
7462
7463static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7464 unsigned int res)
7465{
7466 switch (res >> 26) {
7467 case ALC880_HP_EVENT:
7468 printk("hp_event\n");
7469 alc888_6st_dell_front_automute(codec);
7470 break;
7471 }
7472}
7473
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007474/*
7475 * generic initialization of ADC, input mixers and output mixers
7476 */
7477static struct hda_verb alc883_auto_init_verbs[] = {
7478 /*
7479 * Unmute ADC0-2 and set the default input to mic-in
7480 */
7481 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7483 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7485
Takashi Iwaicb53c622007-08-10 17:21:45 +02007486 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007487 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007488 * Note: PASD motherboards uses the Line In 2 as the input for
7489 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007490 */
7491 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7493 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007497
7498 /*
7499 * Set up output mixers (0x0c - 0x0f)
7500 */
7501 /* set vol=0 to output mixers */
7502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7506 /* set up input amps for analog loopback */
7507 /* Amp Indices: DAC = 0, mixer = 1 */
7508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7516 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7517 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7518
7519 /* FIXME: use matrix-type input source selection */
7520 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7521 /* Input mixer1 */
7522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007525 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7527 /* Input mixer2 */
7528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007531 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007533
7534 { }
7535};
7536
7537/* capture mixer elements */
7538static struct snd_kcontrol_new alc883_capture_mixer[] = {
7539 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7540 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7541 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7542 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7543 {
7544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7545 /* The multiple "Capture Source" controls confuse alsamixer
7546 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007547 */
7548 /* .name = "Capture Source", */
7549 .name = "Input Source",
7550 .count = 2,
7551 .info = alc882_mux_enum_info,
7552 .get = alc882_mux_enum_get,
7553 .put = alc882_mux_enum_put,
7554 },
7555 { } /* end */
7556};
7557
Takashi Iwaicb53c622007-08-10 17:21:45 +02007558#ifdef CONFIG_SND_HDA_POWER_SAVE
7559#define alc883_loopbacks alc880_loopbacks
7560#endif
7561
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007562/* pcm configuration: identiacal with ALC880 */
7563#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7564#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007565#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007566#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7567#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7568
7569/*
7570 * configuration and preset
7571 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007572static const char *alc883_models[ALC883_MODEL_LAST] = {
7573 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7574 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7575 [ALC883_3ST_6ch] = "3stack-6ch",
7576 [ALC883_6ST_DIG] = "6stack-dig",
7577 [ALC883_TARGA_DIG] = "targa-dig",
7578 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007579 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007580 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007581 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007582 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007583 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007584 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007585 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7586 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007587 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007588 [ALC888_6ST_HP] = "6stack-hp",
7589 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007590 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007591 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007592 [ALC883_AUTO] = "auto",
7593};
7594
7595static struct snd_pci_quirk alc883_cfg_tbl[] = {
7596 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007597 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7598 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7599 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7600 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007601 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007602 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007603 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7604 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7605 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7606 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007607 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007608 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7609 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7610 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007611 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007612 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7613 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7614 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7615 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7616 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7617 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7619 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7620 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7621 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7622 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7623 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7624 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007625 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7626 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007627 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007628 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007629 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007630 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007631 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7632 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007633 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007634 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007635 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007636 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007637 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7638 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007639 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007640 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007641 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007642 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007643 {}
7644};
7645
7646static struct alc_config_preset alc883_presets[] = {
7647 [ALC883_3ST_2ch_DIG] = {
7648 .mixers = { alc883_3ST_2ch_mixer },
7649 .init_verbs = { alc883_init_verbs },
7650 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7651 .dac_nids = alc883_dac_nids,
7652 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007653 .dig_in_nid = ALC883_DIGIN_NID,
7654 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7655 .channel_mode = alc883_3ST_2ch_modes,
7656 .input_mux = &alc883_capture_source,
7657 },
7658 [ALC883_3ST_6ch_DIG] = {
7659 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7660 .init_verbs = { alc883_init_verbs },
7661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7662 .dac_nids = alc883_dac_nids,
7663 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007664 .dig_in_nid = ALC883_DIGIN_NID,
7665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7666 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007667 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007668 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007669 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007670 [ALC883_3ST_6ch] = {
7671 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7672 .init_verbs = { alc883_init_verbs },
7673 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7674 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007675 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7676 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007677 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007678 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007679 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007680 [ALC883_6ST_DIG] = {
7681 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7682 .init_verbs = { alc883_init_verbs },
7683 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7684 .dac_nids = alc883_dac_nids,
7685 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007686 .dig_in_nid = ALC883_DIGIN_NID,
7687 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7688 .channel_mode = alc883_sixstack_modes,
7689 .input_mux = &alc883_capture_source,
7690 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007691 [ALC883_TARGA_DIG] = {
7692 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7693 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7694 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7695 .dac_nids = alc883_dac_nids,
7696 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007697 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7698 .channel_mode = alc883_3ST_6ch_modes,
7699 .need_dac_fix = 1,
7700 .input_mux = &alc883_capture_source,
7701 .unsol_event = alc883_tagra_unsol_event,
7702 .init_hook = alc883_tagra_automute,
7703 },
7704 [ALC883_TARGA_2ch_DIG] = {
7705 .mixers = { alc883_tagra_2ch_mixer},
7706 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7708 .dac_nids = alc883_dac_nids,
7709 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7711 .channel_mode = alc883_3ST_2ch_modes,
7712 .input_mux = &alc883_capture_source,
7713 .unsol_event = alc883_tagra_unsol_event,
7714 .init_hook = alc883_tagra_automute,
7715 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007716 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007717 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007718 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7719 * and the headphone jack. Turn this on and rely on the
7720 * standard mute methods whenever the user wants to turn
7721 * these outputs off.
7722 */
7723 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7724 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7725 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007726 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7727 .channel_mode = alc883_3ST_2ch_modes,
7728 .input_mux = &alc883_capture_source,
7729 },
Tobin Davis2880a862007-08-07 11:50:26 +02007730 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007731 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007732 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007733 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7734 .dac_nids = alc883_dac_nids,
7735 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02007736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7737 .channel_mode = alc883_3ST_2ch_modes,
7738 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007739 .unsol_event = alc883_acer_aspire_unsol_event,
7740 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007741 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007742 [ALC883_MEDION] = {
7743 .mixers = { alc883_fivestack_mixer,
7744 alc883_chmode_mixer },
7745 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007746 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007747 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7748 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02007749 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7750 .channel_mode = alc883_sixstack_modes,
7751 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007752 },
Kailang Yang272a5272007-05-14 11:00:38 +02007753 [ALC883_MEDION_MD2] = {
7754 .mixers = { alc883_medion_md2_mixer},
7755 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7756 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7757 .dac_nids = alc883_dac_nids,
7758 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007759 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7760 .channel_mode = alc883_3ST_2ch_modes,
7761 .input_mux = &alc883_capture_source,
7762 .unsol_event = alc883_medion_md2_unsol_event,
7763 .init_hook = alc883_medion_md2_automute,
7764 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007765 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007766 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007767 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7768 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7769 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007770 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7771 .channel_mode = alc883_3ST_2ch_modes,
7772 .input_mux = &alc883_capture_source,
7773 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007774 [ALC883_LENOVO_101E_2ch] = {
7775 .mixers = { alc883_lenovo_101e_2ch_mixer},
7776 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7777 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7778 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7780 .channel_mode = alc883_3ST_2ch_modes,
7781 .input_mux = &alc883_lenovo_101e_capture_source,
7782 .unsol_event = alc883_lenovo_101e_unsol_event,
7783 .init_hook = alc883_lenovo_101e_all_automute,
7784 },
Kailang Yang272a5272007-05-14 11:00:38 +02007785 [ALC883_LENOVO_NB0763] = {
7786 .mixers = { alc883_lenovo_nb0763_mixer },
7787 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7788 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7789 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007790 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7791 .channel_mode = alc883_3ST_2ch_modes,
7792 .need_dac_fix = 1,
7793 .input_mux = &alc883_lenovo_nb0763_capture_source,
7794 .unsol_event = alc883_medion_md2_unsol_event,
7795 .init_hook = alc883_medion_md2_automute,
7796 },
7797 [ALC888_LENOVO_MS7195_DIG] = {
7798 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7799 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7800 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7801 .dac_nids = alc883_dac_nids,
7802 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007803 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7804 .channel_mode = alc883_3ST_6ch_modes,
7805 .need_dac_fix = 1,
7806 .input_mux = &alc883_capture_source,
7807 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7808 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007809 },
7810 [ALC883_HAIER_W66] = {
7811 .mixers = { alc883_tagra_2ch_mixer},
7812 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7813 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7814 .dac_nids = alc883_dac_nids,
7815 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02007816 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7817 .channel_mode = alc883_3ST_2ch_modes,
7818 .input_mux = &alc883_capture_source,
7819 .unsol_event = alc883_haier_w66_unsol_event,
7820 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007821 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007822 [ALC888_6ST_HP] = {
7823 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7824 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007825 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7826 .dac_nids = alc883_dac_nids,
7827 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007828 .dig_in_nid = ALC883_DIGIN_NID,
7829 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7830 .channel_mode = alc883_sixstack_modes,
7831 .input_mux = &alc883_capture_source,
7832 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007833 [ALC888_3ST_HP] = {
7834 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7835 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007836 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7837 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007838 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7839 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007840 .need_dac_fix = 1,
7841 .input_mux = &alc883_capture_source,
7842 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007843 [ALC888_6ST_DELL] = {
7844 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7845 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7847 .dac_nids = alc883_dac_nids,
7848 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007849 .dig_in_nid = ALC883_DIGIN_NID,
7850 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7851 .channel_mode = alc883_sixstack_modes,
7852 .input_mux = &alc883_capture_source,
7853 .unsol_event = alc888_6st_dell_unsol_event,
7854 .init_hook = alc888_6st_dell_front_automute,
7855 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007856 [ALC883_MITAC] = {
7857 .mixers = { alc883_mitac_mixer },
7858 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7860 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7862 .channel_mode = alc883_3ST_2ch_modes,
7863 .input_mux = &alc883_capture_source,
7864 .unsol_event = alc883_mitac_unsol_event,
7865 .init_hook = alc883_mitac_automute,
7866 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007867};
7868
7869
7870/*
7871 * BIOS auto configuration
7872 */
7873static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7874 hda_nid_t nid, int pin_type,
7875 int dac_idx)
7876{
7877 /* set as output */
7878 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007879 int idx;
7880
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007881 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7882 idx = 4;
7883 else
7884 idx = spec->multiout.dac_nids[dac_idx] - 2;
7885
7886 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7887 pin_type);
7888 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7889 AMP_OUT_UNMUTE);
7890 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7891
7892}
7893
7894static void alc883_auto_init_multi_out(struct hda_codec *codec)
7895{
7896 struct alc_spec *spec = codec->spec;
7897 int i;
7898
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007899 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007900 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007901 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007902 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007903 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007904 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007905 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007906 }
7907}
7908
7909static void alc883_auto_init_hp_out(struct hda_codec *codec)
7910{
7911 struct alc_spec *spec = codec->spec;
7912 hda_nid_t pin;
7913
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007914 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007915 if (pin) /* connect to front */
7916 /* use dac 0 */
7917 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7918}
7919
7920#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7921#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7922
7923static void alc883_auto_init_analog_input(struct hda_codec *codec)
7924{
7925 struct alc_spec *spec = codec->spec;
7926 int i;
7927
7928 for (i = 0; i < AUTO_PIN_LAST; i++) {
7929 hda_nid_t nid = spec->autocfg.input_pins[i];
7930 if (alc883_is_input_pin(nid)) {
7931 snd_hda_codec_write(codec, nid, 0,
7932 AC_VERB_SET_PIN_WIDGET_CONTROL,
7933 (i <= AUTO_PIN_FRONT_MIC ?
7934 PIN_VREF80 : PIN_IN));
7935 if (nid != ALC883_PIN_CD_NID)
7936 snd_hda_codec_write(codec, nid, 0,
7937 AC_VERB_SET_AMP_GAIN_MUTE,
7938 AMP_OUT_MUTE);
7939 }
7940 }
7941}
7942
7943/* almost identical with ALC880 parser... */
7944static int alc883_parse_auto_config(struct hda_codec *codec)
7945{
7946 struct alc_spec *spec = codec->spec;
7947 int err = alc880_parse_auto_config(codec);
7948
7949 if (err < 0)
7950 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007951 else if (!err)
7952 return 0; /* no config found */
7953
7954 err = alc_auto_add_mic_boost(codec);
7955 if (err < 0)
7956 return err;
7957
7958 /* hack - override the init verbs */
7959 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007960 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7961 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007962
7963 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007964}
7965
7966/* additional initialization for auto-configuration model */
7967static void alc883_auto_init(struct hda_codec *codec)
7968{
7969 alc883_auto_init_multi_out(codec);
7970 alc883_auto_init_hp_out(codec);
7971 alc883_auto_init_analog_input(codec);
7972}
7973
7974static int patch_alc883(struct hda_codec *codec)
7975{
7976 struct alc_spec *spec;
7977 int err, board_config;
7978
7979 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7980 if (spec == NULL)
7981 return -ENOMEM;
7982
7983 codec->spec = spec;
7984
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007985 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7986 alc883_models,
7987 alc883_cfg_tbl);
7988 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007989 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7990 "trying auto-probe from BIOS...\n");
7991 board_config = ALC883_AUTO;
7992 }
7993
7994 if (board_config == ALC883_AUTO) {
7995 /* automatic parse from the BIOS config */
7996 err = alc883_parse_auto_config(codec);
7997 if (err < 0) {
7998 alc_free(codec);
7999 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008000 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008001 printk(KERN_INFO
8002 "hda_codec: Cannot set up configuration "
8003 "from BIOS. Using base mode...\n");
8004 board_config = ALC883_3ST_2ch_DIG;
8005 }
8006 }
8007
8008 if (board_config != ALC883_AUTO)
8009 setup_preset(spec, &alc883_presets[board_config]);
8010
8011 spec->stream_name_analog = "ALC883 Analog";
8012 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8013 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008014 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008015
8016 spec->stream_name_digital = "ALC883 Digital";
8017 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8018 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8019
Takashi Iwaie1406342008-02-11 18:32:32 +01008020 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8021 spec->adc_nids = alc883_adc_nids;
8022 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008023
Takashi Iwai2134ea42008-01-10 16:53:55 +01008024 spec->vmaster_nid = 0x0c;
8025
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008026 codec->patch_ops = alc_patch_ops;
8027 if (board_config == ALC883_AUTO)
8028 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008029#ifdef CONFIG_SND_HDA_POWER_SAVE
8030 if (!spec->loopback.amplist)
8031 spec->loopback.amplist = alc883_loopbacks;
8032#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008033
8034 return 0;
8035}
8036
8037/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008038 * ALC262 support
8039 */
8040
8041#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8042#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8043
8044#define alc262_dac_nids alc260_dac_nids
8045#define alc262_adc_nids alc882_adc_nids
8046#define alc262_adc_nids_alt alc882_adc_nids_alt
8047
8048#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008049#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008050
8051static struct snd_kcontrol_new alc262_base_mixer[] = {
8052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8053 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008063 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008064 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008065 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008066 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8068 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8069 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008070 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008071};
8072
Kailang Yangccc656c2006-10-17 12:32:26 +02008073static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8075 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008083 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8084 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008085 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008086 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008087 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008088 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8090 { } /* end */
8091};
8092
Takashi Iwaice875f02008-01-28 18:17:43 +01008093/* update HP, line and mono-out pins according to the master switch */
8094static void alc262_hp_master_update(struct hda_codec *codec)
8095{
8096 struct alc_spec *spec = codec->spec;
8097 int val = spec->master_sw;
8098
8099 /* HP & line-out */
8100 snd_hda_codec_write_cache(codec, 0x1b, 0,
8101 AC_VERB_SET_PIN_WIDGET_CONTROL,
8102 val ? PIN_HP : 0);
8103 snd_hda_codec_write_cache(codec, 0x15, 0,
8104 AC_VERB_SET_PIN_WIDGET_CONTROL,
8105 val ? PIN_HP : 0);
8106 /* mono (speaker) depending on the HP jack sense */
8107 val = val && !spec->jack_present;
8108 snd_hda_codec_write_cache(codec, 0x16, 0,
8109 AC_VERB_SET_PIN_WIDGET_CONTROL,
8110 val ? PIN_OUT : 0);
8111}
8112
8113static void alc262_hp_bpc_automute(struct hda_codec *codec)
8114{
8115 struct alc_spec *spec = codec->spec;
8116 unsigned int presence;
8117 presence = snd_hda_codec_read(codec, 0x1b, 0,
8118 AC_VERB_GET_PIN_SENSE, 0);
8119 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8120 alc262_hp_master_update(codec);
8121}
8122
8123static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8124{
8125 if ((res >> 26) != ALC880_HP_EVENT)
8126 return;
8127 alc262_hp_bpc_automute(codec);
8128}
8129
8130static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8131{
8132 struct alc_spec *spec = codec->spec;
8133 unsigned int presence;
8134 presence = snd_hda_codec_read(codec, 0x15, 0,
8135 AC_VERB_GET_PIN_SENSE, 0);
8136 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8137 alc262_hp_master_update(codec);
8138}
8139
8140static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8141 unsigned int res)
8142{
8143 if ((res >> 26) != ALC880_HP_EVENT)
8144 return;
8145 alc262_hp_wildwest_automute(codec);
8146}
8147
8148static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8149 struct snd_ctl_elem_value *ucontrol)
8150{
8151 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8152 struct alc_spec *spec = codec->spec;
8153 *ucontrol->value.integer.value = spec->master_sw;
8154 return 0;
8155}
8156
8157static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8158 struct snd_ctl_elem_value *ucontrol)
8159{
8160 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8161 struct alc_spec *spec = codec->spec;
8162 int val = !!*ucontrol->value.integer.value;
8163
8164 if (val == spec->master_sw)
8165 return 0;
8166 spec->master_sw = val;
8167 alc262_hp_master_update(codec);
8168 return 1;
8169}
8170
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008171static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008172 {
8173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8174 .name = "Master Playback Switch",
8175 .info = snd_ctl_boolean_mono_info,
8176 .get = alc262_hp_master_sw_get,
8177 .put = alc262_hp_master_sw_put,
8178 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8180 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8181 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008182 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8183 HDA_OUTPUT),
8184 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8185 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008186 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8187 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008188 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008189 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8190 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008191 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008192 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8193 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8196 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8197 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8198 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8199 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8200 { } /* end */
8201};
8202
Kailang Yangcd7509a2007-01-26 18:33:17 +01008203static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008204 {
8205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8206 .name = "Master Playback Switch",
8207 .info = snd_ctl_boolean_mono_info,
8208 .get = alc262_hp_master_sw_get,
8209 .put = alc262_hp_master_sw_put,
8210 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8212 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008215 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8216 HDA_OUTPUT),
8217 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8218 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8220 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008221 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8224 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8225 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8226 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8227 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8228 { } /* end */
8229};
8230
8231static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8232 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8233 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008234 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008235 { } /* end */
8236};
8237
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008238/* mute/unmute internal speaker according to the hp jack and mute state */
8239static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8240{
8241 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008242
8243 if (force || !spec->sense_updated) {
8244 unsigned int present;
8245 present = snd_hda_codec_read(codec, 0x15, 0,
8246 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008247 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008248 spec->sense_updated = 1;
8249 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008250 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8251 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008252}
8253
8254static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8255 unsigned int res)
8256{
8257 if ((res >> 26) != ALC880_HP_EVENT)
8258 return;
8259 alc262_hp_t5735_automute(codec, 1);
8260}
8261
8262static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8263{
8264 alc262_hp_t5735_automute(codec, 1);
8265}
8266
8267static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008268 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8269 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8274 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8275 { } /* end */
8276};
8277
8278static struct hda_verb alc262_hp_t5735_verbs[] = {
8279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8281
8282 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8283 { }
8284};
8285
Kailang Yang8c427222008-01-10 13:03:59 +01008286static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008287 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008289 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8290 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8293 { } /* end */
8294};
8295
8296static struct hda_verb alc262_hp_rp5700_verbs[] = {
8297 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8298 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8299 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8300 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8302 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8307 {}
8308};
8309
8310static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8311 .num_items = 1,
8312 .items = {
8313 { "Line", 0x1 },
8314 },
8315};
8316
Takashi Iwai0724ea22007-08-23 00:31:43 +02008317/* bind hp and internal speaker mute (with plug check) */
8318static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8319 struct snd_ctl_elem_value *ucontrol)
8320{
8321 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8322 long *valp = ucontrol->value.integer.value;
8323 int change;
8324
8325 /* change hp mute */
8326 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8327 HDA_AMP_MUTE,
8328 valp[0] ? 0 : HDA_AMP_MUTE);
8329 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8330 HDA_AMP_MUTE,
8331 valp[1] ? 0 : HDA_AMP_MUTE);
8332 if (change) {
8333 /* change speaker according to HP jack state */
8334 struct alc_spec *spec = codec->spec;
8335 unsigned int mute;
8336 if (spec->jack_present)
8337 mute = HDA_AMP_MUTE;
8338 else
8339 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8340 HDA_OUTPUT, 0);
8341 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8342 HDA_AMP_MUTE, mute);
8343 }
8344 return change;
8345}
Takashi Iwai5b319542007-07-26 11:49:22 +02008346
Kailang Yang272a5272007-05-14 11:00:38 +02008347static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008348 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8349 {
8350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8351 .name = "Master Playback Switch",
8352 .info = snd_hda_mixer_amp_switch_info,
8353 .get = snd_hda_mixer_amp_switch_get,
8354 .put = alc262_sony_master_sw_put,
8355 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8356 },
Kailang Yang272a5272007-05-14 11:00:38 +02008357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8359 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8360 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8361 { } /* end */
8362};
8363
Kailang Yang83c34212007-07-05 11:43:05 +02008364static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8366 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8370 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8371 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8372 { } /* end */
8373};
Kailang Yang272a5272007-05-14 11:00:38 +02008374
Kailang Yangdf694da2005-12-05 19:42:22 +01008375#define alc262_capture_mixer alc882_capture_mixer
8376#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8377
8378/*
8379 * generic initialization of ADC, input mixers and output mixers
8380 */
8381static struct hda_verb alc262_init_verbs[] = {
8382 /*
8383 * Unmute ADC0-2 and set the default input to mic-in
8384 */
8385 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8387 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8389 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8391
Takashi Iwaicb53c622007-08-10 17:21:45 +02008392 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008393 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008394 * Note: PASD motherboards uses the Line In 2 as the input for
8395 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008396 */
8397 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008403
8404 /*
8405 * Set up output mixers (0x0c - 0x0e)
8406 */
8407 /* set vol=0 to output mixers */
8408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8411 /* set up input amps for analog loopback */
8412 /* Amp Indices: DAC = 0, mixer = 1 */
8413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8415 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8417 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8419
8420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8422 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8423 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8425 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8426
8427 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8432
8433 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8434 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8435
8436 /* FIXME: use matrix-type input source selection */
8437 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8438 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8442 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8443 /* Input mixer2 */
8444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8446 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8447 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8448 /* Input mixer3 */
8449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008452 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008453
8454 { }
8455};
8456
Kailang Yangccc656c2006-10-17 12:32:26 +02008457static struct hda_verb alc262_hippo_unsol_verbs[] = {
8458 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8460 {}
8461};
8462
8463static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8465 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8466 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8467
8468 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8470 {}
8471};
8472
Kailang Yang272a5272007-05-14 11:00:38 +02008473static struct hda_verb alc262_sony_unsol_verbs[] = {
8474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8475 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8477
8478 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8480};
8481
Kailang Yangccc656c2006-10-17 12:32:26 +02008482/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008483static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008484{
8485 struct alc_spec *spec = codec->spec;
8486 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008487 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008488
Takashi Iwai5b319542007-07-26 11:49:22 +02008489 /* need to execute and sync at first */
8490 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8491 present = snd_hda_codec_read(codec, 0x15, 0,
8492 AC_VERB_GET_PIN_SENSE, 0);
8493 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008494 if (spec->jack_present) {
8495 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008496 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8497 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008498 } else {
8499 /* unmute internal speaker if necessary */
8500 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008501 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8502 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008503 }
8504}
8505
8506/* unsolicited event for HP jack sensing */
8507static void alc262_hippo_unsol_event(struct hda_codec *codec,
8508 unsigned int res)
8509{
8510 if ((res >> 26) != ALC880_HP_EVENT)
8511 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008512 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008513}
8514
Takashi Iwai5b319542007-07-26 11:49:22 +02008515static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008516{
Kailang Yangccc656c2006-10-17 12:32:26 +02008517 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008518 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008519
Takashi Iwai5b319542007-07-26 11:49:22 +02008520 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8521 present = snd_hda_codec_read(codec, 0x1b, 0,
8522 AC_VERB_GET_PIN_SENSE, 0);
8523 present = (present & 0x80000000) != 0;
8524 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008525 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008526 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8527 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008528 } else {
8529 /* unmute internal speaker if necessary */
8530 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008531 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8532 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008533 }
8534}
8535
8536/* unsolicited event for HP jack sensing */
8537static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8538 unsigned int res)
8539{
8540 if ((res >> 26) != ALC880_HP_EVENT)
8541 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008542 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008543}
8544
Takashi Iwai834be882006-03-01 14:16:17 +01008545/*
8546 * fujitsu model
8547 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8548 */
8549
8550#define ALC_HP_EVENT 0x37
8551
8552static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8555 {}
8556};
8557
8558static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008559 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008560 .items = {
8561 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008562 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008563 { "CD", 0x4 },
8564 },
8565};
8566
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008567static struct hda_input_mux alc262_HP_capture_source = {
8568 .num_items = 5,
8569 .items = {
8570 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008571 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008572 { "Line", 0x2 },
8573 { "CD", 0x4 },
8574 { "AUX IN", 0x6 },
8575 },
8576};
8577
zhejiangaccbe492007-08-31 12:36:05 +02008578static struct hda_input_mux alc262_HP_D7000_capture_source = {
8579 .num_items = 4,
8580 .items = {
8581 { "Mic", 0x0 },
8582 { "Front Mic", 0x2 },
8583 { "Line", 0x1 },
8584 { "CD", 0x4 },
8585 },
8586};
8587
Takashi Iwai834be882006-03-01 14:16:17 +01008588/* mute/unmute internal speaker according to the hp jack and mute state */
8589static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8590{
8591 struct alc_spec *spec = codec->spec;
8592 unsigned int mute;
8593
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008594 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008595 unsigned int present;
8596 /* need to execute and sync at first */
8597 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8598 present = snd_hda_codec_read(codec, 0x14, 0,
8599 AC_VERB_GET_PIN_SENSE, 0);
8600 spec->jack_present = (present & 0x80000000) != 0;
8601 spec->sense_updated = 1;
8602 }
8603 if (spec->jack_present) {
8604 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008605 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8606 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008607 } else {
8608 /* unmute internal speaker if necessary */
8609 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008610 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8611 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008612 }
8613}
8614
8615/* unsolicited event for HP jack sensing */
8616static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8617 unsigned int res)
8618{
8619 if ((res >> 26) != ALC_HP_EVENT)
8620 return;
8621 alc262_fujitsu_automute(codec, 1);
8622}
8623
8624/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008625static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8626 .ops = &snd_hda_bind_vol,
8627 .values = {
8628 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8629 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8630 0
8631 },
8632};
Takashi Iwai834be882006-03-01 14:16:17 +01008633
8634/* bind hp and internal speaker mute (with plug check) */
8635static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8636 struct snd_ctl_elem_value *ucontrol)
8637{
8638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8639 long *valp = ucontrol->value.integer.value;
8640 int change;
8641
8642 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008643 HDA_AMP_MUTE,
8644 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008645 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008646 HDA_AMP_MUTE,
8647 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008648 if (change)
8649 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008650 return change;
8651}
8652
8653static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008654 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008655 {
8656 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8657 .name = "Master Playback Switch",
8658 .info = snd_hda_mixer_amp_switch_info,
8659 .get = snd_hda_mixer_amp_switch_get,
8660 .put = alc262_fujitsu_master_sw_put,
8661 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8662 },
8663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8665 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008668 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8669 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8670 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008671 { } /* end */
8672};
8673
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008674/* additional init verbs for Benq laptops */
8675static struct hda_verb alc262_EAPD_verbs[] = {
8676 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8677 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8678 {}
8679};
8680
Kailang Yang83c34212007-07-05 11:43:05 +02008681static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8682 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8684
8685 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8686 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8687 {}
8688};
8689
Tobin Davisf651b502007-10-26 12:40:47 +02008690/* Samsung Q1 Ultra Vista model setup */
8691static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8692 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8693 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8694 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8697 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8698 { } /* end */
8699};
8700
8701static struct hda_verb alc262_ultra_verbs[] = {
8702 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8703 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8704 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8705 /* Mic is on Node 0x19 */
8706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8707 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8709 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8711 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8712 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8713 {}
8714};
8715
8716static struct hda_input_mux alc262_ultra_capture_source = {
8717 .num_items = 1,
8718 .items = {
8719 { "Mic", 0x1 },
8720 },
8721};
8722
8723/* mute/unmute internal speaker according to the hp jack and mute state */
8724static void alc262_ultra_automute(struct hda_codec *codec)
8725{
8726 struct alc_spec *spec = codec->spec;
8727 unsigned int mute;
8728 unsigned int present;
8729
8730 /* need to execute and sync at first */
8731 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8732 present = snd_hda_codec_read(codec, 0x15, 0,
8733 AC_VERB_GET_PIN_SENSE, 0);
8734 spec->jack_present = (present & 0x80000000) != 0;
8735 if (spec->jack_present) {
8736 /* mute internal speaker */
8737 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8738 HDA_AMP_MUTE, HDA_AMP_MUTE);
8739 } else {
8740 /* unmute internal speaker if necessary */
8741 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8742 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8743 HDA_AMP_MUTE, mute);
8744 }
8745}
8746
8747/* unsolicited event for HP jack sensing */
8748static void alc262_ultra_unsol_event(struct hda_codec *codec,
8749 unsigned int res)
8750{
8751 if ((res >> 26) != ALC880_HP_EVENT)
8752 return;
8753 alc262_ultra_automute(codec);
8754}
8755
Kailang Yangdf694da2005-12-05 19:42:22 +01008756/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008757static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8758 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008759{
8760 hda_nid_t nid;
8761 int err;
8762
8763 spec->multiout.num_dacs = 1; /* only use one dac */
8764 spec->multiout.dac_nids = spec->private_dac_nids;
8765 spec->multiout.dac_nids[0] = 2;
8766
8767 nid = cfg->line_out_pins[0];
8768 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008769 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8770 "Front Playback Volume",
8771 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8772 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008773 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008774 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8775 "Front Playback Switch",
8776 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8777 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008778 return err;
8779 }
8780
Takashi Iwai82bc9552006-03-21 11:24:42 +01008781 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008782 if (nid) {
8783 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008784 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8785 "Speaker Playback Volume",
8786 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8787 HDA_OUTPUT));
8788 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008789 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008790 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8791 "Speaker Playback Switch",
8792 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8793 HDA_OUTPUT));
8794 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008795 return err;
8796 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008797 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8798 "Speaker Playback Switch",
8799 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8800 HDA_OUTPUT));
8801 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008802 return err;
8803 }
8804 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008805 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008806 if (nid) {
8807 /* spec->multiout.hp_nid = 2; */
8808 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008809 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8810 "Headphone Playback Volume",
8811 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8812 HDA_OUTPUT));
8813 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008814 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008815 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8816 "Headphone Playback Switch",
8817 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8818 HDA_OUTPUT));
8819 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008820 return err;
8821 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008822 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8823 "Headphone Playback Switch",
8824 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8825 HDA_OUTPUT));
8826 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008827 return err;
8828 }
8829 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008830 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008831}
8832
8833/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008834#define alc262_auto_create_analog_input_ctls \
8835 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008836
8837/*
8838 * generic initialization of ADC, input mixers and output mixers
8839 */
8840static struct hda_verb alc262_volume_init_verbs[] = {
8841 /*
8842 * Unmute ADC0-2 and set the default input to mic-in
8843 */
8844 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8848 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8850
Takashi Iwaicb53c622007-08-10 17:21:45 +02008851 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008852 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008853 * Note: PASD motherboards uses the Line In 2 as the input for
8854 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008855 */
8856 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008862
8863 /*
8864 * Set up output mixers (0x0c - 0x0f)
8865 */
8866 /* set vol=0 to output mixers */
8867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8870
8871 /* set up input amps for analog loopback */
8872 /* Amp Indices: DAC = 0, mixer = 1 */
8873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8877 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8878 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8879
8880 /* FIXME: use matrix-type input source selection */
8881 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8882 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8883 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8885 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8886 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8887 /* Input mixer2 */
8888 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8892 /* Input mixer3 */
8893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8897
8898 { }
8899};
8900
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008901static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8902 /*
8903 * Unmute ADC0-2 and set the default input to mic-in
8904 */
8905 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8907 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8909 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8910 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8911
Takashi Iwaicb53c622007-08-10 17:21:45 +02008912 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008913 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008914 * Note: PASD motherboards uses the Line In 2 as the input for
8915 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008916 */
8917 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008925
8926 /*
8927 * Set up output mixers (0x0c - 0x0e)
8928 */
8929 /* set vol=0 to output mixers */
8930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8931 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8932 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8933
8934 /* set up input amps for analog loopback */
8935 /* Amp Indices: DAC = 0, mixer = 1 */
8936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8938 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8939 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8940 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8941 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8942
Takashi Iwaice875f02008-01-28 18:17:43 +01008943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008944 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8945 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8946
8947 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8949
8950 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8951 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8952
8953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8954 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8955 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8956 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8958
8959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8961 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8963 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8964 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8965
8966
8967 /* FIXME: use matrix-type input source selection */
8968 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8969 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8974 /* Input mixer2 */
8975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8979 /* Input mixer3 */
8980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8984
Takashi Iwaice875f02008-01-28 18:17:43 +01008985 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8986
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987 { }
8988};
8989
Kailang Yangcd7509a2007-01-26 18:33:17 +01008990static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8991 /*
8992 * Unmute ADC0-2 and set the default input to mic-in
8993 */
8994 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8996 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8998 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8999 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9000
Takashi Iwaicb53c622007-08-10 17:21:45 +02009001 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009002 * mixer widget
9003 * Note: PASD motherboards uses the Line In 2 as the input for front
9004 * panel mic (mic 2)
9005 */
9006 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009015 /*
9016 * Set up output mixers (0x0c - 0x0e)
9017 */
9018 /* set vol=0 to output mixers */
9019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9022
9023 /* set up input amps for analog loopback */
9024 /* Amp Indices: DAC = 0, mixer = 1 */
9025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9029 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9031
9032
9033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9034 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9035 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9036 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9037 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9038 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9039 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9040
9041 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9043
9044 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9046
9047 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9048 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9049 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9051 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9052 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9053
9054 /* FIXME: use matrix-type input source selection */
9055 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9056 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9057 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9062 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9064 /* Input mixer2 */
9065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9070 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9072 /* Input mixer3 */
9073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9078 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9080
Takashi Iwaice875f02008-01-28 18:17:43 +01009081 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9082
Kailang Yangcd7509a2007-01-26 18:33:17 +01009083 { }
9084};
9085
Takashi Iwaicb53c622007-08-10 17:21:45 +02009086#ifdef CONFIG_SND_HDA_POWER_SAVE
9087#define alc262_loopbacks alc880_loopbacks
9088#endif
9089
Kailang Yangdf694da2005-12-05 19:42:22 +01009090/* pcm configuration: identiacal with ALC880 */
9091#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9092#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9093#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9094#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9095
9096/*
9097 * BIOS auto configuration
9098 */
9099static int alc262_parse_auto_config(struct hda_codec *codec)
9100{
9101 struct alc_spec *spec = codec->spec;
9102 int err;
9103 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9104
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009105 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9106 alc262_ignore);
9107 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009108 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009109 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009110 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009111 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9112 if (err < 0)
9113 return err;
9114 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9115 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009116 return err;
9117
9118 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9119
9120 if (spec->autocfg.dig_out_pin)
9121 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9122 if (spec->autocfg.dig_in_pin)
9123 spec->dig_in_nid = ALC262_DIGIN_NID;
9124
9125 if (spec->kctl_alloc)
9126 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9127
9128 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009129 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009130 spec->input_mux = &spec->private_imux;
9131
Takashi Iwai776e1842007-08-29 15:07:11 +02009132 err = alc_auto_add_mic_boost(codec);
9133 if (err < 0)
9134 return err;
9135
Kailang Yangdf694da2005-12-05 19:42:22 +01009136 return 1;
9137}
9138
9139#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9140#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9141#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9142
9143
9144/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009145static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009146{
Kailang Yangdf694da2005-12-05 19:42:22 +01009147 alc262_auto_init_multi_out(codec);
9148 alc262_auto_init_hp_out(codec);
9149 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009150}
9151
9152/*
9153 * configuration and preset
9154 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009155static const char *alc262_models[ALC262_MODEL_LAST] = {
9156 [ALC262_BASIC] = "basic",
9157 [ALC262_HIPPO] = "hippo",
9158 [ALC262_HIPPO_1] = "hippo_1",
9159 [ALC262_FUJITSU] = "fujitsu",
9160 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009161 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009162 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009163 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009164 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009165 [ALC262_BENQ_T31] = "benq-t31",
9166 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009167 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009168 [ALC262_AUTO] = "auto",
9169};
9170
9171static struct snd_pci_quirk alc262_cfg_tbl[] = {
9172 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9173 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009174 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009175 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9176 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009177 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009178 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009179 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009180 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009181 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009182 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009183 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009184 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009185 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009186 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009187 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009188 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009189 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9190 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9191 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009192 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9193 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009194 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009195 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009196 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009197 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9198 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9199 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009200 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009201 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009202 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009203 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009204 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009205 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009206 {}
9207};
9208
9209static struct alc_config_preset alc262_presets[] = {
9210 [ALC262_BASIC] = {
9211 .mixers = { alc262_base_mixer },
9212 .init_verbs = { alc262_init_verbs },
9213 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9214 .dac_nids = alc262_dac_nids,
9215 .hp_nid = 0x03,
9216 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9217 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009218 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009219 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009220 [ALC262_HIPPO] = {
9221 .mixers = { alc262_base_mixer },
9222 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9223 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9224 .dac_nids = alc262_dac_nids,
9225 .hp_nid = 0x03,
9226 .dig_out_nid = ALC262_DIGOUT_NID,
9227 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9228 .channel_mode = alc262_modes,
9229 .input_mux = &alc262_capture_source,
9230 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009231 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009232 },
9233 [ALC262_HIPPO_1] = {
9234 .mixers = { alc262_hippo1_mixer },
9235 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9236 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9237 .dac_nids = alc262_dac_nids,
9238 .hp_nid = 0x02,
9239 .dig_out_nid = ALC262_DIGOUT_NID,
9240 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9241 .channel_mode = alc262_modes,
9242 .input_mux = &alc262_capture_source,
9243 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009244 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009245 },
Takashi Iwai834be882006-03-01 14:16:17 +01009246 [ALC262_FUJITSU] = {
9247 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009248 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9249 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009250 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9251 .dac_nids = alc262_dac_nids,
9252 .hp_nid = 0x03,
9253 .dig_out_nid = ALC262_DIGOUT_NID,
9254 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9255 .channel_mode = alc262_modes,
9256 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009257 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009258 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259 [ALC262_HP_BPC] = {
9260 .mixers = { alc262_HP_BPC_mixer },
9261 .init_verbs = { alc262_HP_BPC_init_verbs },
9262 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9263 .dac_nids = alc262_dac_nids,
9264 .hp_nid = 0x03,
9265 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9266 .channel_mode = alc262_modes,
9267 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009268 .unsol_event = alc262_hp_bpc_unsol_event,
9269 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009270 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009271 [ALC262_HP_BPC_D7000_WF] = {
9272 .mixers = { alc262_HP_BPC_WildWest_mixer },
9273 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9274 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9275 .dac_nids = alc262_dac_nids,
9276 .hp_nid = 0x03,
9277 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9278 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009279 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009280 .unsol_event = alc262_hp_wildwest_unsol_event,
9281 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009282 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009283 [ALC262_HP_BPC_D7000_WL] = {
9284 .mixers = { alc262_HP_BPC_WildWest_mixer,
9285 alc262_HP_BPC_WildWest_option_mixer },
9286 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9287 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9288 .dac_nids = alc262_dac_nids,
9289 .hp_nid = 0x03,
9290 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9291 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009292 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009293 .unsol_event = alc262_hp_wildwest_unsol_event,
9294 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009295 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009296 [ALC262_HP_TC_T5735] = {
9297 .mixers = { alc262_hp_t5735_mixer },
9298 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9299 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9300 .dac_nids = alc262_dac_nids,
9301 .hp_nid = 0x03,
9302 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9303 .channel_mode = alc262_modes,
9304 .input_mux = &alc262_capture_source,
9305 .unsol_event = alc262_hp_t5735_unsol_event,
9306 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009307 },
9308 [ALC262_HP_RP5700] = {
9309 .mixers = { alc262_hp_rp5700_mixer },
9310 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9311 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9312 .dac_nids = alc262_dac_nids,
9313 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9314 .channel_mode = alc262_modes,
9315 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009316 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009317 [ALC262_BENQ_ED8] = {
9318 .mixers = { alc262_base_mixer },
9319 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9320 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9321 .dac_nids = alc262_dac_nids,
9322 .hp_nid = 0x03,
9323 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9324 .channel_mode = alc262_modes,
9325 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009326 },
Kailang Yang272a5272007-05-14 11:00:38 +02009327 [ALC262_SONY_ASSAMD] = {
9328 .mixers = { alc262_sony_mixer },
9329 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9330 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9331 .dac_nids = alc262_dac_nids,
9332 .hp_nid = 0x02,
9333 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9334 .channel_mode = alc262_modes,
9335 .input_mux = &alc262_capture_source,
9336 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009337 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009338 },
9339 [ALC262_BENQ_T31] = {
9340 .mixers = { alc262_benq_t31_mixer },
9341 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9342 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9343 .dac_nids = alc262_dac_nids,
9344 .hp_nid = 0x03,
9345 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9346 .channel_mode = alc262_modes,
9347 .input_mux = &alc262_capture_source,
9348 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009349 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009350 },
Tobin Davisf651b502007-10-26 12:40:47 +02009351 [ALC262_ULTRA] = {
9352 .mixers = { alc262_ultra_mixer },
9353 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9354 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9355 .dac_nids = alc262_dac_nids,
9356 .hp_nid = 0x03,
9357 .dig_out_nid = ALC262_DIGOUT_NID,
9358 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9359 .channel_mode = alc262_modes,
9360 .input_mux = &alc262_ultra_capture_source,
9361 .unsol_event = alc262_ultra_unsol_event,
9362 .init_hook = alc262_ultra_automute,
9363 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009364};
9365
9366static int patch_alc262(struct hda_codec *codec)
9367{
9368 struct alc_spec *spec;
9369 int board_config;
9370 int err;
9371
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009372 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009373 if (spec == NULL)
9374 return -ENOMEM;
9375
9376 codec->spec = spec;
9377#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009378 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9379 * under-run
9380 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009381 {
9382 int tmp;
9383 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9384 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9385 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9386 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9387 }
9388#endif
9389
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009390 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9391 alc262_models,
9392 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009393
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009394 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009395 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9396 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009397 board_config = ALC262_AUTO;
9398 }
9399
9400 if (board_config == ALC262_AUTO) {
9401 /* automatic parse from the BIOS config */
9402 err = alc262_parse_auto_config(codec);
9403 if (err < 0) {
9404 alc_free(codec);
9405 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009406 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009407 printk(KERN_INFO
9408 "hda_codec: Cannot set up configuration "
9409 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009410 board_config = ALC262_BASIC;
9411 }
9412 }
9413
9414 if (board_config != ALC262_AUTO)
9415 setup_preset(spec, &alc262_presets[board_config]);
9416
9417 spec->stream_name_analog = "ALC262 Analog";
9418 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9419 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9420
9421 spec->stream_name_digital = "ALC262 Digital";
9422 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9423 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9424
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009425 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009426 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009427 unsigned int wcap = get_wcaps(codec, 0x07);
9428
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009429 /* get type */
9430 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009431 if (wcap != AC_WID_AUD_IN) {
9432 spec->adc_nids = alc262_adc_nids_alt;
9433 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009434 spec->mixers[spec->num_mixers] =
9435 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009436 spec->num_mixers++;
9437 } else {
9438 spec->adc_nids = alc262_adc_nids;
9439 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9440 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9441 spec->num_mixers++;
9442 }
9443 }
9444
Takashi Iwai2134ea42008-01-10 16:53:55 +01009445 spec->vmaster_nid = 0x0c;
9446
Kailang Yangdf694da2005-12-05 19:42:22 +01009447 codec->patch_ops = alc_patch_ops;
9448 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009449 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009450#ifdef CONFIG_SND_HDA_POWER_SAVE
9451 if (!spec->loopback.amplist)
9452 spec->loopback.amplist = alc262_loopbacks;
9453#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009454
Kailang Yangdf694da2005-12-05 19:42:22 +01009455 return 0;
9456}
9457
Kailang Yangdf694da2005-12-05 19:42:22 +01009458/*
Kailang Yanga361d842007-06-05 12:30:55 +02009459 * ALC268 channel source setting (2 channel)
9460 */
9461#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9462#define alc268_modes alc260_modes
9463
9464static hda_nid_t alc268_dac_nids[2] = {
9465 /* front, hp */
9466 0x02, 0x03
9467};
9468
9469static hda_nid_t alc268_adc_nids[2] = {
9470 /* ADC0-1 */
9471 0x08, 0x07
9472};
9473
9474static hda_nid_t alc268_adc_nids_alt[1] = {
9475 /* ADC0 */
9476 0x08
9477};
9478
Takashi Iwaie1406342008-02-11 18:32:32 +01009479static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9480
Kailang Yanga361d842007-06-05 12:30:55 +02009481static struct snd_kcontrol_new alc268_base_mixer[] = {
9482 /* output mixer control */
9483 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9484 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9485 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009487 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9489 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009490 { }
9491};
9492
Kailang Yangd1a991a2007-08-15 16:21:59 +02009493static struct hda_verb alc268_eapd_verbs[] = {
9494 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9495 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9496 { }
9497};
9498
Takashi Iwaid2738092007-08-16 14:59:45 +02009499/* Toshiba specific */
9500#define alc268_toshiba_automute alc262_hippo_automute
9501
9502static struct hda_verb alc268_toshiba_verbs[] = {
9503 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9504 { } /* end */
9505};
9506
9507/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009508/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009509static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9510 .ops = &snd_hda_bind_vol,
9511 .values = {
9512 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9513 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9514 0
9515 },
9516};
9517
Takashi Iwai889c4392007-08-23 18:56:52 +02009518/* mute/unmute internal speaker according to the hp jack and mute state */
9519static void alc268_acer_automute(struct hda_codec *codec, int force)
9520{
9521 struct alc_spec *spec = codec->spec;
9522 unsigned int mute;
9523
9524 if (force || !spec->sense_updated) {
9525 unsigned int present;
9526 present = snd_hda_codec_read(codec, 0x14, 0,
9527 AC_VERB_GET_PIN_SENSE, 0);
9528 spec->jack_present = (present & 0x80000000) != 0;
9529 spec->sense_updated = 1;
9530 }
9531 if (spec->jack_present)
9532 mute = HDA_AMP_MUTE; /* mute internal speaker */
9533 else /* unmute internal speaker if necessary */
9534 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9535 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9536 HDA_AMP_MUTE, mute);
9537}
9538
9539
9540/* bind hp and internal speaker mute (with plug check) */
9541static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9542 struct snd_ctl_elem_value *ucontrol)
9543{
9544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9545 long *valp = ucontrol->value.integer.value;
9546 int change;
9547
9548 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9549 HDA_AMP_MUTE,
9550 valp[0] ? 0 : HDA_AMP_MUTE);
9551 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9552 HDA_AMP_MUTE,
9553 valp[1] ? 0 : HDA_AMP_MUTE);
9554 if (change)
9555 alc268_acer_automute(codec, 0);
9556 return change;
9557}
Takashi Iwaid2738092007-08-16 14:59:45 +02009558
9559static struct snd_kcontrol_new alc268_acer_mixer[] = {
9560 /* output mixer control */
9561 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9562 {
9563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9564 .name = "Master Playback Switch",
9565 .info = snd_hda_mixer_amp_switch_info,
9566 .get = snd_hda_mixer_amp_switch_get,
9567 .put = alc268_acer_master_sw_put,
9568 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9569 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009570 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9571 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9572 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009573 { }
9574};
9575
9576static struct hda_verb alc268_acer_verbs[] = {
9577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9579
9580 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9581 { }
9582};
9583
9584/* unsolicited event for HP jack sensing */
9585static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9586 unsigned int res)
9587{
Takashi Iwai889c4392007-08-23 18:56:52 +02009588 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009589 return;
9590 alc268_toshiba_automute(codec);
9591}
9592
9593static void alc268_acer_unsol_event(struct hda_codec *codec,
9594 unsigned int res)
9595{
Takashi Iwai889c4392007-08-23 18:56:52 +02009596 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009597 return;
9598 alc268_acer_automute(codec, 1);
9599}
9600
Takashi Iwai889c4392007-08-23 18:56:52 +02009601static void alc268_acer_init_hook(struct hda_codec *codec)
9602{
9603 alc268_acer_automute(codec, 1);
9604}
9605
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009606static struct snd_kcontrol_new alc268_dell_mixer[] = {
9607 /* output mixer control */
9608 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9609 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9610 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9612 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9613 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9614 { }
9615};
9616
9617static struct hda_verb alc268_dell_verbs[] = {
9618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9620 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9621 { }
9622};
9623
9624/* mute/unmute internal speaker according to the hp jack and mute state */
9625static void alc268_dell_automute(struct hda_codec *codec)
9626{
9627 unsigned int present;
9628 unsigned int mute;
9629
9630 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9631 if (present & 0x80000000)
9632 mute = HDA_AMP_MUTE;
9633 else
9634 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9635 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9636 HDA_AMP_MUTE, mute);
9637}
9638
9639static void alc268_dell_unsol_event(struct hda_codec *codec,
9640 unsigned int res)
9641{
9642 if ((res >> 26) != ALC880_HP_EVENT)
9643 return;
9644 alc268_dell_automute(codec);
9645}
9646
9647#define alc268_dell_init_hook alc268_dell_automute
9648
Kailang Yanga361d842007-06-05 12:30:55 +02009649/*
9650 * generic initialization of ADC, input mixers and output mixers
9651 */
9652static struct hda_verb alc268_base_init_verbs[] = {
9653 /* Unmute DAC0-1 and set vol = 0 */
9654 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9655 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9656 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9657 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9658 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9659 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9660
9661 /*
9662 * Set up output mixers (0x0c - 0x0e)
9663 */
9664 /* set vol=0 to output mixers */
9665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9666 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9668 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9669
9670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9671 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9672
9673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9675 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9679 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9680 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9681
9682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9686 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9688 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9689 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9690
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009691 /* Unmute Selector 23h,24h and set the default input to mic-in */
9692
9693 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9695 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9696 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009697
Kailang Yanga361d842007-06-05 12:30:55 +02009698 { }
9699};
9700
9701/*
9702 * generic initialization of ADC, input mixers and output mixers
9703 */
9704static struct hda_verb alc268_volume_init_verbs[] = {
9705 /* set output DAC */
9706 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9707 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9708 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9709 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9710
9711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9713 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9714 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9715 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9716
9717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9720 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9721 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9722
9723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9726 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9727
9728 /* set PCBEEP vol = 0 */
9729 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9730
9731 { }
9732};
9733
9734#define alc268_mux_enum_info alc_mux_enum_info
9735#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01009736#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +02009737
9738static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9739 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9740 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9741 {
9742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9743 /* The multiple "Capture Source" controls confuse alsamixer
9744 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009745 */
9746 /* .name = "Capture Source", */
9747 .name = "Input Source",
9748 .count = 1,
9749 .info = alc268_mux_enum_info,
9750 .get = alc268_mux_enum_get,
9751 .put = alc268_mux_enum_put,
9752 },
9753 { } /* end */
9754};
9755
9756static struct snd_kcontrol_new alc268_capture_mixer[] = {
9757 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9758 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9759 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9760 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9761 {
9762 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9763 /* The multiple "Capture Source" controls confuse alsamixer
9764 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009765 */
9766 /* .name = "Capture Source", */
9767 .name = "Input Source",
9768 .count = 2,
9769 .info = alc268_mux_enum_info,
9770 .get = alc268_mux_enum_get,
9771 .put = alc268_mux_enum_put,
9772 },
9773 { } /* end */
9774};
9775
9776static struct hda_input_mux alc268_capture_source = {
9777 .num_items = 4,
9778 .items = {
9779 { "Mic", 0x0 },
9780 { "Front Mic", 0x1 },
9781 { "Line", 0x2 },
9782 { "CD", 0x3 },
9783 },
9784};
9785
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009786#ifdef CONFIG_SND_DEBUG
9787static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009788 /* Volume widgets */
9789 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9790 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9791 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9792 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9793 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9794 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9795 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9796 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9797 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9798 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9799 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9800 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9801 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009802 /* The below appears problematic on some hardwares */
9803 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009804 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9805 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9806 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9807 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9808
9809 /* Modes for retasking pin widgets */
9810 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9811 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9812 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9813 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9814
9815 /* Controls for GPIO pins, assuming they are configured as outputs */
9816 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9817 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9818 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9819 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9820
9821 /* Switches to allow the digital SPDIF output pin to be enabled.
9822 * The ALC268 does not have an SPDIF input.
9823 */
9824 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9825
9826 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9827 * this output to turn on an external amplifier.
9828 */
9829 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9830 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9831
9832 { } /* end */
9833};
9834#endif
9835
Kailang Yanga361d842007-06-05 12:30:55 +02009836/* create input playback/capture controls for the given pin */
9837static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9838 const char *ctlname, int idx)
9839{
9840 char name[32];
9841 int err;
9842
9843 sprintf(name, "%s Playback Volume", ctlname);
9844 if (nid == 0x14) {
9845 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9846 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9847 HDA_OUTPUT));
9848 if (err < 0)
9849 return err;
9850 } else if (nid == 0x15) {
9851 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9852 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9853 HDA_OUTPUT));
9854 if (err < 0)
9855 return err;
9856 } else
9857 return -1;
9858 sprintf(name, "%s Playback Switch", ctlname);
9859 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9860 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9861 if (err < 0)
9862 return err;
9863 return 0;
9864}
9865
9866/* add playback controls from the parsed DAC table */
9867static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9868 const struct auto_pin_cfg *cfg)
9869{
9870 hda_nid_t nid;
9871 int err;
9872
9873 spec->multiout.num_dacs = 2; /* only use one dac */
9874 spec->multiout.dac_nids = spec->private_dac_nids;
9875 spec->multiout.dac_nids[0] = 2;
9876 spec->multiout.dac_nids[1] = 3;
9877
9878 nid = cfg->line_out_pins[0];
9879 if (nid)
9880 alc268_new_analog_output(spec, nid, "Front", 0);
9881
9882 nid = cfg->speaker_pins[0];
9883 if (nid == 0x1d) {
9884 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9885 "Speaker Playback Volume",
9886 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9887 if (err < 0)
9888 return err;
9889 }
9890 nid = cfg->hp_pins[0];
9891 if (nid)
9892 alc268_new_analog_output(spec, nid, "Headphone", 0);
9893
9894 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9895 if (nid == 0x16) {
9896 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9897 "Mono Playback Switch",
9898 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9899 if (err < 0)
9900 return err;
9901 }
9902 return 0;
9903}
9904
9905/* create playback/capture controls for input pins */
9906static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9907 const struct auto_pin_cfg *cfg)
9908{
9909 struct hda_input_mux *imux = &spec->private_imux;
9910 int i, idx1;
9911
9912 for (i = 0; i < AUTO_PIN_LAST; i++) {
9913 switch(cfg->input_pins[i]) {
9914 case 0x18:
9915 idx1 = 0; /* Mic 1 */
9916 break;
9917 case 0x19:
9918 idx1 = 1; /* Mic 2 */
9919 break;
9920 case 0x1a:
9921 idx1 = 2; /* Line In */
9922 break;
9923 case 0x1c:
9924 idx1 = 3; /* CD */
9925 break;
9926 default:
9927 continue;
9928 }
9929 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9930 imux->items[imux->num_items].index = idx1;
9931 imux->num_items++;
9932 }
9933 return 0;
9934}
9935
9936static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9937{
9938 struct alc_spec *spec = codec->spec;
9939 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9940 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9941 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9942 unsigned int dac_vol1, dac_vol2;
9943
9944 if (speaker_nid) {
9945 snd_hda_codec_write(codec, speaker_nid, 0,
9946 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9947 snd_hda_codec_write(codec, 0x0f, 0,
9948 AC_VERB_SET_AMP_GAIN_MUTE,
9949 AMP_IN_UNMUTE(1));
9950 snd_hda_codec_write(codec, 0x10, 0,
9951 AC_VERB_SET_AMP_GAIN_MUTE,
9952 AMP_IN_UNMUTE(1));
9953 } else {
9954 snd_hda_codec_write(codec, 0x0f, 0,
9955 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9956 snd_hda_codec_write(codec, 0x10, 0,
9957 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9958 }
9959
9960 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9961 if (line_nid == 0x14)
9962 dac_vol2 = AMP_OUT_ZERO;
9963 else if (line_nid == 0x15)
9964 dac_vol1 = AMP_OUT_ZERO;
9965 if (hp_nid == 0x14)
9966 dac_vol2 = AMP_OUT_ZERO;
9967 else if (hp_nid == 0x15)
9968 dac_vol1 = AMP_OUT_ZERO;
9969 if (line_nid != 0x16 || hp_nid != 0x16 ||
9970 spec->autocfg.line_out_pins[1] != 0x16 ||
9971 spec->autocfg.line_out_pins[2] != 0x16)
9972 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9973
9974 snd_hda_codec_write(codec, 0x02, 0,
9975 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9976 snd_hda_codec_write(codec, 0x03, 0,
9977 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9978}
9979
9980/* pcm configuration: identiacal with ALC880 */
9981#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9982#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009983#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +02009984#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9985
9986/*
9987 * BIOS auto configuration
9988 */
9989static int alc268_parse_auto_config(struct hda_codec *codec)
9990{
9991 struct alc_spec *spec = codec->spec;
9992 int err;
9993 static hda_nid_t alc268_ignore[] = { 0 };
9994
9995 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9996 alc268_ignore);
9997 if (err < 0)
9998 return err;
9999 if (!spec->autocfg.line_outs)
10000 return 0; /* can't find valid BIOS pin config */
10001
10002 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10003 if (err < 0)
10004 return err;
10005 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10006 if (err < 0)
10007 return err;
10008
10009 spec->multiout.max_channels = 2;
10010
10011 /* digital only support output */
10012 if (spec->autocfg.dig_out_pin)
10013 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10014
10015 if (spec->kctl_alloc)
10016 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10017
10018 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10019 spec->num_mux_defs = 1;
10020 spec->input_mux = &spec->private_imux;
10021
Takashi Iwai776e1842007-08-29 15:07:11 +020010022 err = alc_auto_add_mic_boost(codec);
10023 if (err < 0)
10024 return err;
10025
Kailang Yanga361d842007-06-05 12:30:55 +020010026 return 1;
10027}
10028
10029#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10030#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10031#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10032
10033/* init callback for auto-configuration model -- overriding the default init */
10034static void alc268_auto_init(struct hda_codec *codec)
10035{
10036 alc268_auto_init_multi_out(codec);
10037 alc268_auto_init_hp_out(codec);
10038 alc268_auto_init_mono_speaker_out(codec);
10039 alc268_auto_init_analog_input(codec);
10040}
10041
10042/*
10043 * configuration and preset
10044 */
10045static const char *alc268_models[ALC268_MODEL_LAST] = {
10046 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010047 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010048 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010049 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010050 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010051#ifdef CONFIG_SND_DEBUG
10052 [ALC268_TEST] = "test",
10053#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010054 [ALC268_AUTO] = "auto",
10055};
10056
10057static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010058 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010059 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010060 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010061 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010062 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010063 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010064 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010065 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010066 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010067 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010068 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010069 {}
10070};
10071
10072static struct alc_config_preset alc268_presets[] = {
10073 [ALC268_3ST] = {
10074 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10075 .init_verbs = { alc268_base_init_verbs },
10076 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10077 .dac_nids = alc268_dac_nids,
10078 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10079 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010080 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010081 .hp_nid = 0x03,
10082 .dig_out_nid = ALC268_DIGOUT_NID,
10083 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10084 .channel_mode = alc268_modes,
10085 .input_mux = &alc268_capture_source,
10086 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010087 [ALC268_TOSHIBA] = {
10088 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010089 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10090 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010091 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10092 .dac_nids = alc268_dac_nids,
10093 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10094 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010095 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010096 .hp_nid = 0x03,
10097 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10098 .channel_mode = alc268_modes,
10099 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010100 .unsol_event = alc268_toshiba_unsol_event,
10101 .init_hook = alc268_toshiba_automute,
10102 },
10103 [ALC268_ACER] = {
10104 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
10105 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10106 alc268_acer_verbs },
10107 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10108 .dac_nids = alc268_dac_nids,
10109 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10110 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010111 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010112 .hp_nid = 0x02,
10113 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10114 .channel_mode = alc268_modes,
10115 .input_mux = &alc268_capture_source,
10116 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010117 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010118 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010119 [ALC268_DELL] = {
10120 .mixers = { alc268_dell_mixer },
10121 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10122 alc268_dell_verbs },
10123 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10124 .dac_nids = alc268_dac_nids,
10125 .hp_nid = 0x02,
10126 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10127 .channel_mode = alc268_modes,
10128 .unsol_event = alc268_dell_unsol_event,
10129 .init_hook = alc268_dell_init_hook,
10130 .input_mux = &alc268_capture_source,
10131 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010132 [ALC268_ZEPTO] = {
10133 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10134 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10135 alc268_toshiba_verbs },
10136 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10137 .dac_nids = alc268_dac_nids,
10138 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10139 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010140 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010141 .hp_nid = 0x03,
10142 .dig_out_nid = ALC268_DIGOUT_NID,
10143 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10144 .channel_mode = alc268_modes,
10145 .input_mux = &alc268_capture_source,
10146 .unsol_event = alc268_toshiba_unsol_event,
10147 .init_hook = alc268_toshiba_automute
10148 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010149#ifdef CONFIG_SND_DEBUG
10150 [ALC268_TEST] = {
10151 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10152 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10153 alc268_volume_init_verbs },
10154 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10155 .dac_nids = alc268_dac_nids,
10156 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10157 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010158 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010159 .hp_nid = 0x03,
10160 .dig_out_nid = ALC268_DIGOUT_NID,
10161 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10162 .channel_mode = alc268_modes,
10163 .input_mux = &alc268_capture_source,
10164 },
10165#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010166};
10167
10168static int patch_alc268(struct hda_codec *codec)
10169{
10170 struct alc_spec *spec;
10171 int board_config;
10172 int err;
10173
10174 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10175 if (spec == NULL)
10176 return -ENOMEM;
10177
10178 codec->spec = spec;
10179
10180 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10181 alc268_models,
10182 alc268_cfg_tbl);
10183
10184 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10185 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10186 "trying auto-probe from BIOS...\n");
10187 board_config = ALC268_AUTO;
10188 }
10189
10190 if (board_config == ALC268_AUTO) {
10191 /* automatic parse from the BIOS config */
10192 err = alc268_parse_auto_config(codec);
10193 if (err < 0) {
10194 alc_free(codec);
10195 return err;
10196 } else if (!err) {
10197 printk(KERN_INFO
10198 "hda_codec: Cannot set up configuration "
10199 "from BIOS. Using base mode...\n");
10200 board_config = ALC268_3ST;
10201 }
10202 }
10203
10204 if (board_config != ALC268_AUTO)
10205 setup_preset(spec, &alc268_presets[board_config]);
10206
10207 spec->stream_name_analog = "ALC268 Analog";
10208 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10209 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010210 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010211
10212 spec->stream_name_digital = "ALC268 Digital";
10213 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10214
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010215 if (!spec->adc_nids && spec->input_mux) {
10216 /* check whether NID 0x07 is valid */
10217 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010218
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010219 /* get type */
10220 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10221 if (wcap != AC_WID_AUD_IN) {
10222 spec->adc_nids = alc268_adc_nids_alt;
10223 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10224 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010225 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010226 spec->num_mixers++;
10227 } else {
10228 spec->adc_nids = alc268_adc_nids;
10229 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10230 spec->mixers[spec->num_mixers] =
10231 alc268_capture_mixer;
10232 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010233 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010234 spec->capsrc_nids = alc268_capsrc_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020010235 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010236
10237 spec->vmaster_nid = 0x02;
10238
Kailang Yanga361d842007-06-05 12:30:55 +020010239 codec->patch_ops = alc_patch_ops;
10240 if (board_config == ALC268_AUTO)
10241 spec->init_hook = alc268_auto_init;
10242
10243 return 0;
10244}
10245
10246/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010247 * ALC269 channel source setting (2 channel)
10248 */
10249#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10250
10251#define alc269_dac_nids alc260_dac_nids
10252
10253static hda_nid_t alc269_adc_nids[1] = {
10254 /* ADC1 */
10255 0x07,
10256};
10257
10258#define alc269_modes alc260_modes
10259#define alc269_capture_source alc880_lg_lw_capture_source
10260
10261static struct snd_kcontrol_new alc269_base_mixer[] = {
10262 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10263 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10265 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10268 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10269 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10270 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10271 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10272 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10273 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10274 { } /* end */
10275};
10276
10277/* capture mixer elements */
10278static struct snd_kcontrol_new alc269_capture_mixer[] = {
10279 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10280 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10281 {
10282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10283 /* The multiple "Capture Source" controls confuse alsamixer
10284 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010285 */
10286 /* .name = "Capture Source", */
10287 .name = "Input Source",
10288 .count = 1,
10289 .info = alc_mux_enum_info,
10290 .get = alc_mux_enum_get,
10291 .put = alc_mux_enum_put,
10292 },
10293 { } /* end */
10294};
10295
10296/*
10297 * generic initialization of ADC, input mixers and output mixers
10298 */
10299static struct hda_verb alc269_init_verbs[] = {
10300 /*
10301 * Unmute ADC0 and set the default input to mic-in
10302 */
10303 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10304
10305 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10306 * analog-loopback mixer widget
10307 * Note: PASD motherboards uses the Line In 2 as the input for
10308 * front panel mic (mic 2)
10309 */
10310 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10316
10317 /*
10318 * Set up output mixers (0x0c - 0x0e)
10319 */
10320 /* set vol=0 to output mixers */
10321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10322 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10323
10324 /* set up input amps for analog loopback */
10325 /* Amp Indices: DAC = 0, mixer = 1 */
10326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10332
10333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10340
10341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10345 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10348
10349 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10350 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10351
10352 /* FIXME: use matrix-type input source selection */
10353 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10354 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10359
10360 /* set EAPD */
10361 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10362 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10363 { }
10364};
10365
10366/* add playback controls from the parsed DAC table */
10367static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10368 const struct auto_pin_cfg *cfg)
10369{
10370 hda_nid_t nid;
10371 int err;
10372
10373 spec->multiout.num_dacs = 1; /* only use one dac */
10374 spec->multiout.dac_nids = spec->private_dac_nids;
10375 spec->multiout.dac_nids[0] = 2;
10376
10377 nid = cfg->line_out_pins[0];
10378 if (nid) {
10379 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10380 "Front Playback Volume",
10381 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10382 if (err < 0)
10383 return err;
10384 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10385 "Front Playback Switch",
10386 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10387 if (err < 0)
10388 return err;
10389 }
10390
10391 nid = cfg->speaker_pins[0];
10392 if (nid) {
10393 if (!cfg->line_out_pins[0]) {
10394 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10395 "Speaker Playback Volume",
10396 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10397 HDA_OUTPUT));
10398 if (err < 0)
10399 return err;
10400 }
10401 if (nid == 0x16) {
10402 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10403 "Speaker Playback Switch",
10404 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10405 HDA_OUTPUT));
10406 if (err < 0)
10407 return err;
10408 } else {
10409 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10410 "Speaker Playback Switch",
10411 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10412 HDA_OUTPUT));
10413 if (err < 0)
10414 return err;
10415 }
10416 }
10417 nid = cfg->hp_pins[0];
10418 if (nid) {
10419 /* spec->multiout.hp_nid = 2; */
10420 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10421 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10422 "Headphone Playback Volume",
10423 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10424 HDA_OUTPUT));
10425 if (err < 0)
10426 return err;
10427 }
10428 if (nid == 0x16) {
10429 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10430 "Headphone Playback Switch",
10431 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10432 HDA_OUTPUT));
10433 if (err < 0)
10434 return err;
10435 } else {
10436 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10437 "Headphone Playback Switch",
10438 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10439 HDA_OUTPUT));
10440 if (err < 0)
10441 return err;
10442 }
10443 }
10444 return 0;
10445}
10446
10447#define alc269_auto_create_analog_input_ctls \
10448 alc880_auto_create_analog_input_ctls
10449
10450#ifdef CONFIG_SND_HDA_POWER_SAVE
10451#define alc269_loopbacks alc880_loopbacks
10452#endif
10453
10454/* pcm configuration: identiacal with ALC880 */
10455#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10456#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10457#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10458#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10459
10460/*
10461 * BIOS auto configuration
10462 */
10463static int alc269_parse_auto_config(struct hda_codec *codec)
10464{
10465 struct alc_spec *spec = codec->spec;
10466 int err;
10467 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10468
10469 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10470 alc269_ignore);
10471 if (err < 0)
10472 return err;
10473
10474 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10475 if (err < 0)
10476 return err;
10477 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10478 if (err < 0)
10479 return err;
10480
10481 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10482
10483 if (spec->autocfg.dig_out_pin)
10484 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10485
10486 if (spec->kctl_alloc)
10487 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10488
10489 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10490 spec->num_mux_defs = 1;
10491 spec->input_mux = &spec->private_imux;
10492
10493 err = alc_auto_add_mic_boost(codec);
10494 if (err < 0)
10495 return err;
10496
10497 return 1;
10498}
10499
10500#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10501#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10502#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10503
10504
10505/* init callback for auto-configuration model -- overriding the default init */
10506static void alc269_auto_init(struct hda_codec *codec)
10507{
10508 alc269_auto_init_multi_out(codec);
10509 alc269_auto_init_hp_out(codec);
10510 alc269_auto_init_analog_input(codec);
10511}
10512
10513/*
10514 * configuration and preset
10515 */
10516static const char *alc269_models[ALC269_MODEL_LAST] = {
10517 [ALC269_BASIC] = "basic",
10518};
10519
10520static struct snd_pci_quirk alc269_cfg_tbl[] = {
10521 {}
10522};
10523
10524static struct alc_config_preset alc269_presets[] = {
10525 [ALC269_BASIC] = {
10526 .mixers = { alc269_base_mixer },
10527 .init_verbs = { alc269_init_verbs },
10528 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10529 .dac_nids = alc269_dac_nids,
10530 .hp_nid = 0x03,
10531 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10532 .channel_mode = alc269_modes,
10533 .input_mux = &alc269_capture_source,
10534 },
10535};
10536
10537static int patch_alc269(struct hda_codec *codec)
10538{
10539 struct alc_spec *spec;
10540 int board_config;
10541 int err;
10542
10543 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10544 if (spec == NULL)
10545 return -ENOMEM;
10546
10547 codec->spec = spec;
10548
10549 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10550 alc269_models,
10551 alc269_cfg_tbl);
10552
10553 if (board_config < 0) {
10554 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10555 "trying auto-probe from BIOS...\n");
10556 board_config = ALC269_AUTO;
10557 }
10558
10559 if (board_config == ALC269_AUTO) {
10560 /* automatic parse from the BIOS config */
10561 err = alc269_parse_auto_config(codec);
10562 if (err < 0) {
10563 alc_free(codec);
10564 return err;
10565 } else if (!err) {
10566 printk(KERN_INFO
10567 "hda_codec: Cannot set up configuration "
10568 "from BIOS. Using base mode...\n");
10569 board_config = ALC269_BASIC;
10570 }
10571 }
10572
10573 if (board_config != ALC269_AUTO)
10574 setup_preset(spec, &alc269_presets[board_config]);
10575
10576 spec->stream_name_analog = "ALC269 Analog";
10577 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10578 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10579
10580 spec->stream_name_digital = "ALC269 Digital";
10581 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10582 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10583
10584 spec->adc_nids = alc269_adc_nids;
10585 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10586 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10587 spec->num_mixers++;
10588
10589 codec->patch_ops = alc_patch_ops;
10590 if (board_config == ALC269_AUTO)
10591 spec->init_hook = alc269_auto_init;
10592#ifdef CONFIG_SND_HDA_POWER_SAVE
10593 if (!spec->loopback.amplist)
10594 spec->loopback.amplist = alc269_loopbacks;
10595#endif
10596
10597 return 0;
10598}
10599
10600/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010601 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10602 */
10603
10604/*
10605 * set the path ways for 2 channel output
10606 * need to set the codec line out and mic 1 pin widgets to inputs
10607 */
10608static struct hda_verb alc861_threestack_ch2_init[] = {
10609 /* set pin widget 1Ah (line in) for input */
10610 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010611 /* set pin widget 18h (mic1/2) for input, for mic also enable
10612 * the vref
10613 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010614 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10615
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010616 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10617#if 0
10618 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10619 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10620#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010621 { } /* end */
10622};
10623/*
10624 * 6ch mode
10625 * need to set the codec line out and mic 1 pin widgets to outputs
10626 */
10627static struct hda_verb alc861_threestack_ch6_init[] = {
10628 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10629 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10630 /* set pin widget 18h (mic1) for output (CLFE)*/
10631 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10632
10633 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010634 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010635
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010636 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10637#if 0
10638 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10639 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10640#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010641 { } /* end */
10642};
10643
10644static struct hda_channel_mode alc861_threestack_modes[2] = {
10645 { 2, alc861_threestack_ch2_init },
10646 { 6, alc861_threestack_ch6_init },
10647};
Takashi Iwai22309c32006-08-09 16:57:28 +020010648/* Set mic1 as input and unmute the mixer */
10649static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10650 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10651 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10652 { } /* end */
10653};
10654/* Set mic1 as output and mute mixer */
10655static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10656 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10657 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10658 { } /* end */
10659};
10660
10661static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10662 { 2, alc861_uniwill_m31_ch2_init },
10663 { 4, alc861_uniwill_m31_ch4_init },
10664};
Kailang Yangdf694da2005-12-05 19:42:22 +010010665
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010666/* Set mic1 and line-in as input and unmute the mixer */
10667static struct hda_verb alc861_asus_ch2_init[] = {
10668 /* set pin widget 1Ah (line in) for input */
10669 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010670 /* set pin widget 18h (mic1/2) for input, for mic also enable
10671 * the vref
10672 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010673 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10674
10675 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10676#if 0
10677 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10678 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10679#endif
10680 { } /* end */
10681};
10682/* Set mic1 nad line-in as output and mute mixer */
10683static struct hda_verb alc861_asus_ch6_init[] = {
10684 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10685 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10686 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10687 /* set pin widget 18h (mic1) for output (CLFE)*/
10688 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10689 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10690 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10691 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10692
10693 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10694#if 0
10695 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10696 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10697#endif
10698 { } /* end */
10699};
10700
10701static struct hda_channel_mode alc861_asus_modes[2] = {
10702 { 2, alc861_asus_ch2_init },
10703 { 6, alc861_asus_ch6_init },
10704};
10705
Kailang Yangdf694da2005-12-05 19:42:22 +010010706/* patch-ALC861 */
10707
10708static struct snd_kcontrol_new alc861_base_mixer[] = {
10709 /* output mixer control */
10710 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10711 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10712 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10713 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10714 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10715
10716 /*Input mixer control */
10717 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10718 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10719 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10720 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10721 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10722 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10724 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10725 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010727
Kailang Yangdf694da2005-12-05 19:42:22 +010010728 /* Capture mixer control */
10729 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10730 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10731 {
10732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10733 .name = "Capture Source",
10734 .count = 1,
10735 .info = alc_mux_enum_info,
10736 .get = alc_mux_enum_get,
10737 .put = alc_mux_enum_put,
10738 },
10739 { } /* end */
10740};
10741
10742static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10743 /* output mixer control */
10744 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10745 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10746 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10747 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10748 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10749
10750 /* Input mixer control */
10751 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10752 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10753 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10754 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10756 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10758 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10759 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10760 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010761
Kailang Yangdf694da2005-12-05 19:42:22 +010010762 /* Capture mixer control */
10763 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10764 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10765 {
10766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10767 .name = "Capture Source",
10768 .count = 1,
10769 .info = alc_mux_enum_info,
10770 .get = alc_mux_enum_get,
10771 .put = alc_mux_enum_put,
10772 },
10773 {
10774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10775 .name = "Channel Mode",
10776 .info = alc_ch_mode_info,
10777 .get = alc_ch_mode_get,
10778 .put = alc_ch_mode_put,
10779 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10780 },
10781 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010782};
10783
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010784static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010785 /* output mixer control */
10786 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10788 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10789
10790 /*Capture mixer control */
10791 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10792 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10793 {
10794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10795 .name = "Capture Source",
10796 .count = 1,
10797 .info = alc_mux_enum_info,
10798 .get = alc_mux_enum_get,
10799 .put = alc_mux_enum_put,
10800 },
10801
10802 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010803};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010804
Takashi Iwai22309c32006-08-09 16:57:28 +020010805static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10806 /* output mixer control */
10807 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10808 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10809 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10810 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10811 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10812
10813 /* Input mixer control */
10814 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10815 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10816 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10817 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10818 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10819 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10821 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010824
Takashi Iwai22309c32006-08-09 16:57:28 +020010825 /* Capture mixer control */
10826 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10827 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10828 {
10829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10830 .name = "Capture Source",
10831 .count = 1,
10832 .info = alc_mux_enum_info,
10833 .get = alc_mux_enum_get,
10834 .put = alc_mux_enum_put,
10835 },
10836 {
10837 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10838 .name = "Channel Mode",
10839 .info = alc_ch_mode_info,
10840 .get = alc_ch_mode_get,
10841 .put = alc_ch_mode_put,
10842 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10843 },
10844 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010845};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010846
10847static struct snd_kcontrol_new alc861_asus_mixer[] = {
10848 /* output mixer control */
10849 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10850 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10851 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10852 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10853 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10854
10855 /* Input mixer control */
10856 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10857 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10858 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10859 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10860 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10861 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10863 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10864 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10866
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010867 /* Capture mixer control */
10868 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10869 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10870 {
10871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10872 .name = "Capture Source",
10873 .count = 1,
10874 .info = alc_mux_enum_info,
10875 .get = alc_mux_enum_get,
10876 .put = alc_mux_enum_put,
10877 },
10878 {
10879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10880 .name = "Channel Mode",
10881 .info = alc_ch_mode_info,
10882 .get = alc_ch_mode_get,
10883 .put = alc_ch_mode_put,
10884 .private_value = ARRAY_SIZE(alc861_asus_modes),
10885 },
10886 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010887};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010888
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010889/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010890static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010891 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10892 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10893 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10894 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10895 { }
10896};
10897
Kailang Yangdf694da2005-12-05 19:42:22 +010010898/*
10899 * generic initialization of ADC, input mixers and output mixers
10900 */
10901static struct hda_verb alc861_base_init_verbs[] = {
10902 /*
10903 * Unmute ADC0 and set the default input to mic-in
10904 */
10905 /* port-A for surround (rear panel) */
10906 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10907 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10908 /* port-B for mic-in (rear panel) with vref */
10909 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10910 /* port-C for line-in (rear panel) */
10911 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10912 /* port-D for Front */
10913 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10914 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10915 /* port-E for HP out (front panel) */
10916 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10917 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010918 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010919 /* port-F for mic-in (front panel) with vref */
10920 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10921 /* port-G for CLFE (rear panel) */
10922 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10923 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10924 /* port-H for side (rear panel) */
10925 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10926 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10927 /* CD-in */
10928 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10929 /* route front mic to ADC1*/
10930 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10932
10933 /* Unmute DAC0~3 & spdif out*/
10934 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10935 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10936 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10937 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10939
10940 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10941 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10942 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10943 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10944 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10945
10946 /* Unmute Stereo Mixer 15 */
10947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10949 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010951
10952 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10954 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10957 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10958 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010960 /* hp used DAC 3 (Front) */
10961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10963
10964 { }
10965};
10966
10967static struct hda_verb alc861_threestack_init_verbs[] = {
10968 /*
10969 * Unmute ADC0 and set the default input to mic-in
10970 */
10971 /* port-A for surround (rear panel) */
10972 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10973 /* port-B for mic-in (rear panel) with vref */
10974 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10975 /* port-C for line-in (rear panel) */
10976 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10977 /* port-D for Front */
10978 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10979 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10980 /* port-E for HP out (front panel) */
10981 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10982 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010983 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010984 /* port-F for mic-in (front panel) with vref */
10985 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10986 /* port-G for CLFE (rear panel) */
10987 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10988 /* port-H for side (rear panel) */
10989 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10990 /* CD-in */
10991 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10992 /* route front mic to ADC1*/
10993 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10995 /* Unmute DAC0~3 & spdif out*/
10996 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10997 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10998 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10999 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11001
11002 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11003 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11004 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11005 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11006 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11007
11008 /* Unmute Stereo Mixer 15 */
11009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011013
11014 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11016 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11018 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11019 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11020 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011022 /* hp used DAC 3 (Front) */
11023 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11025 { }
11026};
Takashi Iwai22309c32006-08-09 16:57:28 +020011027
11028static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11029 /*
11030 * Unmute ADC0 and set the default input to mic-in
11031 */
11032 /* port-A for surround (rear panel) */
11033 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11034 /* port-B for mic-in (rear panel) with vref */
11035 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11036 /* port-C for line-in (rear panel) */
11037 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11038 /* port-D for Front */
11039 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11040 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11041 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011042 /* this has to be set to VREF80 */
11043 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011044 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011045 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011046 /* port-F for mic-in (front panel) with vref */
11047 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11048 /* port-G for CLFE (rear panel) */
11049 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11050 /* port-H for side (rear panel) */
11051 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11052 /* CD-in */
11053 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11054 /* route front mic to ADC1*/
11055 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057 /* Unmute DAC0~3 & spdif out*/
11058 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11059 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11060 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11061 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11063
11064 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11065 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11066 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11067 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11068 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11069
11070 /* Unmute Stereo Mixer 15 */
11071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011075
11076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11077 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11079 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11080 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11081 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011084 /* hp used DAC 3 (Front) */
11085 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11087 { }
11088};
11089
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011090static struct hda_verb alc861_asus_init_verbs[] = {
11091 /*
11092 * Unmute ADC0 and set the default input to mic-in
11093 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011094 /* port-A for surround (rear panel)
11095 * according to codec#0 this is the HP jack
11096 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011097 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11098 /* route front PCM to HP */
11099 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11100 /* port-B for mic-in (rear panel) with vref */
11101 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11102 /* port-C for line-in (rear panel) */
11103 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11104 /* port-D for Front */
11105 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11106 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11107 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011108 /* this has to be set to VREF80 */
11109 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011110 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011111 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011112 /* port-F for mic-in (front panel) with vref */
11113 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11114 /* port-G for CLFE (rear panel) */
11115 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11116 /* port-H for side (rear panel) */
11117 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11118 /* CD-in */
11119 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11120 /* route front mic to ADC1*/
11121 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11123 /* Unmute DAC0~3 & spdif out*/
11124 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11125 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11126 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11127 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11129 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11130 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11131 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11132 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11133 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11134
11135 /* Unmute Stereo Mixer 15 */
11136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011140
11141 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11142 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11143 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11144 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11146 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011149 /* hp used DAC 3 (Front) */
11150 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011151 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11152 { }
11153};
11154
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011155/* additional init verbs for ASUS laptops */
11156static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11157 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11158 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11159 { }
11160};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011161
Kailang Yangdf694da2005-12-05 19:42:22 +010011162/*
11163 * generic initialization of ADC, input mixers and output mixers
11164 */
11165static struct hda_verb alc861_auto_init_verbs[] = {
11166 /*
11167 * Unmute ADC0 and set the default input to mic-in
11168 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011169 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011170 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11171
11172 /* Unmute DAC0~3 & spdif out*/
11173 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11174 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11175 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11176 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11177 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11178
11179 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11180 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11181 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11182 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11183 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11184
11185 /* Unmute Stereo Mixer 15 */
11186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11190
11191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11192 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11193 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11194 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11196 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11199
11200 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011202 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011204 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11205 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011206 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011208
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011209 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011210
11211 { }
11212};
11213
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011214static struct hda_verb alc861_toshiba_init_verbs[] = {
11215 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011216
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011217 { }
11218};
11219
11220/* toggle speaker-output according to the hp-jack state */
11221static void alc861_toshiba_automute(struct hda_codec *codec)
11222{
11223 unsigned int present;
11224
11225 present = snd_hda_codec_read(codec, 0x0f, 0,
11226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011227 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11228 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11229 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11230 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011231}
11232
11233static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11234 unsigned int res)
11235{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011236 if ((res >> 26) == ALC880_HP_EVENT)
11237 alc861_toshiba_automute(codec);
11238}
11239
Kailang Yangdf694da2005-12-05 19:42:22 +010011240/* pcm configuration: identiacal with ALC880 */
11241#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11242#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11243#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11244#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11245
11246
11247#define ALC861_DIGOUT_NID 0x07
11248
11249static struct hda_channel_mode alc861_8ch_modes[1] = {
11250 { 8, NULL }
11251};
11252
11253static hda_nid_t alc861_dac_nids[4] = {
11254 /* front, surround, clfe, side */
11255 0x03, 0x06, 0x05, 0x04
11256};
11257
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011258static hda_nid_t alc660_dac_nids[3] = {
11259 /* front, clfe, surround */
11260 0x03, 0x05, 0x06
11261};
11262
Kailang Yangdf694da2005-12-05 19:42:22 +010011263static hda_nid_t alc861_adc_nids[1] = {
11264 /* ADC0-2 */
11265 0x08,
11266};
11267
11268static struct hda_input_mux alc861_capture_source = {
11269 .num_items = 5,
11270 .items = {
11271 { "Mic", 0x0 },
11272 { "Front Mic", 0x3 },
11273 { "Line", 0x1 },
11274 { "CD", 0x4 },
11275 { "Mixer", 0x5 },
11276 },
11277};
11278
11279/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011280static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11281 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011282{
11283 int i;
11284 hda_nid_t nid;
11285
11286 spec->multiout.dac_nids = spec->private_dac_nids;
11287 for (i = 0; i < cfg->line_outs; i++) {
11288 nid = cfg->line_out_pins[i];
11289 if (nid) {
11290 if (i >= ARRAY_SIZE(alc861_dac_nids))
11291 continue;
11292 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11293 }
11294 }
11295 spec->multiout.num_dacs = cfg->line_outs;
11296 return 0;
11297}
11298
11299/* add playback controls from the parsed DAC table */
11300static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11301 const struct auto_pin_cfg *cfg)
11302{
11303 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011304 static const char *chname[4] = {
11305 "Front", "Surround", NULL /*CLFE*/, "Side"
11306 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011307 hda_nid_t nid;
11308 int i, idx, err;
11309
11310 for (i = 0; i < cfg->line_outs; i++) {
11311 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011312 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011313 continue;
11314 if (nid == 0x05) {
11315 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011316 err = add_control(spec, ALC_CTL_BIND_MUTE,
11317 "Center Playback Switch",
11318 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11319 HDA_OUTPUT));
11320 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011321 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011322 err = add_control(spec, ALC_CTL_BIND_MUTE,
11323 "LFE Playback Switch",
11324 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11325 HDA_OUTPUT));
11326 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011327 return err;
11328 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011329 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11330 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011331 if (nid == alc861_dac_nids[idx])
11332 break;
11333 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011334 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11335 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11336 HDA_OUTPUT));
11337 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011338 return err;
11339 }
11340 }
11341 return 0;
11342}
11343
11344static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11345{
11346 int err;
11347 hda_nid_t nid;
11348
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011349 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011350 return 0;
11351
11352 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11353 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011354 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11355 "Headphone Playback Switch",
11356 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11357 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011358 return err;
11359 spec->multiout.hp_nid = nid;
11360 }
11361 return 0;
11362}
11363
11364/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011365static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11366 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011367{
Kailang Yangdf694da2005-12-05 19:42:22 +010011368 struct hda_input_mux *imux = &spec->private_imux;
11369 int i, err, idx, idx1;
11370
11371 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011372 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011373 case 0x0c:
11374 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011375 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011376 break;
11377 case 0x0f:
11378 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011379 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011380 break;
11381 case 0x0d:
11382 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011383 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011384 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011385 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011386 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011387 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011388 break;
11389 case 0x11:
11390 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011391 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011392 break;
11393 default:
11394 continue;
11395 }
11396
Takashi Iwai4a471b72005-12-07 13:56:29 +010011397 err = new_analog_input(spec, cfg->input_pins[i],
11398 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011399 if (err < 0)
11400 return err;
11401
Takashi Iwai4a471b72005-12-07 13:56:29 +010011402 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011403 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011404 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011405 }
11406 return 0;
11407}
11408
11409static struct snd_kcontrol_new alc861_capture_mixer[] = {
11410 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11411 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11412
11413 {
11414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11415 /* The multiple "Capture Source" controls confuse alsamixer
11416 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011417 */
11418 /* .name = "Capture Source", */
11419 .name = "Input Source",
11420 .count = 1,
11421 .info = alc_mux_enum_info,
11422 .get = alc_mux_enum_get,
11423 .put = alc_mux_enum_put,
11424 },
11425 { } /* end */
11426};
11427
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011428static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11429 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011430 int pin_type, int dac_idx)
11431{
11432 /* set as output */
11433
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011434 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11435 pin_type);
11436 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11437 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011438
11439}
11440
11441static void alc861_auto_init_multi_out(struct hda_codec *codec)
11442{
11443 struct alc_spec *spec = codec->spec;
11444 int i;
11445
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011446 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011447 for (i = 0; i < spec->autocfg.line_outs; i++) {
11448 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011449 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011450 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011451 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011452 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011453 }
11454}
11455
11456static void alc861_auto_init_hp_out(struct hda_codec *codec)
11457{
11458 struct alc_spec *spec = codec->spec;
11459 hda_nid_t pin;
11460
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011461 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011462 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011463 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11464 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011465}
11466
11467static void alc861_auto_init_analog_input(struct hda_codec *codec)
11468{
11469 struct alc_spec *spec = codec->spec;
11470 int i;
11471
11472 for (i = 0; i < AUTO_PIN_LAST; i++) {
11473 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011474 if (nid >= 0x0c && nid <= 0x11) {
11475 snd_hda_codec_write(codec, nid, 0,
11476 AC_VERB_SET_PIN_WIDGET_CONTROL,
11477 i <= AUTO_PIN_FRONT_MIC ?
11478 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011479 }
11480 }
11481}
11482
11483/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011484/* return 1 if successful, 0 if the proper config is not found,
11485 * or a negative error code
11486 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011487static int alc861_parse_auto_config(struct hda_codec *codec)
11488{
11489 struct alc_spec *spec = codec->spec;
11490 int err;
11491 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11492
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011493 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11494 alc861_ignore);
11495 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011496 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011497 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011498 return 0; /* can't find valid BIOS pin config */
11499
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011500 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11501 if (err < 0)
11502 return err;
11503 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11504 if (err < 0)
11505 return err;
11506 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11507 if (err < 0)
11508 return err;
11509 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11510 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011511 return err;
11512
11513 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11514
11515 if (spec->autocfg.dig_out_pin)
11516 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11517
11518 if (spec->kctl_alloc)
11519 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11520
11521 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11522
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011523 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011524 spec->input_mux = &spec->private_imux;
11525
11526 spec->adc_nids = alc861_adc_nids;
11527 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11528 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11529 spec->num_mixers++;
11530
11531 return 1;
11532}
11533
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011534/* additional initialization for auto-configuration model */
11535static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011536{
Kailang Yangdf694da2005-12-05 19:42:22 +010011537 alc861_auto_init_multi_out(codec);
11538 alc861_auto_init_hp_out(codec);
11539 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011540}
11541
Takashi Iwaicb53c622007-08-10 17:21:45 +020011542#ifdef CONFIG_SND_HDA_POWER_SAVE
11543static struct hda_amp_list alc861_loopbacks[] = {
11544 { 0x15, HDA_INPUT, 0 },
11545 { 0x15, HDA_INPUT, 1 },
11546 { 0x15, HDA_INPUT, 2 },
11547 { 0x15, HDA_INPUT, 3 },
11548 { } /* end */
11549};
11550#endif
11551
Kailang Yangdf694da2005-12-05 19:42:22 +010011552
11553/*
11554 * configuration and preset
11555 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011556static const char *alc861_models[ALC861_MODEL_LAST] = {
11557 [ALC861_3ST] = "3stack",
11558 [ALC660_3ST] = "3stack-660",
11559 [ALC861_3ST_DIG] = "3stack-dig",
11560 [ALC861_6ST_DIG] = "6stack-dig",
11561 [ALC861_UNIWILL_M31] = "uniwill-m31",
11562 [ALC861_TOSHIBA] = "toshiba",
11563 [ALC861_ASUS] = "asus",
11564 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11565 [ALC861_AUTO] = "auto",
11566};
11567
11568static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011569 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011570 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11571 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11572 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011573 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011574 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011575 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011576 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11577 * Any other models that need this preset?
11578 */
11579 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011580 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11581 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011582 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11583 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11584 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11585 /* FIXME: the below seems conflict */
11586 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11587 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11588 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011589 {}
11590};
11591
11592static struct alc_config_preset alc861_presets[] = {
11593 [ALC861_3ST] = {
11594 .mixers = { alc861_3ST_mixer },
11595 .init_verbs = { alc861_threestack_init_verbs },
11596 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11597 .dac_nids = alc861_dac_nids,
11598 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11599 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011600 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011601 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11602 .adc_nids = alc861_adc_nids,
11603 .input_mux = &alc861_capture_source,
11604 },
11605 [ALC861_3ST_DIG] = {
11606 .mixers = { alc861_base_mixer },
11607 .init_verbs = { alc861_threestack_init_verbs },
11608 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11609 .dac_nids = alc861_dac_nids,
11610 .dig_out_nid = ALC861_DIGOUT_NID,
11611 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11612 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011613 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011614 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11615 .adc_nids = alc861_adc_nids,
11616 .input_mux = &alc861_capture_source,
11617 },
11618 [ALC861_6ST_DIG] = {
11619 .mixers = { alc861_base_mixer },
11620 .init_verbs = { alc861_base_init_verbs },
11621 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11622 .dac_nids = alc861_dac_nids,
11623 .dig_out_nid = ALC861_DIGOUT_NID,
11624 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11625 .channel_mode = alc861_8ch_modes,
11626 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11627 .adc_nids = alc861_adc_nids,
11628 .input_mux = &alc861_capture_source,
11629 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011630 [ALC660_3ST] = {
11631 .mixers = { alc861_3ST_mixer },
11632 .init_verbs = { alc861_threestack_init_verbs },
11633 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11634 .dac_nids = alc660_dac_nids,
11635 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11636 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011637 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011638 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11639 .adc_nids = alc861_adc_nids,
11640 .input_mux = &alc861_capture_source,
11641 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011642 [ALC861_UNIWILL_M31] = {
11643 .mixers = { alc861_uniwill_m31_mixer },
11644 .init_verbs = { alc861_uniwill_m31_init_verbs },
11645 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11646 .dac_nids = alc861_dac_nids,
11647 .dig_out_nid = ALC861_DIGOUT_NID,
11648 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11649 .channel_mode = alc861_uniwill_m31_modes,
11650 .need_dac_fix = 1,
11651 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11652 .adc_nids = alc861_adc_nids,
11653 .input_mux = &alc861_capture_source,
11654 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011655 [ALC861_TOSHIBA] = {
11656 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011657 .init_verbs = { alc861_base_init_verbs,
11658 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011659 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11660 .dac_nids = alc861_dac_nids,
11661 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11662 .channel_mode = alc883_3ST_2ch_modes,
11663 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11664 .adc_nids = alc861_adc_nids,
11665 .input_mux = &alc861_capture_source,
11666 .unsol_event = alc861_toshiba_unsol_event,
11667 .init_hook = alc861_toshiba_automute,
11668 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011669 [ALC861_ASUS] = {
11670 .mixers = { alc861_asus_mixer },
11671 .init_verbs = { alc861_asus_init_verbs },
11672 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11673 .dac_nids = alc861_dac_nids,
11674 .dig_out_nid = ALC861_DIGOUT_NID,
11675 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11676 .channel_mode = alc861_asus_modes,
11677 .need_dac_fix = 1,
11678 .hp_nid = 0x06,
11679 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11680 .adc_nids = alc861_adc_nids,
11681 .input_mux = &alc861_capture_source,
11682 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011683 [ALC861_ASUS_LAPTOP] = {
11684 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11685 .init_verbs = { alc861_asus_init_verbs,
11686 alc861_asus_laptop_init_verbs },
11687 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11688 .dac_nids = alc861_dac_nids,
11689 .dig_out_nid = ALC861_DIGOUT_NID,
11690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11691 .channel_mode = alc883_3ST_2ch_modes,
11692 .need_dac_fix = 1,
11693 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11694 .adc_nids = alc861_adc_nids,
11695 .input_mux = &alc861_capture_source,
11696 },
11697};
Kailang Yangdf694da2005-12-05 19:42:22 +010011698
11699
11700static int patch_alc861(struct hda_codec *codec)
11701{
11702 struct alc_spec *spec;
11703 int board_config;
11704 int err;
11705
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011707 if (spec == NULL)
11708 return -ENOMEM;
11709
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011710 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011711
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011712 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11713 alc861_models,
11714 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011715
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011716 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011717 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11718 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011719 board_config = ALC861_AUTO;
11720 }
11721
11722 if (board_config == ALC861_AUTO) {
11723 /* automatic parse from the BIOS config */
11724 err = alc861_parse_auto_config(codec);
11725 if (err < 0) {
11726 alc_free(codec);
11727 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011728 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011729 printk(KERN_INFO
11730 "hda_codec: Cannot set up configuration "
11731 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011732 board_config = ALC861_3ST_DIG;
11733 }
11734 }
11735
11736 if (board_config != ALC861_AUTO)
11737 setup_preset(spec, &alc861_presets[board_config]);
11738
11739 spec->stream_name_analog = "ALC861 Analog";
11740 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11741 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11742
11743 spec->stream_name_digital = "ALC861 Digital";
11744 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11745 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11746
Takashi Iwai2134ea42008-01-10 16:53:55 +010011747 spec->vmaster_nid = 0x03;
11748
Kailang Yangdf694da2005-12-05 19:42:22 +010011749 codec->patch_ops = alc_patch_ops;
11750 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011751 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011752#ifdef CONFIG_SND_HDA_POWER_SAVE
11753 if (!spec->loopback.amplist)
11754 spec->loopback.amplist = alc861_loopbacks;
11755#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011756
11757 return 0;
11758}
11759
11760/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011761 * ALC861-VD support
11762 *
11763 * Based on ALC882
11764 *
11765 * In addition, an independent DAC
11766 */
11767#define ALC861VD_DIGOUT_NID 0x06
11768
11769static hda_nid_t alc861vd_dac_nids[4] = {
11770 /* front, surr, clfe, side surr */
11771 0x02, 0x03, 0x04, 0x05
11772};
11773
11774/* dac_nids for ALC660vd are in a different order - according to
11775 * Realtek's driver.
11776 * This should probably tesult in a different mixer for 6stack models
11777 * of ALC660vd codecs, but for now there is only 3stack mixer
11778 * - and it is the same as in 861vd.
11779 * adc_nids in ALC660vd are (is) the same as in 861vd
11780 */
11781static hda_nid_t alc660vd_dac_nids[3] = {
11782 /* front, rear, clfe, rear_surr */
11783 0x02, 0x04, 0x03
11784};
11785
11786static hda_nid_t alc861vd_adc_nids[1] = {
11787 /* ADC0 */
11788 0x09,
11789};
11790
Takashi Iwaie1406342008-02-11 18:32:32 +010011791static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
11792
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011793/* input MUX */
11794/* FIXME: should be a matrix-type input source selection */
11795static struct hda_input_mux alc861vd_capture_source = {
11796 .num_items = 4,
11797 .items = {
11798 { "Mic", 0x0 },
11799 { "Front Mic", 0x1 },
11800 { "Line", 0x2 },
11801 { "CD", 0x4 },
11802 },
11803};
11804
Kailang Yang272a5272007-05-14 11:00:38 +020011805static struct hda_input_mux alc861vd_dallas_capture_source = {
11806 .num_items = 3,
11807 .items = {
11808 { "Front Mic", 0x0 },
11809 { "ATAPI Mic", 0x1 },
11810 { "Line In", 0x5 },
11811 },
11812};
11813
Kailang Yangd1a991a2007-08-15 16:21:59 +020011814static struct hda_input_mux alc861vd_hp_capture_source = {
11815 .num_items = 2,
11816 .items = {
11817 { "Front Mic", 0x0 },
11818 { "ATAPI Mic", 0x1 },
11819 },
11820};
11821
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011822#define alc861vd_mux_enum_info alc_mux_enum_info
11823#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010011824/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
11825#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011826
11827/*
11828 * 2ch mode
11829 */
11830static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11831 { 2, NULL }
11832};
11833
11834/*
11835 * 6ch mode
11836 */
11837static struct hda_verb alc861vd_6stack_ch6_init[] = {
11838 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11839 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11840 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11841 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11842 { } /* end */
11843};
11844
11845/*
11846 * 8ch mode
11847 */
11848static struct hda_verb alc861vd_6stack_ch8_init[] = {
11849 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11850 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11851 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11852 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11853 { } /* end */
11854};
11855
11856static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11857 { 6, alc861vd_6stack_ch6_init },
11858 { 8, alc861vd_6stack_ch8_init },
11859};
11860
11861static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11862 {
11863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11864 .name = "Channel Mode",
11865 .info = alc_ch_mode_info,
11866 .get = alc_ch_mode_get,
11867 .put = alc_ch_mode_put,
11868 },
11869 { } /* end */
11870};
11871
11872static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11873 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11874 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11875
11876 {
11877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11878 /* The multiple "Capture Source" controls confuse alsamixer
11879 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011880 */
11881 /* .name = "Capture Source", */
11882 .name = "Input Source",
11883 .count = 1,
11884 .info = alc861vd_mux_enum_info,
11885 .get = alc861vd_mux_enum_get,
11886 .put = alc861vd_mux_enum_put,
11887 },
11888 { } /* end */
11889};
11890
11891/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11892 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11893 */
11894static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11895 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11896 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11897
11898 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11899 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11900
11901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11902 HDA_OUTPUT),
11903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11904 HDA_OUTPUT),
11905 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11906 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11907
11908 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11909 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11910
11911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11912
11913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11916
11917 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11918 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11920
11921 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11922 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11923
11924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11926
11927 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11928 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11929
11930 { } /* end */
11931};
11932
11933static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11934 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11936
11937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11938
11939 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11941 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11942
11943 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11945 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11946
11947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11949
11950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11952
11953 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11954 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11955
11956 { } /* end */
11957};
11958
Kailang Yangbdd148a2007-05-08 15:19:08 +020011959static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11960 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11961 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11962 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11963
11964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11965
11966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11969
11970 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11973
11974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11975 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11976
11977 { } /* end */
11978};
11979
Kailang Yang272a5272007-05-14 11:00:38 +020011980/* Pin assignment: Front=0x14, HP = 0x15,
11981 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11982 */
11983static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11984 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11985 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11987 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11989 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11990 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11991 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011994 { } /* end */
11995};
11996
Kailang Yangd1a991a2007-08-15 16:21:59 +020011997/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11998 * Front Mic=0x18, ATAPI Mic = 0x19,
11999 */
12000static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12001 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12002 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12004 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12007 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12008 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12009
12010 { } /* end */
12011};
12012
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012013/*
12014 * generic initialization of ADC, input mixers and output mixers
12015 */
12016static struct hda_verb alc861vd_volume_init_verbs[] = {
12017 /*
12018 * Unmute ADC0 and set the default input to mic-in
12019 */
12020 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12022
12023 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12024 * the analog-loopback mixer widget
12025 */
12026 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12029 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012032
12033 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012038
12039 /*
12040 * Set up output mixers (0x02 - 0x05)
12041 */
12042 /* set vol=0 to output mixers */
12043 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12044 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12045 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12046 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12047
12048 /* set up input amps for analog loopback */
12049 /* Amp Indices: DAC = 0, mixer = 1 */
12050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12058
12059 { }
12060};
12061
12062/*
12063 * 3-stack pin configuration:
12064 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12065 */
12066static struct hda_verb alc861vd_3stack_init_verbs[] = {
12067 /*
12068 * Set pin mode and muting
12069 */
12070 /* set front pin widgets 0x14 for output */
12071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12073 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12074
12075 /* Mic (rear) pin: input vref at 80% */
12076 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12077 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12078 /* Front Mic pin: input vref at 80% */
12079 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12081 /* Line In pin: input */
12082 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12084 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12085 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12086 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12087 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12088 /* CD pin widget for input */
12089 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12090
12091 { }
12092};
12093
12094/*
12095 * 6-stack pin configuration:
12096 */
12097static struct hda_verb alc861vd_6stack_init_verbs[] = {
12098 /*
12099 * Set pin mode and muting
12100 */
12101 /* set front pin widgets 0x14 for output */
12102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12104 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12105
12106 /* Rear Pin: output 1 (0x0d) */
12107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12109 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12110 /* CLFE Pin: output 2 (0x0e) */
12111 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12112 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12113 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12114 /* Side Pin: output 3 (0x0f) */
12115 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12116 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12117 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12118
12119 /* Mic (rear) pin: input vref at 80% */
12120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12122 /* Front Mic pin: input vref at 80% */
12123 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12125 /* Line In pin: input */
12126 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12128 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12131 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12132 /* CD pin widget for input */
12133 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12134
12135 { }
12136};
12137
Kailang Yangbdd148a2007-05-08 15:19:08 +020012138static struct hda_verb alc861vd_eapd_verbs[] = {
12139 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12140 { }
12141};
12142
12143static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12147 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12148 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12149 {}
12150};
12151
12152/* toggle speaker-output according to the hp-jack state */
12153static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12154{
12155 unsigned int present;
12156 unsigned char bits;
12157
12158 present = snd_hda_codec_read(codec, 0x1b, 0,
12159 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012160 bits = present ? HDA_AMP_MUTE : 0;
12161 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12162 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012163}
12164
12165static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12166{
12167 unsigned int present;
12168 unsigned char bits;
12169
12170 present = snd_hda_codec_read(codec, 0x18, 0,
12171 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012172 bits = present ? HDA_AMP_MUTE : 0;
12173 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12174 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012175}
12176
12177static void alc861vd_lenovo_automute(struct hda_codec *codec)
12178{
12179 alc861vd_lenovo_hp_automute(codec);
12180 alc861vd_lenovo_mic_automute(codec);
12181}
12182
12183static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12184 unsigned int res)
12185{
12186 switch (res >> 26) {
12187 case ALC880_HP_EVENT:
12188 alc861vd_lenovo_hp_automute(codec);
12189 break;
12190 case ALC880_MIC_EVENT:
12191 alc861vd_lenovo_mic_automute(codec);
12192 break;
12193 }
12194}
12195
Kailang Yang272a5272007-05-14 11:00:38 +020012196static struct hda_verb alc861vd_dallas_verbs[] = {
12197 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12198 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12200 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12201
12202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12208 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12209 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12210
12211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12216 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12217 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12218 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12219
12220 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12222 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12224 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12226 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12227 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12228
12229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12233
12234 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12235 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12237
12238 { } /* end */
12239};
12240
12241/* toggle speaker-output according to the hp-jack state */
12242static void alc861vd_dallas_automute(struct hda_codec *codec)
12243{
12244 unsigned int present;
12245
12246 present = snd_hda_codec_read(codec, 0x15, 0,
12247 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12249 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012250}
12251
12252static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12253{
12254 if ((res >> 26) == ALC880_HP_EVENT)
12255 alc861vd_dallas_automute(codec);
12256}
12257
Takashi Iwaicb53c622007-08-10 17:21:45 +020012258#ifdef CONFIG_SND_HDA_POWER_SAVE
12259#define alc861vd_loopbacks alc880_loopbacks
12260#endif
12261
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012262/* pcm configuration: identiacal with ALC880 */
12263#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12264#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12265#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12266#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12267
12268/*
12269 * configuration and preset
12270 */
12271static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12272 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012273 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012274 [ALC861VD_3ST] = "3stack",
12275 [ALC861VD_3ST_DIG] = "3stack-digout",
12276 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012277 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012278 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012279 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012280 [ALC861VD_AUTO] = "auto",
12281};
12282
12283static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012284 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12285 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012286 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012287 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012288 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012289 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012290 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012291 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012292 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012293 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012294 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012295 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12296 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012297 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012298 {}
12299};
12300
12301static struct alc_config_preset alc861vd_presets[] = {
12302 [ALC660VD_3ST] = {
12303 .mixers = { alc861vd_3st_mixer },
12304 .init_verbs = { alc861vd_volume_init_verbs,
12305 alc861vd_3stack_init_verbs },
12306 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12307 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012308 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12309 .channel_mode = alc861vd_3stack_2ch_modes,
12310 .input_mux = &alc861vd_capture_source,
12311 },
Mike Crash6963f842007-06-25 12:12:51 +020012312 [ALC660VD_3ST_DIG] = {
12313 .mixers = { alc861vd_3st_mixer },
12314 .init_verbs = { alc861vd_volume_init_verbs,
12315 alc861vd_3stack_init_verbs },
12316 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12317 .dac_nids = alc660vd_dac_nids,
12318 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020012319 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12320 .channel_mode = alc861vd_3stack_2ch_modes,
12321 .input_mux = &alc861vd_capture_source,
12322 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012323 [ALC861VD_3ST] = {
12324 .mixers = { alc861vd_3st_mixer },
12325 .init_verbs = { alc861vd_volume_init_verbs,
12326 alc861vd_3stack_init_verbs },
12327 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12328 .dac_nids = alc861vd_dac_nids,
12329 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12330 .channel_mode = alc861vd_3stack_2ch_modes,
12331 .input_mux = &alc861vd_capture_source,
12332 },
12333 [ALC861VD_3ST_DIG] = {
12334 .mixers = { alc861vd_3st_mixer },
12335 .init_verbs = { alc861vd_volume_init_verbs,
12336 alc861vd_3stack_init_verbs },
12337 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12338 .dac_nids = alc861vd_dac_nids,
12339 .dig_out_nid = ALC861VD_DIGOUT_NID,
12340 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12341 .channel_mode = alc861vd_3stack_2ch_modes,
12342 .input_mux = &alc861vd_capture_source,
12343 },
12344 [ALC861VD_6ST_DIG] = {
12345 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12346 .init_verbs = { alc861vd_volume_init_verbs,
12347 alc861vd_6stack_init_verbs },
12348 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12349 .dac_nids = alc861vd_dac_nids,
12350 .dig_out_nid = ALC861VD_DIGOUT_NID,
12351 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12352 .channel_mode = alc861vd_6stack_modes,
12353 .input_mux = &alc861vd_capture_source,
12354 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012355 [ALC861VD_LENOVO] = {
12356 .mixers = { alc861vd_lenovo_mixer },
12357 .init_verbs = { alc861vd_volume_init_verbs,
12358 alc861vd_3stack_init_verbs,
12359 alc861vd_eapd_verbs,
12360 alc861vd_lenovo_unsol_verbs },
12361 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12362 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012363 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12364 .channel_mode = alc861vd_3stack_2ch_modes,
12365 .input_mux = &alc861vd_capture_source,
12366 .unsol_event = alc861vd_lenovo_unsol_event,
12367 .init_hook = alc861vd_lenovo_automute,
12368 },
Kailang Yang272a5272007-05-14 11:00:38 +020012369 [ALC861VD_DALLAS] = {
12370 .mixers = { alc861vd_dallas_mixer },
12371 .init_verbs = { alc861vd_dallas_verbs },
12372 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12373 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020012374 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12375 .channel_mode = alc861vd_3stack_2ch_modes,
12376 .input_mux = &alc861vd_dallas_capture_source,
12377 .unsol_event = alc861vd_dallas_unsol_event,
12378 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012379 },
12380 [ALC861VD_HP] = {
12381 .mixers = { alc861vd_hp_mixer },
12382 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12383 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12384 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012385 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012386 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12387 .channel_mode = alc861vd_3stack_2ch_modes,
12388 .input_mux = &alc861vd_hp_capture_source,
12389 .unsol_event = alc861vd_dallas_unsol_event,
12390 .init_hook = alc861vd_dallas_automute,
12391 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012392};
12393
12394/*
12395 * BIOS auto configuration
12396 */
12397static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12398 hda_nid_t nid, int pin_type, int dac_idx)
12399{
12400 /* set as output */
12401 snd_hda_codec_write(codec, nid, 0,
12402 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12403 snd_hda_codec_write(codec, nid, 0,
12404 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12405}
12406
12407static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12408{
12409 struct alc_spec *spec = codec->spec;
12410 int i;
12411
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012412 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012413 for (i = 0; i <= HDA_SIDE; i++) {
12414 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012415 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012416 if (nid)
12417 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012418 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012419 }
12420}
12421
12422
12423static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12424{
12425 struct alc_spec *spec = codec->spec;
12426 hda_nid_t pin;
12427
12428 pin = spec->autocfg.hp_pins[0];
12429 if (pin) /* connect to front and use dac 0 */
12430 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12431}
12432
12433#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12434#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12435
12436static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12437{
12438 struct alc_spec *spec = codec->spec;
12439 int i;
12440
12441 for (i = 0; i < AUTO_PIN_LAST; i++) {
12442 hda_nid_t nid = spec->autocfg.input_pins[i];
12443 if (alc861vd_is_input_pin(nid)) {
12444 snd_hda_codec_write(codec, nid, 0,
12445 AC_VERB_SET_PIN_WIDGET_CONTROL,
12446 i <= AUTO_PIN_FRONT_MIC ?
12447 PIN_VREF80 : PIN_IN);
12448 if (nid != ALC861VD_PIN_CD_NID)
12449 snd_hda_codec_write(codec, nid, 0,
12450 AC_VERB_SET_AMP_GAIN_MUTE,
12451 AMP_OUT_MUTE);
12452 }
12453 }
12454}
12455
12456#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12457#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12458
12459/* add playback controls from the parsed DAC table */
12460/* Based on ALC880 version. But ALC861VD has separate,
12461 * different NIDs for mute/unmute switch and volume control */
12462static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12463 const struct auto_pin_cfg *cfg)
12464{
12465 char name[32];
12466 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12467 hda_nid_t nid_v, nid_s;
12468 int i, err;
12469
12470 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012471 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012472 continue;
12473 nid_v = alc861vd_idx_to_mixer_vol(
12474 alc880_dac_to_idx(
12475 spec->multiout.dac_nids[i]));
12476 nid_s = alc861vd_idx_to_mixer_switch(
12477 alc880_dac_to_idx(
12478 spec->multiout.dac_nids[i]));
12479
12480 if (i == 2) {
12481 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012482 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12483 "Center Playback Volume",
12484 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12485 HDA_OUTPUT));
12486 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012487 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012488 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12489 "LFE Playback Volume",
12490 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12491 HDA_OUTPUT));
12492 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012493 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012494 err = add_control(spec, ALC_CTL_BIND_MUTE,
12495 "Center Playback Switch",
12496 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12497 HDA_INPUT));
12498 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012499 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012500 err = add_control(spec, ALC_CTL_BIND_MUTE,
12501 "LFE Playback Switch",
12502 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12503 HDA_INPUT));
12504 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012505 return err;
12506 } else {
12507 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012508 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12509 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12510 HDA_OUTPUT));
12511 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012512 return err;
12513 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012514 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012515 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012516 HDA_INPUT));
12517 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012518 return err;
12519 }
12520 }
12521 return 0;
12522}
12523
12524/* add playback controls for speaker and HP outputs */
12525/* Based on ALC880 version. But ALC861VD has separate,
12526 * different NIDs for mute/unmute switch and volume control */
12527static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12528 hda_nid_t pin, const char *pfx)
12529{
12530 hda_nid_t nid_v, nid_s;
12531 int err;
12532 char name[32];
12533
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012534 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012535 return 0;
12536
12537 if (alc880_is_fixed_pin(pin)) {
12538 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12539 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012540 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012541 spec->multiout.hp_nid = nid_v;
12542 else
12543 spec->multiout.extra_out_nid[0] = nid_v;
12544 /* control HP volume/switch on the output mixer amp */
12545 nid_v = alc861vd_idx_to_mixer_vol(
12546 alc880_fixed_pin_idx(pin));
12547 nid_s = alc861vd_idx_to_mixer_switch(
12548 alc880_fixed_pin_idx(pin));
12549
12550 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012551 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12552 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12553 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012554 return err;
12555 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012556 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12557 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12558 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012559 return err;
12560 } else if (alc880_is_multi_pin(pin)) {
12561 /* set manual connection */
12562 /* we have only a switch on HP-out PIN */
12563 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012564 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12565 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12566 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012567 return err;
12568 }
12569 return 0;
12570}
12571
12572/* parse the BIOS configuration and set up the alc_spec
12573 * return 1 if successful, 0 if the proper config is not found,
12574 * or a negative error code
12575 * Based on ALC880 version - had to change it to override
12576 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12577static int alc861vd_parse_auto_config(struct hda_codec *codec)
12578{
12579 struct alc_spec *spec = codec->spec;
12580 int err;
12581 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12582
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012583 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12584 alc861vd_ignore);
12585 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012586 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012587 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012588 return 0; /* can't find valid BIOS pin config */
12589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012590 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12591 if (err < 0)
12592 return err;
12593 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12594 if (err < 0)
12595 return err;
12596 err = alc861vd_auto_create_extra_out(spec,
12597 spec->autocfg.speaker_pins[0],
12598 "Speaker");
12599 if (err < 0)
12600 return err;
12601 err = alc861vd_auto_create_extra_out(spec,
12602 spec->autocfg.hp_pins[0],
12603 "Headphone");
12604 if (err < 0)
12605 return err;
12606 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12607 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012608 return err;
12609
12610 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12611
12612 if (spec->autocfg.dig_out_pin)
12613 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12614
12615 if (spec->kctl_alloc)
12616 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12617
12618 spec->init_verbs[spec->num_init_verbs++]
12619 = alc861vd_volume_init_verbs;
12620
12621 spec->num_mux_defs = 1;
12622 spec->input_mux = &spec->private_imux;
12623
Takashi Iwai776e1842007-08-29 15:07:11 +020012624 err = alc_auto_add_mic_boost(codec);
12625 if (err < 0)
12626 return err;
12627
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012628 return 1;
12629}
12630
12631/* additional initialization for auto-configuration model */
12632static void alc861vd_auto_init(struct hda_codec *codec)
12633{
12634 alc861vd_auto_init_multi_out(codec);
12635 alc861vd_auto_init_hp_out(codec);
12636 alc861vd_auto_init_analog_input(codec);
12637}
12638
12639static int patch_alc861vd(struct hda_codec *codec)
12640{
12641 struct alc_spec *spec;
12642 int err, board_config;
12643
12644 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12645 if (spec == NULL)
12646 return -ENOMEM;
12647
12648 codec->spec = spec;
12649
12650 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12651 alc861vd_models,
12652 alc861vd_cfg_tbl);
12653
12654 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12655 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12656 "ALC861VD, trying auto-probe from BIOS...\n");
12657 board_config = ALC861VD_AUTO;
12658 }
12659
12660 if (board_config == ALC861VD_AUTO) {
12661 /* automatic parse from the BIOS config */
12662 err = alc861vd_parse_auto_config(codec);
12663 if (err < 0) {
12664 alc_free(codec);
12665 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012666 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012667 printk(KERN_INFO
12668 "hda_codec: Cannot set up configuration "
12669 "from BIOS. Using base mode...\n");
12670 board_config = ALC861VD_3ST;
12671 }
12672 }
12673
12674 if (board_config != ALC861VD_AUTO)
12675 setup_preset(spec, &alc861vd_presets[board_config]);
12676
12677 spec->stream_name_analog = "ALC861VD Analog";
12678 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12679 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12680
12681 spec->stream_name_digital = "ALC861VD Digital";
12682 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12683 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12684
12685 spec->adc_nids = alc861vd_adc_nids;
12686 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010012687 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012688
12689 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12690 spec->num_mixers++;
12691
Takashi Iwai2134ea42008-01-10 16:53:55 +010012692 spec->vmaster_nid = 0x02;
12693
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012694 codec->patch_ops = alc_patch_ops;
12695
12696 if (board_config == ALC861VD_AUTO)
12697 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012698#ifdef CONFIG_SND_HDA_POWER_SAVE
12699 if (!spec->loopback.amplist)
12700 spec->loopback.amplist = alc861vd_loopbacks;
12701#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012702
12703 return 0;
12704}
12705
12706/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012707 * ALC662 support
12708 *
12709 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12710 * configuration. Each pin widget can choose any input DACs and a mixer.
12711 * Each ADC is connected from a mixer of all inputs. This makes possible
12712 * 6-channel independent captures.
12713 *
12714 * In addition, an independent DAC for the multi-playback (not used in this
12715 * driver yet).
12716 */
12717#define ALC662_DIGOUT_NID 0x06
12718#define ALC662_DIGIN_NID 0x0a
12719
12720static hda_nid_t alc662_dac_nids[4] = {
12721 /* front, rear, clfe, rear_surr */
12722 0x02, 0x03, 0x04
12723};
12724
12725static hda_nid_t alc662_adc_nids[1] = {
12726 /* ADC1-2 */
12727 0x09,
12728};
Takashi Iwaie1406342008-02-11 18:32:32 +010012729
12730static hda_nid_t alc662_capsrc_nids[1] = { 0x23 };
12731
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012732/* input MUX */
12733/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012734static struct hda_input_mux alc662_capture_source = {
12735 .num_items = 4,
12736 .items = {
12737 { "Mic", 0x0 },
12738 { "Front Mic", 0x1 },
12739 { "Line", 0x2 },
12740 { "CD", 0x4 },
12741 },
12742};
12743
12744static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12745 .num_items = 2,
12746 .items = {
12747 { "Mic", 0x1 },
12748 { "Line", 0x2 },
12749 },
12750};
Kailang Yang291702f2007-10-16 14:28:03 +020012751
12752static struct hda_input_mux alc662_eeepc_capture_source = {
12753 .num_items = 2,
12754 .items = {
12755 { "i-Mic", 0x1 },
12756 { "e-Mic", 0x0 },
12757 },
12758};
12759
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012760#define alc662_mux_enum_info alc_mux_enum_info
12761#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012762#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012763
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012764/*
12765 * 2ch mode
12766 */
12767static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12768 { 2, NULL }
12769};
12770
12771/*
12772 * 2ch mode
12773 */
12774static struct hda_verb alc662_3ST_ch2_init[] = {
12775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12779 { } /* end */
12780};
12781
12782/*
12783 * 6ch mode
12784 */
12785static struct hda_verb alc662_3ST_ch6_init[] = {
12786 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12787 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12788 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12789 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12790 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12791 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12792 { } /* end */
12793};
12794
12795static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12796 { 2, alc662_3ST_ch2_init },
12797 { 6, alc662_3ST_ch6_init },
12798};
12799
12800/*
12801 * 2ch mode
12802 */
12803static struct hda_verb alc662_sixstack_ch6_init[] = {
12804 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12805 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12806 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12807 { } /* end */
12808};
12809
12810/*
12811 * 6ch mode
12812 */
12813static struct hda_verb alc662_sixstack_ch8_init[] = {
12814 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12815 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12816 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12817 { } /* end */
12818};
12819
12820static struct hda_channel_mode alc662_5stack_modes[2] = {
12821 { 2, alc662_sixstack_ch6_init },
12822 { 6, alc662_sixstack_ch8_init },
12823};
12824
12825/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12826 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12827 */
12828
12829static struct snd_kcontrol_new alc662_base_mixer[] = {
12830 /* output mixer control */
12831 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12832 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12833 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12834 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12835 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12836 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12837 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12838 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12840
12841 /*Input mixer control */
12842 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12843 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12844 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12845 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12846 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12847 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12848 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12849 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012850 { } /* end */
12851};
12852
12853static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12854 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12855 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12859 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12860 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12863 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12864 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12865 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12866 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012867 { } /* end */
12868};
12869
12870static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12871 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12872 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12873 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12874 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12875 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12876 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12877 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12878 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12882 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12883 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12886 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12888 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12889 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012890 { } /* end */
12891};
12892
12893static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12894 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12895 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012896 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12897 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12899 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12900 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012903 { } /* end */
12904};
12905
Kailang Yang291702f2007-10-16 14:28:03 +020012906static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010012907 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020012908
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010012909 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12910 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020012911
12912 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12913 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12914 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12915
12916 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12917 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12918 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12919 { } /* end */
12920};
12921
Kailang Yang8c427222008-01-10 13:03:59 +010012922static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010012923 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12924 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010012925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12926 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012931 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010012932 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12937 { } /* end */
12938};
12939
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012940static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12941 {
12942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12943 .name = "Channel Mode",
12944 .info = alc_ch_mode_info,
12945 .get = alc_ch_mode_get,
12946 .put = alc_ch_mode_put,
12947 },
12948 { } /* end */
12949};
12950
12951static struct hda_verb alc662_init_verbs[] = {
12952 /* ADC: mute amp left and right */
12953 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12954 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12955 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12956
Takashi Iwaicb53c622007-08-10 17:21:45 +020012957 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12958 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012962
Kailang Yangb60dd392007-09-20 12:50:29 +020012963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12966 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012969
12970 /* Front Pin: output 0 (0x0c) */
12971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12973
12974 /* Rear Pin: output 1 (0x0d) */
12975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12977
12978 /* CLFE Pin: output 2 (0x0e) */
12979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12981
12982 /* Mic (rear) pin: input vref at 80% */
12983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12984 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12985 /* Front Mic pin: input vref at 80% */
12986 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12987 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12988 /* Line In pin: input */
12989 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12990 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12991 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12992 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12994 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12995 /* CD pin widget for input */
12996 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12997
12998 /* FIXME: use matrix-type input source selection */
12999 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13000 /* Input mixer */
13001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013005
13006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013010 { }
13011};
13012
13013static struct hda_verb alc662_sue_init_verbs[] = {
13014 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13015 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013016 {}
13017};
13018
13019static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13020 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13021 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13022 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013023};
13024
Kailang Yang8c427222008-01-10 13:03:59 +010013025/* Set Unsolicited Event*/
13026static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13027 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13028 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13029 {}
13030};
13031
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013032/*
13033 * generic initialization of ADC, input mixers and output mixers
13034 */
13035static struct hda_verb alc662_auto_init_verbs[] = {
13036 /*
13037 * Unmute ADC and set the default input to mic-in
13038 */
13039 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13041
13042 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13043 * mixer widget
13044 * Note: PASD motherboards uses the Line In 2 as the input for front
13045 * panel mic (mic 2)
13046 */
13047 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013053
13054 /*
13055 * Set up output mixers (0x0c - 0x0f)
13056 */
13057 /* set vol=0 to output mixers */
13058 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13059 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13060 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13061
13062 /* set up input amps for analog loopback */
13063 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013064 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13065 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13066 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13067 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13068 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13069 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013070
13071
13072 /* FIXME: use matrix-type input source selection */
13073 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13074 /* Input mixer */
13075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013077 { }
13078};
13079
13080/* capture mixer elements */
13081static struct snd_kcontrol_new alc662_capture_mixer[] = {
13082 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13083 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13084 {
13085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13086 /* The multiple "Capture Source" controls confuse alsamixer
13087 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013088 */
13089 /* .name = "Capture Source", */
13090 .name = "Input Source",
13091 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013092 .info = alc662_mux_enum_info,
13093 .get = alc662_mux_enum_get,
13094 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013095 },
13096 { } /* end */
13097};
13098
13099static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13100{
13101 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013102 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013103
13104 present = snd_hda_codec_read(codec, 0x14, 0,
13105 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013106 bits = present ? HDA_AMP_MUTE : 0;
13107 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13108 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013109}
13110
13111static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13112{
13113 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013114 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013115
13116 present = snd_hda_codec_read(codec, 0x1b, 0,
13117 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013118 bits = present ? HDA_AMP_MUTE : 0;
13119 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13120 HDA_AMP_MUTE, bits);
13121 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13122 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013123}
13124
13125static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13126 unsigned int res)
13127{
13128 if ((res >> 26) == ALC880_HP_EVENT)
13129 alc662_lenovo_101e_all_automute(codec);
13130 if ((res >> 26) == ALC880_FRONT_EVENT)
13131 alc662_lenovo_101e_ispeaker_automute(codec);
13132}
13133
Kailang Yang291702f2007-10-16 14:28:03 +020013134static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13135{
13136 unsigned int present;
13137
13138 present = snd_hda_codec_read(codec, 0x18, 0,
13139 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13140 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13141 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13142 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13143 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13144 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13145 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13146 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13147 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13148}
13149
13150/* unsolicited event for HP jack sensing */
13151static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13152 unsigned int res)
13153{
13154 if ((res >> 26) == ALC880_HP_EVENT)
13155 alc262_hippo1_automute( codec );
13156
13157 if ((res >> 26) == ALC880_MIC_EVENT)
13158 alc662_eeepc_mic_automute(codec);
13159}
13160
13161static void alc662_eeepc_inithook(struct hda_codec *codec)
13162{
13163 alc262_hippo1_automute( codec );
13164 alc662_eeepc_mic_automute(codec);
13165}
13166
Kailang Yang8c427222008-01-10 13:03:59 +010013167static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13168{
13169 unsigned int mute;
13170 unsigned int present;
13171
13172 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13173 present = snd_hda_codec_read(codec, 0x14, 0,
13174 AC_VERB_GET_PIN_SENSE, 0);
13175 present = (present & 0x80000000) != 0;
13176 if (present) {
13177 /* mute internal speaker */
13178 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13179 HDA_AMP_MUTE, HDA_AMP_MUTE);
13180 } else {
13181 /* unmute internal speaker if necessary */
13182 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13183 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13184 HDA_AMP_MUTE, mute);
13185 }
13186}
13187
13188/* unsolicited event for HP jack sensing */
13189static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13190 unsigned int res)
13191{
13192 if ((res >> 26) == ALC880_HP_EVENT)
13193 alc662_eeepc_ep20_automute(codec);
13194}
13195
13196static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13197{
13198 alc662_eeepc_ep20_automute(codec);
13199}
13200
Takashi Iwaicb53c622007-08-10 17:21:45 +020013201#ifdef CONFIG_SND_HDA_POWER_SAVE
13202#define alc662_loopbacks alc880_loopbacks
13203#endif
13204
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013205
13206/* pcm configuration: identiacal with ALC880 */
13207#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13208#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13209#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13210#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13211
13212/*
13213 * configuration and preset
13214 */
13215static const char *alc662_models[ALC662_MODEL_LAST] = {
13216 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13217 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13218 [ALC662_3ST_6ch] = "3stack-6ch",
13219 [ALC662_5ST_DIG] = "6stack-dig",
13220 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013221 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013222 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013223 [ALC662_AUTO] = "auto",
13224};
13225
13226static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013227 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013228 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013229 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013230 {}
13231};
13232
13233static struct alc_config_preset alc662_presets[] = {
13234 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013235 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013236 .init_verbs = { alc662_init_verbs },
13237 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13238 .dac_nids = alc662_dac_nids,
13239 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013240 .dig_in_nid = ALC662_DIGIN_NID,
13241 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13242 .channel_mode = alc662_3ST_2ch_modes,
13243 .input_mux = &alc662_capture_source,
13244 },
13245 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013246 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13247 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013248 .init_verbs = { alc662_init_verbs },
13249 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13250 .dac_nids = alc662_dac_nids,
13251 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013252 .dig_in_nid = ALC662_DIGIN_NID,
13253 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13254 .channel_mode = alc662_3ST_6ch_modes,
13255 .need_dac_fix = 1,
13256 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013257 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013258 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013259 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13260 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013261 .init_verbs = { alc662_init_verbs },
13262 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13263 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013264 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13265 .channel_mode = alc662_3ST_6ch_modes,
13266 .need_dac_fix = 1,
13267 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013268 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013269 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013270 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13271 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013272 .init_verbs = { alc662_init_verbs },
13273 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13274 .dac_nids = alc662_dac_nids,
13275 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013276 .dig_in_nid = ALC662_DIGIN_NID,
13277 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13278 .channel_mode = alc662_5stack_modes,
13279 .input_mux = &alc662_capture_source,
13280 },
13281 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013282 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013283 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13284 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13285 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013286 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13287 .channel_mode = alc662_3ST_2ch_modes,
13288 .input_mux = &alc662_lenovo_101e_capture_source,
13289 .unsol_event = alc662_lenovo_101e_unsol_event,
13290 .init_hook = alc662_lenovo_101e_all_automute,
13291 },
Kailang Yang291702f2007-10-16 14:28:03 +020013292 [ALC662_ASUS_EEEPC_P701] = {
13293 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13294 .init_verbs = { alc662_init_verbs,
13295 alc662_eeepc_sue_init_verbs },
13296 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13297 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020013298 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13299 .channel_mode = alc662_3ST_2ch_modes,
13300 .input_mux = &alc662_eeepc_capture_source,
13301 .unsol_event = alc662_eeepc_unsol_event,
13302 .init_hook = alc662_eeepc_inithook,
13303 },
Kailang Yang8c427222008-01-10 13:03:59 +010013304 [ALC662_ASUS_EEEPC_EP20] = {
13305 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13306 alc662_chmode_mixer },
13307 .init_verbs = { alc662_init_verbs,
13308 alc662_eeepc_ep20_sue_init_verbs },
13309 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13310 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010013311 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13312 .channel_mode = alc662_3ST_6ch_modes,
13313 .input_mux = &alc662_lenovo_101e_capture_source,
13314 .unsol_event = alc662_eeepc_ep20_unsol_event,
13315 .init_hook = alc662_eeepc_ep20_inithook,
13316 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013317
13318};
13319
13320
13321/*
13322 * BIOS auto configuration
13323 */
13324
13325/* add playback controls from the parsed DAC table */
13326static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13327 const struct auto_pin_cfg *cfg)
13328{
13329 char name[32];
13330 static const char *chname[4] = {
13331 "Front", "Surround", NULL /*CLFE*/, "Side"
13332 };
13333 hda_nid_t nid;
13334 int i, err;
13335
13336 for (i = 0; i < cfg->line_outs; i++) {
13337 if (!spec->multiout.dac_nids[i])
13338 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013339 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013340 if (i == 2) {
13341 /* Center/LFE */
13342 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13343 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013344 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13345 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013346 if (err < 0)
13347 return err;
13348 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13349 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013350 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13351 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013352 if (err < 0)
13353 return err;
13354 err = add_control(spec, ALC_CTL_BIND_MUTE,
13355 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013356 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13357 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013358 if (err < 0)
13359 return err;
13360 err = add_control(spec, ALC_CTL_BIND_MUTE,
13361 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013362 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13363 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013364 if (err < 0)
13365 return err;
13366 } else {
13367 sprintf(name, "%s Playback Volume", chname[i]);
13368 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013369 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13370 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013371 if (err < 0)
13372 return err;
13373 sprintf(name, "%s Playback Switch", chname[i]);
13374 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013375 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13376 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013377 if (err < 0)
13378 return err;
13379 }
13380 }
13381 return 0;
13382}
13383
13384/* add playback controls for speaker and HP outputs */
13385static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13386 const char *pfx)
13387{
13388 hda_nid_t nid;
13389 int err;
13390 char name[32];
13391
13392 if (!pin)
13393 return 0;
13394
13395 if (alc880_is_fixed_pin(pin)) {
13396 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13397 /* printk("DAC nid=%x\n",nid); */
13398 /* specify the DAC as the extra output */
13399 if (!spec->multiout.hp_nid)
13400 spec->multiout.hp_nid = nid;
13401 else
13402 spec->multiout.extra_out_nid[0] = nid;
13403 /* control HP volume/switch on the output mixer amp */
13404 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13405 sprintf(name, "%s Playback Volume", pfx);
13406 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13407 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13408 if (err < 0)
13409 return err;
13410 sprintf(name, "%s Playback Switch", pfx);
13411 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13412 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13413 if (err < 0)
13414 return err;
13415 } else if (alc880_is_multi_pin(pin)) {
13416 /* set manual connection */
13417 /* we have only a switch on HP-out PIN */
13418 sprintf(name, "%s Playback Switch", pfx);
13419 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13420 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13421 if (err < 0)
13422 return err;
13423 }
13424 return 0;
13425}
13426
13427/* create playback/capture controls for input pins */
13428static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13429 const struct auto_pin_cfg *cfg)
13430{
13431 struct hda_input_mux *imux = &spec->private_imux;
13432 int i, err, idx;
13433
13434 for (i = 0; i < AUTO_PIN_LAST; i++) {
13435 if (alc880_is_input_pin(cfg->input_pins[i])) {
13436 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13437 err = new_analog_input(spec, cfg->input_pins[i],
13438 auto_pin_cfg_labels[i],
13439 idx, 0x0b);
13440 if (err < 0)
13441 return err;
13442 imux->items[imux->num_items].label =
13443 auto_pin_cfg_labels[i];
13444 imux->items[imux->num_items].index =
13445 alc880_input_pin_idx(cfg->input_pins[i]);
13446 imux->num_items++;
13447 }
13448 }
13449 return 0;
13450}
13451
13452static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13453 hda_nid_t nid, int pin_type,
13454 int dac_idx)
13455{
13456 /* set as output */
13457 snd_hda_codec_write(codec, nid, 0,
13458 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13459 snd_hda_codec_write(codec, nid, 0,
13460 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13461 /* need the manual connection? */
13462 if (alc880_is_multi_pin(nid)) {
13463 struct alc_spec *spec = codec->spec;
13464 int idx = alc880_multi_pin_idx(nid);
13465 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13466 AC_VERB_SET_CONNECT_SEL,
13467 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13468 }
13469}
13470
13471static void alc662_auto_init_multi_out(struct hda_codec *codec)
13472{
13473 struct alc_spec *spec = codec->spec;
13474 int i;
13475
Kailang Yang8c427222008-01-10 13:03:59 +010013476 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013477 for (i = 0; i <= HDA_SIDE; i++) {
13478 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013479 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013480 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013481 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013482 i);
13483 }
13484}
13485
13486static void alc662_auto_init_hp_out(struct hda_codec *codec)
13487{
13488 struct alc_spec *spec = codec->spec;
13489 hda_nid_t pin;
13490
13491 pin = spec->autocfg.hp_pins[0];
13492 if (pin) /* connect to front */
13493 /* use dac 0 */
13494 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13495}
13496
13497#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13498#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13499
13500static void alc662_auto_init_analog_input(struct hda_codec *codec)
13501{
13502 struct alc_spec *spec = codec->spec;
13503 int i;
13504
13505 for (i = 0; i < AUTO_PIN_LAST; i++) {
13506 hda_nid_t nid = spec->autocfg.input_pins[i];
13507 if (alc662_is_input_pin(nid)) {
13508 snd_hda_codec_write(codec, nid, 0,
13509 AC_VERB_SET_PIN_WIDGET_CONTROL,
13510 (i <= AUTO_PIN_FRONT_MIC ?
13511 PIN_VREF80 : PIN_IN));
13512 if (nid != ALC662_PIN_CD_NID)
13513 snd_hda_codec_write(codec, nid, 0,
13514 AC_VERB_SET_AMP_GAIN_MUTE,
13515 AMP_OUT_MUTE);
13516 }
13517 }
13518}
13519
13520static int alc662_parse_auto_config(struct hda_codec *codec)
13521{
13522 struct alc_spec *spec = codec->spec;
13523 int err;
13524 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13525
13526 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13527 alc662_ignore);
13528 if (err < 0)
13529 return err;
13530 if (!spec->autocfg.line_outs)
13531 return 0; /* can't find valid BIOS pin config */
13532
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013533 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13534 if (err < 0)
13535 return err;
13536 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13537 if (err < 0)
13538 return err;
13539 err = alc662_auto_create_extra_out(spec,
13540 spec->autocfg.speaker_pins[0],
13541 "Speaker");
13542 if (err < 0)
13543 return err;
13544 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13545 "Headphone");
13546 if (err < 0)
13547 return err;
13548 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13549 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013550 return err;
13551
13552 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13553
13554 if (spec->autocfg.dig_out_pin)
13555 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13556
13557 if (spec->kctl_alloc)
13558 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13559
13560 spec->num_mux_defs = 1;
13561 spec->input_mux = &spec->private_imux;
13562
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013563 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013564 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13565 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013566 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013567}
13568
13569/* additional initialization for auto-configuration model */
13570static void alc662_auto_init(struct hda_codec *codec)
13571{
13572 alc662_auto_init_multi_out(codec);
13573 alc662_auto_init_hp_out(codec);
13574 alc662_auto_init_analog_input(codec);
13575}
13576
13577static int patch_alc662(struct hda_codec *codec)
13578{
13579 struct alc_spec *spec;
13580 int err, board_config;
13581
13582 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13583 if (!spec)
13584 return -ENOMEM;
13585
13586 codec->spec = spec;
13587
13588 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13589 alc662_models,
13590 alc662_cfg_tbl);
13591 if (board_config < 0) {
13592 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13593 "trying auto-probe from BIOS...\n");
13594 board_config = ALC662_AUTO;
13595 }
13596
13597 if (board_config == ALC662_AUTO) {
13598 /* automatic parse from the BIOS config */
13599 err = alc662_parse_auto_config(codec);
13600 if (err < 0) {
13601 alc_free(codec);
13602 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013603 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013604 printk(KERN_INFO
13605 "hda_codec: Cannot set up configuration "
13606 "from BIOS. Using base mode...\n");
13607 board_config = ALC662_3ST_2ch_DIG;
13608 }
13609 }
13610
13611 if (board_config != ALC662_AUTO)
13612 setup_preset(spec, &alc662_presets[board_config]);
13613
13614 spec->stream_name_analog = "ALC662 Analog";
13615 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13616 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13617
13618 spec->stream_name_digital = "ALC662 Digital";
13619 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13620 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13621
Takashi Iwaie1406342008-02-11 18:32:32 +010013622 spec->adc_nids = alc662_adc_nids;
13623 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13624 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013625
Takashi Iwai2134ea42008-01-10 16:53:55 +010013626 spec->vmaster_nid = 0x02;
13627
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013628 codec->patch_ops = alc_patch_ops;
13629 if (board_config == ALC662_AUTO)
13630 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013631#ifdef CONFIG_SND_HDA_POWER_SAVE
13632 if (!spec->loopback.amplist)
13633 spec->loopback.amplist = alc662_loopbacks;
13634#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013635
13636 return 0;
13637}
13638
13639/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013640 * patch entries
13641 */
13642struct hda_codec_preset snd_hda_preset_realtek[] = {
13643 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013645 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013646 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013647 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013648 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013649 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013650 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13651 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13652 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013653 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13654 .patch = patch_alc883 },
13655 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13656 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013657 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013658 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013659 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013660 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013661 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013662 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013663 {} /* terminator */
13664};