blob: 17784952acdd1f5ce168d4c2e0687e3fcce4a200 [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,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100199 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200200 ALC883_AUTO,
201 ALC883_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* for GPIO Poll */
205#define GPIO_MASK 0x03
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207struct alc_spec {
208 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100209 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 unsigned int num_mixers;
211
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200213 * don't forget NULL
214 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200215 */
216 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
Takashi Iwai16ded522005-06-10 19:58:24 +0200218 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 struct hda_pcm_stream *stream_analog_playback;
220 struct hda_pcm_stream *stream_analog_capture;
221
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200222 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 struct hda_pcm_stream *stream_digital_playback;
224 struct hda_pcm_stream *stream_digital_capture;
225
226 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200227 struct hda_multi_out multiout; /* playback set-up
228 * max_channels, dacs must be set
229 * dig_out_nid and hp_nid are optional
230 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232 /* capture */
233 unsigned int num_adc_nids;
234 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200235 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200238 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 const struct hda_input_mux *input_mux;
240 unsigned int cur_mux[3];
241
242 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100243 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200245 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100248 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200249
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200250 /* dynamic controls, init_verbs and input_mux */
251 struct auto_pin_cfg autocfg;
252 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100253 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200254 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200255 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100256
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100257 /* hooks */
258 void (*init_hook)(struct hda_codec *codec);
259 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
260
Takashi Iwai834be882006-03-01 14:16:17 +0100261 /* for pin sensing */
262 unsigned int sense_updated: 1;
263 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200264
265#ifdef CONFIG_SND_HDA_POWER_SAVE
266 struct hda_loopback_check loopback;
267#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100268};
269
270/*
271 * configuration template - to be copied to the spec instance
272 */
273struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200274 struct snd_kcontrol_new *mixers[5]; /* should be identical size
275 * with spec
276 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100277 const struct hda_verb *init_verbs[5];
278 unsigned int num_dacs;
279 hda_nid_t *dac_nids;
280 hda_nid_t dig_out_nid; /* optional */
281 hda_nid_t hp_nid; /* optional */
282 unsigned int num_adc_nids;
283 hda_nid_t *adc_nids;
284 hda_nid_t dig_in_nid;
285 unsigned int num_channel_mode;
286 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200287 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200288 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100289 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100290 void (*unsol_event)(struct hda_codec *, unsigned int);
291 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200292#ifdef CONFIG_SND_HDA_POWER_SAVE
293 struct hda_amp_list *loopbacks;
294#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295};
296
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
298/*
299 * input MUX handling
300 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200301static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
302 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303{
304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
305 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200306 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
307 if (mux_idx >= spec->num_mux_defs)
308 mux_idx = 0;
309 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310}
311
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200312static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
313 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314{
315 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
316 struct alc_spec *spec = codec->spec;
317 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
318
319 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
320 return 0;
321}
322
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200323static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
324 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325{
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
327 struct alc_spec *spec = codec->spec;
328 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200329 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
330 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200331 spec->adc_nids[adc_idx],
332 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333}
334
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200335
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336/*
337 * channel mode setting
338 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
340 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341{
342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
343 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100344 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
345 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346}
347
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200348static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
349 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
352 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100353 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200354 spec->num_channel_mode,
355 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356}
357
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200358static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
359 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360{
361 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
362 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200363 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
364 spec->num_channel_mode,
365 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200366 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200367 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
368 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372 * Control the mode of pin widget settings via the mixer. "pc" is used
373 * instead of "%" to avoid consequences of accidently treating the % as
374 * being part of a format specifier. Maximum allowed length of a value is
375 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100376 *
377 * Note: some retasking pin complexes seem to ignore requests for input
378 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
379 * are requested. Therefore order this list so that this behaviour will not
380 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200381 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
382 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200383 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100384static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100385 "Mic 50pc bias", "Mic 80pc bias",
386 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100387};
388static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100389 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100390};
391/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200392 * in the pin being assumed to be exclusively an input or an output pin. In
393 * addition, "input" pins may or may not process the mic bias option
394 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
395 * accept requests for bias as of chip versions up to March 2006) and/or
396 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100397 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200398#define ALC_PIN_DIR_IN 0x00
399#define ALC_PIN_DIR_OUT 0x01
400#define ALC_PIN_DIR_INOUT 0x02
401#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
402#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100403
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200404/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405 * For each direction the minimum and maximum values are given.
406 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100408 { 0, 2 }, /* ALC_PIN_DIR_IN */
409 { 3, 4 }, /* ALC_PIN_DIR_OUT */
410 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
412 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413};
414#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
415#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
416#define alc_pin_mode_n_items(_dir) \
417 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
418
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200421{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422 unsigned int item_num = uinfo->value.enumerated.item;
423 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
424
425 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200426 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
428
429 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
430 item_num = alc_pin_mode_min(dir);
431 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200432 return 0;
433}
434
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200437{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
440 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100441 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200442 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
444 AC_VERB_GET_PIN_WIDGET_CONTROL,
445 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200446
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100447 /* Find enumerated value for current pinctl setting */
448 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100450 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200451 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100452 return 0;
453}
454
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100457{
458 signed int change;
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
460 hda_nid_t nid = kcontrol->private_value & 0xffff;
461 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
462 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
464 AC_VERB_GET_PIN_WIDGET_CONTROL,
465 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200467 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100468 val = alc_pin_mode_min(dir);
469
470 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100471 if (change) {
472 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200473 snd_hda_codec_write_cache(codec, nid, 0,
474 AC_VERB_SET_PIN_WIDGET_CONTROL,
475 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100476
477 /* Also enable the retasking pin's input/output as required
478 * for the requested pin mode. Enum values of 2 or less are
479 * input modes.
480 *
481 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200482 * reduces noise slightly (particularly on input) so we'll
483 * do it. However, having both input and output buffers
484 * enabled simultaneously doesn't seem to be problematic if
485 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100486 */
487 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200488 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
489 HDA_AMP_MUTE, HDA_AMP_MUTE);
490 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
491 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100492 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200493 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
494 HDA_AMP_MUTE, HDA_AMP_MUTE);
495 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
496 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100497 }
498 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200499 return change;
500}
501
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100502#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200503 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504 .info = alc_pin_mode_info, \
505 .get = alc_pin_mode_get, \
506 .put = alc_pin_mode_put, \
507 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100508
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100509/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
510 * together using a mask with more than one bit set. This control is
511 * currently used only by the ALC260 test model. At this stage they are not
512 * needed for any "production" models.
513 */
514#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200515#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200516
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200517static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100519{
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 hda_nid_t nid = kcontrol->private_value & 0xffff;
522 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
523 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524 unsigned int val = snd_hda_codec_read(codec, nid, 0,
525 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100526
527 *valp = (val & mask) != 0;
528 return 0;
529}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100532{
533 signed int change;
534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 hda_nid_t nid = kcontrol->private_value & 0xffff;
536 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
537 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
539 AC_VERB_GET_GPIO_DATA,
540 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100541
542 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
544 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100545 gpio_data &= ~mask;
546 else
547 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200548 snd_hda_codec_write_cache(codec, nid, 0,
549 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100550
551 return change;
552}
553#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
554 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
555 .info = alc_gpio_data_info, \
556 .get = alc_gpio_data_get, \
557 .put = alc_gpio_data_put, \
558 .private_value = nid | (mask<<16) }
559#endif /* CONFIG_SND_DEBUG */
560
Jonathan Woithe92621f12006-02-28 11:47:47 +0100561/* A switch control to allow the enabling of the digital IO pins on the
562 * ALC260. This is incredibly simplistic; the intention of this control is
563 * to provide something in the test model allowing digital outputs to be
564 * identified if present. If models are found which can utilise these
565 * outputs a more complete mixer control can be devised for those models if
566 * necessary.
567 */
568#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200569#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200570
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
572 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100573{
574 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
575 hda_nid_t nid = kcontrol->private_value & 0xffff;
576 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
577 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200578 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100579 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100580
581 *valp = (val & mask) != 0;
582 return 0;
583}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200584static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
585 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100586{
587 signed int change;
588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
589 hda_nid_t nid = kcontrol->private_value & 0xffff;
590 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
591 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200592 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100593 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200594 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100595
596 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100598 if (val==0)
599 ctrl_data &= ~mask;
600 else
601 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200602 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
603 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100604
605 return change;
606}
607#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
608 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
609 .info = alc_spdif_ctrl_info, \
610 .get = alc_spdif_ctrl_get, \
611 .put = alc_spdif_ctrl_put, \
612 .private_value = nid | (mask<<16) }
613#endif /* CONFIG_SND_DEBUG */
614
Jonathan Woithef8225f62008-01-08 12:16:54 +0100615/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
616 * Again, this is only used in the ALC26x test models to help identify when
617 * the EAPD line must be asserted for features to work.
618 */
619#ifdef CONFIG_SND_DEBUG
620#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
621
622static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
624{
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 hda_nid_t nid = kcontrol->private_value & 0xffff;
627 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
628 long *valp = ucontrol->value.integer.value;
629 unsigned int val = snd_hda_codec_read(codec, nid, 0,
630 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
631
632 *valp = (val & mask) != 0;
633 return 0;
634}
635
636static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
637 struct snd_ctl_elem_value *ucontrol)
638{
639 int change;
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 hda_nid_t nid = kcontrol->private_value & 0xffff;
642 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
643 long val = *ucontrol->value.integer.value;
644 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
645 AC_VERB_GET_EAPD_BTLENABLE,
646 0x00);
647
648 /* Set/unset the masked control bit(s) as needed */
649 change = (!val ? 0 : mask) != (ctrl_data & mask);
650 if (!val)
651 ctrl_data &= ~mask;
652 else
653 ctrl_data |= mask;
654 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
655 ctrl_data);
656
657 return change;
658}
659
660#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
661 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
662 .info = alc_eapd_ctrl_info, \
663 .get = alc_eapd_ctrl_get, \
664 .put = alc_eapd_ctrl_put, \
665 .private_value = nid | (mask<<16) }
666#endif /* CONFIG_SND_DEBUG */
667
Kailang Yangdf694da2005-12-05 19:42:22 +0100668/*
669 * set up from the preset table
670 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671static void setup_preset(struct alc_spec *spec,
672 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100673{
674 int i;
675
676 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
677 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
679 i++)
680 spec->init_verbs[spec->num_init_verbs++] =
681 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100682
683 spec->channel_mode = preset->channel_mode;
684 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200685 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100686
687 spec->multiout.max_channels = spec->channel_mode[0].channels;
688
689 spec->multiout.num_dacs = preset->num_dacs;
690 spec->multiout.dac_nids = preset->dac_nids;
691 spec->multiout.dig_out_nid = preset->dig_out_nid;
692 spec->multiout.hp_nid = preset->hp_nid;
693
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200694 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200695 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200696 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100697 spec->input_mux = preset->input_mux;
698
699 spec->num_adc_nids = preset->num_adc_nids;
700 spec->adc_nids = preset->adc_nids;
701 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100702
703 spec->unsol_event = preset->unsol_event;
704 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200705#ifdef CONFIG_SND_HDA_POWER_SAVE
706 spec->loopback.amplist = preset->loopbacks;
707#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100708}
709
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200710/* Enable GPIO mask and set output */
711static struct hda_verb alc_gpio1_init_verbs[] = {
712 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
713 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
714 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
715 { }
716};
717
718static struct hda_verb alc_gpio2_init_verbs[] = {
719 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
720 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
721 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
722 { }
723};
724
Kailang Yangbdd148a2007-05-08 15:19:08 +0200725static struct hda_verb alc_gpio3_init_verbs[] = {
726 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
727 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
728 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
729 { }
730};
731
Kailang Yangc9b58002007-10-16 14:30:01 +0200732static void alc_sku_automute(struct hda_codec *codec)
733{
734 struct alc_spec *spec = codec->spec;
735 unsigned int mute;
736 unsigned int present;
737 unsigned int hp_nid = spec->autocfg.hp_pins[0];
738 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
739
740 /* need to execute and sync at first */
741 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
742 present = snd_hda_codec_read(codec, hp_nid, 0,
743 AC_VERB_GET_PIN_SENSE, 0);
744 spec->jack_present = (present & 0x80000000) != 0;
745 if (spec->jack_present) {
746 /* mute internal speaker */
747 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
748 HDA_AMP_MUTE, HDA_AMP_MUTE);
749 } else {
750 /* unmute internal speaker if necessary */
751 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
752 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
753 HDA_AMP_MUTE, mute);
754 }
755}
756
757/* unsolicited event for HP jack sensing */
758static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
759{
760 if (codec->vendor_id == 0x10ec0880)
761 res >>= 28;
762 else
763 res >>= 26;
764 if (res != ALC880_HP_EVENT)
765 return;
766
767 alc_sku_automute(codec);
768}
769
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200770/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
771 * 31 ~ 16 : Manufacture ID
772 * 15 ~ 8 : SKU ID
773 * 7 ~ 0 : Assembly ID
774 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
775 */
776static void alc_subsystem_id(struct hda_codec *codec,
777 unsigned int porta, unsigned int porte,
778 unsigned int portd)
779{
Kailang Yangc9b58002007-10-16 14:30:01 +0200780 unsigned int ass, tmp, i;
781 unsigned nid;
782 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200783
Kailang Yangc9b58002007-10-16 14:30:01 +0200784 ass = codec->subsystem_id & 0xffff;
785 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
786 goto do_sku;
787
788 /*
789 * 31~30 : port conetcivity
790 * 29~21 : reserve
791 * 20 : PCBEEP input
792 * 19~16 : Check sum (15:1)
793 * 15~1 : Custom
794 * 0 : override
795 */
796 nid = 0x1d;
797 if (codec->vendor_id == 0x10ec0260)
798 nid = 0x17;
799 ass = snd_hda_codec_read(codec, nid, 0,
800 AC_VERB_GET_CONFIG_DEFAULT, 0);
801 if (!(ass & 1) && !(ass & 0x100000))
802 return;
803 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200804 return;
805
Kailang Yangc9b58002007-10-16 14:30:01 +0200806 /* check sum */
807 tmp = 0;
808 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100809 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200810 tmp++;
811 }
812 if (((ass >> 16) & 0xf) != tmp)
813 return;
814do_sku:
815 /*
816 * 0 : override
817 * 1 : Swap Jack
818 * 2 : 0 --> Desktop, 1 --> Laptop
819 * 3~5 : External Amplifier control
820 * 7~6 : Reserved
821 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200822 tmp = (ass & 0x38) >> 3; /* external Amp control */
823 switch (tmp) {
824 case 1:
825 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
826 break;
827 case 3:
828 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
829 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200830 case 7:
831 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
832 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200833 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200834 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200835 case 0x10ec0260:
836 snd_hda_codec_write(codec, 0x0f, 0,
837 AC_VERB_SET_EAPD_BTLENABLE, 2);
838 snd_hda_codec_write(codec, 0x10, 0,
839 AC_VERB_SET_EAPD_BTLENABLE, 2);
840 break;
841 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200842 case 0x10ec0267:
843 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200844 case 0x10ec0269:
845 case 0x10ec0862:
846 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200847 snd_hda_codec_write(codec, 0x14, 0,
848 AC_VERB_SET_EAPD_BTLENABLE, 2);
849 snd_hda_codec_write(codec, 0x15, 0,
850 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200851 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200852 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200853 switch (codec->vendor_id) {
854 case 0x10ec0260:
855 snd_hda_codec_write(codec, 0x1a, 0,
856 AC_VERB_SET_COEF_INDEX, 7);
857 tmp = snd_hda_codec_read(codec, 0x1a, 0,
858 AC_VERB_GET_PROC_COEF, 0);
859 snd_hda_codec_write(codec, 0x1a, 0,
860 AC_VERB_SET_COEF_INDEX, 7);
861 snd_hda_codec_write(codec, 0x1a, 0,
862 AC_VERB_SET_PROC_COEF,
863 tmp | 0x2010);
864 break;
865 case 0x10ec0262:
866 case 0x10ec0880:
867 case 0x10ec0882:
868 case 0x10ec0883:
869 case 0x10ec0885:
870 case 0x10ec0888:
871 snd_hda_codec_write(codec, 0x20, 0,
872 AC_VERB_SET_COEF_INDEX, 7);
873 tmp = snd_hda_codec_read(codec, 0x20, 0,
874 AC_VERB_GET_PROC_COEF, 0);
875 snd_hda_codec_write(codec, 0x20, 0,
876 AC_VERB_SET_COEF_INDEX, 7);
877 snd_hda_codec_write(codec, 0x20, 0,
878 AC_VERB_SET_PROC_COEF,
879 tmp | 0x2010);
880 break;
881 case 0x10ec0267:
882 case 0x10ec0268:
883 snd_hda_codec_write(codec, 0x20, 0,
884 AC_VERB_SET_COEF_INDEX, 7);
885 tmp = snd_hda_codec_read(codec, 0x20, 0,
886 AC_VERB_GET_PROC_COEF, 0);
887 snd_hda_codec_write(codec, 0x20, 0,
888 AC_VERB_SET_COEF_INDEX, 7);
889 snd_hda_codec_write(codec, 0x20, 0,
890 AC_VERB_SET_PROC_COEF,
891 tmp | 0x3000);
892 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200893 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200894 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200895 break;
896 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200897
Kailang Yang8c427222008-01-10 13:03:59 +0100898 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200899 * when the external headphone out jack is plugged"
900 */
Kailang Yang8c427222008-01-10 13:03:59 +0100901 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200902 return;
903 /*
904 * 10~8 : Jack location
905 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
906 * 14~13: Resvered
907 * 15 : 1 --> enable the function "Mute internal speaker
908 * when the external headphone out jack is plugged"
909 */
910 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100911 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200912 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100913 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200914 else
915 return;
916 }
917
918 if (!spec->autocfg.hp_pins[0]) {
919 tmp = (ass >> 11) & 0x3; /* HP to chassis */
920 if (tmp == 0)
921 spec->autocfg.hp_pins[0] = porta;
922 else if (tmp == 1)
923 spec->autocfg.hp_pins[0] = porte;
924 else if (tmp == 2)
925 spec->autocfg.hp_pins[0] = portd;
926 else
927 return;
928 }
929
930 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
931 AC_VERB_SET_UNSOLICITED_ENABLE,
932 AC_USRSP_EN | ALC880_HP_EVENT);
933 spec->unsol_event = alc_sku_unsol_event;
934 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200935}
936
Takashi Iwai41e41f12005-06-08 14:48:49 +0200937/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200938 * Fix-up pin default configurations
939 */
940
941struct alc_pincfg {
942 hda_nid_t nid;
943 u32 val;
944};
945
946static void alc_fix_pincfg(struct hda_codec *codec,
947 const struct snd_pci_quirk *quirk,
948 const struct alc_pincfg **pinfix)
949{
950 const struct alc_pincfg *cfg;
951
952 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
953 if (!quirk)
954 return;
955
956 cfg = pinfix[quirk->value];
957 for (; cfg->nid; cfg++) {
958 int i;
959 u32 val = cfg->val;
960 for (i = 0; i < 4; i++) {
961 snd_hda_codec_write(codec, cfg->nid, 0,
962 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
963 val & 0xff);
964 val >>= 8;
965 }
966 }
967}
968
969/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200970 * ALC880 3-stack model
971 *
972 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200973 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
974 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 */
976
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200977static hda_nid_t alc880_dac_nids[4] = {
978 /* front, rear, clfe, rear_surr */
979 0x02, 0x05, 0x04, 0x03
980};
981
982static hda_nid_t alc880_adc_nids[3] = {
983 /* ADC0-2 */
984 0x07, 0x08, 0x09,
985};
986
987/* The datasheet says the node 0x07 is connected from inputs,
988 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100989 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200991static hda_nid_t alc880_adc_nids_alt[2] = {
992 /* ADC1-2 */
993 0x08, 0x09,
994};
995
996#define ALC880_DIGOUT_NID 0x06
997#define ALC880_DIGIN_NID 0x0a
998
999static struct hda_input_mux alc880_capture_source = {
1000 .num_items = 4,
1001 .items = {
1002 { "Mic", 0x0 },
1003 { "Front Mic", 0x3 },
1004 { "Line", 0x2 },
1005 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001007};
1008
1009/* channel source setting (2/6 channel selection for 3-stack) */
1010/* 2ch mode */
1011static struct hda_verb alc880_threestack_ch2_init[] = {
1012 /* set line-in to input, mute it */
1013 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1014 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1015 /* set mic-in to input vref 80%, mute it */
1016 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1017 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 { } /* end */
1019};
1020
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001021/* 6ch mode */
1022static struct hda_verb alc880_threestack_ch6_init[] = {
1023 /* set line-in to output, unmute it */
1024 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1025 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1026 /* set mic-in to output, unmute it */
1027 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1028 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1029 { } /* end */
1030};
1031
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001032static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001033 { 2, alc880_threestack_ch2_init },
1034 { 6, alc880_threestack_ch6_init },
1035};
1036
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001037static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001041 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001042 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001044 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1045 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1052 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1054 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1055 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001057 {
1058 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1059 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001060 .info = alc_ch_mode_info,
1061 .get = alc_ch_mode_get,
1062 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001063 },
1064 { } /* end */
1065};
1066
1067/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001068static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1070 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1071 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1072 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1074 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1075 {
1076 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1077 /* The multiple "Capture Source" controls confuse alsamixer
1078 * So call somewhat different..
1079 * FIXME: the controls appear in the "playback" view!
1080 */
1081 /* .name = "Capture Source", */
1082 .name = "Input Source",
1083 .count = 3,
1084 .info = alc_mux_enum_info,
1085 .get = alc_mux_enum_get,
1086 .put = alc_mux_enum_put,
1087 },
1088 { } /* end */
1089};
1090
1091/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001092static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001093 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1094 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1095 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1096 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 {
1098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1099 /* The multiple "Capture Source" controls confuse alsamixer
1100 * So call somewhat different..
1101 * FIXME: the controls appear in the "playback" view!
1102 */
1103 /* .name = "Capture Source", */
1104 .name = "Input Source",
1105 .count = 2,
1106 .info = alc_mux_enum_info,
1107 .get = alc_mux_enum_get,
1108 .put = alc_mux_enum_put,
1109 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 { } /* end */
1111};
1112
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001113
1114
1115/*
1116 * ALC880 5-stack model
1117 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001118 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1119 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001120 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1121 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1122 */
1123
1124/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001125static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001126 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001127 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 { } /* end */
1129};
1130
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001131/* channel source setting (6/8 channel selection for 5-stack) */
1132/* 6ch mode */
1133static struct hda_verb alc880_fivestack_ch6_init[] = {
1134 /* set line-in to input, mute it */
1135 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1136 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001137 { } /* end */
1138};
1139
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001140/* 8ch mode */
1141static struct hda_verb alc880_fivestack_ch8_init[] = {
1142 /* set line-in to output, unmute it */
1143 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1144 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1145 { } /* end */
1146};
1147
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001148static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001149 { 6, alc880_fivestack_ch6_init },
1150 { 8, alc880_fivestack_ch8_init },
1151};
1152
1153
1154/*
1155 * ALC880 6-stack model
1156 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001157 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1158 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001159 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1160 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1161 */
1162
1163static hda_nid_t alc880_6st_dac_nids[4] = {
1164 /* front, rear, clfe, rear_surr */
1165 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001166};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001167
1168static struct hda_input_mux alc880_6stack_capture_source = {
1169 .num_items = 4,
1170 .items = {
1171 { "Mic", 0x0 },
1172 { "Front Mic", 0x1 },
1173 { "Line", 0x2 },
1174 { "CD", 0x4 },
1175 },
1176};
1177
1178/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001179static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001180 { 8, NULL },
1181};
1182
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001183static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001184 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001185 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001186 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001187 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001188 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1189 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001190 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1191 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001192 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001193 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1201 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1202 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1203 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001204 {
1205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1206 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001207 .info = alc_ch_mode_info,
1208 .get = alc_ch_mode_get,
1209 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001210 },
1211 { } /* end */
1212};
1213
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001214
1215/*
1216 * ALC880 W810 model
1217 *
1218 * W810 has rear IO for:
1219 * Front (DAC 02)
1220 * Surround (DAC 03)
1221 * Center/LFE (DAC 04)
1222 * Digital out (06)
1223 *
1224 * The system also has a pair of internal speakers, and a headphone jack.
1225 * These are both connected to Line2 on the codec, hence to DAC 02.
1226 *
1227 * There is a variable resistor to control the speaker or headphone
1228 * volume. This is a hardware-only device without a software API.
1229 *
1230 * Plugging headphones in will disable the internal speakers. This is
1231 * implemented in hardware, not via the driver using jack sense. In
1232 * a similar fashion, plugging into the rear socket marked "front" will
1233 * disable both the speakers and headphones.
1234 *
1235 * For input, there's a microphone jack, and an "audio in" jack.
1236 * These may not do anything useful with this driver yet, because I
1237 * haven't setup any initialization verbs for these yet...
1238 */
1239
1240static hda_nid_t alc880_w810_dac_nids[3] = {
1241 /* front, rear/surround, clfe */
1242 0x02, 0x03, 0x04
1243};
1244
1245/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001246static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001247 { 6, NULL }
1248};
1249
1250/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001251static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001253 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001255 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1257 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001258 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1259 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1261 { } /* end */
1262};
1263
1264
1265/*
1266 * Z710V model
1267 *
1268 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001269 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1270 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001271 */
1272
1273static hda_nid_t alc880_z71v_dac_nids[1] = {
1274 0x02
1275};
1276#define ALC880_Z71V_HP_DAC 0x03
1277
1278/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001279static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280 { 2, NULL }
1281};
1282
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001283static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001284 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001285 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001287 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1289 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1291 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1292 { } /* end */
1293};
1294
1295
1296/* FIXME! */
1297/*
1298 * ALC880 F1734 model
1299 *
1300 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1301 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1302 */
1303
1304static hda_nid_t alc880_f1734_dac_nids[1] = {
1305 0x03
1306};
1307#define ALC880_F1734_HP_DAC 0x02
1308
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001309static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001311 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001312 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001313 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001318 { } /* end */
1319};
1320
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001321
1322/* FIXME! */
1323/*
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/* FIXME! */
1360/*
1361 * ALC880 ASUS W1V model
1362 *
1363 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1364 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1365 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1366 */
1367
1368/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001369static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001370 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1371 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001372 { } /* end */
1373};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001374
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001375/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001376static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001377 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1378 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1379 { } /* end */
1380};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001381
Kailang Yangdf694da2005-12-05 19:42:22 +01001382/* TCL S700 */
1383static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1384 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1385 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1388 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1391 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1392 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1393 {
1394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1395 /* The multiple "Capture Source" controls confuse alsamixer
1396 * So call somewhat different..
1397 * FIXME: the controls appear in the "playback" view!
1398 */
1399 /* .name = "Capture Source", */
1400 .name = "Input Source",
1401 .count = 1,
1402 .info = alc_mux_enum_info,
1403 .get = alc_mux_enum_get,
1404 .put = alc_mux_enum_put,
1405 },
1406 { } /* end */
1407};
1408
Kailang Yangccc656c2006-10-17 12:32:26 +02001409/* Uniwill */
1410static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1411 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1412 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1413 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1414 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1415 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1416 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1417 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1418 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1419 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1420 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1426 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1427 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1428 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1429 {
1430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1431 .name = "Channel Mode",
1432 .info = alc_ch_mode_info,
1433 .get = alc_ch_mode_get,
1434 .put = alc_ch_mode_put,
1435 },
1436 { } /* end */
1437};
1438
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001439static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1440 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1442 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1446 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1447 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1449 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1450 { } /* end */
1451};
1452
Kailang Yangccc656c2006-10-17 12:32:26 +02001453static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1454 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1455 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1456 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1460 { } /* end */
1461};
1462
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001464 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 */
1466static int alc_build_controls(struct hda_codec *codec)
1467{
1468 struct alc_spec *spec = codec->spec;
1469 int err;
1470 int i;
1471
1472 for (i = 0; i < spec->num_mixers; i++) {
1473 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1474 if (err < 0)
1475 return err;
1476 }
1477
1478 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001479 err = snd_hda_create_spdif_out_ctls(codec,
1480 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 if (err < 0)
1482 return err;
1483 }
1484 if (spec->dig_in_nid) {
1485 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1486 if (err < 0)
1487 return err;
1488 }
1489 return 0;
1490}
1491
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001492
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493/*
1494 * initialize the codec volumes, etc
1495 */
1496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001497/*
1498 * generic initialization of ADC, input mixers and output mixers
1499 */
1500static struct hda_verb alc880_volume_init_verbs[] = {
1501 /*
1502 * Unmute ADC0-2 and set the default input to mic-in
1503 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001504 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001506 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001508 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001511 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1512 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001513 * Note: PASD motherboards uses the Line In 2 as the input for front
1514 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001516 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001525 /*
1526 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001528 /* set vol=0 to output mixers */
1529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1532 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1533 /* set up input amps for analog loopback */
1534 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543
1544 { }
1545};
1546
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001547/*
1548 * 3-stack pin configuration:
1549 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1550 */
1551static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1552 /*
1553 * preset connection lists of input pins
1554 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1555 */
1556 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1557 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1558 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1559
1560 /*
1561 * Set pin mode and muting
1562 */
1563 /* set front pin widgets 0x14 for output */
1564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1566 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1567 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1569 /* Mic2 (as headphone out) for HP output */
1570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1572 /* Line In pin widget for input */
1573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1574 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1575 /* Line2 (as front mic) pin widget for input and vref at 80% */
1576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1577 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1578 /* CD pin widget for input */
1579 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1580
1581 { }
1582};
1583
1584/*
1585 * 5-stack pin configuration:
1586 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1587 * line-in/side = 0x1a, f-mic = 0x1b
1588 */
1589static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1590 /*
1591 * preset connection lists of input pins
1592 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1593 */
1594 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1595 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1596
1597 /*
1598 * Set pin mode and muting
1599 */
1600 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1604 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001605 /* unmute pins for output (no gain on this amp) */
1606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1609 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1610
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001612 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001613 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1614 /* Mic2 (as headphone out) for HP output */
1615 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001616 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001617 /* Line In pin widget for input */
1618 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1619 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1620 /* Line2 (as front mic) pin widget for input and vref at 80% */
1621 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1622 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1623 /* CD pin widget for input */
1624 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625
1626 { }
1627};
1628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001629/*
1630 * W810 pin configuration:
1631 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1632 */
1633static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 /* hphone/speaker input selector: front DAC */
1635 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1636
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643
1644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001645 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647 { }
1648};
1649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001650/*
1651 * Z71V pin configuration:
1652 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1653 */
1654static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001656 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001657 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001659
Takashi Iwai16ded522005-06-10 19:58:24 +02001660 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001663 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001664
1665 { }
1666};
1667
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001668/*
1669 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001670 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1671 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001672 */
1673static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1674 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1675
Takashi Iwai16ded522005-06-10 19:58:24 +02001676 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001677 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001678 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001680 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001681 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001682 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684
Takashi Iwai16ded522005-06-10 19:58:24 +02001685 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001686 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001689 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001690 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001692 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001693 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1694
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001695 { }
1696};
Takashi Iwai16ded522005-06-10 19:58:24 +02001697
Kailang Yangccc656c2006-10-17 12:32:26 +02001698/*
1699 * Uniwill pin configuration:
1700 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1701 * line = 0x1a
1702 */
1703static struct hda_verb alc880_uniwill_init_verbs[] = {
1704 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1705
1706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1707 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1708 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1710 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1711 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1720
1721 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1722 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1725 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1727 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1728 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1729 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1730
1731 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1732 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1733
1734 { }
1735};
1736
1737/*
1738* Uniwill P53
1739* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1740 */
1741static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1742 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1743
1744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1748 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1749 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1756
1757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1758 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1763
1764 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1765 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1766
1767 { }
1768};
1769
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001770static struct hda_verb alc880_beep_init_verbs[] = {
1771 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1772 { }
1773};
1774
Kailang Yangccc656c2006-10-17 12:32:26 +02001775/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001776static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001777{
1778 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001779 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001780
1781 present = snd_hda_codec_read(codec, 0x14, 0,
1782 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001783 bits = present ? HDA_AMP_MUTE : 0;
1784 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1785 HDA_AMP_MUTE, bits);
1786 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1787 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001788}
1789
1790/* auto-toggle front mic */
1791static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1792{
1793 unsigned int present;
1794 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001795
1796 present = snd_hda_codec_read(codec, 0x18, 0,
1797 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001798 bits = present ? HDA_AMP_MUTE : 0;
1799 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001800}
1801
1802static void alc880_uniwill_automute(struct hda_codec *codec)
1803{
1804 alc880_uniwill_hp_automute(codec);
1805 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001806}
1807
1808static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1809 unsigned int res)
1810{
1811 /* Looks like the unsol event is incompatible with the standard
1812 * definition. 4bit tag is placed at 28 bit!
1813 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001814 switch (res >> 28) {
1815 case ALC880_HP_EVENT:
1816 alc880_uniwill_hp_automute(codec);
1817 break;
1818 case ALC880_MIC_EVENT:
1819 alc880_uniwill_mic_automute(codec);
1820 break;
1821 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001822}
1823
1824static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1825{
1826 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001827 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001828
1829 present = snd_hda_codec_read(codec, 0x14, 0,
1830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001831 bits = present ? HDA_AMP_MUTE : 0;
1832 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001833}
1834
1835static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1836{
1837 unsigned int present;
1838
1839 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001840 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1841 present &= HDA_AMP_VOLMASK;
1842 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1843 HDA_AMP_VOLMASK, present);
1844 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1845 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001846}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001847
Kailang Yangccc656c2006-10-17 12:32:26 +02001848static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1849 unsigned int res)
1850{
1851 /* Looks like the unsol event is incompatible with the standard
1852 * definition. 4bit tag is placed at 28 bit!
1853 */
1854 if ((res >> 28) == ALC880_HP_EVENT)
1855 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001856 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001857 alc880_uniwill_p53_dcvol_automute(codec);
1858}
1859
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001860/* FIXME! */
1861/*
1862 * F1734 pin configuration:
1863 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1864 */
1865static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1866 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1867 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1868 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1869 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1870
1871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1875
1876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1878 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1879 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1880 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1881 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1882 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1883 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1884 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001885
1886 { }
1887};
1888
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001889/* FIXME! */
1890/*
1891 * ASUS pin configuration:
1892 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1893 */
1894static struct hda_verb alc880_pin_asus_init_verbs[] = {
1895 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1896 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1897 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1898 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1899
1900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1906 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1908
1909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1915 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1917 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1918
1919 { }
1920};
1921
1922/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001923#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1924#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001925
Kailang Yangdf694da2005-12-05 19:42:22 +01001926/* Clevo m520g init */
1927static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1928 /* headphone output */
1929 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1930 /* line-out */
1931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 /* Line-in */
1934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 /* CD */
1937 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1938 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1939 /* Mic1 (rear panel) */
1940 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1942 /* Mic2 (front panel) */
1943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1945 /* headphone */
1946 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1947 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1948 /* change to EAPD mode */
1949 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1950 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1951
1952 { }
1953};
1954
1955static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001956 /* change to EAPD mode */
1957 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1958 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1959
Kailang Yangdf694da2005-12-05 19:42:22 +01001960 /* Headphone output */
1961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1962 /* Front output*/
1963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1965
1966 /* Line In pin widget for input */
1967 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1968 /* CD pin widget for input */
1969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1970 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1972
1973 /* change to EAPD mode */
1974 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1975 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1976
1977 { }
1978};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001979
1980/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001981 * LG m1 express dual
1982 *
1983 * Pin assignment:
1984 * Rear Line-In/Out (blue): 0x14
1985 * Build-in Mic-In: 0x15
1986 * Speaker-out: 0x17
1987 * HP-Out (green): 0x1b
1988 * Mic-In/Out (red): 0x19
1989 * SPDIF-Out: 0x1e
1990 */
1991
1992/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1993static hda_nid_t alc880_lg_dac_nids[3] = {
1994 0x05, 0x02, 0x03
1995};
1996
1997/* seems analog CD is not working */
1998static struct hda_input_mux alc880_lg_capture_source = {
1999 .num_items = 3,
2000 .items = {
2001 { "Mic", 0x1 },
2002 { "Line", 0x5 },
2003 { "Internal Mic", 0x6 },
2004 },
2005};
2006
2007/* 2,4,6 channel modes */
2008static struct hda_verb alc880_lg_ch2_init[] = {
2009 /* set line-in and mic-in to input */
2010 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2011 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2012 { }
2013};
2014
2015static struct hda_verb alc880_lg_ch4_init[] = {
2016 /* set line-in to out and mic-in to input */
2017 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2018 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2019 { }
2020};
2021
2022static struct hda_verb alc880_lg_ch6_init[] = {
2023 /* set line-in and mic-in to output */
2024 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2025 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2026 { }
2027};
2028
2029static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2030 { 2, alc880_lg_ch2_init },
2031 { 4, alc880_lg_ch4_init },
2032 { 6, alc880_lg_ch6_init },
2033};
2034
2035static struct snd_kcontrol_new alc880_lg_mixer[] = {
2036 /* FIXME: it's not really "master" but front channels */
2037 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2038 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
2039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2040 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2041 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2042 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2043 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2044 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2048 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2049 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2050 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2051 {
2052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2053 .name = "Channel Mode",
2054 .info = alc_ch_mode_info,
2055 .get = alc_ch_mode_get,
2056 .put = alc_ch_mode_put,
2057 },
2058 { } /* end */
2059};
2060
2061static struct hda_verb alc880_lg_init_verbs[] = {
2062 /* set capture source to mic-in */
2063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2065 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2066 /* mute all amp mixer inputs */
2067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002070 /* line-in to input */
2071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2073 /* built-in mic */
2074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2076 /* speaker-out */
2077 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2079 /* mic-in to input */
2080 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2081 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2083 /* HP-out */
2084 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2085 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2086 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2087 /* jack sense */
2088 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2089 { }
2090};
2091
2092/* toggle speaker-output according to the hp-jack state */
2093static void alc880_lg_automute(struct hda_codec *codec)
2094{
2095 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002096 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002097
2098 present = snd_hda_codec_read(codec, 0x1b, 0,
2099 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002100 bits = present ? HDA_AMP_MUTE : 0;
2101 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2102 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002103}
2104
2105static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2106{
2107 /* Looks like the unsol event is incompatible with the standard
2108 * definition. 4bit tag is placed at 28 bit!
2109 */
2110 if ((res >> 28) == 0x01)
2111 alc880_lg_automute(codec);
2112}
2113
2114/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002115 * LG LW20
2116 *
2117 * Pin assignment:
2118 * Speaker-out: 0x14
2119 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002120 * Built-in Mic-In: 0x19
2121 * Line-In: 0x1b
2122 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002123 * SPDIF-Out: 0x1e
2124 */
2125
Takashi Iwaid6815182006-03-23 16:06:23 +01002126static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002127 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002128 .items = {
2129 { "Mic", 0x0 },
2130 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002131 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002132 },
2133};
2134
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002135#define alc880_lg_lw_modes alc880_threestack_modes
2136
Takashi Iwaid6815182006-03-23 16:06:23 +01002137static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2140 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2141 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2142 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2143 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2146 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2147 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2150 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2151 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002152 {
2153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2154 .name = "Channel Mode",
2155 .info = alc_ch_mode_info,
2156 .get = alc_ch_mode_get,
2157 .put = alc_ch_mode_put,
2158 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002159 { } /* end */
2160};
2161
2162static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002163 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2164 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2165 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2166
Takashi Iwaid6815182006-03-23 16:06:23 +01002167 /* set capture source to mic-in */
2168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2169 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002172 /* speaker-out */
2173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2174 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2175 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002176 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2177 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2178 /* mic-in to input */
2179 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2180 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2181 /* built-in mic */
2182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2184 /* jack sense */
2185 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2186 { }
2187};
2188
2189/* toggle speaker-output according to the hp-jack state */
2190static void alc880_lg_lw_automute(struct hda_codec *codec)
2191{
2192 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002193 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002194
2195 present = snd_hda_codec_read(codec, 0x1b, 0,
2196 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002197 bits = present ? HDA_AMP_MUTE : 0;
2198 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2199 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002200}
2201
2202static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2203{
2204 /* Looks like the unsol event is incompatible with the standard
2205 * definition. 4bit tag is placed at 28 bit!
2206 */
2207 if ((res >> 28) == 0x01)
2208 alc880_lg_lw_automute(codec);
2209}
2210
Takashi Iwaicb53c622007-08-10 17:21:45 +02002211#ifdef CONFIG_SND_HDA_POWER_SAVE
2212static struct hda_amp_list alc880_loopbacks[] = {
2213 { 0x0b, HDA_INPUT, 0 },
2214 { 0x0b, HDA_INPUT, 1 },
2215 { 0x0b, HDA_INPUT, 2 },
2216 { 0x0b, HDA_INPUT, 3 },
2217 { 0x0b, HDA_INPUT, 4 },
2218 { } /* end */
2219};
2220
2221static struct hda_amp_list alc880_lg_loopbacks[] = {
2222 { 0x0b, HDA_INPUT, 1 },
2223 { 0x0b, HDA_INPUT, 6 },
2224 { 0x0b, HDA_INPUT, 7 },
2225 { } /* end */
2226};
2227#endif
2228
Takashi Iwaid6815182006-03-23 16:06:23 +01002229/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002230 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002232
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233static int alc_init(struct hda_codec *codec)
2234{
2235 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236 unsigned int i;
2237
2238 for (i = 0; i < spec->num_init_verbs; i++)
2239 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002240
2241 if (spec->init_hook)
2242 spec->init_hook(codec);
2243
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 return 0;
2245}
2246
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002247static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2248{
2249 struct alc_spec *spec = codec->spec;
2250
2251 if (spec->unsol_event)
2252 spec->unsol_event(codec, res);
2253}
2254
Takashi Iwaicb53c622007-08-10 17:21:45 +02002255#ifdef CONFIG_SND_HDA_POWER_SAVE
2256static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2257{
2258 struct alc_spec *spec = codec->spec;
2259 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2260}
2261#endif
2262
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263/*
2264 * Analog playback callbacks
2265 */
2266static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2267 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002268 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269{
2270 struct alc_spec *spec = codec->spec;
2271 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2272}
2273
2274static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2275 struct hda_codec *codec,
2276 unsigned int stream_tag,
2277 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002278 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279{
2280 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002281 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2282 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283}
2284
2285static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2286 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002287 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288{
2289 struct alc_spec *spec = codec->spec;
2290 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2291}
2292
2293/*
2294 * Digital out
2295 */
2296static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2297 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002298 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299{
2300 struct alc_spec *spec = codec->spec;
2301 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2302}
2303
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002304static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2305 struct hda_codec *codec,
2306 unsigned int stream_tag,
2307 unsigned int format,
2308 struct snd_pcm_substream *substream)
2309{
2310 struct alc_spec *spec = codec->spec;
2311 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2312 stream_tag, format, substream);
2313}
2314
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2316 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002317 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318{
2319 struct alc_spec *spec = codec->spec;
2320 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2321}
2322
2323/*
2324 * Analog capture
2325 */
2326static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2327 struct hda_codec *codec,
2328 unsigned int stream_tag,
2329 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002330 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331{
2332 struct alc_spec *spec = codec->spec;
2333
2334 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2335 stream_tag, 0, format);
2336 return 0;
2337}
2338
2339static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2340 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002341 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342{
2343 struct alc_spec *spec = codec->spec;
2344
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002345 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2346 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 return 0;
2348}
2349
2350
2351/*
2352 */
2353static struct hda_pcm_stream alc880_pcm_analog_playback = {
2354 .substreams = 1,
2355 .channels_min = 2,
2356 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002357 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 .ops = {
2359 .open = alc880_playback_pcm_open,
2360 .prepare = alc880_playback_pcm_prepare,
2361 .cleanup = alc880_playback_pcm_cleanup
2362 },
2363};
2364
2365static struct hda_pcm_stream alc880_pcm_analog_capture = {
2366 .substreams = 2,
2367 .channels_min = 2,
2368 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002369 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 .ops = {
2371 .prepare = alc880_capture_pcm_prepare,
2372 .cleanup = alc880_capture_pcm_cleanup
2373 },
2374};
2375
2376static struct hda_pcm_stream alc880_pcm_digital_playback = {
2377 .substreams = 1,
2378 .channels_min = 2,
2379 .channels_max = 2,
2380 /* NID is set in alc_build_pcms */
2381 .ops = {
2382 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002383 .close = alc880_dig_playback_pcm_close,
2384 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 },
2386};
2387
2388static struct hda_pcm_stream alc880_pcm_digital_capture = {
2389 .substreams = 1,
2390 .channels_min = 2,
2391 .channels_max = 2,
2392 /* NID is set in alc_build_pcms */
2393};
2394
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002395/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2396static struct hda_pcm_stream alc_pcm_null_playback = {
2397 .substreams = 0,
2398 .channels_min = 0,
2399 .channels_max = 0,
2400};
2401
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402static int alc_build_pcms(struct hda_codec *codec)
2403{
2404 struct alc_spec *spec = codec->spec;
2405 struct hda_pcm *info = spec->pcm_rec;
2406 int i;
2407
2408 codec->num_pcms = 1;
2409 codec->pcm_info = info;
2410
2411 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002412 if (spec->stream_analog_playback) {
2413 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2414 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2415 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2416 }
2417 if (spec->stream_analog_capture) {
2418 snd_assert(spec->adc_nids, return -EINVAL);
2419 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2420 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2421 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422
Takashi Iwai4a471b72005-12-07 13:56:29 +01002423 if (spec->channel_mode) {
2424 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2425 for (i = 0; i < spec->num_channel_mode; i++) {
2426 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2427 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 }
2430 }
2431
Takashi Iwaie08a0072006-09-07 17:52:14 +02002432 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002434 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002435 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002437 if (spec->multiout.dig_out_nid &&
2438 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2440 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2441 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002442 if (spec->dig_in_nid &&
2443 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2445 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2446 }
2447 }
2448
Takashi Iwaie08a0072006-09-07 17:52:14 +02002449 /* If the use of more than one ADC is requested for the current
2450 * model, configure a second analog capture-only PCM.
2451 */
2452 /* Additional Analaog capture for index #2 */
2453 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2454 spec->adc_nids) {
2455 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002456 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002457 info->name = spec->stream_name_analog;
2458 /* No playback stream for second PCM */
2459 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2460 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2461 if (spec->stream_analog_capture) {
2462 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2463 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2464 }
2465 }
2466
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 return 0;
2468}
2469
2470static void alc_free(struct hda_codec *codec)
2471{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472 struct alc_spec *spec = codec->spec;
2473 unsigned int i;
2474
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002475 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002476 return;
2477
2478 if (spec->kctl_alloc) {
2479 for (i = 0; i < spec->num_kctl_used; i++)
2480 kfree(spec->kctl_alloc[i].name);
2481 kfree(spec->kctl_alloc);
2482 }
2483 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484}
2485
2486/*
2487 */
2488static struct hda_codec_ops alc_patch_ops = {
2489 .build_controls = alc_build_controls,
2490 .build_pcms = alc_build_pcms,
2491 .init = alc_init,
2492 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002493 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002494#ifdef CONFIG_SND_HDA_POWER_SAVE
2495 .check_power_status = alc_check_power_status,
2496#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497};
2498
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002499
2500/*
2501 * Test configuration for debugging
2502 *
2503 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2504 * enum controls.
2505 */
2506#ifdef CONFIG_SND_DEBUG
2507static hda_nid_t alc880_test_dac_nids[4] = {
2508 0x02, 0x03, 0x04, 0x05
2509};
2510
2511static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002512 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002513 .items = {
2514 { "In-1", 0x0 },
2515 { "In-2", 0x1 },
2516 { "In-3", 0x2 },
2517 { "In-4", 0x3 },
2518 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002519 { "Front", 0x5 },
2520 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002521 },
2522};
2523
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002524static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002525 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002526 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002527 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002528 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002529};
2530
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002531static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2532 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002533{
2534 static char *texts[] = {
2535 "N/A", "Line Out", "HP Out",
2536 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2537 };
2538 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2539 uinfo->count = 1;
2540 uinfo->value.enumerated.items = 8;
2541 if (uinfo->value.enumerated.item >= 8)
2542 uinfo->value.enumerated.item = 7;
2543 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2544 return 0;
2545}
2546
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002547static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002549{
2550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2551 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2552 unsigned int pin_ctl, item = 0;
2553
2554 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2555 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2556 if (pin_ctl & AC_PINCTL_OUT_EN) {
2557 if (pin_ctl & AC_PINCTL_HP_EN)
2558 item = 2;
2559 else
2560 item = 1;
2561 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2562 switch (pin_ctl & AC_PINCTL_VREFEN) {
2563 case AC_PINCTL_VREF_HIZ: item = 3; break;
2564 case AC_PINCTL_VREF_50: item = 4; break;
2565 case AC_PINCTL_VREF_GRD: item = 5; break;
2566 case AC_PINCTL_VREF_80: item = 6; break;
2567 case AC_PINCTL_VREF_100: item = 7; break;
2568 }
2569 }
2570 ucontrol->value.enumerated.item[0] = item;
2571 return 0;
2572}
2573
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002574static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2575 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002576{
2577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2578 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2579 static unsigned int ctls[] = {
2580 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2581 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2582 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2583 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2584 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2585 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2586 };
2587 unsigned int old_ctl, new_ctl;
2588
2589 old_ctl = snd_hda_codec_read(codec, nid, 0,
2590 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2591 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2592 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002593 int val;
2594 snd_hda_codec_write_cache(codec, nid, 0,
2595 AC_VERB_SET_PIN_WIDGET_CONTROL,
2596 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002597 val = ucontrol->value.enumerated.item[0] >= 3 ?
2598 HDA_AMP_MUTE : 0;
2599 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2600 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002601 return 1;
2602 }
2603 return 0;
2604}
2605
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002606static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2607 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002608{
2609 static char *texts[] = {
2610 "Front", "Surround", "CLFE", "Side"
2611 };
2612 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2613 uinfo->count = 1;
2614 uinfo->value.enumerated.items = 4;
2615 if (uinfo->value.enumerated.item >= 4)
2616 uinfo->value.enumerated.item = 3;
2617 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2618 return 0;
2619}
2620
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002621static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2622 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002623{
2624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2625 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2626 unsigned int sel;
2627
2628 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2629 ucontrol->value.enumerated.item[0] = sel & 3;
2630 return 0;
2631}
2632
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002633static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2634 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002635{
2636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2637 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2638 unsigned int sel;
2639
2640 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2641 if (ucontrol->value.enumerated.item[0] != sel) {
2642 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002643 snd_hda_codec_write_cache(codec, nid, 0,
2644 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002645 return 1;
2646 }
2647 return 0;
2648}
2649
2650#define PIN_CTL_TEST(xname,nid) { \
2651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2652 .name = xname, \
2653 .info = alc_test_pin_ctl_info, \
2654 .get = alc_test_pin_ctl_get, \
2655 .put = alc_test_pin_ctl_put, \
2656 .private_value = nid \
2657 }
2658
2659#define PIN_SRC_TEST(xname,nid) { \
2660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2661 .name = xname, \
2662 .info = alc_test_pin_src_info, \
2663 .get = alc_test_pin_src_get, \
2664 .put = alc_test_pin_src_put, \
2665 .private_value = nid \
2666 }
2667
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002668static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002669 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2670 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2671 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2672 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2674 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2675 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2676 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002677 PIN_CTL_TEST("Front Pin Mode", 0x14),
2678 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2679 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2680 PIN_CTL_TEST("Side Pin Mode", 0x17),
2681 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2682 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2683 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2684 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2685 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2686 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2687 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2688 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2689 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2690 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2691 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2692 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2693 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2694 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2695 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2696 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2697 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2698 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002699 {
2700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2701 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002702 .info = alc_ch_mode_info,
2703 .get = alc_ch_mode_get,
2704 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002705 },
2706 { } /* end */
2707};
2708
2709static struct hda_verb alc880_test_init_verbs[] = {
2710 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2718 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002719 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2723 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002724 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2726 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2727 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2728 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002729 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2733 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002734 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002735 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2738 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002740 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2744 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002745 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002752 /* Analog input/passthru */
2753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002758 { }
2759};
2760#endif
2761
Linus Torvalds1da177e2005-04-16 15:20:36 -07002762/*
2763 */
2764
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002765static const char *alc880_models[ALC880_MODEL_LAST] = {
2766 [ALC880_3ST] = "3stack",
2767 [ALC880_TCL_S700] = "tcl",
2768 [ALC880_3ST_DIG] = "3stack-digout",
2769 [ALC880_CLEVO] = "clevo",
2770 [ALC880_5ST] = "5stack",
2771 [ALC880_5ST_DIG] = "5stack-digout",
2772 [ALC880_W810] = "w810",
2773 [ALC880_Z71V] = "z71v",
2774 [ALC880_6ST] = "6stack",
2775 [ALC880_6ST_DIG] = "6stack-digout",
2776 [ALC880_ASUS] = "asus",
2777 [ALC880_ASUS_W1V] = "asus-w1v",
2778 [ALC880_ASUS_DIG] = "asus-dig",
2779 [ALC880_ASUS_DIG2] = "asus-dig2",
2780 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002781 [ALC880_UNIWILL_P53] = "uniwill-p53",
2782 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002783 [ALC880_F1734] = "F1734",
2784 [ALC880_LG] = "lg",
2785 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002786#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002787 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002788#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002789 [ALC880_AUTO] = "auto",
2790};
2791
2792static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002793 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002794 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2795 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2796 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2797 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2798 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2799 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2800 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2801 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002802 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2803 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002804 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2805 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2806 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2807 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2808 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2809 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2810 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2811 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2812 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2813 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002814 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002815 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2816 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2817 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002818 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002819 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002820 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2821 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002822 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2823 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002824 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2825 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2826 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2827 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002828 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2829 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002830 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002831 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002832 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002833 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002834 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2835 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002836 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2837 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002838 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002839 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002840 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002841 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002842 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002843 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2844 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002845 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002846 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2847 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2848 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2849 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002850 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2851 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002852 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002853 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002854 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2855 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002856 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2857 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2858 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002859 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2860 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2861 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862 {}
2863};
2864
Takashi Iwai16ded522005-06-10 19:58:24 +02002865/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002866 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002867 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002868static struct alc_config_preset alc880_presets[] = {
2869 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002870 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002871 .init_verbs = { alc880_volume_init_verbs,
2872 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002873 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002874 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002875 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2876 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002877 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002878 .input_mux = &alc880_capture_source,
2879 },
2880 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002881 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002882 .init_verbs = { alc880_volume_init_verbs,
2883 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002884 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002885 .dac_nids = alc880_dac_nids,
2886 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002887 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2888 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002889 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002890 .input_mux = &alc880_capture_source,
2891 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002892 [ALC880_TCL_S700] = {
2893 .mixers = { alc880_tcl_s700_mixer },
2894 .init_verbs = { alc880_volume_init_verbs,
2895 alc880_pin_tcl_S700_init_verbs,
2896 alc880_gpio2_init_verbs },
2897 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2898 .dac_nids = alc880_dac_nids,
2899 .hp_nid = 0x03,
2900 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2901 .channel_mode = alc880_2_jack_modes,
2902 .input_mux = &alc880_capture_source,
2903 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002904 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002905 .mixers = { alc880_three_stack_mixer,
2906 alc880_five_stack_mixer},
2907 .init_verbs = { alc880_volume_init_verbs,
2908 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2910 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002911 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2912 .channel_mode = alc880_fivestack_modes,
2913 .input_mux = &alc880_capture_source,
2914 },
2915 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002916 .mixers = { alc880_three_stack_mixer,
2917 alc880_five_stack_mixer },
2918 .init_verbs = { alc880_volume_init_verbs,
2919 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002920 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2921 .dac_nids = alc880_dac_nids,
2922 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002923 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2924 .channel_mode = alc880_fivestack_modes,
2925 .input_mux = &alc880_capture_source,
2926 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002927 [ALC880_6ST] = {
2928 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002929 .init_verbs = { alc880_volume_init_verbs,
2930 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002931 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2932 .dac_nids = alc880_6st_dac_nids,
2933 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2934 .channel_mode = alc880_sixstack_modes,
2935 .input_mux = &alc880_6stack_capture_source,
2936 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002937 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002938 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002939 .init_verbs = { alc880_volume_init_verbs,
2940 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002941 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2942 .dac_nids = alc880_6st_dac_nids,
2943 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002944 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2945 .channel_mode = alc880_sixstack_modes,
2946 .input_mux = &alc880_6stack_capture_source,
2947 },
2948 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002950 .init_verbs = { alc880_volume_init_verbs,
2951 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002952 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002953 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2954 .dac_nids = alc880_w810_dac_nids,
2955 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002956 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2957 .channel_mode = alc880_w810_modes,
2958 .input_mux = &alc880_capture_source,
2959 },
2960 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002962 .init_verbs = { alc880_volume_init_verbs,
2963 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002964 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2965 .dac_nids = alc880_z71v_dac_nids,
2966 .dig_out_nid = ALC880_DIGOUT_NID,
2967 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2969 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 .input_mux = &alc880_capture_source,
2971 },
2972 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002974 .init_verbs = { alc880_volume_init_verbs,
2975 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002976 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2977 .dac_nids = alc880_f1734_dac_nids,
2978 .hp_nid = 0x02,
2979 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2980 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 .input_mux = &alc880_capture_source,
2982 },
2983 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002985 .init_verbs = { alc880_volume_init_verbs,
2986 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002987 alc880_gpio1_init_verbs },
2988 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2989 .dac_nids = alc880_asus_dac_nids,
2990 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2991 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002992 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002993 .input_mux = &alc880_capture_source,
2994 },
2995 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999 alc880_gpio1_init_verbs },
3000 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3001 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3004 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003005 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003006 .input_mux = &alc880_capture_source,
3007 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003008 [ALC880_ASUS_DIG2] = {
3009 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003010 .init_verbs = { alc880_volume_init_verbs,
3011 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003012 alc880_gpio2_init_verbs }, /* use GPIO2 */
3013 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3014 .dac_nids = alc880_asus_dac_nids,
3015 .dig_out_nid = ALC880_DIGOUT_NID,
3016 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3017 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003018 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003019 .input_mux = &alc880_capture_source,
3020 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003021 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003022 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003023 .init_verbs = { alc880_volume_init_verbs,
3024 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003025 alc880_gpio1_init_verbs },
3026 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3027 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003028 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003029 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3030 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003031 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003032 .input_mux = &alc880_capture_source,
3033 },
3034 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003035 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003036 .init_verbs = { alc880_volume_init_verbs,
3037 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003038 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3039 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003040 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003041 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3042 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003043 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003044 .input_mux = &alc880_capture_source,
3045 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003046 [ALC880_UNIWILL] = {
3047 .mixers = { alc880_uniwill_mixer },
3048 .init_verbs = { alc880_volume_init_verbs,
3049 alc880_uniwill_init_verbs },
3050 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3051 .dac_nids = alc880_asus_dac_nids,
3052 .dig_out_nid = ALC880_DIGOUT_NID,
3053 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3054 .channel_mode = alc880_threestack_modes,
3055 .need_dac_fix = 1,
3056 .input_mux = &alc880_capture_source,
3057 .unsol_event = alc880_uniwill_unsol_event,
3058 .init_hook = alc880_uniwill_automute,
3059 },
3060 [ALC880_UNIWILL_P53] = {
3061 .mixers = { alc880_uniwill_p53_mixer },
3062 .init_verbs = { alc880_volume_init_verbs,
3063 alc880_uniwill_p53_init_verbs },
3064 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3065 .dac_nids = alc880_asus_dac_nids,
3066 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003067 .channel_mode = alc880_threestack_modes,
3068 .input_mux = &alc880_capture_source,
3069 .unsol_event = alc880_uniwill_p53_unsol_event,
3070 .init_hook = alc880_uniwill_p53_hp_automute,
3071 },
3072 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003073 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003074 alc880_pcbeep_mixer, },
3075 .init_verbs = { alc880_volume_init_verbs,
3076 alc880_uniwill_p53_init_verbs,
3077 alc880_beep_init_verbs },
3078 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3079 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003080 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003081 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3082 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003083 .input_mux = &alc880_capture_source,
3084 .unsol_event = alc880_uniwill_p53_unsol_event,
3085 .init_hook = alc880_uniwill_p53_hp_automute,
3086 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003087 [ALC880_CLEVO] = {
3088 .mixers = { alc880_three_stack_mixer },
3089 .init_verbs = { alc880_volume_init_verbs,
3090 alc880_pin_clevo_init_verbs },
3091 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3092 .dac_nids = alc880_dac_nids,
3093 .hp_nid = 0x03,
3094 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3095 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003096 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003097 .input_mux = &alc880_capture_source,
3098 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003099 [ALC880_LG] = {
3100 .mixers = { alc880_lg_mixer },
3101 .init_verbs = { alc880_volume_init_verbs,
3102 alc880_lg_init_verbs },
3103 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3104 .dac_nids = alc880_lg_dac_nids,
3105 .dig_out_nid = ALC880_DIGOUT_NID,
3106 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3107 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003108 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003109 .input_mux = &alc880_lg_capture_source,
3110 .unsol_event = alc880_lg_unsol_event,
3111 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003112#ifdef CONFIG_SND_HDA_POWER_SAVE
3113 .loopbacks = alc880_lg_loopbacks,
3114#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003115 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003116 [ALC880_LG_LW] = {
3117 .mixers = { alc880_lg_lw_mixer },
3118 .init_verbs = { alc880_volume_init_verbs,
3119 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003120 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003121 .dac_nids = alc880_dac_nids,
3122 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003123 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3124 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003125 .input_mux = &alc880_lg_lw_capture_source,
3126 .unsol_event = alc880_lg_lw_unsol_event,
3127 .init_hook = alc880_lg_lw_automute,
3128 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003129#ifdef CONFIG_SND_DEBUG
3130 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 .mixers = { alc880_test_mixer },
3132 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003133 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3134 .dac_nids = alc880_test_dac_nids,
3135 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3137 .channel_mode = alc880_test_modes,
3138 .input_mux = &alc880_test_capture_source,
3139 },
3140#endif
3141};
3142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003143/*
3144 * Automatic parse of I/O pins from the BIOS configuration
3145 */
3146
3147#define NUM_CONTROL_ALLOC 32
3148#define NUM_VERB_ALLOC 32
3149
3150enum {
3151 ALC_CTL_WIDGET_VOL,
3152 ALC_CTL_WIDGET_MUTE,
3153 ALC_CTL_BIND_MUTE,
3154};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003155static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003156 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3157 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003158 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159};
3160
3161/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003162static int add_control(struct alc_spec *spec, int type, const char *name,
3163 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003164{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003165 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003166
3167 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3168 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3169
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003170 /* array + terminator */
3171 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3172 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003173 return -ENOMEM;
3174 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003175 memcpy(knew, spec->kctl_alloc,
3176 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177 kfree(spec->kctl_alloc);
3178 }
3179 spec->kctl_alloc = knew;
3180 spec->num_kctl_alloc = num;
3181 }
3182
3183 knew = &spec->kctl_alloc[spec->num_kctl_used];
3184 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003185 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003186 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 return -ENOMEM;
3188 knew->private_value = val;
3189 spec->num_kctl_used++;
3190 return 0;
3191}
3192
3193#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3194#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3195#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3196#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3197#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3198#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3199#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3200#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3201#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3202#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3203#define ALC880_PIN_CD_NID 0x1c
3204
3205/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003206static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3207 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208{
3209 hda_nid_t nid;
3210 int assigned[4];
3211 int i, j;
3212
3213 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003214 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003215
3216 /* check the pins hardwired to audio widget */
3217 for (i = 0; i < cfg->line_outs; i++) {
3218 nid = cfg->line_out_pins[i];
3219 if (alc880_is_fixed_pin(nid)) {
3220 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003221 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222 assigned[idx] = 1;
3223 }
3224 }
3225 /* left pins can be connect to any audio widget */
3226 for (i = 0; i < cfg->line_outs; i++) {
3227 nid = cfg->line_out_pins[i];
3228 if (alc880_is_fixed_pin(nid))
3229 continue;
3230 /* search for an empty channel */
3231 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003232 if (!assigned[j]) {
3233 spec->multiout.dac_nids[i] =
3234 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 assigned[j] = 1;
3236 break;
3237 }
3238 }
3239 }
3240 spec->multiout.num_dacs = cfg->line_outs;
3241 return 0;
3242}
3243
3244/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003245static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3246 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247{
3248 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 static const char *chname[4] = {
3250 "Front", "Surround", NULL /*CLFE*/, "Side"
3251 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 hda_nid_t nid;
3253 int i, err;
3254
3255 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003256 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 continue;
3258 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3259 if (i == 2) {
3260 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003261 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3262 "Center Playback Volume",
3263 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3264 HDA_OUTPUT));
3265 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003267 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3268 "LFE Playback Volume",
3269 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3270 HDA_OUTPUT));
3271 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003273 err = add_control(spec, ALC_CTL_BIND_MUTE,
3274 "Center Playback Switch",
3275 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3276 HDA_INPUT));
3277 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003279 err = add_control(spec, ALC_CTL_BIND_MUTE,
3280 "LFE Playback Switch",
3281 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3282 HDA_INPUT));
3283 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003284 return err;
3285 } else {
3286 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003287 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3288 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3289 HDA_OUTPUT));
3290 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003291 return err;
3292 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003293 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3294 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3295 HDA_INPUT));
3296 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297 return err;
3298 }
3299 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003300 return 0;
3301}
3302
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003303/* add playback controls for speaker and HP outputs */
3304static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3305 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003306{
3307 hda_nid_t nid;
3308 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003309 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003310
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003311 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003312 return 0;
3313
3314 if (alc880_is_fixed_pin(pin)) {
3315 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003316 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003317 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003319 else
3320 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003321 /* control HP volume/switch on the output mixer amp */
3322 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003323 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003324 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3325 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3326 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003328 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003329 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3330 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3331 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003332 return err;
3333 } else if (alc880_is_multi_pin(pin)) {
3334 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003335 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003336 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003337 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3338 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3339 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003340 return err;
3341 }
3342 return 0;
3343}
3344
3345/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003346static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3347 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003348 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349{
3350 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003351 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352
3353 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3355 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3356 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357 return err;
3358 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003359 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3360 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3361 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003362 return err;
3363 return 0;
3364}
3365
3366/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003367static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3368 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003369{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003371 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003372
3373 for (i = 0; i < AUTO_PIN_LAST; i++) {
3374 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003375 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003376 err = new_analog_input(spec, cfg->input_pins[i],
3377 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003378 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 if (err < 0)
3380 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003381 imux->items[imux->num_items].label =
3382 auto_pin_cfg_labels[i];
3383 imux->items[imux->num_items].index =
3384 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 imux->num_items++;
3386 }
3387 }
3388 return 0;
3389}
3390
Kailang Yangdf694da2005-12-05 19:42:22 +01003391static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3392 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003393 int dac_idx)
3394{
3395 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003396 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3397 pin_type);
3398 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3399 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003400 /* need the manual connection? */
3401 if (alc880_is_multi_pin(nid)) {
3402 struct alc_spec *spec = codec->spec;
3403 int idx = alc880_multi_pin_idx(nid);
3404 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3405 AC_VERB_SET_CONNECT_SEL,
3406 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3407 }
3408}
3409
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003410static int get_pin_type(int line_out_type)
3411{
3412 if (line_out_type == AUTO_PIN_HP_OUT)
3413 return PIN_HP;
3414 else
3415 return PIN_OUT;
3416}
3417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003418static void alc880_auto_init_multi_out(struct hda_codec *codec)
3419{
3420 struct alc_spec *spec = codec->spec;
3421 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003422
3423 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003424 for (i = 0; i < spec->autocfg.line_outs; i++) {
3425 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003426 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3427 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003428 }
3429}
3430
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003431static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432{
3433 struct alc_spec *spec = codec->spec;
3434 hda_nid_t pin;
3435
Takashi Iwai82bc9552006-03-21 11:24:42 +01003436 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003437 if (pin) /* connect to front */
3438 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003439 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 if (pin) /* connect to front */
3441 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3442}
3443
3444static void alc880_auto_init_analog_input(struct hda_codec *codec)
3445{
3446 struct alc_spec *spec = codec->spec;
3447 int i;
3448
3449 for (i = 0; i < AUTO_PIN_LAST; i++) {
3450 hda_nid_t nid = spec->autocfg.input_pins[i];
3451 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003452 snd_hda_codec_write(codec, nid, 0,
3453 AC_VERB_SET_PIN_WIDGET_CONTROL,
3454 i <= AUTO_PIN_FRONT_MIC ?
3455 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003456 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003457 snd_hda_codec_write(codec, nid, 0,
3458 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003459 AMP_OUT_MUTE);
3460 }
3461 }
3462}
3463
3464/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003465/* return 1 if successful, 0 if the proper config is not found,
3466 * or a negative error code
3467 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468static int alc880_parse_auto_config(struct hda_codec *codec)
3469{
3470 struct alc_spec *spec = codec->spec;
3471 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003472 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003473
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003474 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3475 alc880_ignore);
3476 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003477 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003478 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003479 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003480
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003481 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3482 if (err < 0)
3483 return err;
3484 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3485 if (err < 0)
3486 return err;
3487 err = alc880_auto_create_extra_out(spec,
3488 spec->autocfg.speaker_pins[0],
3489 "Speaker");
3490 if (err < 0)
3491 return err;
3492 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3493 "Headphone");
3494 if (err < 0)
3495 return err;
3496 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3497 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498 return err;
3499
3500 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3501
3502 if (spec->autocfg.dig_out_pin)
3503 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3504 if (spec->autocfg.dig_in_pin)
3505 spec->dig_in_nid = ALC880_DIGIN_NID;
3506
3507 if (spec->kctl_alloc)
3508 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3509
3510 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3511
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003512 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 spec->input_mux = &spec->private_imux;
3514
3515 return 1;
3516}
3517
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003518/* additional initialization for auto-configuration model */
3519static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003521 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003522 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003524}
3525
3526/*
3527 * OK, here we have finally the patch for ALC880
3528 */
3529
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530static int patch_alc880(struct hda_codec *codec)
3531{
3532 struct alc_spec *spec;
3533 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003534 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003535
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003536 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003537 if (spec == NULL)
3538 return -ENOMEM;
3539
3540 codec->spec = spec;
3541
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003542 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3543 alc880_models,
3544 alc880_cfg_tbl);
3545 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003546 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3547 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003548 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549 }
3550
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551 if (board_config == ALC880_AUTO) {
3552 /* automatic parse from the BIOS config */
3553 err = alc880_parse_auto_config(codec);
3554 if (err < 0) {
3555 alc_free(codec);
3556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003557 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003558 printk(KERN_INFO
3559 "hda_codec: Cannot set up configuration "
3560 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003561 board_config = ALC880_3ST;
3562 }
3563 }
3564
Kailang Yangdf694da2005-12-05 19:42:22 +01003565 if (board_config != ALC880_AUTO)
3566 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003567
3568 spec->stream_name_analog = "ALC880 Analog";
3569 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3570 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3571
3572 spec->stream_name_digital = "ALC880 Digital";
3573 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3574 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3575
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003576 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003578 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003579 /* get type */
3580 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003581 if (wcap != AC_WID_AUD_IN) {
3582 spec->adc_nids = alc880_adc_nids_alt;
3583 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003584 spec->mixers[spec->num_mixers] =
3585 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003586 spec->num_mixers++;
3587 } else {
3588 spec->adc_nids = alc880_adc_nids;
3589 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3590 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3591 spec->num_mixers++;
3592 }
3593 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003594
3595 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003597 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003598#ifdef CONFIG_SND_HDA_POWER_SAVE
3599 if (!spec->loopback.amplist)
3600 spec->loopback.amplist = alc880_loopbacks;
3601#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003602
3603 return 0;
3604}
3605
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003606
Linus Torvalds1da177e2005-04-16 15:20:36 -07003607/*
3608 * ALC260 support
3609 */
3610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003611static hda_nid_t alc260_dac_nids[1] = {
3612 /* front */
3613 0x02,
3614};
3615
3616static hda_nid_t alc260_adc_nids[1] = {
3617 /* ADC0 */
3618 0x04,
3619};
3620
Kailang Yangdf694da2005-12-05 19:42:22 +01003621static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622 /* ADC1 */
3623 0x05,
3624};
3625
Kailang Yangdf694da2005-12-05 19:42:22 +01003626static hda_nid_t alc260_hp_adc_nids[2] = {
3627 /* ADC1, 0 */
3628 0x05, 0x04
3629};
3630
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003631/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3632 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3633 */
3634static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003635 /* ADC0, ADC1 */
3636 0x04, 0x05
3637};
3638
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003639#define ALC260_DIGOUT_NID 0x03
3640#define ALC260_DIGIN_NID 0x06
3641
3642static struct hda_input_mux alc260_capture_source = {
3643 .num_items = 4,
3644 .items = {
3645 { "Mic", 0x0 },
3646 { "Front Mic", 0x1 },
3647 { "Line", 0x2 },
3648 { "CD", 0x4 },
3649 },
3650};
3651
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003652/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003653 * headphone jack and the internal CD lines since these are the only pins at
3654 * which audio can appear. For flexibility, also allow the option of
3655 * recording the mixer output on the second ADC (ADC0 doesn't have a
3656 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003657 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003658static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3659 {
3660 .num_items = 3,
3661 .items = {
3662 { "Mic/Line", 0x0 },
3663 { "CD", 0x4 },
3664 { "Headphone", 0x2 },
3665 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003666 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003667 {
3668 .num_items = 4,
3669 .items = {
3670 { "Mic/Line", 0x0 },
3671 { "CD", 0x4 },
3672 { "Headphone", 0x2 },
3673 { "Mixer", 0x5 },
3674 },
3675 },
3676
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003677};
3678
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003679/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3680 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003681 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003682static struct hda_input_mux alc260_acer_capture_sources[2] = {
3683 {
3684 .num_items = 4,
3685 .items = {
3686 { "Mic", 0x0 },
3687 { "Line", 0x2 },
3688 { "CD", 0x4 },
3689 { "Headphone", 0x5 },
3690 },
3691 },
3692 {
3693 .num_items = 5,
3694 .items = {
3695 { "Mic", 0x0 },
3696 { "Line", 0x2 },
3697 { "CD", 0x4 },
3698 { "Headphone", 0x6 },
3699 { "Mixer", 0x5 },
3700 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003701 },
3702};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703/*
3704 * This is just place-holder, so there's something for alc_build_pcms to look
3705 * at when it calculates the maximum number of channels. ALC260 has no mixer
3706 * element which allows changing the channel mode, so the verb list is
3707 * never used.
3708 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003709static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 { 2, NULL },
3711};
3712
Kailang Yangdf694da2005-12-05 19:42:22 +01003713
3714/* Mixer combinations
3715 *
3716 * basic: base_output + input + pc_beep + capture
3717 * HP: base_output + input + capture_alt
3718 * HP_3013: hp_3013 + input + capture
3719 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003720 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003721 */
3722
3723static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003724 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003725 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003726 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3727 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3728 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3729 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3730 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003731};
Kailang Yangdf694da2005-12-05 19:42:22 +01003732
3733static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003734 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3735 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3736 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3737 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3739 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3740 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003742 { } /* end */
3743};
3744
Kailang Yangdf694da2005-12-05 19:42:22 +01003745static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3746 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3747 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3748 { } /* end */
3749};
3750
3751static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3752 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3753 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3754 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3755 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3756 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3758 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3759 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003760 { } /* end */
3761};
3762
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003763/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3764 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3765 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003766static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003767 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003768 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003769 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003770 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3771 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3772 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3773 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003774 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003775 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3776 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3777 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003778 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003779 { } /* end */
3780};
3781
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003782/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3783 * versions of the ALC260 don't act on requests to enable mic bias from NID
3784 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3785 * datasheet doesn't mention this restriction. At this stage it's not clear
3786 * whether this behaviour is intentional or is a hardware bug in chip
3787 * revisions available in early 2006. Therefore for now allow the
3788 * "Headphone Jack Mode" control to span all choices, but if it turns out
3789 * that the lack of mic bias for this NID is intentional we could change the
3790 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3791 *
3792 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3793 * don't appear to make the mic bias available from the "line" jack, even
3794 * though the NID used for this jack (0x14) can supply it. The theory is
3795 * that perhaps Acer have included blocking capacitors between the ALC260
3796 * and the output jack. If this turns out to be the case for all such
3797 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3798 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003799 *
3800 * The C20x Tablet series have a mono internal speaker which is controlled
3801 * via the chip's Mono sum widget and pin complex, so include the necessary
3802 * controls for such models. On models without a "mono speaker" the control
3803 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003804 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003805static struct snd_kcontrol_new alc260_acer_mixer[] = {
3806 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3807 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003808 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003809 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3810 HDA_OUTPUT),
3811 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3812 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003813 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3814 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3816 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3817 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3820 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3821 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3822 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3823 { } /* end */
3824};
3825
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003826/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3827 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3828 */
3829static struct snd_kcontrol_new alc260_will_mixer[] = {
3830 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3831 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3833 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3834 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3835 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3836 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3837 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3838 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3839 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3840 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3841 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3842 { } /* end */
3843};
3844
3845/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3846 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3847 */
3848static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3849 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3850 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3852 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3853 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3854 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3855 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3856 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3857 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3858 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3859 { } /* end */
3860};
3861
Kailang Yangdf694da2005-12-05 19:42:22 +01003862/* capture mixer elements */
3863static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003864 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3865 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003866 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3867 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003868 {
3869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003870 /* The multiple "Capture Source" controls confuse alsamixer
3871 * So call somewhat different..
3872 * FIXME: the controls appear in the "playback" view!
3873 */
3874 /* .name = "Capture Source", */
3875 .name = "Input Source",
3876 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003877 .info = alc_mux_enum_info,
3878 .get = alc_mux_enum_get,
3879 .put = alc_mux_enum_put,
3880 },
3881 { } /* end */
3882};
3883
Kailang Yangdf694da2005-12-05 19:42:22 +01003884static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3885 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3886 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3887 {
3888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3889 /* The multiple "Capture Source" controls confuse alsamixer
3890 * So call somewhat different..
3891 * FIXME: the controls appear in the "playback" view!
3892 */
3893 /* .name = "Capture Source", */
3894 .name = "Input Source",
3895 .count = 1,
3896 .info = alc_mux_enum_info,
3897 .get = alc_mux_enum_get,
3898 .put = alc_mux_enum_put,
3899 },
3900 { } /* end */
3901};
3902
3903/*
3904 * initialization verbs
3905 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003906static struct hda_verb alc260_init_verbs[] = {
3907 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003909 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003910 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003911 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003912 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003913 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003914 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003915 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003917 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003918 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003919 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003920 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003921 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003922 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003923 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003924 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3925 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003926 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003927 /* set connection select to line in (default select for this ADC) */
3928 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003929 /* mute capture amp left and right */
3930 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3931 /* set connection select to line in (default select for this ADC) */
3932 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003933 /* set vol=0 Line-Out mixer amp left and right */
3934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3935 /* unmute pin widget amp left and right (no gain on this amp) */
3936 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3937 /* set vol=0 HP mixer amp left and right */
3938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3939 /* unmute pin widget amp left and right (no gain on this amp) */
3940 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3941 /* set vol=0 Mono mixer amp left and right */
3942 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3943 /* unmute pin widget amp left and right (no gain on this amp) */
3944 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3945 /* unmute LINE-2 out pin */
3946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003947 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3948 * Line In 2 = 0x03
3949 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003950 /* mute analog inputs */
3951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003956 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003957 /* mute Front out path */
3958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3960 /* mute Headphone out path */
3961 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3962 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3963 /* mute Mono out path */
3964 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3965 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003966 { }
3967};
3968
Takashi Iwai474167d2006-05-17 17:17:43 +02003969#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003970static struct hda_verb alc260_hp_init_verbs[] = {
3971 /* Headphone and output */
3972 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3973 /* mono output */
3974 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3975 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3976 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3977 /* Mic2 (front panel) pin widget for input and vref at 80% */
3978 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3979 /* Line In pin widget for input */
3980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3981 /* Line-2 pin widget for output */
3982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3983 /* CD pin widget for input */
3984 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3985 /* unmute amp left and right */
3986 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3987 /* set connection select to line in (default select for this ADC) */
3988 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3989 /* unmute Line-Out mixer amp left and right (volume = 0) */
3990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3991 /* mute pin widget amp left and right (no gain on this amp) */
3992 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3993 /* unmute HP mixer amp left and right (volume = 0) */
3994 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3995 /* mute pin widget amp left and right (no gain on this amp) */
3996 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3998 * Line In 2 = 0x03
3999 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004000 /* mute analog inputs */
4001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004006 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4007 /* Unmute Front out path */
4008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4010 /* Unmute Headphone out path */
4011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4013 /* Unmute Mono out path */
4014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4016 { }
4017};
Takashi Iwai474167d2006-05-17 17:17:43 +02004018#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004019
4020static struct hda_verb alc260_hp_3013_init_verbs[] = {
4021 /* Line out and output */
4022 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4023 /* mono output */
4024 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4025 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4026 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4027 /* Mic2 (front panel) pin widget for input and vref at 80% */
4028 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4029 /* Line In pin widget for input */
4030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4031 /* Headphone pin widget for output */
4032 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4033 /* CD pin widget for input */
4034 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4035 /* unmute amp left and right */
4036 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4037 /* set connection select to line in (default select for this ADC) */
4038 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4039 /* unmute Line-Out mixer amp left and right (volume = 0) */
4040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4041 /* mute pin widget amp left and right (no gain on this amp) */
4042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4043 /* unmute HP mixer amp left and right (volume = 0) */
4044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4045 /* mute pin widget amp left and right (no gain on this amp) */
4046 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004047 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4048 * Line In 2 = 0x03
4049 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004050 /* mute analog inputs */
4051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004056 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4057 /* Unmute Front out path */
4058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4060 /* Unmute Headphone out path */
4061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4063 /* Unmute Mono out path */
4064 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4065 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4066 { }
4067};
4068
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004069/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004070 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4071 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004072 */
4073static struct hda_verb alc260_fujitsu_init_verbs[] = {
4074 /* Disable all GPIOs */
4075 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4076 /* Internal speaker is connected to headphone pin */
4077 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4078 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004080 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4081 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4082 /* Ensure all other unused pins are disabled and muted. */
4083 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004085 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004086 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004087 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004088 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004091
Jonathan Woithef7ace402006-02-28 11:46:14 +01004092 /* Disable digital (SPDIF) pins */
4093 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4094 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004095
Jonathan Woithef7ace402006-02-28 11:46:14 +01004096 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4097 * when acting as an output.
4098 */
4099 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4100
4101 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004102 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4108 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4109 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4110 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004111
Jonathan Woithef7ace402006-02-28 11:46:14 +01004112 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4113 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4114 /* Unmute Line1 pin widget output buffer since it starts as an output.
4115 * If the pin mode is changed by the user the pin mode control will
4116 * take care of enabling the pin's input/output buffers as needed.
4117 * Therefore there's no need to enable the input buffer at this
4118 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004119 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004120 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004121 /* Unmute input buffer of pin widget used for Line-in (no equiv
4122 * mixer ctrl)
4123 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004124 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004125
Jonathan Woithef7ace402006-02-28 11:46:14 +01004126 /* Mute capture amp left and right */
4127 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4128 /* Set ADC connection select to match default mixer setting - line
4129 * in (on mic1 pin)
4130 */
4131 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004132
Jonathan Woithef7ace402006-02-28 11:46:14 +01004133 /* Do the same for the second ADC: mute capture input amp and
4134 * set ADC connection to line in (on mic1 pin)
4135 */
4136 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4137 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004138
Jonathan Woithef7ace402006-02-28 11:46:14 +01004139 /* Mute all inputs to mixer widget (even unconnected ones) */
4140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004148
4149 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004150};
4151
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004152/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4153 * similar laptops (adapted from Fujitsu init verbs).
4154 */
4155static struct hda_verb alc260_acer_init_verbs[] = {
4156 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4157 * the headphone jack. Turn this on and rely on the standard mute
4158 * methods whenever the user wants to turn these outputs off.
4159 */
4160 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4161 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4162 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4163 /* Internal speaker/Headphone jack is connected to Line-out pin */
4164 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4165 /* Internal microphone/Mic jack is connected to Mic1 pin */
4166 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4167 /* Line In jack is connected to Line1 pin */
4168 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004169 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4170 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004171 /* Ensure all other unused pins are disabled and muted. */
4172 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4173 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004174 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4175 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4178 /* Disable digital (SPDIF) pins */
4179 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4180 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4181
4182 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4183 * bus when acting as outputs.
4184 */
4185 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4186 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4187
4188 /* Start with output sum widgets muted and their output gains at min */
4189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4195 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4198
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004199 /* Unmute Line-out pin widget amp left and right
4200 * (no equiv mixer ctrl)
4201 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004202 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004203 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4204 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004205 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4206 * inputs. If the pin mode is changed by the user the pin mode control
4207 * will take care of enabling the pin's input/output buffers as needed.
4208 * Therefore there's no need to enable the input buffer at this
4209 * stage.
4210 */
4211 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4213
4214 /* Mute capture amp left and right */
4215 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4216 /* Set ADC connection select to match default mixer setting - mic
4217 * (on mic1 pin)
4218 */
4219 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4220
4221 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004222 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004223 */
4224 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004225 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004226
4227 /* Mute all inputs to mixer widget (even unconnected ones) */
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4236
4237 { }
4238};
4239
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004240static struct hda_verb alc260_will_verbs[] = {
4241 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4242 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4243 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4244 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4245 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4246 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4247 {}
4248};
4249
4250static struct hda_verb alc260_replacer_672v_verbs[] = {
4251 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4252 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4253 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4254
4255 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4256 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4257 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4258
4259 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4260 {}
4261};
4262
4263/* toggle speaker-output according to the hp-jack state */
4264static void alc260_replacer_672v_automute(struct hda_codec *codec)
4265{
4266 unsigned int present;
4267
4268 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4269 present = snd_hda_codec_read(codec, 0x0f, 0,
4270 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4271 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004272 snd_hda_codec_write_cache(codec, 0x01, 0,
4273 AC_VERB_SET_GPIO_DATA, 1);
4274 snd_hda_codec_write_cache(codec, 0x0f, 0,
4275 AC_VERB_SET_PIN_WIDGET_CONTROL,
4276 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004277 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004278 snd_hda_codec_write_cache(codec, 0x01, 0,
4279 AC_VERB_SET_GPIO_DATA, 0);
4280 snd_hda_codec_write_cache(codec, 0x0f, 0,
4281 AC_VERB_SET_PIN_WIDGET_CONTROL,
4282 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004283 }
4284}
4285
4286static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4287 unsigned int res)
4288{
4289 if ((res >> 26) == ALC880_HP_EVENT)
4290 alc260_replacer_672v_automute(codec);
4291}
4292
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004293/* Test configuration for debugging, modelled after the ALC880 test
4294 * configuration.
4295 */
4296#ifdef CONFIG_SND_DEBUG
4297static hda_nid_t alc260_test_dac_nids[1] = {
4298 0x02,
4299};
4300static hda_nid_t alc260_test_adc_nids[2] = {
4301 0x04, 0x05,
4302};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004303/* For testing the ALC260, each input MUX needs its own definition since
4304 * the signal assignments are different. This assumes that the first ADC
4305 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004306 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004307static struct hda_input_mux alc260_test_capture_sources[2] = {
4308 {
4309 .num_items = 7,
4310 .items = {
4311 { "MIC1 pin", 0x0 },
4312 { "MIC2 pin", 0x1 },
4313 { "LINE1 pin", 0x2 },
4314 { "LINE2 pin", 0x3 },
4315 { "CD pin", 0x4 },
4316 { "LINE-OUT pin", 0x5 },
4317 { "HP-OUT pin", 0x6 },
4318 },
4319 },
4320 {
4321 .num_items = 8,
4322 .items = {
4323 { "MIC1 pin", 0x0 },
4324 { "MIC2 pin", 0x1 },
4325 { "LINE1 pin", 0x2 },
4326 { "LINE2 pin", 0x3 },
4327 { "CD pin", 0x4 },
4328 { "Mixer", 0x5 },
4329 { "LINE-OUT pin", 0x6 },
4330 { "HP-OUT pin", 0x7 },
4331 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004332 },
4333};
4334static struct snd_kcontrol_new alc260_test_mixer[] = {
4335 /* Output driver widgets */
4336 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4337 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4338 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4339 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4340 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4341 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4342
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004343 /* Modes for retasking pin widgets
4344 * Note: the ALC260 doesn't seem to act on requests to enable mic
4345 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4346 * mention this restriction. At this stage it's not clear whether
4347 * this behaviour is intentional or is a hardware bug in chip
4348 * revisions available at least up until early 2006. Therefore for
4349 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4350 * choices, but if it turns out that the lack of mic bias for these
4351 * NIDs is intentional we could change their modes from
4352 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4353 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004354 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4355 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4356 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4357 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4358 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4359 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4360
4361 /* Loopback mixer controls */
4362 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4363 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4364 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4365 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4366 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4367 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4368 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4369 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4370 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4371 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4372 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4373 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4374 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4375 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4376 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4377 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004378
4379 /* Controls for GPIO pins, assuming they are configured as outputs */
4380 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4381 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4382 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4383 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4384
Jonathan Woithe92621f12006-02-28 11:47:47 +01004385 /* Switches to allow the digital IO pins to be enabled. The datasheet
4386 * is ambigious as to which NID is which; testing on laptops which
4387 * make this output available should provide clarification.
4388 */
4389 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4390 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4391
Jonathan Woithef8225f62008-01-08 12:16:54 +01004392 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4393 * this output to turn on an external amplifier.
4394 */
4395 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4396 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4397
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004398 { } /* end */
4399};
4400static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004401 /* Enable all GPIOs as outputs with an initial value of 0 */
4402 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4403 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4404 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4405
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004406 /* Enable retasking pins as output, initially without power amp */
4407 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4408 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4411 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4412 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4413
Jonathan Woithe92621f12006-02-28 11:47:47 +01004414 /* Disable digital (SPDIF) pins initially, but users can enable
4415 * them via a mixer switch. In the case of SPDIF-out, this initverb
4416 * payload also sets the generation to 0, output to be in "consumer"
4417 * PCM format, copyright asserted, no pre-emphasis and no validity
4418 * control.
4419 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004420 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4421 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4422
Jonathan Woithef7ace402006-02-28 11:46:14 +01004423 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004424 * OUT1 sum bus when acting as an output.
4425 */
4426 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4427 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4428 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4429 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4430
4431 /* Start with output sum widgets muted and their output gains at min */
4432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4436 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4438 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4439 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4440 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4441
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004442 /* Unmute retasking pin widget output buffers since the default
4443 * state appears to be output. As the pin mode is changed by the
4444 * user the pin mode control will take care of enabling the pin's
4445 * input/output buffers as needed.
4446 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004447 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4448 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4451 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4452 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4453 /* Also unmute the mono-out pin widget */
4454 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4455
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004456 /* Mute capture amp left and right */
4457 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004458 /* Set ADC connection select to match default mixer setting (mic1
4459 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004460 */
4461 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4462
4463 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004464 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004465 */
4466 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4467 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4468
4469 /* Mute all inputs to mixer widget (even unconnected ones) */
4470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4478
4479 { }
4480};
4481#endif
4482
Linus Torvalds1da177e2005-04-16 15:20:36 -07004483static struct hda_pcm_stream alc260_pcm_analog_playback = {
4484 .substreams = 1,
4485 .channels_min = 2,
4486 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004487};
4488
4489static struct hda_pcm_stream alc260_pcm_analog_capture = {
4490 .substreams = 1,
4491 .channels_min = 2,
4492 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004493};
4494
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004495#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4496#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4497
Kailang Yangdf694da2005-12-05 19:42:22 +01004498/*
4499 * for BIOS auto-configuration
4500 */
4501
4502static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4503 const char *pfx)
4504{
4505 hda_nid_t nid_vol;
4506 unsigned long vol_val, sw_val;
4507 char name[32];
4508 int err;
4509
4510 if (nid >= 0x0f && nid < 0x11) {
4511 nid_vol = nid - 0x7;
4512 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4513 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4514 } else if (nid == 0x11) {
4515 nid_vol = nid - 0x7;
4516 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4517 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4518 } else if (nid >= 0x12 && nid <= 0x15) {
4519 nid_vol = 0x08;
4520 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4521 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4522 } else
4523 return 0; /* N/A */
4524
4525 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004526 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4527 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004528 return err;
4529 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004530 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4531 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004532 return err;
4533 return 1;
4534}
4535
4536/* add playback controls from the parsed DAC table */
4537static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4538 const struct auto_pin_cfg *cfg)
4539{
4540 hda_nid_t nid;
4541 int err;
4542
4543 spec->multiout.num_dacs = 1;
4544 spec->multiout.dac_nids = spec->private_dac_nids;
4545 spec->multiout.dac_nids[0] = 0x02;
4546
4547 nid = cfg->line_out_pins[0];
4548 if (nid) {
4549 err = alc260_add_playback_controls(spec, nid, "Front");
4550 if (err < 0)
4551 return err;
4552 }
4553
Takashi Iwai82bc9552006-03-21 11:24:42 +01004554 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004555 if (nid) {
4556 err = alc260_add_playback_controls(spec, nid, "Speaker");
4557 if (err < 0)
4558 return err;
4559 }
4560
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004561 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004562 if (nid) {
4563 err = alc260_add_playback_controls(spec, nid, "Headphone");
4564 if (err < 0)
4565 return err;
4566 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004567 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004568}
4569
4570/* create playback/capture controls for input pins */
4571static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4572 const struct auto_pin_cfg *cfg)
4573{
Kailang Yangdf694da2005-12-05 19:42:22 +01004574 struct hda_input_mux *imux = &spec->private_imux;
4575 int i, err, idx;
4576
4577 for (i = 0; i < AUTO_PIN_LAST; i++) {
4578 if (cfg->input_pins[i] >= 0x12) {
4579 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004580 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004581 auto_pin_cfg_labels[i], idx,
4582 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004583 if (err < 0)
4584 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585 imux->items[imux->num_items].label =
4586 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004587 imux->items[imux->num_items].index = idx;
4588 imux->num_items++;
4589 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004590 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004591 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004592 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004593 auto_pin_cfg_labels[i], idx,
4594 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004595 if (err < 0)
4596 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004597 imux->items[imux->num_items].label =
4598 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004599 imux->items[imux->num_items].index = idx;
4600 imux->num_items++;
4601 }
4602 }
4603 return 0;
4604}
4605
4606static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4607 hda_nid_t nid, int pin_type,
4608 int sel_idx)
4609{
4610 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004611 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4612 pin_type);
4613 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4614 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004615 /* need the manual connection? */
4616 if (nid >= 0x12) {
4617 int idx = nid - 0x12;
4618 snd_hda_codec_write(codec, idx + 0x0b, 0,
4619 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004620 }
4621}
4622
4623static void alc260_auto_init_multi_out(struct hda_codec *codec)
4624{
4625 struct alc_spec *spec = codec->spec;
4626 hda_nid_t nid;
4627
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004628 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004629 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004630 if (nid) {
4631 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4632 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4633 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004634
Takashi Iwai82bc9552006-03-21 11:24:42 +01004635 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004636 if (nid)
4637 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4638
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004639 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004640 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004641 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004642}
Kailang Yangdf694da2005-12-05 19:42:22 +01004643
4644#define ALC260_PIN_CD_NID 0x16
4645static void alc260_auto_init_analog_input(struct hda_codec *codec)
4646{
4647 struct alc_spec *spec = codec->spec;
4648 int i;
4649
4650 for (i = 0; i < AUTO_PIN_LAST; i++) {
4651 hda_nid_t nid = spec->autocfg.input_pins[i];
4652 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004653 snd_hda_codec_write(codec, nid, 0,
4654 AC_VERB_SET_PIN_WIDGET_CONTROL,
4655 i <= AUTO_PIN_FRONT_MIC ?
4656 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004658 snd_hda_codec_write(codec, nid, 0,
4659 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004660 AMP_OUT_MUTE);
4661 }
4662 }
4663}
4664
4665/*
4666 * generic initialization of ADC, input mixers and output mixers
4667 */
4668static struct hda_verb alc260_volume_init_verbs[] = {
4669 /*
4670 * Unmute ADC0-1 and set the default input to mic-in
4671 */
4672 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4673 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4674 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4676
4677 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4678 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004679 * Note: PASD motherboards uses the Line In 2 as the input for
4680 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004681 */
4682 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004683 /* mute analog inputs */
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004689
4690 /*
4691 * Set up output mixers (0x08 - 0x0a)
4692 */
4693 /* set vol=0 to output mixers */
4694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4696 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4697 /* set up input amps for analog loopback */
4698 /* Amp Indices: DAC = 0, mixer = 1 */
4699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4704 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4705
4706 { }
4707};
4708
4709static int alc260_parse_auto_config(struct hda_codec *codec)
4710{
4711 struct alc_spec *spec = codec->spec;
4712 unsigned int wcap;
4713 int err;
4714 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4715
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004716 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4717 alc260_ignore);
4718 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004719 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004720 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4721 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004722 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004723 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004724 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004725 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4726 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 return err;
4728
4729 spec->multiout.max_channels = 2;
4730
4731 if (spec->autocfg.dig_out_pin)
4732 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4733 if (spec->kctl_alloc)
4734 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4735
4736 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4737
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004738 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004739 spec->input_mux = &spec->private_imux;
4740
4741 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004742 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004743 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4744 if (wcap != AC_WID_AUD_IN) {
4745 spec->adc_nids = alc260_adc_nids_alt;
4746 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4747 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004748 } else {
4749 spec->adc_nids = alc260_adc_nids;
4750 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4751 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004752 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004753 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004754
4755 return 1;
4756}
4757
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004758/* additional initialization for auto-configuration model */
4759static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004760{
Kailang Yangdf694da2005-12-05 19:42:22 +01004761 alc260_auto_init_multi_out(codec);
4762 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004763}
4764
Takashi Iwaicb53c622007-08-10 17:21:45 +02004765#ifdef CONFIG_SND_HDA_POWER_SAVE
4766static struct hda_amp_list alc260_loopbacks[] = {
4767 { 0x07, HDA_INPUT, 0 },
4768 { 0x07, HDA_INPUT, 1 },
4769 { 0x07, HDA_INPUT, 2 },
4770 { 0x07, HDA_INPUT, 3 },
4771 { 0x07, HDA_INPUT, 4 },
4772 { } /* end */
4773};
4774#endif
4775
Kailang Yangdf694da2005-12-05 19:42:22 +01004776/*
4777 * ALC260 configurations
4778 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004779static const char *alc260_models[ALC260_MODEL_LAST] = {
4780 [ALC260_BASIC] = "basic",
4781 [ALC260_HP] = "hp",
4782 [ALC260_HP_3013] = "hp-3013",
4783 [ALC260_FUJITSU_S702X] = "fujitsu",
4784 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004785 [ALC260_WILL] = "will",
4786 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004787#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004788 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004789#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004790 [ALC260_AUTO] = "auto",
4791};
4792
4793static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004794 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004795 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004796 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004797 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004798 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4799 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4800 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4801 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4802 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4803 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4804 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4805 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4806 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4807 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4808 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4809 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004810 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004811 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 {}
4813};
4814
Kailang Yangdf694da2005-12-05 19:42:22 +01004815static struct alc_config_preset alc260_presets[] = {
4816 [ALC260_BASIC] = {
4817 .mixers = { alc260_base_output_mixer,
4818 alc260_input_mixer,
4819 alc260_pc_beep_mixer,
4820 alc260_capture_mixer },
4821 .init_verbs = { alc260_init_verbs },
4822 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4823 .dac_nids = alc260_dac_nids,
4824 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4825 .adc_nids = alc260_adc_nids,
4826 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4827 .channel_mode = alc260_modes,
4828 .input_mux = &alc260_capture_source,
4829 },
4830 [ALC260_HP] = {
4831 .mixers = { alc260_base_output_mixer,
4832 alc260_input_mixer,
4833 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004834 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004835 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4836 .dac_nids = alc260_dac_nids,
4837 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4838 .adc_nids = alc260_hp_adc_nids,
4839 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4840 .channel_mode = alc260_modes,
4841 .input_mux = &alc260_capture_source,
4842 },
4843 [ALC260_HP_3013] = {
4844 .mixers = { alc260_hp_3013_mixer,
4845 alc260_input_mixer,
4846 alc260_capture_alt_mixer },
4847 .init_verbs = { alc260_hp_3013_init_verbs },
4848 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4849 .dac_nids = alc260_dac_nids,
4850 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4851 .adc_nids = alc260_hp_adc_nids,
4852 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4853 .channel_mode = alc260_modes,
4854 .input_mux = &alc260_capture_source,
4855 },
4856 [ALC260_FUJITSU_S702X] = {
4857 .mixers = { alc260_fujitsu_mixer,
4858 alc260_capture_mixer },
4859 .init_verbs = { alc260_fujitsu_init_verbs },
4860 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4861 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004862 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4863 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004864 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4865 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004866 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4867 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004868 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004869 [ALC260_ACER] = {
4870 .mixers = { alc260_acer_mixer,
4871 alc260_capture_mixer },
4872 .init_verbs = { alc260_acer_init_verbs },
4873 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4874 .dac_nids = alc260_dac_nids,
4875 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4876 .adc_nids = alc260_dual_adc_nids,
4877 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4878 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004879 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4880 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004881 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004882 [ALC260_WILL] = {
4883 .mixers = { alc260_will_mixer,
4884 alc260_capture_mixer },
4885 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4886 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4887 .dac_nids = alc260_dac_nids,
4888 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4889 .adc_nids = alc260_adc_nids,
4890 .dig_out_nid = ALC260_DIGOUT_NID,
4891 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4892 .channel_mode = alc260_modes,
4893 .input_mux = &alc260_capture_source,
4894 },
4895 [ALC260_REPLACER_672V] = {
4896 .mixers = { alc260_replacer_672v_mixer,
4897 alc260_capture_mixer },
4898 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4899 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4900 .dac_nids = alc260_dac_nids,
4901 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4902 .adc_nids = alc260_adc_nids,
4903 .dig_out_nid = ALC260_DIGOUT_NID,
4904 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4905 .channel_mode = alc260_modes,
4906 .input_mux = &alc260_capture_source,
4907 .unsol_event = alc260_replacer_672v_unsol_event,
4908 .init_hook = alc260_replacer_672v_automute,
4909 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004910#ifdef CONFIG_SND_DEBUG
4911 [ALC260_TEST] = {
4912 .mixers = { alc260_test_mixer,
4913 alc260_capture_mixer },
4914 .init_verbs = { alc260_test_init_verbs },
4915 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4916 .dac_nids = alc260_test_dac_nids,
4917 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4918 .adc_nids = alc260_test_adc_nids,
4919 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4920 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004921 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4922 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004923 },
4924#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004925};
4926
Linus Torvalds1da177e2005-04-16 15:20:36 -07004927static int patch_alc260(struct hda_codec *codec)
4928{
4929 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004930 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004931
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004932 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004933 if (spec == NULL)
4934 return -ENOMEM;
4935
4936 codec->spec = spec;
4937
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004938 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4939 alc260_models,
4940 alc260_cfg_tbl);
4941 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004942 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4943 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004944 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004945 }
4946
Kailang Yangdf694da2005-12-05 19:42:22 +01004947 if (board_config == ALC260_AUTO) {
4948 /* automatic parse from the BIOS config */
4949 err = alc260_parse_auto_config(codec);
4950 if (err < 0) {
4951 alc_free(codec);
4952 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004953 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004954 printk(KERN_INFO
4955 "hda_codec: Cannot set up configuration "
4956 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004957 board_config = ALC260_BASIC;
4958 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004959 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004960
Kailang Yangdf694da2005-12-05 19:42:22 +01004961 if (board_config != ALC260_AUTO)
4962 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004963
4964 spec->stream_name_analog = "ALC260 Analog";
4965 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4966 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4967
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004968 spec->stream_name_digital = "ALC260 Digital";
4969 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4970 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4971
Linus Torvalds1da177e2005-04-16 15:20:36 -07004972 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004973 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004974 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004975#ifdef CONFIG_SND_HDA_POWER_SAVE
4976 if (!spec->loopback.amplist)
4977 spec->loopback.amplist = alc260_loopbacks;
4978#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004979
4980 return 0;
4981}
4982
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004983
Linus Torvalds1da177e2005-04-16 15:20:36 -07004984/*
4985 * ALC882 support
4986 *
4987 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4988 * configuration. Each pin widget can choose any input DACs and a mixer.
4989 * Each ADC is connected from a mixer of all inputs. This makes possible
4990 * 6-channel independent captures.
4991 *
4992 * In addition, an independent DAC for the multi-playback (not used in this
4993 * driver yet).
4994 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004995#define ALC882_DIGOUT_NID 0x06
4996#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004998static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004999 { 8, NULL }
5000};
5001
5002static hda_nid_t alc882_dac_nids[4] = {
5003 /* front, rear, clfe, rear_surr */
5004 0x02, 0x03, 0x04, 0x05
5005};
5006
Kailang Yangdf694da2005-12-05 19:42:22 +01005007/* identical with ALC880 */
5008#define alc882_adc_nids alc880_adc_nids
5009#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005010
5011/* input MUX */
5012/* FIXME: should be a matrix-type input source selection */
5013
5014static struct hda_input_mux alc882_capture_source = {
5015 .num_items = 4,
5016 .items = {
5017 { "Mic", 0x0 },
5018 { "Front Mic", 0x1 },
5019 { "Line", 0x2 },
5020 { "CD", 0x4 },
5021 },
5022};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005023#define alc882_mux_enum_info alc_mux_enum_info
5024#define alc882_mux_enum_get alc_mux_enum_get
5025
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005026static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5027 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005028{
5029 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5030 struct alc_spec *spec = codec->spec;
5031 const struct hda_input_mux *imux = spec->input_mux;
5032 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5033 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5034 hda_nid_t nid = capture_mixers[adc_idx];
5035 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5036 unsigned int i, idx;
5037
5038 idx = ucontrol->value.enumerated.item[0];
5039 if (idx >= imux->num_items)
5040 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005041 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005042 return 0;
5043 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005044 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5045 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005046 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005047 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005048 }
5049 *cur_val = idx;
5050 return 1;
5051}
5052
Kailang Yangdf694da2005-12-05 19:42:22 +01005053/*
Kailang Yang272a5272007-05-14 11:00:38 +02005054 * 2ch mode
5055 */
5056static struct hda_verb alc882_3ST_ch2_init[] = {
5057 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5058 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5059 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5060 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5061 { } /* end */
5062};
5063
5064/*
5065 * 6ch mode
5066 */
5067static struct hda_verb alc882_3ST_ch6_init[] = {
5068 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5069 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5070 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5071 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5072 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5073 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5074 { } /* end */
5075};
5076
5077static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5078 { 2, alc882_3ST_ch2_init },
5079 { 6, alc882_3ST_ch6_init },
5080};
5081
5082/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005083 * 6ch mode
5084 */
5085static struct hda_verb alc882_sixstack_ch6_init[] = {
5086 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5087 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5088 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5089 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5090 { } /* end */
5091};
5092
5093/*
5094 * 8ch mode
5095 */
5096static struct hda_verb alc882_sixstack_ch8_init[] = {
5097 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5098 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5099 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5100 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5101 { } /* end */
5102};
5103
5104static struct hda_channel_mode alc882_sixstack_modes[2] = {
5105 { 6, alc882_sixstack_ch6_init },
5106 { 8, alc882_sixstack_ch8_init },
5107};
5108
Takashi Iwai87350ad2007-08-16 18:19:38 +02005109/*
5110 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5111 */
5112
5113/*
5114 * 2ch mode
5115 */
5116static struct hda_verb alc885_mbp_ch2_init[] = {
5117 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5118 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5119 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5120 { } /* end */
5121};
5122
5123/*
5124 * 6ch mode
5125 */
5126static struct hda_verb alc885_mbp_ch6_init[] = {
5127 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5128 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5129 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5130 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5131 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5132 { } /* end */
5133};
5134
5135static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5136 { 2, alc885_mbp_ch2_init },
5137 { 6, alc885_mbp_ch6_init },
5138};
5139
5140
Linus Torvalds1da177e2005-04-16 15:20:36 -07005141/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5142 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5143 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005144static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005146 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005147 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005148 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005153 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005154 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5156 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5157 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5158 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5159 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005161 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5163 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005164 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005168 { } /* end */
5169};
5170
Takashi Iwai87350ad2007-08-16 18:19:38 +02005171static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5172 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
5173 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
5174 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
5175 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
5176 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
5177 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
5178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5179 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5180 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
5181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5182 { } /* end */
5183};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005184static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5189 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5190 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5192 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5194 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5195 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5196 { } /* end */
5197};
5198
Kailang Yang272a5272007-05-14 11:00:38 +02005199static struct snd_kcontrol_new alc882_targa_mixer[] = {
5200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5203 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5204 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005209 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005210 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5211 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005212 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005213 { } /* end */
5214};
5215
5216/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5217 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5218 */
5219static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5221 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5223 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5224 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5225 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5228 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5229 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005232 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005233 { } /* end */
5234};
5235
Takashi Iwai914759b2007-09-06 14:52:04 +02005236static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5238 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5247 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5248 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5249 { } /* end */
5250};
5251
Kailang Yangdf694da2005-12-05 19:42:22 +01005252static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5253 {
5254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5255 .name = "Channel Mode",
5256 .info = alc_ch_mode_info,
5257 .get = alc_ch_mode_get,
5258 .put = alc_ch_mode_put,
5259 },
5260 { } /* end */
5261};
5262
Linus Torvalds1da177e2005-04-16 15:20:36 -07005263static struct hda_verb alc882_init_verbs[] = {
5264 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005268 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5271 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005272 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5274 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005276 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005281 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005284 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005285 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005289 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005292 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005293 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005294 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005296 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005297 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005299 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5300 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5303 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5306 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5309 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005311 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312
5313 /* FIXME: use matrix-type input source selection */
5314 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5315 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005325 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5330 /* ADC1: mute amp left and right */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005332 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005333 /* ADC2: mute amp left and right */
5334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005335 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005336 /* ADC3: mute amp left and right */
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005338 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005339
5340 { }
5341};
5342
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005343static struct hda_verb alc882_eapd_verbs[] = {
5344 /* change to EAPD mode */
5345 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005346 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005347 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005348};
5349
Tobin Davis9102cd12006-12-15 10:02:12 +01005350/* Mac Pro test */
5351static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5353 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5357 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5358 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5359 { } /* end */
5360};
5361
5362static struct hda_verb alc882_macpro_init_verbs[] = {
5363 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5367 /* Front Pin: output 0 (0x0c) */
5368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5371 /* Front Mic pin: input vref at 80% */
5372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5374 /* Speaker: output */
5375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5377 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5378 /* Headphone output (output 0 - 0x0c) */
5379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5381 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5382
5383 /* FIXME: use matrix-type input source selection */
5384 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5385 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5390 /* Input mixer2 */
5391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5395 /* Input mixer3 */
5396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5400 /* ADC1: mute amp left and right */
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5402 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5403 /* ADC2: mute amp left and right */
5404 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5405 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5406 /* ADC3: mute amp left and right */
5407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5408 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5409
5410 { }
5411};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005412
Takashi Iwai87350ad2007-08-16 18:19:38 +02005413/* Macbook Pro rev3 */
5414static struct hda_verb alc885_mbp3_init_verbs[] = {
5415 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5419 /* Rear mixer */
5420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5423 /* Front Pin: output 0 (0x0c) */
5424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5425 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5426 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5427 /* HP Pin: output 0 (0x0d) */
5428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5431 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5432 /* Mic (rear) pin: input vref at 80% */
5433 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5434 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5435 /* Front Mic pin: input vref at 80% */
5436 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5437 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5438 /* Line In pin: use output 1 when in LineOut mode */
5439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5441 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5442
5443 /* FIXME: use matrix-type input source selection */
5444 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5445 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5450 /* Input mixer2 */
5451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5455 /* Input mixer3 */
5456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5460 /* ADC1: mute amp left and right */
5461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5463 /* ADC2: mute amp left and right */
5464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5465 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5466 /* ADC3: mute amp left and right */
5467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5468 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5469
5470 { }
5471};
5472
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005473/* iMac 24 mixer. */
5474static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5475 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5476 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5477 { } /* end */
5478};
5479
5480/* iMac 24 init verbs. */
5481static struct hda_verb alc885_imac24_init_verbs[] = {
5482 /* Internal speakers: output 0 (0x0c) */
5483 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5484 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5485 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5486 /* Internal speakers: output 0 (0x0c) */
5487 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5489 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5490 /* Headphone: output 0 (0x0c) */
5491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5493 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5494 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5495 /* Front Mic: input vref at 80% */
5496 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5498 { }
5499};
5500
5501/* Toggle speaker-output according to the hp-jack state */
5502static void alc885_imac24_automute(struct hda_codec *codec)
5503{
5504 unsigned int present;
5505
5506 present = snd_hda_codec_read(codec, 0x14, 0,
5507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005508 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5509 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5510 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5511 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005512}
5513
5514/* Processes unsolicited events. */
5515static void alc885_imac24_unsol_event(struct hda_codec *codec,
5516 unsigned int res)
5517{
5518 /* Headphone insertion or removal. */
5519 if ((res >> 26) == ALC880_HP_EVENT)
5520 alc885_imac24_automute(codec);
5521}
5522
Takashi Iwai87350ad2007-08-16 18:19:38 +02005523static void alc885_mbp3_automute(struct hda_codec *codec)
5524{
5525 unsigned int present;
5526
5527 present = snd_hda_codec_read(codec, 0x15, 0,
5528 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5529 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5530 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5531 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5532 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5533
5534}
5535static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5536 unsigned int res)
5537{
5538 /* Headphone insertion or removal. */
5539 if ((res >> 26) == ALC880_HP_EVENT)
5540 alc885_mbp3_automute(codec);
5541}
5542
5543
Kailang Yang272a5272007-05-14 11:00:38 +02005544static struct hda_verb alc882_targa_verbs[] = {
5545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5547
5548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5550
5551 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5552 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5554
5555 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5556 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5557 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5558 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5559 { } /* end */
5560};
5561
5562/* toggle speaker-output according to the hp-jack state */
5563static void alc882_targa_automute(struct hda_codec *codec)
5564{
5565 unsigned int present;
5566
5567 present = snd_hda_codec_read(codec, 0x14, 0,
5568 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005569 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5570 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005571 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5572 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005573}
5574
5575static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5576{
5577 /* Looks like the unsol event is incompatible with the standard
5578 * definition. 4bit tag is placed at 26 bit!
5579 */
5580 if (((res >> 26) == ALC880_HP_EVENT)) {
5581 alc882_targa_automute(codec);
5582 }
5583}
5584
5585static struct hda_verb alc882_asus_a7j_verbs[] = {
5586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5588
5589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5591 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5592
5593 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5595 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5596
5597 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5598 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5599 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5600 { } /* end */
5601};
5602
Takashi Iwai914759b2007-09-06 14:52:04 +02005603static struct hda_verb alc882_asus_a7m_verbs[] = {
5604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5605 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5606
5607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5610
5611 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5612 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5613 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5614
5615 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5616 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5617 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5618 { } /* end */
5619};
5620
Tobin Davis9102cd12006-12-15 10:02:12 +01005621static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5622{
5623 unsigned int gpiostate, gpiomask, gpiodir;
5624
5625 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5626 AC_VERB_GET_GPIO_DATA, 0);
5627
5628 if (!muted)
5629 gpiostate |= (1 << pin);
5630 else
5631 gpiostate &= ~(1 << pin);
5632
5633 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5634 AC_VERB_GET_GPIO_MASK, 0);
5635 gpiomask |= (1 << pin);
5636
5637 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5638 AC_VERB_GET_GPIO_DIRECTION, 0);
5639 gpiodir |= (1 << pin);
5640
5641
5642 snd_hda_codec_write(codec, codec->afg, 0,
5643 AC_VERB_SET_GPIO_MASK, gpiomask);
5644 snd_hda_codec_write(codec, codec->afg, 0,
5645 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5646
5647 msleep(1);
5648
5649 snd_hda_codec_write(codec, codec->afg, 0,
5650 AC_VERB_SET_GPIO_DATA, gpiostate);
5651}
5652
Takashi Iwai7debbe52007-08-16 15:01:03 +02005653/* set up GPIO at initialization */
5654static void alc885_macpro_init_hook(struct hda_codec *codec)
5655{
5656 alc882_gpio_mute(codec, 0, 0);
5657 alc882_gpio_mute(codec, 1, 0);
5658}
5659
5660/* set up GPIO and update auto-muting at initialization */
5661static void alc885_imac24_init_hook(struct hda_codec *codec)
5662{
5663 alc885_macpro_init_hook(codec);
5664 alc885_imac24_automute(codec);
5665}
5666
Kailang Yangdf694da2005-12-05 19:42:22 +01005667/*
5668 * generic initialization of ADC, input mixers and output mixers
5669 */
5670static struct hda_verb alc882_auto_init_verbs[] = {
5671 /*
5672 * Unmute ADC0-2 and set the default input to mic-in
5673 */
5674 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5678 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5680
Takashi Iwaicb53c622007-08-10 17:21:45 +02005681 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005683 * Note: PASD motherboards uses the Line In 2 as the input for
5684 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005685 */
5686 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005692
5693 /*
5694 * Set up output mixers (0x0c - 0x0f)
5695 */
5696 /* set vol=0 to output mixers */
5697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5699 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5700 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5701 /* set up input amps for analog loopback */
5702 /* Amp Indices: DAC = 0, mixer = 1 */
5703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5710 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5711 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5712 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5713
5714 /* FIXME: use matrix-type input source selection */
5715 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5716 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5721 /* Input mixer2 */
5722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5726 /* Input mixer3 */
5727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5731
5732 { }
5733};
5734
5735/* capture mixer elements */
5736static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5737 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5738 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5739 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5740 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5741 {
5742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5743 /* The multiple "Capture Source" controls confuse alsamixer
5744 * So call somewhat different..
5745 * FIXME: the controls appear in the "playback" view!
5746 */
5747 /* .name = "Capture Source", */
5748 .name = "Input Source",
5749 .count = 2,
5750 .info = alc882_mux_enum_info,
5751 .get = alc882_mux_enum_get,
5752 .put = alc882_mux_enum_put,
5753 },
5754 { } /* end */
5755};
5756
5757static struct snd_kcontrol_new alc882_capture_mixer[] = {
5758 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5759 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5760 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5761 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5762 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5763 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5764 {
5765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5766 /* The multiple "Capture Source" controls confuse alsamixer
5767 * So call somewhat different..
5768 * FIXME: the controls appear in the "playback" view!
5769 */
5770 /* .name = "Capture Source", */
5771 .name = "Input Source",
5772 .count = 3,
5773 .info = alc882_mux_enum_info,
5774 .get = alc882_mux_enum_get,
5775 .put = alc882_mux_enum_put,
5776 },
5777 { } /* end */
5778};
5779
Takashi Iwaicb53c622007-08-10 17:21:45 +02005780#ifdef CONFIG_SND_HDA_POWER_SAVE
5781#define alc882_loopbacks alc880_loopbacks
5782#endif
5783
Kailang Yangdf694da2005-12-05 19:42:22 +01005784/* pcm configuration: identiacal with ALC880 */
5785#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5786#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5787#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5788#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5789
5790/*
5791 * configuration and preset
5792 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005793static const char *alc882_models[ALC882_MODEL_LAST] = {
5794 [ALC882_3ST_DIG] = "3stack-dig",
5795 [ALC882_6ST_DIG] = "6stack-dig",
5796 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005797 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005798 [ALC882_TARGA] = "targa",
5799 [ALC882_ASUS_A7J] = "asus-a7j",
5800 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005801 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005802 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005803 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005804 [ALC882_AUTO] = "auto",
5805};
5806
5807static struct snd_pci_quirk alc882_cfg_tbl[] = {
5808 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005809 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005810 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005811 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005812 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005813 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005814 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005815 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5816 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5817 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5818 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01005819 {}
5820};
5821
5822static struct alc_config_preset alc882_presets[] = {
5823 [ALC882_3ST_DIG] = {
5824 .mixers = { alc882_base_mixer },
5825 .init_verbs = { alc882_init_verbs },
5826 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5827 .dac_nids = alc882_dac_nids,
5828 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005829 .dig_in_nid = ALC882_DIGIN_NID,
5830 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5831 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005832 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005833 .input_mux = &alc882_capture_source,
5834 },
5835 [ALC882_6ST_DIG] = {
5836 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5837 .init_verbs = { alc882_init_verbs },
5838 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5839 .dac_nids = alc882_dac_nids,
5840 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005841 .dig_in_nid = ALC882_DIGIN_NID,
5842 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5843 .channel_mode = alc882_sixstack_modes,
5844 .input_mux = &alc882_capture_source,
5845 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005846 [ALC882_ARIMA] = {
5847 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5848 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5849 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5850 .dac_nids = alc882_dac_nids,
5851 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5852 .channel_mode = alc882_sixstack_modes,
5853 .input_mux = &alc882_capture_source,
5854 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005855 [ALC882_W2JC] = {
5856 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5857 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5858 alc880_gpio1_init_verbs },
5859 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5860 .dac_nids = alc882_dac_nids,
5861 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5862 .channel_mode = alc880_threestack_modes,
5863 .need_dac_fix = 1,
5864 .input_mux = &alc882_capture_source,
5865 .dig_out_nid = ALC882_DIGOUT_NID,
5866 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005867 [ALC885_MBP3] = {
5868 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5869 .init_verbs = { alc885_mbp3_init_verbs,
5870 alc880_gpio1_init_verbs },
5871 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5872 .dac_nids = alc882_dac_nids,
5873 .channel_mode = alc885_mbp_6ch_modes,
5874 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5875 .input_mux = &alc882_capture_source,
5876 .dig_out_nid = ALC882_DIGOUT_NID,
5877 .dig_in_nid = ALC882_DIGIN_NID,
5878 .unsol_event = alc885_mbp3_unsol_event,
5879 .init_hook = alc885_mbp3_automute,
5880 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005881 [ALC885_MACPRO] = {
5882 .mixers = { alc882_macpro_mixer },
5883 .init_verbs = { alc882_macpro_init_verbs },
5884 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5885 .dac_nids = alc882_dac_nids,
5886 .dig_out_nid = ALC882_DIGOUT_NID,
5887 .dig_in_nid = ALC882_DIGIN_NID,
5888 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5889 .channel_mode = alc882_ch_modes,
5890 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005891 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005892 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005893 [ALC885_IMAC24] = {
5894 .mixers = { alc885_imac24_mixer },
5895 .init_verbs = { alc885_imac24_init_verbs },
5896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5897 .dac_nids = alc882_dac_nids,
5898 .dig_out_nid = ALC882_DIGOUT_NID,
5899 .dig_in_nid = ALC882_DIGIN_NID,
5900 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5901 .channel_mode = alc882_ch_modes,
5902 .input_mux = &alc882_capture_source,
5903 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005904 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005905 },
Kailang Yang272a5272007-05-14 11:00:38 +02005906 [ALC882_TARGA] = {
5907 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5908 alc882_capture_mixer },
5909 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5910 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5911 .dac_nids = alc882_dac_nids,
5912 .dig_out_nid = ALC882_DIGOUT_NID,
5913 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5914 .adc_nids = alc882_adc_nids,
5915 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5916 .channel_mode = alc882_3ST_6ch_modes,
5917 .need_dac_fix = 1,
5918 .input_mux = &alc882_capture_source,
5919 .unsol_event = alc882_targa_unsol_event,
5920 .init_hook = alc882_targa_automute,
5921 },
5922 [ALC882_ASUS_A7J] = {
5923 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5924 alc882_capture_mixer },
5925 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5926 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5927 .dac_nids = alc882_dac_nids,
5928 .dig_out_nid = ALC882_DIGOUT_NID,
5929 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5930 .adc_nids = alc882_adc_nids,
5931 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5932 .channel_mode = alc882_3ST_6ch_modes,
5933 .need_dac_fix = 1,
5934 .input_mux = &alc882_capture_source,
5935 },
Takashi Iwai914759b2007-09-06 14:52:04 +02005936 [ALC882_ASUS_A7M] = {
5937 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5938 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5939 alc880_gpio1_init_verbs,
5940 alc882_asus_a7m_verbs },
5941 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5942 .dac_nids = alc882_dac_nids,
5943 .dig_out_nid = ALC882_DIGOUT_NID,
5944 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5945 .channel_mode = alc880_threestack_modes,
5946 .need_dac_fix = 1,
5947 .input_mux = &alc882_capture_source,
5948 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005949};
5950
5951
5952/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005953 * Pin config fixes
5954 */
5955enum {
5956 PINFIX_ABIT_AW9D_MAX
5957};
5958
5959static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5960 { 0x15, 0x01080104 }, /* side */
5961 { 0x16, 0x01011012 }, /* rear */
5962 { 0x17, 0x01016011 }, /* clfe */
5963 { }
5964};
5965
5966static const struct alc_pincfg *alc882_pin_fixes[] = {
5967 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5968};
5969
5970static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5971 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5972 {}
5973};
5974
5975/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005976 * BIOS auto configuration
5977 */
5978static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5979 hda_nid_t nid, int pin_type,
5980 int dac_idx)
5981{
5982 /* set as output */
5983 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005984 int idx;
5985
Kailang Yangdf694da2005-12-05 19:42:22 +01005986 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5987 idx = 4;
5988 else
5989 idx = spec->multiout.dac_nids[dac_idx] - 2;
5990
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005991 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5992 pin_type);
5993 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5994 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005995 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5996
5997}
5998
5999static void alc882_auto_init_multi_out(struct hda_codec *codec)
6000{
6001 struct alc_spec *spec = codec->spec;
6002 int i;
6003
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006004 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006005 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006006 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006007 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006008 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006009 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006010 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006011 }
6012}
6013
6014static void alc882_auto_init_hp_out(struct hda_codec *codec)
6015{
6016 struct alc_spec *spec = codec->spec;
6017 hda_nid_t pin;
6018
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006019 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006020 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006021 /* use dac 0 */
6022 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006023}
6024
6025#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6026#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6027
6028static void alc882_auto_init_analog_input(struct hda_codec *codec)
6029{
6030 struct alc_spec *spec = codec->spec;
6031 int i;
6032
6033 for (i = 0; i < AUTO_PIN_LAST; i++) {
6034 hda_nid_t nid = spec->autocfg.input_pins[i];
6035 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006036 snd_hda_codec_write(codec, nid, 0,
6037 AC_VERB_SET_PIN_WIDGET_CONTROL,
6038 i <= AUTO_PIN_FRONT_MIC ?
6039 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006040 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006041 snd_hda_codec_write(codec, nid, 0,
6042 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006043 AMP_OUT_MUTE);
6044 }
6045 }
6046}
6047
Takashi Iwai776e1842007-08-29 15:07:11 +02006048/* add mic boosts if needed */
6049static int alc_auto_add_mic_boost(struct hda_codec *codec)
6050{
6051 struct alc_spec *spec = codec->spec;
6052 int err;
6053 hda_nid_t nid;
6054
6055 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6056 if (nid) {
6057 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6058 "Mic Boost",
6059 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6060 if (err < 0)
6061 return err;
6062 }
6063 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6064 if (nid) {
6065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6066 "Front Mic Boost",
6067 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6068 if (err < 0)
6069 return err;
6070 }
6071 return 0;
6072}
6073
Kailang Yangdf694da2005-12-05 19:42:22 +01006074/* almost identical with ALC880 parser... */
6075static int alc882_parse_auto_config(struct hda_codec *codec)
6076{
6077 struct alc_spec *spec = codec->spec;
6078 int err = alc880_parse_auto_config(codec);
6079
6080 if (err < 0)
6081 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006082 else if (!err)
6083 return 0; /* no config found */
6084
6085 err = alc_auto_add_mic_boost(codec);
6086 if (err < 0)
6087 return err;
6088
6089 /* hack - override the init verbs */
6090 spec->init_verbs[0] = alc882_auto_init_verbs;
6091
6092 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006093}
6094
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006095/* additional initialization for auto-configuration model */
6096static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006097{
Kailang Yangdf694da2005-12-05 19:42:22 +01006098 alc882_auto_init_multi_out(codec);
6099 alc882_auto_init_hp_out(codec);
6100 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006101}
6102
Linus Torvalds1da177e2005-04-16 15:20:36 -07006103static int patch_alc882(struct hda_codec *codec)
6104{
6105 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006106 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006107
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006108 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006109 if (spec == NULL)
6110 return -ENOMEM;
6111
Linus Torvalds1da177e2005-04-16 15:20:36 -07006112 codec->spec = spec;
6113
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006114 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6115 alc882_models,
6116 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006117
Kailang Yangdf694da2005-12-05 19:42:22 +01006118 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006119 /* Pick up systems that don't supply PCI SSID */
6120 switch (codec->subsystem_id) {
6121 case 0x106b0c00: /* Mac Pro */
6122 board_config = ALC885_MACPRO;
6123 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006124 case 0x106b1000: /* iMac 24 */
6125 board_config = ALC885_IMAC24;
6126 break;
Takashi Iwai87350ad2007-08-16 18:19:38 +02006127 case 0x106b2c00: /* Macbook Pro rev3 */
6128 board_config = ALC885_MBP3;
6129 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006130 default:
6131 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6132 "trying auto-probe from BIOS...\n");
6133 board_config = ALC882_AUTO;
6134 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006135 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006136
Takashi Iwaif95474e2007-07-10 00:47:43 +02006137 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6138
Kailang Yangdf694da2005-12-05 19:42:22 +01006139 if (board_config == ALC882_AUTO) {
6140 /* automatic parse from the BIOS config */
6141 err = alc882_parse_auto_config(codec);
6142 if (err < 0) {
6143 alc_free(codec);
6144 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006145 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006146 printk(KERN_INFO
6147 "hda_codec: Cannot set up configuration "
6148 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006149 board_config = ALC882_3ST_DIG;
6150 }
6151 }
6152
6153 if (board_config != ALC882_AUTO)
6154 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006155
6156 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006157 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6158 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006159
6160 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006161 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6162 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006163
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006164 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006165 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006166 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006167 /* get type */
6168 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 if (wcap != AC_WID_AUD_IN) {
6170 spec->adc_nids = alc882_adc_nids_alt;
6171 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006172 spec->mixers[spec->num_mixers] =
6173 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006174 spec->num_mixers++;
6175 } else {
6176 spec->adc_nids = alc882_adc_nids;
6177 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6178 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6179 spec->num_mixers++;
6180 }
6181 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006182
6183 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006184 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006185 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006186#ifdef CONFIG_SND_HDA_POWER_SAVE
6187 if (!spec->loopback.amplist)
6188 spec->loopback.amplist = alc882_loopbacks;
6189#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006190
6191 return 0;
6192}
6193
6194/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006195 * ALC883 support
6196 *
6197 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6198 * configuration. Each pin widget can choose any input DACs and a mixer.
6199 * Each ADC is connected from a mixer of all inputs. This makes possible
6200 * 6-channel independent captures.
6201 *
6202 * In addition, an independent DAC for the multi-playback (not used in this
6203 * driver yet).
6204 */
6205#define ALC883_DIGOUT_NID 0x06
6206#define ALC883_DIGIN_NID 0x0a
6207
6208static hda_nid_t alc883_dac_nids[4] = {
6209 /* front, rear, clfe, rear_surr */
6210 0x02, 0x04, 0x03, 0x05
6211};
6212
6213static hda_nid_t alc883_adc_nids[2] = {
6214 /* ADC1-2 */
6215 0x08, 0x09,
6216};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006217
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006218/* input MUX */
6219/* FIXME: should be a matrix-type input source selection */
6220
6221static struct hda_input_mux alc883_capture_source = {
6222 .num_items = 4,
6223 .items = {
6224 { "Mic", 0x0 },
6225 { "Front Mic", 0x1 },
6226 { "Line", 0x2 },
6227 { "CD", 0x4 },
6228 },
6229};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006230
6231static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6232 .num_items = 2,
6233 .items = {
6234 { "Mic", 0x1 },
6235 { "Line", 0x2 },
6236 },
6237};
6238
Kailang Yang272a5272007-05-14 11:00:38 +02006239static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6240 .num_items = 4,
6241 .items = {
6242 { "Mic", 0x0 },
6243 { "iMic", 0x1 },
6244 { "Line", 0x2 },
6245 { "CD", 0x4 },
6246 },
6247};
6248
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006249#define alc883_mux_enum_info alc_mux_enum_info
6250#define alc883_mux_enum_get alc_mux_enum_get
6251
6252static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6253 struct snd_ctl_elem_value *ucontrol)
6254{
6255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6256 struct alc_spec *spec = codec->spec;
6257 const struct hda_input_mux *imux = spec->input_mux;
6258 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6259 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6260 hda_nid_t nid = capture_mixers[adc_idx];
6261 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6262 unsigned int i, idx;
6263
6264 idx = ucontrol->value.enumerated.item[0];
6265 if (idx >= imux->num_items)
6266 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006267 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006268 return 0;
6269 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006270 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6271 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006272 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006273 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006274 }
6275 *cur_val = idx;
6276 return 1;
6277}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006278
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006279/*
6280 * 2ch mode
6281 */
6282static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6283 { 2, NULL }
6284};
6285
6286/*
6287 * 2ch mode
6288 */
6289static struct hda_verb alc883_3ST_ch2_init[] = {
6290 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6291 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6292 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6293 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6294 { } /* end */
6295};
6296
6297/*
Tobin Davisb2011312007-09-17 12:45:11 +02006298 * 4ch mode
6299 */
6300static struct hda_verb alc883_3ST_ch4_init[] = {
6301 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6302 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6303 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6304 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6305 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6306 { } /* end */
6307};
6308
6309/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006310 * 6ch mode
6311 */
6312static struct hda_verb alc883_3ST_ch6_init[] = {
6313 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6314 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6315 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6316 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6317 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6318 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6319 { } /* end */
6320};
6321
Tobin Davisb2011312007-09-17 12:45:11 +02006322static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006323 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006324 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006325 { 6, alc883_3ST_ch6_init },
6326};
6327
6328/*
6329 * 6ch mode
6330 */
6331static struct hda_verb alc883_sixstack_ch6_init[] = {
6332 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6333 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6334 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6335 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6336 { } /* end */
6337};
6338
6339/*
6340 * 8ch mode
6341 */
6342static struct hda_verb alc883_sixstack_ch8_init[] = {
6343 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6344 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6345 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6346 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6347 { } /* end */
6348};
6349
6350static struct hda_channel_mode alc883_sixstack_modes[2] = {
6351 { 6, alc883_sixstack_ch6_init },
6352 { 8, alc883_sixstack_ch8_init },
6353};
6354
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006355static struct hda_verb alc883_medion_eapd_verbs[] = {
6356 /* eanable EAPD on medion laptop */
6357 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6358 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6359 { }
6360};
6361
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006362/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6363 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6364 */
6365
6366static struct snd_kcontrol_new alc883_base_mixer[] = {
6367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6368 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6369 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6370 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6371 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6372 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6373 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6374 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6375 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6376 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006383 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6385 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006386 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006387 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6388 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6389 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6390 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6391 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6392 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6393 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6394 {
6395 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6396 /* .name = "Capture Source", */
6397 .name = "Input Source",
6398 .count = 2,
6399 .info = alc883_mux_enum_info,
6400 .get = alc883_mux_enum_get,
6401 .put = alc883_mux_enum_put,
6402 },
6403 { } /* end */
6404};
6405
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006406static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6408 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6409 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6410 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6411 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6412 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6415 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6416 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6417 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6418 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6420 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6421 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6422 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6423 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6424 {
6425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6426 /* .name = "Capture Source", */
6427 .name = "Input Source",
6428 .count = 2,
6429 .info = alc883_mux_enum_info,
6430 .get = alc883_mux_enum_get,
6431 .put = alc883_mux_enum_put,
6432 },
6433 { } /* end */
6434};
6435
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006436static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6450 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6451 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6452 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6453 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6454 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6455 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6456 {
6457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6458 /* .name = "Capture Source", */
6459 .name = "Input Source",
6460 .count = 2,
6461 .info = alc883_mux_enum_info,
6462 .get = alc883_mux_enum_get,
6463 .put = alc883_mux_enum_put,
6464 },
6465 { } /* end */
6466};
6467
6468static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6478 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6479 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6480 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6481 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006483 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006486 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6488 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6489 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6490 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6491 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6492 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6493 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6494 {
6495 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6496 /* .name = "Capture Source", */
6497 .name = "Input Source",
6498 .count = 2,
6499 .info = alc883_mux_enum_info,
6500 .get = alc883_mux_enum_get,
6501 .put = alc883_mux_enum_put,
6502 },
6503 { } /* end */
6504};
6505
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006506static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006507 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6508 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6509 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6510 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6511 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6512 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6513 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6514 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6518 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6519 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006521 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6523 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006524 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006525 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6526 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6527 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6528 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6529 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6530
6531 {
6532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6533 /* .name = "Capture Source", */
6534 .name = "Input Source",
6535 .count = 1,
6536 .info = alc883_mux_enum_info,
6537 .get = alc883_mux_enum_get,
6538 .put = alc883_mux_enum_put,
6539 },
6540 { } /* end */
6541};
6542
Kailang Yangccc656c2006-10-17 12:32:26 +02006543static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6544 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6546 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6547 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6548 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6549 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6550 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6551 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6552 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6553 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6554 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6555 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6556 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006558 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6560 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6561 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6562 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6563 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6564 {
6565 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6566 /* .name = "Capture Source", */
6567 .name = "Input Source",
6568 .count = 2,
6569 .info = alc883_mux_enum_info,
6570 .get = alc883_mux_enum_get,
6571 .put = alc883_mux_enum_put,
6572 },
6573 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006574};
Kailang Yangccc656c2006-10-17 12:32:26 +02006575
6576static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6577 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6579 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6580 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6581 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006583 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6585 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6586 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6587 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6588 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6589 {
6590 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6591 /* .name = "Capture Source", */
6592 .name = "Input Source",
6593 .count = 2,
6594 .info = alc883_mux_enum_info,
6595 .get = alc883_mux_enum_get,
6596 .put = alc883_mux_enum_put,
6597 },
6598 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006599};
Kailang Yangccc656c2006-10-17 12:32:26 +02006600
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006601static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6604 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6605 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6608 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6610 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6611 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6612 {
6613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6614 /* .name = "Capture Source", */
6615 .name = "Input Source",
6616 .count = 1,
6617 .info = alc883_mux_enum_info,
6618 .get = alc883_mux_enum_get,
6619 .put = alc883_mux_enum_put,
6620 },
6621 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006622};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006623
Kailang Yang272a5272007-05-14 11:00:38 +02006624static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6625 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6626 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6627 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6628 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6629 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6632 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6633 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, 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 */
6648};
6649
6650static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6651 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6653 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6654 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6655 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6660 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6661 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6662 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6663 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6664 {
6665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6666 /* .name = "Capture Source", */
6667 .name = "Input Source",
6668 .count = 2,
6669 .info = alc883_mux_enum_info,
6670 .get = alc883_mux_enum_get,
6671 .put = alc883_mux_enum_put,
6672 },
6673 { } /* end */
6674};
6675
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006676static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006677 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6678 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6679 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6680 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6681 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6682 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6683 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6684 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6685 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6686 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6687 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6690 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6691 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6693 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6695 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6696 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6697 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6698 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6699 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6700 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6701 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6702 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6703 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6704 {
6705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6706 /* .name = "Capture Source", */
6707 .name = "Input Source",
6708 .count = 2,
6709 .info = alc883_mux_enum_info,
6710 .get = alc883_mux_enum_get,
6711 .put = alc883_mux_enum_put,
6712 },
6713 { } /* end */
6714};
6715
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006716static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006717 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6718 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6719 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6720 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6721 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6722 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6723 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6724 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6726 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6727 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6731 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6736 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6737 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6738 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6739 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6740 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6741 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6742 {
6743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6744 /* .name = "Capture Source", */
6745 .name = "Input Source",
6746 .count = 2,
6747 .info = alc883_mux_enum_info,
6748 .get = alc883_mux_enum_get,
6749 .put = alc883_mux_enum_put,
6750 },
6751 { } /* end */
6752};
6753
Tobin Davis2880a862007-08-07 11:50:26 +02006754static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6756 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006763 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6764 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6765 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6766 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6767 {
6768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6769 /* .name = "Capture Source", */
6770 .name = "Input Source",
6771 .count = 2,
6772 .info = alc883_mux_enum_info,
6773 .get = alc883_mux_enum_get,
6774 .put = alc883_mux_enum_put,
6775 },
6776 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006777};
Tobin Davis2880a862007-08-07 11:50:26 +02006778
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006779static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6780 {
6781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6782 .name = "Channel Mode",
6783 .info = alc_ch_mode_info,
6784 .get = alc_ch_mode_get,
6785 .put = alc_ch_mode_put,
6786 },
6787 { } /* end */
6788};
6789
6790static struct hda_verb alc883_init_verbs[] = {
6791 /* ADC1: mute amp left and right */
6792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6793 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6794 /* ADC2: mute amp left and right */
6795 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6796 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6797 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6801 /* Rear mixer */
6802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6805 /* CLFE mixer */
6806 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6809 /* Side mixer */
6810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6811 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6812 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6813
Takashi Iwaicb53c622007-08-10 17:21:45 +02006814 /* mute analog input loopbacks */
6815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6819 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006820
6821 /* Front Pin: output 0 (0x0c) */
6822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6824 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6825 /* Rear Pin: output 1 (0x0d) */
6826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6828 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6829 /* CLFE Pin: output 2 (0x0e) */
6830 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6831 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6832 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6833 /* Side Pin: output 3 (0x0f) */
6834 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6836 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6837 /* Mic (rear) pin: input vref at 80% */
6838 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6840 /* Front Mic pin: input vref at 80% */
6841 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6843 /* Line In pin: input */
6844 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6846 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6847 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6848 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6849 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6850 /* CD pin widget for input */
6851 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6852
6853 /* FIXME: use matrix-type input source selection */
6854 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6855 /* Input mixer2 */
6856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6860 /* Input mixer3 */
6861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6865 { }
6866};
6867
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006868/* toggle speaker-output according to the hp-jack state */
6869static void alc883_mitac_hp_automute(struct hda_codec *codec)
6870{
6871 unsigned int present;
6872
6873 present = snd_hda_codec_read(codec, 0x15, 0,
6874 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6875 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6876 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6877 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6878 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6879}
6880
6881/* auto-toggle front mic */
6882/*
6883static void alc883_mitac_mic_automute(struct hda_codec *codec)
6884{
6885 unsigned int present;
6886 unsigned char bits;
6887
6888 present = snd_hda_codec_read(codec, 0x18, 0,
6889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6890 bits = present ? HDA_AMP_MUTE : 0;
6891 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
6892}
6893*/
6894
6895static void alc883_mitac_automute(struct hda_codec *codec)
6896{
6897 alc883_mitac_hp_automute(codec);
6898 /* alc883_mitac_mic_automute(codec); */
6899}
6900
6901static void alc883_mitac_unsol_event(struct hda_codec *codec,
6902 unsigned int res)
6903{
6904 switch (res >> 26) {
6905 case ALC880_HP_EVENT:
6906 alc883_mitac_hp_automute(codec);
6907 break;
6908 case ALC880_MIC_EVENT:
6909 /* alc883_mitac_mic_automute(codec); */
6910 break;
6911 }
6912}
6913
6914static struct hda_verb alc883_mitac_verbs[] = {
6915 /* HP */
6916 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6918 /* Subwoofer */
6919 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
6920 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6921
6922 /* enable unsolicited event */
6923 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6924 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
6925
6926 { } /* end */
6927};
6928
Kailang Yangccc656c2006-10-17 12:32:26 +02006929static struct hda_verb alc883_tagra_verbs[] = {
6930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6932
6933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6935
6936 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6937 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6939
6940 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006941 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6942 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6943 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006944
6945 { } /* end */
6946};
6947
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006948static struct hda_verb alc883_lenovo_101e_verbs[] = {
6949 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6950 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6951 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6952 { } /* end */
6953};
6954
Kailang Yang272a5272007-05-14 11:00:38 +02006955static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6958 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6960 { } /* end */
6961};
6962
6963static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6967 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6968 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6969 { } /* end */
6970};
6971
Kailang Yang189609a2007-08-20 11:31:23 +02006972static struct hda_verb alc883_haier_w66_verbs[] = {
6973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6975
6976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6977
6978 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6980 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6982 { } /* end */
6983};
6984
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006985static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006986 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6987 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6988 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6989 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6990 { }
6991};
6992
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006993static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006994 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6995 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6996 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6997 { }
6998};
6999
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007000static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007001 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7002 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7003 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7004 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7005 { }
7006};
7007
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007008static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007009 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7010 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7011 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7012 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7013 { }
7014};
7015
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007016static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7017 { 2, alc888_3st_hp_2ch_init },
7018 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007019};
7020
Kailang Yang272a5272007-05-14 11:00:38 +02007021/* toggle front-jack and RCA according to the hp-jack state */
7022static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7023{
7024 unsigned int present;
7025
7026 present = snd_hda_codec_read(codec, 0x1b, 0,
7027 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007028 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7029 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7030 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7031 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007032}
7033
7034/* toggle RCA according to the front-jack state */
7035static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7036{
7037 unsigned int present;
7038
7039 present = snd_hda_codec_read(codec, 0x14, 0,
7040 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007041 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7042 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007043}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007044
Kailang Yang272a5272007-05-14 11:00:38 +02007045static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7046 unsigned int res)
7047{
7048 if ((res >> 26) == ALC880_HP_EVENT)
7049 alc888_lenovo_ms7195_front_automute(codec);
7050 if ((res >> 26) == ALC880_FRONT_EVENT)
7051 alc888_lenovo_ms7195_rca_automute(codec);
7052}
7053
7054static struct hda_verb alc883_medion_md2_verbs[] = {
7055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7057
7058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7059
7060 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7061 { } /* end */
7062};
7063
7064/* toggle speaker-output according to the hp-jack state */
7065static void alc883_medion_md2_automute(struct hda_codec *codec)
7066{
7067 unsigned int present;
7068
7069 present = snd_hda_codec_read(codec, 0x14, 0,
7070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007071 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7072 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007073}
7074
7075static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7076 unsigned int res)
7077{
7078 if ((res >> 26) == ALC880_HP_EVENT)
7079 alc883_medion_md2_automute(codec);
7080}
7081
Kailang Yangccc656c2006-10-17 12:32:26 +02007082/* toggle speaker-output according to the hp-jack state */
7083static void alc883_tagra_automute(struct hda_codec *codec)
7084{
7085 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007086 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007087
7088 present = snd_hda_codec_read(codec, 0x14, 0,
7089 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007090 bits = present ? HDA_AMP_MUTE : 0;
7091 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7092 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007093 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7094 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007095}
7096
7097static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7098{
7099 if ((res >> 26) == ALC880_HP_EVENT)
7100 alc883_tagra_automute(codec);
7101}
7102
Kailang Yang189609a2007-08-20 11:31:23 +02007103static void alc883_haier_w66_automute(struct hda_codec *codec)
7104{
7105 unsigned int present;
7106 unsigned char bits;
7107
7108 present = snd_hda_codec_read(codec, 0x1b, 0,
7109 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7110 bits = present ? 0x80 : 0;
7111 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7112 0x80, bits);
7113}
7114
7115static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7116 unsigned int res)
7117{
7118 if ((res >> 26) == ALC880_HP_EVENT)
7119 alc883_haier_w66_automute(codec);
7120}
7121
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007122static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7123{
7124 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007125 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007126
7127 present = snd_hda_codec_read(codec, 0x14, 0,
7128 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007129 bits = present ? HDA_AMP_MUTE : 0;
7130 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7131 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007132}
7133
7134static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7135{
7136 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007137 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007138
7139 present = snd_hda_codec_read(codec, 0x1b, 0,
7140 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007141 bits = present ? HDA_AMP_MUTE : 0;
7142 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7143 HDA_AMP_MUTE, bits);
7144 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7145 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007146}
7147
7148static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7149 unsigned int res)
7150{
7151 if ((res >> 26) == ALC880_HP_EVENT)
7152 alc883_lenovo_101e_all_automute(codec);
7153 if ((res >> 26) == ALC880_FRONT_EVENT)
7154 alc883_lenovo_101e_ispeaker_automute(codec);
7155}
7156
Takashi Iwai676a9b52007-08-16 15:23:35 +02007157/* toggle speaker-output according to the hp-jack state */
7158static void alc883_acer_aspire_automute(struct hda_codec *codec)
7159{
7160 unsigned int present;
7161
7162 present = snd_hda_codec_read(codec, 0x14, 0,
7163 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7164 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7165 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7166 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7167 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7168}
7169
7170static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7171 unsigned int res)
7172{
7173 if ((res >> 26) == ALC880_HP_EVENT)
7174 alc883_acer_aspire_automute(codec);
7175}
7176
Kailang Yangd1a991a2007-08-15 16:21:59 +02007177static struct hda_verb alc883_acer_eapd_verbs[] = {
7178 /* HP Pin: output 0 (0x0c) */
7179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7181 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7182 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7184 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007186 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7187 /* eanable EAPD on medion laptop */
7188 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7189 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007190 /* enable unsolicited event */
7191 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007192 { }
7193};
7194
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007195/*
7196 * generic initialization of ADC, input mixers and output mixers
7197 */
7198static struct hda_verb alc883_auto_init_verbs[] = {
7199 /*
7200 * Unmute ADC0-2 and set the default input to mic-in
7201 */
7202 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7204 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7206
Takashi Iwaicb53c622007-08-10 17:21:45 +02007207 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007208 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007209 * Note: PASD motherboards uses the Line In 2 as the input for
7210 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007211 */
7212 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007218
7219 /*
7220 * Set up output mixers (0x0c - 0x0f)
7221 */
7222 /* set vol=0 to output mixers */
7223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7226 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7227 /* set up input amps for analog loopback */
7228 /* Amp Indices: DAC = 0, mixer = 1 */
7229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7235 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7237 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7238 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7239
7240 /* FIXME: use matrix-type input source selection */
7241 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7242 /* Input mixer1 */
7243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007246 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7248 /* Input mixer2 */
7249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007252 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007254
7255 { }
7256};
7257
7258/* capture mixer elements */
7259static struct snd_kcontrol_new alc883_capture_mixer[] = {
7260 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7261 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7262 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7263 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7264 {
7265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7266 /* The multiple "Capture Source" controls confuse alsamixer
7267 * So call somewhat different..
7268 * FIXME: the controls appear in the "playback" view!
7269 */
7270 /* .name = "Capture Source", */
7271 .name = "Input Source",
7272 .count = 2,
7273 .info = alc882_mux_enum_info,
7274 .get = alc882_mux_enum_get,
7275 .put = alc882_mux_enum_put,
7276 },
7277 { } /* end */
7278};
7279
Takashi Iwaicb53c622007-08-10 17:21:45 +02007280#ifdef CONFIG_SND_HDA_POWER_SAVE
7281#define alc883_loopbacks alc880_loopbacks
7282#endif
7283
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007284/* pcm configuration: identiacal with ALC880 */
7285#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7286#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7287#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7288#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7289
7290/*
7291 * configuration and preset
7292 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007293static const char *alc883_models[ALC883_MODEL_LAST] = {
7294 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7295 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7296 [ALC883_3ST_6ch] = "3stack-6ch",
7297 [ALC883_6ST_DIG] = "6stack-dig",
7298 [ALC883_TARGA_DIG] = "targa-dig",
7299 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007300 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007301 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007302 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007303 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007304 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007305 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007306 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7307 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007308 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007309 [ALC888_6ST_HP] = "6stack-hp",
7310 [ALC888_3ST_HP] = "3stack-hp",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007311 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007312 [ALC883_AUTO] = "auto",
7313};
7314
7315static struct snd_pci_quirk alc883_cfg_tbl[] = {
7316 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007317 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7318 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7319 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7320 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Tobin Davisfebe3372007-06-12 11:27:46 +02007321 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007322 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7323 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7324 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7325 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007326 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007327 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7328 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7329 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007330 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007331 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7332 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7333 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7334 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7335 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7336 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7337 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7338 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7339 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7340 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7341 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7342 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7343 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007344 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7345 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007346 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007347 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007348 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007349 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007350 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7351 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007352 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007353 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007354 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007355 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007356 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7357 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007358 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007359 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007360 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007361 {}
7362};
7363
7364static struct alc_config_preset alc883_presets[] = {
7365 [ALC883_3ST_2ch_DIG] = {
7366 .mixers = { alc883_3ST_2ch_mixer },
7367 .init_verbs = { alc883_init_verbs },
7368 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7369 .dac_nids = alc883_dac_nids,
7370 .dig_out_nid = ALC883_DIGOUT_NID,
7371 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7372 .adc_nids = alc883_adc_nids,
7373 .dig_in_nid = ALC883_DIGIN_NID,
7374 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7375 .channel_mode = alc883_3ST_2ch_modes,
7376 .input_mux = &alc883_capture_source,
7377 },
7378 [ALC883_3ST_6ch_DIG] = {
7379 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7380 .init_verbs = { alc883_init_verbs },
7381 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7382 .dac_nids = alc883_dac_nids,
7383 .dig_out_nid = ALC883_DIGOUT_NID,
7384 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7385 .adc_nids = alc883_adc_nids,
7386 .dig_in_nid = ALC883_DIGIN_NID,
7387 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7388 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007389 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007390 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007391 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007392 [ALC883_3ST_6ch] = {
7393 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7394 .init_verbs = { alc883_init_verbs },
7395 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7396 .dac_nids = alc883_dac_nids,
7397 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7398 .adc_nids = alc883_adc_nids,
7399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7400 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007401 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007402 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007403 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007404 [ALC883_6ST_DIG] = {
7405 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7406 .init_verbs = { alc883_init_verbs },
7407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7408 .dac_nids = alc883_dac_nids,
7409 .dig_out_nid = ALC883_DIGOUT_NID,
7410 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7411 .adc_nids = alc883_adc_nids,
7412 .dig_in_nid = ALC883_DIGIN_NID,
7413 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7414 .channel_mode = alc883_sixstack_modes,
7415 .input_mux = &alc883_capture_source,
7416 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007417 [ALC883_TARGA_DIG] = {
7418 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7419 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7420 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7421 .dac_nids = alc883_dac_nids,
7422 .dig_out_nid = ALC883_DIGOUT_NID,
7423 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7424 .adc_nids = alc883_adc_nids,
7425 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7426 .channel_mode = alc883_3ST_6ch_modes,
7427 .need_dac_fix = 1,
7428 .input_mux = &alc883_capture_source,
7429 .unsol_event = alc883_tagra_unsol_event,
7430 .init_hook = alc883_tagra_automute,
7431 },
7432 [ALC883_TARGA_2ch_DIG] = {
7433 .mixers = { alc883_tagra_2ch_mixer},
7434 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7435 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7436 .dac_nids = alc883_dac_nids,
7437 .dig_out_nid = ALC883_DIGOUT_NID,
7438 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7439 .adc_nids = alc883_adc_nids,
7440 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7441 .channel_mode = alc883_3ST_2ch_modes,
7442 .input_mux = &alc883_capture_source,
7443 .unsol_event = alc883_tagra_unsol_event,
7444 .init_hook = alc883_tagra_automute,
7445 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007446 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007447 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007448 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7449 * and the headphone jack. Turn this on and rely on the
7450 * standard mute methods whenever the user wants to turn
7451 * these outputs off.
7452 */
7453 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7454 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7455 .dac_nids = alc883_dac_nids,
7456 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7457 .adc_nids = alc883_adc_nids,
7458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7459 .channel_mode = alc883_3ST_2ch_modes,
7460 .input_mux = &alc883_capture_source,
7461 },
Tobin Davis2880a862007-08-07 11:50:26 +02007462 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007463 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007464 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007465 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7466 .dac_nids = alc883_dac_nids,
7467 .dig_out_nid = ALC883_DIGOUT_NID,
7468 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7469 .adc_nids = alc883_adc_nids,
7470 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7471 .channel_mode = alc883_3ST_2ch_modes,
7472 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007473 .unsol_event = alc883_acer_aspire_unsol_event,
7474 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007475 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007476 [ALC883_MEDION] = {
7477 .mixers = { alc883_fivestack_mixer,
7478 alc883_chmode_mixer },
7479 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007480 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7482 .dac_nids = alc883_dac_nids,
7483 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7484 .adc_nids = alc883_adc_nids,
7485 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7486 .channel_mode = alc883_sixstack_modes,
7487 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007488 },
Kailang Yang272a5272007-05-14 11:00:38 +02007489 [ALC883_MEDION_MD2] = {
7490 .mixers = { alc883_medion_md2_mixer},
7491 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7493 .dac_nids = alc883_dac_nids,
7494 .dig_out_nid = ALC883_DIGOUT_NID,
7495 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7496 .adc_nids = alc883_adc_nids,
7497 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7498 .channel_mode = alc883_3ST_2ch_modes,
7499 .input_mux = &alc883_capture_source,
7500 .unsol_event = alc883_medion_md2_unsol_event,
7501 .init_hook = alc883_medion_md2_automute,
7502 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007503 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007504 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007505 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7507 .dac_nids = alc883_dac_nids,
7508 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7509 .adc_nids = alc883_adc_nids,
7510 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7511 .channel_mode = alc883_3ST_2ch_modes,
7512 .input_mux = &alc883_capture_source,
7513 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007514 [ALC883_LENOVO_101E_2ch] = {
7515 .mixers = { alc883_lenovo_101e_2ch_mixer},
7516 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7518 .dac_nids = alc883_dac_nids,
7519 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7520 .adc_nids = alc883_adc_nids,
7521 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7522 .channel_mode = alc883_3ST_2ch_modes,
7523 .input_mux = &alc883_lenovo_101e_capture_source,
7524 .unsol_event = alc883_lenovo_101e_unsol_event,
7525 .init_hook = alc883_lenovo_101e_all_automute,
7526 },
Kailang Yang272a5272007-05-14 11:00:38 +02007527 [ALC883_LENOVO_NB0763] = {
7528 .mixers = { alc883_lenovo_nb0763_mixer },
7529 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7531 .dac_nids = alc883_dac_nids,
7532 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7533 .adc_nids = alc883_adc_nids,
7534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7535 .channel_mode = alc883_3ST_2ch_modes,
7536 .need_dac_fix = 1,
7537 .input_mux = &alc883_lenovo_nb0763_capture_source,
7538 .unsol_event = alc883_medion_md2_unsol_event,
7539 .init_hook = alc883_medion_md2_automute,
7540 },
7541 [ALC888_LENOVO_MS7195_DIG] = {
7542 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7543 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7544 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7545 .dac_nids = alc883_dac_nids,
7546 .dig_out_nid = ALC883_DIGOUT_NID,
7547 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7548 .adc_nids = alc883_adc_nids,
7549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7550 .channel_mode = alc883_3ST_6ch_modes,
7551 .need_dac_fix = 1,
7552 .input_mux = &alc883_capture_source,
7553 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7554 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007555 },
7556 [ALC883_HAIER_W66] = {
7557 .mixers = { alc883_tagra_2ch_mixer},
7558 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7560 .dac_nids = alc883_dac_nids,
7561 .dig_out_nid = ALC883_DIGOUT_NID,
7562 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7563 .adc_nids = alc883_adc_nids,
7564 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7565 .channel_mode = alc883_3ST_2ch_modes,
7566 .input_mux = &alc883_capture_source,
7567 .unsol_event = alc883_haier_w66_unsol_event,
7568 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007569 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007570 [ALC888_6ST_HP] = {
7571 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7572 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7574 .dac_nids = alc883_dac_nids,
7575 .dig_out_nid = ALC883_DIGOUT_NID,
7576 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7577 .adc_nids = alc883_adc_nids,
7578 .dig_in_nid = ALC883_DIGIN_NID,
7579 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7580 .channel_mode = alc883_sixstack_modes,
7581 .input_mux = &alc883_capture_source,
7582 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007583 [ALC888_3ST_HP] = {
7584 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7585 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7587 .dac_nids = alc883_dac_nids,
7588 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7589 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007590 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7591 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007592 .need_dac_fix = 1,
7593 .input_mux = &alc883_capture_source,
7594 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007595 [ALC883_MITAC] = {
7596 .mixers = { alc883_mitac_mixer },
7597 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7598 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7599 .dac_nids = alc883_dac_nids,
7600 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7601 .adc_nids = alc883_adc_nids,
7602 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7603 .channel_mode = alc883_3ST_2ch_modes,
7604 .input_mux = &alc883_capture_source,
7605 .unsol_event = alc883_mitac_unsol_event,
7606 .init_hook = alc883_mitac_automute,
7607 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007608};
7609
7610
7611/*
7612 * BIOS auto configuration
7613 */
7614static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7615 hda_nid_t nid, int pin_type,
7616 int dac_idx)
7617{
7618 /* set as output */
7619 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007620 int idx;
7621
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007622 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7623 idx = 4;
7624 else
7625 idx = spec->multiout.dac_nids[dac_idx] - 2;
7626
7627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7628 pin_type);
7629 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7630 AMP_OUT_UNMUTE);
7631 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7632
7633}
7634
7635static void alc883_auto_init_multi_out(struct hda_codec *codec)
7636{
7637 struct alc_spec *spec = codec->spec;
7638 int i;
7639
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007640 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007641 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007642 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007643 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007644 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007645 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007646 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007647 }
7648}
7649
7650static void alc883_auto_init_hp_out(struct hda_codec *codec)
7651{
7652 struct alc_spec *spec = codec->spec;
7653 hda_nid_t pin;
7654
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007655 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007656 if (pin) /* connect to front */
7657 /* use dac 0 */
7658 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7659}
7660
7661#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7662#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7663
7664static void alc883_auto_init_analog_input(struct hda_codec *codec)
7665{
7666 struct alc_spec *spec = codec->spec;
7667 int i;
7668
7669 for (i = 0; i < AUTO_PIN_LAST; i++) {
7670 hda_nid_t nid = spec->autocfg.input_pins[i];
7671 if (alc883_is_input_pin(nid)) {
7672 snd_hda_codec_write(codec, nid, 0,
7673 AC_VERB_SET_PIN_WIDGET_CONTROL,
7674 (i <= AUTO_PIN_FRONT_MIC ?
7675 PIN_VREF80 : PIN_IN));
7676 if (nid != ALC883_PIN_CD_NID)
7677 snd_hda_codec_write(codec, nid, 0,
7678 AC_VERB_SET_AMP_GAIN_MUTE,
7679 AMP_OUT_MUTE);
7680 }
7681 }
7682}
7683
7684/* almost identical with ALC880 parser... */
7685static int alc883_parse_auto_config(struct hda_codec *codec)
7686{
7687 struct alc_spec *spec = codec->spec;
7688 int err = alc880_parse_auto_config(codec);
7689
7690 if (err < 0)
7691 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007692 else if (!err)
7693 return 0; /* no config found */
7694
7695 err = alc_auto_add_mic_boost(codec);
7696 if (err < 0)
7697 return err;
7698
7699 /* hack - override the init verbs */
7700 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007701 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7702 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007703
7704 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007705}
7706
7707/* additional initialization for auto-configuration model */
7708static void alc883_auto_init(struct hda_codec *codec)
7709{
7710 alc883_auto_init_multi_out(codec);
7711 alc883_auto_init_hp_out(codec);
7712 alc883_auto_init_analog_input(codec);
7713}
7714
7715static int patch_alc883(struct hda_codec *codec)
7716{
7717 struct alc_spec *spec;
7718 int err, board_config;
7719
7720 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7721 if (spec == NULL)
7722 return -ENOMEM;
7723
7724 codec->spec = spec;
7725
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007726 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7727 alc883_models,
7728 alc883_cfg_tbl);
7729 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007730 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7731 "trying auto-probe from BIOS...\n");
7732 board_config = ALC883_AUTO;
7733 }
7734
7735 if (board_config == ALC883_AUTO) {
7736 /* automatic parse from the BIOS config */
7737 err = alc883_parse_auto_config(codec);
7738 if (err < 0) {
7739 alc_free(codec);
7740 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007741 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007742 printk(KERN_INFO
7743 "hda_codec: Cannot set up configuration "
7744 "from BIOS. Using base mode...\n");
7745 board_config = ALC883_3ST_2ch_DIG;
7746 }
7747 }
7748
7749 if (board_config != ALC883_AUTO)
7750 setup_preset(spec, &alc883_presets[board_config]);
7751
7752 spec->stream_name_analog = "ALC883 Analog";
7753 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7754 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7755
7756 spec->stream_name_digital = "ALC883 Digital";
7757 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7758 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7759
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007760 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007761 spec->adc_nids = alc883_adc_nids;
7762 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7763 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007764
7765 codec->patch_ops = alc_patch_ops;
7766 if (board_config == ALC883_AUTO)
7767 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007768#ifdef CONFIG_SND_HDA_POWER_SAVE
7769 if (!spec->loopback.amplist)
7770 spec->loopback.amplist = alc883_loopbacks;
7771#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007772
7773 return 0;
7774}
7775
7776/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007777 * ALC262 support
7778 */
7779
7780#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7781#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7782
7783#define alc262_dac_nids alc260_dac_nids
7784#define alc262_adc_nids alc882_adc_nids
7785#define alc262_adc_nids_alt alc882_adc_nids_alt
7786
7787#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007788#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007789
7790static struct snd_kcontrol_new alc262_base_mixer[] = {
7791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7792 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007803 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7804 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7807 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7808 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007809 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007810};
7811
Kailang Yangccc656c2006-10-17 12:32:26 +02007812static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7814 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007824 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007825 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7826 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7827 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7829 { } /* end */
7830};
7831
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007832static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7833 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7834 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7836 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7837 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7838
7839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007844 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7847 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7849 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7850 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7851 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7852 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7853 { } /* end */
7854};
7855
Kailang Yangcd7509a2007-01-26 18:33:17 +01007856static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7858 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7859 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7863 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007865 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007866 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7867 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7870 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7871 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7872 { } /* end */
7873};
7874
7875static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7876 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7877 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007878 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007879 { } /* end */
7880};
7881
Kailang Yang66d2a9d2007-11-14 12:06:21 +01007882static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
7883 .ops = &snd_hda_bind_vol,
7884 .values = {
7885 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7886 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7887 0
7888 },
7889};
7890
7891static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
7892 .ops = &snd_hda_bind_sw,
7893 .values = {
7894 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7895 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7896 0
7897 },
7898};
7899
7900/* mute/unmute internal speaker according to the hp jack and mute state */
7901static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
7902{
7903 struct alc_spec *spec = codec->spec;
7904 unsigned int mute;
7905
7906 if (force || !spec->sense_updated) {
7907 unsigned int present;
7908 present = snd_hda_codec_read(codec, 0x15, 0,
7909 AC_VERB_GET_PIN_SENSE, 0);
7910 spec->jack_present = (present & 0x80000000) != 0;
7911 spec->sense_updated = 1;
7912 }
7913 if (spec->jack_present)
7914 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
7915 else /* unmute internal speaker if necessary */
7916 mute = (0x7000 | ((0)<<8));
7917 snd_hda_codec_write(codec, 0x0c, 0,
7918 AC_VERB_SET_AMP_GAIN_MUTE, mute );
7919}
7920
7921static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
7922 unsigned int res)
7923{
7924 if ((res >> 26) != ALC880_HP_EVENT)
7925 return;
7926 alc262_hp_t5735_automute(codec, 1);
7927}
7928
7929static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
7930{
7931 alc262_hp_t5735_automute(codec, 1);
7932}
7933
7934static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
7935 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
7936 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
7937 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7938 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7939 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7940 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7943 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7946 { } /* end */
7947};
7948
7949static struct hda_verb alc262_hp_t5735_verbs[] = {
7950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7951 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7952
7953 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7954 { }
7955};
7956
Kailang Yang8c427222008-01-10 13:03:59 +01007957static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
7958 .ops = &snd_hda_bind_vol,
7959 .values = {
7960 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7961 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
7962 0
7963 },
7964};
7965
7966static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
7967 .ops = &snd_hda_bind_sw,
7968 .values = {
7969 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
7970 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
7971 0
7972 },
7973};
7974
7975static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
7976 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
7977 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
7978 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7984 { } /* end */
7985};
7986
7987static struct hda_verb alc262_hp_rp5700_verbs[] = {
7988 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7989 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7992 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7993 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
7997 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
7998 {}
7999};
8000
8001static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8002 .num_items = 1,
8003 .items = {
8004 { "Line", 0x1 },
8005 },
8006};
8007
Takashi Iwai0724ea22007-08-23 00:31:43 +02008008/* bind hp and internal speaker mute (with plug check) */
8009static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8010 struct snd_ctl_elem_value *ucontrol)
8011{
8012 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8013 long *valp = ucontrol->value.integer.value;
8014 int change;
8015
8016 /* change hp mute */
8017 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8018 HDA_AMP_MUTE,
8019 valp[0] ? 0 : HDA_AMP_MUTE);
8020 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8021 HDA_AMP_MUTE,
8022 valp[1] ? 0 : HDA_AMP_MUTE);
8023 if (change) {
8024 /* change speaker according to HP jack state */
8025 struct alc_spec *spec = codec->spec;
8026 unsigned int mute;
8027 if (spec->jack_present)
8028 mute = HDA_AMP_MUTE;
8029 else
8030 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8031 HDA_OUTPUT, 0);
8032 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8033 HDA_AMP_MUTE, mute);
8034 }
8035 return change;
8036}
Takashi Iwai5b319542007-07-26 11:49:22 +02008037
Kailang Yang272a5272007-05-14 11:00:38 +02008038static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008039 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8040 {
8041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8042 .name = "Master Playback Switch",
8043 .info = snd_hda_mixer_amp_switch_info,
8044 .get = snd_hda_mixer_amp_switch_get,
8045 .put = alc262_sony_master_sw_put,
8046 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8047 },
Kailang Yang272a5272007-05-14 11:00:38 +02008048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8051 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8052 { } /* end */
8053};
8054
Kailang Yang83c34212007-07-05 11:43:05 +02008055static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8061 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8062 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8063 { } /* end */
8064};
Kailang Yang272a5272007-05-14 11:00:38 +02008065
Kailang Yangdf694da2005-12-05 19:42:22 +01008066#define alc262_capture_mixer alc882_capture_mixer
8067#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8068
8069/*
8070 * generic initialization of ADC, input mixers and output mixers
8071 */
8072static struct hda_verb alc262_init_verbs[] = {
8073 /*
8074 * Unmute ADC0-2 and set the default input to mic-in
8075 */
8076 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8082
Takashi Iwaicb53c622007-08-10 17:21:45 +02008083 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008084 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008085 * Note: PASD motherboards uses the Line In 2 as the input for
8086 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008087 */
8088 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008094
8095 /*
8096 * Set up output mixers (0x0c - 0x0e)
8097 */
8098 /* set vol=0 to output mixers */
8099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8102 /* set up input amps for analog loopback */
8103 /* Amp Indices: DAC = 0, mixer = 1 */
8104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8110
8111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8113 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8114 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8117
8118 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8120 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8123
8124 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8125 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8126
8127 /* FIXME: use matrix-type input source selection */
8128 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8129 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8134 /* Input mixer2 */
8135 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8136 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8139 /* Input mixer3 */
8140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8142 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008143 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008144
8145 { }
8146};
8147
Kailang Yangccc656c2006-10-17 12:32:26 +02008148static struct hda_verb alc262_hippo_unsol_verbs[] = {
8149 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8151 {}
8152};
8153
8154static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8156 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8158
8159 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8160 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8161 {}
8162};
8163
Kailang Yang272a5272007-05-14 11:00:38 +02008164static struct hda_verb alc262_sony_unsol_verbs[] = {
8165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8166 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8167 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8168
8169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8171};
8172
Kailang Yangccc656c2006-10-17 12:32:26 +02008173/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008174static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008175{
8176 struct alc_spec *spec = codec->spec;
8177 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008178 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008179
Takashi Iwai5b319542007-07-26 11:49:22 +02008180 /* need to execute and sync at first */
8181 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8182 present = snd_hda_codec_read(codec, 0x15, 0,
8183 AC_VERB_GET_PIN_SENSE, 0);
8184 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008185 if (spec->jack_present) {
8186 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008187 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8188 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008189 } else {
8190 /* unmute internal speaker if necessary */
8191 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008192 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8193 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008194 }
8195}
8196
8197/* unsolicited event for HP jack sensing */
8198static void alc262_hippo_unsol_event(struct hda_codec *codec,
8199 unsigned int res)
8200{
8201 if ((res >> 26) != ALC880_HP_EVENT)
8202 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008203 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008204}
8205
Takashi Iwai5b319542007-07-26 11:49:22 +02008206static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008207{
Kailang Yangccc656c2006-10-17 12:32:26 +02008208 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008209 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008210
Takashi Iwai5b319542007-07-26 11:49:22 +02008211 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8212 present = snd_hda_codec_read(codec, 0x1b, 0,
8213 AC_VERB_GET_PIN_SENSE, 0);
8214 present = (present & 0x80000000) != 0;
8215 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008216 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008217 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8218 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008219 } else {
8220 /* unmute internal speaker if necessary */
8221 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008222 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8223 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008224 }
8225}
8226
8227/* unsolicited event for HP jack sensing */
8228static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8229 unsigned int res)
8230{
8231 if ((res >> 26) != ALC880_HP_EVENT)
8232 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008233 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008234}
8235
Takashi Iwai834be882006-03-01 14:16:17 +01008236/*
8237 * fujitsu model
8238 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8239 */
8240
8241#define ALC_HP_EVENT 0x37
8242
8243static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8244 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8246 {}
8247};
8248
8249static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008250 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008251 .items = {
8252 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008253 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008254 { "CD", 0x4 },
8255 },
8256};
8257
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008258static struct hda_input_mux alc262_HP_capture_source = {
8259 .num_items = 5,
8260 .items = {
8261 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008262 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008263 { "Line", 0x2 },
8264 { "CD", 0x4 },
8265 { "AUX IN", 0x6 },
8266 },
8267};
8268
zhejiangaccbe492007-08-31 12:36:05 +02008269static struct hda_input_mux alc262_HP_D7000_capture_source = {
8270 .num_items = 4,
8271 .items = {
8272 { "Mic", 0x0 },
8273 { "Front Mic", 0x2 },
8274 { "Line", 0x1 },
8275 { "CD", 0x4 },
8276 },
8277};
8278
Takashi Iwai834be882006-03-01 14:16:17 +01008279/* mute/unmute internal speaker according to the hp jack and mute state */
8280static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8281{
8282 struct alc_spec *spec = codec->spec;
8283 unsigned int mute;
8284
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008285 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008286 unsigned int present;
8287 /* need to execute and sync at first */
8288 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8289 present = snd_hda_codec_read(codec, 0x14, 0,
8290 AC_VERB_GET_PIN_SENSE, 0);
8291 spec->jack_present = (present & 0x80000000) != 0;
8292 spec->sense_updated = 1;
8293 }
8294 if (spec->jack_present) {
8295 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8297 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008298 } else {
8299 /* unmute internal speaker if necessary */
8300 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008301 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8302 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008303 }
8304}
8305
8306/* unsolicited event for HP jack sensing */
8307static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8308 unsigned int res)
8309{
8310 if ((res >> 26) != ALC_HP_EVENT)
8311 return;
8312 alc262_fujitsu_automute(codec, 1);
8313}
8314
8315/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008316static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8317 .ops = &snd_hda_bind_vol,
8318 .values = {
8319 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8320 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8321 0
8322 },
8323};
Takashi Iwai834be882006-03-01 14:16:17 +01008324
8325/* bind hp and internal speaker mute (with plug check) */
8326static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8327 struct snd_ctl_elem_value *ucontrol)
8328{
8329 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8330 long *valp = ucontrol->value.integer.value;
8331 int change;
8332
8333 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008334 HDA_AMP_MUTE,
8335 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008336 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008337 HDA_AMP_MUTE,
8338 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008339 if (change)
8340 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008341 return change;
8342}
8343
8344static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008345 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008346 {
8347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8348 .name = "Master Playback Switch",
8349 .info = snd_hda_mixer_amp_switch_info,
8350 .get = snd_hda_mixer_amp_switch_get,
8351 .put = alc262_fujitsu_master_sw_put,
8352 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8353 },
8354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008359 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8360 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8361 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008362 { } /* end */
8363};
8364
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008365/* additional init verbs for Benq laptops */
8366static struct hda_verb alc262_EAPD_verbs[] = {
8367 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8368 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8369 {}
8370};
8371
Kailang Yang83c34212007-07-05 11:43:05 +02008372static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8373 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8375
8376 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8377 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8378 {}
8379};
8380
Tobin Davisf651b502007-10-26 12:40:47 +02008381/* Samsung Q1 Ultra Vista model setup */
8382static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8384 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8388 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8389 { } /* end */
8390};
8391
8392static struct hda_verb alc262_ultra_verbs[] = {
8393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8395 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8396 /* Mic is on Node 0x19 */
8397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8398 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8400 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8402 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8404 {}
8405};
8406
8407static struct hda_input_mux alc262_ultra_capture_source = {
8408 .num_items = 1,
8409 .items = {
8410 { "Mic", 0x1 },
8411 },
8412};
8413
8414/* mute/unmute internal speaker according to the hp jack and mute state */
8415static void alc262_ultra_automute(struct hda_codec *codec)
8416{
8417 struct alc_spec *spec = codec->spec;
8418 unsigned int mute;
8419 unsigned int present;
8420
8421 /* need to execute and sync at first */
8422 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8423 present = snd_hda_codec_read(codec, 0x15, 0,
8424 AC_VERB_GET_PIN_SENSE, 0);
8425 spec->jack_present = (present & 0x80000000) != 0;
8426 if (spec->jack_present) {
8427 /* mute internal speaker */
8428 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8429 HDA_AMP_MUTE, HDA_AMP_MUTE);
8430 } else {
8431 /* unmute internal speaker if necessary */
8432 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8433 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8434 HDA_AMP_MUTE, mute);
8435 }
8436}
8437
8438/* unsolicited event for HP jack sensing */
8439static void alc262_ultra_unsol_event(struct hda_codec *codec,
8440 unsigned int res)
8441{
8442 if ((res >> 26) != ALC880_HP_EVENT)
8443 return;
8444 alc262_ultra_automute(codec);
8445}
8446
Kailang Yangdf694da2005-12-05 19:42:22 +01008447/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008448static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8449 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008450{
8451 hda_nid_t nid;
8452 int err;
8453
8454 spec->multiout.num_dacs = 1; /* only use one dac */
8455 spec->multiout.dac_nids = spec->private_dac_nids;
8456 spec->multiout.dac_nids[0] = 2;
8457
8458 nid = cfg->line_out_pins[0];
8459 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008460 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8461 "Front Playback Volume",
8462 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8463 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008464 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008465 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8466 "Front Playback Switch",
8467 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8468 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008469 return err;
8470 }
8471
Takashi Iwai82bc9552006-03-21 11:24:42 +01008472 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008473 if (nid) {
8474 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008475 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8476 "Speaker Playback Volume",
8477 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8478 HDA_OUTPUT));
8479 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008480 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008481 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8482 "Speaker Playback Switch",
8483 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8484 HDA_OUTPUT));
8485 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008486 return err;
8487 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008488 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8489 "Speaker Playback Switch",
8490 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8491 HDA_OUTPUT));
8492 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008493 return err;
8494 }
8495 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008496 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008497 if (nid) {
8498 /* spec->multiout.hp_nid = 2; */
8499 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008500 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8501 "Headphone Playback Volume",
8502 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8503 HDA_OUTPUT));
8504 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008505 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008506 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8507 "Headphone Playback Switch",
8508 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8509 HDA_OUTPUT));
8510 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008511 return err;
8512 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008513 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8514 "Headphone Playback Switch",
8515 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8516 HDA_OUTPUT));
8517 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008518 return err;
8519 }
8520 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008521 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008522}
8523
8524/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008525#define alc262_auto_create_analog_input_ctls \
8526 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008527
8528/*
8529 * generic initialization of ADC, input mixers and output mixers
8530 */
8531static struct hda_verb alc262_volume_init_verbs[] = {
8532 /*
8533 * Unmute ADC0-2 and set the default input to mic-in
8534 */
8535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8537 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8541
Takashi Iwaicb53c622007-08-10 17:21:45 +02008542 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008543 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008544 * Note: PASD motherboards uses the Line In 2 as the input for
8545 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008546 */
8547 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008553
8554 /*
8555 * Set up output mixers (0x0c - 0x0f)
8556 */
8557 /* set vol=0 to output mixers */
8558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8561
8562 /* set up input amps for analog loopback */
8563 /* Amp Indices: DAC = 0, mixer = 1 */
8564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8567 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8570
8571 /* FIXME: use matrix-type input source selection */
8572 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8573 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8578 /* Input mixer2 */
8579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8580 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8581 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8582 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8583 /* Input mixer3 */
8584 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8588
8589 { }
8590};
8591
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008592static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8593 /*
8594 * Unmute ADC0-2 and set the default input to mic-in
8595 */
8596 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8598 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8599 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8600 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8601 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8602
Takashi Iwaicb53c622007-08-10 17:21:45 +02008603 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008604 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008605 * Note: PASD motherboards uses the Line In 2 as the input for
8606 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008607 */
8608 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008616
8617 /*
8618 * Set up output mixers (0x0c - 0x0e)
8619 */
8620 /* set vol=0 to output mixers */
8621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8623 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8624
8625 /* set up input amps for analog loopback */
8626 /* Amp Indices: DAC = 0, mixer = 1 */
8627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8633
8634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8636 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8637
8638 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8640
8641 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8643
8644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8645 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8646 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8648 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8649
8650 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8654 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8655 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8656
8657
8658 /* FIXME: use matrix-type input source selection */
8659 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8660 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8665 /* Input mixer2 */
8666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8670 /* Input mixer3 */
8671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8675
8676 { }
8677};
8678
Kailang Yangcd7509a2007-01-26 18:33:17 +01008679static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8680 /*
8681 * Unmute ADC0-2 and set the default input to mic-in
8682 */
8683 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8685 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8687 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8688 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8689
Takashi Iwaicb53c622007-08-10 17:21:45 +02008690 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008691 * mixer widget
8692 * Note: PASD motherboards uses the Line In 2 as the input for front
8693 * panel mic (mic 2)
8694 */
8695 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008704 /*
8705 * Set up output mixers (0x0c - 0x0e)
8706 */
8707 /* set vol=0 to output mixers */
8708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8710 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8711
8712 /* set up input amps for analog loopback */
8713 /* Amp Indices: DAC = 0, mixer = 1 */
8714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8720
8721
8722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8724 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8729
8730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8732
8733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8735
8736 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8738 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8740 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8741 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8742
8743 /* FIXME: use matrix-type input source selection */
8744 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8745 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8751 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8753 /* Input mixer2 */
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8757 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8758 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8759 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8760 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8761 /* Input mixer3 */
8762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8767 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8769
8770 { }
8771};
8772
Takashi Iwaicb53c622007-08-10 17:21:45 +02008773#ifdef CONFIG_SND_HDA_POWER_SAVE
8774#define alc262_loopbacks alc880_loopbacks
8775#endif
8776
Kailang Yangdf694da2005-12-05 19:42:22 +01008777/* pcm configuration: identiacal with ALC880 */
8778#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8779#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8780#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8781#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8782
8783/*
8784 * BIOS auto configuration
8785 */
8786static int alc262_parse_auto_config(struct hda_codec *codec)
8787{
8788 struct alc_spec *spec = codec->spec;
8789 int err;
8790 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8791
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008792 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8793 alc262_ignore);
8794 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008795 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008796 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008797 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008798 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8799 if (err < 0)
8800 return err;
8801 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8802 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008803 return err;
8804
8805 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8806
8807 if (spec->autocfg.dig_out_pin)
8808 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8809 if (spec->autocfg.dig_in_pin)
8810 spec->dig_in_nid = ALC262_DIGIN_NID;
8811
8812 if (spec->kctl_alloc)
8813 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8814
8815 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008816 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008817 spec->input_mux = &spec->private_imux;
8818
Takashi Iwai776e1842007-08-29 15:07:11 +02008819 err = alc_auto_add_mic_boost(codec);
8820 if (err < 0)
8821 return err;
8822
Kailang Yangdf694da2005-12-05 19:42:22 +01008823 return 1;
8824}
8825
8826#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8827#define alc262_auto_init_hp_out alc882_auto_init_hp_out
8828#define alc262_auto_init_analog_input alc882_auto_init_analog_input
8829
8830
8831/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008832static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008833{
Kailang Yangdf694da2005-12-05 19:42:22 +01008834 alc262_auto_init_multi_out(codec);
8835 alc262_auto_init_hp_out(codec);
8836 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008837}
8838
8839/*
8840 * configuration and preset
8841 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008842static const char *alc262_models[ALC262_MODEL_LAST] = {
8843 [ALC262_BASIC] = "basic",
8844 [ALC262_HIPPO] = "hippo",
8845 [ALC262_HIPPO_1] = "hippo_1",
8846 [ALC262_FUJITSU] = "fujitsu",
8847 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01008848 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01008849 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01008850 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008851 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02008852 [ALC262_BENQ_T31] = "benq-t31",
8853 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02008854 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008855 [ALC262_AUTO] = "auto",
8856};
8857
8858static struct snd_pci_quirk alc262_cfg_tbl[] = {
8859 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8860 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008861 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008862 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
8863 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008864 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01008865 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01008866 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01008867 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008868 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008869 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008870 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008871 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008872 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008873 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008874 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008875 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008876 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
8877 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8878 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008879 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
8880 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01008881 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008882 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008883 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008884 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8885 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8886 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008887 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008888 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008889 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02008890 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008891 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01008892 {}
8893};
8894
8895static struct alc_config_preset alc262_presets[] = {
8896 [ALC262_BASIC] = {
8897 .mixers = { alc262_base_mixer },
8898 .init_verbs = { alc262_init_verbs },
8899 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8900 .dac_nids = alc262_dac_nids,
8901 .hp_nid = 0x03,
8902 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8903 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01008904 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008905 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008906 [ALC262_HIPPO] = {
8907 .mixers = { alc262_base_mixer },
8908 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8909 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8910 .dac_nids = alc262_dac_nids,
8911 .hp_nid = 0x03,
8912 .dig_out_nid = ALC262_DIGOUT_NID,
8913 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8914 .channel_mode = alc262_modes,
8915 .input_mux = &alc262_capture_source,
8916 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008917 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008918 },
8919 [ALC262_HIPPO_1] = {
8920 .mixers = { alc262_hippo1_mixer },
8921 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8922 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8923 .dac_nids = alc262_dac_nids,
8924 .hp_nid = 0x02,
8925 .dig_out_nid = ALC262_DIGOUT_NID,
8926 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8927 .channel_mode = alc262_modes,
8928 .input_mux = &alc262_capture_source,
8929 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008930 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008931 },
Takashi Iwai834be882006-03-01 14:16:17 +01008932 [ALC262_FUJITSU] = {
8933 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008934 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
8935 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01008936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8937 .dac_nids = alc262_dac_nids,
8938 .hp_nid = 0x03,
8939 .dig_out_nid = ALC262_DIGOUT_NID,
8940 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8941 .channel_mode = alc262_modes,
8942 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008943 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008944 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008945 [ALC262_HP_BPC] = {
8946 .mixers = { alc262_HP_BPC_mixer },
8947 .init_verbs = { alc262_HP_BPC_init_verbs },
8948 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8949 .dac_nids = alc262_dac_nids,
8950 .hp_nid = 0x03,
8951 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8952 .channel_mode = alc262_modes,
8953 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008954 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008955 [ALC262_HP_BPC_D7000_WF] = {
8956 .mixers = { alc262_HP_BPC_WildWest_mixer },
8957 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8958 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8959 .dac_nids = alc262_dac_nids,
8960 .hp_nid = 0x03,
8961 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8962 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02008963 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008964 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008965 [ALC262_HP_BPC_D7000_WL] = {
8966 .mixers = { alc262_HP_BPC_WildWest_mixer,
8967 alc262_HP_BPC_WildWest_option_mixer },
8968 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8969 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8970 .dac_nids = alc262_dac_nids,
8971 .hp_nid = 0x03,
8972 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8973 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02008974 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008975 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008976 [ALC262_HP_TC_T5735] = {
8977 .mixers = { alc262_hp_t5735_mixer },
8978 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
8979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8980 .dac_nids = alc262_dac_nids,
8981 .hp_nid = 0x03,
8982 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8983 .channel_mode = alc262_modes,
8984 .input_mux = &alc262_capture_source,
8985 .unsol_event = alc262_hp_t5735_unsol_event,
8986 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01008987 },
8988 [ALC262_HP_RP5700] = {
8989 .mixers = { alc262_hp_rp5700_mixer },
8990 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
8991 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8992 .dac_nids = alc262_dac_nids,
8993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8994 .channel_mode = alc262_modes,
8995 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008996 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008997 [ALC262_BENQ_ED8] = {
8998 .mixers = { alc262_base_mixer },
8999 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9000 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9001 .dac_nids = alc262_dac_nids,
9002 .hp_nid = 0x03,
9003 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9004 .channel_mode = alc262_modes,
9005 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009006 },
Kailang Yang272a5272007-05-14 11:00:38 +02009007 [ALC262_SONY_ASSAMD] = {
9008 .mixers = { alc262_sony_mixer },
9009 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9010 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9011 .dac_nids = alc262_dac_nids,
9012 .hp_nid = 0x02,
9013 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9014 .channel_mode = alc262_modes,
9015 .input_mux = &alc262_capture_source,
9016 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009017 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009018 },
9019 [ALC262_BENQ_T31] = {
9020 .mixers = { alc262_benq_t31_mixer },
9021 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9022 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9023 .dac_nids = alc262_dac_nids,
9024 .hp_nid = 0x03,
9025 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9026 .channel_mode = alc262_modes,
9027 .input_mux = &alc262_capture_source,
9028 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009029 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009030 },
Tobin Davisf651b502007-10-26 12:40:47 +02009031 [ALC262_ULTRA] = {
9032 .mixers = { alc262_ultra_mixer },
9033 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9034 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9035 .dac_nids = alc262_dac_nids,
9036 .hp_nid = 0x03,
9037 .dig_out_nid = ALC262_DIGOUT_NID,
9038 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9039 .channel_mode = alc262_modes,
9040 .input_mux = &alc262_ultra_capture_source,
9041 .unsol_event = alc262_ultra_unsol_event,
9042 .init_hook = alc262_ultra_automute,
9043 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009044};
9045
9046static int patch_alc262(struct hda_codec *codec)
9047{
9048 struct alc_spec *spec;
9049 int board_config;
9050 int err;
9051
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009052 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009053 if (spec == NULL)
9054 return -ENOMEM;
9055
9056 codec->spec = spec;
9057#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009058 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9059 * under-run
9060 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009061 {
9062 int tmp;
9063 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9064 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9065 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9066 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9067 }
9068#endif
9069
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009070 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9071 alc262_models,
9072 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009073
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009074 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009075 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9076 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009077 board_config = ALC262_AUTO;
9078 }
9079
9080 if (board_config == ALC262_AUTO) {
9081 /* automatic parse from the BIOS config */
9082 err = alc262_parse_auto_config(codec);
9083 if (err < 0) {
9084 alc_free(codec);
9085 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009086 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009087 printk(KERN_INFO
9088 "hda_codec: Cannot set up configuration "
9089 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009090 board_config = ALC262_BASIC;
9091 }
9092 }
9093
9094 if (board_config != ALC262_AUTO)
9095 setup_preset(spec, &alc262_presets[board_config]);
9096
9097 spec->stream_name_analog = "ALC262 Analog";
9098 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9099 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9100
9101 spec->stream_name_digital = "ALC262 Digital";
9102 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9103 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9104
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009105 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009106 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009107 unsigned int wcap = get_wcaps(codec, 0x07);
9108
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009109 /* get type */
9110 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009111 if (wcap != AC_WID_AUD_IN) {
9112 spec->adc_nids = alc262_adc_nids_alt;
9113 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009114 spec->mixers[spec->num_mixers] =
9115 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009116 spec->num_mixers++;
9117 } else {
9118 spec->adc_nids = alc262_adc_nids;
9119 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9120 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9121 spec->num_mixers++;
9122 }
9123 }
9124
9125 codec->patch_ops = alc_patch_ops;
9126 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009127 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009128#ifdef CONFIG_SND_HDA_POWER_SAVE
9129 if (!spec->loopback.amplist)
9130 spec->loopback.amplist = alc262_loopbacks;
9131#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009132
Kailang Yangdf694da2005-12-05 19:42:22 +01009133 return 0;
9134}
9135
Kailang Yangdf694da2005-12-05 19:42:22 +01009136/*
Kailang Yanga361d842007-06-05 12:30:55 +02009137 * ALC268 channel source setting (2 channel)
9138 */
9139#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9140#define alc268_modes alc260_modes
9141
9142static hda_nid_t alc268_dac_nids[2] = {
9143 /* front, hp */
9144 0x02, 0x03
9145};
9146
9147static hda_nid_t alc268_adc_nids[2] = {
9148 /* ADC0-1 */
9149 0x08, 0x07
9150};
9151
9152static hda_nid_t alc268_adc_nids_alt[1] = {
9153 /* ADC0 */
9154 0x08
9155};
9156
9157static struct snd_kcontrol_new alc268_base_mixer[] = {
9158 /* output mixer control */
9159 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9160 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9164 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9165 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009166 { }
9167};
9168
Kailang Yangd1a991a2007-08-15 16:21:59 +02009169static struct hda_verb alc268_eapd_verbs[] = {
9170 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9171 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9172 { }
9173};
9174
Takashi Iwaid2738092007-08-16 14:59:45 +02009175/* Toshiba specific */
9176#define alc268_toshiba_automute alc262_hippo_automute
9177
9178static struct hda_verb alc268_toshiba_verbs[] = {
9179 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9180 { } /* end */
9181};
9182
9183/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009184/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009185static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9186 .ops = &snd_hda_bind_vol,
9187 .values = {
9188 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9189 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9190 0
9191 },
9192};
9193
Takashi Iwai889c4392007-08-23 18:56:52 +02009194/* mute/unmute internal speaker according to the hp jack and mute state */
9195static void alc268_acer_automute(struct hda_codec *codec, int force)
9196{
9197 struct alc_spec *spec = codec->spec;
9198 unsigned int mute;
9199
9200 if (force || !spec->sense_updated) {
9201 unsigned int present;
9202 present = snd_hda_codec_read(codec, 0x14, 0,
9203 AC_VERB_GET_PIN_SENSE, 0);
9204 spec->jack_present = (present & 0x80000000) != 0;
9205 spec->sense_updated = 1;
9206 }
9207 if (spec->jack_present)
9208 mute = HDA_AMP_MUTE; /* mute internal speaker */
9209 else /* unmute internal speaker if necessary */
9210 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9211 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9212 HDA_AMP_MUTE, mute);
9213}
9214
9215
9216/* bind hp and internal speaker mute (with plug check) */
9217static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9218 struct snd_ctl_elem_value *ucontrol)
9219{
9220 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9221 long *valp = ucontrol->value.integer.value;
9222 int change;
9223
9224 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9225 HDA_AMP_MUTE,
9226 valp[0] ? 0 : HDA_AMP_MUTE);
9227 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9228 HDA_AMP_MUTE,
9229 valp[1] ? 0 : HDA_AMP_MUTE);
9230 if (change)
9231 alc268_acer_automute(codec, 0);
9232 return change;
9233}
Takashi Iwaid2738092007-08-16 14:59:45 +02009234
9235static struct snd_kcontrol_new alc268_acer_mixer[] = {
9236 /* output mixer control */
9237 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9238 {
9239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9240 .name = "Master Playback Switch",
9241 .info = snd_hda_mixer_amp_switch_info,
9242 .get = snd_hda_mixer_amp_switch_get,
9243 .put = alc268_acer_master_sw_put,
9244 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9245 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009246 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9247 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9248 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009249 { }
9250};
9251
9252static struct hda_verb alc268_acer_verbs[] = {
9253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9255
9256 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9257 { }
9258};
9259
9260/* unsolicited event for HP jack sensing */
9261static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9262 unsigned int res)
9263{
Takashi Iwai889c4392007-08-23 18:56:52 +02009264 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009265 return;
9266 alc268_toshiba_automute(codec);
9267}
9268
9269static void alc268_acer_unsol_event(struct hda_codec *codec,
9270 unsigned int res)
9271{
Takashi Iwai889c4392007-08-23 18:56:52 +02009272 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009273 return;
9274 alc268_acer_automute(codec, 1);
9275}
9276
Takashi Iwai889c4392007-08-23 18:56:52 +02009277static void alc268_acer_init_hook(struct hda_codec *codec)
9278{
9279 alc268_acer_automute(codec, 1);
9280}
9281
Kailang Yanga361d842007-06-05 12:30:55 +02009282/*
9283 * generic initialization of ADC, input mixers and output mixers
9284 */
9285static struct hda_verb alc268_base_init_verbs[] = {
9286 /* Unmute DAC0-1 and set vol = 0 */
9287 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9288 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9289 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9290 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9291 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9292 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9293
9294 /*
9295 * Set up output mixers (0x0c - 0x0e)
9296 */
9297 /* set vol=0 to output mixers */
9298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9301 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9302
9303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9304 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9305
9306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9308 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9309 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9310 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9311 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9312 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9313 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9314
9315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9317 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9319 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9321 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9322 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9323
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009324 /* Unmute Selector 23h,24h and set the default input to mic-in */
9325
9326 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9328 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009330
Kailang Yanga361d842007-06-05 12:30:55 +02009331 { }
9332};
9333
9334/*
9335 * generic initialization of ADC, input mixers and output mixers
9336 */
9337static struct hda_verb alc268_volume_init_verbs[] = {
9338 /* set output DAC */
9339 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9340 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9341 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9342 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9343
9344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9347 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9348 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9349
9350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9352 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9353 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9354 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9355
9356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9359 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9360
9361 /* set PCBEEP vol = 0 */
9362 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9363
9364 { }
9365};
9366
9367#define alc268_mux_enum_info alc_mux_enum_info
9368#define alc268_mux_enum_get alc_mux_enum_get
9369
9370static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9371 struct snd_ctl_elem_value *ucontrol)
9372{
9373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9374 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009375
Kailang Yanga361d842007-06-05 12:30:55 +02009376 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9377 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9378 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009379
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009380 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9381 nid,
9382 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009383}
9384
9385static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9386 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9387 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9388 {
9389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9390 /* The multiple "Capture Source" controls confuse alsamixer
9391 * So call somewhat different..
9392 * FIXME: the controls appear in the "playback" view!
9393 */
9394 /* .name = "Capture Source", */
9395 .name = "Input Source",
9396 .count = 1,
9397 .info = alc268_mux_enum_info,
9398 .get = alc268_mux_enum_get,
9399 .put = alc268_mux_enum_put,
9400 },
9401 { } /* end */
9402};
9403
9404static struct snd_kcontrol_new alc268_capture_mixer[] = {
9405 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9406 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9407 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9408 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9409 {
9410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9411 /* The multiple "Capture Source" controls confuse alsamixer
9412 * So call somewhat different..
9413 * FIXME: the controls appear in the "playback" view!
9414 */
9415 /* .name = "Capture Source", */
9416 .name = "Input Source",
9417 .count = 2,
9418 .info = alc268_mux_enum_info,
9419 .get = alc268_mux_enum_get,
9420 .put = alc268_mux_enum_put,
9421 },
9422 { } /* end */
9423};
9424
9425static struct hda_input_mux alc268_capture_source = {
9426 .num_items = 4,
9427 .items = {
9428 { "Mic", 0x0 },
9429 { "Front Mic", 0x1 },
9430 { "Line", 0x2 },
9431 { "CD", 0x3 },
9432 },
9433};
9434
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009435#ifdef CONFIG_SND_DEBUG
9436static struct snd_kcontrol_new alc268_test_mixer[] = {
9437 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9438 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9439 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9441
9442 /* Volume widgets */
9443 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9444 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9445 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9446 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9447 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9448 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9449 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9450 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9451 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9452 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9453 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9454 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9455 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9456 HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),
9457 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9458 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9459 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9460 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9461
9462 /* Modes for retasking pin widgets */
9463 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9464 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9465 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9466 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9467
9468 /* Controls for GPIO pins, assuming they are configured as outputs */
9469 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9470 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9471 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9472 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9473
9474 /* Switches to allow the digital SPDIF output pin to be enabled.
9475 * The ALC268 does not have an SPDIF input.
9476 */
9477 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9478
9479 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9480 * this output to turn on an external amplifier.
9481 */
9482 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9483 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9484
9485 { } /* end */
9486};
9487#endif
9488
Kailang Yanga361d842007-06-05 12:30:55 +02009489/* create input playback/capture controls for the given pin */
9490static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9491 const char *ctlname, int idx)
9492{
9493 char name[32];
9494 int err;
9495
9496 sprintf(name, "%s Playback Volume", ctlname);
9497 if (nid == 0x14) {
9498 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9499 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9500 HDA_OUTPUT));
9501 if (err < 0)
9502 return err;
9503 } else if (nid == 0x15) {
9504 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9505 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9506 HDA_OUTPUT));
9507 if (err < 0)
9508 return err;
9509 } else
9510 return -1;
9511 sprintf(name, "%s Playback Switch", ctlname);
9512 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9513 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9514 if (err < 0)
9515 return err;
9516 return 0;
9517}
9518
9519/* add playback controls from the parsed DAC table */
9520static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9521 const struct auto_pin_cfg *cfg)
9522{
9523 hda_nid_t nid;
9524 int err;
9525
9526 spec->multiout.num_dacs = 2; /* only use one dac */
9527 spec->multiout.dac_nids = spec->private_dac_nids;
9528 spec->multiout.dac_nids[0] = 2;
9529 spec->multiout.dac_nids[1] = 3;
9530
9531 nid = cfg->line_out_pins[0];
9532 if (nid)
9533 alc268_new_analog_output(spec, nid, "Front", 0);
9534
9535 nid = cfg->speaker_pins[0];
9536 if (nid == 0x1d) {
9537 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9538 "Speaker Playback Volume",
9539 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9540 if (err < 0)
9541 return err;
9542 }
9543 nid = cfg->hp_pins[0];
9544 if (nid)
9545 alc268_new_analog_output(spec, nid, "Headphone", 0);
9546
9547 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9548 if (nid == 0x16) {
9549 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9550 "Mono Playback Switch",
9551 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9552 if (err < 0)
9553 return err;
9554 }
9555 return 0;
9556}
9557
9558/* create playback/capture controls for input pins */
9559static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9560 const struct auto_pin_cfg *cfg)
9561{
9562 struct hda_input_mux *imux = &spec->private_imux;
9563 int i, idx1;
9564
9565 for (i = 0; i < AUTO_PIN_LAST; i++) {
9566 switch(cfg->input_pins[i]) {
9567 case 0x18:
9568 idx1 = 0; /* Mic 1 */
9569 break;
9570 case 0x19:
9571 idx1 = 1; /* Mic 2 */
9572 break;
9573 case 0x1a:
9574 idx1 = 2; /* Line In */
9575 break;
9576 case 0x1c:
9577 idx1 = 3; /* CD */
9578 break;
9579 default:
9580 continue;
9581 }
9582 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9583 imux->items[imux->num_items].index = idx1;
9584 imux->num_items++;
9585 }
9586 return 0;
9587}
9588
9589static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9590{
9591 struct alc_spec *spec = codec->spec;
9592 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9593 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9594 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9595 unsigned int dac_vol1, dac_vol2;
9596
9597 if (speaker_nid) {
9598 snd_hda_codec_write(codec, speaker_nid, 0,
9599 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9600 snd_hda_codec_write(codec, 0x0f, 0,
9601 AC_VERB_SET_AMP_GAIN_MUTE,
9602 AMP_IN_UNMUTE(1));
9603 snd_hda_codec_write(codec, 0x10, 0,
9604 AC_VERB_SET_AMP_GAIN_MUTE,
9605 AMP_IN_UNMUTE(1));
9606 } else {
9607 snd_hda_codec_write(codec, 0x0f, 0,
9608 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9609 snd_hda_codec_write(codec, 0x10, 0,
9610 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9611 }
9612
9613 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9614 if (line_nid == 0x14)
9615 dac_vol2 = AMP_OUT_ZERO;
9616 else if (line_nid == 0x15)
9617 dac_vol1 = AMP_OUT_ZERO;
9618 if (hp_nid == 0x14)
9619 dac_vol2 = AMP_OUT_ZERO;
9620 else if (hp_nid == 0x15)
9621 dac_vol1 = AMP_OUT_ZERO;
9622 if (line_nid != 0x16 || hp_nid != 0x16 ||
9623 spec->autocfg.line_out_pins[1] != 0x16 ||
9624 spec->autocfg.line_out_pins[2] != 0x16)
9625 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9626
9627 snd_hda_codec_write(codec, 0x02, 0,
9628 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9629 snd_hda_codec_write(codec, 0x03, 0,
9630 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9631}
9632
9633/* pcm configuration: identiacal with ALC880 */
9634#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9635#define alc268_pcm_analog_capture alc880_pcm_analog_capture
9636#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9637
9638/*
9639 * BIOS auto configuration
9640 */
9641static int alc268_parse_auto_config(struct hda_codec *codec)
9642{
9643 struct alc_spec *spec = codec->spec;
9644 int err;
9645 static hda_nid_t alc268_ignore[] = { 0 };
9646
9647 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9648 alc268_ignore);
9649 if (err < 0)
9650 return err;
9651 if (!spec->autocfg.line_outs)
9652 return 0; /* can't find valid BIOS pin config */
9653
9654 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9655 if (err < 0)
9656 return err;
9657 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9658 if (err < 0)
9659 return err;
9660
9661 spec->multiout.max_channels = 2;
9662
9663 /* digital only support output */
9664 if (spec->autocfg.dig_out_pin)
9665 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9666
9667 if (spec->kctl_alloc)
9668 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9669
9670 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9671 spec->num_mux_defs = 1;
9672 spec->input_mux = &spec->private_imux;
9673
Takashi Iwai776e1842007-08-29 15:07:11 +02009674 err = alc_auto_add_mic_boost(codec);
9675 if (err < 0)
9676 return err;
9677
Kailang Yanga361d842007-06-05 12:30:55 +02009678 return 1;
9679}
9680
9681#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9682#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9683#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9684
9685/* init callback for auto-configuration model -- overriding the default init */
9686static void alc268_auto_init(struct hda_codec *codec)
9687{
9688 alc268_auto_init_multi_out(codec);
9689 alc268_auto_init_hp_out(codec);
9690 alc268_auto_init_mono_speaker_out(codec);
9691 alc268_auto_init_analog_input(codec);
9692}
9693
9694/*
9695 * configuration and preset
9696 */
9697static const char *alc268_models[ALC268_MODEL_LAST] = {
9698 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009699 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009700 [ALC268_ACER] = "acer",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009701#ifdef CONFIG_SND_DEBUG
9702 [ALC268_TEST] = "test",
9703#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009704 [ALC268_AUTO] = "auto",
9705};
9706
9707static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009708 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9709 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9710 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +02009711 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009712 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009713 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009714 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009715 {}
9716};
9717
9718static struct alc_config_preset alc268_presets[] = {
9719 [ALC268_3ST] = {
9720 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9721 .init_verbs = { alc268_base_init_verbs },
9722 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9723 .dac_nids = alc268_dac_nids,
9724 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9725 .adc_nids = alc268_adc_nids_alt,
9726 .hp_nid = 0x03,
9727 .dig_out_nid = ALC268_DIGOUT_NID,
9728 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9729 .channel_mode = alc268_modes,
9730 .input_mux = &alc268_capture_source,
9731 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009732 [ALC268_TOSHIBA] = {
9733 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009734 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9735 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009736 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9737 .dac_nids = alc268_dac_nids,
9738 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9739 .adc_nids = alc268_adc_nids_alt,
9740 .hp_nid = 0x03,
9741 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9742 .channel_mode = alc268_modes,
9743 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009744 .unsol_event = alc268_toshiba_unsol_event,
9745 .init_hook = alc268_toshiba_automute,
9746 },
9747 [ALC268_ACER] = {
9748 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9749 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9750 alc268_acer_verbs },
9751 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9752 .dac_nids = alc268_dac_nids,
9753 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9754 .adc_nids = alc268_adc_nids_alt,
9755 .hp_nid = 0x02,
9756 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9757 .channel_mode = alc268_modes,
9758 .input_mux = &alc268_capture_source,
9759 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009760 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009761 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009762#ifdef CONFIG_SND_DEBUG
9763 [ALC268_TEST] = {
9764 .mixers = { alc268_test_mixer, alc268_capture_mixer },
9765 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9766 alc268_volume_init_verbs },
9767 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9768 .dac_nids = alc268_dac_nids,
9769 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9770 .adc_nids = alc268_adc_nids_alt,
9771 .hp_nid = 0x03,
9772 .dig_out_nid = ALC268_DIGOUT_NID,
9773 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9774 .channel_mode = alc268_modes,
9775 .input_mux = &alc268_capture_source,
9776 },
9777#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009778};
9779
9780static int patch_alc268(struct hda_codec *codec)
9781{
9782 struct alc_spec *spec;
9783 int board_config;
9784 int err;
9785
9786 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9787 if (spec == NULL)
9788 return -ENOMEM;
9789
9790 codec->spec = spec;
9791
9792 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9793 alc268_models,
9794 alc268_cfg_tbl);
9795
9796 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9797 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9798 "trying auto-probe from BIOS...\n");
9799 board_config = ALC268_AUTO;
9800 }
9801
9802 if (board_config == ALC268_AUTO) {
9803 /* automatic parse from the BIOS config */
9804 err = alc268_parse_auto_config(codec);
9805 if (err < 0) {
9806 alc_free(codec);
9807 return err;
9808 } else if (!err) {
9809 printk(KERN_INFO
9810 "hda_codec: Cannot set up configuration "
9811 "from BIOS. Using base mode...\n");
9812 board_config = ALC268_3ST;
9813 }
9814 }
9815
9816 if (board_config != ALC268_AUTO)
9817 setup_preset(spec, &alc268_presets[board_config]);
9818
9819 spec->stream_name_analog = "ALC268 Analog";
9820 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9821 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9822
9823 spec->stream_name_digital = "ALC268 Digital";
9824 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9825
9826 if (board_config == ALC268_AUTO) {
9827 if (!spec->adc_nids && spec->input_mux) {
9828 /* check whether NID 0x07 is valid */
9829 unsigned int wcap = get_wcaps(codec, 0x07);
9830
9831 /* get type */
9832 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9833 if (wcap != AC_WID_AUD_IN) {
9834 spec->adc_nids = alc268_adc_nids_alt;
9835 spec->num_adc_nids =
9836 ARRAY_SIZE(alc268_adc_nids_alt);
9837 spec->mixers[spec->num_mixers] =
9838 alc268_capture_alt_mixer;
9839 spec->num_mixers++;
9840 } else {
9841 spec->adc_nids = alc268_adc_nids;
9842 spec->num_adc_nids =
9843 ARRAY_SIZE(alc268_adc_nids);
9844 spec->mixers[spec->num_mixers] =
9845 alc268_capture_mixer;
9846 spec->num_mixers++;
9847 }
9848 }
9849 }
9850 codec->patch_ops = alc_patch_ops;
9851 if (board_config == ALC268_AUTO)
9852 spec->init_hook = alc268_auto_init;
9853
9854 return 0;
9855}
9856
9857/*
Kailang Yangf6a92242007-12-13 16:52:54 +01009858 * ALC269 channel source setting (2 channel)
9859 */
9860#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
9861
9862#define alc269_dac_nids alc260_dac_nids
9863
9864static hda_nid_t alc269_adc_nids[1] = {
9865 /* ADC1 */
9866 0x07,
9867};
9868
9869#define alc269_modes alc260_modes
9870#define alc269_capture_source alc880_lg_lw_capture_source
9871
9872static struct snd_kcontrol_new alc269_base_mixer[] = {
9873 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9874 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9880 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9882 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9884 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
9885 { } /* end */
9886};
9887
9888/* capture mixer elements */
9889static struct snd_kcontrol_new alc269_capture_mixer[] = {
9890 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9891 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9892 {
9893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9894 /* The multiple "Capture Source" controls confuse alsamixer
9895 * So call somewhat different..
9896 * FIXME: the controls appear in the "playback" view!
9897 */
9898 /* .name = "Capture Source", */
9899 .name = "Input Source",
9900 .count = 1,
9901 .info = alc_mux_enum_info,
9902 .get = alc_mux_enum_get,
9903 .put = alc_mux_enum_put,
9904 },
9905 { } /* end */
9906};
9907
9908/*
9909 * generic initialization of ADC, input mixers and output mixers
9910 */
9911static struct hda_verb alc269_init_verbs[] = {
9912 /*
9913 * Unmute ADC0 and set the default input to mic-in
9914 */
9915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9916
9917 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
9918 * analog-loopback mixer widget
9919 * Note: PASD motherboards uses the Line In 2 as the input for
9920 * front panel mic (mic 2)
9921 */
9922 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9928
9929 /*
9930 * Set up output mixers (0x0c - 0x0e)
9931 */
9932 /* set vol=0 to output mixers */
9933 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9934 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9935
9936 /* set up input amps for analog loopback */
9937 /* Amp Indices: DAC = 0, mixer = 1 */
9938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9940 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9942 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9944
9945 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9947 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9948 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9949 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9950 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9952
9953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9955 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9957 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9960
9961 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9963
9964 /* FIXME: use matrix-type input source selection */
9965 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
9966 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9971
9972 /* set EAPD */
9973 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9974 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9975 { }
9976};
9977
9978/* add playback controls from the parsed DAC table */
9979static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
9980 const struct auto_pin_cfg *cfg)
9981{
9982 hda_nid_t nid;
9983 int err;
9984
9985 spec->multiout.num_dacs = 1; /* only use one dac */
9986 spec->multiout.dac_nids = spec->private_dac_nids;
9987 spec->multiout.dac_nids[0] = 2;
9988
9989 nid = cfg->line_out_pins[0];
9990 if (nid) {
9991 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9992 "Front Playback Volume",
9993 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
9994 if (err < 0)
9995 return err;
9996 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9997 "Front Playback Switch",
9998 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9999 if (err < 0)
10000 return err;
10001 }
10002
10003 nid = cfg->speaker_pins[0];
10004 if (nid) {
10005 if (!cfg->line_out_pins[0]) {
10006 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10007 "Speaker Playback Volume",
10008 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10009 HDA_OUTPUT));
10010 if (err < 0)
10011 return err;
10012 }
10013 if (nid == 0x16) {
10014 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10015 "Speaker Playback Switch",
10016 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10017 HDA_OUTPUT));
10018 if (err < 0)
10019 return err;
10020 } else {
10021 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10022 "Speaker Playback Switch",
10023 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10024 HDA_OUTPUT));
10025 if (err < 0)
10026 return err;
10027 }
10028 }
10029 nid = cfg->hp_pins[0];
10030 if (nid) {
10031 /* spec->multiout.hp_nid = 2; */
10032 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10033 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10034 "Headphone Playback Volume",
10035 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10036 HDA_OUTPUT));
10037 if (err < 0)
10038 return err;
10039 }
10040 if (nid == 0x16) {
10041 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10042 "Headphone Playback Switch",
10043 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10044 HDA_OUTPUT));
10045 if (err < 0)
10046 return err;
10047 } else {
10048 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10049 "Headphone Playback Switch",
10050 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10051 HDA_OUTPUT));
10052 if (err < 0)
10053 return err;
10054 }
10055 }
10056 return 0;
10057}
10058
10059#define alc269_auto_create_analog_input_ctls \
10060 alc880_auto_create_analog_input_ctls
10061
10062#ifdef CONFIG_SND_HDA_POWER_SAVE
10063#define alc269_loopbacks alc880_loopbacks
10064#endif
10065
10066/* pcm configuration: identiacal with ALC880 */
10067#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10068#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10069#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10070#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10071
10072/*
10073 * BIOS auto configuration
10074 */
10075static int alc269_parse_auto_config(struct hda_codec *codec)
10076{
10077 struct alc_spec *spec = codec->spec;
10078 int err;
10079 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10080
10081 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10082 alc269_ignore);
10083 if (err < 0)
10084 return err;
10085
10086 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10087 if (err < 0)
10088 return err;
10089 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10090 if (err < 0)
10091 return err;
10092
10093 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10094
10095 if (spec->autocfg.dig_out_pin)
10096 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10097
10098 if (spec->kctl_alloc)
10099 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10100
10101 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10102 spec->num_mux_defs = 1;
10103 spec->input_mux = &spec->private_imux;
10104
10105 err = alc_auto_add_mic_boost(codec);
10106 if (err < 0)
10107 return err;
10108
10109 return 1;
10110}
10111
10112#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10113#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10114#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10115
10116
10117/* init callback for auto-configuration model -- overriding the default init */
10118static void alc269_auto_init(struct hda_codec *codec)
10119{
10120 alc269_auto_init_multi_out(codec);
10121 alc269_auto_init_hp_out(codec);
10122 alc269_auto_init_analog_input(codec);
10123}
10124
10125/*
10126 * configuration and preset
10127 */
10128static const char *alc269_models[ALC269_MODEL_LAST] = {
10129 [ALC269_BASIC] = "basic",
10130};
10131
10132static struct snd_pci_quirk alc269_cfg_tbl[] = {
10133 {}
10134};
10135
10136static struct alc_config_preset alc269_presets[] = {
10137 [ALC269_BASIC] = {
10138 .mixers = { alc269_base_mixer },
10139 .init_verbs = { alc269_init_verbs },
10140 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10141 .dac_nids = alc269_dac_nids,
10142 .hp_nid = 0x03,
10143 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10144 .channel_mode = alc269_modes,
10145 .input_mux = &alc269_capture_source,
10146 },
10147};
10148
10149static int patch_alc269(struct hda_codec *codec)
10150{
10151 struct alc_spec *spec;
10152 int board_config;
10153 int err;
10154
10155 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10156 if (spec == NULL)
10157 return -ENOMEM;
10158
10159 codec->spec = spec;
10160
10161 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10162 alc269_models,
10163 alc269_cfg_tbl);
10164
10165 if (board_config < 0) {
10166 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10167 "trying auto-probe from BIOS...\n");
10168 board_config = ALC269_AUTO;
10169 }
10170
10171 if (board_config == ALC269_AUTO) {
10172 /* automatic parse from the BIOS config */
10173 err = alc269_parse_auto_config(codec);
10174 if (err < 0) {
10175 alc_free(codec);
10176 return err;
10177 } else if (!err) {
10178 printk(KERN_INFO
10179 "hda_codec: Cannot set up configuration "
10180 "from BIOS. Using base mode...\n");
10181 board_config = ALC269_BASIC;
10182 }
10183 }
10184
10185 if (board_config != ALC269_AUTO)
10186 setup_preset(spec, &alc269_presets[board_config]);
10187
10188 spec->stream_name_analog = "ALC269 Analog";
10189 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10190 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10191
10192 spec->stream_name_digital = "ALC269 Digital";
10193 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10194 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10195
10196 spec->adc_nids = alc269_adc_nids;
10197 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10198 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10199 spec->num_mixers++;
10200
10201 codec->patch_ops = alc_patch_ops;
10202 if (board_config == ALC269_AUTO)
10203 spec->init_hook = alc269_auto_init;
10204#ifdef CONFIG_SND_HDA_POWER_SAVE
10205 if (!spec->loopback.amplist)
10206 spec->loopback.amplist = alc269_loopbacks;
10207#endif
10208
10209 return 0;
10210}
10211
10212/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010213 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10214 */
10215
10216/*
10217 * set the path ways for 2 channel output
10218 * need to set the codec line out and mic 1 pin widgets to inputs
10219 */
10220static struct hda_verb alc861_threestack_ch2_init[] = {
10221 /* set pin widget 1Ah (line in) for input */
10222 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010223 /* set pin widget 18h (mic1/2) for input, for mic also enable
10224 * the vref
10225 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010226 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10227
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010228 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10229#if 0
10230 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10231 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10232#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010233 { } /* end */
10234};
10235/*
10236 * 6ch mode
10237 * need to set the codec line out and mic 1 pin widgets to outputs
10238 */
10239static struct hda_verb alc861_threestack_ch6_init[] = {
10240 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10241 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10242 /* set pin widget 18h (mic1) for output (CLFE)*/
10243 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10244
10245 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010246 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010247
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010248 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10249#if 0
10250 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10251 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10252#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010253 { } /* end */
10254};
10255
10256static struct hda_channel_mode alc861_threestack_modes[2] = {
10257 { 2, alc861_threestack_ch2_init },
10258 { 6, alc861_threestack_ch6_init },
10259};
Takashi Iwai22309c32006-08-09 16:57:28 +020010260/* Set mic1 as input and unmute the mixer */
10261static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10262 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10263 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10264 { } /* end */
10265};
10266/* Set mic1 as output and mute mixer */
10267static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10268 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10269 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10270 { } /* end */
10271};
10272
10273static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10274 { 2, alc861_uniwill_m31_ch2_init },
10275 { 4, alc861_uniwill_m31_ch4_init },
10276};
Kailang Yangdf694da2005-12-05 19:42:22 +010010277
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010278/* Set mic1 and line-in as input and unmute the mixer */
10279static struct hda_verb alc861_asus_ch2_init[] = {
10280 /* set pin widget 1Ah (line in) for input */
10281 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010282 /* set pin widget 18h (mic1/2) for input, for mic also enable
10283 * the vref
10284 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010285 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10286
10287 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10288#if 0
10289 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10291#endif
10292 { } /* end */
10293};
10294/* Set mic1 nad line-in as output and mute mixer */
10295static struct hda_verb alc861_asus_ch6_init[] = {
10296 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10297 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10298 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10299 /* set pin widget 18h (mic1) for output (CLFE)*/
10300 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10301 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10302 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10303 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10304
10305 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10306#if 0
10307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10308 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10309#endif
10310 { } /* end */
10311};
10312
10313static struct hda_channel_mode alc861_asus_modes[2] = {
10314 { 2, alc861_asus_ch2_init },
10315 { 6, alc861_asus_ch6_init },
10316};
10317
Kailang Yangdf694da2005-12-05 19:42:22 +010010318/* patch-ALC861 */
10319
10320static struct snd_kcontrol_new alc861_base_mixer[] = {
10321 /* output mixer control */
10322 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10323 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10324 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10325 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10326 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10327
10328 /*Input mixer control */
10329 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10330 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10331 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10332 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10333 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10334 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10336 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10337 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010339
Kailang Yangdf694da2005-12-05 19:42:22 +010010340 /* Capture mixer control */
10341 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10342 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10343 {
10344 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10345 .name = "Capture Source",
10346 .count = 1,
10347 .info = alc_mux_enum_info,
10348 .get = alc_mux_enum_get,
10349 .put = alc_mux_enum_put,
10350 },
10351 { } /* end */
10352};
10353
10354static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10355 /* output mixer control */
10356 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10357 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10358 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10359 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10360 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10361
10362 /* Input mixer control */
10363 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10364 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10365 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10366 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10367 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10368 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10370 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010373
Kailang Yangdf694da2005-12-05 19:42:22 +010010374 /* Capture mixer control */
10375 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10376 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10377 {
10378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10379 .name = "Capture Source",
10380 .count = 1,
10381 .info = alc_mux_enum_info,
10382 .get = alc_mux_enum_get,
10383 .put = alc_mux_enum_put,
10384 },
10385 {
10386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10387 .name = "Channel Mode",
10388 .info = alc_ch_mode_info,
10389 .get = alc_ch_mode_get,
10390 .put = alc_ch_mode_put,
10391 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10392 },
10393 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010394};
10395
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010396static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010397 /* output mixer control */
10398 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10400 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10401
10402 /*Capture mixer control */
10403 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10404 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10405 {
10406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10407 .name = "Capture Source",
10408 .count = 1,
10409 .info = alc_mux_enum_info,
10410 .get = alc_mux_enum_get,
10411 .put = alc_mux_enum_put,
10412 },
10413
10414 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010415};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010416
Takashi Iwai22309c32006-08-09 16:57:28 +020010417static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10418 /* output mixer control */
10419 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10420 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10421 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10422 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10423 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10424
10425 /* Input mixer control */
10426 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10427 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10428 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10429 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10430 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10431 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10433 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010436
Takashi Iwai22309c32006-08-09 16:57:28 +020010437 /* Capture mixer control */
10438 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10439 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10440 {
10441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10442 .name = "Capture Source",
10443 .count = 1,
10444 .info = alc_mux_enum_info,
10445 .get = alc_mux_enum_get,
10446 .put = alc_mux_enum_put,
10447 },
10448 {
10449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10450 .name = "Channel Mode",
10451 .info = alc_ch_mode_info,
10452 .get = alc_ch_mode_get,
10453 .put = alc_ch_mode_put,
10454 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10455 },
10456 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010457};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010458
10459static struct snd_kcontrol_new alc861_asus_mixer[] = {
10460 /* output mixer control */
10461 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10462 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10463 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10464 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10465 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10466
10467 /* Input mixer control */
10468 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10469 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10470 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10471 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10472 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10473 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10475 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10476 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10478
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010479 /* Capture mixer control */
10480 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10481 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10482 {
10483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10484 .name = "Capture Source",
10485 .count = 1,
10486 .info = alc_mux_enum_info,
10487 .get = alc_mux_enum_get,
10488 .put = alc_mux_enum_put,
10489 },
10490 {
10491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10492 .name = "Channel Mode",
10493 .info = alc_ch_mode_info,
10494 .get = alc_ch_mode_get,
10495 .put = alc_ch_mode_put,
10496 .private_value = ARRAY_SIZE(alc861_asus_modes),
10497 },
10498 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010499};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010500
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010501/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010502static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010503 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10504 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10505 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10506 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10507 { }
10508};
10509
Kailang Yangdf694da2005-12-05 19:42:22 +010010510/*
10511 * generic initialization of ADC, input mixers and output mixers
10512 */
10513static struct hda_verb alc861_base_init_verbs[] = {
10514 /*
10515 * Unmute ADC0 and set the default input to mic-in
10516 */
10517 /* port-A for surround (rear panel) */
10518 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10519 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10520 /* port-B for mic-in (rear panel) with vref */
10521 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10522 /* port-C for line-in (rear panel) */
10523 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10524 /* port-D for Front */
10525 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10526 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10527 /* port-E for HP out (front panel) */
10528 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10529 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010530 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010531 /* port-F for mic-in (front panel) with vref */
10532 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10533 /* port-G for CLFE (rear panel) */
10534 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10535 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10536 /* port-H for side (rear panel) */
10537 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10538 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10539 /* CD-in */
10540 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10541 /* route front mic to ADC1*/
10542 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10544
10545 /* Unmute DAC0~3 & spdif out*/
10546 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10547 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10548 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10549 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10551
10552 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10553 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10554 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10555 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10556 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10557
10558 /* Unmute Stereo Mixer 15 */
10559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010563
10564 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10565 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10566 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10567 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010572 /* hp used DAC 3 (Front) */
10573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010574 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10575
10576 { }
10577};
10578
10579static struct hda_verb alc861_threestack_init_verbs[] = {
10580 /*
10581 * Unmute ADC0 and set the default input to mic-in
10582 */
10583 /* port-A for surround (rear panel) */
10584 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10585 /* port-B for mic-in (rear panel) with vref */
10586 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10587 /* port-C for line-in (rear panel) */
10588 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10589 /* port-D for Front */
10590 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10591 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10592 /* port-E for HP out (front panel) */
10593 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10594 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010595 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010596 /* port-F for mic-in (front panel) with vref */
10597 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10598 /* port-G for CLFE (rear panel) */
10599 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10600 /* port-H for side (rear panel) */
10601 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10602 /* CD-in */
10603 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10604 /* route front mic to ADC1*/
10605 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10607 /* Unmute DAC0~3 & spdif out*/
10608 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10609 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10610 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10611 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10613
10614 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10615 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10616 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10617 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10618 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10619
10620 /* Unmute Stereo Mixer 15 */
10621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010625
10626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10627 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10628 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10629 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10632 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010634 /* hp used DAC 3 (Front) */
10635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010636 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10637 { }
10638};
Takashi Iwai22309c32006-08-09 16:57:28 +020010639
10640static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10641 /*
10642 * Unmute ADC0 and set the default input to mic-in
10643 */
10644 /* port-A for surround (rear panel) */
10645 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10646 /* port-B for mic-in (rear panel) with vref */
10647 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10648 /* port-C for line-in (rear panel) */
10649 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10650 /* port-D for Front */
10651 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10652 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10653 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010654 /* this has to be set to VREF80 */
10655 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010656 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010657 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010658 /* port-F for mic-in (front panel) with vref */
10659 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10660 /* port-G for CLFE (rear panel) */
10661 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10662 /* port-H for side (rear panel) */
10663 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10664 /* CD-in */
10665 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10666 /* route front mic to ADC1*/
10667 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10668 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10669 /* Unmute DAC0~3 & spdif out*/
10670 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10671 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10672 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10673 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10675
10676 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10677 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10678 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10679 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10680 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10681
10682 /* Unmute Stereo Mixer 15 */
10683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020010687
10688 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10689 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10690 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10691 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10692 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10694 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010696 /* hp used DAC 3 (Front) */
10697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020010698 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10699 { }
10700};
10701
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010702static struct hda_verb alc861_asus_init_verbs[] = {
10703 /*
10704 * Unmute ADC0 and set the default input to mic-in
10705 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010706 /* port-A for surround (rear panel)
10707 * according to codec#0 this is the HP jack
10708 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010709 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10710 /* route front PCM to HP */
10711 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10712 /* port-B for mic-in (rear panel) with vref */
10713 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10714 /* port-C for line-in (rear panel) */
10715 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10716 /* port-D for Front */
10717 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10718 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10719 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010720 /* this has to be set to VREF80 */
10721 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010722 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010723 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010724 /* port-F for mic-in (front panel) with vref */
10725 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10726 /* port-G for CLFE (rear panel) */
10727 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10728 /* port-H for side (rear panel) */
10729 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10730 /* CD-in */
10731 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10732 /* route front mic to ADC1*/
10733 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10734 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10735 /* Unmute DAC0~3 & spdif out*/
10736 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10737 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10738 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10739 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10741 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10742 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10743 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10744 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10745 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10746
10747 /* Unmute Stereo Mixer 15 */
10748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010752
10753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10754 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10755 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10756 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10758 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010761 /* hp used DAC 3 (Front) */
10762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10764 { }
10765};
10766
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010767/* additional init verbs for ASUS laptops */
10768static struct hda_verb alc861_asus_laptop_init_verbs[] = {
10769 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
10770 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
10771 { }
10772};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010773
Kailang Yangdf694da2005-12-05 19:42:22 +010010774/*
10775 * generic initialization of ADC, input mixers and output mixers
10776 */
10777static struct hda_verb alc861_auto_init_verbs[] = {
10778 /*
10779 * Unmute ADC0 and set the default input to mic-in
10780 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010781 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010010782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10783
10784 /* Unmute DAC0~3 & spdif out*/
10785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10787 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10788 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10790
10791 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10792 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10793 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10794 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10795 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10796
10797 /* Unmute Stereo Mixer 15 */
10798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
10802
10803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10804 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10805 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10806 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10807 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10808 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10809 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10811
10812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10813 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010814 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010816 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10817 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010818 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10819 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010820
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010821 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010822
10823 { }
10824};
10825
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010826static struct hda_verb alc861_toshiba_init_verbs[] = {
10827 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010828
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010829 { }
10830};
10831
10832/* toggle speaker-output according to the hp-jack state */
10833static void alc861_toshiba_automute(struct hda_codec *codec)
10834{
10835 unsigned int present;
10836
10837 present = snd_hda_codec_read(codec, 0x0f, 0,
10838 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010839 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
10840 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10841 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
10842 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010843}
10844
10845static void alc861_toshiba_unsol_event(struct hda_codec *codec,
10846 unsigned int res)
10847{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010848 if ((res >> 26) == ALC880_HP_EVENT)
10849 alc861_toshiba_automute(codec);
10850}
10851
Kailang Yangdf694da2005-12-05 19:42:22 +010010852/* pcm configuration: identiacal with ALC880 */
10853#define alc861_pcm_analog_playback alc880_pcm_analog_playback
10854#define alc861_pcm_analog_capture alc880_pcm_analog_capture
10855#define alc861_pcm_digital_playback alc880_pcm_digital_playback
10856#define alc861_pcm_digital_capture alc880_pcm_digital_capture
10857
10858
10859#define ALC861_DIGOUT_NID 0x07
10860
10861static struct hda_channel_mode alc861_8ch_modes[1] = {
10862 { 8, NULL }
10863};
10864
10865static hda_nid_t alc861_dac_nids[4] = {
10866 /* front, surround, clfe, side */
10867 0x03, 0x06, 0x05, 0x04
10868};
10869
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010870static hda_nid_t alc660_dac_nids[3] = {
10871 /* front, clfe, surround */
10872 0x03, 0x05, 0x06
10873};
10874
Kailang Yangdf694da2005-12-05 19:42:22 +010010875static hda_nid_t alc861_adc_nids[1] = {
10876 /* ADC0-2 */
10877 0x08,
10878};
10879
10880static struct hda_input_mux alc861_capture_source = {
10881 .num_items = 5,
10882 .items = {
10883 { "Mic", 0x0 },
10884 { "Front Mic", 0x3 },
10885 { "Line", 0x1 },
10886 { "CD", 0x4 },
10887 { "Mixer", 0x5 },
10888 },
10889};
10890
10891/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010892static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
10893 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010894{
10895 int i;
10896 hda_nid_t nid;
10897
10898 spec->multiout.dac_nids = spec->private_dac_nids;
10899 for (i = 0; i < cfg->line_outs; i++) {
10900 nid = cfg->line_out_pins[i];
10901 if (nid) {
10902 if (i >= ARRAY_SIZE(alc861_dac_nids))
10903 continue;
10904 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
10905 }
10906 }
10907 spec->multiout.num_dacs = cfg->line_outs;
10908 return 0;
10909}
10910
10911/* add playback controls from the parsed DAC table */
10912static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
10913 const struct auto_pin_cfg *cfg)
10914{
10915 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010916 static const char *chname[4] = {
10917 "Front", "Surround", NULL /*CLFE*/, "Side"
10918 };
Kailang Yangdf694da2005-12-05 19:42:22 +010010919 hda_nid_t nid;
10920 int i, idx, err;
10921
10922 for (i = 0; i < cfg->line_outs; i++) {
10923 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010924 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010010925 continue;
10926 if (nid == 0x05) {
10927 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010928 err = add_control(spec, ALC_CTL_BIND_MUTE,
10929 "Center Playback Switch",
10930 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10931 HDA_OUTPUT));
10932 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010933 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010934 err = add_control(spec, ALC_CTL_BIND_MUTE,
10935 "LFE Playback Switch",
10936 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10937 HDA_OUTPUT));
10938 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010939 return err;
10940 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010941 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
10942 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010010943 if (nid == alc861_dac_nids[idx])
10944 break;
10945 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010946 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10947 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10948 HDA_OUTPUT));
10949 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010950 return err;
10951 }
10952 }
10953 return 0;
10954}
10955
10956static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
10957{
10958 int err;
10959 hda_nid_t nid;
10960
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010961 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010010962 return 0;
10963
10964 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
10965 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010966 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10967 "Headphone Playback Switch",
10968 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10969 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010970 return err;
10971 spec->multiout.hp_nid = nid;
10972 }
10973 return 0;
10974}
10975
10976/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010977static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
10978 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010979{
Kailang Yangdf694da2005-12-05 19:42:22 +010010980 struct hda_input_mux *imux = &spec->private_imux;
10981 int i, err, idx, idx1;
10982
10983 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010984 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010985 case 0x0c:
10986 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010987 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010988 break;
10989 case 0x0f:
10990 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010991 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010992 break;
10993 case 0x0d:
10994 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010995 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010996 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010997 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010010998 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010999 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011000 break;
11001 case 0x11:
11002 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011003 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011004 break;
11005 default:
11006 continue;
11007 }
11008
Takashi Iwai4a471b72005-12-07 13:56:29 +010011009 err = new_analog_input(spec, cfg->input_pins[i],
11010 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011011 if (err < 0)
11012 return err;
11013
Takashi Iwai4a471b72005-12-07 13:56:29 +010011014 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011015 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011016 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011017 }
11018 return 0;
11019}
11020
11021static struct snd_kcontrol_new alc861_capture_mixer[] = {
11022 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11023 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11024
11025 {
11026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11027 /* The multiple "Capture Source" controls confuse alsamixer
11028 * So call somewhat different..
11029 *FIXME: the controls appear in the "playback" view!
11030 */
11031 /* .name = "Capture Source", */
11032 .name = "Input Source",
11033 .count = 1,
11034 .info = alc_mux_enum_info,
11035 .get = alc_mux_enum_get,
11036 .put = alc_mux_enum_put,
11037 },
11038 { } /* end */
11039};
11040
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011041static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11042 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011043 int pin_type, int dac_idx)
11044{
11045 /* set as output */
11046
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011047 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11048 pin_type);
11049 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11050 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011051
11052}
11053
11054static void alc861_auto_init_multi_out(struct hda_codec *codec)
11055{
11056 struct alc_spec *spec = codec->spec;
11057 int i;
11058
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011059 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 for (i = 0; i < spec->autocfg.line_outs; i++) {
11061 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011062 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011063 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011064 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011065 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011066 }
11067}
11068
11069static void alc861_auto_init_hp_out(struct hda_codec *codec)
11070{
11071 struct alc_spec *spec = codec->spec;
11072 hda_nid_t pin;
11073
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011074 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011075 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011076 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11077 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011078}
11079
11080static void alc861_auto_init_analog_input(struct hda_codec *codec)
11081{
11082 struct alc_spec *spec = codec->spec;
11083 int i;
11084
11085 for (i = 0; i < AUTO_PIN_LAST; i++) {
11086 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011087 if (nid >= 0x0c && nid <= 0x11) {
11088 snd_hda_codec_write(codec, nid, 0,
11089 AC_VERB_SET_PIN_WIDGET_CONTROL,
11090 i <= AUTO_PIN_FRONT_MIC ?
11091 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011092 }
11093 }
11094}
11095
11096/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011097/* return 1 if successful, 0 if the proper config is not found,
11098 * or a negative error code
11099 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011100static int alc861_parse_auto_config(struct hda_codec *codec)
11101{
11102 struct alc_spec *spec = codec->spec;
11103 int err;
11104 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11105
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011106 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11107 alc861_ignore);
11108 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011109 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011110 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011111 return 0; /* can't find valid BIOS pin config */
11112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011113 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11114 if (err < 0)
11115 return err;
11116 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11117 if (err < 0)
11118 return err;
11119 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11120 if (err < 0)
11121 return err;
11122 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11123 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011124 return err;
11125
11126 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11127
11128 if (spec->autocfg.dig_out_pin)
11129 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11130
11131 if (spec->kctl_alloc)
11132 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11133
11134 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11135
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011136 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011137 spec->input_mux = &spec->private_imux;
11138
11139 spec->adc_nids = alc861_adc_nids;
11140 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11141 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11142 spec->num_mixers++;
11143
11144 return 1;
11145}
11146
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011147/* additional initialization for auto-configuration model */
11148static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011149{
Kailang Yangdf694da2005-12-05 19:42:22 +010011150 alc861_auto_init_multi_out(codec);
11151 alc861_auto_init_hp_out(codec);
11152 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011153}
11154
Takashi Iwaicb53c622007-08-10 17:21:45 +020011155#ifdef CONFIG_SND_HDA_POWER_SAVE
11156static struct hda_amp_list alc861_loopbacks[] = {
11157 { 0x15, HDA_INPUT, 0 },
11158 { 0x15, HDA_INPUT, 1 },
11159 { 0x15, HDA_INPUT, 2 },
11160 { 0x15, HDA_INPUT, 3 },
11161 { } /* end */
11162};
11163#endif
11164
Kailang Yangdf694da2005-12-05 19:42:22 +010011165
11166/*
11167 * configuration and preset
11168 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011169static const char *alc861_models[ALC861_MODEL_LAST] = {
11170 [ALC861_3ST] = "3stack",
11171 [ALC660_3ST] = "3stack-660",
11172 [ALC861_3ST_DIG] = "3stack-dig",
11173 [ALC861_6ST_DIG] = "6stack-dig",
11174 [ALC861_UNIWILL_M31] = "uniwill-m31",
11175 [ALC861_TOSHIBA] = "toshiba",
11176 [ALC861_ASUS] = "asus",
11177 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11178 [ALC861_AUTO] = "auto",
11179};
11180
11181static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011182 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011183 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11184 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11185 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011186 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011187 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011188 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011189 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11190 * Any other models that need this preset?
11191 */
11192 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011193 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11194 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011195 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11196 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11197 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11198 /* FIXME: the below seems conflict */
11199 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11200 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11201 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011202 {}
11203};
11204
11205static struct alc_config_preset alc861_presets[] = {
11206 [ALC861_3ST] = {
11207 .mixers = { alc861_3ST_mixer },
11208 .init_verbs = { alc861_threestack_init_verbs },
11209 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11210 .dac_nids = alc861_dac_nids,
11211 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11212 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011213 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011214 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11215 .adc_nids = alc861_adc_nids,
11216 .input_mux = &alc861_capture_source,
11217 },
11218 [ALC861_3ST_DIG] = {
11219 .mixers = { alc861_base_mixer },
11220 .init_verbs = { alc861_threestack_init_verbs },
11221 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11222 .dac_nids = alc861_dac_nids,
11223 .dig_out_nid = ALC861_DIGOUT_NID,
11224 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11225 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011226 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011227 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11228 .adc_nids = alc861_adc_nids,
11229 .input_mux = &alc861_capture_source,
11230 },
11231 [ALC861_6ST_DIG] = {
11232 .mixers = { alc861_base_mixer },
11233 .init_verbs = { alc861_base_init_verbs },
11234 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11235 .dac_nids = alc861_dac_nids,
11236 .dig_out_nid = ALC861_DIGOUT_NID,
11237 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11238 .channel_mode = alc861_8ch_modes,
11239 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11240 .adc_nids = alc861_adc_nids,
11241 .input_mux = &alc861_capture_source,
11242 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011243 [ALC660_3ST] = {
11244 .mixers = { alc861_3ST_mixer },
11245 .init_verbs = { alc861_threestack_init_verbs },
11246 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11247 .dac_nids = alc660_dac_nids,
11248 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11249 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011250 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011251 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11252 .adc_nids = alc861_adc_nids,
11253 .input_mux = &alc861_capture_source,
11254 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011255 [ALC861_UNIWILL_M31] = {
11256 .mixers = { alc861_uniwill_m31_mixer },
11257 .init_verbs = { alc861_uniwill_m31_init_verbs },
11258 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11259 .dac_nids = alc861_dac_nids,
11260 .dig_out_nid = ALC861_DIGOUT_NID,
11261 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11262 .channel_mode = alc861_uniwill_m31_modes,
11263 .need_dac_fix = 1,
11264 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11265 .adc_nids = alc861_adc_nids,
11266 .input_mux = &alc861_capture_source,
11267 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011268 [ALC861_TOSHIBA] = {
11269 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011270 .init_verbs = { alc861_base_init_verbs,
11271 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011272 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11273 .dac_nids = alc861_dac_nids,
11274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11275 .channel_mode = alc883_3ST_2ch_modes,
11276 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11277 .adc_nids = alc861_adc_nids,
11278 .input_mux = &alc861_capture_source,
11279 .unsol_event = alc861_toshiba_unsol_event,
11280 .init_hook = alc861_toshiba_automute,
11281 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011282 [ALC861_ASUS] = {
11283 .mixers = { alc861_asus_mixer },
11284 .init_verbs = { alc861_asus_init_verbs },
11285 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11286 .dac_nids = alc861_dac_nids,
11287 .dig_out_nid = ALC861_DIGOUT_NID,
11288 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11289 .channel_mode = alc861_asus_modes,
11290 .need_dac_fix = 1,
11291 .hp_nid = 0x06,
11292 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11293 .adc_nids = alc861_adc_nids,
11294 .input_mux = &alc861_capture_source,
11295 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011296 [ALC861_ASUS_LAPTOP] = {
11297 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11298 .init_verbs = { alc861_asus_init_verbs,
11299 alc861_asus_laptop_init_verbs },
11300 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11301 .dac_nids = alc861_dac_nids,
11302 .dig_out_nid = ALC861_DIGOUT_NID,
11303 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11304 .channel_mode = alc883_3ST_2ch_modes,
11305 .need_dac_fix = 1,
11306 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11307 .adc_nids = alc861_adc_nids,
11308 .input_mux = &alc861_capture_source,
11309 },
11310};
Kailang Yangdf694da2005-12-05 19:42:22 +010011311
11312
11313static int patch_alc861(struct hda_codec *codec)
11314{
11315 struct alc_spec *spec;
11316 int board_config;
11317 int err;
11318
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011319 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011320 if (spec == NULL)
11321 return -ENOMEM;
11322
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011323 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011324
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011325 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11326 alc861_models,
11327 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011328
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011329 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011330 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11331 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011332 board_config = ALC861_AUTO;
11333 }
11334
11335 if (board_config == ALC861_AUTO) {
11336 /* automatic parse from the BIOS config */
11337 err = alc861_parse_auto_config(codec);
11338 if (err < 0) {
11339 alc_free(codec);
11340 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011341 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011342 printk(KERN_INFO
11343 "hda_codec: Cannot set up configuration "
11344 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011345 board_config = ALC861_3ST_DIG;
11346 }
11347 }
11348
11349 if (board_config != ALC861_AUTO)
11350 setup_preset(spec, &alc861_presets[board_config]);
11351
11352 spec->stream_name_analog = "ALC861 Analog";
11353 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11354 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11355
11356 spec->stream_name_digital = "ALC861 Digital";
11357 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11358 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11359
11360 codec->patch_ops = alc_patch_ops;
11361 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011362 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011363#ifdef CONFIG_SND_HDA_POWER_SAVE
11364 if (!spec->loopback.amplist)
11365 spec->loopback.amplist = alc861_loopbacks;
11366#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011367
11368 return 0;
11369}
11370
11371/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011372 * ALC861-VD support
11373 *
11374 * Based on ALC882
11375 *
11376 * In addition, an independent DAC
11377 */
11378#define ALC861VD_DIGOUT_NID 0x06
11379
11380static hda_nid_t alc861vd_dac_nids[4] = {
11381 /* front, surr, clfe, side surr */
11382 0x02, 0x03, 0x04, 0x05
11383};
11384
11385/* dac_nids for ALC660vd are in a different order - according to
11386 * Realtek's driver.
11387 * This should probably tesult in a different mixer for 6stack models
11388 * of ALC660vd codecs, but for now there is only 3stack mixer
11389 * - and it is the same as in 861vd.
11390 * adc_nids in ALC660vd are (is) the same as in 861vd
11391 */
11392static hda_nid_t alc660vd_dac_nids[3] = {
11393 /* front, rear, clfe, rear_surr */
11394 0x02, 0x04, 0x03
11395};
11396
11397static hda_nid_t alc861vd_adc_nids[1] = {
11398 /* ADC0 */
11399 0x09,
11400};
11401
11402/* input MUX */
11403/* FIXME: should be a matrix-type input source selection */
11404static struct hda_input_mux alc861vd_capture_source = {
11405 .num_items = 4,
11406 .items = {
11407 { "Mic", 0x0 },
11408 { "Front Mic", 0x1 },
11409 { "Line", 0x2 },
11410 { "CD", 0x4 },
11411 },
11412};
11413
Kailang Yang272a5272007-05-14 11:00:38 +020011414static struct hda_input_mux alc861vd_dallas_capture_source = {
11415 .num_items = 3,
11416 .items = {
11417 { "Front Mic", 0x0 },
11418 { "ATAPI Mic", 0x1 },
11419 { "Line In", 0x5 },
11420 },
11421};
11422
Kailang Yangd1a991a2007-08-15 16:21:59 +020011423static struct hda_input_mux alc861vd_hp_capture_source = {
11424 .num_items = 2,
11425 .items = {
11426 { "Front Mic", 0x0 },
11427 { "ATAPI Mic", 0x1 },
11428 },
11429};
11430
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011431#define alc861vd_mux_enum_info alc_mux_enum_info
11432#define alc861vd_mux_enum_get alc_mux_enum_get
11433
11434static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11435 struct snd_ctl_elem_value *ucontrol)
11436{
11437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11438 struct alc_spec *spec = codec->spec;
11439 const struct hda_input_mux *imux = spec->input_mux;
11440 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11441 static hda_nid_t capture_mixers[1] = { 0x22 };
11442 hda_nid_t nid = capture_mixers[adc_idx];
11443 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11444 unsigned int i, idx;
11445
11446 idx = ucontrol->value.enumerated.item[0];
11447 if (idx >= imux->num_items)
11448 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011449 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011450 return 0;
11451 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011452 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11453 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11454 imux->items[i].index,
11455 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011456 }
11457 *cur_val = idx;
11458 return 1;
11459}
11460
11461/*
11462 * 2ch mode
11463 */
11464static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11465 { 2, NULL }
11466};
11467
11468/*
11469 * 6ch mode
11470 */
11471static struct hda_verb alc861vd_6stack_ch6_init[] = {
11472 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11473 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11474 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11475 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11476 { } /* end */
11477};
11478
11479/*
11480 * 8ch mode
11481 */
11482static struct hda_verb alc861vd_6stack_ch8_init[] = {
11483 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11484 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11485 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11486 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11487 { } /* end */
11488};
11489
11490static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11491 { 6, alc861vd_6stack_ch6_init },
11492 { 8, alc861vd_6stack_ch8_init },
11493};
11494
11495static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11496 {
11497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11498 .name = "Channel Mode",
11499 .info = alc_ch_mode_info,
11500 .get = alc_ch_mode_get,
11501 .put = alc_ch_mode_put,
11502 },
11503 { } /* end */
11504};
11505
11506static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11507 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11508 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11509
11510 {
11511 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11512 /* The multiple "Capture Source" controls confuse alsamixer
11513 * So call somewhat different..
11514 *FIXME: the controls appear in the "playback" view!
11515 */
11516 /* .name = "Capture Source", */
11517 .name = "Input Source",
11518 .count = 1,
11519 .info = alc861vd_mux_enum_info,
11520 .get = alc861vd_mux_enum_get,
11521 .put = alc861vd_mux_enum_put,
11522 },
11523 { } /* end */
11524};
11525
11526/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11527 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11528 */
11529static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11530 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11531 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11532
11533 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11534 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11535
11536 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11537 HDA_OUTPUT),
11538 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11539 HDA_OUTPUT),
11540 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11541 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11542
11543 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11544 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11545
11546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11547
11548 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11551
11552 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11553 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11554 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11555
11556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11558
11559 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11560 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11561
11562 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11563 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11564
11565 { } /* end */
11566};
11567
11568static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11569 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11570 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11571
11572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11573
11574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11577
11578 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11579 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11580 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11581
11582 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11583 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11584
11585 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11586 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11587
11588 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11589 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11590
11591 { } /* end */
11592};
11593
Kailang Yangbdd148a2007-05-08 15:19:08 +020011594static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11595 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11596 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11597 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11598
11599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11600
11601 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11604
11605 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11606 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11607 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11608
11609 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11610 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11611
11612 { } /* end */
11613};
11614
Kailang Yang272a5272007-05-14 11:00:38 +020011615/* Pin assignment: Front=0x14, HP = 0x15,
11616 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11617 */
11618static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11619 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11620 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11621 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11622 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11623 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11624 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11625 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11626 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11627 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11628 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011629 { } /* end */
11630};
11631
Kailang Yangd1a991a2007-08-15 16:21:59 +020011632/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11633 * Front Mic=0x18, ATAPI Mic = 0x19,
11634 */
11635static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11636 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11637 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11639 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11640 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11642 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11643 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11644
11645 { } /* end */
11646};
11647
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011648/*
11649 * generic initialization of ADC, input mixers and output mixers
11650 */
11651static struct hda_verb alc861vd_volume_init_verbs[] = {
11652 /*
11653 * Unmute ADC0 and set the default input to mic-in
11654 */
11655 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11656 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11657
11658 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11659 * the analog-loopback mixer widget
11660 */
11661 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011667
11668 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020011669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011673
11674 /*
11675 * Set up output mixers (0x02 - 0x05)
11676 */
11677 /* set vol=0 to output mixers */
11678 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11679 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11680 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11681 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11682
11683 /* set up input amps for analog loopback */
11684 /* Amp Indices: DAC = 0, mixer = 1 */
11685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11693
11694 { }
11695};
11696
11697/*
11698 * 3-stack pin configuration:
11699 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11700 */
11701static struct hda_verb alc861vd_3stack_init_verbs[] = {
11702 /*
11703 * Set pin mode and muting
11704 */
11705 /* set front pin widgets 0x14 for output */
11706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11707 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11708 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11709
11710 /* Mic (rear) pin: input vref at 80% */
11711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11712 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11713 /* Front Mic pin: input vref at 80% */
11714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11715 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11716 /* Line In pin: input */
11717 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11718 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11719 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11721 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11722 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11723 /* CD pin widget for input */
11724 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11725
11726 { }
11727};
11728
11729/*
11730 * 6-stack pin configuration:
11731 */
11732static struct hda_verb alc861vd_6stack_init_verbs[] = {
11733 /*
11734 * Set pin mode and muting
11735 */
11736 /* set front pin widgets 0x14 for output */
11737 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11739 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11740
11741 /* Rear Pin: output 1 (0x0d) */
11742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11744 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11745 /* CLFE Pin: output 2 (0x0e) */
11746 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11748 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11749 /* Side Pin: output 3 (0x0f) */
11750 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11751 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11752 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11753
11754 /* Mic (rear) pin: input vref at 80% */
11755 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11756 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11757 /* Front Mic pin: input vref at 80% */
11758 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11760 /* Line In pin: input */
11761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11763 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11764 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11765 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11767 /* CD pin widget for input */
11768 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11769
11770 { }
11771};
11772
Kailang Yangbdd148a2007-05-08 15:19:08 +020011773static struct hda_verb alc861vd_eapd_verbs[] = {
11774 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11775 { }
11776};
11777
11778static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
11779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11782 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11783 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11784 {}
11785};
11786
11787/* toggle speaker-output according to the hp-jack state */
11788static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
11789{
11790 unsigned int present;
11791 unsigned char bits;
11792
11793 present = snd_hda_codec_read(codec, 0x1b, 0,
11794 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011795 bits = present ? HDA_AMP_MUTE : 0;
11796 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11797 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011798}
11799
11800static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
11801{
11802 unsigned int present;
11803 unsigned char bits;
11804
11805 present = snd_hda_codec_read(codec, 0x18, 0,
11806 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011807 bits = present ? HDA_AMP_MUTE : 0;
11808 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
11809 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011810}
11811
11812static void alc861vd_lenovo_automute(struct hda_codec *codec)
11813{
11814 alc861vd_lenovo_hp_automute(codec);
11815 alc861vd_lenovo_mic_automute(codec);
11816}
11817
11818static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
11819 unsigned int res)
11820{
11821 switch (res >> 26) {
11822 case ALC880_HP_EVENT:
11823 alc861vd_lenovo_hp_automute(codec);
11824 break;
11825 case ALC880_MIC_EVENT:
11826 alc861vd_lenovo_mic_automute(codec);
11827 break;
11828 }
11829}
11830
Kailang Yang272a5272007-05-14 11:00:38 +020011831static struct hda_verb alc861vd_dallas_verbs[] = {
11832 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11833 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11836
11837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11845
11846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11852 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11854
11855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11861 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11862 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11863
11864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11868
11869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11870 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11871 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11872
11873 { } /* end */
11874};
11875
11876/* toggle speaker-output according to the hp-jack state */
11877static void alc861vd_dallas_automute(struct hda_codec *codec)
11878{
11879 unsigned int present;
11880
11881 present = snd_hda_codec_read(codec, 0x15, 0,
11882 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011883 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11884 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020011885}
11886
11887static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
11888{
11889 if ((res >> 26) == ALC880_HP_EVENT)
11890 alc861vd_dallas_automute(codec);
11891}
11892
Takashi Iwaicb53c622007-08-10 17:21:45 +020011893#ifdef CONFIG_SND_HDA_POWER_SAVE
11894#define alc861vd_loopbacks alc880_loopbacks
11895#endif
11896
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011897/* pcm configuration: identiacal with ALC880 */
11898#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
11899#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
11900#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
11901#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
11902
11903/*
11904 * configuration and preset
11905 */
11906static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
11907 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011908 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011909 [ALC861VD_3ST] = "3stack",
11910 [ALC861VD_3ST_DIG] = "3stack-digout",
11911 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020011912 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020011913 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011914 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011915 [ALC861VD_AUTO] = "auto",
11916};
11917
11918static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011919 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
11920 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010011921 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011922 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020011923 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011924 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011925 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020011926 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020011927 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020011928 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020011929 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011930 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
11931 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020011932 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011933 {}
11934};
11935
11936static struct alc_config_preset alc861vd_presets[] = {
11937 [ALC660VD_3ST] = {
11938 .mixers = { alc861vd_3st_mixer },
11939 .init_verbs = { alc861vd_volume_init_verbs,
11940 alc861vd_3stack_init_verbs },
11941 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11942 .dac_nids = alc660vd_dac_nids,
11943 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11944 .adc_nids = alc861vd_adc_nids,
11945 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11946 .channel_mode = alc861vd_3stack_2ch_modes,
11947 .input_mux = &alc861vd_capture_source,
11948 },
Mike Crash6963f842007-06-25 12:12:51 +020011949 [ALC660VD_3ST_DIG] = {
11950 .mixers = { alc861vd_3st_mixer },
11951 .init_verbs = { alc861vd_volume_init_verbs,
11952 alc861vd_3stack_init_verbs },
11953 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11954 .dac_nids = alc660vd_dac_nids,
11955 .dig_out_nid = ALC861VD_DIGOUT_NID,
11956 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11957 .adc_nids = alc861vd_adc_nids,
11958 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11959 .channel_mode = alc861vd_3stack_2ch_modes,
11960 .input_mux = &alc861vd_capture_source,
11961 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011962 [ALC861VD_3ST] = {
11963 .mixers = { alc861vd_3st_mixer },
11964 .init_verbs = { alc861vd_volume_init_verbs,
11965 alc861vd_3stack_init_verbs },
11966 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11967 .dac_nids = alc861vd_dac_nids,
11968 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11969 .channel_mode = alc861vd_3stack_2ch_modes,
11970 .input_mux = &alc861vd_capture_source,
11971 },
11972 [ALC861VD_3ST_DIG] = {
11973 .mixers = { alc861vd_3st_mixer },
11974 .init_verbs = { alc861vd_volume_init_verbs,
11975 alc861vd_3stack_init_verbs },
11976 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11977 .dac_nids = alc861vd_dac_nids,
11978 .dig_out_nid = ALC861VD_DIGOUT_NID,
11979 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11980 .channel_mode = alc861vd_3stack_2ch_modes,
11981 .input_mux = &alc861vd_capture_source,
11982 },
11983 [ALC861VD_6ST_DIG] = {
11984 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
11985 .init_verbs = { alc861vd_volume_init_verbs,
11986 alc861vd_6stack_init_verbs },
11987 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11988 .dac_nids = alc861vd_dac_nids,
11989 .dig_out_nid = ALC861VD_DIGOUT_NID,
11990 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
11991 .channel_mode = alc861vd_6stack_modes,
11992 .input_mux = &alc861vd_capture_source,
11993 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020011994 [ALC861VD_LENOVO] = {
11995 .mixers = { alc861vd_lenovo_mixer },
11996 .init_verbs = { alc861vd_volume_init_verbs,
11997 alc861vd_3stack_init_verbs,
11998 alc861vd_eapd_verbs,
11999 alc861vd_lenovo_unsol_verbs },
12000 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12001 .dac_nids = alc660vd_dac_nids,
12002 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12003 .adc_nids = alc861vd_adc_nids,
12004 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12005 .channel_mode = alc861vd_3stack_2ch_modes,
12006 .input_mux = &alc861vd_capture_source,
12007 .unsol_event = alc861vd_lenovo_unsol_event,
12008 .init_hook = alc861vd_lenovo_automute,
12009 },
Kailang Yang272a5272007-05-14 11:00:38 +020012010 [ALC861VD_DALLAS] = {
12011 .mixers = { alc861vd_dallas_mixer },
12012 .init_verbs = { alc861vd_dallas_verbs },
12013 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12014 .dac_nids = alc861vd_dac_nids,
12015 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12016 .adc_nids = alc861vd_adc_nids,
12017 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12018 .channel_mode = alc861vd_3stack_2ch_modes,
12019 .input_mux = &alc861vd_dallas_capture_source,
12020 .unsol_event = alc861vd_dallas_unsol_event,
12021 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012022 },
12023 [ALC861VD_HP] = {
12024 .mixers = { alc861vd_hp_mixer },
12025 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12026 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12027 .dac_nids = alc861vd_dac_nids,
12028 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12029 .dig_out_nid = ALC861VD_DIGOUT_NID,
12030 .adc_nids = alc861vd_adc_nids,
12031 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12032 .channel_mode = alc861vd_3stack_2ch_modes,
12033 .input_mux = &alc861vd_hp_capture_source,
12034 .unsol_event = alc861vd_dallas_unsol_event,
12035 .init_hook = alc861vd_dallas_automute,
12036 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012037};
12038
12039/*
12040 * BIOS auto configuration
12041 */
12042static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12043 hda_nid_t nid, int pin_type, int dac_idx)
12044{
12045 /* set as output */
12046 snd_hda_codec_write(codec, nid, 0,
12047 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12048 snd_hda_codec_write(codec, nid, 0,
12049 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12050}
12051
12052static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12053{
12054 struct alc_spec *spec = codec->spec;
12055 int i;
12056
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012057 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012058 for (i = 0; i <= HDA_SIDE; i++) {
12059 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012060 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012061 if (nid)
12062 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012063 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012064 }
12065}
12066
12067
12068static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12069{
12070 struct alc_spec *spec = codec->spec;
12071 hda_nid_t pin;
12072
12073 pin = spec->autocfg.hp_pins[0];
12074 if (pin) /* connect to front and use dac 0 */
12075 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12076}
12077
12078#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12079#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12080
12081static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12082{
12083 struct alc_spec *spec = codec->spec;
12084 int i;
12085
12086 for (i = 0; i < AUTO_PIN_LAST; i++) {
12087 hda_nid_t nid = spec->autocfg.input_pins[i];
12088 if (alc861vd_is_input_pin(nid)) {
12089 snd_hda_codec_write(codec, nid, 0,
12090 AC_VERB_SET_PIN_WIDGET_CONTROL,
12091 i <= AUTO_PIN_FRONT_MIC ?
12092 PIN_VREF80 : PIN_IN);
12093 if (nid != ALC861VD_PIN_CD_NID)
12094 snd_hda_codec_write(codec, nid, 0,
12095 AC_VERB_SET_AMP_GAIN_MUTE,
12096 AMP_OUT_MUTE);
12097 }
12098 }
12099}
12100
12101#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12102#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12103
12104/* add playback controls from the parsed DAC table */
12105/* Based on ALC880 version. But ALC861VD has separate,
12106 * different NIDs for mute/unmute switch and volume control */
12107static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12108 const struct auto_pin_cfg *cfg)
12109{
12110 char name[32];
12111 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12112 hda_nid_t nid_v, nid_s;
12113 int i, err;
12114
12115 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012116 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012117 continue;
12118 nid_v = alc861vd_idx_to_mixer_vol(
12119 alc880_dac_to_idx(
12120 spec->multiout.dac_nids[i]));
12121 nid_s = alc861vd_idx_to_mixer_switch(
12122 alc880_dac_to_idx(
12123 spec->multiout.dac_nids[i]));
12124
12125 if (i == 2) {
12126 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012127 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12128 "Center Playback Volume",
12129 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12130 HDA_OUTPUT));
12131 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012132 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012133 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12134 "LFE Playback Volume",
12135 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12136 HDA_OUTPUT));
12137 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012138 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012139 err = add_control(spec, ALC_CTL_BIND_MUTE,
12140 "Center Playback Switch",
12141 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12142 HDA_INPUT));
12143 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012144 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012145 err = add_control(spec, ALC_CTL_BIND_MUTE,
12146 "LFE Playback Switch",
12147 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12148 HDA_INPUT));
12149 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012150 return err;
12151 } else {
12152 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012153 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12154 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12155 HDA_OUTPUT));
12156 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012157 return err;
12158 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012159 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012160 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012161 HDA_INPUT));
12162 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012163 return err;
12164 }
12165 }
12166 return 0;
12167}
12168
12169/* add playback controls for speaker and HP outputs */
12170/* Based on ALC880 version. But ALC861VD has separate,
12171 * different NIDs for mute/unmute switch and volume control */
12172static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12173 hda_nid_t pin, const char *pfx)
12174{
12175 hda_nid_t nid_v, nid_s;
12176 int err;
12177 char name[32];
12178
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012179 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012180 return 0;
12181
12182 if (alc880_is_fixed_pin(pin)) {
12183 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12184 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012185 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012186 spec->multiout.hp_nid = nid_v;
12187 else
12188 spec->multiout.extra_out_nid[0] = nid_v;
12189 /* control HP volume/switch on the output mixer amp */
12190 nid_v = alc861vd_idx_to_mixer_vol(
12191 alc880_fixed_pin_idx(pin));
12192 nid_s = alc861vd_idx_to_mixer_switch(
12193 alc880_fixed_pin_idx(pin));
12194
12195 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012196 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12197 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12198 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012199 return err;
12200 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012201 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12202 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12203 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012204 return err;
12205 } else if (alc880_is_multi_pin(pin)) {
12206 /* set manual connection */
12207 /* we have only a switch on HP-out PIN */
12208 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012209 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12210 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12211 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012212 return err;
12213 }
12214 return 0;
12215}
12216
12217/* parse the BIOS configuration and set up the alc_spec
12218 * return 1 if successful, 0 if the proper config is not found,
12219 * or a negative error code
12220 * Based on ALC880 version - had to change it to override
12221 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12222static int alc861vd_parse_auto_config(struct hda_codec *codec)
12223{
12224 struct alc_spec *spec = codec->spec;
12225 int err;
12226 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012228 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12229 alc861vd_ignore);
12230 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012231 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012232 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012233 return 0; /* can't find valid BIOS pin config */
12234
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012235 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12236 if (err < 0)
12237 return err;
12238 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12239 if (err < 0)
12240 return err;
12241 err = alc861vd_auto_create_extra_out(spec,
12242 spec->autocfg.speaker_pins[0],
12243 "Speaker");
12244 if (err < 0)
12245 return err;
12246 err = alc861vd_auto_create_extra_out(spec,
12247 spec->autocfg.hp_pins[0],
12248 "Headphone");
12249 if (err < 0)
12250 return err;
12251 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12252 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012253 return err;
12254
12255 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12256
12257 if (spec->autocfg.dig_out_pin)
12258 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12259
12260 if (spec->kctl_alloc)
12261 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12262
12263 spec->init_verbs[spec->num_init_verbs++]
12264 = alc861vd_volume_init_verbs;
12265
12266 spec->num_mux_defs = 1;
12267 spec->input_mux = &spec->private_imux;
12268
Takashi Iwai776e1842007-08-29 15:07:11 +020012269 err = alc_auto_add_mic_boost(codec);
12270 if (err < 0)
12271 return err;
12272
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012273 return 1;
12274}
12275
12276/* additional initialization for auto-configuration model */
12277static void alc861vd_auto_init(struct hda_codec *codec)
12278{
12279 alc861vd_auto_init_multi_out(codec);
12280 alc861vd_auto_init_hp_out(codec);
12281 alc861vd_auto_init_analog_input(codec);
12282}
12283
12284static int patch_alc861vd(struct hda_codec *codec)
12285{
12286 struct alc_spec *spec;
12287 int err, board_config;
12288
12289 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12290 if (spec == NULL)
12291 return -ENOMEM;
12292
12293 codec->spec = spec;
12294
12295 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12296 alc861vd_models,
12297 alc861vd_cfg_tbl);
12298
12299 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12300 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12301 "ALC861VD, trying auto-probe from BIOS...\n");
12302 board_config = ALC861VD_AUTO;
12303 }
12304
12305 if (board_config == ALC861VD_AUTO) {
12306 /* automatic parse from the BIOS config */
12307 err = alc861vd_parse_auto_config(codec);
12308 if (err < 0) {
12309 alc_free(codec);
12310 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012311 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012312 printk(KERN_INFO
12313 "hda_codec: Cannot set up configuration "
12314 "from BIOS. Using base mode...\n");
12315 board_config = ALC861VD_3ST;
12316 }
12317 }
12318
12319 if (board_config != ALC861VD_AUTO)
12320 setup_preset(spec, &alc861vd_presets[board_config]);
12321
12322 spec->stream_name_analog = "ALC861VD Analog";
12323 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12324 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12325
12326 spec->stream_name_digital = "ALC861VD Digital";
12327 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12328 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12329
12330 spec->adc_nids = alc861vd_adc_nids;
12331 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12332
12333 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12334 spec->num_mixers++;
12335
12336 codec->patch_ops = alc_patch_ops;
12337
12338 if (board_config == ALC861VD_AUTO)
12339 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012340#ifdef CONFIG_SND_HDA_POWER_SAVE
12341 if (!spec->loopback.amplist)
12342 spec->loopback.amplist = alc861vd_loopbacks;
12343#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012344
12345 return 0;
12346}
12347
12348/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012349 * ALC662 support
12350 *
12351 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12352 * configuration. Each pin widget can choose any input DACs and a mixer.
12353 * Each ADC is connected from a mixer of all inputs. This makes possible
12354 * 6-channel independent captures.
12355 *
12356 * In addition, an independent DAC for the multi-playback (not used in this
12357 * driver yet).
12358 */
12359#define ALC662_DIGOUT_NID 0x06
12360#define ALC662_DIGIN_NID 0x0a
12361
12362static hda_nid_t alc662_dac_nids[4] = {
12363 /* front, rear, clfe, rear_surr */
12364 0x02, 0x03, 0x04
12365};
12366
12367static hda_nid_t alc662_adc_nids[1] = {
12368 /* ADC1-2 */
12369 0x09,
12370};
12371/* input MUX */
12372/* FIXME: should be a matrix-type input source selection */
12373
12374static struct hda_input_mux alc662_capture_source = {
12375 .num_items = 4,
12376 .items = {
12377 { "Mic", 0x0 },
12378 { "Front Mic", 0x1 },
12379 { "Line", 0x2 },
12380 { "CD", 0x4 },
12381 },
12382};
12383
12384static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12385 .num_items = 2,
12386 .items = {
12387 { "Mic", 0x1 },
12388 { "Line", 0x2 },
12389 },
12390};
Kailang Yang291702f2007-10-16 14:28:03 +020012391
12392static struct hda_input_mux alc662_eeepc_capture_source = {
12393 .num_items = 2,
12394 .items = {
12395 { "i-Mic", 0x1 },
12396 { "e-Mic", 0x0 },
12397 },
12398};
12399
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012400#define alc662_mux_enum_info alc_mux_enum_info
12401#define alc662_mux_enum_get alc_mux_enum_get
12402
12403static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12404 struct snd_ctl_elem_value *ucontrol)
12405{
12406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12407 struct alc_spec *spec = codec->spec;
12408 const struct hda_input_mux *imux = spec->input_mux;
12409 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012410 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012411 hda_nid_t nid = capture_mixers[adc_idx];
12412 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12413 unsigned int i, idx;
12414
12415 idx = ucontrol->value.enumerated.item[0];
12416 if (idx >= imux->num_items)
12417 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012418 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012419 return 0;
12420 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012421 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12422 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12423 imux->items[i].index,
12424 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012425 }
12426 *cur_val = idx;
12427 return 1;
12428}
12429/*
12430 * 2ch mode
12431 */
12432static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12433 { 2, NULL }
12434};
12435
12436/*
12437 * 2ch mode
12438 */
12439static struct hda_verb alc662_3ST_ch2_init[] = {
12440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12442 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12443 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12444 { } /* end */
12445};
12446
12447/*
12448 * 6ch mode
12449 */
12450static struct hda_verb alc662_3ST_ch6_init[] = {
12451 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12452 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12453 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12454 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12455 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12456 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12457 { } /* end */
12458};
12459
12460static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12461 { 2, alc662_3ST_ch2_init },
12462 { 6, alc662_3ST_ch6_init },
12463};
12464
12465/*
12466 * 2ch mode
12467 */
12468static struct hda_verb alc662_sixstack_ch6_init[] = {
12469 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12470 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12471 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12472 { } /* end */
12473};
12474
12475/*
12476 * 6ch mode
12477 */
12478static struct hda_verb alc662_sixstack_ch8_init[] = {
12479 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12480 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12481 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12482 { } /* end */
12483};
12484
12485static struct hda_channel_mode alc662_5stack_modes[2] = {
12486 { 2, alc662_sixstack_ch6_init },
12487 { 6, alc662_sixstack_ch8_init },
12488};
12489
12490/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12491 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12492 */
12493
12494static struct snd_kcontrol_new alc662_base_mixer[] = {
12495 /* output mixer control */
12496 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12497 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12498 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12499 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12500 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12501 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12502 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12503 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12505
12506 /*Input mixer control */
12507 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12508 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12509 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12510 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12511 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12512 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12513 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012515 { } /* end */
12516};
12517
12518static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12519 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12520 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12522 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12523 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12524 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12525 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12528 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12529 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12530 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12531 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012532 { } /* end */
12533};
12534
12535static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12536 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12537 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12538 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12539 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12540 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12541 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12542 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12543 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12547 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12548 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12551 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12553 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12554 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012555 { } /* end */
12556};
12557
12558static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12559 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12560 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12561 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12562 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12564 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12565 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012568 { } /* end */
12569};
12570
Kailang Yang291702f2007-10-16 14:28:03 +020012571static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12572 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12573
12574 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12575 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12576
12577 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12578 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12579 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12580
12581 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12582 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12583 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12584 { } /* end */
12585};
12586
Kailang Yang8c427222008-01-10 13:03:59 +010012587static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12588 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12589 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12590 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12591 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12592 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12593 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12594 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12595 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12596 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12597 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12598 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12599 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12602 { } /* end */
12603};
12604
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012605static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12606 {
12607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12608 .name = "Channel Mode",
12609 .info = alc_ch_mode_info,
12610 .get = alc_ch_mode_get,
12611 .put = alc_ch_mode_put,
12612 },
12613 { } /* end */
12614};
12615
12616static struct hda_verb alc662_init_verbs[] = {
12617 /* ADC: mute amp left and right */
12618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12619 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12620 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12621
Takashi Iwaicb53c622007-08-10 17:21:45 +020012622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012627
Kailang Yangb60dd392007-09-20 12:50:29 +020012628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012634
12635 /* Front Pin: output 0 (0x0c) */
12636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12638
12639 /* Rear Pin: output 1 (0x0d) */
12640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12642
12643 /* CLFE Pin: output 2 (0x0e) */
12644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12646
12647 /* Mic (rear) pin: input vref at 80% */
12648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12650 /* Front Mic pin: input vref at 80% */
12651 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12653 /* Line In pin: input */
12654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12656 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12659 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12660 /* CD pin widget for input */
12661 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12662
12663 /* FIXME: use matrix-type input source selection */
12664 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12665 /* Input mixer */
12666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020012670
12671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012675 { }
12676};
12677
12678static struct hda_verb alc662_sue_init_verbs[] = {
12679 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12680 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020012681 {}
12682};
12683
12684static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12685 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12686 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12687 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012688};
12689
Kailang Yang8c427222008-01-10 13:03:59 +010012690/* Set Unsolicited Event*/
12691static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12693 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12694 {}
12695};
12696
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012697/*
12698 * generic initialization of ADC, input mixers and output mixers
12699 */
12700static struct hda_verb alc662_auto_init_verbs[] = {
12701 /*
12702 * Unmute ADC and set the default input to mic-in
12703 */
12704 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12706
12707 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12708 * mixer widget
12709 * Note: PASD motherboards uses the Line In 2 as the input for front
12710 * panel mic (mic 2)
12711 */
12712 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012718
12719 /*
12720 * Set up output mixers (0x0c - 0x0f)
12721 */
12722 /* set vol=0 to output mixers */
12723 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12724 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12725 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12726
12727 /* set up input amps for analog loopback */
12728 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020012729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12731 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12732 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12733 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012735
12736
12737 /* FIXME: use matrix-type input source selection */
12738 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12739 /* Input mixer */
12740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020012741 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012742 { }
12743};
12744
12745/* capture mixer elements */
12746static struct snd_kcontrol_new alc662_capture_mixer[] = {
12747 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12748 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12749 {
12750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12751 /* The multiple "Capture Source" controls confuse alsamixer
12752 * So call somewhat different..
12753 * FIXME: the controls appear in the "playback" view!
12754 */
12755 /* .name = "Capture Source", */
12756 .name = "Input Source",
12757 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010012758 .info = alc662_mux_enum_info,
12759 .get = alc662_mux_enum_get,
12760 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012761 },
12762 { } /* end */
12763};
12764
12765static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
12766{
12767 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012768 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012769
12770 present = snd_hda_codec_read(codec, 0x14, 0,
12771 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012772 bits = present ? HDA_AMP_MUTE : 0;
12773 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12774 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012775}
12776
12777static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
12778{
12779 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012780 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012781
12782 present = snd_hda_codec_read(codec, 0x1b, 0,
12783 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012784 bits = present ? HDA_AMP_MUTE : 0;
12785 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12786 HDA_AMP_MUTE, bits);
12787 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12788 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012789}
12790
12791static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
12792 unsigned int res)
12793{
12794 if ((res >> 26) == ALC880_HP_EVENT)
12795 alc662_lenovo_101e_all_automute(codec);
12796 if ((res >> 26) == ALC880_FRONT_EVENT)
12797 alc662_lenovo_101e_ispeaker_automute(codec);
12798}
12799
Kailang Yang291702f2007-10-16 14:28:03 +020012800static void alc662_eeepc_mic_automute(struct hda_codec *codec)
12801{
12802 unsigned int present;
12803
12804 present = snd_hda_codec_read(codec, 0x18, 0,
12805 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12806 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12807 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12808 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12809 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12810 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12811 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12812 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12813 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12814}
12815
12816/* unsolicited event for HP jack sensing */
12817static void alc662_eeepc_unsol_event(struct hda_codec *codec,
12818 unsigned int res)
12819{
12820 if ((res >> 26) == ALC880_HP_EVENT)
12821 alc262_hippo1_automute( codec );
12822
12823 if ((res >> 26) == ALC880_MIC_EVENT)
12824 alc662_eeepc_mic_automute(codec);
12825}
12826
12827static void alc662_eeepc_inithook(struct hda_codec *codec)
12828{
12829 alc262_hippo1_automute( codec );
12830 alc662_eeepc_mic_automute(codec);
12831}
12832
Kailang Yang8c427222008-01-10 13:03:59 +010012833static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
12834{
12835 unsigned int mute;
12836 unsigned int present;
12837
12838 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
12839 present = snd_hda_codec_read(codec, 0x14, 0,
12840 AC_VERB_GET_PIN_SENSE, 0);
12841 present = (present & 0x80000000) != 0;
12842 if (present) {
12843 /* mute internal speaker */
12844 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
12845 HDA_AMP_MUTE, HDA_AMP_MUTE);
12846 } else {
12847 /* unmute internal speaker if necessary */
12848 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12849 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
12850 HDA_AMP_MUTE, mute);
12851 }
12852}
12853
12854/* unsolicited event for HP jack sensing */
12855static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
12856 unsigned int res)
12857{
12858 if ((res >> 26) == ALC880_HP_EVENT)
12859 alc662_eeepc_ep20_automute(codec);
12860}
12861
12862static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
12863{
12864 alc662_eeepc_ep20_automute(codec);
12865}
12866
Takashi Iwaicb53c622007-08-10 17:21:45 +020012867#ifdef CONFIG_SND_HDA_POWER_SAVE
12868#define alc662_loopbacks alc880_loopbacks
12869#endif
12870
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012871
12872/* pcm configuration: identiacal with ALC880 */
12873#define alc662_pcm_analog_playback alc880_pcm_analog_playback
12874#define alc662_pcm_analog_capture alc880_pcm_analog_capture
12875#define alc662_pcm_digital_playback alc880_pcm_digital_playback
12876#define alc662_pcm_digital_capture alc880_pcm_digital_capture
12877
12878/*
12879 * configuration and preset
12880 */
12881static const char *alc662_models[ALC662_MODEL_LAST] = {
12882 [ALC662_3ST_2ch_DIG] = "3stack-dig",
12883 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
12884 [ALC662_3ST_6ch] = "3stack-6ch",
12885 [ALC662_5ST_DIG] = "6stack-dig",
12886 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020012887 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010012888 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012889 [ALC662_AUTO] = "auto",
12890};
12891
12892static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012893 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010012894 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012895 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012896 {}
12897};
12898
12899static struct alc_config_preset alc662_presets[] = {
12900 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012901 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012902 .init_verbs = { alc662_init_verbs },
12903 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12904 .dac_nids = alc662_dac_nids,
12905 .dig_out_nid = ALC662_DIGOUT_NID,
12906 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12907 .adc_nids = alc662_adc_nids,
12908 .dig_in_nid = ALC662_DIGIN_NID,
12909 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12910 .channel_mode = alc662_3ST_2ch_modes,
12911 .input_mux = &alc662_capture_source,
12912 },
12913 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012914 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
12915 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012916 .init_verbs = { alc662_init_verbs },
12917 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12918 .dac_nids = alc662_dac_nids,
12919 .dig_out_nid = ALC662_DIGOUT_NID,
12920 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12921 .adc_nids = alc662_adc_nids,
12922 .dig_in_nid = ALC662_DIGIN_NID,
12923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12924 .channel_mode = alc662_3ST_6ch_modes,
12925 .need_dac_fix = 1,
12926 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012927 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012928 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012929 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
12930 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012931 .init_verbs = { alc662_init_verbs },
12932 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12933 .dac_nids = alc662_dac_nids,
12934 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12935 .adc_nids = alc662_adc_nids,
12936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12937 .channel_mode = alc662_3ST_6ch_modes,
12938 .need_dac_fix = 1,
12939 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012940 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012941 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012942 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
12943 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012944 .init_verbs = { alc662_init_verbs },
12945 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12946 .dac_nids = alc662_dac_nids,
12947 .dig_out_nid = ALC662_DIGOUT_NID,
12948 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12949 .adc_nids = alc662_adc_nids,
12950 .dig_in_nid = ALC662_DIGIN_NID,
12951 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
12952 .channel_mode = alc662_5stack_modes,
12953 .input_mux = &alc662_capture_source,
12954 },
12955 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012956 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012957 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
12958 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12959 .dac_nids = alc662_dac_nids,
12960 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12961 .adc_nids = alc662_adc_nids,
12962 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12963 .channel_mode = alc662_3ST_2ch_modes,
12964 .input_mux = &alc662_lenovo_101e_capture_source,
12965 .unsol_event = alc662_lenovo_101e_unsol_event,
12966 .init_hook = alc662_lenovo_101e_all_automute,
12967 },
Kailang Yang291702f2007-10-16 14:28:03 +020012968 [ALC662_ASUS_EEEPC_P701] = {
12969 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
12970 .init_verbs = { alc662_init_verbs,
12971 alc662_eeepc_sue_init_verbs },
12972 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12973 .dac_nids = alc662_dac_nids,
12974 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12975 .adc_nids = alc662_adc_nids,
12976 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12977 .channel_mode = alc662_3ST_2ch_modes,
12978 .input_mux = &alc662_eeepc_capture_source,
12979 .unsol_event = alc662_eeepc_unsol_event,
12980 .init_hook = alc662_eeepc_inithook,
12981 },
Kailang Yang8c427222008-01-10 13:03:59 +010012982 [ALC662_ASUS_EEEPC_EP20] = {
12983 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
12984 alc662_chmode_mixer },
12985 .init_verbs = { alc662_init_verbs,
12986 alc662_eeepc_ep20_sue_init_verbs },
12987 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12988 .dac_nids = alc662_dac_nids,
12989 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12990 .adc_nids = alc662_adc_nids,
12991 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12992 .channel_mode = alc662_3ST_6ch_modes,
12993 .input_mux = &alc662_lenovo_101e_capture_source,
12994 .unsol_event = alc662_eeepc_ep20_unsol_event,
12995 .init_hook = alc662_eeepc_ep20_inithook,
12996 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012997
12998};
12999
13000
13001/*
13002 * BIOS auto configuration
13003 */
13004
13005/* add playback controls from the parsed DAC table */
13006static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13007 const struct auto_pin_cfg *cfg)
13008{
13009 char name[32];
13010 static const char *chname[4] = {
13011 "Front", "Surround", NULL /*CLFE*/, "Side"
13012 };
13013 hda_nid_t nid;
13014 int i, err;
13015
13016 for (i = 0; i < cfg->line_outs; i++) {
13017 if (!spec->multiout.dac_nids[i])
13018 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013019 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013020 if (i == 2) {
13021 /* Center/LFE */
13022 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13023 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013024 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13025 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013026 if (err < 0)
13027 return err;
13028 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13029 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013030 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13031 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013032 if (err < 0)
13033 return err;
13034 err = add_control(spec, ALC_CTL_BIND_MUTE,
13035 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013036 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13037 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013038 if (err < 0)
13039 return err;
13040 err = add_control(spec, ALC_CTL_BIND_MUTE,
13041 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013042 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13043 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013044 if (err < 0)
13045 return err;
13046 } else {
13047 sprintf(name, "%s Playback Volume", chname[i]);
13048 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013049 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13050 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013051 if (err < 0)
13052 return err;
13053 sprintf(name, "%s Playback Switch", chname[i]);
13054 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013055 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13056 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013057 if (err < 0)
13058 return err;
13059 }
13060 }
13061 return 0;
13062}
13063
13064/* add playback controls for speaker and HP outputs */
13065static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13066 const char *pfx)
13067{
13068 hda_nid_t nid;
13069 int err;
13070 char name[32];
13071
13072 if (!pin)
13073 return 0;
13074
13075 if (alc880_is_fixed_pin(pin)) {
13076 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13077 /* printk("DAC nid=%x\n",nid); */
13078 /* specify the DAC as the extra output */
13079 if (!spec->multiout.hp_nid)
13080 spec->multiout.hp_nid = nid;
13081 else
13082 spec->multiout.extra_out_nid[0] = nid;
13083 /* control HP volume/switch on the output mixer amp */
13084 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13085 sprintf(name, "%s Playback Volume", pfx);
13086 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13087 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13088 if (err < 0)
13089 return err;
13090 sprintf(name, "%s Playback Switch", pfx);
13091 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13092 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13093 if (err < 0)
13094 return err;
13095 } else if (alc880_is_multi_pin(pin)) {
13096 /* set manual connection */
13097 /* we have only a switch on HP-out PIN */
13098 sprintf(name, "%s Playback Switch", pfx);
13099 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13100 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13101 if (err < 0)
13102 return err;
13103 }
13104 return 0;
13105}
13106
13107/* create playback/capture controls for input pins */
13108static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13109 const struct auto_pin_cfg *cfg)
13110{
13111 struct hda_input_mux *imux = &spec->private_imux;
13112 int i, err, idx;
13113
13114 for (i = 0; i < AUTO_PIN_LAST; i++) {
13115 if (alc880_is_input_pin(cfg->input_pins[i])) {
13116 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13117 err = new_analog_input(spec, cfg->input_pins[i],
13118 auto_pin_cfg_labels[i],
13119 idx, 0x0b);
13120 if (err < 0)
13121 return err;
13122 imux->items[imux->num_items].label =
13123 auto_pin_cfg_labels[i];
13124 imux->items[imux->num_items].index =
13125 alc880_input_pin_idx(cfg->input_pins[i]);
13126 imux->num_items++;
13127 }
13128 }
13129 return 0;
13130}
13131
13132static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13133 hda_nid_t nid, int pin_type,
13134 int dac_idx)
13135{
13136 /* set as output */
13137 snd_hda_codec_write(codec, nid, 0,
13138 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13139 snd_hda_codec_write(codec, nid, 0,
13140 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13141 /* need the manual connection? */
13142 if (alc880_is_multi_pin(nid)) {
13143 struct alc_spec *spec = codec->spec;
13144 int idx = alc880_multi_pin_idx(nid);
13145 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13146 AC_VERB_SET_CONNECT_SEL,
13147 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13148 }
13149}
13150
13151static void alc662_auto_init_multi_out(struct hda_codec *codec)
13152{
13153 struct alc_spec *spec = codec->spec;
13154 int i;
13155
Kailang Yang8c427222008-01-10 13:03:59 +010013156 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013157 for (i = 0; i <= HDA_SIDE; i++) {
13158 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013159 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013160 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013161 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013162 i);
13163 }
13164}
13165
13166static void alc662_auto_init_hp_out(struct hda_codec *codec)
13167{
13168 struct alc_spec *spec = codec->spec;
13169 hda_nid_t pin;
13170
13171 pin = spec->autocfg.hp_pins[0];
13172 if (pin) /* connect to front */
13173 /* use dac 0 */
13174 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13175}
13176
13177#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13178#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13179
13180static void alc662_auto_init_analog_input(struct hda_codec *codec)
13181{
13182 struct alc_spec *spec = codec->spec;
13183 int i;
13184
13185 for (i = 0; i < AUTO_PIN_LAST; i++) {
13186 hda_nid_t nid = spec->autocfg.input_pins[i];
13187 if (alc662_is_input_pin(nid)) {
13188 snd_hda_codec_write(codec, nid, 0,
13189 AC_VERB_SET_PIN_WIDGET_CONTROL,
13190 (i <= AUTO_PIN_FRONT_MIC ?
13191 PIN_VREF80 : PIN_IN));
13192 if (nid != ALC662_PIN_CD_NID)
13193 snd_hda_codec_write(codec, nid, 0,
13194 AC_VERB_SET_AMP_GAIN_MUTE,
13195 AMP_OUT_MUTE);
13196 }
13197 }
13198}
13199
13200static int alc662_parse_auto_config(struct hda_codec *codec)
13201{
13202 struct alc_spec *spec = codec->spec;
13203 int err;
13204 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13205
13206 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13207 alc662_ignore);
13208 if (err < 0)
13209 return err;
13210 if (!spec->autocfg.line_outs)
13211 return 0; /* can't find valid BIOS pin config */
13212
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013213 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13214 if (err < 0)
13215 return err;
13216 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13217 if (err < 0)
13218 return err;
13219 err = alc662_auto_create_extra_out(spec,
13220 spec->autocfg.speaker_pins[0],
13221 "Speaker");
13222 if (err < 0)
13223 return err;
13224 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13225 "Headphone");
13226 if (err < 0)
13227 return err;
13228 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13229 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013230 return err;
13231
13232 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13233
13234 if (spec->autocfg.dig_out_pin)
13235 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13236
13237 if (spec->kctl_alloc)
13238 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13239
13240 spec->num_mux_defs = 1;
13241 spec->input_mux = &spec->private_imux;
13242
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013243 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013244 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13245 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013246 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013247}
13248
13249/* additional initialization for auto-configuration model */
13250static void alc662_auto_init(struct hda_codec *codec)
13251{
13252 alc662_auto_init_multi_out(codec);
13253 alc662_auto_init_hp_out(codec);
13254 alc662_auto_init_analog_input(codec);
13255}
13256
13257static int patch_alc662(struct hda_codec *codec)
13258{
13259 struct alc_spec *spec;
13260 int err, board_config;
13261
13262 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13263 if (!spec)
13264 return -ENOMEM;
13265
13266 codec->spec = spec;
13267
13268 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13269 alc662_models,
13270 alc662_cfg_tbl);
13271 if (board_config < 0) {
13272 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13273 "trying auto-probe from BIOS...\n");
13274 board_config = ALC662_AUTO;
13275 }
13276
13277 if (board_config == ALC662_AUTO) {
13278 /* automatic parse from the BIOS config */
13279 err = alc662_parse_auto_config(codec);
13280 if (err < 0) {
13281 alc_free(codec);
13282 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013283 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013284 printk(KERN_INFO
13285 "hda_codec: Cannot set up configuration "
13286 "from BIOS. Using base mode...\n");
13287 board_config = ALC662_3ST_2ch_DIG;
13288 }
13289 }
13290
13291 if (board_config != ALC662_AUTO)
13292 setup_preset(spec, &alc662_presets[board_config]);
13293
13294 spec->stream_name_analog = "ALC662 Analog";
13295 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13296 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13297
13298 spec->stream_name_digital = "ALC662 Digital";
13299 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13300 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13301
13302 if (!spec->adc_nids && spec->input_mux) {
13303 spec->adc_nids = alc662_adc_nids;
13304 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13305 }
13306
13307 codec->patch_ops = alc_patch_ops;
13308 if (board_config == ALC662_AUTO)
13309 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013310#ifdef CONFIG_SND_HDA_POWER_SAVE
13311 if (!spec->loopback.amplist)
13312 spec->loopback.amplist = alc662_loopbacks;
13313#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013314
13315 return 0;
13316}
13317
13318/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013319 * patch entries
13320 */
13321struct hda_codec_preset snd_hda_preset_realtek[] = {
13322 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013323 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013324 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013325 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013326 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013327 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013328 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013329 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13330 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13331 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013332 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13333 .patch = patch_alc883 },
13334 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13335 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013336 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013337 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013338 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013339 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013340 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013341 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013342 {} /* terminator */
13343};