blob: 3b34bb6779630f1f4f634e149ff47ace3d1e3d59 [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,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100109#ifdef CONFIG_SND_DEBUG
110 ALC268_TEST,
111#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200112 ALC268_AUTO,
113 ALC268_MODEL_LAST /* last tag */
114};
115
Kailang Yangf6a92242007-12-13 16:52:54 +0100116/* ALC269 models */
117enum {
118 ALC269_BASIC,
119 ALC269_AUTO,
120 ALC269_MODEL_LAST /* last tag */
121};
122
Kailang Yangdf694da2005-12-05 19:42:22 +0100123/* ALC861 models */
124enum {
125 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200126 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100127 ALC861_3ST_DIG,
128 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200129 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200130 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200131 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100132 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100133 ALC861_AUTO,
134 ALC861_MODEL_LAST,
135};
136
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100137/* ALC861-VD models */
138enum {
139 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200140 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100141 ALC861VD_3ST,
142 ALC861VD_3ST_DIG,
143 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200144 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200145 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200146 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100147 ALC861VD_AUTO,
148 ALC861VD_MODEL_LAST,
149};
150
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200151/* ALC662 models */
152enum {
153 ALC662_3ST_2ch_DIG,
154 ALC662_3ST_6ch_DIG,
155 ALC662_3ST_6ch,
156 ALC662_5ST_DIG,
157 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200158 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100159 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200160 ALC662_AUTO,
161 ALC662_MODEL_LAST,
162};
163
Kailang Yangdf694da2005-12-05 19:42:22 +0100164/* ALC882 models */
165enum {
166 ALC882_3ST_DIG,
167 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200168 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200169 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200170 ALC882_TARGA,
171 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200172 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100173 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200174 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200175 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200176 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100177 ALC882_MODEL_LAST,
178};
179
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200180/* ALC883 models */
181enum {
182 ALC883_3ST_2ch_DIG,
183 ALC883_3ST_6ch_DIG,
184 ALC883_3ST_6ch,
185 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200186 ALC883_TARGA_DIG,
187 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200188 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200189 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200190 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200191 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100192 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200193 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200194 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200195 ALC888_LENOVO_MS7195_DIG,
196 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200197 ALC888_6ST_HP,
198 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100199 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100200 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200201 ALC883_AUTO,
202 ALC883_MODEL_LAST,
203};
204
Kailang Yangdf694da2005-12-05 19:42:22 +0100205/* for GPIO Poll */
206#define GPIO_MASK 0x03
207
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208struct alc_spec {
209 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100210 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 unsigned int num_mixers;
212
Kailang Yangdf694da2005-12-05 19:42:22 +0100213 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200214 * don't forget NULL
215 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200216 */
217 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Takashi Iwai16ded522005-06-10 19:58:24 +0200219 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 struct hda_pcm_stream *stream_analog_playback;
221 struct hda_pcm_stream *stream_analog_capture;
222
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200223 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 struct hda_pcm_stream *stream_digital_playback;
225 struct hda_pcm_stream *stream_digital_capture;
226
227 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200228 struct hda_multi_out multiout; /* playback set-up
229 * max_channels, dacs must be set
230 * dig_out_nid and hp_nid are optional
231 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
233 /* capture */
234 unsigned int num_adc_nids;
235 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200236 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200239 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 const struct hda_input_mux *input_mux;
241 unsigned int cur_mux[3];
242
243 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100244 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200246 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
248 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100249 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200250
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200251 /* dynamic controls, init_verbs and input_mux */
252 struct auto_pin_cfg autocfg;
253 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100254 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200255 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200256 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100257
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100258 /* hooks */
259 void (*init_hook)(struct hda_codec *codec);
260 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
261
Takashi Iwai834be882006-03-01 14:16:17 +0100262 /* for pin sensing */
263 unsigned int sense_updated: 1;
264 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200265
Takashi Iwai2134ea42008-01-10 16:53:55 +0100266 /* for virtual master */
267 hda_nid_t vmaster_nid;
268 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200269#ifdef CONFIG_SND_HDA_POWER_SAVE
270 struct hda_loopback_check loopback;
271#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100272};
273
274/*
275 * configuration template - to be copied to the spec instance
276 */
277struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200278 struct snd_kcontrol_new *mixers[5]; /* should be identical size
279 * with spec
280 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100281 const struct hda_verb *init_verbs[5];
282 unsigned int num_dacs;
283 hda_nid_t *dac_nids;
284 hda_nid_t dig_out_nid; /* optional */
285 hda_nid_t hp_nid; /* optional */
286 unsigned int num_adc_nids;
287 hda_nid_t *adc_nids;
288 hda_nid_t dig_in_nid;
289 unsigned int num_channel_mode;
290 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200291 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200292 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100293 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100294 void (*unsol_event)(struct hda_codec *, unsigned int);
295 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200296#ifdef CONFIG_SND_HDA_POWER_SAVE
297 struct hda_amp_list *loopbacks;
298#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299};
300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
302/*
303 * input MUX handling
304 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200305static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307{
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
309 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200310 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
311 if (mux_idx >= spec->num_mux_defs)
312 mux_idx = 0;
313 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314}
315
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200316static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
317 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318{
319 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
320 struct alc_spec *spec = codec->spec;
321 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
322
323 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
324 return 0;
325}
326
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200327static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
331 struct alc_spec *spec = codec->spec;
332 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200333 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
334 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200335 spec->adc_nids[adc_idx],
336 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337}
338
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200339
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340/*
341 * channel mode setting
342 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100348 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
349 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350}
351
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
353 struct snd_ctl_elem_value *ucontrol)
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_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200358 spec->num_channel_mode,
359 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360}
361
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200362static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
366 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200367 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
368 spec->num_channel_mode,
369 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200370 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200371 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
372 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373}
374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100376 * Control the mode of pin widget settings via the mixer. "pc" is used
377 * instead of "%" to avoid consequences of accidently treating the % as
378 * being part of a format specifier. Maximum allowed length of a value is
379 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100380 *
381 * Note: some retasking pin complexes seem to ignore requests for input
382 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
383 * are requested. Therefore order this list so that this behaviour will not
384 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200385 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
386 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200387 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100388static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100389 "Mic 50pc bias", "Mic 80pc bias",
390 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100391};
392static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100393 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100394};
395/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200396 * in the pin being assumed to be exclusively an input or an output pin. In
397 * addition, "input" pins may or may not process the mic bias option
398 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
399 * accept requests for bias as of chip versions up to March 2006) and/or
400 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100401 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200402#define ALC_PIN_DIR_IN 0x00
403#define ALC_PIN_DIR_OUT 0x01
404#define ALC_PIN_DIR_INOUT 0x02
405#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
406#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200408/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100409 * For each direction the minimum and maximum values are given.
410 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412 { 0, 2 }, /* ALC_PIN_DIR_IN */
413 { 3, 4 }, /* ALC_PIN_DIR_OUT */
414 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200415 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
416 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417};
418#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
419#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
420#define alc_pin_mode_n_items(_dir) \
421 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
422
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200423static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
424 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200425{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426 unsigned int item_num = uinfo->value.enumerated.item;
427 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
428
429 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200430 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100431 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
432
433 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
434 item_num = alc_pin_mode_min(dir);
435 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200436 return 0;
437}
438
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200441{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100442 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100445 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200446 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
448 AC_VERB_GET_PIN_WIDGET_CONTROL,
449 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200450
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 /* Find enumerated value for current pinctl setting */
452 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100454 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 return 0;
457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100461{
462 signed int change;
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 hda_nid_t nid = kcontrol->private_value & 0xffff;
465 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
466 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
468 AC_VERB_GET_PIN_WIDGET_CONTROL,
469 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200471 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472 val = alc_pin_mode_min(dir);
473
474 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100475 if (change) {
476 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200477 snd_hda_codec_write_cache(codec, nid, 0,
478 AC_VERB_SET_PIN_WIDGET_CONTROL,
479 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100480
481 /* Also enable the retasking pin's input/output as required
482 * for the requested pin mode. Enum values of 2 or less are
483 * input modes.
484 *
485 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200486 * reduces noise slightly (particularly on input) so we'll
487 * do it. However, having both input and output buffers
488 * enabled simultaneously doesn't seem to be problematic if
489 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100490 */
491 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200492 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
493 HDA_AMP_MUTE, HDA_AMP_MUTE);
494 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
495 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100496 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200497 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
498 HDA_AMP_MUTE, HDA_AMP_MUTE);
499 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
500 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100501 }
502 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200503 return change;
504}
505
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200507 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508 .info = alc_pin_mode_info, \
509 .get = alc_pin_mode_get, \
510 .put = alc_pin_mode_put, \
511 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100512
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100513/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
514 * together using a mask with more than one bit set. This control is
515 * currently used only by the ALC260 test model. At this stage they are not
516 * needed for any "production" models.
517 */
518#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200519#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200520
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200521static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
522 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100523{
524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
525 hda_nid_t nid = kcontrol->private_value & 0xffff;
526 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
527 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528 unsigned int val = snd_hda_codec_read(codec, nid, 0,
529 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100530
531 *valp = (val & mask) != 0;
532 return 0;
533}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100536{
537 signed int change;
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 hda_nid_t nid = kcontrol->private_value & 0xffff;
540 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
541 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
543 AC_VERB_GET_GPIO_DATA,
544 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100545
546 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
548 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100549 gpio_data &= ~mask;
550 else
551 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200552 snd_hda_codec_write_cache(codec, nid, 0,
553 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100554
555 return change;
556}
557#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
558 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
559 .info = alc_gpio_data_info, \
560 .get = alc_gpio_data_get, \
561 .put = alc_gpio_data_put, \
562 .private_value = nid | (mask<<16) }
563#endif /* CONFIG_SND_DEBUG */
564
Jonathan Woithe92621f12006-02-28 11:47:47 +0100565/* A switch control to allow the enabling of the digital IO pins on the
566 * ALC260. This is incredibly simplistic; the intention of this control is
567 * to provide something in the test model allowing digital outputs to be
568 * identified if present. If models are found which can utilise these
569 * outputs a more complete mixer control can be devised for those models if
570 * necessary.
571 */
572#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200573#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200574
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100577{
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 hda_nid_t nid = kcontrol->private_value & 0xffff;
580 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
581 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200582 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100583 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100584
585 *valp = (val & mask) != 0;
586 return 0;
587}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100590{
591 signed int change;
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 hda_nid_t nid = kcontrol->private_value & 0xffff;
594 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
595 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100597 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100599
600 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200601 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100602 if (val==0)
603 ctrl_data &= ~mask;
604 else
605 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200606 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
607 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100608
609 return change;
610}
611#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
612 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
613 .info = alc_spdif_ctrl_info, \
614 .get = alc_spdif_ctrl_get, \
615 .put = alc_spdif_ctrl_put, \
616 .private_value = nid | (mask<<16) }
617#endif /* CONFIG_SND_DEBUG */
618
Jonathan Woithef8225f62008-01-08 12:16:54 +0100619/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
620 * Again, this is only used in the ALC26x test models to help identify when
621 * the EAPD line must be asserted for features to work.
622 */
623#ifdef CONFIG_SND_DEBUG
624#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
625
626static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long *valp = ucontrol->value.integer.value;
633 unsigned int val = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
635
636 *valp = (val & mask) != 0;
637 return 0;
638}
639
640static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 int change;
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 hda_nid_t nid = kcontrol->private_value & 0xffff;
646 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
647 long val = *ucontrol->value.integer.value;
648 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
649 AC_VERB_GET_EAPD_BTLENABLE,
650 0x00);
651
652 /* Set/unset the masked control bit(s) as needed */
653 change = (!val ? 0 : mask) != (ctrl_data & mask);
654 if (!val)
655 ctrl_data &= ~mask;
656 else
657 ctrl_data |= mask;
658 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
659 ctrl_data);
660
661 return change;
662}
663
664#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
665 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
666 .info = alc_eapd_ctrl_info, \
667 .get = alc_eapd_ctrl_get, \
668 .put = alc_eapd_ctrl_put, \
669 .private_value = nid | (mask<<16) }
670#endif /* CONFIG_SND_DEBUG */
671
Kailang Yangdf694da2005-12-05 19:42:22 +0100672/*
673 * set up from the preset table
674 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200675static void setup_preset(struct alc_spec *spec,
676 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100677{
678 int i;
679
680 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
681 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200682 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
683 i++)
684 spec->init_verbs[spec->num_init_verbs++] =
685 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100686
687 spec->channel_mode = preset->channel_mode;
688 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200689 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100690
691 spec->multiout.max_channels = spec->channel_mode[0].channels;
692
693 spec->multiout.num_dacs = preset->num_dacs;
694 spec->multiout.dac_nids = preset->dac_nids;
695 spec->multiout.dig_out_nid = preset->dig_out_nid;
696 spec->multiout.hp_nid = preset->hp_nid;
697
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200698 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200699 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200700 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100701 spec->input_mux = preset->input_mux;
702
703 spec->num_adc_nids = preset->num_adc_nids;
704 spec->adc_nids = preset->adc_nids;
705 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100706
707 spec->unsol_event = preset->unsol_event;
708 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200709#ifdef CONFIG_SND_HDA_POWER_SAVE
710 spec->loopback.amplist = preset->loopbacks;
711#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100712}
713
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200714/* Enable GPIO mask and set output */
715static struct hda_verb alc_gpio1_init_verbs[] = {
716 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
717 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
718 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
719 { }
720};
721
722static struct hda_verb alc_gpio2_init_verbs[] = {
723 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
724 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
725 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
726 { }
727};
728
Kailang Yangbdd148a2007-05-08 15:19:08 +0200729static struct hda_verb alc_gpio3_init_verbs[] = {
730 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
731 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
732 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
733 { }
734};
735
Kailang Yangc9b58002007-10-16 14:30:01 +0200736static void alc_sku_automute(struct hda_codec *codec)
737{
738 struct alc_spec *spec = codec->spec;
739 unsigned int mute;
740 unsigned int present;
741 unsigned int hp_nid = spec->autocfg.hp_pins[0];
742 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
743
744 /* need to execute and sync at first */
745 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
746 present = snd_hda_codec_read(codec, hp_nid, 0,
747 AC_VERB_GET_PIN_SENSE, 0);
748 spec->jack_present = (present & 0x80000000) != 0;
749 if (spec->jack_present) {
750 /* mute internal speaker */
751 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
752 HDA_AMP_MUTE, HDA_AMP_MUTE);
753 } else {
754 /* unmute internal speaker if necessary */
755 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
756 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
757 HDA_AMP_MUTE, mute);
758 }
759}
760
761/* unsolicited event for HP jack sensing */
762static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
763{
764 if (codec->vendor_id == 0x10ec0880)
765 res >>= 28;
766 else
767 res >>= 26;
768 if (res != ALC880_HP_EVENT)
769 return;
770
771 alc_sku_automute(codec);
772}
773
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200774/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
775 * 31 ~ 16 : Manufacture ID
776 * 15 ~ 8 : SKU ID
777 * 7 ~ 0 : Assembly ID
778 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
779 */
780static void alc_subsystem_id(struct hda_codec *codec,
781 unsigned int porta, unsigned int porte,
782 unsigned int portd)
783{
Kailang Yangc9b58002007-10-16 14:30:01 +0200784 unsigned int ass, tmp, i;
785 unsigned nid;
786 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200787
Kailang Yangc9b58002007-10-16 14:30:01 +0200788 ass = codec->subsystem_id & 0xffff;
789 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
790 goto do_sku;
791
792 /*
793 * 31~30 : port conetcivity
794 * 29~21 : reserve
795 * 20 : PCBEEP input
796 * 19~16 : Check sum (15:1)
797 * 15~1 : Custom
798 * 0 : override
799 */
800 nid = 0x1d;
801 if (codec->vendor_id == 0x10ec0260)
802 nid = 0x17;
803 ass = snd_hda_codec_read(codec, nid, 0,
804 AC_VERB_GET_CONFIG_DEFAULT, 0);
805 if (!(ass & 1) && !(ass & 0x100000))
806 return;
807 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200808 return;
809
Kailang Yangc9b58002007-10-16 14:30:01 +0200810 /* check sum */
811 tmp = 0;
812 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100813 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200814 tmp++;
815 }
816 if (((ass >> 16) & 0xf) != tmp)
817 return;
818do_sku:
819 /*
820 * 0 : override
821 * 1 : Swap Jack
822 * 2 : 0 --> Desktop, 1 --> Laptop
823 * 3~5 : External Amplifier control
824 * 7~6 : Reserved
825 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200826 tmp = (ass & 0x38) >> 3; /* external Amp control */
827 switch (tmp) {
828 case 1:
829 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
830 break;
831 case 3:
832 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
833 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200834 case 7:
835 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
836 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200837 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200838 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200839 case 0x10ec0260:
840 snd_hda_codec_write(codec, 0x0f, 0,
841 AC_VERB_SET_EAPD_BTLENABLE, 2);
842 snd_hda_codec_write(codec, 0x10, 0,
843 AC_VERB_SET_EAPD_BTLENABLE, 2);
844 break;
845 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200846 case 0x10ec0267:
847 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200848 case 0x10ec0269:
849 case 0x10ec0862:
850 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200851 snd_hda_codec_write(codec, 0x14, 0,
852 AC_VERB_SET_EAPD_BTLENABLE, 2);
853 snd_hda_codec_write(codec, 0x15, 0,
854 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200855 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200856 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200857 switch (codec->vendor_id) {
858 case 0x10ec0260:
859 snd_hda_codec_write(codec, 0x1a, 0,
860 AC_VERB_SET_COEF_INDEX, 7);
861 tmp = snd_hda_codec_read(codec, 0x1a, 0,
862 AC_VERB_GET_PROC_COEF, 0);
863 snd_hda_codec_write(codec, 0x1a, 0,
864 AC_VERB_SET_COEF_INDEX, 7);
865 snd_hda_codec_write(codec, 0x1a, 0,
866 AC_VERB_SET_PROC_COEF,
867 tmp | 0x2010);
868 break;
869 case 0x10ec0262:
870 case 0x10ec0880:
871 case 0x10ec0882:
872 case 0x10ec0883:
873 case 0x10ec0885:
874 case 0x10ec0888:
875 snd_hda_codec_write(codec, 0x20, 0,
876 AC_VERB_SET_COEF_INDEX, 7);
877 tmp = snd_hda_codec_read(codec, 0x20, 0,
878 AC_VERB_GET_PROC_COEF, 0);
879 snd_hda_codec_write(codec, 0x20, 0,
880 AC_VERB_SET_COEF_INDEX, 7);
881 snd_hda_codec_write(codec, 0x20, 0,
882 AC_VERB_SET_PROC_COEF,
883 tmp | 0x2010);
884 break;
885 case 0x10ec0267:
886 case 0x10ec0268:
887 snd_hda_codec_write(codec, 0x20, 0,
888 AC_VERB_SET_COEF_INDEX, 7);
889 tmp = snd_hda_codec_read(codec, 0x20, 0,
890 AC_VERB_GET_PROC_COEF, 0);
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_COEF_INDEX, 7);
893 snd_hda_codec_write(codec, 0x20, 0,
894 AC_VERB_SET_PROC_COEF,
895 tmp | 0x3000);
896 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200897 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200898 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200899 break;
900 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200901
Kailang Yang8c427222008-01-10 13:03:59 +0100902 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200903 * when the external headphone out jack is plugged"
904 */
Kailang Yang8c427222008-01-10 13:03:59 +0100905 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200906 return;
907 /*
908 * 10~8 : Jack location
909 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
910 * 14~13: Resvered
911 * 15 : 1 --> enable the function "Mute internal speaker
912 * when the external headphone out jack is plugged"
913 */
914 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100915 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200916 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100917 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200918 else
919 return;
920 }
921
922 if (!spec->autocfg.hp_pins[0]) {
923 tmp = (ass >> 11) & 0x3; /* HP to chassis */
924 if (tmp == 0)
925 spec->autocfg.hp_pins[0] = porta;
926 else if (tmp == 1)
927 spec->autocfg.hp_pins[0] = porte;
928 else if (tmp == 2)
929 spec->autocfg.hp_pins[0] = portd;
930 else
931 return;
932 }
933
934 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
935 AC_VERB_SET_UNSOLICITED_ENABLE,
936 AC_USRSP_EN | ALC880_HP_EVENT);
937 spec->unsol_event = alc_sku_unsol_event;
938 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200939}
940
Takashi Iwai41e41f12005-06-08 14:48:49 +0200941/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200942 * Fix-up pin default configurations
943 */
944
945struct alc_pincfg {
946 hda_nid_t nid;
947 u32 val;
948};
949
950static void alc_fix_pincfg(struct hda_codec *codec,
951 const struct snd_pci_quirk *quirk,
952 const struct alc_pincfg **pinfix)
953{
954 const struct alc_pincfg *cfg;
955
956 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
957 if (!quirk)
958 return;
959
960 cfg = pinfix[quirk->value];
961 for (; cfg->nid; cfg++) {
962 int i;
963 u32 val = cfg->val;
964 for (i = 0; i < 4; i++) {
965 snd_hda_codec_write(codec, cfg->nid, 0,
966 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
967 val & 0xff);
968 val >>= 8;
969 }
970 }
971}
972
973/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200974 * ALC880 3-stack model
975 *
976 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200977 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
978 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 */
980
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200981static hda_nid_t alc880_dac_nids[4] = {
982 /* front, rear, clfe, rear_surr */
983 0x02, 0x05, 0x04, 0x03
984};
985
986static hda_nid_t alc880_adc_nids[3] = {
987 /* ADC0-2 */
988 0x07, 0x08, 0x09,
989};
990
991/* The datasheet says the node 0x07 is connected from inputs,
992 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100993 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200995static hda_nid_t alc880_adc_nids_alt[2] = {
996 /* ADC1-2 */
997 0x08, 0x09,
998};
999
1000#define ALC880_DIGOUT_NID 0x06
1001#define ALC880_DIGIN_NID 0x0a
1002
1003static struct hda_input_mux alc880_capture_source = {
1004 .num_items = 4,
1005 .items = {
1006 { "Mic", 0x0 },
1007 { "Front Mic", 0x3 },
1008 { "Line", 0x2 },
1009 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001011};
1012
1013/* channel source setting (2/6 channel selection for 3-stack) */
1014/* 2ch mode */
1015static struct hda_verb alc880_threestack_ch2_init[] = {
1016 /* set line-in to input, mute it */
1017 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1018 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1019 /* set mic-in to input vref 80%, mute it */
1020 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1021 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022 { } /* end */
1023};
1024
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001025/* 6ch mode */
1026static struct hda_verb alc880_threestack_ch6_init[] = {
1027 /* set line-in to output, unmute it */
1028 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1029 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1030 /* set mic-in to output, unmute it */
1031 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1032 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1033 { } /* end */
1034};
1035
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001036static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037 { 2, alc880_threestack_ch2_init },
1038 { 6, alc880_threestack_ch6_init },
1039};
1040
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001041static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001045 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001046 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001048 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1049 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1052 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1053 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1056 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1058 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1059 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 {
1062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1063 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001064 .info = alc_ch_mode_info,
1065 .get = alc_ch_mode_get,
1066 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067 },
1068 { } /* end */
1069};
1070
1071/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001072static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1074 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1077 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1078 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1079 {
1080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1081 /* The multiple "Capture Source" controls confuse alsamixer
1082 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001083 */
1084 /* .name = "Capture Source", */
1085 .name = "Input Source",
1086 .count = 3,
1087 .info = alc_mux_enum_info,
1088 .get = alc_mux_enum_get,
1089 .put = alc_mux_enum_put,
1090 },
1091 { } /* end */
1092};
1093
1094/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001095static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001096 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1097 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1098 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 {
1101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1102 /* The multiple "Capture Source" controls confuse alsamixer
1103 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 */
1105 /* .name = "Capture Source", */
1106 .name = "Input Source",
1107 .count = 2,
1108 .info = alc_mux_enum_info,
1109 .get = alc_mux_enum_get,
1110 .put = alc_mux_enum_put,
1111 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 { } /* end */
1113};
1114
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001115
1116
1117/*
1118 * ALC880 5-stack model
1119 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001120 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1121 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001122 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1123 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1124 */
1125
1126/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001127static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001128 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001129 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 { } /* end */
1131};
1132
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001133/* channel source setting (6/8 channel selection for 5-stack) */
1134/* 6ch mode */
1135static struct hda_verb alc880_fivestack_ch6_init[] = {
1136 /* set line-in to input, mute it */
1137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1138 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001139 { } /* end */
1140};
1141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001142/* 8ch mode */
1143static struct hda_verb alc880_fivestack_ch8_init[] = {
1144 /* set line-in to output, unmute it */
1145 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1146 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1147 { } /* end */
1148};
1149
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001150static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001151 { 6, alc880_fivestack_ch6_init },
1152 { 8, alc880_fivestack_ch8_init },
1153};
1154
1155
1156/*
1157 * ALC880 6-stack model
1158 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001159 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1160 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001161 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1162 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1163 */
1164
1165static hda_nid_t alc880_6st_dac_nids[4] = {
1166 /* front, rear, clfe, rear_surr */
1167 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001168};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001169
1170static struct hda_input_mux alc880_6stack_capture_source = {
1171 .num_items = 4,
1172 .items = {
1173 { "Mic", 0x0 },
1174 { "Front Mic", 0x1 },
1175 { "Line", 0x2 },
1176 { "CD", 0x4 },
1177 },
1178};
1179
1180/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001181static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001182 { 8, NULL },
1183};
1184
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001185static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001186 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001188 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001189 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001194 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001195 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1204 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1205 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001206 {
1207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1208 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001209 .info = alc_ch_mode_info,
1210 .get = alc_ch_mode_get,
1211 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001212 },
1213 { } /* end */
1214};
1215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001216
1217/*
1218 * ALC880 W810 model
1219 *
1220 * W810 has rear IO for:
1221 * Front (DAC 02)
1222 * Surround (DAC 03)
1223 * Center/LFE (DAC 04)
1224 * Digital out (06)
1225 *
1226 * The system also has a pair of internal speakers, and a headphone jack.
1227 * These are both connected to Line2 on the codec, hence to DAC 02.
1228 *
1229 * There is a variable resistor to control the speaker or headphone
1230 * volume. This is a hardware-only device without a software API.
1231 *
1232 * Plugging headphones in will disable the internal speakers. This is
1233 * implemented in hardware, not via the driver using jack sense. In
1234 * a similar fashion, plugging into the rear socket marked "front" will
1235 * disable both the speakers and headphones.
1236 *
1237 * For input, there's a microphone jack, and an "audio in" jack.
1238 * These may not do anything useful with this driver yet, because I
1239 * haven't setup any initialization verbs for these yet...
1240 */
1241
1242static hda_nid_t alc880_w810_dac_nids[3] = {
1243 /* front, rear/surround, clfe */
1244 0x02, 0x03, 0x04
1245};
1246
1247/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001248static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249 { 6, NULL }
1250};
1251
1252/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001253static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001255 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001257 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1259 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001260 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1261 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1263 { } /* end */
1264};
1265
1266
1267/*
1268 * Z710V model
1269 *
1270 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001271 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1272 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001273 */
1274
1275static hda_nid_t alc880_z71v_dac_nids[1] = {
1276 0x02
1277};
1278#define ALC880_Z71V_HP_DAC 0x03
1279
1280/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001281static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001282 { 2, NULL }
1283};
1284
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001285static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001289 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1293 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1294 { } /* end */
1295};
1296
1297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298/*
1299 * ALC880 F1734 model
1300 *
1301 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1302 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1303 */
1304
1305static hda_nid_t alc880_f1734_dac_nids[1] = {
1306 0x03
1307};
1308#define ALC880_F1734_HP_DAC 0x02
1309
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001310static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001311 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001312 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001313 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1314 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001315 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1316 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001319 { } /* end */
1320};
1321
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001322
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001323/*
1324 * ALC880 ASUS model
1325 *
1326 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1327 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1328 * Mic = 0x18, Line = 0x1a
1329 */
1330
1331#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1332#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1333
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001334static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001335 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001336 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001337 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001338 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001339 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1340 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001341 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1342 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001343 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1344 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1345 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1346 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001349 {
1350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1351 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001352 .info = alc_ch_mode_info,
1353 .get = alc_ch_mode_get,
1354 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001355 },
1356 { } /* end */
1357};
1358
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001359/*
1360 * ALC880 ASUS W1V model
1361 *
1362 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1363 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1364 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1365 */
1366
1367/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001368static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001369 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1370 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001371 { } /* end */
1372};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001373
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001374/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001375static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001376 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1377 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1378 { } /* end */
1379};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001380
Kailang Yangdf694da2005-12-05 19:42:22 +01001381/* TCL S700 */
1382static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1384 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1387 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1391 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1392 {
1393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1394 /* The multiple "Capture Source" controls confuse alsamixer
1395 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001396 */
1397 /* .name = "Capture Source", */
1398 .name = "Input Source",
1399 .count = 1,
1400 .info = alc_mux_enum_info,
1401 .get = alc_mux_enum_get,
1402 .put = alc_mux_enum_put,
1403 },
1404 { } /* end */
1405};
1406
Kailang Yangccc656c2006-10-17 12:32:26 +02001407/* Uniwill */
1408static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1410 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1412 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001413 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1414 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1415 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1416 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1422 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1425 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1426 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1427 {
1428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1429 .name = "Channel Mode",
1430 .info = alc_ch_mode_info,
1431 .get = alc_ch_mode_get,
1432 .put = alc_ch_mode_put,
1433 },
1434 { } /* end */
1435};
1436
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001437static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1438 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1439 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1440 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1442 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1443 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1445 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1446 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1447 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1448 { } /* end */
1449};
1450
Kailang Yangccc656c2006-10-17 12:32:26 +02001451static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001452 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1453 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1454 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1455 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1458 { } /* end */
1459};
1460
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001462 * virtual master controls
1463 */
1464
1465/*
1466 * slave controls for virtual master
1467 */
1468static const char *alc_slave_vols[] = {
1469 "Front Playback Volume",
1470 "Surround Playback Volume",
1471 "Center Playback Volume",
1472 "LFE Playback Volume",
1473 "Side Playback Volume",
1474 "Headphone Playback Volume",
1475 "Speaker Playback Volume",
1476 "Mono Playback Volume",
1477 "iSpeaker Playback Volume",
1478 "Line-Out Playback Volume",
1479 NULL,
1480};
1481
1482static const char *alc_slave_sws[] = {
1483 "Front Playback Switch",
1484 "Surround Playback Switch",
1485 "Center Playback Switch",
1486 "LFE Playback Switch",
1487 "Side Playback Switch",
1488 "Headphone Playback Switch",
1489 "Speaker Playback Switch",
1490 "Mono Playback Switch",
1491 "iSpeaker Playback Switch",
1492 NULL,
1493};
1494
1495/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001496 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 */
1498static int alc_build_controls(struct hda_codec *codec)
1499{
1500 struct alc_spec *spec = codec->spec;
1501 int err;
1502 int i;
1503
1504 for (i = 0; i < spec->num_mixers; i++) {
1505 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1506 if (err < 0)
1507 return err;
1508 }
1509
1510 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001511 err = snd_hda_create_spdif_out_ctls(codec,
1512 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 if (err < 0)
1514 return err;
1515 }
1516 if (spec->dig_in_nid) {
1517 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1518 if (err < 0)
1519 return err;
1520 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001521
1522 /* if we have no master control, let's create it */
1523 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1524 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1525 HDA_OUTPUT, spec->vmaster_tlv);
1526 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1527 spec->vmaster_tlv, alc_slave_vols);
1528 if (err < 0)
1529 return err;
1530 }
1531 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1532 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1533 NULL, alc_slave_sws);
1534 if (err < 0)
1535 return err;
1536 }
1537
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 return 0;
1539}
1540
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001541
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542/*
1543 * initialize the codec volumes, etc
1544 */
1545
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001546/*
1547 * generic initialization of ADC, input mixers and output mixers
1548 */
1549static struct hda_verb alc880_volume_init_verbs[] = {
1550 /*
1551 * Unmute ADC0-2 and set the default input to mic-in
1552 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001553 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001555 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001557 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001560 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1561 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001562 * Note: PASD motherboards uses the Line In 2 as the input for front
1563 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001565 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001574 /*
1575 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001577 /* set vol=0 to output mixers */
1578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1581 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1582 /* set up input amps for analog loopback */
1583 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592
1593 { }
1594};
1595
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001596/*
1597 * 3-stack pin configuration:
1598 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1599 */
1600static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1601 /*
1602 * preset connection lists of input pins
1603 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1604 */
1605 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1606 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1607 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1608
1609 /*
1610 * Set pin mode and muting
1611 */
1612 /* set front pin widgets 0x14 for output */
1613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1615 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1616 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1617 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1618 /* Mic2 (as headphone out) for HP output */
1619 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1620 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1621 /* Line In pin widget for input */
1622 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1623 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1624 /* Line2 (as front mic) pin widget for input and vref at 80% */
1625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1626 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1627 /* CD pin widget for input */
1628 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1629
1630 { }
1631};
1632
1633/*
1634 * 5-stack pin configuration:
1635 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1636 * line-in/side = 0x1a, f-mic = 0x1b
1637 */
1638static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1639 /*
1640 * preset connection lists of input pins
1641 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1642 */
1643 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1644 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1645
1646 /*
1647 * Set pin mode and muting
1648 */
1649 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 /* unmute pins for output (no gain on this amp) */
1655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1657 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001661 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1663 /* Mic2 (as headphone out) for HP output */
1664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 /* Line In pin widget for input */
1667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1669 /* Line2 (as front mic) pin widget for input and vref at 80% */
1670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1672 /* CD pin widget for input */
1673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674
1675 { }
1676};
1677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678/*
1679 * W810 pin configuration:
1680 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1681 */
1682static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 /* hphone/speaker input selector: front DAC */
1684 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692
1693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001694 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 { }
1697};
1698
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001699/*
1700 * Z71V pin configuration:
1701 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1702 */
1703static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001704 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001708
Takashi Iwai16ded522005-06-10 19:58:24 +02001709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001710 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001711 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001712 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001713
1714 { }
1715};
1716
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717/*
1718 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001719 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1720 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001721 */
1722static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1723 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1724
Takashi Iwai16ded522005-06-10 19:58:24 +02001725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001726 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001730 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001731 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733
Takashi Iwai16ded522005-06-10 19:58:24 +02001734 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001735 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001738 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001740 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001741 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 { }
1745};
Takashi Iwai16ded522005-06-10 19:58:24 +02001746
Kailang Yangccc656c2006-10-17 12:32:26 +02001747/*
1748 * Uniwill pin configuration:
1749 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1750 * line = 0x1a
1751 */
1752static struct hda_verb alc880_uniwill_init_verbs[] = {
1753 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1754
1755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769
1770 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1772 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1773 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1774 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1775 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1777 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1778 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1779
1780 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1781 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1782
1783 { }
1784};
1785
1786/*
1787* Uniwill P53
1788* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1789 */
1790static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1791 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1792
1793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805
1806 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1807 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1808 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1809 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812
1813 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1814 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1815
1816 { }
1817};
1818
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001819static struct hda_verb alc880_beep_init_verbs[] = {
1820 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1821 { }
1822};
1823
Kailang Yangccc656c2006-10-17 12:32:26 +02001824/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001825static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001826{
1827 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001828 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001829
1830 present = snd_hda_codec_read(codec, 0x14, 0,
1831 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001832 bits = present ? HDA_AMP_MUTE : 0;
1833 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1834 HDA_AMP_MUTE, bits);
1835 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1836 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001837}
1838
1839/* auto-toggle front mic */
1840static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1841{
1842 unsigned int present;
1843 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001844
1845 present = snd_hda_codec_read(codec, 0x18, 0,
1846 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001847 bits = present ? HDA_AMP_MUTE : 0;
1848 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001849}
1850
1851static void alc880_uniwill_automute(struct hda_codec *codec)
1852{
1853 alc880_uniwill_hp_automute(codec);
1854 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001855}
1856
1857static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1858 unsigned int res)
1859{
1860 /* Looks like the unsol event is incompatible with the standard
1861 * definition. 4bit tag is placed at 28 bit!
1862 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001863 switch (res >> 28) {
1864 case ALC880_HP_EVENT:
1865 alc880_uniwill_hp_automute(codec);
1866 break;
1867 case ALC880_MIC_EVENT:
1868 alc880_uniwill_mic_automute(codec);
1869 break;
1870 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001871}
1872
1873static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1874{
1875 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001876 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001877
1878 present = snd_hda_codec_read(codec, 0x14, 0,
1879 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001880 bits = present ? HDA_AMP_MUTE : 0;
1881 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001882}
1883
1884static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1885{
1886 unsigned int present;
1887
1888 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001889 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1890 present &= HDA_AMP_VOLMASK;
1891 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1892 HDA_AMP_VOLMASK, present);
1893 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1894 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001895}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001896
Kailang Yangccc656c2006-10-17 12:32:26 +02001897static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1898 unsigned int res)
1899{
1900 /* Looks like the unsol event is incompatible with the standard
1901 * definition. 4bit tag is placed at 28 bit!
1902 */
1903 if ((res >> 28) == ALC880_HP_EVENT)
1904 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001905 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001906 alc880_uniwill_p53_dcvol_automute(codec);
1907}
1908
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909/*
1910 * F1734 pin configuration:
1911 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1912 */
1913static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1914 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1915 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1916 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1917 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1918
1919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1922 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1923
1924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001933
1934 { }
1935};
1936
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001937/*
1938 * ASUS pin configuration:
1939 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1940 */
1941static struct hda_verb alc880_pin_asus_init_verbs[] = {
1942 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1943 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1944 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1945 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1946
1947 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1948 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1949 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1951 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955
1956 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1957 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1965
1966 { }
1967};
1968
1969/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001970#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1971#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001972
Kailang Yangdf694da2005-12-05 19:42:22 +01001973/* Clevo m520g init */
1974static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1975 /* headphone output */
1976 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1977 /* line-out */
1978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1980 /* Line-in */
1981 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 /* CD */
1984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1985 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1986 /* Mic1 (rear panel) */
1987 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1989 /* Mic2 (front panel) */
1990 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1991 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1992 /* headphone */
1993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1995 /* change to EAPD mode */
1996 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1997 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1998
1999 { }
2000};
2001
2002static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002003 /* change to EAPD mode */
2004 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2005 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2006
Kailang Yangdf694da2005-12-05 19:42:22 +01002007 /* Headphone output */
2008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2009 /* Front output*/
2010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2011 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2012
2013 /* Line In pin widget for input */
2014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2015 /* CD pin widget for input */
2016 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2017 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2018 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2019
2020 /* change to EAPD mode */
2021 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2022 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2023
2024 { }
2025};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002026
2027/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002028 * LG m1 express dual
2029 *
2030 * Pin assignment:
2031 * Rear Line-In/Out (blue): 0x14
2032 * Build-in Mic-In: 0x15
2033 * Speaker-out: 0x17
2034 * HP-Out (green): 0x1b
2035 * Mic-In/Out (red): 0x19
2036 * SPDIF-Out: 0x1e
2037 */
2038
2039/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2040static hda_nid_t alc880_lg_dac_nids[3] = {
2041 0x05, 0x02, 0x03
2042};
2043
2044/* seems analog CD is not working */
2045static struct hda_input_mux alc880_lg_capture_source = {
2046 .num_items = 3,
2047 .items = {
2048 { "Mic", 0x1 },
2049 { "Line", 0x5 },
2050 { "Internal Mic", 0x6 },
2051 },
2052};
2053
2054/* 2,4,6 channel modes */
2055static struct hda_verb alc880_lg_ch2_init[] = {
2056 /* set line-in and mic-in to input */
2057 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2058 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2059 { }
2060};
2061
2062static struct hda_verb alc880_lg_ch4_init[] = {
2063 /* set line-in to out and mic-in to input */
2064 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2065 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2066 { }
2067};
2068
2069static struct hda_verb alc880_lg_ch6_init[] = {
2070 /* set line-in and mic-in to output */
2071 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2072 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2073 { }
2074};
2075
2076static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2077 { 2, alc880_lg_ch2_init },
2078 { 4, alc880_lg_ch4_init },
2079 { 6, alc880_lg_ch6_init },
2080};
2081
2082static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2084 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2086 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2087 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2088 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2089 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2090 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2094 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2096 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2097 {
2098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2099 .name = "Channel Mode",
2100 .info = alc_ch_mode_info,
2101 .get = alc_ch_mode_get,
2102 .put = alc_ch_mode_put,
2103 },
2104 { } /* end */
2105};
2106
2107static struct hda_verb alc880_lg_init_verbs[] = {
2108 /* set capture source to mic-in */
2109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2110 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2111 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2112 /* mute all amp mixer inputs */
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002116 /* line-in to input */
2117 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2118 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2119 /* built-in mic */
2120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2122 /* speaker-out */
2123 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2124 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2125 /* mic-in to input */
2126 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2127 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2128 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* HP-out */
2130 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2132 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* jack sense */
2134 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2135 { }
2136};
2137
2138/* toggle speaker-output according to the hp-jack state */
2139static void alc880_lg_automute(struct hda_codec *codec)
2140{
2141 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002142 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002143
2144 present = snd_hda_codec_read(codec, 0x1b, 0,
2145 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002146 bits = present ? HDA_AMP_MUTE : 0;
2147 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2148 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002149}
2150
2151static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2152{
2153 /* Looks like the unsol event is incompatible with the standard
2154 * definition. 4bit tag is placed at 28 bit!
2155 */
2156 if ((res >> 28) == 0x01)
2157 alc880_lg_automute(codec);
2158}
2159
2160/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002161 * LG LW20
2162 *
2163 * Pin assignment:
2164 * Speaker-out: 0x14
2165 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002166 * Built-in Mic-In: 0x19
2167 * Line-In: 0x1b
2168 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002169 * SPDIF-Out: 0x1e
2170 */
2171
Takashi Iwaid6815182006-03-23 16:06:23 +01002172static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002173 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002174 .items = {
2175 { "Mic", 0x0 },
2176 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002177 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002178 },
2179};
2180
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002181#define alc880_lg_lw_modes alc880_threestack_modes
2182
Takashi Iwaid6815182006-03-23 16:06:23 +01002183static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002184 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2185 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2186 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2187 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2188 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2189 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2190 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2191 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2193 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2197 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002198 {
2199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2200 .name = "Channel Mode",
2201 .info = alc_ch_mode_info,
2202 .get = alc_ch_mode_get,
2203 .put = alc_ch_mode_put,
2204 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002205 { } /* end */
2206};
2207
2208static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002209 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2210 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2211 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2212
Takashi Iwaid6815182006-03-23 16:06:23 +01002213 /* set capture source to mic-in */
2214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002218 /* speaker-out */
2219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2221 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002222 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2223 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 /* mic-in to input */
2225 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2226 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2227 /* built-in mic */
2228 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2230 /* jack sense */
2231 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2232 { }
2233};
2234
2235/* toggle speaker-output according to the hp-jack state */
2236static void alc880_lg_lw_automute(struct hda_codec *codec)
2237{
2238 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002239 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002240
2241 present = snd_hda_codec_read(codec, 0x1b, 0,
2242 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002243 bits = present ? HDA_AMP_MUTE : 0;
2244 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2245 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002246}
2247
2248static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2249{
2250 /* Looks like the unsol event is incompatible with the standard
2251 * definition. 4bit tag is placed at 28 bit!
2252 */
2253 if ((res >> 28) == 0x01)
2254 alc880_lg_lw_automute(codec);
2255}
2256
Takashi Iwaicb53c622007-08-10 17:21:45 +02002257#ifdef CONFIG_SND_HDA_POWER_SAVE
2258static struct hda_amp_list alc880_loopbacks[] = {
2259 { 0x0b, HDA_INPUT, 0 },
2260 { 0x0b, HDA_INPUT, 1 },
2261 { 0x0b, HDA_INPUT, 2 },
2262 { 0x0b, HDA_INPUT, 3 },
2263 { 0x0b, HDA_INPUT, 4 },
2264 { } /* end */
2265};
2266
2267static struct hda_amp_list alc880_lg_loopbacks[] = {
2268 { 0x0b, HDA_INPUT, 1 },
2269 { 0x0b, HDA_INPUT, 6 },
2270 { 0x0b, HDA_INPUT, 7 },
2271 { } /* end */
2272};
2273#endif
2274
Takashi Iwaid6815182006-03-23 16:06:23 +01002275/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002276 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002278
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279static int alc_init(struct hda_codec *codec)
2280{
2281 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 unsigned int i;
2283
2284 for (i = 0; i < spec->num_init_verbs; i++)
2285 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002286
2287 if (spec->init_hook)
2288 spec->init_hook(codec);
2289
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 return 0;
2291}
2292
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002293static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2294{
2295 struct alc_spec *spec = codec->spec;
2296
2297 if (spec->unsol_event)
2298 spec->unsol_event(codec, res);
2299}
2300
Takashi Iwaicb53c622007-08-10 17:21:45 +02002301#ifdef CONFIG_SND_HDA_POWER_SAVE
2302static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2303{
2304 struct alc_spec *spec = codec->spec;
2305 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2306}
2307#endif
2308
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309/*
2310 * Analog playback callbacks
2311 */
2312static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2313 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002314 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315{
2316 struct alc_spec *spec = codec->spec;
2317 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2318}
2319
2320static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2321 struct hda_codec *codec,
2322 unsigned int stream_tag,
2323 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002324 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325{
2326 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002327 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2328 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329}
2330
2331static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2332 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002333 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334{
2335 struct alc_spec *spec = codec->spec;
2336 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2337}
2338
2339/*
2340 * Digital out
2341 */
2342static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2343 struct hda_codec *codec,
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;
2347 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2348}
2349
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002350static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2351 struct hda_codec *codec,
2352 unsigned int stream_tag,
2353 unsigned int format,
2354 struct snd_pcm_substream *substream)
2355{
2356 struct alc_spec *spec = codec->spec;
2357 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2358 stream_tag, format, substream);
2359}
2360
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2362 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002363 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364{
2365 struct alc_spec *spec = codec->spec;
2366 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2367}
2368
2369/*
2370 * Analog capture
2371 */
2372static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2373 struct hda_codec *codec,
2374 unsigned int stream_tag,
2375 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002376 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377{
2378 struct alc_spec *spec = codec->spec;
2379
2380 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2381 stream_tag, 0, format);
2382 return 0;
2383}
2384
2385static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2386 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002387 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388{
2389 struct alc_spec *spec = codec->spec;
2390
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002391 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2392 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 return 0;
2394}
2395
2396
2397/*
2398 */
2399static struct hda_pcm_stream alc880_pcm_analog_playback = {
2400 .substreams = 1,
2401 .channels_min = 2,
2402 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 .ops = {
2405 .open = alc880_playback_pcm_open,
2406 .prepare = alc880_playback_pcm_prepare,
2407 .cleanup = alc880_playback_pcm_cleanup
2408 },
2409};
2410
2411static struct hda_pcm_stream alc880_pcm_analog_capture = {
2412 .substreams = 2,
2413 .channels_min = 2,
2414 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002415 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416 .ops = {
2417 .prepare = alc880_capture_pcm_prepare,
2418 .cleanup = alc880_capture_pcm_cleanup
2419 },
2420};
2421
2422static struct hda_pcm_stream alc880_pcm_digital_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2427 .ops = {
2428 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002429 .close = alc880_dig_playback_pcm_close,
2430 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 },
2432};
2433
2434static struct hda_pcm_stream alc880_pcm_digital_capture = {
2435 .substreams = 1,
2436 .channels_min = 2,
2437 .channels_max = 2,
2438 /* NID is set in alc_build_pcms */
2439};
2440
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002441/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2442static struct hda_pcm_stream alc_pcm_null_playback = {
2443 .substreams = 0,
2444 .channels_min = 0,
2445 .channels_max = 0,
2446};
2447
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448static int alc_build_pcms(struct hda_codec *codec)
2449{
2450 struct alc_spec *spec = codec->spec;
2451 struct hda_pcm *info = spec->pcm_rec;
2452 int i;
2453
2454 codec->num_pcms = 1;
2455 codec->pcm_info = info;
2456
2457 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002458 if (spec->stream_analog_playback) {
2459 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2460 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2461 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2462 }
2463 if (spec->stream_analog_capture) {
2464 snd_assert(spec->adc_nids, return -EINVAL);
2465 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2466 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2467 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468
Takashi Iwai4a471b72005-12-07 13:56:29 +01002469 if (spec->channel_mode) {
2470 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2471 for (i = 0; i < spec->num_channel_mode; i++) {
2472 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2473 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2474 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 }
2476 }
2477
Takashi Iwaie08a0072006-09-07 17:52:14 +02002478 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002480 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002481 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002483 if (spec->multiout.dig_out_nid &&
2484 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2486 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2487 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002488 if (spec->dig_in_nid &&
2489 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2491 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2492 }
2493 }
2494
Takashi Iwaie08a0072006-09-07 17:52:14 +02002495 /* If the use of more than one ADC is requested for the current
2496 * model, configure a second analog capture-only PCM.
2497 */
2498 /* Additional Analaog capture for index #2 */
2499 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2500 spec->adc_nids) {
2501 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002502 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002503 info->name = spec->stream_name_analog;
2504 /* No playback stream for second PCM */
2505 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2506 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2507 if (spec->stream_analog_capture) {
2508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2510 }
2511 }
2512
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 return 0;
2514}
2515
2516static void alc_free(struct hda_codec *codec)
2517{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002518 struct alc_spec *spec = codec->spec;
2519 unsigned int i;
2520
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002521 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522 return;
2523
2524 if (spec->kctl_alloc) {
2525 for (i = 0; i < spec->num_kctl_used; i++)
2526 kfree(spec->kctl_alloc[i].name);
2527 kfree(spec->kctl_alloc);
2528 }
2529 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530}
2531
2532/*
2533 */
2534static struct hda_codec_ops alc_patch_ops = {
2535 .build_controls = alc_build_controls,
2536 .build_pcms = alc_build_pcms,
2537 .init = alc_init,
2538 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002539 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002540#ifdef CONFIG_SND_HDA_POWER_SAVE
2541 .check_power_status = alc_check_power_status,
2542#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543};
2544
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002545
2546/*
2547 * Test configuration for debugging
2548 *
2549 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2550 * enum controls.
2551 */
2552#ifdef CONFIG_SND_DEBUG
2553static hda_nid_t alc880_test_dac_nids[4] = {
2554 0x02, 0x03, 0x04, 0x05
2555};
2556
2557static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002558 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002559 .items = {
2560 { "In-1", 0x0 },
2561 { "In-2", 0x1 },
2562 { "In-3", 0x2 },
2563 { "In-4", 0x3 },
2564 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002565 { "Front", 0x5 },
2566 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002567 },
2568};
2569
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002570static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002571 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002572 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002573 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002574 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002575};
2576
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002577static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2578 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002579{
2580 static char *texts[] = {
2581 "N/A", "Line Out", "HP Out",
2582 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2583 };
2584 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2585 uinfo->count = 1;
2586 uinfo->value.enumerated.items = 8;
2587 if (uinfo->value.enumerated.item >= 8)
2588 uinfo->value.enumerated.item = 7;
2589 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2590 return 0;
2591}
2592
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002593static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2594 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002595{
2596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2597 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2598 unsigned int pin_ctl, item = 0;
2599
2600 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2601 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2602 if (pin_ctl & AC_PINCTL_OUT_EN) {
2603 if (pin_ctl & AC_PINCTL_HP_EN)
2604 item = 2;
2605 else
2606 item = 1;
2607 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2608 switch (pin_ctl & AC_PINCTL_VREFEN) {
2609 case AC_PINCTL_VREF_HIZ: item = 3; break;
2610 case AC_PINCTL_VREF_50: item = 4; break;
2611 case AC_PINCTL_VREF_GRD: item = 5; break;
2612 case AC_PINCTL_VREF_80: item = 6; break;
2613 case AC_PINCTL_VREF_100: item = 7; break;
2614 }
2615 }
2616 ucontrol->value.enumerated.item[0] = item;
2617 return 0;
2618}
2619
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002620static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2621 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002622{
2623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2624 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2625 static unsigned int ctls[] = {
2626 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2627 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2628 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2629 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2630 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2631 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2632 };
2633 unsigned int old_ctl, new_ctl;
2634
2635 old_ctl = snd_hda_codec_read(codec, nid, 0,
2636 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2637 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2638 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002639 int val;
2640 snd_hda_codec_write_cache(codec, nid, 0,
2641 AC_VERB_SET_PIN_WIDGET_CONTROL,
2642 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002643 val = ucontrol->value.enumerated.item[0] >= 3 ?
2644 HDA_AMP_MUTE : 0;
2645 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2646 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002647 return 1;
2648 }
2649 return 0;
2650}
2651
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002652static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2653 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002654{
2655 static char *texts[] = {
2656 "Front", "Surround", "CLFE", "Side"
2657 };
2658 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2659 uinfo->count = 1;
2660 uinfo->value.enumerated.items = 4;
2661 if (uinfo->value.enumerated.item >= 4)
2662 uinfo->value.enumerated.item = 3;
2663 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2664 return 0;
2665}
2666
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002667static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2668 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002669{
2670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2671 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2672 unsigned int sel;
2673
2674 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2675 ucontrol->value.enumerated.item[0] = sel & 3;
2676 return 0;
2677}
2678
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002679static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2680 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002681{
2682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2683 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2684 unsigned int sel;
2685
2686 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2687 if (ucontrol->value.enumerated.item[0] != sel) {
2688 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002689 snd_hda_codec_write_cache(codec, nid, 0,
2690 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002691 return 1;
2692 }
2693 return 0;
2694}
2695
2696#define PIN_CTL_TEST(xname,nid) { \
2697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2698 .name = xname, \
2699 .info = alc_test_pin_ctl_info, \
2700 .get = alc_test_pin_ctl_get, \
2701 .put = alc_test_pin_ctl_put, \
2702 .private_value = nid \
2703 }
2704
2705#define PIN_SRC_TEST(xname,nid) { \
2706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2707 .name = xname, \
2708 .info = alc_test_pin_src_info, \
2709 .get = alc_test_pin_src_get, \
2710 .put = alc_test_pin_src_put, \
2711 .private_value = nid \
2712 }
2713
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002714static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002715 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2716 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2717 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2718 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2720 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2721 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2722 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002723 PIN_CTL_TEST("Front Pin Mode", 0x14),
2724 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2725 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2726 PIN_CTL_TEST("Side Pin Mode", 0x17),
2727 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2728 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2729 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2730 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2731 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2732 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2733 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2734 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2735 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2736 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2737 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2738 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2739 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2740 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2741 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2742 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2743 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2744 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002745 {
2746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2747 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002748 .info = alc_ch_mode_info,
2749 .get = alc_ch_mode_get,
2750 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002751 },
2752 { } /* end */
2753};
2754
2755static struct hda_verb alc880_test_init_verbs[] = {
2756 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2763 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002765 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2769 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002770 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2772 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2773 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2774 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002775 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2778 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002780 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002781 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002783 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2784 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2785 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002786 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002787 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2788 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2789 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2790 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002791 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002793 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002795 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002797 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002798 /* Analog input/passthru */
2799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002804 { }
2805};
2806#endif
2807
Linus Torvalds1da177e2005-04-16 15:20:36 -07002808/*
2809 */
2810
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002811static const char *alc880_models[ALC880_MODEL_LAST] = {
2812 [ALC880_3ST] = "3stack",
2813 [ALC880_TCL_S700] = "tcl",
2814 [ALC880_3ST_DIG] = "3stack-digout",
2815 [ALC880_CLEVO] = "clevo",
2816 [ALC880_5ST] = "5stack",
2817 [ALC880_5ST_DIG] = "5stack-digout",
2818 [ALC880_W810] = "w810",
2819 [ALC880_Z71V] = "z71v",
2820 [ALC880_6ST] = "6stack",
2821 [ALC880_6ST_DIG] = "6stack-digout",
2822 [ALC880_ASUS] = "asus",
2823 [ALC880_ASUS_W1V] = "asus-w1v",
2824 [ALC880_ASUS_DIG] = "asus-dig",
2825 [ALC880_ASUS_DIG2] = "asus-dig2",
2826 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002827 [ALC880_UNIWILL_P53] = "uniwill-p53",
2828 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002829 [ALC880_F1734] = "F1734",
2830 [ALC880_LG] = "lg",
2831 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002832#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002833 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002834#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002835 [ALC880_AUTO] = "auto",
2836};
2837
2838static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002839 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002840 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2841 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2842 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2843 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2844 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2845 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2846 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2847 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002848 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2849 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002850 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2851 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2852 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2853 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2854 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2855 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2856 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2857 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2858 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2859 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002860 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002861 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2862 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2863 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002864 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002865 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002866 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2867 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002868 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2869 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002870 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2871 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2872 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2873 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002874 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2875 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002876 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002877 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002878 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002879 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002880 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2881 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002882 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2883 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002884 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002885 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002886 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002887 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002888 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002889 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2890 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002891 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002892 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2893 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2894 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2895 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002896 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2897 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002898 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002899 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002900 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2901 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002902 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2903 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2904 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002905 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2906 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2907 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908 {}
2909};
2910
Takashi Iwai16ded522005-06-10 19:58:24 +02002911/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002912 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002913 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002914static struct alc_config_preset alc880_presets[] = {
2915 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002917 .init_verbs = { alc880_volume_init_verbs,
2918 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002919 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002920 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002921 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2922 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002923 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002924 .input_mux = &alc880_capture_source,
2925 },
2926 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002927 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002928 .init_verbs = { alc880_volume_init_verbs,
2929 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002930 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002931 .dac_nids = alc880_dac_nids,
2932 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002933 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2934 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002935 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002936 .input_mux = &alc880_capture_source,
2937 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002938 [ALC880_TCL_S700] = {
2939 .mixers = { alc880_tcl_s700_mixer },
2940 .init_verbs = { alc880_volume_init_verbs,
2941 alc880_pin_tcl_S700_init_verbs,
2942 alc880_gpio2_init_verbs },
2943 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2944 .dac_nids = alc880_dac_nids,
2945 .hp_nid = 0x03,
2946 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2947 .channel_mode = alc880_2_jack_modes,
2948 .input_mux = &alc880_capture_source,
2949 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002950 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002951 .mixers = { alc880_three_stack_mixer,
2952 alc880_five_stack_mixer},
2953 .init_verbs = { alc880_volume_init_verbs,
2954 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002955 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2956 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002957 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2958 .channel_mode = alc880_fivestack_modes,
2959 .input_mux = &alc880_capture_source,
2960 },
2961 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002962 .mixers = { alc880_three_stack_mixer,
2963 alc880_five_stack_mixer },
2964 .init_verbs = { alc880_volume_init_verbs,
2965 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002966 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2967 .dac_nids = alc880_dac_nids,
2968 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002969 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2970 .channel_mode = alc880_fivestack_modes,
2971 .input_mux = &alc880_capture_source,
2972 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002973 [ALC880_6ST] = {
2974 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002975 .init_verbs = { alc880_volume_init_verbs,
2976 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002977 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2978 .dac_nids = alc880_6st_dac_nids,
2979 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2980 .channel_mode = alc880_sixstack_modes,
2981 .input_mux = &alc880_6stack_capture_source,
2982 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002985 .init_verbs = { alc880_volume_init_verbs,
2986 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002987 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2988 .dac_nids = alc880_6st_dac_nids,
2989 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002990 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2991 .channel_mode = alc880_sixstack_modes,
2992 .input_mux = &alc880_6stack_capture_source,
2993 },
2994 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002995 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002996 .init_verbs = { alc880_volume_init_verbs,
2997 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002998 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002999 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3000 .dac_nids = alc880_w810_dac_nids,
3001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3003 .channel_mode = alc880_w810_modes,
3004 .input_mux = &alc880_capture_source,
3005 },
3006 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003008 .init_verbs = { alc880_volume_init_verbs,
3009 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003010 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3011 .dac_nids = alc880_z71v_dac_nids,
3012 .dig_out_nid = ALC880_DIGOUT_NID,
3013 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003014 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3015 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003016 .input_mux = &alc880_capture_source,
3017 },
3018 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003020 .init_verbs = { alc880_volume_init_verbs,
3021 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003022 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3023 .dac_nids = alc880_f1734_dac_nids,
3024 .hp_nid = 0x02,
3025 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3026 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003027 .input_mux = &alc880_capture_source,
3028 },
3029 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003030 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003031 .init_verbs = { alc880_volume_init_verbs,
3032 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003033 alc880_gpio1_init_verbs },
3034 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3035 .dac_nids = alc880_asus_dac_nids,
3036 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3037 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003038 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003039 .input_mux = &alc880_capture_source,
3040 },
3041 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003043 .init_verbs = { alc880_volume_init_verbs,
3044 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 alc880_gpio1_init_verbs },
3046 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3047 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003048 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003049 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3050 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003051 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003052 .input_mux = &alc880_capture_source,
3053 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003054 [ALC880_ASUS_DIG2] = {
3055 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003056 .init_verbs = { alc880_volume_init_verbs,
3057 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003058 alc880_gpio2_init_verbs }, /* use GPIO2 */
3059 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3060 .dac_nids = alc880_asus_dac_nids,
3061 .dig_out_nid = ALC880_DIGOUT_NID,
3062 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3063 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003064 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003065 .input_mux = &alc880_capture_source,
3066 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003067 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003068 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003069 .init_verbs = { alc880_volume_init_verbs,
3070 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003071 alc880_gpio1_init_verbs },
3072 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3073 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003074 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003075 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3076 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003077 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003078 .input_mux = &alc880_capture_source,
3079 },
3080 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003081 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003082 .init_verbs = { alc880_volume_init_verbs,
3083 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003084 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3085 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003086 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3088 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003089 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003090 .input_mux = &alc880_capture_source,
3091 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003092 [ALC880_UNIWILL] = {
3093 .mixers = { alc880_uniwill_mixer },
3094 .init_verbs = { alc880_volume_init_verbs,
3095 alc880_uniwill_init_verbs },
3096 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3097 .dac_nids = alc880_asus_dac_nids,
3098 .dig_out_nid = ALC880_DIGOUT_NID,
3099 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3100 .channel_mode = alc880_threestack_modes,
3101 .need_dac_fix = 1,
3102 .input_mux = &alc880_capture_source,
3103 .unsol_event = alc880_uniwill_unsol_event,
3104 .init_hook = alc880_uniwill_automute,
3105 },
3106 [ALC880_UNIWILL_P53] = {
3107 .mixers = { alc880_uniwill_p53_mixer },
3108 .init_verbs = { alc880_volume_init_verbs,
3109 alc880_uniwill_p53_init_verbs },
3110 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3111 .dac_nids = alc880_asus_dac_nids,
3112 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003113 .channel_mode = alc880_threestack_modes,
3114 .input_mux = &alc880_capture_source,
3115 .unsol_event = alc880_uniwill_p53_unsol_event,
3116 .init_hook = alc880_uniwill_p53_hp_automute,
3117 },
3118 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003119 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003120 alc880_pcbeep_mixer, },
3121 .init_verbs = { alc880_volume_init_verbs,
3122 alc880_uniwill_p53_init_verbs,
3123 alc880_beep_init_verbs },
3124 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3125 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003126 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003127 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3128 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003129 .input_mux = &alc880_capture_source,
3130 .unsol_event = alc880_uniwill_p53_unsol_event,
3131 .init_hook = alc880_uniwill_p53_hp_automute,
3132 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003133 [ALC880_CLEVO] = {
3134 .mixers = { alc880_three_stack_mixer },
3135 .init_verbs = { alc880_volume_init_verbs,
3136 alc880_pin_clevo_init_verbs },
3137 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3138 .dac_nids = alc880_dac_nids,
3139 .hp_nid = 0x03,
3140 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3141 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003142 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003143 .input_mux = &alc880_capture_source,
3144 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003145 [ALC880_LG] = {
3146 .mixers = { alc880_lg_mixer },
3147 .init_verbs = { alc880_volume_init_verbs,
3148 alc880_lg_init_verbs },
3149 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3150 .dac_nids = alc880_lg_dac_nids,
3151 .dig_out_nid = ALC880_DIGOUT_NID,
3152 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3153 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003154 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003155 .input_mux = &alc880_lg_capture_source,
3156 .unsol_event = alc880_lg_unsol_event,
3157 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003158#ifdef CONFIG_SND_HDA_POWER_SAVE
3159 .loopbacks = alc880_lg_loopbacks,
3160#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003161 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003162 [ALC880_LG_LW] = {
3163 .mixers = { alc880_lg_lw_mixer },
3164 .init_verbs = { alc880_volume_init_verbs,
3165 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003166 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003167 .dac_nids = alc880_dac_nids,
3168 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003169 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3170 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003171 .input_mux = &alc880_lg_lw_capture_source,
3172 .unsol_event = alc880_lg_lw_unsol_event,
3173 .init_hook = alc880_lg_lw_automute,
3174 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003175#ifdef CONFIG_SND_DEBUG
3176 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177 .mixers = { alc880_test_mixer },
3178 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003179 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3180 .dac_nids = alc880_test_dac_nids,
3181 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003182 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3183 .channel_mode = alc880_test_modes,
3184 .input_mux = &alc880_test_capture_source,
3185 },
3186#endif
3187};
3188
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003189/*
3190 * Automatic parse of I/O pins from the BIOS configuration
3191 */
3192
3193#define NUM_CONTROL_ALLOC 32
3194#define NUM_VERB_ALLOC 32
3195
3196enum {
3197 ALC_CTL_WIDGET_VOL,
3198 ALC_CTL_WIDGET_MUTE,
3199 ALC_CTL_BIND_MUTE,
3200};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003201static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003202 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3203 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003204 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003205};
3206
3207/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003208static int add_control(struct alc_spec *spec, int type, const char *name,
3209 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003211 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003212
3213 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3214 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3215
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003216 /* array + terminator */
3217 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3218 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219 return -ENOMEM;
3220 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003221 memcpy(knew, spec->kctl_alloc,
3222 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 kfree(spec->kctl_alloc);
3224 }
3225 spec->kctl_alloc = knew;
3226 spec->num_kctl_alloc = num;
3227 }
3228
3229 knew = &spec->kctl_alloc[spec->num_kctl_used];
3230 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003231 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003232 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003233 return -ENOMEM;
3234 knew->private_value = val;
3235 spec->num_kctl_used++;
3236 return 0;
3237}
3238
3239#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3240#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3241#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3242#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3243#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3244#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3245#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3246#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3247#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3248#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3249#define ALC880_PIN_CD_NID 0x1c
3250
3251/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003252static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3253 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254{
3255 hda_nid_t nid;
3256 int assigned[4];
3257 int i, j;
3258
3259 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003260 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261
3262 /* check the pins hardwired to audio widget */
3263 for (i = 0; i < cfg->line_outs; i++) {
3264 nid = cfg->line_out_pins[i];
3265 if (alc880_is_fixed_pin(nid)) {
3266 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003267 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 assigned[idx] = 1;
3269 }
3270 }
3271 /* left pins can be connect to any audio widget */
3272 for (i = 0; i < cfg->line_outs; i++) {
3273 nid = cfg->line_out_pins[i];
3274 if (alc880_is_fixed_pin(nid))
3275 continue;
3276 /* search for an empty channel */
3277 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003278 if (!assigned[j]) {
3279 spec->multiout.dac_nids[i] =
3280 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281 assigned[j] = 1;
3282 break;
3283 }
3284 }
3285 }
3286 spec->multiout.num_dacs = cfg->line_outs;
3287 return 0;
3288}
3289
3290/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003291static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3292 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293{
3294 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003295 static const char *chname[4] = {
3296 "Front", "Surround", NULL /*CLFE*/, "Side"
3297 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003298 hda_nid_t nid;
3299 int i, err;
3300
3301 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003302 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003303 continue;
3304 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3305 if (i == 2) {
3306 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003307 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3308 "Center Playback Volume",
3309 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3310 HDA_OUTPUT));
3311 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003312 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003313 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3314 "LFE Playback Volume",
3315 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3316 HDA_OUTPUT));
3317 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003319 err = add_control(spec, ALC_CTL_BIND_MUTE,
3320 "Center Playback Switch",
3321 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3322 HDA_INPUT));
3323 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003324 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003325 err = add_control(spec, ALC_CTL_BIND_MUTE,
3326 "LFE Playback Switch",
3327 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3328 HDA_INPUT));
3329 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003330 return err;
3331 } else {
3332 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003333 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3334 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3335 HDA_OUTPUT));
3336 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003337 return err;
3338 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003339 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3340 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3341 HDA_INPUT));
3342 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343 return err;
3344 }
3345 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003346 return 0;
3347}
3348
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003349/* add playback controls for speaker and HP outputs */
3350static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3351 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352{
3353 hda_nid_t nid;
3354 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003355 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003357 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 return 0;
3359
3360 if (alc880_is_fixed_pin(pin)) {
3361 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003362 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003363 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003365 else
3366 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003367 /* control HP volume/switch on the output mixer amp */
3368 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003369 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003370 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3371 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3372 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003373 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003374 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003375 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3376 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3377 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003378 return err;
3379 } else if (alc880_is_multi_pin(pin)) {
3380 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003382 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003383 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3384 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3385 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003386 return err;
3387 }
3388 return 0;
3389}
3390
3391/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003392static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3393 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003394 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395{
3396 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003397 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398
3399 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003400 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3401 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3402 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003403 return err;
3404 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003405 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3406 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3407 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408 return err;
3409 return 0;
3410}
3411
3412/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003413static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3414 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003415{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003417 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003418
3419 for (i = 0; i < AUTO_PIN_LAST; i++) {
3420 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003421 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003422 err = new_analog_input(spec, cfg->input_pins[i],
3423 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003424 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003425 if (err < 0)
3426 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003427 imux->items[imux->num_items].label =
3428 auto_pin_cfg_labels[i];
3429 imux->items[imux->num_items].index =
3430 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431 imux->num_items++;
3432 }
3433 }
3434 return 0;
3435}
3436
Kailang Yangdf694da2005-12-05 19:42:22 +01003437static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3438 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 int dac_idx)
3440{
3441 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003442 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3443 pin_type);
3444 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3445 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003446 /* need the manual connection? */
3447 if (alc880_is_multi_pin(nid)) {
3448 struct alc_spec *spec = codec->spec;
3449 int idx = alc880_multi_pin_idx(nid);
3450 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3451 AC_VERB_SET_CONNECT_SEL,
3452 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3453 }
3454}
3455
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003456static int get_pin_type(int line_out_type)
3457{
3458 if (line_out_type == AUTO_PIN_HP_OUT)
3459 return PIN_HP;
3460 else
3461 return PIN_OUT;
3462}
3463
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464static void alc880_auto_init_multi_out(struct hda_codec *codec)
3465{
3466 struct alc_spec *spec = codec->spec;
3467 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003468
3469 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470 for (i = 0; i < spec->autocfg.line_outs; i++) {
3471 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003472 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3473 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474 }
3475}
3476
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003477static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003478{
3479 struct alc_spec *spec = codec->spec;
3480 hda_nid_t pin;
3481
Takashi Iwai82bc9552006-03-21 11:24:42 +01003482 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003483 if (pin) /* connect to front */
3484 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003485 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003486 if (pin) /* connect to front */
3487 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3488}
3489
3490static void alc880_auto_init_analog_input(struct hda_codec *codec)
3491{
3492 struct alc_spec *spec = codec->spec;
3493 int i;
3494
3495 for (i = 0; i < AUTO_PIN_LAST; i++) {
3496 hda_nid_t nid = spec->autocfg.input_pins[i];
3497 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003498 snd_hda_codec_write(codec, nid, 0,
3499 AC_VERB_SET_PIN_WIDGET_CONTROL,
3500 i <= AUTO_PIN_FRONT_MIC ?
3501 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003502 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003503 snd_hda_codec_write(codec, nid, 0,
3504 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 AMP_OUT_MUTE);
3506 }
3507 }
3508}
3509
3510/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003511/* return 1 if successful, 0 if the proper config is not found,
3512 * or a negative error code
3513 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003514static int alc880_parse_auto_config(struct hda_codec *codec)
3515{
3516 struct alc_spec *spec = codec->spec;
3517 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003518 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003520 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3521 alc880_ignore);
3522 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003524 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003526
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003527 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3528 if (err < 0)
3529 return err;
3530 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3531 if (err < 0)
3532 return err;
3533 err = alc880_auto_create_extra_out(spec,
3534 spec->autocfg.speaker_pins[0],
3535 "Speaker");
3536 if (err < 0)
3537 return err;
3538 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3539 "Headphone");
3540 if (err < 0)
3541 return err;
3542 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3543 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544 return err;
3545
3546 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3547
3548 if (spec->autocfg.dig_out_pin)
3549 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3550 if (spec->autocfg.dig_in_pin)
3551 spec->dig_in_nid = ALC880_DIGIN_NID;
3552
3553 if (spec->kctl_alloc)
3554 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3555
3556 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3557
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003558 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003559 spec->input_mux = &spec->private_imux;
3560
3561 return 1;
3562}
3563
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003564/* additional initialization for auto-configuration model */
3565static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003566{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003567 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003568 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570}
3571
3572/*
3573 * OK, here we have finally the patch for ALC880
3574 */
3575
Linus Torvalds1da177e2005-04-16 15:20:36 -07003576static int patch_alc880(struct hda_codec *codec)
3577{
3578 struct alc_spec *spec;
3579 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003580 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003581
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003582 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003583 if (spec == NULL)
3584 return -ENOMEM;
3585
3586 codec->spec = spec;
3587
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003588 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3589 alc880_models,
3590 alc880_cfg_tbl);
3591 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003592 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3593 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003595 }
3596
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597 if (board_config == ALC880_AUTO) {
3598 /* automatic parse from the BIOS config */
3599 err = alc880_parse_auto_config(codec);
3600 if (err < 0) {
3601 alc_free(codec);
3602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003603 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003604 printk(KERN_INFO
3605 "hda_codec: Cannot set up configuration "
3606 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003607 board_config = ALC880_3ST;
3608 }
3609 }
3610
Kailang Yangdf694da2005-12-05 19:42:22 +01003611 if (board_config != ALC880_AUTO)
3612 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003613
3614 spec->stream_name_analog = "ALC880 Analog";
3615 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3616 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3617
3618 spec->stream_name_digital = "ALC880 Digital";
3619 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3620 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3621
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003622 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003624 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003625 /* get type */
3626 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 if (wcap != AC_WID_AUD_IN) {
3628 spec->adc_nids = alc880_adc_nids_alt;
3629 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003630 spec->mixers[spec->num_mixers] =
3631 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 spec->num_mixers++;
3633 } else {
3634 spec->adc_nids = alc880_adc_nids;
3635 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3636 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3637 spec->num_mixers++;
3638 }
3639 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003640
Takashi Iwai2134ea42008-01-10 16:53:55 +01003641 spec->vmaster_nid = 0x0c;
3642
Linus Torvalds1da177e2005-04-16 15:20:36 -07003643 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003644 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003645 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003646#ifdef CONFIG_SND_HDA_POWER_SAVE
3647 if (!spec->loopback.amplist)
3648 spec->loopback.amplist = alc880_loopbacks;
3649#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003650
3651 return 0;
3652}
3653
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003654
Linus Torvalds1da177e2005-04-16 15:20:36 -07003655/*
3656 * ALC260 support
3657 */
3658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659static hda_nid_t alc260_dac_nids[1] = {
3660 /* front */
3661 0x02,
3662};
3663
3664static hda_nid_t alc260_adc_nids[1] = {
3665 /* ADC0 */
3666 0x04,
3667};
3668
Kailang Yangdf694da2005-12-05 19:42:22 +01003669static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003670 /* ADC1 */
3671 0x05,
3672};
3673
Kailang Yangdf694da2005-12-05 19:42:22 +01003674static hda_nid_t alc260_hp_adc_nids[2] = {
3675 /* ADC1, 0 */
3676 0x05, 0x04
3677};
3678
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003679/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3680 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3681 */
3682static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003683 /* ADC0, ADC1 */
3684 0x04, 0x05
3685};
3686
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003687#define ALC260_DIGOUT_NID 0x03
3688#define ALC260_DIGIN_NID 0x06
3689
3690static struct hda_input_mux alc260_capture_source = {
3691 .num_items = 4,
3692 .items = {
3693 { "Mic", 0x0 },
3694 { "Front Mic", 0x1 },
3695 { "Line", 0x2 },
3696 { "CD", 0x4 },
3697 },
3698};
3699
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003700/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003701 * headphone jack and the internal CD lines since these are the only pins at
3702 * which audio can appear. For flexibility, also allow the option of
3703 * recording the mixer output on the second ADC (ADC0 doesn't have a
3704 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003705 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003706static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3707 {
3708 .num_items = 3,
3709 .items = {
3710 { "Mic/Line", 0x0 },
3711 { "CD", 0x4 },
3712 { "Headphone", 0x2 },
3713 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003714 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003715 {
3716 .num_items = 4,
3717 .items = {
3718 { "Mic/Line", 0x0 },
3719 { "CD", 0x4 },
3720 { "Headphone", 0x2 },
3721 { "Mixer", 0x5 },
3722 },
3723 },
3724
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003725};
3726
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003727/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3728 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003729 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003730static struct hda_input_mux alc260_acer_capture_sources[2] = {
3731 {
3732 .num_items = 4,
3733 .items = {
3734 { "Mic", 0x0 },
3735 { "Line", 0x2 },
3736 { "CD", 0x4 },
3737 { "Headphone", 0x5 },
3738 },
3739 },
3740 {
3741 .num_items = 5,
3742 .items = {
3743 { "Mic", 0x0 },
3744 { "Line", 0x2 },
3745 { "CD", 0x4 },
3746 { "Headphone", 0x6 },
3747 { "Mixer", 0x5 },
3748 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003749 },
3750};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003751/*
3752 * This is just place-holder, so there's something for alc_build_pcms to look
3753 * at when it calculates the maximum number of channels. ALC260 has no mixer
3754 * element which allows changing the channel mode, so the verb list is
3755 * never used.
3756 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003757static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003758 { 2, NULL },
3759};
3760
Kailang Yangdf694da2005-12-05 19:42:22 +01003761
3762/* Mixer combinations
3763 *
3764 * basic: base_output + input + pc_beep + capture
3765 * HP: base_output + input + capture_alt
3766 * HP_3013: hp_3013 + input + capture
3767 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003768 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003769 */
3770
3771static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003772 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003773 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003774 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3775 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3776 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3777 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3778 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003779};
Kailang Yangdf694da2005-12-05 19:42:22 +01003780
3781static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003782 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3783 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3784 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3785 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3787 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003790 { } /* end */
3791};
3792
Kailang Yangdf694da2005-12-05 19:42:22 +01003793static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3794 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3795 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3796 { } /* end */
3797};
3798
3799static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3800 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3801 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3802 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3803 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3806 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3807 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003808 { } /* end */
3809};
3810
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003811/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3812 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3813 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003814static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003815 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003816 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003817 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003818 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3819 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3821 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003822 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003823 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3824 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3825 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003826 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 { } /* end */
3828};
3829
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003830/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3831 * versions of the ALC260 don't act on requests to enable mic bias from NID
3832 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3833 * datasheet doesn't mention this restriction. At this stage it's not clear
3834 * whether this behaviour is intentional or is a hardware bug in chip
3835 * revisions available in early 2006. Therefore for now allow the
3836 * "Headphone Jack Mode" control to span all choices, but if it turns out
3837 * that the lack of mic bias for this NID is intentional we could change the
3838 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3839 *
3840 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3841 * don't appear to make the mic bias available from the "line" jack, even
3842 * though the NID used for this jack (0x14) can supply it. The theory is
3843 * that perhaps Acer have included blocking capacitors between the ALC260
3844 * and the output jack. If this turns out to be the case for all such
3845 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3846 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003847 *
3848 * The C20x Tablet series have a mono internal speaker which is controlled
3849 * via the chip's Mono sum widget and pin complex, so include the necessary
3850 * controls for such models. On models without a "mono speaker" the control
3851 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003852 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003853static struct snd_kcontrol_new alc260_acer_mixer[] = {
3854 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3855 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003856 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003857 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3858 HDA_OUTPUT),
3859 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3860 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003861 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3862 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3864 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3865 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3866 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3867 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3868 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3869 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3870 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3871 { } /* end */
3872};
3873
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003874/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3875 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3876 */
3877static struct snd_kcontrol_new alc260_will_mixer[] = {
3878 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3879 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3881 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3882 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3883 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3884 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3885 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3886 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3887 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3888 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3889 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3890 { } /* end */
3891};
3892
3893/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3894 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3895 */
3896static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3897 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3898 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3900 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3901 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3902 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3903 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3904 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3905 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3906 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3907 { } /* end */
3908};
3909
Kailang Yangdf694da2005-12-05 19:42:22 +01003910/* capture mixer elements */
3911static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003912 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3913 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003914 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3915 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003916 {
3917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003918 /* The multiple "Capture Source" controls confuse alsamixer
3919 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003920 */
3921 /* .name = "Capture Source", */
3922 .name = "Input Source",
3923 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003924 .info = alc_mux_enum_info,
3925 .get = alc_mux_enum_get,
3926 .put = alc_mux_enum_put,
3927 },
3928 { } /* end */
3929};
3930
Kailang Yangdf694da2005-12-05 19:42:22 +01003931static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3932 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3933 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3934 {
3935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3936 /* The multiple "Capture Source" controls confuse alsamixer
3937 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003938 */
3939 /* .name = "Capture Source", */
3940 .name = "Input Source",
3941 .count = 1,
3942 .info = alc_mux_enum_info,
3943 .get = alc_mux_enum_get,
3944 .put = alc_mux_enum_put,
3945 },
3946 { } /* end */
3947};
3948
3949/*
3950 * initialization verbs
3951 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003952static struct hda_verb alc260_init_verbs[] = {
3953 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003955 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003957 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003958 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003960 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003961 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003962 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003964 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003966 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003967 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003968 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003970 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3971 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003972 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003973 /* set connection select to line in (default select for this ADC) */
3974 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003975 /* mute capture amp left and right */
3976 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3977 /* set connection select to line in (default select for this ADC) */
3978 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003979 /* set vol=0 Line-Out mixer amp left and right */
3980 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3981 /* unmute pin widget amp left and right (no gain on this amp) */
3982 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3983 /* set vol=0 HP mixer amp left and right */
3984 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3985 /* unmute pin widget amp left and right (no gain on this amp) */
3986 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3987 /* set vol=0 Mono mixer amp left and right */
3988 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3989 /* unmute pin widget amp left and right (no gain on this amp) */
3990 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3991 /* unmute LINE-2 out pin */
3992 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003993 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3994 * Line In 2 = 0x03
3995 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003996 /* mute analog inputs */
3997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004002 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004003 /* mute Front out path */
4004 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4006 /* mute Headphone out path */
4007 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4009 /* mute Mono out path */
4010 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4011 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004012 { }
4013};
4014
Takashi Iwai474167d2006-05-17 17:17:43 +02004015#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004016static struct hda_verb alc260_hp_init_verbs[] = {
4017 /* Headphone and output */
4018 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4019 /* mono output */
4020 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4021 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4022 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4023 /* Mic2 (front panel) pin widget for input and vref at 80% */
4024 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4025 /* Line In pin widget for input */
4026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4027 /* Line-2 pin widget for output */
4028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4029 /* CD pin widget for input */
4030 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4031 /* unmute amp left and right */
4032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4033 /* set connection select to line in (default select for this ADC) */
4034 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4035 /* unmute Line-Out mixer amp left and right (volume = 0) */
4036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4037 /* mute pin widget amp left and right (no gain on this amp) */
4038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4039 /* unmute HP mixer amp left and right (volume = 0) */
4040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4041 /* mute pin widget amp left and right (no gain on this amp) */
4042 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004043 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4044 * Line In 2 = 0x03
4045 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004046 /* mute analog inputs */
4047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004052 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4053 /* Unmute Front out path */
4054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4056 /* Unmute Headphone out path */
4057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4059 /* Unmute Mono out path */
4060 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4061 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4062 { }
4063};
Takashi Iwai474167d2006-05-17 17:17:43 +02004064#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004065
4066static struct hda_verb alc260_hp_3013_init_verbs[] = {
4067 /* Line out and output */
4068 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4069 /* mono output */
4070 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4071 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4072 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4073 /* Mic2 (front panel) pin widget for input and vref at 80% */
4074 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4075 /* Line In pin widget for input */
4076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4077 /* Headphone pin widget for output */
4078 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4079 /* CD pin widget for input */
4080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4081 /* unmute amp left and right */
4082 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4083 /* set connection select to line in (default select for this ADC) */
4084 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4085 /* unmute Line-Out mixer amp left and right (volume = 0) */
4086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4087 /* mute pin widget amp left and right (no gain on this amp) */
4088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4089 /* unmute HP mixer amp left and right (volume = 0) */
4090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4091 /* mute pin widget amp left and right (no gain on this amp) */
4092 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004093 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4094 * Line In 2 = 0x03
4095 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004096 /* mute analog inputs */
4097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004102 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4103 /* Unmute Front out path */
4104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4105 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4106 /* Unmute Headphone out path */
4107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4109 /* Unmute Mono out path */
4110 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4111 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4112 { }
4113};
4114
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004115/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004116 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4117 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004118 */
4119static struct hda_verb alc260_fujitsu_init_verbs[] = {
4120 /* Disable all GPIOs */
4121 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4122 /* Internal speaker is connected to headphone pin */
4123 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4124 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004126 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4127 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4128 /* Ensure all other unused pins are disabled and muted. */
4129 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004131 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004132 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004133 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004134 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004137
Jonathan Woithef7ace402006-02-28 11:46:14 +01004138 /* Disable digital (SPDIF) pins */
4139 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4140 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004141
Jonathan Woithef7ace402006-02-28 11:46:14 +01004142 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4143 * when acting as an output.
4144 */
4145 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4146
4147 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004148 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4149 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4153 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4154 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4155 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4156 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004157
Jonathan Woithef7ace402006-02-28 11:46:14 +01004158 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4159 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4160 /* Unmute Line1 pin widget output buffer since it starts as an output.
4161 * If the pin mode is changed by the user the pin mode control will
4162 * take care of enabling the pin's input/output buffers as needed.
4163 * Therefore there's no need to enable the input buffer at this
4164 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004165 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004166 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004167 /* Unmute input buffer of pin widget used for Line-in (no equiv
4168 * mixer ctrl)
4169 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004170 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004171
Jonathan Woithef7ace402006-02-28 11:46:14 +01004172 /* Mute capture amp left and right */
4173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4174 /* Set ADC connection select to match default mixer setting - line
4175 * in (on mic1 pin)
4176 */
4177 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004178
Jonathan Woithef7ace402006-02-28 11:46:14 +01004179 /* Do the same for the second ADC: mute capture input amp and
4180 * set ADC connection to line in (on mic1 pin)
4181 */
4182 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4183 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004184
Jonathan Woithef7ace402006-02-28 11:46:14 +01004185 /* Mute all inputs to mixer widget (even unconnected ones) */
4186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004194
4195 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004196};
4197
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004198/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4199 * similar laptops (adapted from Fujitsu init verbs).
4200 */
4201static struct hda_verb alc260_acer_init_verbs[] = {
4202 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4203 * the headphone jack. Turn this on and rely on the standard mute
4204 * methods whenever the user wants to turn these outputs off.
4205 */
4206 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4207 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4208 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4209 /* Internal speaker/Headphone jack is connected to Line-out pin */
4210 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4211 /* Internal microphone/Mic jack is connected to Mic1 pin */
4212 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4213 /* Line In jack is connected to Line1 pin */
4214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004215 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4216 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004217 /* Ensure all other unused pins are disabled and muted. */
4218 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4219 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004220 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4221 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4224 /* Disable digital (SPDIF) pins */
4225 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4226 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4227
4228 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4229 * bus when acting as outputs.
4230 */
4231 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4232 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4233
4234 /* Start with output sum widgets muted and their output gains at min */
4235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4242 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4243 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4244
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004245 /* Unmute Line-out pin widget amp left and right
4246 * (no equiv mixer ctrl)
4247 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004248 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004249 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4250 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004251 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4252 * inputs. If the pin mode is changed by the user the pin mode control
4253 * will take care of enabling the pin's input/output buffers as needed.
4254 * Therefore there's no need to enable the input buffer at this
4255 * stage.
4256 */
4257 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4259
4260 /* Mute capture amp left and right */
4261 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4262 /* Set ADC connection select to match default mixer setting - mic
4263 * (on mic1 pin)
4264 */
4265 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4266
4267 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004268 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004269 */
4270 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004271 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004272
4273 /* Mute all inputs to mixer widget (even unconnected ones) */
4274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4282
4283 { }
4284};
4285
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004286static struct hda_verb alc260_will_verbs[] = {
4287 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4288 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4289 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4290 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4291 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4292 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4293 {}
4294};
4295
4296static struct hda_verb alc260_replacer_672v_verbs[] = {
4297 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4298 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4299 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4300
4301 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4302 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4303 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4304
4305 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4306 {}
4307};
4308
4309/* toggle speaker-output according to the hp-jack state */
4310static void alc260_replacer_672v_automute(struct hda_codec *codec)
4311{
4312 unsigned int present;
4313
4314 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4315 present = snd_hda_codec_read(codec, 0x0f, 0,
4316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4317 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004318 snd_hda_codec_write_cache(codec, 0x01, 0,
4319 AC_VERB_SET_GPIO_DATA, 1);
4320 snd_hda_codec_write_cache(codec, 0x0f, 0,
4321 AC_VERB_SET_PIN_WIDGET_CONTROL,
4322 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004323 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004324 snd_hda_codec_write_cache(codec, 0x01, 0,
4325 AC_VERB_SET_GPIO_DATA, 0);
4326 snd_hda_codec_write_cache(codec, 0x0f, 0,
4327 AC_VERB_SET_PIN_WIDGET_CONTROL,
4328 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004329 }
4330}
4331
4332static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4333 unsigned int res)
4334{
4335 if ((res >> 26) == ALC880_HP_EVENT)
4336 alc260_replacer_672v_automute(codec);
4337}
4338
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004339/* Test configuration for debugging, modelled after the ALC880 test
4340 * configuration.
4341 */
4342#ifdef CONFIG_SND_DEBUG
4343static hda_nid_t alc260_test_dac_nids[1] = {
4344 0x02,
4345};
4346static hda_nid_t alc260_test_adc_nids[2] = {
4347 0x04, 0x05,
4348};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004349/* For testing the ALC260, each input MUX needs its own definition since
4350 * the signal assignments are different. This assumes that the first ADC
4351 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004352 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004353static struct hda_input_mux alc260_test_capture_sources[2] = {
4354 {
4355 .num_items = 7,
4356 .items = {
4357 { "MIC1 pin", 0x0 },
4358 { "MIC2 pin", 0x1 },
4359 { "LINE1 pin", 0x2 },
4360 { "LINE2 pin", 0x3 },
4361 { "CD pin", 0x4 },
4362 { "LINE-OUT pin", 0x5 },
4363 { "HP-OUT pin", 0x6 },
4364 },
4365 },
4366 {
4367 .num_items = 8,
4368 .items = {
4369 { "MIC1 pin", 0x0 },
4370 { "MIC2 pin", 0x1 },
4371 { "LINE1 pin", 0x2 },
4372 { "LINE2 pin", 0x3 },
4373 { "CD pin", 0x4 },
4374 { "Mixer", 0x5 },
4375 { "LINE-OUT pin", 0x6 },
4376 { "HP-OUT pin", 0x7 },
4377 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004378 },
4379};
4380static struct snd_kcontrol_new alc260_test_mixer[] = {
4381 /* Output driver widgets */
4382 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4383 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4384 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4385 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4386 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4387 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4388
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004389 /* Modes for retasking pin widgets
4390 * Note: the ALC260 doesn't seem to act on requests to enable mic
4391 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4392 * mention this restriction. At this stage it's not clear whether
4393 * this behaviour is intentional or is a hardware bug in chip
4394 * revisions available at least up until early 2006. Therefore for
4395 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4396 * choices, but if it turns out that the lack of mic bias for these
4397 * NIDs is intentional we could change their modes from
4398 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4399 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004400 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4401 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4402 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4403 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4404 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4405 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4406
4407 /* Loopback mixer controls */
4408 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4409 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4410 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4411 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4412 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4413 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4414 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4415 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4416 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4417 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4418 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4419 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4420 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4421 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4422 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4423 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004424
4425 /* Controls for GPIO pins, assuming they are configured as outputs */
4426 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4427 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4428 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4429 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4430
Jonathan Woithe92621f12006-02-28 11:47:47 +01004431 /* Switches to allow the digital IO pins to be enabled. The datasheet
4432 * is ambigious as to which NID is which; testing on laptops which
4433 * make this output available should provide clarification.
4434 */
4435 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4436 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4437
Jonathan Woithef8225f62008-01-08 12:16:54 +01004438 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4439 * this output to turn on an external amplifier.
4440 */
4441 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4442 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4443
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004444 { } /* end */
4445};
4446static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004447 /* Enable all GPIOs as outputs with an initial value of 0 */
4448 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4449 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4450 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4451
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004452 /* Enable retasking pins as output, initially without power amp */
4453 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4454 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4457 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4458 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4459
Jonathan Woithe92621f12006-02-28 11:47:47 +01004460 /* Disable digital (SPDIF) pins initially, but users can enable
4461 * them via a mixer switch. In the case of SPDIF-out, this initverb
4462 * payload also sets the generation to 0, output to be in "consumer"
4463 * PCM format, copyright asserted, no pre-emphasis and no validity
4464 * control.
4465 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004466 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4467 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4468
Jonathan Woithef7ace402006-02-28 11:46:14 +01004469 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004470 * OUT1 sum bus when acting as an output.
4471 */
4472 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4473 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4474 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4475 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4476
4477 /* Start with output sum widgets muted and their output gains at min */
4478 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4479 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4480 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4481 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4484 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4485 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4486 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4487
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004488 /* Unmute retasking pin widget output buffers since the default
4489 * state appears to be output. As the pin mode is changed by the
4490 * user the pin mode control will take care of enabling the pin's
4491 * input/output buffers as needed.
4492 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004493 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4494 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4497 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4498 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4499 /* Also unmute the mono-out pin widget */
4500 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4501
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004502 /* Mute capture amp left and right */
4503 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004504 /* Set ADC connection select to match default mixer setting (mic1
4505 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004506 */
4507 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4508
4509 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004510 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004511 */
4512 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4513 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4514
4515 /* Mute all inputs to mixer widget (even unconnected ones) */
4516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4519 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4520 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4524
4525 { }
4526};
4527#endif
4528
Linus Torvalds1da177e2005-04-16 15:20:36 -07004529static struct hda_pcm_stream alc260_pcm_analog_playback = {
4530 .substreams = 1,
4531 .channels_min = 2,
4532 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004533};
4534
4535static struct hda_pcm_stream alc260_pcm_analog_capture = {
4536 .substreams = 1,
4537 .channels_min = 2,
4538 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004539};
4540
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004541#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4542#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4543
Kailang Yangdf694da2005-12-05 19:42:22 +01004544/*
4545 * for BIOS auto-configuration
4546 */
4547
4548static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4549 const char *pfx)
4550{
4551 hda_nid_t nid_vol;
4552 unsigned long vol_val, sw_val;
4553 char name[32];
4554 int err;
4555
4556 if (nid >= 0x0f && nid < 0x11) {
4557 nid_vol = nid - 0x7;
4558 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4559 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4560 } else if (nid == 0x11) {
4561 nid_vol = nid - 0x7;
4562 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4563 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4564 } else if (nid >= 0x12 && nid <= 0x15) {
4565 nid_vol = 0x08;
4566 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4567 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4568 } else
4569 return 0; /* N/A */
4570
4571 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004572 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4573 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004574 return err;
4575 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004576 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4577 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004578 return err;
4579 return 1;
4580}
4581
4582/* add playback controls from the parsed DAC table */
4583static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4584 const struct auto_pin_cfg *cfg)
4585{
4586 hda_nid_t nid;
4587 int err;
4588
4589 spec->multiout.num_dacs = 1;
4590 spec->multiout.dac_nids = spec->private_dac_nids;
4591 spec->multiout.dac_nids[0] = 0x02;
4592
4593 nid = cfg->line_out_pins[0];
4594 if (nid) {
4595 err = alc260_add_playback_controls(spec, nid, "Front");
4596 if (err < 0)
4597 return err;
4598 }
4599
Takashi Iwai82bc9552006-03-21 11:24:42 +01004600 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004601 if (nid) {
4602 err = alc260_add_playback_controls(spec, nid, "Speaker");
4603 if (err < 0)
4604 return err;
4605 }
4606
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004607 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004608 if (nid) {
4609 err = alc260_add_playback_controls(spec, nid, "Headphone");
4610 if (err < 0)
4611 return err;
4612 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004613 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004614}
4615
4616/* create playback/capture controls for input pins */
4617static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4618 const struct auto_pin_cfg *cfg)
4619{
Kailang Yangdf694da2005-12-05 19:42:22 +01004620 struct hda_input_mux *imux = &spec->private_imux;
4621 int i, err, idx;
4622
4623 for (i = 0; i < AUTO_PIN_LAST; i++) {
4624 if (cfg->input_pins[i] >= 0x12) {
4625 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004626 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004627 auto_pin_cfg_labels[i], idx,
4628 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004629 if (err < 0)
4630 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004631 imux->items[imux->num_items].label =
4632 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004633 imux->items[imux->num_items].index = idx;
4634 imux->num_items++;
4635 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004637 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004638 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004639 auto_pin_cfg_labels[i], idx,
4640 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004641 if (err < 0)
4642 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004643 imux->items[imux->num_items].label =
4644 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004645 imux->items[imux->num_items].index = idx;
4646 imux->num_items++;
4647 }
4648 }
4649 return 0;
4650}
4651
4652static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4653 hda_nid_t nid, int pin_type,
4654 int sel_idx)
4655{
4656 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004657 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4658 pin_type);
4659 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4660 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004661 /* need the manual connection? */
4662 if (nid >= 0x12) {
4663 int idx = nid - 0x12;
4664 snd_hda_codec_write(codec, idx + 0x0b, 0,
4665 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004666 }
4667}
4668
4669static void alc260_auto_init_multi_out(struct hda_codec *codec)
4670{
4671 struct alc_spec *spec = codec->spec;
4672 hda_nid_t nid;
4673
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004674 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004675 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004676 if (nid) {
4677 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4678 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4679 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004680
Takashi Iwai82bc9552006-03-21 11:24:42 +01004681 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004682 if (nid)
4683 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4684
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004685 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004686 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004687 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004688}
Kailang Yangdf694da2005-12-05 19:42:22 +01004689
4690#define ALC260_PIN_CD_NID 0x16
4691static void alc260_auto_init_analog_input(struct hda_codec *codec)
4692{
4693 struct alc_spec *spec = codec->spec;
4694 int i;
4695
4696 for (i = 0; i < AUTO_PIN_LAST; i++) {
4697 hda_nid_t nid = spec->autocfg.input_pins[i];
4698 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004699 snd_hda_codec_write(codec, nid, 0,
4700 AC_VERB_SET_PIN_WIDGET_CONTROL,
4701 i <= AUTO_PIN_FRONT_MIC ?
4702 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004703 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004704 snd_hda_codec_write(codec, nid, 0,
4705 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 AMP_OUT_MUTE);
4707 }
4708 }
4709}
4710
4711/*
4712 * generic initialization of ADC, input mixers and output mixers
4713 */
4714static struct hda_verb alc260_volume_init_verbs[] = {
4715 /*
4716 * Unmute ADC0-1 and set the default input to mic-in
4717 */
4718 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4719 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4720 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4721 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4722
4723 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4724 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004725 * Note: PASD motherboards uses the Line In 2 as the input for
4726 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 */
4728 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004729 /* mute analog inputs */
4730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004735
4736 /*
4737 * Set up output mixers (0x08 - 0x0a)
4738 */
4739 /* set vol=0 to output mixers */
4740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4743 /* set up input amps for analog loopback */
4744 /* Amp Indices: DAC = 0, mixer = 1 */
4745 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4746 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4747 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4748 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4749 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4751
4752 { }
4753};
4754
4755static int alc260_parse_auto_config(struct hda_codec *codec)
4756{
4757 struct alc_spec *spec = codec->spec;
4758 unsigned int wcap;
4759 int err;
4760 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4761
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004762 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4763 alc260_ignore);
4764 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004765 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004766 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4767 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004768 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004769 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004770 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004771 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4772 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004773 return err;
4774
4775 spec->multiout.max_channels = 2;
4776
4777 if (spec->autocfg.dig_out_pin)
4778 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4779 if (spec->kctl_alloc)
4780 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4781
4782 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4783
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004784 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004785 spec->input_mux = &spec->private_imux;
4786
4787 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004788 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004789 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4790 if (wcap != AC_WID_AUD_IN) {
4791 spec->adc_nids = alc260_adc_nids_alt;
4792 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4793 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004794 } else {
4795 spec->adc_nids = alc260_adc_nids;
4796 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4797 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004798 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004799 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004800
4801 return 1;
4802}
4803
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004804/* additional initialization for auto-configuration model */
4805static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004806{
Kailang Yangdf694da2005-12-05 19:42:22 +01004807 alc260_auto_init_multi_out(codec);
4808 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004809}
4810
Takashi Iwaicb53c622007-08-10 17:21:45 +02004811#ifdef CONFIG_SND_HDA_POWER_SAVE
4812static struct hda_amp_list alc260_loopbacks[] = {
4813 { 0x07, HDA_INPUT, 0 },
4814 { 0x07, HDA_INPUT, 1 },
4815 { 0x07, HDA_INPUT, 2 },
4816 { 0x07, HDA_INPUT, 3 },
4817 { 0x07, HDA_INPUT, 4 },
4818 { } /* end */
4819};
4820#endif
4821
Kailang Yangdf694da2005-12-05 19:42:22 +01004822/*
4823 * ALC260 configurations
4824 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004825static const char *alc260_models[ALC260_MODEL_LAST] = {
4826 [ALC260_BASIC] = "basic",
4827 [ALC260_HP] = "hp",
4828 [ALC260_HP_3013] = "hp-3013",
4829 [ALC260_FUJITSU_S702X] = "fujitsu",
4830 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004831 [ALC260_WILL] = "will",
4832 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004833#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004834 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004835#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004836 [ALC260_AUTO] = "auto",
4837};
4838
4839static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004840 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004841 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004842 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004843 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004844 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4845 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4846 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4847 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4848 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4849 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4850 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4851 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4852 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4853 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4854 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4855 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004856 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004857 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02004858 {}
4859};
4860
Kailang Yangdf694da2005-12-05 19:42:22 +01004861static struct alc_config_preset alc260_presets[] = {
4862 [ALC260_BASIC] = {
4863 .mixers = { alc260_base_output_mixer,
4864 alc260_input_mixer,
4865 alc260_pc_beep_mixer,
4866 alc260_capture_mixer },
4867 .init_verbs = { alc260_init_verbs },
4868 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4869 .dac_nids = alc260_dac_nids,
4870 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4871 .adc_nids = alc260_adc_nids,
4872 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4873 .channel_mode = alc260_modes,
4874 .input_mux = &alc260_capture_source,
4875 },
4876 [ALC260_HP] = {
4877 .mixers = { alc260_base_output_mixer,
4878 alc260_input_mixer,
4879 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004880 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004881 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4882 .dac_nids = alc260_dac_nids,
4883 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4884 .adc_nids = alc260_hp_adc_nids,
4885 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4886 .channel_mode = alc260_modes,
4887 .input_mux = &alc260_capture_source,
4888 },
4889 [ALC260_HP_3013] = {
4890 .mixers = { alc260_hp_3013_mixer,
4891 alc260_input_mixer,
4892 alc260_capture_alt_mixer },
4893 .init_verbs = { alc260_hp_3013_init_verbs },
4894 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4895 .dac_nids = alc260_dac_nids,
4896 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4897 .adc_nids = alc260_hp_adc_nids,
4898 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4899 .channel_mode = alc260_modes,
4900 .input_mux = &alc260_capture_source,
4901 },
4902 [ALC260_FUJITSU_S702X] = {
4903 .mixers = { alc260_fujitsu_mixer,
4904 alc260_capture_mixer },
4905 .init_verbs = { alc260_fujitsu_init_verbs },
4906 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4907 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004908 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4909 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004910 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4911 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004912 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4913 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004914 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004915 [ALC260_ACER] = {
4916 .mixers = { alc260_acer_mixer,
4917 alc260_capture_mixer },
4918 .init_verbs = { alc260_acer_init_verbs },
4919 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4920 .dac_nids = alc260_dac_nids,
4921 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4922 .adc_nids = alc260_dual_adc_nids,
4923 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4924 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004925 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4926 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004927 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004928 [ALC260_WILL] = {
4929 .mixers = { alc260_will_mixer,
4930 alc260_capture_mixer },
4931 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4932 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4933 .dac_nids = alc260_dac_nids,
4934 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4935 .adc_nids = alc260_adc_nids,
4936 .dig_out_nid = ALC260_DIGOUT_NID,
4937 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4938 .channel_mode = alc260_modes,
4939 .input_mux = &alc260_capture_source,
4940 },
4941 [ALC260_REPLACER_672V] = {
4942 .mixers = { alc260_replacer_672v_mixer,
4943 alc260_capture_mixer },
4944 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4945 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4946 .dac_nids = alc260_dac_nids,
4947 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4948 .adc_nids = alc260_adc_nids,
4949 .dig_out_nid = ALC260_DIGOUT_NID,
4950 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4951 .channel_mode = alc260_modes,
4952 .input_mux = &alc260_capture_source,
4953 .unsol_event = alc260_replacer_672v_unsol_event,
4954 .init_hook = alc260_replacer_672v_automute,
4955 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004956#ifdef CONFIG_SND_DEBUG
4957 [ALC260_TEST] = {
4958 .mixers = { alc260_test_mixer,
4959 alc260_capture_mixer },
4960 .init_verbs = { alc260_test_init_verbs },
4961 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4962 .dac_nids = alc260_test_dac_nids,
4963 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4964 .adc_nids = alc260_test_adc_nids,
4965 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4966 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004967 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4968 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004969 },
4970#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004971};
4972
Linus Torvalds1da177e2005-04-16 15:20:36 -07004973static int patch_alc260(struct hda_codec *codec)
4974{
4975 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004976 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004977
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004978 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004979 if (spec == NULL)
4980 return -ENOMEM;
4981
4982 codec->spec = spec;
4983
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004984 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4985 alc260_models,
4986 alc260_cfg_tbl);
4987 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004988 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4989 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004990 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004991 }
4992
Kailang Yangdf694da2005-12-05 19:42:22 +01004993 if (board_config == ALC260_AUTO) {
4994 /* automatic parse from the BIOS config */
4995 err = alc260_parse_auto_config(codec);
4996 if (err < 0) {
4997 alc_free(codec);
4998 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004999 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005000 printk(KERN_INFO
5001 "hda_codec: Cannot set up configuration "
5002 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005003 board_config = ALC260_BASIC;
5004 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005005 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005006
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 if (board_config != ALC260_AUTO)
5008 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005009
5010 spec->stream_name_analog = "ALC260 Analog";
5011 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5012 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5013
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005014 spec->stream_name_digital = "ALC260 Digital";
5015 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5016 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5017
Takashi Iwai2134ea42008-01-10 16:53:55 +01005018 spec->vmaster_nid = 0x08;
5019
Linus Torvalds1da177e2005-04-16 15:20:36 -07005020 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005021 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005022 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005023#ifdef CONFIG_SND_HDA_POWER_SAVE
5024 if (!spec->loopback.amplist)
5025 spec->loopback.amplist = alc260_loopbacks;
5026#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005027
5028 return 0;
5029}
5030
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005031
Linus Torvalds1da177e2005-04-16 15:20:36 -07005032/*
5033 * ALC882 support
5034 *
5035 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5036 * configuration. Each pin widget can choose any input DACs and a mixer.
5037 * Each ADC is connected from a mixer of all inputs. This makes possible
5038 * 6-channel independent captures.
5039 *
5040 * In addition, an independent DAC for the multi-playback (not used in this
5041 * driver yet).
5042 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005043#define ALC882_DIGOUT_NID 0x06
5044#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005045
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005046static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005047 { 8, NULL }
5048};
5049
5050static hda_nid_t alc882_dac_nids[4] = {
5051 /* front, rear, clfe, rear_surr */
5052 0x02, 0x03, 0x04, 0x05
5053};
5054
Kailang Yangdf694da2005-12-05 19:42:22 +01005055/* identical with ALC880 */
5056#define alc882_adc_nids alc880_adc_nids
5057#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005058
5059/* input MUX */
5060/* FIXME: should be a matrix-type input source selection */
5061
5062static struct hda_input_mux alc882_capture_source = {
5063 .num_items = 4,
5064 .items = {
5065 { "Mic", 0x0 },
5066 { "Front Mic", 0x1 },
5067 { "Line", 0x2 },
5068 { "CD", 0x4 },
5069 },
5070};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005071#define alc882_mux_enum_info alc_mux_enum_info
5072#define alc882_mux_enum_get alc_mux_enum_get
5073
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005074static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5075 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005076{
5077 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5078 struct alc_spec *spec = codec->spec;
5079 const struct hda_input_mux *imux = spec->input_mux;
5080 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5081 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5082 hda_nid_t nid = capture_mixers[adc_idx];
5083 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5084 unsigned int i, idx;
5085
5086 idx = ucontrol->value.enumerated.item[0];
5087 if (idx >= imux->num_items)
5088 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005089 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005090 return 0;
5091 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005092 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5093 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005094 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005095 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005096 }
5097 *cur_val = idx;
5098 return 1;
5099}
5100
Kailang Yangdf694da2005-12-05 19:42:22 +01005101/*
Kailang Yang272a5272007-05-14 11:00:38 +02005102 * 2ch mode
5103 */
5104static struct hda_verb alc882_3ST_ch2_init[] = {
5105 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5106 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5107 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5108 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5109 { } /* end */
5110};
5111
5112/*
5113 * 6ch mode
5114 */
5115static struct hda_verb alc882_3ST_ch6_init[] = {
5116 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5117 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5118 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5119 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5120 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5121 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5122 { } /* end */
5123};
5124
5125static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5126 { 2, alc882_3ST_ch2_init },
5127 { 6, alc882_3ST_ch6_init },
5128};
5129
5130/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005131 * 6ch mode
5132 */
5133static struct hda_verb alc882_sixstack_ch6_init[] = {
5134 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5135 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5136 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5137 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5138 { } /* end */
5139};
5140
5141/*
5142 * 8ch mode
5143 */
5144static struct hda_verb alc882_sixstack_ch8_init[] = {
5145 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5146 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5147 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5148 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5149 { } /* end */
5150};
5151
5152static struct hda_channel_mode alc882_sixstack_modes[2] = {
5153 { 6, alc882_sixstack_ch6_init },
5154 { 8, alc882_sixstack_ch8_init },
5155};
5156
Takashi Iwai87350ad2007-08-16 18:19:38 +02005157/*
5158 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5159 */
5160
5161/*
5162 * 2ch mode
5163 */
5164static struct hda_verb alc885_mbp_ch2_init[] = {
5165 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5166 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5167 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5168 { } /* end */
5169};
5170
5171/*
5172 * 6ch mode
5173 */
5174static struct hda_verb alc885_mbp_ch6_init[] = {
5175 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5176 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5177 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5178 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5179 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5180 { } /* end */
5181};
5182
5183static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5184 { 2, alc885_mbp_ch2_init },
5185 { 6, alc885_mbp_ch6_init },
5186};
5187
5188
Linus Torvalds1da177e2005-04-16 15:20:36 -07005189/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5190 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5191 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005192static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005193 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005194 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005195 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005196 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005197 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5198 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005199 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5200 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005201 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005202 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5204 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5205 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5207 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005209 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005212 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5214 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5215 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005216 { } /* end */
5217};
5218
Takashi Iwai87350ad2007-08-16 18:19:38 +02005219static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5221 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5222 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5223 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5225 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5227 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005228 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5230 { } /* end */
5231};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005232static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5234 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5242 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5243 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5244 { } /* end */
5245};
5246
Kailang Yang272a5272007-05-14 11:00:38 +02005247static struct snd_kcontrol_new alc882_targa_mixer[] = {
5248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5249 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5256 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005257 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005258 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5259 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005260 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005261 { } /* end */
5262};
5263
5264/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5265 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5266 */
5267static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5269 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5271 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5272 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5273 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5274 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5275 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5276 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5277 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005280 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005281 { } /* end */
5282};
5283
Takashi Iwai914759b2007-09-06 14:52:04 +02005284static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5285 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5286 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5287 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5288 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5289 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5290 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5291 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5293 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5295 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5296 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5297 { } /* end */
5298};
5299
Kailang Yangdf694da2005-12-05 19:42:22 +01005300static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5301 {
5302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5303 .name = "Channel Mode",
5304 .info = alc_ch_mode_info,
5305 .get = alc_ch_mode_get,
5306 .put = alc_ch_mode_put,
5307 },
5308 { } /* end */
5309};
5310
Linus Torvalds1da177e2005-04-16 15:20:36 -07005311static struct hda_verb alc882_init_verbs[] = {
5312 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5319 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005324 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005325 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005328
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005329 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005332 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005333 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005337 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005338 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005339 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005340 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005341 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005342 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005344 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005345 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005346 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5348 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5351 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5354 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5356 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5357 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005358 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005360
5361 /* FIXME: use matrix-type input source selection */
5362 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5363 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005368 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005373 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5378 /* ADC1: mute amp left and right */
5379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005380 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005381 /* ADC2: mute amp left and right */
5382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005383 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005384 /* ADC3: mute amp left and right */
5385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005386 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005387
5388 { }
5389};
5390
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005391static struct hda_verb alc882_eapd_verbs[] = {
5392 /* change to EAPD mode */
5393 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005394 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005395 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005396};
5397
Tobin Davis9102cd12006-12-15 10:02:12 +01005398/* Mac Pro test */
5399static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5400 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5401 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5405 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5406 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5407 { } /* end */
5408};
5409
5410static struct hda_verb alc882_macpro_init_verbs[] = {
5411 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5415 /* Front Pin: output 0 (0x0c) */
5416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5417 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5419 /* Front Mic pin: input vref at 80% */
5420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5422 /* Speaker: output */
5423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5424 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5425 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5426 /* Headphone output (output 0 - 0x0c) */
5427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5428 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5429 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5430
5431 /* FIXME: use matrix-type input source selection */
5432 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5433 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5438 /* Input mixer2 */
5439 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5443 /* Input mixer3 */
5444 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5448 /* ADC1: mute amp left and right */
5449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5450 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5451 /* ADC2: mute amp left and right */
5452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5453 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5454 /* ADC3: mute amp left and right */
5455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5456 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5457
5458 { }
5459};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005460
Takashi Iwai87350ad2007-08-16 18:19:38 +02005461/* Macbook Pro rev3 */
5462static struct hda_verb alc885_mbp3_init_verbs[] = {
5463 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5467 /* Rear mixer */
5468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5471 /* Front Pin: output 0 (0x0c) */
5472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5474 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5475 /* HP Pin: output 0 (0x0d) */
5476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5479 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5480 /* Mic (rear) pin: input vref at 80% */
5481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5483 /* Front Mic pin: input vref at 80% */
5484 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5486 /* Line In pin: use output 1 when in LineOut mode */
5487 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5489 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5490
5491 /* FIXME: use matrix-type input source selection */
5492 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5493 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5498 /* Input mixer2 */
5499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5503 /* Input mixer3 */
5504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5508 /* ADC1: mute amp left and right */
5509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5510 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5511 /* ADC2: mute amp left and right */
5512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5513 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5514 /* ADC3: mute amp left and right */
5515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5516 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5517
5518 { }
5519};
5520
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005521/* iMac 24 mixer. */
5522static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5523 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5524 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5525 { } /* end */
5526};
5527
5528/* iMac 24 init verbs. */
5529static struct hda_verb alc885_imac24_init_verbs[] = {
5530 /* Internal speakers: output 0 (0x0c) */
5531 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5532 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5533 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5534 /* Internal speakers: output 0 (0x0c) */
5535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5536 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5537 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5538 /* Headphone: output 0 (0x0c) */
5539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5541 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5542 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5543 /* Front Mic: input vref at 80% */
5544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5546 { }
5547};
5548
5549/* Toggle speaker-output according to the hp-jack state */
5550static void alc885_imac24_automute(struct hda_codec *codec)
5551{
5552 unsigned int present;
5553
5554 present = snd_hda_codec_read(codec, 0x14, 0,
5555 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005556 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5557 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5558 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5559 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005560}
5561
5562/* Processes unsolicited events. */
5563static void alc885_imac24_unsol_event(struct hda_codec *codec,
5564 unsigned int res)
5565{
5566 /* Headphone insertion or removal. */
5567 if ((res >> 26) == ALC880_HP_EVENT)
5568 alc885_imac24_automute(codec);
5569}
5570
Takashi Iwai87350ad2007-08-16 18:19:38 +02005571static void alc885_mbp3_automute(struct hda_codec *codec)
5572{
5573 unsigned int present;
5574
5575 present = snd_hda_codec_read(codec, 0x15, 0,
5576 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5577 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5578 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5579 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5580 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5581
5582}
5583static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5584 unsigned int res)
5585{
5586 /* Headphone insertion or removal. */
5587 if ((res >> 26) == ALC880_HP_EVENT)
5588 alc885_mbp3_automute(codec);
5589}
5590
5591
Kailang Yang272a5272007-05-14 11:00:38 +02005592static struct hda_verb alc882_targa_verbs[] = {
5593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5595
5596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5597 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5598
5599 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5600 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5602
5603 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5604 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5605 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5606 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5607 { } /* end */
5608};
5609
5610/* toggle speaker-output according to the hp-jack state */
5611static void alc882_targa_automute(struct hda_codec *codec)
5612{
5613 unsigned int present;
5614
5615 present = snd_hda_codec_read(codec, 0x14, 0,
5616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005617 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5618 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005619 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5620 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005621}
5622
5623static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5624{
5625 /* Looks like the unsol event is incompatible with the standard
5626 * definition. 4bit tag is placed at 26 bit!
5627 */
5628 if (((res >> 26) == ALC880_HP_EVENT)) {
5629 alc882_targa_automute(codec);
5630 }
5631}
5632
5633static struct hda_verb alc882_asus_a7j_verbs[] = {
5634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5636
5637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5640
5641 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5643 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5644
5645 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5646 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5647 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5648 { } /* end */
5649};
5650
Takashi Iwai914759b2007-09-06 14:52:04 +02005651static struct hda_verb alc882_asus_a7m_verbs[] = {
5652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5654
5655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5657 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5658
5659 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5660 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5661 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5662
5663 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5664 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5665 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5666 { } /* end */
5667};
5668
Tobin Davis9102cd12006-12-15 10:02:12 +01005669static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5670{
5671 unsigned int gpiostate, gpiomask, gpiodir;
5672
5673 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5674 AC_VERB_GET_GPIO_DATA, 0);
5675
5676 if (!muted)
5677 gpiostate |= (1 << pin);
5678 else
5679 gpiostate &= ~(1 << pin);
5680
5681 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5682 AC_VERB_GET_GPIO_MASK, 0);
5683 gpiomask |= (1 << pin);
5684
5685 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5686 AC_VERB_GET_GPIO_DIRECTION, 0);
5687 gpiodir |= (1 << pin);
5688
5689
5690 snd_hda_codec_write(codec, codec->afg, 0,
5691 AC_VERB_SET_GPIO_MASK, gpiomask);
5692 snd_hda_codec_write(codec, codec->afg, 0,
5693 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5694
5695 msleep(1);
5696
5697 snd_hda_codec_write(codec, codec->afg, 0,
5698 AC_VERB_SET_GPIO_DATA, gpiostate);
5699}
5700
Takashi Iwai7debbe52007-08-16 15:01:03 +02005701/* set up GPIO at initialization */
5702static void alc885_macpro_init_hook(struct hda_codec *codec)
5703{
5704 alc882_gpio_mute(codec, 0, 0);
5705 alc882_gpio_mute(codec, 1, 0);
5706}
5707
5708/* set up GPIO and update auto-muting at initialization */
5709static void alc885_imac24_init_hook(struct hda_codec *codec)
5710{
5711 alc885_macpro_init_hook(codec);
5712 alc885_imac24_automute(codec);
5713}
5714
Kailang Yangdf694da2005-12-05 19:42:22 +01005715/*
5716 * generic initialization of ADC, input mixers and output mixers
5717 */
5718static struct hda_verb alc882_auto_init_verbs[] = {
5719 /*
5720 * Unmute ADC0-2 and set the default input to mic-in
5721 */
5722 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5724 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5726 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5728
Takashi Iwaicb53c622007-08-10 17:21:45 +02005729 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005730 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005731 * Note: PASD motherboards uses the Line In 2 as the input for
5732 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005733 */
5734 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005740
5741 /*
5742 * Set up output mixers (0x0c - 0x0f)
5743 */
5744 /* set vol=0 to output mixers */
5745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5749 /* set up input amps for analog loopback */
5750 /* Amp Indices: DAC = 0, mixer = 1 */
5751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5757 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5758 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5759 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5760 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5761
5762 /* FIXME: use matrix-type input source selection */
5763 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5764 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5765 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5769 /* Input mixer2 */
5770 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5774 /* Input mixer3 */
5775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5779
5780 { }
5781};
5782
5783/* capture mixer elements */
5784static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5785 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5786 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5787 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5788 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5789 {
5790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5791 /* The multiple "Capture Source" controls confuse alsamixer
5792 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005793 */
5794 /* .name = "Capture Source", */
5795 .name = "Input Source",
5796 .count = 2,
5797 .info = alc882_mux_enum_info,
5798 .get = alc882_mux_enum_get,
5799 .put = alc882_mux_enum_put,
5800 },
5801 { } /* end */
5802};
5803
5804static struct snd_kcontrol_new alc882_capture_mixer[] = {
5805 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5806 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5807 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5808 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5809 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5810 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5811 {
5812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5813 /* The multiple "Capture Source" controls confuse alsamixer
5814 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005815 */
5816 /* .name = "Capture Source", */
5817 .name = "Input Source",
5818 .count = 3,
5819 .info = alc882_mux_enum_info,
5820 .get = alc882_mux_enum_get,
5821 .put = alc882_mux_enum_put,
5822 },
5823 { } /* end */
5824};
5825
Takashi Iwaicb53c622007-08-10 17:21:45 +02005826#ifdef CONFIG_SND_HDA_POWER_SAVE
5827#define alc882_loopbacks alc880_loopbacks
5828#endif
5829
Kailang Yangdf694da2005-12-05 19:42:22 +01005830/* pcm configuration: identiacal with ALC880 */
5831#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5832#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5833#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5834#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5835
5836/*
5837 * configuration and preset
5838 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005839static const char *alc882_models[ALC882_MODEL_LAST] = {
5840 [ALC882_3ST_DIG] = "3stack-dig",
5841 [ALC882_6ST_DIG] = "6stack-dig",
5842 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005843 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005844 [ALC882_TARGA] = "targa",
5845 [ALC882_ASUS_A7J] = "asus-a7j",
5846 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005847 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005848 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005849 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005850 [ALC882_AUTO] = "auto",
5851};
5852
5853static struct snd_pci_quirk alc882_cfg_tbl[] = {
5854 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005855 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005856 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005857 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005858 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005859 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005860 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005861 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5862 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5863 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5864 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01005865 {}
5866};
5867
5868static struct alc_config_preset alc882_presets[] = {
5869 [ALC882_3ST_DIG] = {
5870 .mixers = { alc882_base_mixer },
5871 .init_verbs = { alc882_init_verbs },
5872 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5873 .dac_nids = alc882_dac_nids,
5874 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005875 .dig_in_nid = ALC882_DIGIN_NID,
5876 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5877 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005878 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005879 .input_mux = &alc882_capture_source,
5880 },
5881 [ALC882_6ST_DIG] = {
5882 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5883 .init_verbs = { alc882_init_verbs },
5884 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5885 .dac_nids = alc882_dac_nids,
5886 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005887 .dig_in_nid = ALC882_DIGIN_NID,
5888 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5889 .channel_mode = alc882_sixstack_modes,
5890 .input_mux = &alc882_capture_source,
5891 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005892 [ALC882_ARIMA] = {
5893 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5894 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5895 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5896 .dac_nids = alc882_dac_nids,
5897 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5898 .channel_mode = alc882_sixstack_modes,
5899 .input_mux = &alc882_capture_source,
5900 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005901 [ALC882_W2JC] = {
5902 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5903 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5904 alc880_gpio1_init_verbs },
5905 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5906 .dac_nids = alc882_dac_nids,
5907 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5908 .channel_mode = alc880_threestack_modes,
5909 .need_dac_fix = 1,
5910 .input_mux = &alc882_capture_source,
5911 .dig_out_nid = ALC882_DIGOUT_NID,
5912 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005913 [ALC885_MBP3] = {
5914 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5915 .init_verbs = { alc885_mbp3_init_verbs,
5916 alc880_gpio1_init_verbs },
5917 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5918 .dac_nids = alc882_dac_nids,
5919 .channel_mode = alc885_mbp_6ch_modes,
5920 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5921 .input_mux = &alc882_capture_source,
5922 .dig_out_nid = ALC882_DIGOUT_NID,
5923 .dig_in_nid = ALC882_DIGIN_NID,
5924 .unsol_event = alc885_mbp3_unsol_event,
5925 .init_hook = alc885_mbp3_automute,
5926 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005927 [ALC885_MACPRO] = {
5928 .mixers = { alc882_macpro_mixer },
5929 .init_verbs = { alc882_macpro_init_verbs },
5930 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5931 .dac_nids = alc882_dac_nids,
5932 .dig_out_nid = ALC882_DIGOUT_NID,
5933 .dig_in_nid = ALC882_DIGIN_NID,
5934 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5935 .channel_mode = alc882_ch_modes,
5936 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005937 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005938 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005939 [ALC885_IMAC24] = {
5940 .mixers = { alc885_imac24_mixer },
5941 .init_verbs = { alc885_imac24_init_verbs },
5942 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5943 .dac_nids = alc882_dac_nids,
5944 .dig_out_nid = ALC882_DIGOUT_NID,
5945 .dig_in_nid = ALC882_DIGIN_NID,
5946 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5947 .channel_mode = alc882_ch_modes,
5948 .input_mux = &alc882_capture_source,
5949 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005950 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005951 },
Kailang Yang272a5272007-05-14 11:00:38 +02005952 [ALC882_TARGA] = {
5953 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5954 alc882_capture_mixer },
5955 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5956 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5957 .dac_nids = alc882_dac_nids,
5958 .dig_out_nid = ALC882_DIGOUT_NID,
5959 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5960 .adc_nids = alc882_adc_nids,
5961 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5962 .channel_mode = alc882_3ST_6ch_modes,
5963 .need_dac_fix = 1,
5964 .input_mux = &alc882_capture_source,
5965 .unsol_event = alc882_targa_unsol_event,
5966 .init_hook = alc882_targa_automute,
5967 },
5968 [ALC882_ASUS_A7J] = {
5969 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5970 alc882_capture_mixer },
5971 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5973 .dac_nids = alc882_dac_nids,
5974 .dig_out_nid = ALC882_DIGOUT_NID,
5975 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5976 .adc_nids = alc882_adc_nids,
5977 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5978 .channel_mode = alc882_3ST_6ch_modes,
5979 .need_dac_fix = 1,
5980 .input_mux = &alc882_capture_source,
5981 },
Takashi Iwai914759b2007-09-06 14:52:04 +02005982 [ALC882_ASUS_A7M] = {
5983 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5984 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5985 alc880_gpio1_init_verbs,
5986 alc882_asus_a7m_verbs },
5987 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5988 .dac_nids = alc882_dac_nids,
5989 .dig_out_nid = ALC882_DIGOUT_NID,
5990 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5991 .channel_mode = alc880_threestack_modes,
5992 .need_dac_fix = 1,
5993 .input_mux = &alc882_capture_source,
5994 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005995};
5996
5997
5998/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005999 * Pin config fixes
6000 */
6001enum {
6002 PINFIX_ABIT_AW9D_MAX
6003};
6004
6005static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6006 { 0x15, 0x01080104 }, /* side */
6007 { 0x16, 0x01011012 }, /* rear */
6008 { 0x17, 0x01016011 }, /* clfe */
6009 { }
6010};
6011
6012static const struct alc_pincfg *alc882_pin_fixes[] = {
6013 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6014};
6015
6016static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6017 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6018 {}
6019};
6020
6021/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006022 * BIOS auto configuration
6023 */
6024static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6025 hda_nid_t nid, int pin_type,
6026 int dac_idx)
6027{
6028 /* set as output */
6029 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006030 int idx;
6031
Kailang Yangdf694da2005-12-05 19:42:22 +01006032 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6033 idx = 4;
6034 else
6035 idx = spec->multiout.dac_nids[dac_idx] - 2;
6036
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006037 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6038 pin_type);
6039 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6040 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6042
6043}
6044
6045static void alc882_auto_init_multi_out(struct hda_codec *codec)
6046{
6047 struct alc_spec *spec = codec->spec;
6048 int i;
6049
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006050 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006051 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006052 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006053 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006054 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006055 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006056 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006057 }
6058}
6059
6060static void alc882_auto_init_hp_out(struct hda_codec *codec)
6061{
6062 struct alc_spec *spec = codec->spec;
6063 hda_nid_t pin;
6064
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006065 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006067 /* use dac 0 */
6068 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006069}
6070
6071#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6072#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6073
6074static void alc882_auto_init_analog_input(struct hda_codec *codec)
6075{
6076 struct alc_spec *spec = codec->spec;
6077 int i;
6078
6079 for (i = 0; i < AUTO_PIN_LAST; i++) {
6080 hda_nid_t nid = spec->autocfg.input_pins[i];
6081 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006082 snd_hda_codec_write(codec, nid, 0,
6083 AC_VERB_SET_PIN_WIDGET_CONTROL,
6084 i <= AUTO_PIN_FRONT_MIC ?
6085 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006086 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006087 snd_hda_codec_write(codec, nid, 0,
6088 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006089 AMP_OUT_MUTE);
6090 }
6091 }
6092}
6093
Takashi Iwai776e1842007-08-29 15:07:11 +02006094/* add mic boosts if needed */
6095static int alc_auto_add_mic_boost(struct hda_codec *codec)
6096{
6097 struct alc_spec *spec = codec->spec;
6098 int err;
6099 hda_nid_t nid;
6100
6101 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006102 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006103 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6104 "Mic Boost",
6105 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6106 if (err < 0)
6107 return err;
6108 }
6109 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006110 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006111 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6112 "Front Mic Boost",
6113 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6114 if (err < 0)
6115 return err;
6116 }
6117 return 0;
6118}
6119
Kailang Yangdf694da2005-12-05 19:42:22 +01006120/* almost identical with ALC880 parser... */
6121static int alc882_parse_auto_config(struct hda_codec *codec)
6122{
6123 struct alc_spec *spec = codec->spec;
6124 int err = alc880_parse_auto_config(codec);
6125
6126 if (err < 0)
6127 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006128 else if (!err)
6129 return 0; /* no config found */
6130
6131 err = alc_auto_add_mic_boost(codec);
6132 if (err < 0)
6133 return err;
6134
6135 /* hack - override the init verbs */
6136 spec->init_verbs[0] = alc882_auto_init_verbs;
6137
6138 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006139}
6140
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006141/* additional initialization for auto-configuration model */
6142static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006143{
Kailang Yangdf694da2005-12-05 19:42:22 +01006144 alc882_auto_init_multi_out(codec);
6145 alc882_auto_init_hp_out(codec);
6146 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006147}
6148
Linus Torvalds1da177e2005-04-16 15:20:36 -07006149static int patch_alc882(struct hda_codec *codec)
6150{
6151 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006152 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006153
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006155 if (spec == NULL)
6156 return -ENOMEM;
6157
Linus Torvalds1da177e2005-04-16 15:20:36 -07006158 codec->spec = spec;
6159
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006160 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6161 alc882_models,
6162 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006163
Kailang Yangdf694da2005-12-05 19:42:22 +01006164 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006165 /* Pick up systems that don't supply PCI SSID */
6166 switch (codec->subsystem_id) {
6167 case 0x106b0c00: /* Mac Pro */
6168 board_config = ALC885_MACPRO;
6169 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006170 case 0x106b1000: /* iMac 24 */
6171 board_config = ALC885_IMAC24;
6172 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006173 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006174 case 0x106b2c00: /* Macbook Pro rev3 */
6175 board_config = ALC885_MBP3;
6176 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006177 default:
6178 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6179 "trying auto-probe from BIOS...\n");
6180 board_config = ALC882_AUTO;
6181 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006182 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006183
Takashi Iwaif95474e2007-07-10 00:47:43 +02006184 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6185
Kailang Yangdf694da2005-12-05 19:42:22 +01006186 if (board_config == ALC882_AUTO) {
6187 /* automatic parse from the BIOS config */
6188 err = alc882_parse_auto_config(codec);
6189 if (err < 0) {
6190 alc_free(codec);
6191 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006192 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006193 printk(KERN_INFO
6194 "hda_codec: Cannot set up configuration "
6195 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006196 board_config = ALC882_3ST_DIG;
6197 }
6198 }
6199
6200 if (board_config != ALC882_AUTO)
6201 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006202
6203 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6205 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006206
6207 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006208 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6209 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006210
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006211 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006212 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006213 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006214 /* get type */
6215 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006216 if (wcap != AC_WID_AUD_IN) {
6217 spec->adc_nids = alc882_adc_nids_alt;
6218 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006219 spec->mixers[spec->num_mixers] =
6220 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 spec->num_mixers++;
6222 } else {
6223 spec->adc_nids = alc882_adc_nids;
6224 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6225 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6226 spec->num_mixers++;
6227 }
6228 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006229
Takashi Iwai2134ea42008-01-10 16:53:55 +01006230 spec->vmaster_nid = 0x0c;
6231
Linus Torvalds1da177e2005-04-16 15:20:36 -07006232 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006234 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006235#ifdef CONFIG_SND_HDA_POWER_SAVE
6236 if (!spec->loopback.amplist)
6237 spec->loopback.amplist = alc882_loopbacks;
6238#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006239
6240 return 0;
6241}
6242
6243/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006244 * ALC883 support
6245 *
6246 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6247 * configuration. Each pin widget can choose any input DACs and a mixer.
6248 * Each ADC is connected from a mixer of all inputs. This makes possible
6249 * 6-channel independent captures.
6250 *
6251 * In addition, an independent DAC for the multi-playback (not used in this
6252 * driver yet).
6253 */
6254#define ALC883_DIGOUT_NID 0x06
6255#define ALC883_DIGIN_NID 0x0a
6256
6257static hda_nid_t alc883_dac_nids[4] = {
6258 /* front, rear, clfe, rear_surr */
6259 0x02, 0x04, 0x03, 0x05
6260};
6261
6262static hda_nid_t alc883_adc_nids[2] = {
6263 /* ADC1-2 */
6264 0x08, 0x09,
6265};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006266
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006267/* input MUX */
6268/* FIXME: should be a matrix-type input source selection */
6269
6270static struct hda_input_mux alc883_capture_source = {
6271 .num_items = 4,
6272 .items = {
6273 { "Mic", 0x0 },
6274 { "Front Mic", 0x1 },
6275 { "Line", 0x2 },
6276 { "CD", 0x4 },
6277 },
6278};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006279
6280static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6281 .num_items = 2,
6282 .items = {
6283 { "Mic", 0x1 },
6284 { "Line", 0x2 },
6285 },
6286};
6287
Kailang Yang272a5272007-05-14 11:00:38 +02006288static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6289 .num_items = 4,
6290 .items = {
6291 { "Mic", 0x0 },
6292 { "iMic", 0x1 },
6293 { "Line", 0x2 },
6294 { "CD", 0x4 },
6295 },
6296};
6297
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006298#define alc883_mux_enum_info alc_mux_enum_info
6299#define alc883_mux_enum_get alc_mux_enum_get
6300
6301static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6302 struct snd_ctl_elem_value *ucontrol)
6303{
6304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6305 struct alc_spec *spec = codec->spec;
6306 const struct hda_input_mux *imux = spec->input_mux;
6307 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6308 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6309 hda_nid_t nid = capture_mixers[adc_idx];
6310 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6311 unsigned int i, idx;
6312
6313 idx = ucontrol->value.enumerated.item[0];
6314 if (idx >= imux->num_items)
6315 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006316 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006317 return 0;
6318 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006319 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6320 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006321 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006322 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006323 }
6324 *cur_val = idx;
6325 return 1;
6326}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006327
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006328/*
6329 * 2ch mode
6330 */
6331static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6332 { 2, NULL }
6333};
6334
6335/*
6336 * 2ch mode
6337 */
6338static struct hda_verb alc883_3ST_ch2_init[] = {
6339 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6340 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6341 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6342 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6343 { } /* end */
6344};
6345
6346/*
Tobin Davisb2011312007-09-17 12:45:11 +02006347 * 4ch mode
6348 */
6349static struct hda_verb alc883_3ST_ch4_init[] = {
6350 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6351 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6352 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6353 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6354 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6355 { } /* end */
6356};
6357
6358/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006359 * 6ch mode
6360 */
6361static struct hda_verb alc883_3ST_ch6_init[] = {
6362 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6363 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6364 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6365 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6366 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6367 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6368 { } /* end */
6369};
6370
Tobin Davisb2011312007-09-17 12:45:11 +02006371static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006372 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006373 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006374 { 6, alc883_3ST_ch6_init },
6375};
6376
6377/*
6378 * 6ch mode
6379 */
6380static struct hda_verb alc883_sixstack_ch6_init[] = {
6381 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6382 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6383 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6384 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6385 { } /* end */
6386};
6387
6388/*
6389 * 8ch mode
6390 */
6391static struct hda_verb alc883_sixstack_ch8_init[] = {
6392 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6393 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6395 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { } /* end */
6397};
6398
6399static struct hda_channel_mode alc883_sixstack_modes[2] = {
6400 { 6, alc883_sixstack_ch6_init },
6401 { 8, alc883_sixstack_ch8_init },
6402};
6403
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006404static struct hda_verb alc883_medion_eapd_verbs[] = {
6405 /* eanable EAPD on medion laptop */
6406 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6407 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6408 { }
6409};
6410
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006411/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6412 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6413 */
6414
6415static struct snd_kcontrol_new alc883_base_mixer[] = {
6416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6417 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6418 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6419 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6420 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6421 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6422 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6423 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6424 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6425 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6429 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6430 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6434 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006435 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006436 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6437 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6438 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6439 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6440 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6441 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6442 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6443 {
6444 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6445 /* .name = "Capture Source", */
6446 .name = "Input Source",
6447 .count = 2,
6448 .info = alc883_mux_enum_info,
6449 .get = alc883_mux_enum_get,
6450 .put = alc883_mux_enum_put,
6451 },
6452 { } /* end */
6453};
6454
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006455static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6456 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6457 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6458 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6459 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6460 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6461 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6463 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6464 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6468 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6469 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6470 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6471 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6472 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6473 {
6474 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6475 /* .name = "Capture Source", */
6476 .name = "Input Source",
6477 .count = 2,
6478 .info = alc883_mux_enum_info,
6479 .get = alc883_mux_enum_get,
6480 .put = alc883_mux_enum_put,
6481 },
6482 { } /* end */
6483};
6484
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006485static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6487 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6489 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6490 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6491 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6492 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006494 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6496 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006497 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006498 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6499 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6500 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6501 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6502 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6503 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6504 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6505 {
6506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6507 /* .name = "Capture Source", */
6508 .name = "Input Source",
6509 .count = 2,
6510 .info = alc883_mux_enum_info,
6511 .get = alc883_mux_enum_get,
6512 .put = alc883_mux_enum_put,
6513 },
6514 { } /* end */
6515};
6516
6517static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6518 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6519 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6521 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6522 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6523 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6524 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6525 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6527 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6528 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6529 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6530 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006532 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6534 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006535 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6537 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6538 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6539 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6540 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6541 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6542 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6543 {
6544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6545 /* .name = "Capture Source", */
6546 .name = "Input Source",
6547 .count = 2,
6548 .info = alc883_mux_enum_info,
6549 .get = alc883_mux_enum_get,
6550 .put = alc883_mux_enum_put,
6551 },
6552 { } /* end */
6553};
6554
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006555static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6557 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6558 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6559 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6560 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6561 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6562 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6563 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6565 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6566 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6567 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6568 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006570 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6572 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006573 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006574 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6575 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6576 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6577 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6578 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6579
6580 {
6581 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6582 /* .name = "Capture Source", */
6583 .name = "Input Source",
6584 .count = 1,
6585 .info = alc883_mux_enum_info,
6586 .get = alc883_mux_enum_get,
6587 .put = alc883_mux_enum_put,
6588 },
6589 { } /* end */
6590};
6591
Kailang Yangccc656c2006-10-17 12:32:26 +02006592static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6593 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6595 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6596 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6597 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6598 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6599 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6600 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6601 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6604 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6605 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6606 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006607 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006608 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6609 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6610 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6611 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6612 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6613 {
6614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6615 /* .name = "Capture Source", */
6616 .name = "Input Source",
6617 .count = 2,
6618 .info = alc883_mux_enum_info,
6619 .get = alc883_mux_enum_get,
6620 .put = alc883_mux_enum_put,
6621 },
6622 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006623};
Kailang Yangccc656c2006-10-17 12:32:26 +02006624
6625static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6626 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6627 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6628 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006632 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6634 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6635 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6636 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6637 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6638 {
6639 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6640 /* .name = "Capture Source", */
6641 .name = "Input Source",
6642 .count = 2,
6643 .info = alc883_mux_enum_info,
6644 .get = alc883_mux_enum_get,
6645 .put = alc883_mux_enum_put,
6646 },
6647 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006648};
Kailang Yangccc656c2006-10-17 12:32:26 +02006649
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006650static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6651 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6652 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6653 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6654 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6657 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6659 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6660 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6661 {
6662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6663 /* .name = "Capture Source", */
6664 .name = "Input Source",
6665 .count = 1,
6666 .info = alc883_mux_enum_info,
6667 .get = alc883_mux_enum_get,
6668 .put = alc883_mux_enum_put,
6669 },
6670 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006671};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006672
Kailang Yang272a5272007-05-14 11:00:38 +02006673static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6674 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6675 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6677 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6678 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6681 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6682 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6683 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6684 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6685 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6686 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6687 {
6688 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6689 /* .name = "Capture Source", */
6690 .name = "Input Source",
6691 .count = 2,
6692 .info = alc883_mux_enum_info,
6693 .get = alc883_mux_enum_get,
6694 .put = alc883_mux_enum_put,
6695 },
6696 { } /* end */
6697};
6698
6699static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6700 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6701 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6702 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6707 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6708 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6709 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6710 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6711 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6712 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6713 {
6714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6715 /* .name = "Capture Source", */
6716 .name = "Input Source",
6717 .count = 2,
6718 .info = alc883_mux_enum_info,
6719 .get = alc883_mux_enum_get,
6720 .put = alc883_mux_enum_put,
6721 },
6722 { } /* end */
6723};
6724
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006725static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006726 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6727 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6728 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6729 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6730 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6731 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6732 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6733 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6735 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6737 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6738 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6742 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6744 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6745 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6747 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6748 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6749 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6750 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6751 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6752 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6753 {
6754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6755 /* .name = "Capture Source", */
6756 .name = "Input Source",
6757 .count = 2,
6758 .info = alc883_mux_enum_info,
6759 .get = alc883_mux_enum_get,
6760 .put = alc883_mux_enum_put,
6761 },
6762 { } /* end */
6763};
6764
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006765static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6769 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6772 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6773 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6775 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6776 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6777 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6778 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6782 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6783 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6785 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6786 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6787 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6788 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6789 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6790 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6791 {
6792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6793 /* .name = "Capture Source", */
6794 .name = "Input Source",
6795 .count = 2,
6796 .info = alc883_mux_enum_info,
6797 .get = alc883_mux_enum_get,
6798 .put = alc883_mux_enum_put,
6799 },
6800 { } /* end */
6801};
6802
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006803static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6804 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6805 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6806 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6807 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6808 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6809 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6810 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6811 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6812 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6813 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6823 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6825 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6826 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6827 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6828 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6829 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6830 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6831 {
6832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6833 /* .name = "Capture Source", */
6834 .name = "Input Source",
6835 .count = 2,
6836 .info = alc883_mux_enum_info,
6837 .get = alc883_mux_enum_get,
6838 .put = alc883_mux_enum_put,
6839 },
6840 { } /* end */
6841};
6842
Tobin Davis2880a862007-08-07 11:50:26 +02006843static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006844 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6845 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6850 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006852 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6853 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6854 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6855 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6856 {
6857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6858 /* .name = "Capture Source", */
6859 .name = "Input Source",
6860 .count = 2,
6861 .info = alc883_mux_enum_info,
6862 .get = alc883_mux_enum_get,
6863 .put = alc883_mux_enum_put,
6864 },
6865 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006866};
Tobin Davis2880a862007-08-07 11:50:26 +02006867
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006868static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6869 {
6870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6871 .name = "Channel Mode",
6872 .info = alc_ch_mode_info,
6873 .get = alc_ch_mode_get,
6874 .put = alc_ch_mode_put,
6875 },
6876 { } /* end */
6877};
6878
6879static struct hda_verb alc883_init_verbs[] = {
6880 /* ADC1: mute amp left and right */
6881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6882 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6883 /* ADC2: mute amp left and right */
6884 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6885 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6886 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6890 /* Rear mixer */
6891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6894 /* CLFE mixer */
6895 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6898 /* Side mixer */
6899 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6902
Takashi Iwaicb53c622007-08-10 17:21:45 +02006903 /* mute analog input loopbacks */
6904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006909
6910 /* Front Pin: output 0 (0x0c) */
6911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6913 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6914 /* Rear Pin: output 1 (0x0d) */
6915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6917 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6918 /* CLFE Pin: output 2 (0x0e) */
6919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6921 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6922 /* Side Pin: output 3 (0x0f) */
6923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6925 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6926 /* Mic (rear) pin: input vref at 80% */
6927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6929 /* Front Mic pin: input vref at 80% */
6930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6932 /* Line In pin: input */
6933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6935 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6939 /* CD pin widget for input */
6940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6941
6942 /* FIXME: use matrix-type input source selection */
6943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6944 /* Input mixer2 */
6945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6949 /* Input mixer3 */
6950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6954 { }
6955};
6956
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006957/* toggle speaker-output according to the hp-jack state */
6958static void alc883_mitac_hp_automute(struct hda_codec *codec)
6959{
6960 unsigned int present;
6961
6962 present = snd_hda_codec_read(codec, 0x15, 0,
6963 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6964 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6965 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6966 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6967 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6968}
6969
6970/* auto-toggle front mic */
6971/*
6972static void alc883_mitac_mic_automute(struct hda_codec *codec)
6973{
6974 unsigned int present;
6975 unsigned char bits;
6976
6977 present = snd_hda_codec_read(codec, 0x18, 0,
6978 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6979 bits = present ? HDA_AMP_MUTE : 0;
6980 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
6981}
6982*/
6983
6984static void alc883_mitac_automute(struct hda_codec *codec)
6985{
6986 alc883_mitac_hp_automute(codec);
6987 /* alc883_mitac_mic_automute(codec); */
6988}
6989
6990static void alc883_mitac_unsol_event(struct hda_codec *codec,
6991 unsigned int res)
6992{
6993 switch (res >> 26) {
6994 case ALC880_HP_EVENT:
6995 alc883_mitac_hp_automute(codec);
6996 break;
6997 case ALC880_MIC_EVENT:
6998 /* alc883_mitac_mic_automute(codec); */
6999 break;
7000 }
7001}
7002
7003static struct hda_verb alc883_mitac_verbs[] = {
7004 /* HP */
7005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7007 /* Subwoofer */
7008 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7009 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7010
7011 /* enable unsolicited event */
7012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7013 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7014
7015 { } /* end */
7016};
7017
Kailang Yangccc656c2006-10-17 12:32:26 +02007018static struct hda_verb alc883_tagra_verbs[] = {
7019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7021
7022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7024
7025 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7026 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7027 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7028
7029 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007030 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7031 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7032 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007033
7034 { } /* end */
7035};
7036
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007037static struct hda_verb alc883_lenovo_101e_verbs[] = {
7038 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7039 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7041 { } /* end */
7042};
7043
Kailang Yang272a5272007-05-14 11:00:38 +02007044static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7047 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7049 { } /* end */
7050};
7051
7052static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7056 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7057 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7058 { } /* end */
7059};
7060
Kailang Yang189609a2007-08-20 11:31:23 +02007061static struct hda_verb alc883_haier_w66_verbs[] = {
7062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7064
7065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7066
7067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7069 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7070 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7071 { } /* end */
7072};
7073
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007074static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007075 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7076 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7077 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7078 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7079 { }
7080};
7081
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007082static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007083 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7084 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7085 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7086 { }
7087};
7088
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007089static struct hda_verb alc888_6st_dell_verbs[] = {
7090 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7091 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7092 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7093 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7094 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7095 { }
7096};
7097
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007098static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007099 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7100 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7101 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7102 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7103 { }
7104};
7105
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007106static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007107 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7108 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7109 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7110 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7111 { }
7112};
7113
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007114static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7115 { 2, alc888_3st_hp_2ch_init },
7116 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007117};
7118
Kailang Yang272a5272007-05-14 11:00:38 +02007119/* toggle front-jack and RCA according to the hp-jack state */
7120static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7121{
7122 unsigned int present;
7123
7124 present = snd_hda_codec_read(codec, 0x1b, 0,
7125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007126 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7128 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7129 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007130}
7131
7132/* toggle RCA according to the front-jack state */
7133static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7134{
7135 unsigned int present;
7136
7137 present = snd_hda_codec_read(codec, 0x14, 0,
7138 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007139 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7140 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007141}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007142
Kailang Yang272a5272007-05-14 11:00:38 +02007143static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7144 unsigned int res)
7145{
7146 if ((res >> 26) == ALC880_HP_EVENT)
7147 alc888_lenovo_ms7195_front_automute(codec);
7148 if ((res >> 26) == ALC880_FRONT_EVENT)
7149 alc888_lenovo_ms7195_rca_automute(codec);
7150}
7151
7152static struct hda_verb alc883_medion_md2_verbs[] = {
7153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7155
7156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7157
7158 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7159 { } /* end */
7160};
7161
7162/* toggle speaker-output according to the hp-jack state */
7163static void alc883_medion_md2_automute(struct hda_codec *codec)
7164{
7165 unsigned int present;
7166
7167 present = snd_hda_codec_read(codec, 0x14, 0,
7168 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007169 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7170 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007171}
7172
7173static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7174 unsigned int res)
7175{
7176 if ((res >> 26) == ALC880_HP_EVENT)
7177 alc883_medion_md2_automute(codec);
7178}
7179
Kailang Yangccc656c2006-10-17 12:32:26 +02007180/* toggle speaker-output according to the hp-jack state */
7181static void alc883_tagra_automute(struct hda_codec *codec)
7182{
7183 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007184 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007185
7186 present = snd_hda_codec_read(codec, 0x14, 0,
7187 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007188 bits = present ? HDA_AMP_MUTE : 0;
7189 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7190 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007191 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7192 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007193}
7194
7195static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7196{
7197 if ((res >> 26) == ALC880_HP_EVENT)
7198 alc883_tagra_automute(codec);
7199}
7200
Kailang Yang189609a2007-08-20 11:31:23 +02007201static void alc883_haier_w66_automute(struct hda_codec *codec)
7202{
7203 unsigned int present;
7204 unsigned char bits;
7205
7206 present = snd_hda_codec_read(codec, 0x1b, 0,
7207 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7208 bits = present ? 0x80 : 0;
7209 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7210 0x80, bits);
7211}
7212
7213static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7214 unsigned int res)
7215{
7216 if ((res >> 26) == ALC880_HP_EVENT)
7217 alc883_haier_w66_automute(codec);
7218}
7219
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007220static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7221{
7222 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007223 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007224
7225 present = snd_hda_codec_read(codec, 0x14, 0,
7226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007227 bits = present ? HDA_AMP_MUTE : 0;
7228 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7229 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007230}
7231
7232static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7233{
7234 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007235 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007236
7237 present = snd_hda_codec_read(codec, 0x1b, 0,
7238 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007239 bits = present ? HDA_AMP_MUTE : 0;
7240 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7241 HDA_AMP_MUTE, bits);
7242 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7243 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007244}
7245
7246static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7247 unsigned int res)
7248{
7249 if ((res >> 26) == ALC880_HP_EVENT)
7250 alc883_lenovo_101e_all_automute(codec);
7251 if ((res >> 26) == ALC880_FRONT_EVENT)
7252 alc883_lenovo_101e_ispeaker_automute(codec);
7253}
7254
Takashi Iwai676a9b52007-08-16 15:23:35 +02007255/* toggle speaker-output according to the hp-jack state */
7256static void alc883_acer_aspire_automute(struct hda_codec *codec)
7257{
7258 unsigned int present;
7259
7260 present = snd_hda_codec_read(codec, 0x14, 0,
7261 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7262 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7263 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7264 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7265 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7266}
7267
7268static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7269 unsigned int res)
7270{
7271 if ((res >> 26) == ALC880_HP_EVENT)
7272 alc883_acer_aspire_automute(codec);
7273}
7274
Kailang Yangd1a991a2007-08-15 16:21:59 +02007275static struct hda_verb alc883_acer_eapd_verbs[] = {
7276 /* HP Pin: output 0 (0x0c) */
7277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7278 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7279 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7280 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007283 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007284 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7285 /* eanable EAPD on medion laptop */
7286 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7287 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007288 /* enable unsolicited event */
7289 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007290 { }
7291};
7292
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007293static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7294{
7295 unsigned int present;
7296
7297 present = snd_hda_codec_read(codec, 0x1b, 0,
7298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7300 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7301 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7302 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7303 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7304 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7305 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7306 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7307}
7308
7309static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7310 unsigned int res)
7311{
7312 switch (res >> 26) {
7313 case ALC880_HP_EVENT:
7314 printk("hp_event\n");
7315 alc888_6st_dell_front_automute(codec);
7316 break;
7317 }
7318}
7319
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007320/*
7321 * generic initialization of ADC, input mixers and output mixers
7322 */
7323static struct hda_verb alc883_auto_init_verbs[] = {
7324 /*
7325 * Unmute ADC0-2 and set the default input to mic-in
7326 */
7327 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7329 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7331
Takashi Iwaicb53c622007-08-10 17:21:45 +02007332 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007333 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007334 * Note: PASD motherboards uses the Line In 2 as the input for
7335 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007336 */
7337 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007343
7344 /*
7345 * Set up output mixers (0x0c - 0x0f)
7346 */
7347 /* set vol=0 to output mixers */
7348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7352 /* set up input amps for analog loopback */
7353 /* Amp Indices: DAC = 0, mixer = 1 */
7354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7359 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7360 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7361 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7362 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7363 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7364
7365 /* FIXME: use matrix-type input source selection */
7366 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7367 /* Input mixer1 */
7368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007371 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7373 /* Input mixer2 */
7374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007377 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007379
7380 { }
7381};
7382
7383/* capture mixer elements */
7384static struct snd_kcontrol_new alc883_capture_mixer[] = {
7385 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7386 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7387 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7388 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7389 {
7390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7391 /* The multiple "Capture Source" controls confuse alsamixer
7392 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007393 */
7394 /* .name = "Capture Source", */
7395 .name = "Input Source",
7396 .count = 2,
7397 .info = alc882_mux_enum_info,
7398 .get = alc882_mux_enum_get,
7399 .put = alc882_mux_enum_put,
7400 },
7401 { } /* end */
7402};
7403
Takashi Iwaicb53c622007-08-10 17:21:45 +02007404#ifdef CONFIG_SND_HDA_POWER_SAVE
7405#define alc883_loopbacks alc880_loopbacks
7406#endif
7407
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007408/* pcm configuration: identiacal with ALC880 */
7409#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7410#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7411#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7412#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7413
7414/*
7415 * configuration and preset
7416 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007417static const char *alc883_models[ALC883_MODEL_LAST] = {
7418 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7419 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7420 [ALC883_3ST_6ch] = "3stack-6ch",
7421 [ALC883_6ST_DIG] = "6stack-dig",
7422 [ALC883_TARGA_DIG] = "targa-dig",
7423 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007424 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007425 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007426 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007427 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007428 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007429 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007430 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7431 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007432 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007433 [ALC888_6ST_HP] = "6stack-hp",
7434 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007435 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007436 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007437 [ALC883_AUTO] = "auto",
7438};
7439
7440static struct snd_pci_quirk alc883_cfg_tbl[] = {
7441 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007442 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7443 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7444 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7445 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007446 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007447 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007448 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7449 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7450 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7451 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007452 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007453 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7454 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7455 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007456 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007457 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7458 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7459 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7460 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7461 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7462 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7463 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7464 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7465 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7466 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7467 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7468 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7469 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007470 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7471 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007472 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007473 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007474 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007475 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007476 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7477 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007478 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007479 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007480 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007481 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007482 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7483 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007484 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007485 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007486 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007487 {}
7488};
7489
7490static struct alc_config_preset alc883_presets[] = {
7491 [ALC883_3ST_2ch_DIG] = {
7492 .mixers = { alc883_3ST_2ch_mixer },
7493 .init_verbs = { alc883_init_verbs },
7494 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7495 .dac_nids = alc883_dac_nids,
7496 .dig_out_nid = ALC883_DIGOUT_NID,
7497 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7498 .adc_nids = alc883_adc_nids,
7499 .dig_in_nid = ALC883_DIGIN_NID,
7500 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7501 .channel_mode = alc883_3ST_2ch_modes,
7502 .input_mux = &alc883_capture_source,
7503 },
7504 [ALC883_3ST_6ch_DIG] = {
7505 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7506 .init_verbs = { alc883_init_verbs },
7507 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7508 .dac_nids = alc883_dac_nids,
7509 .dig_out_nid = ALC883_DIGOUT_NID,
7510 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7511 .adc_nids = alc883_adc_nids,
7512 .dig_in_nid = ALC883_DIGIN_NID,
7513 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7514 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007515 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007516 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007517 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007518 [ALC883_3ST_6ch] = {
7519 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7520 .init_verbs = { alc883_init_verbs },
7521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7522 .dac_nids = alc883_dac_nids,
7523 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7524 .adc_nids = alc883_adc_nids,
7525 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7526 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007527 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007528 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007529 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007530 [ALC883_6ST_DIG] = {
7531 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7532 .init_verbs = { alc883_init_verbs },
7533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7534 .dac_nids = alc883_dac_nids,
7535 .dig_out_nid = ALC883_DIGOUT_NID,
7536 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7537 .adc_nids = alc883_adc_nids,
7538 .dig_in_nid = ALC883_DIGIN_NID,
7539 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7540 .channel_mode = alc883_sixstack_modes,
7541 .input_mux = &alc883_capture_source,
7542 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007543 [ALC883_TARGA_DIG] = {
7544 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7545 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7547 .dac_nids = alc883_dac_nids,
7548 .dig_out_nid = ALC883_DIGOUT_NID,
7549 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7550 .adc_nids = alc883_adc_nids,
7551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7552 .channel_mode = alc883_3ST_6ch_modes,
7553 .need_dac_fix = 1,
7554 .input_mux = &alc883_capture_source,
7555 .unsol_event = alc883_tagra_unsol_event,
7556 .init_hook = alc883_tagra_automute,
7557 },
7558 [ALC883_TARGA_2ch_DIG] = {
7559 .mixers = { alc883_tagra_2ch_mixer},
7560 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7562 .dac_nids = alc883_dac_nids,
7563 .dig_out_nid = ALC883_DIGOUT_NID,
7564 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7565 .adc_nids = alc883_adc_nids,
7566 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7567 .channel_mode = alc883_3ST_2ch_modes,
7568 .input_mux = &alc883_capture_source,
7569 .unsol_event = alc883_tagra_unsol_event,
7570 .init_hook = alc883_tagra_automute,
7571 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007572 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007573 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007574 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7575 * and the headphone jack. Turn this on and rely on the
7576 * standard mute methods whenever the user wants to turn
7577 * these outputs off.
7578 */
7579 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7580 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7581 .dac_nids = alc883_dac_nids,
7582 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7583 .adc_nids = alc883_adc_nids,
7584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7585 .channel_mode = alc883_3ST_2ch_modes,
7586 .input_mux = &alc883_capture_source,
7587 },
Tobin Davis2880a862007-08-07 11:50:26 +02007588 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007589 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007590 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7592 .dac_nids = alc883_dac_nids,
7593 .dig_out_nid = ALC883_DIGOUT_NID,
7594 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7595 .adc_nids = alc883_adc_nids,
7596 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7597 .channel_mode = alc883_3ST_2ch_modes,
7598 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007599 .unsol_event = alc883_acer_aspire_unsol_event,
7600 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007601 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007602 [ALC883_MEDION] = {
7603 .mixers = { alc883_fivestack_mixer,
7604 alc883_chmode_mixer },
7605 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007606 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007607 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7608 .dac_nids = alc883_dac_nids,
7609 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7610 .adc_nids = alc883_adc_nids,
7611 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7612 .channel_mode = alc883_sixstack_modes,
7613 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007614 },
Kailang Yang272a5272007-05-14 11:00:38 +02007615 [ALC883_MEDION_MD2] = {
7616 .mixers = { alc883_medion_md2_mixer},
7617 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7618 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7619 .dac_nids = alc883_dac_nids,
7620 .dig_out_nid = ALC883_DIGOUT_NID,
7621 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7622 .adc_nids = alc883_adc_nids,
7623 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7624 .channel_mode = alc883_3ST_2ch_modes,
7625 .input_mux = &alc883_capture_source,
7626 .unsol_event = alc883_medion_md2_unsol_event,
7627 .init_hook = alc883_medion_md2_automute,
7628 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007629 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007630 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007631 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7632 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7633 .dac_nids = alc883_dac_nids,
7634 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7635 .adc_nids = alc883_adc_nids,
7636 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7637 .channel_mode = alc883_3ST_2ch_modes,
7638 .input_mux = &alc883_capture_source,
7639 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007640 [ALC883_LENOVO_101E_2ch] = {
7641 .mixers = { alc883_lenovo_101e_2ch_mixer},
7642 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7644 .dac_nids = alc883_dac_nids,
7645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7646 .adc_nids = alc883_adc_nids,
7647 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7648 .channel_mode = alc883_3ST_2ch_modes,
7649 .input_mux = &alc883_lenovo_101e_capture_source,
7650 .unsol_event = alc883_lenovo_101e_unsol_event,
7651 .init_hook = alc883_lenovo_101e_all_automute,
7652 },
Kailang Yang272a5272007-05-14 11:00:38 +02007653 [ALC883_LENOVO_NB0763] = {
7654 .mixers = { alc883_lenovo_nb0763_mixer },
7655 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7656 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7657 .dac_nids = alc883_dac_nids,
7658 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7659 .adc_nids = alc883_adc_nids,
7660 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7661 .channel_mode = alc883_3ST_2ch_modes,
7662 .need_dac_fix = 1,
7663 .input_mux = &alc883_lenovo_nb0763_capture_source,
7664 .unsol_event = alc883_medion_md2_unsol_event,
7665 .init_hook = alc883_medion_md2_automute,
7666 },
7667 [ALC888_LENOVO_MS7195_DIG] = {
7668 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7669 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7670 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7671 .dac_nids = alc883_dac_nids,
7672 .dig_out_nid = ALC883_DIGOUT_NID,
7673 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7674 .adc_nids = alc883_adc_nids,
7675 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7676 .channel_mode = alc883_3ST_6ch_modes,
7677 .need_dac_fix = 1,
7678 .input_mux = &alc883_capture_source,
7679 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7680 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007681 },
7682 [ALC883_HAIER_W66] = {
7683 .mixers = { alc883_tagra_2ch_mixer},
7684 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7685 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7686 .dac_nids = alc883_dac_nids,
7687 .dig_out_nid = ALC883_DIGOUT_NID,
7688 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7689 .adc_nids = alc883_adc_nids,
7690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7691 .channel_mode = alc883_3ST_2ch_modes,
7692 .input_mux = &alc883_capture_source,
7693 .unsol_event = alc883_haier_w66_unsol_event,
7694 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007695 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007696 [ALC888_6ST_HP] = {
7697 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7698 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7700 .dac_nids = alc883_dac_nids,
7701 .dig_out_nid = ALC883_DIGOUT_NID,
7702 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7703 .adc_nids = alc883_adc_nids,
7704 .dig_in_nid = ALC883_DIGIN_NID,
7705 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7706 .channel_mode = alc883_sixstack_modes,
7707 .input_mux = &alc883_capture_source,
7708 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007709 [ALC888_3ST_HP] = {
7710 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7711 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007712 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7713 .dac_nids = alc883_dac_nids,
7714 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7715 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007716 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7717 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007718 .need_dac_fix = 1,
7719 .input_mux = &alc883_capture_source,
7720 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007721 [ALC888_6ST_DELL] = {
7722 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7723 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7724 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7725 .dac_nids = alc883_dac_nids,
7726 .dig_out_nid = ALC883_DIGOUT_NID,
7727 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7728 .adc_nids = alc883_adc_nids,
7729 .dig_in_nid = ALC883_DIGIN_NID,
7730 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7731 .channel_mode = alc883_sixstack_modes,
7732 .input_mux = &alc883_capture_source,
7733 .unsol_event = alc888_6st_dell_unsol_event,
7734 .init_hook = alc888_6st_dell_front_automute,
7735 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007736 [ALC883_MITAC] = {
7737 .mixers = { alc883_mitac_mixer },
7738 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7739 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7740 .dac_nids = alc883_dac_nids,
7741 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7742 .adc_nids = alc883_adc_nids,
7743 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7744 .channel_mode = alc883_3ST_2ch_modes,
7745 .input_mux = &alc883_capture_source,
7746 .unsol_event = alc883_mitac_unsol_event,
7747 .init_hook = alc883_mitac_automute,
7748 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007749};
7750
7751
7752/*
7753 * BIOS auto configuration
7754 */
7755static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7756 hda_nid_t nid, int pin_type,
7757 int dac_idx)
7758{
7759 /* set as output */
7760 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007761 int idx;
7762
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007763 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7764 idx = 4;
7765 else
7766 idx = spec->multiout.dac_nids[dac_idx] - 2;
7767
7768 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7769 pin_type);
7770 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7771 AMP_OUT_UNMUTE);
7772 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7773
7774}
7775
7776static void alc883_auto_init_multi_out(struct hda_codec *codec)
7777{
7778 struct alc_spec *spec = codec->spec;
7779 int i;
7780
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007781 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007782 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007783 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007784 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007785 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007786 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007787 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007788 }
7789}
7790
7791static void alc883_auto_init_hp_out(struct hda_codec *codec)
7792{
7793 struct alc_spec *spec = codec->spec;
7794 hda_nid_t pin;
7795
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007796 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007797 if (pin) /* connect to front */
7798 /* use dac 0 */
7799 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7800}
7801
7802#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7803#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7804
7805static void alc883_auto_init_analog_input(struct hda_codec *codec)
7806{
7807 struct alc_spec *spec = codec->spec;
7808 int i;
7809
7810 for (i = 0; i < AUTO_PIN_LAST; i++) {
7811 hda_nid_t nid = spec->autocfg.input_pins[i];
7812 if (alc883_is_input_pin(nid)) {
7813 snd_hda_codec_write(codec, nid, 0,
7814 AC_VERB_SET_PIN_WIDGET_CONTROL,
7815 (i <= AUTO_PIN_FRONT_MIC ?
7816 PIN_VREF80 : PIN_IN));
7817 if (nid != ALC883_PIN_CD_NID)
7818 snd_hda_codec_write(codec, nid, 0,
7819 AC_VERB_SET_AMP_GAIN_MUTE,
7820 AMP_OUT_MUTE);
7821 }
7822 }
7823}
7824
7825/* almost identical with ALC880 parser... */
7826static int alc883_parse_auto_config(struct hda_codec *codec)
7827{
7828 struct alc_spec *spec = codec->spec;
7829 int err = alc880_parse_auto_config(codec);
7830
7831 if (err < 0)
7832 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007833 else if (!err)
7834 return 0; /* no config found */
7835
7836 err = alc_auto_add_mic_boost(codec);
7837 if (err < 0)
7838 return err;
7839
7840 /* hack - override the init verbs */
7841 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007842 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7843 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007844
7845 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007846}
7847
7848/* additional initialization for auto-configuration model */
7849static void alc883_auto_init(struct hda_codec *codec)
7850{
7851 alc883_auto_init_multi_out(codec);
7852 alc883_auto_init_hp_out(codec);
7853 alc883_auto_init_analog_input(codec);
7854}
7855
7856static int patch_alc883(struct hda_codec *codec)
7857{
7858 struct alc_spec *spec;
7859 int err, board_config;
7860
7861 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7862 if (spec == NULL)
7863 return -ENOMEM;
7864
7865 codec->spec = spec;
7866
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007867 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7868 alc883_models,
7869 alc883_cfg_tbl);
7870 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007871 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7872 "trying auto-probe from BIOS...\n");
7873 board_config = ALC883_AUTO;
7874 }
7875
7876 if (board_config == ALC883_AUTO) {
7877 /* automatic parse from the BIOS config */
7878 err = alc883_parse_auto_config(codec);
7879 if (err < 0) {
7880 alc_free(codec);
7881 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007882 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007883 printk(KERN_INFO
7884 "hda_codec: Cannot set up configuration "
7885 "from BIOS. Using base mode...\n");
7886 board_config = ALC883_3ST_2ch_DIG;
7887 }
7888 }
7889
7890 if (board_config != ALC883_AUTO)
7891 setup_preset(spec, &alc883_presets[board_config]);
7892
7893 spec->stream_name_analog = "ALC883 Analog";
7894 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7895 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7896
7897 spec->stream_name_digital = "ALC883 Digital";
7898 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7899 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7900
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007901 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007902 spec->adc_nids = alc883_adc_nids;
7903 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7904 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007905
Takashi Iwai2134ea42008-01-10 16:53:55 +01007906 spec->vmaster_nid = 0x0c;
7907
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007908 codec->patch_ops = alc_patch_ops;
7909 if (board_config == ALC883_AUTO)
7910 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007911#ifdef CONFIG_SND_HDA_POWER_SAVE
7912 if (!spec->loopback.amplist)
7913 spec->loopback.amplist = alc883_loopbacks;
7914#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007915
7916 return 0;
7917}
7918
7919/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007920 * ALC262 support
7921 */
7922
7923#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7924#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7925
7926#define alc262_dac_nids alc260_dac_nids
7927#define alc262_adc_nids alc882_adc_nids
7928#define alc262_adc_nids_alt alc882_adc_nids_alt
7929
7930#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007931#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007932
7933static struct snd_kcontrol_new alc262_base_mixer[] = {
7934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7935 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7939 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7941 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007942 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007943 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7944 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007945 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007946 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7947 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7948 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7950 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007952 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007953};
7954
Kailang Yangccc656c2006-10-17 12:32:26 +02007955static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7956 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7958 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7959 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7961 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007964 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007965 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007967 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007968 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7969 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7970 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7972 { } /* end */
7973};
7974
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007975static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7977 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7981
7982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007984 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007985 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7986 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007987 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7990 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7991 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7992 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7993 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7994 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7995 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7996 { } /* end */
7997};
7998
Kailang Yangcd7509a2007-01-26 18:33:17 +01007999static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8001 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8004 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8005 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008008 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8012 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8013 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8014 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8015 { } /* end */
8016};
8017
8018static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8019 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8020 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008021 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008022 { } /* end */
8023};
8024
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008025static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
8026 .ops = &snd_hda_bind_vol,
8027 .values = {
8028 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8029 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8030 0
8031 },
8032};
8033
8034static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
8035 .ops = &snd_hda_bind_sw,
8036 .values = {
8037 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8038 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8039 0
8040 },
8041};
8042
8043/* mute/unmute internal speaker according to the hp jack and mute state */
8044static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8045{
8046 struct alc_spec *spec = codec->spec;
8047 unsigned int mute;
8048
8049 if (force || !spec->sense_updated) {
8050 unsigned int present;
8051 present = snd_hda_codec_read(codec, 0x15, 0,
8052 AC_VERB_GET_PIN_SENSE, 0);
8053 spec->jack_present = (present & 0x80000000) != 0;
8054 spec->sense_updated = 1;
8055 }
8056 if (spec->jack_present)
8057 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
8058 else /* unmute internal speaker if necessary */
8059 mute = (0x7000 | ((0)<<8));
8060 snd_hda_codec_write(codec, 0x0c, 0,
8061 AC_VERB_SET_AMP_GAIN_MUTE, mute );
8062}
8063
8064static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8065 unsigned int res)
8066{
8067 if ((res >> 26) != ALC880_HP_EVENT)
8068 return;
8069 alc262_hp_t5735_automute(codec, 1);
8070}
8071
8072static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8073{
8074 alc262_hp_t5735_automute(codec, 1);
8075}
8076
8077static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8078 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
8079 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
8080 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8081 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8082 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8083 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8084 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8088 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8089 { } /* end */
8090};
8091
8092static struct hda_verb alc262_hp_t5735_verbs[] = {
8093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8094 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8095
8096 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8097 { }
8098};
8099
Kailang Yang8c427222008-01-10 13:03:59 +01008100static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
8101 .ops = &snd_hda_bind_vol,
8102 .values = {
8103 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8104 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
8105 0
8106 },
8107};
8108
8109static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
8110 .ops = &snd_hda_bind_sw,
8111 .values = {
8112 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8113 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
8114 0
8115 },
8116};
8117
8118static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8119 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
8120 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
8121 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8122 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8123 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8124 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8127 { } /* end */
8128};
8129
8130static struct hda_verb alc262_hp_rp5700_verbs[] = {
8131 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8134 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8135 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8136 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8138 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8139 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8141 {}
8142};
8143
8144static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8145 .num_items = 1,
8146 .items = {
8147 { "Line", 0x1 },
8148 },
8149};
8150
Takashi Iwai0724ea22007-08-23 00:31:43 +02008151/* bind hp and internal speaker mute (with plug check) */
8152static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8153 struct snd_ctl_elem_value *ucontrol)
8154{
8155 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8156 long *valp = ucontrol->value.integer.value;
8157 int change;
8158
8159 /* change hp mute */
8160 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8161 HDA_AMP_MUTE,
8162 valp[0] ? 0 : HDA_AMP_MUTE);
8163 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8164 HDA_AMP_MUTE,
8165 valp[1] ? 0 : HDA_AMP_MUTE);
8166 if (change) {
8167 /* change speaker according to HP jack state */
8168 struct alc_spec *spec = codec->spec;
8169 unsigned int mute;
8170 if (spec->jack_present)
8171 mute = HDA_AMP_MUTE;
8172 else
8173 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8174 HDA_OUTPUT, 0);
8175 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8176 HDA_AMP_MUTE, mute);
8177 }
8178 return change;
8179}
Takashi Iwai5b319542007-07-26 11:49:22 +02008180
Kailang Yang272a5272007-05-14 11:00:38 +02008181static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008182 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8183 {
8184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8185 .name = "Master Playback Switch",
8186 .info = snd_hda_mixer_amp_switch_info,
8187 .get = snd_hda_mixer_amp_switch_get,
8188 .put = alc262_sony_master_sw_put,
8189 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8190 },
Kailang Yang272a5272007-05-14 11:00:38 +02008191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8193 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8194 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8195 { } /* end */
8196};
8197
Kailang Yang83c34212007-07-05 11:43:05 +02008198static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8200 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8204 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8205 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8206 { } /* end */
8207};
Kailang Yang272a5272007-05-14 11:00:38 +02008208
Kailang Yangdf694da2005-12-05 19:42:22 +01008209#define alc262_capture_mixer alc882_capture_mixer
8210#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8211
8212/*
8213 * generic initialization of ADC, input mixers and output mixers
8214 */
8215static struct hda_verb alc262_init_verbs[] = {
8216 /*
8217 * Unmute ADC0-2 and set the default input to mic-in
8218 */
8219 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8221 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8223 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8225
Takashi Iwaicb53c622007-08-10 17:21:45 +02008226 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008227 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008228 * Note: PASD motherboards uses the Line In 2 as the input for
8229 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008230 */
8231 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008237
8238 /*
8239 * Set up output mixers (0x0c - 0x0e)
8240 */
8241 /* set vol=0 to output mixers */
8242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8245 /* set up input amps for analog loopback */
8246 /* Amp Indices: DAC = 0, mixer = 1 */
8247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8249 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253
8254 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8256 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8258 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8259 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8260
8261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8266
8267 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8268 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8269
8270 /* FIXME: use matrix-type input source selection */
8271 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8272 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8277 /* Input mixer2 */
8278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8282 /* Input mixer3 */
8283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008287
8288 { }
8289};
8290
Kailang Yangccc656c2006-10-17 12:32:26 +02008291static struct hda_verb alc262_hippo_unsol_verbs[] = {
8292 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8294 {}
8295};
8296
8297static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8298 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8299 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8301
8302 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8303 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8304 {}
8305};
8306
Kailang Yang272a5272007-05-14 11:00:38 +02008307static struct hda_verb alc262_sony_unsol_verbs[] = {
8308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8310 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8311
8312 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8314};
8315
Kailang Yangccc656c2006-10-17 12:32:26 +02008316/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008317static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008318{
8319 struct alc_spec *spec = codec->spec;
8320 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008321 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008322
Takashi Iwai5b319542007-07-26 11:49:22 +02008323 /* need to execute and sync at first */
8324 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8325 present = snd_hda_codec_read(codec, 0x15, 0,
8326 AC_VERB_GET_PIN_SENSE, 0);
8327 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008328 if (spec->jack_present) {
8329 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8331 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008332 } else {
8333 /* unmute internal speaker if necessary */
8334 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008335 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8336 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008337 }
8338}
8339
8340/* unsolicited event for HP jack sensing */
8341static void alc262_hippo_unsol_event(struct hda_codec *codec,
8342 unsigned int res)
8343{
8344 if ((res >> 26) != ALC880_HP_EVENT)
8345 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008346 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008347}
8348
Takashi Iwai5b319542007-07-26 11:49:22 +02008349static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008350{
Kailang Yangccc656c2006-10-17 12:32:26 +02008351 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008352 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008353
Takashi Iwai5b319542007-07-26 11:49:22 +02008354 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8355 present = snd_hda_codec_read(codec, 0x1b, 0,
8356 AC_VERB_GET_PIN_SENSE, 0);
8357 present = (present & 0x80000000) != 0;
8358 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008359 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8361 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008362 } else {
8363 /* unmute internal speaker if necessary */
8364 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008365 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8366 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008367 }
8368}
8369
8370/* unsolicited event for HP jack sensing */
8371static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8372 unsigned int res)
8373{
8374 if ((res >> 26) != ALC880_HP_EVENT)
8375 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008376 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008377}
8378
Takashi Iwai834be882006-03-01 14:16:17 +01008379/*
8380 * fujitsu model
8381 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8382 */
8383
8384#define ALC_HP_EVENT 0x37
8385
8386static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8387 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8389 {}
8390};
8391
8392static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008393 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008394 .items = {
8395 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008396 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008397 { "CD", 0x4 },
8398 },
8399};
8400
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008401static struct hda_input_mux alc262_HP_capture_source = {
8402 .num_items = 5,
8403 .items = {
8404 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008405 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008406 { "Line", 0x2 },
8407 { "CD", 0x4 },
8408 { "AUX IN", 0x6 },
8409 },
8410};
8411
zhejiangaccbe492007-08-31 12:36:05 +02008412static struct hda_input_mux alc262_HP_D7000_capture_source = {
8413 .num_items = 4,
8414 .items = {
8415 { "Mic", 0x0 },
8416 { "Front Mic", 0x2 },
8417 { "Line", 0x1 },
8418 { "CD", 0x4 },
8419 },
8420};
8421
Takashi Iwai834be882006-03-01 14:16:17 +01008422/* mute/unmute internal speaker according to the hp jack and mute state */
8423static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8424{
8425 struct alc_spec *spec = codec->spec;
8426 unsigned int mute;
8427
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008428 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008429 unsigned int present;
8430 /* need to execute and sync at first */
8431 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8432 present = snd_hda_codec_read(codec, 0x14, 0,
8433 AC_VERB_GET_PIN_SENSE, 0);
8434 spec->jack_present = (present & 0x80000000) != 0;
8435 spec->sense_updated = 1;
8436 }
8437 if (spec->jack_present) {
8438 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008439 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8440 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008441 } else {
8442 /* unmute internal speaker if necessary */
8443 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008444 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8445 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008446 }
8447}
8448
8449/* unsolicited event for HP jack sensing */
8450static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8451 unsigned int res)
8452{
8453 if ((res >> 26) != ALC_HP_EVENT)
8454 return;
8455 alc262_fujitsu_automute(codec, 1);
8456}
8457
8458/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008459static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8460 .ops = &snd_hda_bind_vol,
8461 .values = {
8462 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8463 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8464 0
8465 },
8466};
Takashi Iwai834be882006-03-01 14:16:17 +01008467
8468/* bind hp and internal speaker mute (with plug check) */
8469static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8470 struct snd_ctl_elem_value *ucontrol)
8471{
8472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8473 long *valp = ucontrol->value.integer.value;
8474 int change;
8475
8476 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008477 HDA_AMP_MUTE,
8478 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008479 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008480 HDA_AMP_MUTE,
8481 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008482 if (change)
8483 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008484 return change;
8485}
8486
8487static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008488 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008489 {
8490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8491 .name = "Master Playback Switch",
8492 .info = snd_hda_mixer_amp_switch_info,
8493 .get = snd_hda_mixer_amp_switch_get,
8494 .put = alc262_fujitsu_master_sw_put,
8495 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8496 },
8497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8499 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008502 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8503 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8504 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008505 { } /* end */
8506};
8507
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008508/* additional init verbs for Benq laptops */
8509static struct hda_verb alc262_EAPD_verbs[] = {
8510 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8511 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8512 {}
8513};
8514
Kailang Yang83c34212007-07-05 11:43:05 +02008515static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8517 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8518
8519 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8520 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8521 {}
8522};
8523
Tobin Davisf651b502007-10-26 12:40:47 +02008524/* Samsung Q1 Ultra Vista model setup */
8525static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8526 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8527 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8531 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8532 { } /* end */
8533};
8534
8535static struct hda_verb alc262_ultra_verbs[] = {
8536 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8538 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8539 /* Mic is on Node 0x19 */
8540 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8541 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8543 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8545 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8547 {}
8548};
8549
8550static struct hda_input_mux alc262_ultra_capture_source = {
8551 .num_items = 1,
8552 .items = {
8553 { "Mic", 0x1 },
8554 },
8555};
8556
8557/* mute/unmute internal speaker according to the hp jack and mute state */
8558static void alc262_ultra_automute(struct hda_codec *codec)
8559{
8560 struct alc_spec *spec = codec->spec;
8561 unsigned int mute;
8562 unsigned int present;
8563
8564 /* need to execute and sync at first */
8565 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8566 present = snd_hda_codec_read(codec, 0x15, 0,
8567 AC_VERB_GET_PIN_SENSE, 0);
8568 spec->jack_present = (present & 0x80000000) != 0;
8569 if (spec->jack_present) {
8570 /* mute internal speaker */
8571 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8572 HDA_AMP_MUTE, HDA_AMP_MUTE);
8573 } else {
8574 /* unmute internal speaker if necessary */
8575 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8576 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8577 HDA_AMP_MUTE, mute);
8578 }
8579}
8580
8581/* unsolicited event for HP jack sensing */
8582static void alc262_ultra_unsol_event(struct hda_codec *codec,
8583 unsigned int res)
8584{
8585 if ((res >> 26) != ALC880_HP_EVENT)
8586 return;
8587 alc262_ultra_automute(codec);
8588}
8589
Kailang Yangdf694da2005-12-05 19:42:22 +01008590/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008591static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8592 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008593{
8594 hda_nid_t nid;
8595 int err;
8596
8597 spec->multiout.num_dacs = 1; /* only use one dac */
8598 spec->multiout.dac_nids = spec->private_dac_nids;
8599 spec->multiout.dac_nids[0] = 2;
8600
8601 nid = cfg->line_out_pins[0];
8602 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008603 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8604 "Front Playback Volume",
8605 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8606 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008607 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008608 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8609 "Front Playback Switch",
8610 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8611 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008612 return err;
8613 }
8614
Takashi Iwai82bc9552006-03-21 11:24:42 +01008615 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008616 if (nid) {
8617 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008618 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8619 "Speaker Playback Volume",
8620 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8621 HDA_OUTPUT));
8622 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008623 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008624 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8625 "Speaker Playback Switch",
8626 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8627 HDA_OUTPUT));
8628 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008629 return err;
8630 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008631 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8632 "Speaker Playback Switch",
8633 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8634 HDA_OUTPUT));
8635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008636 return err;
8637 }
8638 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008639 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008640 if (nid) {
8641 /* spec->multiout.hp_nid = 2; */
8642 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008643 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8644 "Headphone Playback Volume",
8645 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8646 HDA_OUTPUT));
8647 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008648 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008649 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8650 "Headphone Playback Switch",
8651 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8652 HDA_OUTPUT));
8653 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008654 return err;
8655 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008656 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8657 "Headphone Playback Switch",
8658 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8659 HDA_OUTPUT));
8660 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008661 return err;
8662 }
8663 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008664 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008665}
8666
8667/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008668#define alc262_auto_create_analog_input_ctls \
8669 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008670
8671/*
8672 * generic initialization of ADC, input mixers and output mixers
8673 */
8674static struct hda_verb alc262_volume_init_verbs[] = {
8675 /*
8676 * Unmute ADC0-2 and set the default input to mic-in
8677 */
8678 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8680 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8682 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8684
Takashi Iwaicb53c622007-08-10 17:21:45 +02008685 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008686 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008687 * Note: PASD motherboards uses the Line In 2 as the input for
8688 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008689 */
8690 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008696
8697 /*
8698 * Set up output mixers (0x0c - 0x0f)
8699 */
8700 /* set vol=0 to output mixers */
8701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8704
8705 /* set up input amps for analog loopback */
8706 /* Amp Indices: DAC = 0, mixer = 1 */
8707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8713
8714 /* FIXME: use matrix-type input source selection */
8715 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8716 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8721 /* Input mixer2 */
8722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8726 /* Input mixer3 */
8727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8731
8732 { }
8733};
8734
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008735static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8736 /*
8737 * Unmute ADC0-2 and set the default input to mic-in
8738 */
8739 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8743 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8744 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8745
Takashi Iwaicb53c622007-08-10 17:21:45 +02008746 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008747 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008748 * Note: PASD motherboards uses the Line In 2 as the input for
8749 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008750 */
8751 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008759
8760 /*
8761 * Set up output mixers (0x0c - 0x0e)
8762 */
8763 /* set vol=0 to output mixers */
8764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8767
8768 /* set up input amps for analog loopback */
8769 /* Amp Indices: DAC = 0, mixer = 1 */
8770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8776
8777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8780
8781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8783
8784 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8785 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8786
8787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8789 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8792
8793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8797 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8798 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8799
8800
8801 /* FIXME: use matrix-type input source selection */
8802 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8803 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8808 /* Input mixer2 */
8809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8813 /* Input mixer3 */
8814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8818
8819 { }
8820};
8821
Kailang Yangcd7509a2007-01-26 18:33:17 +01008822static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8823 /*
8824 * Unmute ADC0-2 and set the default input to mic-in
8825 */
8826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8829 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8832
Takashi Iwaicb53c622007-08-10 17:21:45 +02008833 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008834 * mixer widget
8835 * Note: PASD motherboards uses the Line In 2 as the input for front
8836 * panel mic (mic 2)
8837 */
8838 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008847 /*
8848 * Set up output mixers (0x0c - 0x0e)
8849 */
8850 /* set vol=0 to output mixers */
8851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8854
8855 /* set up input amps for analog loopback */
8856 /* Amp Indices: DAC = 0, mixer = 1 */
8857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8863
8864
8865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8866 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8867 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8870 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8871 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8872
8873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8875
8876 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8878
8879 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8880 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8882 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8883 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8884 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8885
8886 /* FIXME: use matrix-type input source selection */
8887 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8888 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8889 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8890 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8891 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8894 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8896 /* Input mixer2 */
8897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8898 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8902 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8904 /* Input mixer3 */
8905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8910 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8912
8913 { }
8914};
8915
Takashi Iwaicb53c622007-08-10 17:21:45 +02008916#ifdef CONFIG_SND_HDA_POWER_SAVE
8917#define alc262_loopbacks alc880_loopbacks
8918#endif
8919
Kailang Yangdf694da2005-12-05 19:42:22 +01008920/* pcm configuration: identiacal with ALC880 */
8921#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8922#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8923#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8924#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8925
8926/*
8927 * BIOS auto configuration
8928 */
8929static int alc262_parse_auto_config(struct hda_codec *codec)
8930{
8931 struct alc_spec *spec = codec->spec;
8932 int err;
8933 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8934
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008935 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8936 alc262_ignore);
8937 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008938 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008939 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008940 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008941 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8942 if (err < 0)
8943 return err;
8944 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8945 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008946 return err;
8947
8948 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8949
8950 if (spec->autocfg.dig_out_pin)
8951 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8952 if (spec->autocfg.dig_in_pin)
8953 spec->dig_in_nid = ALC262_DIGIN_NID;
8954
8955 if (spec->kctl_alloc)
8956 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8957
8958 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008959 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008960 spec->input_mux = &spec->private_imux;
8961
Takashi Iwai776e1842007-08-29 15:07:11 +02008962 err = alc_auto_add_mic_boost(codec);
8963 if (err < 0)
8964 return err;
8965
Kailang Yangdf694da2005-12-05 19:42:22 +01008966 return 1;
8967}
8968
8969#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8970#define alc262_auto_init_hp_out alc882_auto_init_hp_out
8971#define alc262_auto_init_analog_input alc882_auto_init_analog_input
8972
8973
8974/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008975static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008976{
Kailang Yangdf694da2005-12-05 19:42:22 +01008977 alc262_auto_init_multi_out(codec);
8978 alc262_auto_init_hp_out(codec);
8979 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008980}
8981
8982/*
8983 * configuration and preset
8984 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008985static const char *alc262_models[ALC262_MODEL_LAST] = {
8986 [ALC262_BASIC] = "basic",
8987 [ALC262_HIPPO] = "hippo",
8988 [ALC262_HIPPO_1] = "hippo_1",
8989 [ALC262_FUJITSU] = "fujitsu",
8990 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01008991 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01008992 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01008993 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008994 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02008995 [ALC262_BENQ_T31] = "benq-t31",
8996 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02008997 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008998 [ALC262_AUTO] = "auto",
8999};
9000
9001static struct snd_pci_quirk alc262_cfg_tbl[] = {
9002 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9003 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009004 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009005 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9006 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009007 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009008 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009009 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009010 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009011 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009012 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009013 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009014 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009015 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009016 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009017 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009018 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009019 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9020 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9021 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009022 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9023 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009024 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009025 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009026 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009027 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9028 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9029 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009030 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009031 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009032 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009033 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009034 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009035 {}
9036};
9037
9038static struct alc_config_preset alc262_presets[] = {
9039 [ALC262_BASIC] = {
9040 .mixers = { alc262_base_mixer },
9041 .init_verbs = { alc262_init_verbs },
9042 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9043 .dac_nids = alc262_dac_nids,
9044 .hp_nid = 0x03,
9045 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9046 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009047 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009048 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009049 [ALC262_HIPPO] = {
9050 .mixers = { alc262_base_mixer },
9051 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9052 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9053 .dac_nids = alc262_dac_nids,
9054 .hp_nid = 0x03,
9055 .dig_out_nid = ALC262_DIGOUT_NID,
9056 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9057 .channel_mode = alc262_modes,
9058 .input_mux = &alc262_capture_source,
9059 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009060 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009061 },
9062 [ALC262_HIPPO_1] = {
9063 .mixers = { alc262_hippo1_mixer },
9064 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9065 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9066 .dac_nids = alc262_dac_nids,
9067 .hp_nid = 0x02,
9068 .dig_out_nid = ALC262_DIGOUT_NID,
9069 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9070 .channel_mode = alc262_modes,
9071 .input_mux = &alc262_capture_source,
9072 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009073 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009074 },
Takashi Iwai834be882006-03-01 14:16:17 +01009075 [ALC262_FUJITSU] = {
9076 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009077 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9078 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009079 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9080 .dac_nids = alc262_dac_nids,
9081 .hp_nid = 0x03,
9082 .dig_out_nid = ALC262_DIGOUT_NID,
9083 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9084 .channel_mode = alc262_modes,
9085 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009086 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009087 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009088 [ALC262_HP_BPC] = {
9089 .mixers = { alc262_HP_BPC_mixer },
9090 .init_verbs = { alc262_HP_BPC_init_verbs },
9091 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9092 .dac_nids = alc262_dac_nids,
9093 .hp_nid = 0x03,
9094 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9095 .channel_mode = alc262_modes,
9096 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009097 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009098 [ALC262_HP_BPC_D7000_WF] = {
9099 .mixers = { alc262_HP_BPC_WildWest_mixer },
9100 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9101 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9102 .dac_nids = alc262_dac_nids,
9103 .hp_nid = 0x03,
9104 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9105 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009106 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009107 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009108 [ALC262_HP_BPC_D7000_WL] = {
9109 .mixers = { alc262_HP_BPC_WildWest_mixer,
9110 alc262_HP_BPC_WildWest_option_mixer },
9111 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9112 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9113 .dac_nids = alc262_dac_nids,
9114 .hp_nid = 0x03,
9115 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9116 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009117 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009118 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009119 [ALC262_HP_TC_T5735] = {
9120 .mixers = { alc262_hp_t5735_mixer },
9121 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9122 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9123 .dac_nids = alc262_dac_nids,
9124 .hp_nid = 0x03,
9125 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9126 .channel_mode = alc262_modes,
9127 .input_mux = &alc262_capture_source,
9128 .unsol_event = alc262_hp_t5735_unsol_event,
9129 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009130 },
9131 [ALC262_HP_RP5700] = {
9132 .mixers = { alc262_hp_rp5700_mixer },
9133 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9134 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9135 .dac_nids = alc262_dac_nids,
9136 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9137 .channel_mode = alc262_modes,
9138 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009139 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009140 [ALC262_BENQ_ED8] = {
9141 .mixers = { alc262_base_mixer },
9142 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9143 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9144 .dac_nids = alc262_dac_nids,
9145 .hp_nid = 0x03,
9146 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9147 .channel_mode = alc262_modes,
9148 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009149 },
Kailang Yang272a5272007-05-14 11:00:38 +02009150 [ALC262_SONY_ASSAMD] = {
9151 .mixers = { alc262_sony_mixer },
9152 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9153 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9154 .dac_nids = alc262_dac_nids,
9155 .hp_nid = 0x02,
9156 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9157 .channel_mode = alc262_modes,
9158 .input_mux = &alc262_capture_source,
9159 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009160 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009161 },
9162 [ALC262_BENQ_T31] = {
9163 .mixers = { alc262_benq_t31_mixer },
9164 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9165 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9166 .dac_nids = alc262_dac_nids,
9167 .hp_nid = 0x03,
9168 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9169 .channel_mode = alc262_modes,
9170 .input_mux = &alc262_capture_source,
9171 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009172 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009173 },
Tobin Davisf651b502007-10-26 12:40:47 +02009174 [ALC262_ULTRA] = {
9175 .mixers = { alc262_ultra_mixer },
9176 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9177 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9178 .dac_nids = alc262_dac_nids,
9179 .hp_nid = 0x03,
9180 .dig_out_nid = ALC262_DIGOUT_NID,
9181 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9182 .channel_mode = alc262_modes,
9183 .input_mux = &alc262_ultra_capture_source,
9184 .unsol_event = alc262_ultra_unsol_event,
9185 .init_hook = alc262_ultra_automute,
9186 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009187};
9188
9189static int patch_alc262(struct hda_codec *codec)
9190{
9191 struct alc_spec *spec;
9192 int board_config;
9193 int err;
9194
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009195 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009196 if (spec == NULL)
9197 return -ENOMEM;
9198
9199 codec->spec = spec;
9200#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009201 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9202 * under-run
9203 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009204 {
9205 int tmp;
9206 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9207 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9208 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9209 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9210 }
9211#endif
9212
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009213 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9214 alc262_models,
9215 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009216
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009217 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009218 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9219 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009220 board_config = ALC262_AUTO;
9221 }
9222
9223 if (board_config == ALC262_AUTO) {
9224 /* automatic parse from the BIOS config */
9225 err = alc262_parse_auto_config(codec);
9226 if (err < 0) {
9227 alc_free(codec);
9228 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009229 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009230 printk(KERN_INFO
9231 "hda_codec: Cannot set up configuration "
9232 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009233 board_config = ALC262_BASIC;
9234 }
9235 }
9236
9237 if (board_config != ALC262_AUTO)
9238 setup_preset(spec, &alc262_presets[board_config]);
9239
9240 spec->stream_name_analog = "ALC262 Analog";
9241 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9242 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9243
9244 spec->stream_name_digital = "ALC262 Digital";
9245 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9246 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9247
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009248 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009249 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009250 unsigned int wcap = get_wcaps(codec, 0x07);
9251
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009252 /* get type */
9253 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009254 if (wcap != AC_WID_AUD_IN) {
9255 spec->adc_nids = alc262_adc_nids_alt;
9256 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009257 spec->mixers[spec->num_mixers] =
9258 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009259 spec->num_mixers++;
9260 } else {
9261 spec->adc_nids = alc262_adc_nids;
9262 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9263 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9264 spec->num_mixers++;
9265 }
9266 }
9267
Takashi Iwai2134ea42008-01-10 16:53:55 +01009268 spec->vmaster_nid = 0x0c;
9269
Kailang Yangdf694da2005-12-05 19:42:22 +01009270 codec->patch_ops = alc_patch_ops;
9271 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009272 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009273#ifdef CONFIG_SND_HDA_POWER_SAVE
9274 if (!spec->loopback.amplist)
9275 spec->loopback.amplist = alc262_loopbacks;
9276#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009277
Kailang Yangdf694da2005-12-05 19:42:22 +01009278 return 0;
9279}
9280
Kailang Yangdf694da2005-12-05 19:42:22 +01009281/*
Kailang Yanga361d842007-06-05 12:30:55 +02009282 * ALC268 channel source setting (2 channel)
9283 */
9284#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9285#define alc268_modes alc260_modes
9286
9287static hda_nid_t alc268_dac_nids[2] = {
9288 /* front, hp */
9289 0x02, 0x03
9290};
9291
9292static hda_nid_t alc268_adc_nids[2] = {
9293 /* ADC0-1 */
9294 0x08, 0x07
9295};
9296
9297static hda_nid_t alc268_adc_nids_alt[1] = {
9298 /* ADC0 */
9299 0x08
9300};
9301
9302static struct snd_kcontrol_new alc268_base_mixer[] = {
9303 /* output mixer control */
9304 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9305 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009308 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9309 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9310 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009311 { }
9312};
9313
Kailang Yangd1a991a2007-08-15 16:21:59 +02009314static struct hda_verb alc268_eapd_verbs[] = {
9315 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9316 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9317 { }
9318};
9319
Takashi Iwaid2738092007-08-16 14:59:45 +02009320/* Toshiba specific */
9321#define alc268_toshiba_automute alc262_hippo_automute
9322
9323static struct hda_verb alc268_toshiba_verbs[] = {
9324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9325 { } /* end */
9326};
9327
9328/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009329/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009330static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9331 .ops = &snd_hda_bind_vol,
9332 .values = {
9333 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9334 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9335 0
9336 },
9337};
9338
Takashi Iwai889c4392007-08-23 18:56:52 +02009339/* mute/unmute internal speaker according to the hp jack and mute state */
9340static void alc268_acer_automute(struct hda_codec *codec, int force)
9341{
9342 struct alc_spec *spec = codec->spec;
9343 unsigned int mute;
9344
9345 if (force || !spec->sense_updated) {
9346 unsigned int present;
9347 present = snd_hda_codec_read(codec, 0x14, 0,
9348 AC_VERB_GET_PIN_SENSE, 0);
9349 spec->jack_present = (present & 0x80000000) != 0;
9350 spec->sense_updated = 1;
9351 }
9352 if (spec->jack_present)
9353 mute = HDA_AMP_MUTE; /* mute internal speaker */
9354 else /* unmute internal speaker if necessary */
9355 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9356 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9357 HDA_AMP_MUTE, mute);
9358}
9359
9360
9361/* bind hp and internal speaker mute (with plug check) */
9362static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9363 struct snd_ctl_elem_value *ucontrol)
9364{
9365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9366 long *valp = ucontrol->value.integer.value;
9367 int change;
9368
9369 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9370 HDA_AMP_MUTE,
9371 valp[0] ? 0 : HDA_AMP_MUTE);
9372 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9373 HDA_AMP_MUTE,
9374 valp[1] ? 0 : HDA_AMP_MUTE);
9375 if (change)
9376 alc268_acer_automute(codec, 0);
9377 return change;
9378}
Takashi Iwaid2738092007-08-16 14:59:45 +02009379
9380static struct snd_kcontrol_new alc268_acer_mixer[] = {
9381 /* output mixer control */
9382 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9383 {
9384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9385 .name = "Master Playback Switch",
9386 .info = snd_hda_mixer_amp_switch_info,
9387 .get = snd_hda_mixer_amp_switch_get,
9388 .put = alc268_acer_master_sw_put,
9389 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9390 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9392 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9393 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009394 { }
9395};
9396
9397static struct hda_verb alc268_acer_verbs[] = {
9398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9400
9401 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9402 { }
9403};
9404
9405/* unsolicited event for HP jack sensing */
9406static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9407 unsigned int res)
9408{
Takashi Iwai889c4392007-08-23 18:56:52 +02009409 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009410 return;
9411 alc268_toshiba_automute(codec);
9412}
9413
9414static void alc268_acer_unsol_event(struct hda_codec *codec,
9415 unsigned int res)
9416{
Takashi Iwai889c4392007-08-23 18:56:52 +02009417 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009418 return;
9419 alc268_acer_automute(codec, 1);
9420}
9421
Takashi Iwai889c4392007-08-23 18:56:52 +02009422static void alc268_acer_init_hook(struct hda_codec *codec)
9423{
9424 alc268_acer_automute(codec, 1);
9425}
9426
Kailang Yanga361d842007-06-05 12:30:55 +02009427/*
9428 * generic initialization of ADC, input mixers and output mixers
9429 */
9430static struct hda_verb alc268_base_init_verbs[] = {
9431 /* Unmute DAC0-1 and set vol = 0 */
9432 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9433 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9434 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9435 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9437 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9438
9439 /*
9440 * Set up output mixers (0x0c - 0x0e)
9441 */
9442 /* set vol=0 to output mixers */
9443 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9446 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9447
9448 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9449 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9450
9451 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9454 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9457 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9458 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9459
9460 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9462 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9463 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9465 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9466 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9467 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9468
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009469 /* Unmute Selector 23h,24h and set the default input to mic-in */
9470
9471 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9473 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009475
Kailang Yanga361d842007-06-05 12:30:55 +02009476 { }
9477};
9478
9479/*
9480 * generic initialization of ADC, input mixers and output mixers
9481 */
9482static struct hda_verb alc268_volume_init_verbs[] = {
9483 /* set output DAC */
9484 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9485 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9486 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9487 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9488
9489 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9490 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9492 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9493 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9494
9495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9496 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9498 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9499 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9500
9501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9504 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9505
9506 /* set PCBEEP vol = 0 */
9507 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9508
9509 { }
9510};
9511
9512#define alc268_mux_enum_info alc_mux_enum_info
9513#define alc268_mux_enum_get alc_mux_enum_get
9514
9515static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9516 struct snd_ctl_elem_value *ucontrol)
9517{
9518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9519 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009520
Kailang Yanga361d842007-06-05 12:30:55 +02009521 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9522 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9523 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009524
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009525 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9526 nid,
9527 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009528}
9529
9530static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9531 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9532 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9533 {
9534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9535 /* The multiple "Capture Source" controls confuse alsamixer
9536 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009537 */
9538 /* .name = "Capture Source", */
9539 .name = "Input Source",
9540 .count = 1,
9541 .info = alc268_mux_enum_info,
9542 .get = alc268_mux_enum_get,
9543 .put = alc268_mux_enum_put,
9544 },
9545 { } /* end */
9546};
9547
9548static struct snd_kcontrol_new alc268_capture_mixer[] = {
9549 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9550 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9551 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9552 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9553 {
9554 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9555 /* The multiple "Capture Source" controls confuse alsamixer
9556 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009557 */
9558 /* .name = "Capture Source", */
9559 .name = "Input Source",
9560 .count = 2,
9561 .info = alc268_mux_enum_info,
9562 .get = alc268_mux_enum_get,
9563 .put = alc268_mux_enum_put,
9564 },
9565 { } /* end */
9566};
9567
9568static struct hda_input_mux alc268_capture_source = {
9569 .num_items = 4,
9570 .items = {
9571 { "Mic", 0x0 },
9572 { "Front Mic", 0x1 },
9573 { "Line", 0x2 },
9574 { "CD", 0x3 },
9575 },
9576};
9577
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009578#ifdef CONFIG_SND_DEBUG
9579static struct snd_kcontrol_new alc268_test_mixer[] = {
9580 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9581 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9582 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9584
9585 /* Volume widgets */
9586 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9587 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9588 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9589 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9590 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9591 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9592 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9593 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9594 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9595 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9596 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9597 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9598 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009599 /* The below appears problematic on some hardwares */
9600 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009601 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9602 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9603 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9604 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9605
9606 /* Modes for retasking pin widgets */
9607 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9608 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9609 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9610 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9611
9612 /* Controls for GPIO pins, assuming they are configured as outputs */
9613 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9614 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9615 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9616 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9617
9618 /* Switches to allow the digital SPDIF output pin to be enabled.
9619 * The ALC268 does not have an SPDIF input.
9620 */
9621 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9622
9623 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9624 * this output to turn on an external amplifier.
9625 */
9626 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9627 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9628
9629 { } /* end */
9630};
9631#endif
9632
Kailang Yanga361d842007-06-05 12:30:55 +02009633/* create input playback/capture controls for the given pin */
9634static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9635 const char *ctlname, int idx)
9636{
9637 char name[32];
9638 int err;
9639
9640 sprintf(name, "%s Playback Volume", ctlname);
9641 if (nid == 0x14) {
9642 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9643 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9644 HDA_OUTPUT));
9645 if (err < 0)
9646 return err;
9647 } else if (nid == 0x15) {
9648 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9649 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9650 HDA_OUTPUT));
9651 if (err < 0)
9652 return err;
9653 } else
9654 return -1;
9655 sprintf(name, "%s Playback Switch", ctlname);
9656 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9657 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9658 if (err < 0)
9659 return err;
9660 return 0;
9661}
9662
9663/* add playback controls from the parsed DAC table */
9664static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9665 const struct auto_pin_cfg *cfg)
9666{
9667 hda_nid_t nid;
9668 int err;
9669
9670 spec->multiout.num_dacs = 2; /* only use one dac */
9671 spec->multiout.dac_nids = spec->private_dac_nids;
9672 spec->multiout.dac_nids[0] = 2;
9673 spec->multiout.dac_nids[1] = 3;
9674
9675 nid = cfg->line_out_pins[0];
9676 if (nid)
9677 alc268_new_analog_output(spec, nid, "Front", 0);
9678
9679 nid = cfg->speaker_pins[0];
9680 if (nid == 0x1d) {
9681 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9682 "Speaker Playback Volume",
9683 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9684 if (err < 0)
9685 return err;
9686 }
9687 nid = cfg->hp_pins[0];
9688 if (nid)
9689 alc268_new_analog_output(spec, nid, "Headphone", 0);
9690
9691 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9692 if (nid == 0x16) {
9693 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9694 "Mono Playback Switch",
9695 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9696 if (err < 0)
9697 return err;
9698 }
9699 return 0;
9700}
9701
9702/* create playback/capture controls for input pins */
9703static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9704 const struct auto_pin_cfg *cfg)
9705{
9706 struct hda_input_mux *imux = &spec->private_imux;
9707 int i, idx1;
9708
9709 for (i = 0; i < AUTO_PIN_LAST; i++) {
9710 switch(cfg->input_pins[i]) {
9711 case 0x18:
9712 idx1 = 0; /* Mic 1 */
9713 break;
9714 case 0x19:
9715 idx1 = 1; /* Mic 2 */
9716 break;
9717 case 0x1a:
9718 idx1 = 2; /* Line In */
9719 break;
9720 case 0x1c:
9721 idx1 = 3; /* CD */
9722 break;
9723 default:
9724 continue;
9725 }
9726 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9727 imux->items[imux->num_items].index = idx1;
9728 imux->num_items++;
9729 }
9730 return 0;
9731}
9732
9733static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9734{
9735 struct alc_spec *spec = codec->spec;
9736 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9737 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9738 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9739 unsigned int dac_vol1, dac_vol2;
9740
9741 if (speaker_nid) {
9742 snd_hda_codec_write(codec, speaker_nid, 0,
9743 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9744 snd_hda_codec_write(codec, 0x0f, 0,
9745 AC_VERB_SET_AMP_GAIN_MUTE,
9746 AMP_IN_UNMUTE(1));
9747 snd_hda_codec_write(codec, 0x10, 0,
9748 AC_VERB_SET_AMP_GAIN_MUTE,
9749 AMP_IN_UNMUTE(1));
9750 } else {
9751 snd_hda_codec_write(codec, 0x0f, 0,
9752 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9753 snd_hda_codec_write(codec, 0x10, 0,
9754 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9755 }
9756
9757 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9758 if (line_nid == 0x14)
9759 dac_vol2 = AMP_OUT_ZERO;
9760 else if (line_nid == 0x15)
9761 dac_vol1 = AMP_OUT_ZERO;
9762 if (hp_nid == 0x14)
9763 dac_vol2 = AMP_OUT_ZERO;
9764 else if (hp_nid == 0x15)
9765 dac_vol1 = AMP_OUT_ZERO;
9766 if (line_nid != 0x16 || hp_nid != 0x16 ||
9767 spec->autocfg.line_out_pins[1] != 0x16 ||
9768 spec->autocfg.line_out_pins[2] != 0x16)
9769 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9770
9771 snd_hda_codec_write(codec, 0x02, 0,
9772 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9773 snd_hda_codec_write(codec, 0x03, 0,
9774 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9775}
9776
9777/* pcm configuration: identiacal with ALC880 */
9778#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9779#define alc268_pcm_analog_capture alc880_pcm_analog_capture
9780#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9781
9782/*
9783 * BIOS auto configuration
9784 */
9785static int alc268_parse_auto_config(struct hda_codec *codec)
9786{
9787 struct alc_spec *spec = codec->spec;
9788 int err;
9789 static hda_nid_t alc268_ignore[] = { 0 };
9790
9791 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9792 alc268_ignore);
9793 if (err < 0)
9794 return err;
9795 if (!spec->autocfg.line_outs)
9796 return 0; /* can't find valid BIOS pin config */
9797
9798 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9799 if (err < 0)
9800 return err;
9801 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9802 if (err < 0)
9803 return err;
9804
9805 spec->multiout.max_channels = 2;
9806
9807 /* digital only support output */
9808 if (spec->autocfg.dig_out_pin)
9809 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9810
9811 if (spec->kctl_alloc)
9812 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9813
9814 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9815 spec->num_mux_defs = 1;
9816 spec->input_mux = &spec->private_imux;
9817
Takashi Iwai776e1842007-08-29 15:07:11 +02009818 err = alc_auto_add_mic_boost(codec);
9819 if (err < 0)
9820 return err;
9821
Kailang Yanga361d842007-06-05 12:30:55 +02009822 return 1;
9823}
9824
9825#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9826#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9827#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9828
9829/* init callback for auto-configuration model -- overriding the default init */
9830static void alc268_auto_init(struct hda_codec *codec)
9831{
9832 alc268_auto_init_multi_out(codec);
9833 alc268_auto_init_hp_out(codec);
9834 alc268_auto_init_mono_speaker_out(codec);
9835 alc268_auto_init_analog_input(codec);
9836}
9837
9838/*
9839 * configuration and preset
9840 */
9841static const char *alc268_models[ALC268_MODEL_LAST] = {
9842 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009843 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009844 [ALC268_ACER] = "acer",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009845#ifdef CONFIG_SND_DEBUG
9846 [ALC268_TEST] = "test",
9847#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009848 [ALC268_AUTO] = "auto",
9849};
9850
9851static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009852 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9853 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9854 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +02009855 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009856 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009857 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009858 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009859 {}
9860};
9861
9862static struct alc_config_preset alc268_presets[] = {
9863 [ALC268_3ST] = {
9864 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9865 .init_verbs = { alc268_base_init_verbs },
9866 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9867 .dac_nids = alc268_dac_nids,
9868 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9869 .adc_nids = alc268_adc_nids_alt,
9870 .hp_nid = 0x03,
9871 .dig_out_nid = ALC268_DIGOUT_NID,
9872 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9873 .channel_mode = alc268_modes,
9874 .input_mux = &alc268_capture_source,
9875 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009876 [ALC268_TOSHIBA] = {
9877 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009878 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9879 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009880 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9881 .dac_nids = alc268_dac_nids,
9882 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9883 .adc_nids = alc268_adc_nids_alt,
9884 .hp_nid = 0x03,
9885 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9886 .channel_mode = alc268_modes,
9887 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009888 .unsol_event = alc268_toshiba_unsol_event,
9889 .init_hook = alc268_toshiba_automute,
9890 },
9891 [ALC268_ACER] = {
9892 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9893 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9894 alc268_acer_verbs },
9895 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9896 .dac_nids = alc268_dac_nids,
9897 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9898 .adc_nids = alc268_adc_nids_alt,
9899 .hp_nid = 0x02,
9900 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9901 .channel_mode = alc268_modes,
9902 .input_mux = &alc268_capture_source,
9903 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009904 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009905 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009906#ifdef CONFIG_SND_DEBUG
9907 [ALC268_TEST] = {
9908 .mixers = { alc268_test_mixer, alc268_capture_mixer },
9909 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9910 alc268_volume_init_verbs },
9911 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9912 .dac_nids = alc268_dac_nids,
9913 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9914 .adc_nids = alc268_adc_nids_alt,
9915 .hp_nid = 0x03,
9916 .dig_out_nid = ALC268_DIGOUT_NID,
9917 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9918 .channel_mode = alc268_modes,
9919 .input_mux = &alc268_capture_source,
9920 },
9921#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009922};
9923
9924static int patch_alc268(struct hda_codec *codec)
9925{
9926 struct alc_spec *spec;
9927 int board_config;
9928 int err;
9929
9930 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9931 if (spec == NULL)
9932 return -ENOMEM;
9933
9934 codec->spec = spec;
9935
9936 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9937 alc268_models,
9938 alc268_cfg_tbl);
9939
9940 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9941 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9942 "trying auto-probe from BIOS...\n");
9943 board_config = ALC268_AUTO;
9944 }
9945
9946 if (board_config == ALC268_AUTO) {
9947 /* automatic parse from the BIOS config */
9948 err = alc268_parse_auto_config(codec);
9949 if (err < 0) {
9950 alc_free(codec);
9951 return err;
9952 } else if (!err) {
9953 printk(KERN_INFO
9954 "hda_codec: Cannot set up configuration "
9955 "from BIOS. Using base mode...\n");
9956 board_config = ALC268_3ST;
9957 }
9958 }
9959
9960 if (board_config != ALC268_AUTO)
9961 setup_preset(spec, &alc268_presets[board_config]);
9962
9963 spec->stream_name_analog = "ALC268 Analog";
9964 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9965 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9966
9967 spec->stream_name_digital = "ALC268 Digital";
9968 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9969
9970 if (board_config == ALC268_AUTO) {
9971 if (!spec->adc_nids && spec->input_mux) {
9972 /* check whether NID 0x07 is valid */
9973 unsigned int wcap = get_wcaps(codec, 0x07);
9974
9975 /* get type */
9976 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9977 if (wcap != AC_WID_AUD_IN) {
9978 spec->adc_nids = alc268_adc_nids_alt;
9979 spec->num_adc_nids =
9980 ARRAY_SIZE(alc268_adc_nids_alt);
9981 spec->mixers[spec->num_mixers] =
9982 alc268_capture_alt_mixer;
9983 spec->num_mixers++;
9984 } else {
9985 spec->adc_nids = alc268_adc_nids;
9986 spec->num_adc_nids =
9987 ARRAY_SIZE(alc268_adc_nids);
9988 spec->mixers[spec->num_mixers] =
9989 alc268_capture_mixer;
9990 spec->num_mixers++;
9991 }
9992 }
9993 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01009994
9995 spec->vmaster_nid = 0x02;
9996
Kailang Yanga361d842007-06-05 12:30:55 +02009997 codec->patch_ops = alc_patch_ops;
9998 if (board_config == ALC268_AUTO)
9999 spec->init_hook = alc268_auto_init;
10000
10001 return 0;
10002}
10003
10004/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010005 * ALC269 channel source setting (2 channel)
10006 */
10007#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10008
10009#define alc269_dac_nids alc260_dac_nids
10010
10011static hda_nid_t alc269_adc_nids[1] = {
10012 /* ADC1 */
10013 0x07,
10014};
10015
10016#define alc269_modes alc260_modes
10017#define alc269_capture_source alc880_lg_lw_capture_source
10018
10019static struct snd_kcontrol_new alc269_base_mixer[] = {
10020 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10021 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10026 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10029 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10031 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10032 { } /* end */
10033};
10034
10035/* capture mixer elements */
10036static struct snd_kcontrol_new alc269_capture_mixer[] = {
10037 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10038 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10039 {
10040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10041 /* The multiple "Capture Source" controls confuse alsamixer
10042 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010043 */
10044 /* .name = "Capture Source", */
10045 .name = "Input Source",
10046 .count = 1,
10047 .info = alc_mux_enum_info,
10048 .get = alc_mux_enum_get,
10049 .put = alc_mux_enum_put,
10050 },
10051 { } /* end */
10052};
10053
10054/*
10055 * generic initialization of ADC, input mixers and output mixers
10056 */
10057static struct hda_verb alc269_init_verbs[] = {
10058 /*
10059 * Unmute ADC0 and set the default input to mic-in
10060 */
10061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10062
10063 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10064 * analog-loopback mixer widget
10065 * Note: PASD motherboards uses the Line In 2 as the input for
10066 * front panel mic (mic 2)
10067 */
10068 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10074
10075 /*
10076 * Set up output mixers (0x0c - 0x0e)
10077 */
10078 /* set vol=0 to output mixers */
10079 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10080 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10081
10082 /* set up input amps for analog loopback */
10083 /* Amp Indices: DAC = 0, mixer = 1 */
10084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10086 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10090
10091 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10098
10099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10101 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10102 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10106
10107 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10108 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10109
10110 /* FIXME: use matrix-type input source selection */
10111 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10112 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10117
10118 /* set EAPD */
10119 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10120 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10121 { }
10122};
10123
10124/* add playback controls from the parsed DAC table */
10125static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10126 const struct auto_pin_cfg *cfg)
10127{
10128 hda_nid_t nid;
10129 int err;
10130
10131 spec->multiout.num_dacs = 1; /* only use one dac */
10132 spec->multiout.dac_nids = spec->private_dac_nids;
10133 spec->multiout.dac_nids[0] = 2;
10134
10135 nid = cfg->line_out_pins[0];
10136 if (nid) {
10137 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10138 "Front Playback Volume",
10139 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10140 if (err < 0)
10141 return err;
10142 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10143 "Front Playback Switch",
10144 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10145 if (err < 0)
10146 return err;
10147 }
10148
10149 nid = cfg->speaker_pins[0];
10150 if (nid) {
10151 if (!cfg->line_out_pins[0]) {
10152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10153 "Speaker Playback Volume",
10154 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10155 HDA_OUTPUT));
10156 if (err < 0)
10157 return err;
10158 }
10159 if (nid == 0x16) {
10160 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10161 "Speaker Playback Switch",
10162 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10163 HDA_OUTPUT));
10164 if (err < 0)
10165 return err;
10166 } else {
10167 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10168 "Speaker Playback Switch",
10169 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10170 HDA_OUTPUT));
10171 if (err < 0)
10172 return err;
10173 }
10174 }
10175 nid = cfg->hp_pins[0];
10176 if (nid) {
10177 /* spec->multiout.hp_nid = 2; */
10178 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10179 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10180 "Headphone Playback Volume",
10181 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10182 HDA_OUTPUT));
10183 if (err < 0)
10184 return err;
10185 }
10186 if (nid == 0x16) {
10187 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10188 "Headphone Playback Switch",
10189 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10190 HDA_OUTPUT));
10191 if (err < 0)
10192 return err;
10193 } else {
10194 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10195 "Headphone Playback Switch",
10196 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10197 HDA_OUTPUT));
10198 if (err < 0)
10199 return err;
10200 }
10201 }
10202 return 0;
10203}
10204
10205#define alc269_auto_create_analog_input_ctls \
10206 alc880_auto_create_analog_input_ctls
10207
10208#ifdef CONFIG_SND_HDA_POWER_SAVE
10209#define alc269_loopbacks alc880_loopbacks
10210#endif
10211
10212/* pcm configuration: identiacal with ALC880 */
10213#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10214#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10215#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10216#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10217
10218/*
10219 * BIOS auto configuration
10220 */
10221static int alc269_parse_auto_config(struct hda_codec *codec)
10222{
10223 struct alc_spec *spec = codec->spec;
10224 int err;
10225 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10226
10227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10228 alc269_ignore);
10229 if (err < 0)
10230 return err;
10231
10232 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10233 if (err < 0)
10234 return err;
10235 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10236 if (err < 0)
10237 return err;
10238
10239 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10240
10241 if (spec->autocfg.dig_out_pin)
10242 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10243
10244 if (spec->kctl_alloc)
10245 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10246
10247 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10248 spec->num_mux_defs = 1;
10249 spec->input_mux = &spec->private_imux;
10250
10251 err = alc_auto_add_mic_boost(codec);
10252 if (err < 0)
10253 return err;
10254
10255 return 1;
10256}
10257
10258#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10259#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10260#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10261
10262
10263/* init callback for auto-configuration model -- overriding the default init */
10264static void alc269_auto_init(struct hda_codec *codec)
10265{
10266 alc269_auto_init_multi_out(codec);
10267 alc269_auto_init_hp_out(codec);
10268 alc269_auto_init_analog_input(codec);
10269}
10270
10271/*
10272 * configuration and preset
10273 */
10274static const char *alc269_models[ALC269_MODEL_LAST] = {
10275 [ALC269_BASIC] = "basic",
10276};
10277
10278static struct snd_pci_quirk alc269_cfg_tbl[] = {
10279 {}
10280};
10281
10282static struct alc_config_preset alc269_presets[] = {
10283 [ALC269_BASIC] = {
10284 .mixers = { alc269_base_mixer },
10285 .init_verbs = { alc269_init_verbs },
10286 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10287 .dac_nids = alc269_dac_nids,
10288 .hp_nid = 0x03,
10289 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10290 .channel_mode = alc269_modes,
10291 .input_mux = &alc269_capture_source,
10292 },
10293};
10294
10295static int patch_alc269(struct hda_codec *codec)
10296{
10297 struct alc_spec *spec;
10298 int board_config;
10299 int err;
10300
10301 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10302 if (spec == NULL)
10303 return -ENOMEM;
10304
10305 codec->spec = spec;
10306
10307 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10308 alc269_models,
10309 alc269_cfg_tbl);
10310
10311 if (board_config < 0) {
10312 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10313 "trying auto-probe from BIOS...\n");
10314 board_config = ALC269_AUTO;
10315 }
10316
10317 if (board_config == ALC269_AUTO) {
10318 /* automatic parse from the BIOS config */
10319 err = alc269_parse_auto_config(codec);
10320 if (err < 0) {
10321 alc_free(codec);
10322 return err;
10323 } else if (!err) {
10324 printk(KERN_INFO
10325 "hda_codec: Cannot set up configuration "
10326 "from BIOS. Using base mode...\n");
10327 board_config = ALC269_BASIC;
10328 }
10329 }
10330
10331 if (board_config != ALC269_AUTO)
10332 setup_preset(spec, &alc269_presets[board_config]);
10333
10334 spec->stream_name_analog = "ALC269 Analog";
10335 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10336 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10337
10338 spec->stream_name_digital = "ALC269 Digital";
10339 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10340 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10341
10342 spec->adc_nids = alc269_adc_nids;
10343 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10344 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10345 spec->num_mixers++;
10346
10347 codec->patch_ops = alc_patch_ops;
10348 if (board_config == ALC269_AUTO)
10349 spec->init_hook = alc269_auto_init;
10350#ifdef CONFIG_SND_HDA_POWER_SAVE
10351 if (!spec->loopback.amplist)
10352 spec->loopback.amplist = alc269_loopbacks;
10353#endif
10354
10355 return 0;
10356}
10357
10358/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010359 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10360 */
10361
10362/*
10363 * set the path ways for 2 channel output
10364 * need to set the codec line out and mic 1 pin widgets to inputs
10365 */
10366static struct hda_verb alc861_threestack_ch2_init[] = {
10367 /* set pin widget 1Ah (line in) for input */
10368 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010369 /* set pin widget 18h (mic1/2) for input, for mic also enable
10370 * the vref
10371 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010372 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10373
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10375#if 0
10376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10378#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010379 { } /* end */
10380};
10381/*
10382 * 6ch mode
10383 * need to set the codec line out and mic 1 pin widgets to outputs
10384 */
10385static struct hda_verb alc861_threestack_ch6_init[] = {
10386 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10387 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10388 /* set pin widget 18h (mic1) for output (CLFE)*/
10389 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10390
10391 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010392 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010393
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010394 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10395#if 0
10396 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10397 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10398#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010399 { } /* end */
10400};
10401
10402static struct hda_channel_mode alc861_threestack_modes[2] = {
10403 { 2, alc861_threestack_ch2_init },
10404 { 6, alc861_threestack_ch6_init },
10405};
Takashi Iwai22309c32006-08-09 16:57:28 +020010406/* Set mic1 as input and unmute the mixer */
10407static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10408 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10409 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10410 { } /* end */
10411};
10412/* Set mic1 as output and mute mixer */
10413static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10414 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10415 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10416 { } /* end */
10417};
10418
10419static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10420 { 2, alc861_uniwill_m31_ch2_init },
10421 { 4, alc861_uniwill_m31_ch4_init },
10422};
Kailang Yangdf694da2005-12-05 19:42:22 +010010423
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010424/* Set mic1 and line-in as input and unmute the mixer */
10425static struct hda_verb alc861_asus_ch2_init[] = {
10426 /* set pin widget 1Ah (line in) for input */
10427 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010428 /* set pin widget 18h (mic1/2) for input, for mic also enable
10429 * the vref
10430 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010431 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10432
10433 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10434#if 0
10435 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10436 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10437#endif
10438 { } /* end */
10439};
10440/* Set mic1 nad line-in as output and mute mixer */
10441static struct hda_verb alc861_asus_ch6_init[] = {
10442 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10443 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10444 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10445 /* set pin widget 18h (mic1) for output (CLFE)*/
10446 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10447 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10448 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10449 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10450
10451 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10452#if 0
10453 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10454 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10455#endif
10456 { } /* end */
10457};
10458
10459static struct hda_channel_mode alc861_asus_modes[2] = {
10460 { 2, alc861_asus_ch2_init },
10461 { 6, alc861_asus_ch6_init },
10462};
10463
Kailang Yangdf694da2005-12-05 19:42:22 +010010464/* patch-ALC861 */
10465
10466static struct snd_kcontrol_new alc861_base_mixer[] = {
10467 /* output mixer control */
10468 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10469 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10470 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10471 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10472 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10473
10474 /*Input mixer control */
10475 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10476 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10477 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10478 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10479 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10480 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10482 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010485
Kailang Yangdf694da2005-12-05 19:42:22 +010010486 /* Capture mixer control */
10487 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10488 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10489 {
10490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10491 .name = "Capture Source",
10492 .count = 1,
10493 .info = alc_mux_enum_info,
10494 .get = alc_mux_enum_get,
10495 .put = alc_mux_enum_put,
10496 },
10497 { } /* end */
10498};
10499
10500static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10501 /* output mixer control */
10502 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10503 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10504 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10505 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10506 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10507
10508 /* Input mixer control */
10509 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10510 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10511 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10512 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10513 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10514 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10516 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10518 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010519
Kailang Yangdf694da2005-12-05 19:42:22 +010010520 /* Capture mixer control */
10521 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10522 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10523 {
10524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10525 .name = "Capture Source",
10526 .count = 1,
10527 .info = alc_mux_enum_info,
10528 .get = alc_mux_enum_get,
10529 .put = alc_mux_enum_put,
10530 },
10531 {
10532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10533 .name = "Channel Mode",
10534 .info = alc_ch_mode_info,
10535 .get = alc_ch_mode_get,
10536 .put = alc_ch_mode_put,
10537 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10538 },
10539 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010540};
10541
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010542static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010543 /* output mixer control */
10544 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10546 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10547
10548 /*Capture mixer control */
10549 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10550 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10551 {
10552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10553 .name = "Capture Source",
10554 .count = 1,
10555 .info = alc_mux_enum_info,
10556 .get = alc_mux_enum_get,
10557 .put = alc_mux_enum_put,
10558 },
10559
10560 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010561};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010562
Takashi Iwai22309c32006-08-09 16:57:28 +020010563static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10564 /* output mixer control */
10565 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10567 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10569 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10570
10571 /* Input mixer control */
10572 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10573 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10574 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10575 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10576 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10577 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10579 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10580 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010582
Takashi Iwai22309c32006-08-09 16:57:28 +020010583 /* Capture mixer control */
10584 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10585 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10586 {
10587 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10588 .name = "Capture Source",
10589 .count = 1,
10590 .info = alc_mux_enum_info,
10591 .get = alc_mux_enum_get,
10592 .put = alc_mux_enum_put,
10593 },
10594 {
10595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10596 .name = "Channel Mode",
10597 .info = alc_ch_mode_info,
10598 .get = alc_ch_mode_get,
10599 .put = alc_ch_mode_put,
10600 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10601 },
10602 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010603};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010604
10605static struct snd_kcontrol_new alc861_asus_mixer[] = {
10606 /* output mixer control */
10607 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10608 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10609 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10610 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10611 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10612
10613 /* Input mixer control */
10614 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10615 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10616 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10617 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10618 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10619 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10621 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10622 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10624
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010625 /* Capture mixer control */
10626 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10627 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10628 {
10629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10630 .name = "Capture Source",
10631 .count = 1,
10632 .info = alc_mux_enum_info,
10633 .get = alc_mux_enum_get,
10634 .put = alc_mux_enum_put,
10635 },
10636 {
10637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10638 .name = "Channel Mode",
10639 .info = alc_ch_mode_info,
10640 .get = alc_ch_mode_get,
10641 .put = alc_ch_mode_put,
10642 .private_value = ARRAY_SIZE(alc861_asus_modes),
10643 },
10644 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010645};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010646
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010647/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010648static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010649 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10650 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10651 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10652 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10653 { }
10654};
10655
Kailang Yangdf694da2005-12-05 19:42:22 +010010656/*
10657 * generic initialization of ADC, input mixers and output mixers
10658 */
10659static struct hda_verb alc861_base_init_verbs[] = {
10660 /*
10661 * Unmute ADC0 and set the default input to mic-in
10662 */
10663 /* port-A for surround (rear panel) */
10664 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10665 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10666 /* port-B for mic-in (rear panel) with vref */
10667 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10668 /* port-C for line-in (rear panel) */
10669 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10670 /* port-D for Front */
10671 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10672 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10673 /* port-E for HP out (front panel) */
10674 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10675 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010676 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010677 /* port-F for mic-in (front panel) with vref */
10678 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10679 /* port-G for CLFE (rear panel) */
10680 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10681 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10682 /* port-H for side (rear panel) */
10683 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10684 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10685 /* CD-in */
10686 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10687 /* route front mic to ADC1*/
10688 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10689 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10690
10691 /* Unmute DAC0~3 & spdif out*/
10692 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10693 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10694 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10695 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10697
10698 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10699 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10700 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10701 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10702 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10703
10704 /* Unmute Stereo Mixer 15 */
10705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010709
10710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10711 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10714 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10715 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010718 /* hp used DAC 3 (Front) */
10719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010720 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10721
10722 { }
10723};
10724
10725static struct hda_verb alc861_threestack_init_verbs[] = {
10726 /*
10727 * Unmute ADC0 and set the default input to mic-in
10728 */
10729 /* port-A for surround (rear panel) */
10730 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10731 /* port-B for mic-in (rear panel) with vref */
10732 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10733 /* port-C for line-in (rear panel) */
10734 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10735 /* port-D for Front */
10736 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10737 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10738 /* port-E for HP out (front panel) */
10739 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10740 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010741 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010742 /* port-F for mic-in (front panel) with vref */
10743 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10744 /* port-G for CLFE (rear panel) */
10745 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10746 /* port-H for side (rear panel) */
10747 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10748 /* CD-in */
10749 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10750 /* route front mic to ADC1*/
10751 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10753 /* Unmute DAC0~3 & spdif out*/
10754 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10755 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10756 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10757 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10759
10760 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10761 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10762 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10763 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10764 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10765
10766 /* Unmute Stereo Mixer 15 */
10767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010771
10772 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10774 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10779 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010780 /* hp used DAC 3 (Front) */
10781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10783 { }
10784};
Takashi Iwai22309c32006-08-09 16:57:28 +020010785
10786static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10787 /*
10788 * Unmute ADC0 and set the default input to mic-in
10789 */
10790 /* port-A for surround (rear panel) */
10791 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10792 /* port-B for mic-in (rear panel) with vref */
10793 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10794 /* port-C for line-in (rear panel) */
10795 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10796 /* port-D for Front */
10797 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10798 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10799 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010800 /* this has to be set to VREF80 */
10801 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010802 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010803 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010804 /* port-F for mic-in (front panel) with vref */
10805 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10806 /* port-G for CLFE (rear panel) */
10807 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10808 /* port-H for side (rear panel) */
10809 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10810 /* CD-in */
10811 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10812 /* route front mic to ADC1*/
10813 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10815 /* Unmute DAC0~3 & spdif out*/
10816 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10817 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10818 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10819 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10821
10822 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10823 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10824 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10825 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10826 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10827
10828 /* Unmute Stereo Mixer 15 */
10829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10831 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020010833
10834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10835 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10836 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010842 /* hp used DAC 3 (Front) */
10843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020010844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10845 { }
10846};
10847
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010848static struct hda_verb alc861_asus_init_verbs[] = {
10849 /*
10850 * Unmute ADC0 and set the default input to mic-in
10851 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010852 /* port-A for surround (rear panel)
10853 * according to codec#0 this is the HP jack
10854 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010855 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10856 /* route front PCM to HP */
10857 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10858 /* port-B for mic-in (rear panel) with vref */
10859 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10860 /* port-C for line-in (rear panel) */
10861 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10862 /* port-D for Front */
10863 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10864 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10865 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010866 /* this has to be set to VREF80 */
10867 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010868 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010869 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010870 /* port-F for mic-in (front panel) with vref */
10871 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10872 /* port-G for CLFE (rear panel) */
10873 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10874 /* port-H for side (rear panel) */
10875 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10876 /* CD-in */
10877 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10878 /* route front mic to ADC1*/
10879 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10881 /* Unmute DAC0~3 & spdif out*/
10882 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10883 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10884 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10885 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10887 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10888 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10889 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10890 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10891 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10892
10893 /* Unmute Stereo Mixer 15 */
10894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010898
10899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10900 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10902 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10905 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10906 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010907 /* hp used DAC 3 (Front) */
10908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010909 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10910 { }
10911};
10912
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010913/* additional init verbs for ASUS laptops */
10914static struct hda_verb alc861_asus_laptop_init_verbs[] = {
10915 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
10916 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
10917 { }
10918};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010919
Kailang Yangdf694da2005-12-05 19:42:22 +010010920/*
10921 * generic initialization of ADC, input mixers and output mixers
10922 */
10923static struct hda_verb alc861_auto_init_verbs[] = {
10924 /*
10925 * Unmute ADC0 and set the default input to mic-in
10926 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010927 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010010928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10929
10930 /* Unmute DAC0~3 & spdif out*/
10931 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10932 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10933 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10934 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10936
10937 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10938 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10939 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10940 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10941 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10942
10943 /* Unmute Stereo Mixer 15 */
10944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
10948
10949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10950 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10951 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10952 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10953 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10954 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10955 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10956 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10957
10958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10959 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010960 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010962 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10965 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010967 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010968
10969 { }
10970};
10971
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010972static struct hda_verb alc861_toshiba_init_verbs[] = {
10973 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010974
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010975 { }
10976};
10977
10978/* toggle speaker-output according to the hp-jack state */
10979static void alc861_toshiba_automute(struct hda_codec *codec)
10980{
10981 unsigned int present;
10982
10983 present = snd_hda_codec_read(codec, 0x0f, 0,
10984 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010985 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
10986 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10987 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
10988 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010989}
10990
10991static void alc861_toshiba_unsol_event(struct hda_codec *codec,
10992 unsigned int res)
10993{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010994 if ((res >> 26) == ALC880_HP_EVENT)
10995 alc861_toshiba_automute(codec);
10996}
10997
Kailang Yangdf694da2005-12-05 19:42:22 +010010998/* pcm configuration: identiacal with ALC880 */
10999#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11000#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11001#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11002#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11003
11004
11005#define ALC861_DIGOUT_NID 0x07
11006
11007static struct hda_channel_mode alc861_8ch_modes[1] = {
11008 { 8, NULL }
11009};
11010
11011static hda_nid_t alc861_dac_nids[4] = {
11012 /* front, surround, clfe, side */
11013 0x03, 0x06, 0x05, 0x04
11014};
11015
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011016static hda_nid_t alc660_dac_nids[3] = {
11017 /* front, clfe, surround */
11018 0x03, 0x05, 0x06
11019};
11020
Kailang Yangdf694da2005-12-05 19:42:22 +010011021static hda_nid_t alc861_adc_nids[1] = {
11022 /* ADC0-2 */
11023 0x08,
11024};
11025
11026static struct hda_input_mux alc861_capture_source = {
11027 .num_items = 5,
11028 .items = {
11029 { "Mic", 0x0 },
11030 { "Front Mic", 0x3 },
11031 { "Line", 0x1 },
11032 { "CD", 0x4 },
11033 { "Mixer", 0x5 },
11034 },
11035};
11036
11037/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011038static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11039 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011040{
11041 int i;
11042 hda_nid_t nid;
11043
11044 spec->multiout.dac_nids = spec->private_dac_nids;
11045 for (i = 0; i < cfg->line_outs; i++) {
11046 nid = cfg->line_out_pins[i];
11047 if (nid) {
11048 if (i >= ARRAY_SIZE(alc861_dac_nids))
11049 continue;
11050 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11051 }
11052 }
11053 spec->multiout.num_dacs = cfg->line_outs;
11054 return 0;
11055}
11056
11057/* add playback controls from the parsed DAC table */
11058static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11059 const struct auto_pin_cfg *cfg)
11060{
11061 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011062 static const char *chname[4] = {
11063 "Front", "Surround", NULL /*CLFE*/, "Side"
11064 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011065 hda_nid_t nid;
11066 int i, idx, err;
11067
11068 for (i = 0; i < cfg->line_outs; i++) {
11069 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011070 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011071 continue;
11072 if (nid == 0x05) {
11073 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011074 err = add_control(spec, ALC_CTL_BIND_MUTE,
11075 "Center Playback Switch",
11076 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11077 HDA_OUTPUT));
11078 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011079 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011080 err = add_control(spec, ALC_CTL_BIND_MUTE,
11081 "LFE Playback Switch",
11082 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11083 HDA_OUTPUT));
11084 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011085 return err;
11086 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011087 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11088 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011089 if (nid == alc861_dac_nids[idx])
11090 break;
11091 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011092 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11093 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11094 HDA_OUTPUT));
11095 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011096 return err;
11097 }
11098 }
11099 return 0;
11100}
11101
11102static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11103{
11104 int err;
11105 hda_nid_t nid;
11106
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011107 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011108 return 0;
11109
11110 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11111 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011112 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11113 "Headphone Playback Switch",
11114 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11115 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011116 return err;
11117 spec->multiout.hp_nid = nid;
11118 }
11119 return 0;
11120}
11121
11122/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011123static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11124 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011125{
Kailang Yangdf694da2005-12-05 19:42:22 +010011126 struct hda_input_mux *imux = &spec->private_imux;
11127 int i, err, idx, idx1;
11128
11129 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011130 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011131 case 0x0c:
11132 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011133 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011134 break;
11135 case 0x0f:
11136 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011137 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011138 break;
11139 case 0x0d:
11140 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011141 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011142 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011143 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011144 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011145 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011146 break;
11147 case 0x11:
11148 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011149 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011150 break;
11151 default:
11152 continue;
11153 }
11154
Takashi Iwai4a471b72005-12-07 13:56:29 +010011155 err = new_analog_input(spec, cfg->input_pins[i],
11156 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011157 if (err < 0)
11158 return err;
11159
Takashi Iwai4a471b72005-12-07 13:56:29 +010011160 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011161 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011162 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011163 }
11164 return 0;
11165}
11166
11167static struct snd_kcontrol_new alc861_capture_mixer[] = {
11168 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11169 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11170
11171 {
11172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11173 /* The multiple "Capture Source" controls confuse alsamixer
11174 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011175 */
11176 /* .name = "Capture Source", */
11177 .name = "Input Source",
11178 .count = 1,
11179 .info = alc_mux_enum_info,
11180 .get = alc_mux_enum_get,
11181 .put = alc_mux_enum_put,
11182 },
11183 { } /* end */
11184};
11185
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011186static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11187 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011188 int pin_type, int dac_idx)
11189{
11190 /* set as output */
11191
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011192 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11193 pin_type);
11194 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11195 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011196
11197}
11198
11199static void alc861_auto_init_multi_out(struct hda_codec *codec)
11200{
11201 struct alc_spec *spec = codec->spec;
11202 int i;
11203
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011204 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011205 for (i = 0; i < spec->autocfg.line_outs; i++) {
11206 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011207 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011208 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011209 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011210 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011211 }
11212}
11213
11214static void alc861_auto_init_hp_out(struct hda_codec *codec)
11215{
11216 struct alc_spec *spec = codec->spec;
11217 hda_nid_t pin;
11218
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011219 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011220 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11222 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011223}
11224
11225static void alc861_auto_init_analog_input(struct hda_codec *codec)
11226{
11227 struct alc_spec *spec = codec->spec;
11228 int i;
11229
11230 for (i = 0; i < AUTO_PIN_LAST; i++) {
11231 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011232 if (nid >= 0x0c && nid <= 0x11) {
11233 snd_hda_codec_write(codec, nid, 0,
11234 AC_VERB_SET_PIN_WIDGET_CONTROL,
11235 i <= AUTO_PIN_FRONT_MIC ?
11236 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011237 }
11238 }
11239}
11240
11241/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011242/* return 1 if successful, 0 if the proper config is not found,
11243 * or a negative error code
11244 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011245static int alc861_parse_auto_config(struct hda_codec *codec)
11246{
11247 struct alc_spec *spec = codec->spec;
11248 int err;
11249 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11250
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011251 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11252 alc861_ignore);
11253 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011254 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011255 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011256 return 0; /* can't find valid BIOS pin config */
11257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011258 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11259 if (err < 0)
11260 return err;
11261 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11262 if (err < 0)
11263 return err;
11264 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11265 if (err < 0)
11266 return err;
11267 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11268 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011269 return err;
11270
11271 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11272
11273 if (spec->autocfg.dig_out_pin)
11274 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11275
11276 if (spec->kctl_alloc)
11277 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11278
11279 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11280
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011281 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011282 spec->input_mux = &spec->private_imux;
11283
11284 spec->adc_nids = alc861_adc_nids;
11285 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11286 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11287 spec->num_mixers++;
11288
11289 return 1;
11290}
11291
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011292/* additional initialization for auto-configuration model */
11293static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011294{
Kailang Yangdf694da2005-12-05 19:42:22 +010011295 alc861_auto_init_multi_out(codec);
11296 alc861_auto_init_hp_out(codec);
11297 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011298}
11299
Takashi Iwaicb53c622007-08-10 17:21:45 +020011300#ifdef CONFIG_SND_HDA_POWER_SAVE
11301static struct hda_amp_list alc861_loopbacks[] = {
11302 { 0x15, HDA_INPUT, 0 },
11303 { 0x15, HDA_INPUT, 1 },
11304 { 0x15, HDA_INPUT, 2 },
11305 { 0x15, HDA_INPUT, 3 },
11306 { } /* end */
11307};
11308#endif
11309
Kailang Yangdf694da2005-12-05 19:42:22 +010011310
11311/*
11312 * configuration and preset
11313 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011314static const char *alc861_models[ALC861_MODEL_LAST] = {
11315 [ALC861_3ST] = "3stack",
11316 [ALC660_3ST] = "3stack-660",
11317 [ALC861_3ST_DIG] = "3stack-dig",
11318 [ALC861_6ST_DIG] = "6stack-dig",
11319 [ALC861_UNIWILL_M31] = "uniwill-m31",
11320 [ALC861_TOSHIBA] = "toshiba",
11321 [ALC861_ASUS] = "asus",
11322 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11323 [ALC861_AUTO] = "auto",
11324};
11325
11326static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011327 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011328 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11329 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11330 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011331 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011332 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011333 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011334 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11335 * Any other models that need this preset?
11336 */
11337 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011338 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11339 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011340 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11341 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11342 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11343 /* FIXME: the below seems conflict */
11344 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11345 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11346 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011347 {}
11348};
11349
11350static struct alc_config_preset alc861_presets[] = {
11351 [ALC861_3ST] = {
11352 .mixers = { alc861_3ST_mixer },
11353 .init_verbs = { alc861_threestack_init_verbs },
11354 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11355 .dac_nids = alc861_dac_nids,
11356 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11357 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011358 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011359 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11360 .adc_nids = alc861_adc_nids,
11361 .input_mux = &alc861_capture_source,
11362 },
11363 [ALC861_3ST_DIG] = {
11364 .mixers = { alc861_base_mixer },
11365 .init_verbs = { alc861_threestack_init_verbs },
11366 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11367 .dac_nids = alc861_dac_nids,
11368 .dig_out_nid = ALC861_DIGOUT_NID,
11369 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11370 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011371 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011372 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11373 .adc_nids = alc861_adc_nids,
11374 .input_mux = &alc861_capture_source,
11375 },
11376 [ALC861_6ST_DIG] = {
11377 .mixers = { alc861_base_mixer },
11378 .init_verbs = { alc861_base_init_verbs },
11379 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11380 .dac_nids = alc861_dac_nids,
11381 .dig_out_nid = ALC861_DIGOUT_NID,
11382 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11383 .channel_mode = alc861_8ch_modes,
11384 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11385 .adc_nids = alc861_adc_nids,
11386 .input_mux = &alc861_capture_source,
11387 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011388 [ALC660_3ST] = {
11389 .mixers = { alc861_3ST_mixer },
11390 .init_verbs = { alc861_threestack_init_verbs },
11391 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11392 .dac_nids = alc660_dac_nids,
11393 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11394 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011395 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011396 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11397 .adc_nids = alc861_adc_nids,
11398 .input_mux = &alc861_capture_source,
11399 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011400 [ALC861_UNIWILL_M31] = {
11401 .mixers = { alc861_uniwill_m31_mixer },
11402 .init_verbs = { alc861_uniwill_m31_init_verbs },
11403 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11404 .dac_nids = alc861_dac_nids,
11405 .dig_out_nid = ALC861_DIGOUT_NID,
11406 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11407 .channel_mode = alc861_uniwill_m31_modes,
11408 .need_dac_fix = 1,
11409 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11410 .adc_nids = alc861_adc_nids,
11411 .input_mux = &alc861_capture_source,
11412 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011413 [ALC861_TOSHIBA] = {
11414 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011415 .init_verbs = { alc861_base_init_verbs,
11416 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011417 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11418 .dac_nids = alc861_dac_nids,
11419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11420 .channel_mode = alc883_3ST_2ch_modes,
11421 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11422 .adc_nids = alc861_adc_nids,
11423 .input_mux = &alc861_capture_source,
11424 .unsol_event = alc861_toshiba_unsol_event,
11425 .init_hook = alc861_toshiba_automute,
11426 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011427 [ALC861_ASUS] = {
11428 .mixers = { alc861_asus_mixer },
11429 .init_verbs = { alc861_asus_init_verbs },
11430 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11431 .dac_nids = alc861_dac_nids,
11432 .dig_out_nid = ALC861_DIGOUT_NID,
11433 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11434 .channel_mode = alc861_asus_modes,
11435 .need_dac_fix = 1,
11436 .hp_nid = 0x06,
11437 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11438 .adc_nids = alc861_adc_nids,
11439 .input_mux = &alc861_capture_source,
11440 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011441 [ALC861_ASUS_LAPTOP] = {
11442 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11443 .init_verbs = { alc861_asus_init_verbs,
11444 alc861_asus_laptop_init_verbs },
11445 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11446 .dac_nids = alc861_dac_nids,
11447 .dig_out_nid = ALC861_DIGOUT_NID,
11448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11449 .channel_mode = alc883_3ST_2ch_modes,
11450 .need_dac_fix = 1,
11451 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11452 .adc_nids = alc861_adc_nids,
11453 .input_mux = &alc861_capture_source,
11454 },
11455};
Kailang Yangdf694da2005-12-05 19:42:22 +010011456
11457
11458static int patch_alc861(struct hda_codec *codec)
11459{
11460 struct alc_spec *spec;
11461 int board_config;
11462 int err;
11463
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011464 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011465 if (spec == NULL)
11466 return -ENOMEM;
11467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011468 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011469
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011470 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11471 alc861_models,
11472 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011473
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011474 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011475 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11476 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011477 board_config = ALC861_AUTO;
11478 }
11479
11480 if (board_config == ALC861_AUTO) {
11481 /* automatic parse from the BIOS config */
11482 err = alc861_parse_auto_config(codec);
11483 if (err < 0) {
11484 alc_free(codec);
11485 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011486 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011487 printk(KERN_INFO
11488 "hda_codec: Cannot set up configuration "
11489 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011490 board_config = ALC861_3ST_DIG;
11491 }
11492 }
11493
11494 if (board_config != ALC861_AUTO)
11495 setup_preset(spec, &alc861_presets[board_config]);
11496
11497 spec->stream_name_analog = "ALC861 Analog";
11498 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11499 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11500
11501 spec->stream_name_digital = "ALC861 Digital";
11502 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11503 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11504
Takashi Iwai2134ea42008-01-10 16:53:55 +010011505 spec->vmaster_nid = 0x03;
11506
Kailang Yangdf694da2005-12-05 19:42:22 +010011507 codec->patch_ops = alc_patch_ops;
11508 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011509 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011510#ifdef CONFIG_SND_HDA_POWER_SAVE
11511 if (!spec->loopback.amplist)
11512 spec->loopback.amplist = alc861_loopbacks;
11513#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011514
11515 return 0;
11516}
11517
11518/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011519 * ALC861-VD support
11520 *
11521 * Based on ALC882
11522 *
11523 * In addition, an independent DAC
11524 */
11525#define ALC861VD_DIGOUT_NID 0x06
11526
11527static hda_nid_t alc861vd_dac_nids[4] = {
11528 /* front, surr, clfe, side surr */
11529 0x02, 0x03, 0x04, 0x05
11530};
11531
11532/* dac_nids for ALC660vd are in a different order - according to
11533 * Realtek's driver.
11534 * This should probably tesult in a different mixer for 6stack models
11535 * of ALC660vd codecs, but for now there is only 3stack mixer
11536 * - and it is the same as in 861vd.
11537 * adc_nids in ALC660vd are (is) the same as in 861vd
11538 */
11539static hda_nid_t alc660vd_dac_nids[3] = {
11540 /* front, rear, clfe, rear_surr */
11541 0x02, 0x04, 0x03
11542};
11543
11544static hda_nid_t alc861vd_adc_nids[1] = {
11545 /* ADC0 */
11546 0x09,
11547};
11548
11549/* input MUX */
11550/* FIXME: should be a matrix-type input source selection */
11551static struct hda_input_mux alc861vd_capture_source = {
11552 .num_items = 4,
11553 .items = {
11554 { "Mic", 0x0 },
11555 { "Front Mic", 0x1 },
11556 { "Line", 0x2 },
11557 { "CD", 0x4 },
11558 },
11559};
11560
Kailang Yang272a5272007-05-14 11:00:38 +020011561static struct hda_input_mux alc861vd_dallas_capture_source = {
11562 .num_items = 3,
11563 .items = {
11564 { "Front Mic", 0x0 },
11565 { "ATAPI Mic", 0x1 },
11566 { "Line In", 0x5 },
11567 },
11568};
11569
Kailang Yangd1a991a2007-08-15 16:21:59 +020011570static struct hda_input_mux alc861vd_hp_capture_source = {
11571 .num_items = 2,
11572 .items = {
11573 { "Front Mic", 0x0 },
11574 { "ATAPI Mic", 0x1 },
11575 },
11576};
11577
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011578#define alc861vd_mux_enum_info alc_mux_enum_info
11579#define alc861vd_mux_enum_get alc_mux_enum_get
11580
11581static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11582 struct snd_ctl_elem_value *ucontrol)
11583{
11584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11585 struct alc_spec *spec = codec->spec;
11586 const struct hda_input_mux *imux = spec->input_mux;
11587 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11588 static hda_nid_t capture_mixers[1] = { 0x22 };
11589 hda_nid_t nid = capture_mixers[adc_idx];
11590 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11591 unsigned int i, idx;
11592
11593 idx = ucontrol->value.enumerated.item[0];
11594 if (idx >= imux->num_items)
11595 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011596 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011597 return 0;
11598 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011599 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11600 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11601 imux->items[i].index,
11602 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011603 }
11604 *cur_val = idx;
11605 return 1;
11606}
11607
11608/*
11609 * 2ch mode
11610 */
11611static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11612 { 2, NULL }
11613};
11614
11615/*
11616 * 6ch mode
11617 */
11618static struct hda_verb alc861vd_6stack_ch6_init[] = {
11619 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11620 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11621 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11622 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11623 { } /* end */
11624};
11625
11626/*
11627 * 8ch mode
11628 */
11629static struct hda_verb alc861vd_6stack_ch8_init[] = {
11630 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11631 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11632 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11633 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11634 { } /* end */
11635};
11636
11637static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11638 { 6, alc861vd_6stack_ch6_init },
11639 { 8, alc861vd_6stack_ch8_init },
11640};
11641
11642static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11643 {
11644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11645 .name = "Channel Mode",
11646 .info = alc_ch_mode_info,
11647 .get = alc_ch_mode_get,
11648 .put = alc_ch_mode_put,
11649 },
11650 { } /* end */
11651};
11652
11653static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11654 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11655 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11656
11657 {
11658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11659 /* The multiple "Capture Source" controls confuse alsamixer
11660 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011661 */
11662 /* .name = "Capture Source", */
11663 .name = "Input Source",
11664 .count = 1,
11665 .info = alc861vd_mux_enum_info,
11666 .get = alc861vd_mux_enum_get,
11667 .put = alc861vd_mux_enum_put,
11668 },
11669 { } /* end */
11670};
11671
11672/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11673 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11674 */
11675static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11676 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11678
11679 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11680 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11681
11682 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11683 HDA_OUTPUT),
11684 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11685 HDA_OUTPUT),
11686 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11687 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11688
11689 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11690 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11691
11692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11693
11694 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11697
11698 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11699 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11701
11702 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11703 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11704
11705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11707
11708 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11709 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11710
11711 { } /* end */
11712};
11713
11714static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11715 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11716 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11717
11718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11719
11720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11723
11724 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11725 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11727
11728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11730
11731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11733
11734 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11735 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11736
11737 { } /* end */
11738};
11739
Kailang Yangbdd148a2007-05-08 15:19:08 +020011740static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11741 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11742 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11743 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11744
11745 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11746
11747 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11750
11751 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11752 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11753 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11754
11755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11756 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11757
11758 { } /* end */
11759};
11760
Kailang Yang272a5272007-05-14 11:00:38 +020011761/* Pin assignment: Front=0x14, HP = 0x15,
11762 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11763 */
11764static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11765 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11766 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11767 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11768 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11769 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11771 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11772 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011775 { } /* end */
11776};
11777
Kailang Yangd1a991a2007-08-15 16:21:59 +020011778/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11779 * Front Mic=0x18, ATAPI Mic = 0x19,
11780 */
11781static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11782 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11783 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11784 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11785 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11786 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11787 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11788 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11789 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11790
11791 { } /* end */
11792};
11793
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011794/*
11795 * generic initialization of ADC, input mixers and output mixers
11796 */
11797static struct hda_verb alc861vd_volume_init_verbs[] = {
11798 /*
11799 * Unmute ADC0 and set the default input to mic-in
11800 */
11801 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11802 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11803
11804 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11805 * the analog-loopback mixer widget
11806 */
11807 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011813
11814 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020011815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011819
11820 /*
11821 * Set up output mixers (0x02 - 0x05)
11822 */
11823 /* set vol=0 to output mixers */
11824 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11825 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11826 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11827 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11828
11829 /* set up input amps for analog loopback */
11830 /* Amp Indices: DAC = 0, mixer = 1 */
11831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11837 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11838 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11839
11840 { }
11841};
11842
11843/*
11844 * 3-stack pin configuration:
11845 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11846 */
11847static struct hda_verb alc861vd_3stack_init_verbs[] = {
11848 /*
11849 * Set pin mode and muting
11850 */
11851 /* set front pin widgets 0x14 for output */
11852 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11854 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11855
11856 /* Mic (rear) pin: input vref at 80% */
11857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11859 /* Front Mic pin: input vref at 80% */
11860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11862 /* Line In pin: input */
11863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11865 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11869 /* CD pin widget for input */
11870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11871
11872 { }
11873};
11874
11875/*
11876 * 6-stack pin configuration:
11877 */
11878static struct hda_verb alc861vd_6stack_init_verbs[] = {
11879 /*
11880 * Set pin mode and muting
11881 */
11882 /* set front pin widgets 0x14 for output */
11883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11885 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11886
11887 /* Rear Pin: output 1 (0x0d) */
11888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11890 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11891 /* CLFE Pin: output 2 (0x0e) */
11892 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11893 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11894 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11895 /* Side Pin: output 3 (0x0f) */
11896 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11897 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11898 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11899
11900 /* Mic (rear) pin: input vref at 80% */
11901 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11902 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11903 /* Front Mic pin: input vref at 80% */
11904 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11905 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11906 /* Line In pin: input */
11907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11909 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11911 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11912 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11913 /* CD pin widget for input */
11914 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11915
11916 { }
11917};
11918
Kailang Yangbdd148a2007-05-08 15:19:08 +020011919static struct hda_verb alc861vd_eapd_verbs[] = {
11920 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11921 { }
11922};
11923
11924static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
11925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11928 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11929 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11930 {}
11931};
11932
11933/* toggle speaker-output according to the hp-jack state */
11934static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
11935{
11936 unsigned int present;
11937 unsigned char bits;
11938
11939 present = snd_hda_codec_read(codec, 0x1b, 0,
11940 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011941 bits = present ? HDA_AMP_MUTE : 0;
11942 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11943 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011944}
11945
11946static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
11947{
11948 unsigned int present;
11949 unsigned char bits;
11950
11951 present = snd_hda_codec_read(codec, 0x18, 0,
11952 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011953 bits = present ? HDA_AMP_MUTE : 0;
11954 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
11955 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011956}
11957
11958static void alc861vd_lenovo_automute(struct hda_codec *codec)
11959{
11960 alc861vd_lenovo_hp_automute(codec);
11961 alc861vd_lenovo_mic_automute(codec);
11962}
11963
11964static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
11965 unsigned int res)
11966{
11967 switch (res >> 26) {
11968 case ALC880_HP_EVENT:
11969 alc861vd_lenovo_hp_automute(codec);
11970 break;
11971 case ALC880_MIC_EVENT:
11972 alc861vd_lenovo_mic_automute(codec);
11973 break;
11974 }
11975}
11976
Kailang Yang272a5272007-05-14 11:00:38 +020011977static struct hda_verb alc861vd_dallas_verbs[] = {
11978 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11979 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11980 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11981 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11982
11983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11990 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11991
11992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11993 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11996 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11997 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11998 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11999 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12000
12001 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12002 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12004 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12005 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12007 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12008 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12009
12010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12014
12015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12016 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12017 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12018
12019 { } /* end */
12020};
12021
12022/* toggle speaker-output according to the hp-jack state */
12023static void alc861vd_dallas_automute(struct hda_codec *codec)
12024{
12025 unsigned int present;
12026
12027 present = snd_hda_codec_read(codec, 0x15, 0,
12028 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012029 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12030 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012031}
12032
12033static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12034{
12035 if ((res >> 26) == ALC880_HP_EVENT)
12036 alc861vd_dallas_automute(codec);
12037}
12038
Takashi Iwaicb53c622007-08-10 17:21:45 +020012039#ifdef CONFIG_SND_HDA_POWER_SAVE
12040#define alc861vd_loopbacks alc880_loopbacks
12041#endif
12042
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012043/* pcm configuration: identiacal with ALC880 */
12044#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12045#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12046#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12047#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12048
12049/*
12050 * configuration and preset
12051 */
12052static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12053 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012054 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012055 [ALC861VD_3ST] = "3stack",
12056 [ALC861VD_3ST_DIG] = "3stack-digout",
12057 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012058 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012059 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012060 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012061 [ALC861VD_AUTO] = "auto",
12062};
12063
12064static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012065 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12066 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012067 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012068 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012069 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012070 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012071 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012072 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012073 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012074 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012075 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012076 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12077 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012078 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012079 {}
12080};
12081
12082static struct alc_config_preset alc861vd_presets[] = {
12083 [ALC660VD_3ST] = {
12084 .mixers = { alc861vd_3st_mixer },
12085 .init_verbs = { alc861vd_volume_init_verbs,
12086 alc861vd_3stack_init_verbs },
12087 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12088 .dac_nids = alc660vd_dac_nids,
12089 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12090 .adc_nids = alc861vd_adc_nids,
12091 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12092 .channel_mode = alc861vd_3stack_2ch_modes,
12093 .input_mux = &alc861vd_capture_source,
12094 },
Mike Crash6963f842007-06-25 12:12:51 +020012095 [ALC660VD_3ST_DIG] = {
12096 .mixers = { alc861vd_3st_mixer },
12097 .init_verbs = { alc861vd_volume_init_verbs,
12098 alc861vd_3stack_init_verbs },
12099 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12100 .dac_nids = alc660vd_dac_nids,
12101 .dig_out_nid = ALC861VD_DIGOUT_NID,
12102 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12103 .adc_nids = alc861vd_adc_nids,
12104 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12105 .channel_mode = alc861vd_3stack_2ch_modes,
12106 .input_mux = &alc861vd_capture_source,
12107 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012108 [ALC861VD_3ST] = {
12109 .mixers = { alc861vd_3st_mixer },
12110 .init_verbs = { alc861vd_volume_init_verbs,
12111 alc861vd_3stack_init_verbs },
12112 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12113 .dac_nids = alc861vd_dac_nids,
12114 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12115 .channel_mode = alc861vd_3stack_2ch_modes,
12116 .input_mux = &alc861vd_capture_source,
12117 },
12118 [ALC861VD_3ST_DIG] = {
12119 .mixers = { alc861vd_3st_mixer },
12120 .init_verbs = { alc861vd_volume_init_verbs,
12121 alc861vd_3stack_init_verbs },
12122 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12123 .dac_nids = alc861vd_dac_nids,
12124 .dig_out_nid = ALC861VD_DIGOUT_NID,
12125 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12126 .channel_mode = alc861vd_3stack_2ch_modes,
12127 .input_mux = &alc861vd_capture_source,
12128 },
12129 [ALC861VD_6ST_DIG] = {
12130 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12131 .init_verbs = { alc861vd_volume_init_verbs,
12132 alc861vd_6stack_init_verbs },
12133 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12134 .dac_nids = alc861vd_dac_nids,
12135 .dig_out_nid = ALC861VD_DIGOUT_NID,
12136 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12137 .channel_mode = alc861vd_6stack_modes,
12138 .input_mux = &alc861vd_capture_source,
12139 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012140 [ALC861VD_LENOVO] = {
12141 .mixers = { alc861vd_lenovo_mixer },
12142 .init_verbs = { alc861vd_volume_init_verbs,
12143 alc861vd_3stack_init_verbs,
12144 alc861vd_eapd_verbs,
12145 alc861vd_lenovo_unsol_verbs },
12146 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12147 .dac_nids = alc660vd_dac_nids,
12148 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12149 .adc_nids = alc861vd_adc_nids,
12150 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12151 .channel_mode = alc861vd_3stack_2ch_modes,
12152 .input_mux = &alc861vd_capture_source,
12153 .unsol_event = alc861vd_lenovo_unsol_event,
12154 .init_hook = alc861vd_lenovo_automute,
12155 },
Kailang Yang272a5272007-05-14 11:00:38 +020012156 [ALC861VD_DALLAS] = {
12157 .mixers = { alc861vd_dallas_mixer },
12158 .init_verbs = { alc861vd_dallas_verbs },
12159 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12160 .dac_nids = alc861vd_dac_nids,
12161 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12162 .adc_nids = alc861vd_adc_nids,
12163 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12164 .channel_mode = alc861vd_3stack_2ch_modes,
12165 .input_mux = &alc861vd_dallas_capture_source,
12166 .unsol_event = alc861vd_dallas_unsol_event,
12167 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012168 },
12169 [ALC861VD_HP] = {
12170 .mixers = { alc861vd_hp_mixer },
12171 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12172 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12173 .dac_nids = alc861vd_dac_nids,
12174 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12175 .dig_out_nid = ALC861VD_DIGOUT_NID,
12176 .adc_nids = alc861vd_adc_nids,
12177 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12178 .channel_mode = alc861vd_3stack_2ch_modes,
12179 .input_mux = &alc861vd_hp_capture_source,
12180 .unsol_event = alc861vd_dallas_unsol_event,
12181 .init_hook = alc861vd_dallas_automute,
12182 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012183};
12184
12185/*
12186 * BIOS auto configuration
12187 */
12188static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12189 hda_nid_t nid, int pin_type, int dac_idx)
12190{
12191 /* set as output */
12192 snd_hda_codec_write(codec, nid, 0,
12193 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12194 snd_hda_codec_write(codec, nid, 0,
12195 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12196}
12197
12198static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12199{
12200 struct alc_spec *spec = codec->spec;
12201 int i;
12202
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012203 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012204 for (i = 0; i <= HDA_SIDE; i++) {
12205 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012206 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012207 if (nid)
12208 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012209 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012210 }
12211}
12212
12213
12214static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12215{
12216 struct alc_spec *spec = codec->spec;
12217 hda_nid_t pin;
12218
12219 pin = spec->autocfg.hp_pins[0];
12220 if (pin) /* connect to front and use dac 0 */
12221 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12222}
12223
12224#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12225#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12226
12227static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12228{
12229 struct alc_spec *spec = codec->spec;
12230 int i;
12231
12232 for (i = 0; i < AUTO_PIN_LAST; i++) {
12233 hda_nid_t nid = spec->autocfg.input_pins[i];
12234 if (alc861vd_is_input_pin(nid)) {
12235 snd_hda_codec_write(codec, nid, 0,
12236 AC_VERB_SET_PIN_WIDGET_CONTROL,
12237 i <= AUTO_PIN_FRONT_MIC ?
12238 PIN_VREF80 : PIN_IN);
12239 if (nid != ALC861VD_PIN_CD_NID)
12240 snd_hda_codec_write(codec, nid, 0,
12241 AC_VERB_SET_AMP_GAIN_MUTE,
12242 AMP_OUT_MUTE);
12243 }
12244 }
12245}
12246
12247#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12248#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12249
12250/* add playback controls from the parsed DAC table */
12251/* Based on ALC880 version. But ALC861VD has separate,
12252 * different NIDs for mute/unmute switch and volume control */
12253static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12254 const struct auto_pin_cfg *cfg)
12255{
12256 char name[32];
12257 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12258 hda_nid_t nid_v, nid_s;
12259 int i, err;
12260
12261 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012262 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012263 continue;
12264 nid_v = alc861vd_idx_to_mixer_vol(
12265 alc880_dac_to_idx(
12266 spec->multiout.dac_nids[i]));
12267 nid_s = alc861vd_idx_to_mixer_switch(
12268 alc880_dac_to_idx(
12269 spec->multiout.dac_nids[i]));
12270
12271 if (i == 2) {
12272 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012273 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12274 "Center Playback Volume",
12275 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12276 HDA_OUTPUT));
12277 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012278 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012279 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12280 "LFE Playback Volume",
12281 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12282 HDA_OUTPUT));
12283 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012284 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012285 err = add_control(spec, ALC_CTL_BIND_MUTE,
12286 "Center Playback Switch",
12287 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12288 HDA_INPUT));
12289 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012290 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012291 err = add_control(spec, ALC_CTL_BIND_MUTE,
12292 "LFE Playback Switch",
12293 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12294 HDA_INPUT));
12295 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012296 return err;
12297 } else {
12298 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012299 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12300 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12301 HDA_OUTPUT));
12302 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012303 return err;
12304 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012305 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012306 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012307 HDA_INPUT));
12308 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012309 return err;
12310 }
12311 }
12312 return 0;
12313}
12314
12315/* add playback controls for speaker and HP outputs */
12316/* Based on ALC880 version. But ALC861VD has separate,
12317 * different NIDs for mute/unmute switch and volume control */
12318static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12319 hda_nid_t pin, const char *pfx)
12320{
12321 hda_nid_t nid_v, nid_s;
12322 int err;
12323 char name[32];
12324
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012325 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012326 return 0;
12327
12328 if (alc880_is_fixed_pin(pin)) {
12329 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12330 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012331 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012332 spec->multiout.hp_nid = nid_v;
12333 else
12334 spec->multiout.extra_out_nid[0] = nid_v;
12335 /* control HP volume/switch on the output mixer amp */
12336 nid_v = alc861vd_idx_to_mixer_vol(
12337 alc880_fixed_pin_idx(pin));
12338 nid_s = alc861vd_idx_to_mixer_switch(
12339 alc880_fixed_pin_idx(pin));
12340
12341 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012342 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12343 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12344 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012345 return err;
12346 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012347 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12348 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12349 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012350 return err;
12351 } else if (alc880_is_multi_pin(pin)) {
12352 /* set manual connection */
12353 /* we have only a switch on HP-out PIN */
12354 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012355 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12356 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12357 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012358 return err;
12359 }
12360 return 0;
12361}
12362
12363/* parse the BIOS configuration and set up the alc_spec
12364 * return 1 if successful, 0 if the proper config is not found,
12365 * or a negative error code
12366 * Based on ALC880 version - had to change it to override
12367 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12368static int alc861vd_parse_auto_config(struct hda_codec *codec)
12369{
12370 struct alc_spec *spec = codec->spec;
12371 int err;
12372 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12373
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012374 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12375 alc861vd_ignore);
12376 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012377 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012378 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012379 return 0; /* can't find valid BIOS pin config */
12380
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012381 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12382 if (err < 0)
12383 return err;
12384 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12385 if (err < 0)
12386 return err;
12387 err = alc861vd_auto_create_extra_out(spec,
12388 spec->autocfg.speaker_pins[0],
12389 "Speaker");
12390 if (err < 0)
12391 return err;
12392 err = alc861vd_auto_create_extra_out(spec,
12393 spec->autocfg.hp_pins[0],
12394 "Headphone");
12395 if (err < 0)
12396 return err;
12397 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12398 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012399 return err;
12400
12401 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12402
12403 if (spec->autocfg.dig_out_pin)
12404 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12405
12406 if (spec->kctl_alloc)
12407 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12408
12409 spec->init_verbs[spec->num_init_verbs++]
12410 = alc861vd_volume_init_verbs;
12411
12412 spec->num_mux_defs = 1;
12413 spec->input_mux = &spec->private_imux;
12414
Takashi Iwai776e1842007-08-29 15:07:11 +020012415 err = alc_auto_add_mic_boost(codec);
12416 if (err < 0)
12417 return err;
12418
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012419 return 1;
12420}
12421
12422/* additional initialization for auto-configuration model */
12423static void alc861vd_auto_init(struct hda_codec *codec)
12424{
12425 alc861vd_auto_init_multi_out(codec);
12426 alc861vd_auto_init_hp_out(codec);
12427 alc861vd_auto_init_analog_input(codec);
12428}
12429
12430static int patch_alc861vd(struct hda_codec *codec)
12431{
12432 struct alc_spec *spec;
12433 int err, board_config;
12434
12435 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12436 if (spec == NULL)
12437 return -ENOMEM;
12438
12439 codec->spec = spec;
12440
12441 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12442 alc861vd_models,
12443 alc861vd_cfg_tbl);
12444
12445 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12446 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12447 "ALC861VD, trying auto-probe from BIOS...\n");
12448 board_config = ALC861VD_AUTO;
12449 }
12450
12451 if (board_config == ALC861VD_AUTO) {
12452 /* automatic parse from the BIOS config */
12453 err = alc861vd_parse_auto_config(codec);
12454 if (err < 0) {
12455 alc_free(codec);
12456 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012457 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012458 printk(KERN_INFO
12459 "hda_codec: Cannot set up configuration "
12460 "from BIOS. Using base mode...\n");
12461 board_config = ALC861VD_3ST;
12462 }
12463 }
12464
12465 if (board_config != ALC861VD_AUTO)
12466 setup_preset(spec, &alc861vd_presets[board_config]);
12467
12468 spec->stream_name_analog = "ALC861VD Analog";
12469 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12470 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12471
12472 spec->stream_name_digital = "ALC861VD Digital";
12473 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12474 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12475
12476 spec->adc_nids = alc861vd_adc_nids;
12477 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12478
12479 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12480 spec->num_mixers++;
12481
Takashi Iwai2134ea42008-01-10 16:53:55 +010012482 spec->vmaster_nid = 0x02;
12483
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012484 codec->patch_ops = alc_patch_ops;
12485
12486 if (board_config == ALC861VD_AUTO)
12487 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012488#ifdef CONFIG_SND_HDA_POWER_SAVE
12489 if (!spec->loopback.amplist)
12490 spec->loopback.amplist = alc861vd_loopbacks;
12491#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012492
12493 return 0;
12494}
12495
12496/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012497 * ALC662 support
12498 *
12499 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12500 * configuration. Each pin widget can choose any input DACs and a mixer.
12501 * Each ADC is connected from a mixer of all inputs. This makes possible
12502 * 6-channel independent captures.
12503 *
12504 * In addition, an independent DAC for the multi-playback (not used in this
12505 * driver yet).
12506 */
12507#define ALC662_DIGOUT_NID 0x06
12508#define ALC662_DIGIN_NID 0x0a
12509
12510static hda_nid_t alc662_dac_nids[4] = {
12511 /* front, rear, clfe, rear_surr */
12512 0x02, 0x03, 0x04
12513};
12514
12515static hda_nid_t alc662_adc_nids[1] = {
12516 /* ADC1-2 */
12517 0x09,
12518};
12519/* input MUX */
12520/* FIXME: should be a matrix-type input source selection */
12521
12522static struct hda_input_mux alc662_capture_source = {
12523 .num_items = 4,
12524 .items = {
12525 { "Mic", 0x0 },
12526 { "Front Mic", 0x1 },
12527 { "Line", 0x2 },
12528 { "CD", 0x4 },
12529 },
12530};
12531
12532static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12533 .num_items = 2,
12534 .items = {
12535 { "Mic", 0x1 },
12536 { "Line", 0x2 },
12537 },
12538};
Kailang Yang291702f2007-10-16 14:28:03 +020012539
12540static struct hda_input_mux alc662_eeepc_capture_source = {
12541 .num_items = 2,
12542 .items = {
12543 { "i-Mic", 0x1 },
12544 { "e-Mic", 0x0 },
12545 },
12546};
12547
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012548#define alc662_mux_enum_info alc_mux_enum_info
12549#define alc662_mux_enum_get alc_mux_enum_get
12550
12551static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12552 struct snd_ctl_elem_value *ucontrol)
12553{
12554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12555 struct alc_spec *spec = codec->spec;
12556 const struct hda_input_mux *imux = spec->input_mux;
12557 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012558 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012559 hda_nid_t nid = capture_mixers[adc_idx];
12560 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12561 unsigned int i, idx;
12562
12563 idx = ucontrol->value.enumerated.item[0];
12564 if (idx >= imux->num_items)
12565 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012566 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012567 return 0;
12568 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012569 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12570 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12571 imux->items[i].index,
12572 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012573 }
12574 *cur_val = idx;
12575 return 1;
12576}
12577/*
12578 * 2ch mode
12579 */
12580static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12581 { 2, NULL }
12582};
12583
12584/*
12585 * 2ch mode
12586 */
12587static struct hda_verb alc662_3ST_ch2_init[] = {
12588 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12589 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12590 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12591 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12592 { } /* end */
12593};
12594
12595/*
12596 * 6ch mode
12597 */
12598static struct hda_verb alc662_3ST_ch6_init[] = {
12599 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12600 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12601 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12602 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12603 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12604 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12605 { } /* end */
12606};
12607
12608static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12609 { 2, alc662_3ST_ch2_init },
12610 { 6, alc662_3ST_ch6_init },
12611};
12612
12613/*
12614 * 2ch mode
12615 */
12616static struct hda_verb alc662_sixstack_ch6_init[] = {
12617 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12618 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12619 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12620 { } /* end */
12621};
12622
12623/*
12624 * 6ch mode
12625 */
12626static struct hda_verb alc662_sixstack_ch8_init[] = {
12627 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12628 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12629 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12630 { } /* end */
12631};
12632
12633static struct hda_channel_mode alc662_5stack_modes[2] = {
12634 { 2, alc662_sixstack_ch6_init },
12635 { 6, alc662_sixstack_ch8_init },
12636};
12637
12638/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12639 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12640 */
12641
12642static struct snd_kcontrol_new alc662_base_mixer[] = {
12643 /* output mixer control */
12644 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12645 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12646 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12647 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12648 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12649 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12650 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12651 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12653
12654 /*Input mixer control */
12655 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12656 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12657 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12658 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12659 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12660 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012663 { } /* end */
12664};
12665
12666static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12667 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12668 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12669 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12672 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12673 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12676 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12677 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12678 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12679 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012680 { } /* end */
12681};
12682
12683static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12684 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12685 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12686 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12687 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12688 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12689 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12690 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12691 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12693 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12694 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12695 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12696 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12697 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12698 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12699 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12701 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12702 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012703 { } /* end */
12704};
12705
12706static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12707 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12708 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12709 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12710 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12712 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12713 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012716 { } /* end */
12717};
12718
Kailang Yang291702f2007-10-16 14:28:03 +020012719static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12720 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12721
12722 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12723 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12724
12725 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12726 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12727 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12728
12729 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12730 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12731 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12732 { } /* end */
12733};
12734
Kailang Yang8c427222008-01-10 13:03:59 +010012735static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12736 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12737 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12738 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12739 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12740 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12741 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12742 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12743 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12744 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12745 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12746 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12747 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12750 { } /* end */
12751};
12752
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012753static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12754 {
12755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12756 .name = "Channel Mode",
12757 .info = alc_ch_mode_info,
12758 .get = alc_ch_mode_get,
12759 .put = alc_ch_mode_put,
12760 },
12761 { } /* end */
12762};
12763
12764static struct hda_verb alc662_init_verbs[] = {
12765 /* ADC: mute amp left and right */
12766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12767 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12768 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12769
Takashi Iwaicb53c622007-08-10 17:21:45 +020012770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012775
Kailang Yangb60dd392007-09-20 12:50:29 +020012776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012782
12783 /* Front Pin: output 0 (0x0c) */
12784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12786
12787 /* Rear Pin: output 1 (0x0d) */
12788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12790
12791 /* CLFE Pin: output 2 (0x0e) */
12792 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12794
12795 /* Mic (rear) pin: input vref at 80% */
12796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12798 /* Front Mic pin: input vref at 80% */
12799 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12800 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12801 /* Line In pin: input */
12802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12804 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12805 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12806 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12807 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12808 /* CD pin widget for input */
12809 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12810
12811 /* FIXME: use matrix-type input source selection */
12812 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12813 /* Input mixer */
12814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020012818
12819 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12821 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012823 { }
12824};
12825
12826static struct hda_verb alc662_sue_init_verbs[] = {
12827 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12828 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020012829 {}
12830};
12831
12832static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12834 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12835 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012836};
12837
Kailang Yang8c427222008-01-10 13:03:59 +010012838/* Set Unsolicited Event*/
12839static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12841 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12842 {}
12843};
12844
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012845/*
12846 * generic initialization of ADC, input mixers and output mixers
12847 */
12848static struct hda_verb alc662_auto_init_verbs[] = {
12849 /*
12850 * Unmute ADC and set the default input to mic-in
12851 */
12852 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12854
12855 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12856 * mixer widget
12857 * Note: PASD motherboards uses the Line In 2 as the input for front
12858 * panel mic (mic 2)
12859 */
12860 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012866
12867 /*
12868 * Set up output mixers (0x0c - 0x0f)
12869 */
12870 /* set vol=0 to output mixers */
12871 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12872 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12873 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12874
12875 /* set up input amps for analog loopback */
12876 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020012877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12878 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12879 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12880 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12882 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012883
12884
12885 /* FIXME: use matrix-type input source selection */
12886 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12887 /* Input mixer */
12888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020012889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012890 { }
12891};
12892
12893/* capture mixer elements */
12894static struct snd_kcontrol_new alc662_capture_mixer[] = {
12895 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12896 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12897 {
12898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12899 /* The multiple "Capture Source" controls confuse alsamixer
12900 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012901 */
12902 /* .name = "Capture Source", */
12903 .name = "Input Source",
12904 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010012905 .info = alc662_mux_enum_info,
12906 .get = alc662_mux_enum_get,
12907 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012908 },
12909 { } /* end */
12910};
12911
12912static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
12913{
12914 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012915 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012916
12917 present = snd_hda_codec_read(codec, 0x14, 0,
12918 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012919 bits = present ? HDA_AMP_MUTE : 0;
12920 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12921 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012922}
12923
12924static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
12925{
12926 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012927 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012928
12929 present = snd_hda_codec_read(codec, 0x1b, 0,
12930 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012931 bits = present ? HDA_AMP_MUTE : 0;
12932 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12933 HDA_AMP_MUTE, bits);
12934 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12935 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012936}
12937
12938static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
12939 unsigned int res)
12940{
12941 if ((res >> 26) == ALC880_HP_EVENT)
12942 alc662_lenovo_101e_all_automute(codec);
12943 if ((res >> 26) == ALC880_FRONT_EVENT)
12944 alc662_lenovo_101e_ispeaker_automute(codec);
12945}
12946
Kailang Yang291702f2007-10-16 14:28:03 +020012947static void alc662_eeepc_mic_automute(struct hda_codec *codec)
12948{
12949 unsigned int present;
12950
12951 present = snd_hda_codec_read(codec, 0x18, 0,
12952 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12953 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12954 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12955 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12956 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12957 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12958 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12959 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12960 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12961}
12962
12963/* unsolicited event for HP jack sensing */
12964static void alc662_eeepc_unsol_event(struct hda_codec *codec,
12965 unsigned int res)
12966{
12967 if ((res >> 26) == ALC880_HP_EVENT)
12968 alc262_hippo1_automute( codec );
12969
12970 if ((res >> 26) == ALC880_MIC_EVENT)
12971 alc662_eeepc_mic_automute(codec);
12972}
12973
12974static void alc662_eeepc_inithook(struct hda_codec *codec)
12975{
12976 alc262_hippo1_automute( codec );
12977 alc662_eeepc_mic_automute(codec);
12978}
12979
Kailang Yang8c427222008-01-10 13:03:59 +010012980static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
12981{
12982 unsigned int mute;
12983 unsigned int present;
12984
12985 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
12986 present = snd_hda_codec_read(codec, 0x14, 0,
12987 AC_VERB_GET_PIN_SENSE, 0);
12988 present = (present & 0x80000000) != 0;
12989 if (present) {
12990 /* mute internal speaker */
12991 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
12992 HDA_AMP_MUTE, HDA_AMP_MUTE);
12993 } else {
12994 /* unmute internal speaker if necessary */
12995 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12996 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
12997 HDA_AMP_MUTE, mute);
12998 }
12999}
13000
13001/* unsolicited event for HP jack sensing */
13002static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13003 unsigned int res)
13004{
13005 if ((res >> 26) == ALC880_HP_EVENT)
13006 alc662_eeepc_ep20_automute(codec);
13007}
13008
13009static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13010{
13011 alc662_eeepc_ep20_automute(codec);
13012}
13013
Takashi Iwaicb53c622007-08-10 17:21:45 +020013014#ifdef CONFIG_SND_HDA_POWER_SAVE
13015#define alc662_loopbacks alc880_loopbacks
13016#endif
13017
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013018
13019/* pcm configuration: identiacal with ALC880 */
13020#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13021#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13022#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13023#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13024
13025/*
13026 * configuration and preset
13027 */
13028static const char *alc662_models[ALC662_MODEL_LAST] = {
13029 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13030 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13031 [ALC662_3ST_6ch] = "3stack-6ch",
13032 [ALC662_5ST_DIG] = "6stack-dig",
13033 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013034 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013035 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013036 [ALC662_AUTO] = "auto",
13037};
13038
13039static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013040 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013041 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013042 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013043 {}
13044};
13045
13046static struct alc_config_preset alc662_presets[] = {
13047 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013048 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013049 .init_verbs = { alc662_init_verbs },
13050 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13051 .dac_nids = alc662_dac_nids,
13052 .dig_out_nid = ALC662_DIGOUT_NID,
13053 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13054 .adc_nids = alc662_adc_nids,
13055 .dig_in_nid = ALC662_DIGIN_NID,
13056 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13057 .channel_mode = alc662_3ST_2ch_modes,
13058 .input_mux = &alc662_capture_source,
13059 },
13060 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013061 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13062 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013063 .init_verbs = { alc662_init_verbs },
13064 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13065 .dac_nids = alc662_dac_nids,
13066 .dig_out_nid = ALC662_DIGOUT_NID,
13067 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13068 .adc_nids = alc662_adc_nids,
13069 .dig_in_nid = ALC662_DIGIN_NID,
13070 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13071 .channel_mode = alc662_3ST_6ch_modes,
13072 .need_dac_fix = 1,
13073 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013074 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013075 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013076 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13077 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013078 .init_verbs = { alc662_init_verbs },
13079 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13080 .dac_nids = alc662_dac_nids,
13081 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13082 .adc_nids = alc662_adc_nids,
13083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13084 .channel_mode = alc662_3ST_6ch_modes,
13085 .need_dac_fix = 1,
13086 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013087 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013088 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013089 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13090 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013091 .init_verbs = { alc662_init_verbs },
13092 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13093 .dac_nids = alc662_dac_nids,
13094 .dig_out_nid = ALC662_DIGOUT_NID,
13095 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13096 .adc_nids = alc662_adc_nids,
13097 .dig_in_nid = ALC662_DIGIN_NID,
13098 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13099 .channel_mode = alc662_5stack_modes,
13100 .input_mux = &alc662_capture_source,
13101 },
13102 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013103 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013104 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13105 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13106 .dac_nids = alc662_dac_nids,
13107 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13108 .adc_nids = alc662_adc_nids,
13109 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13110 .channel_mode = alc662_3ST_2ch_modes,
13111 .input_mux = &alc662_lenovo_101e_capture_source,
13112 .unsol_event = alc662_lenovo_101e_unsol_event,
13113 .init_hook = alc662_lenovo_101e_all_automute,
13114 },
Kailang Yang291702f2007-10-16 14:28:03 +020013115 [ALC662_ASUS_EEEPC_P701] = {
13116 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13117 .init_verbs = { alc662_init_verbs,
13118 alc662_eeepc_sue_init_verbs },
13119 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13120 .dac_nids = alc662_dac_nids,
13121 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13122 .adc_nids = alc662_adc_nids,
13123 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13124 .channel_mode = alc662_3ST_2ch_modes,
13125 .input_mux = &alc662_eeepc_capture_source,
13126 .unsol_event = alc662_eeepc_unsol_event,
13127 .init_hook = alc662_eeepc_inithook,
13128 },
Kailang Yang8c427222008-01-10 13:03:59 +010013129 [ALC662_ASUS_EEEPC_EP20] = {
13130 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13131 alc662_chmode_mixer },
13132 .init_verbs = { alc662_init_verbs,
13133 alc662_eeepc_ep20_sue_init_verbs },
13134 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13135 .dac_nids = alc662_dac_nids,
13136 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13137 .adc_nids = alc662_adc_nids,
13138 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13139 .channel_mode = alc662_3ST_6ch_modes,
13140 .input_mux = &alc662_lenovo_101e_capture_source,
13141 .unsol_event = alc662_eeepc_ep20_unsol_event,
13142 .init_hook = alc662_eeepc_ep20_inithook,
13143 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013144
13145};
13146
13147
13148/*
13149 * BIOS auto configuration
13150 */
13151
13152/* add playback controls from the parsed DAC table */
13153static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13154 const struct auto_pin_cfg *cfg)
13155{
13156 char name[32];
13157 static const char *chname[4] = {
13158 "Front", "Surround", NULL /*CLFE*/, "Side"
13159 };
13160 hda_nid_t nid;
13161 int i, err;
13162
13163 for (i = 0; i < cfg->line_outs; i++) {
13164 if (!spec->multiout.dac_nids[i])
13165 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013166 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013167 if (i == 2) {
13168 /* Center/LFE */
13169 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13170 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013171 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13172 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013173 if (err < 0)
13174 return err;
13175 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13176 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013177 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13178 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013179 if (err < 0)
13180 return err;
13181 err = add_control(spec, ALC_CTL_BIND_MUTE,
13182 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013183 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13184 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013185 if (err < 0)
13186 return err;
13187 err = add_control(spec, ALC_CTL_BIND_MUTE,
13188 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013189 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13190 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013191 if (err < 0)
13192 return err;
13193 } else {
13194 sprintf(name, "%s Playback Volume", chname[i]);
13195 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013196 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13197 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013198 if (err < 0)
13199 return err;
13200 sprintf(name, "%s Playback Switch", chname[i]);
13201 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013202 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13203 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013204 if (err < 0)
13205 return err;
13206 }
13207 }
13208 return 0;
13209}
13210
13211/* add playback controls for speaker and HP outputs */
13212static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13213 const char *pfx)
13214{
13215 hda_nid_t nid;
13216 int err;
13217 char name[32];
13218
13219 if (!pin)
13220 return 0;
13221
13222 if (alc880_is_fixed_pin(pin)) {
13223 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13224 /* printk("DAC nid=%x\n",nid); */
13225 /* specify the DAC as the extra output */
13226 if (!spec->multiout.hp_nid)
13227 spec->multiout.hp_nid = nid;
13228 else
13229 spec->multiout.extra_out_nid[0] = nid;
13230 /* control HP volume/switch on the output mixer amp */
13231 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13232 sprintf(name, "%s Playback Volume", pfx);
13233 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13234 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13235 if (err < 0)
13236 return err;
13237 sprintf(name, "%s Playback Switch", pfx);
13238 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13239 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13240 if (err < 0)
13241 return err;
13242 } else if (alc880_is_multi_pin(pin)) {
13243 /* set manual connection */
13244 /* we have only a switch on HP-out PIN */
13245 sprintf(name, "%s Playback Switch", pfx);
13246 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13247 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13248 if (err < 0)
13249 return err;
13250 }
13251 return 0;
13252}
13253
13254/* create playback/capture controls for input pins */
13255static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13256 const struct auto_pin_cfg *cfg)
13257{
13258 struct hda_input_mux *imux = &spec->private_imux;
13259 int i, err, idx;
13260
13261 for (i = 0; i < AUTO_PIN_LAST; i++) {
13262 if (alc880_is_input_pin(cfg->input_pins[i])) {
13263 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13264 err = new_analog_input(spec, cfg->input_pins[i],
13265 auto_pin_cfg_labels[i],
13266 idx, 0x0b);
13267 if (err < 0)
13268 return err;
13269 imux->items[imux->num_items].label =
13270 auto_pin_cfg_labels[i];
13271 imux->items[imux->num_items].index =
13272 alc880_input_pin_idx(cfg->input_pins[i]);
13273 imux->num_items++;
13274 }
13275 }
13276 return 0;
13277}
13278
13279static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13280 hda_nid_t nid, int pin_type,
13281 int dac_idx)
13282{
13283 /* set as output */
13284 snd_hda_codec_write(codec, nid, 0,
13285 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13286 snd_hda_codec_write(codec, nid, 0,
13287 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13288 /* need the manual connection? */
13289 if (alc880_is_multi_pin(nid)) {
13290 struct alc_spec *spec = codec->spec;
13291 int idx = alc880_multi_pin_idx(nid);
13292 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13293 AC_VERB_SET_CONNECT_SEL,
13294 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13295 }
13296}
13297
13298static void alc662_auto_init_multi_out(struct hda_codec *codec)
13299{
13300 struct alc_spec *spec = codec->spec;
13301 int i;
13302
Kailang Yang8c427222008-01-10 13:03:59 +010013303 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013304 for (i = 0; i <= HDA_SIDE; i++) {
13305 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013306 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013307 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013308 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013309 i);
13310 }
13311}
13312
13313static void alc662_auto_init_hp_out(struct hda_codec *codec)
13314{
13315 struct alc_spec *spec = codec->spec;
13316 hda_nid_t pin;
13317
13318 pin = spec->autocfg.hp_pins[0];
13319 if (pin) /* connect to front */
13320 /* use dac 0 */
13321 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13322}
13323
13324#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13325#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13326
13327static void alc662_auto_init_analog_input(struct hda_codec *codec)
13328{
13329 struct alc_spec *spec = codec->spec;
13330 int i;
13331
13332 for (i = 0; i < AUTO_PIN_LAST; i++) {
13333 hda_nid_t nid = spec->autocfg.input_pins[i];
13334 if (alc662_is_input_pin(nid)) {
13335 snd_hda_codec_write(codec, nid, 0,
13336 AC_VERB_SET_PIN_WIDGET_CONTROL,
13337 (i <= AUTO_PIN_FRONT_MIC ?
13338 PIN_VREF80 : PIN_IN));
13339 if (nid != ALC662_PIN_CD_NID)
13340 snd_hda_codec_write(codec, nid, 0,
13341 AC_VERB_SET_AMP_GAIN_MUTE,
13342 AMP_OUT_MUTE);
13343 }
13344 }
13345}
13346
13347static int alc662_parse_auto_config(struct hda_codec *codec)
13348{
13349 struct alc_spec *spec = codec->spec;
13350 int err;
13351 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13352
13353 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13354 alc662_ignore);
13355 if (err < 0)
13356 return err;
13357 if (!spec->autocfg.line_outs)
13358 return 0; /* can't find valid BIOS pin config */
13359
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013360 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13361 if (err < 0)
13362 return err;
13363 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13364 if (err < 0)
13365 return err;
13366 err = alc662_auto_create_extra_out(spec,
13367 spec->autocfg.speaker_pins[0],
13368 "Speaker");
13369 if (err < 0)
13370 return err;
13371 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13372 "Headphone");
13373 if (err < 0)
13374 return err;
13375 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13376 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013377 return err;
13378
13379 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13380
13381 if (spec->autocfg.dig_out_pin)
13382 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13383
13384 if (spec->kctl_alloc)
13385 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13386
13387 spec->num_mux_defs = 1;
13388 spec->input_mux = &spec->private_imux;
13389
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013390 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013391 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13392 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013393 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013394}
13395
13396/* additional initialization for auto-configuration model */
13397static void alc662_auto_init(struct hda_codec *codec)
13398{
13399 alc662_auto_init_multi_out(codec);
13400 alc662_auto_init_hp_out(codec);
13401 alc662_auto_init_analog_input(codec);
13402}
13403
13404static int patch_alc662(struct hda_codec *codec)
13405{
13406 struct alc_spec *spec;
13407 int err, board_config;
13408
13409 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13410 if (!spec)
13411 return -ENOMEM;
13412
13413 codec->spec = spec;
13414
13415 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13416 alc662_models,
13417 alc662_cfg_tbl);
13418 if (board_config < 0) {
13419 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13420 "trying auto-probe from BIOS...\n");
13421 board_config = ALC662_AUTO;
13422 }
13423
13424 if (board_config == ALC662_AUTO) {
13425 /* automatic parse from the BIOS config */
13426 err = alc662_parse_auto_config(codec);
13427 if (err < 0) {
13428 alc_free(codec);
13429 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013430 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013431 printk(KERN_INFO
13432 "hda_codec: Cannot set up configuration "
13433 "from BIOS. Using base mode...\n");
13434 board_config = ALC662_3ST_2ch_DIG;
13435 }
13436 }
13437
13438 if (board_config != ALC662_AUTO)
13439 setup_preset(spec, &alc662_presets[board_config]);
13440
13441 spec->stream_name_analog = "ALC662 Analog";
13442 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13443 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13444
13445 spec->stream_name_digital = "ALC662 Digital";
13446 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13447 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13448
13449 if (!spec->adc_nids && spec->input_mux) {
13450 spec->adc_nids = alc662_adc_nids;
13451 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13452 }
13453
Takashi Iwai2134ea42008-01-10 16:53:55 +010013454 spec->vmaster_nid = 0x02;
13455
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013456 codec->patch_ops = alc_patch_ops;
13457 if (board_config == ALC662_AUTO)
13458 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013459#ifdef CONFIG_SND_HDA_POWER_SAVE
13460 if (!spec->loopback.amplist)
13461 spec->loopback.amplist = alc662_loopbacks;
13462#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013463
13464 return 0;
13465}
13466
13467/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013468 * patch entries
13469 */
13470struct hda_codec_preset snd_hda_preset_realtek[] = {
13471 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013472 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013473 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013474 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013475 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013476 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013477 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013478 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13479 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13480 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013481 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13482 .patch = patch_alc883 },
13483 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13484 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013485 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013486 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013487 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013488 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013489 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013490 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013491 {} /* terminator */
13492};