blob: 990714e2bcb33a2d0472c411f9ce20e99ba3d244 [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
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
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,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010076#ifdef CONFIG_SND_DEBUG
77 ALC260_TEST,
78#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010079 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020080 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081};
82
Kailang Yangdf694da2005-12-05 19:42:22 +010083/* ALC262 models */
84enum {
85 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020086 ALC262_HIPPO,
87 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010088 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020089 ALC262_HP_BPC,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020090 ALC262_BENQ_ED8,
Kailang Yangdf694da2005-12-05 19:42:22 +010091 ALC262_AUTO,
92 ALC262_MODEL_LAST /* last tag */
93};
94
95/* ALC861 models */
96enum {
97 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020098 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +010099 ALC861_3ST_DIG,
100 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200101 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200102 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200103 ALC861_ASUS,
Kailang Yangdf694da2005-12-05 19:42:22 +0100104 ALC861_AUTO,
105 ALC861_MODEL_LAST,
106};
107
108/* ALC882 models */
109enum {
110 ALC882_3ST_DIG,
111 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200112 ALC882_ARIMA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC882_AUTO,
114 ALC882_MODEL_LAST,
115};
116
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200117/* ALC883 models */
118enum {
119 ALC883_3ST_2ch_DIG,
120 ALC883_3ST_6ch_DIG,
121 ALC883_3ST_6ch,
122 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200123 ALC883_TARGA_DIG,
124 ALC883_TARGA_2ch_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200125 ALC888_DEMO_BOARD,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200126 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200127 ALC883_MEDION,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200128 ALC883_AUTO,
129 ALC883_MODEL_LAST,
130};
131
Kailang Yangdf694da2005-12-05 19:42:22 +0100132/* for GPIO Poll */
133#define GPIO_MASK 0x03
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135struct alc_spec {
136 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100137 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 unsigned int num_mixers;
139
Kailang Yangdf694da2005-12-05 19:42:22 +0100140 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200141 * don't forget NULL
142 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200143 */
144 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Takashi Iwai16ded522005-06-10 19:58:24 +0200146 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 struct hda_pcm_stream *stream_analog_playback;
148 struct hda_pcm_stream *stream_analog_capture;
149
Takashi Iwai16ded522005-06-10 19:58:24 +0200150 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 struct hda_pcm_stream *stream_digital_playback;
152 struct hda_pcm_stream *stream_digital_capture;
153
154 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200155 struct hda_multi_out multiout; /* playback set-up
156 * max_channels, dacs must be set
157 * dig_out_nid and hp_nid are optional
158 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160 /* capture */
161 unsigned int num_adc_nids;
162 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200163 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
165 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200166 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 const struct hda_input_mux *input_mux;
168 unsigned int cur_mux[3];
169
170 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100171 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200173 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100176 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200177
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200178 /* dynamic controls, init_verbs and input_mux */
179 struct auto_pin_cfg autocfg;
180 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100181 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200182 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100183 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100184
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100185 /* hooks */
186 void (*init_hook)(struct hda_codec *codec);
187 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
188
Takashi Iwai834be882006-03-01 14:16:17 +0100189 /* for pin sensing */
190 unsigned int sense_updated: 1;
191 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100192};
193
194/*
195 * configuration template - to be copied to the spec instance
196 */
197struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200198 struct snd_kcontrol_new *mixers[5]; /* should be identical size
199 * with spec
200 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100201 const struct hda_verb *init_verbs[5];
202 unsigned int num_dacs;
203 hda_nid_t *dac_nids;
204 hda_nid_t dig_out_nid; /* optional */
205 hda_nid_t hp_nid; /* optional */
206 unsigned int num_adc_nids;
207 hda_nid_t *adc_nids;
208 hda_nid_t dig_in_nid;
209 unsigned int num_channel_mode;
210 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200211 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200212 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100213 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100214 void (*unsol_event)(struct hda_codec *, unsigned int);
215 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216};
217
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219/*
220 * input MUX handling
221 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200222static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
223 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224{
225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
226 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200227 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
228 if (mux_idx >= spec->num_mux_defs)
229 mux_idx = 0;
230 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231}
232
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200233static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
234 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235{
236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
237 struct alc_spec *spec = codec->spec;
238 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
239
240 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
241 return 0;
242}
243
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200244static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
245 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246{
247 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
248 struct alc_spec *spec = codec->spec;
249 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200250 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
251 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200252 spec->adc_nids[adc_idx],
253 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254}
255
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257/*
258 * channel mode setting
259 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200260static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
261 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
264 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100265 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
266 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267}
268
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200269static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
270 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271{
272 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
273 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100274 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200275 spec->num_channel_mode,
276 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
278
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200279static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
280 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
283 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200284 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
285 spec->num_channel_mode,
286 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200287 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200288 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
289 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290}
291
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100293 * Control the mode of pin widget settings via the mixer. "pc" is used
294 * instead of "%" to avoid consequences of accidently treating the % as
295 * being part of a format specifier. Maximum allowed length of a value is
296 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100297 *
298 * Note: some retasking pin complexes seem to ignore requests for input
299 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
300 * are requested. Therefore order this list so that this behaviour will not
301 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200302 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
303 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200304 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100305static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100306 "Mic 50pc bias", "Mic 80pc bias",
307 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100308};
309static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100310 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100311};
312/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313 * in the pin being assumed to be exclusively an input or an output pin. In
314 * addition, "input" pins may or may not process the mic bias option
315 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
316 * accept requests for bias as of chip versions up to March 2006) and/or
317 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100318 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200319#define ALC_PIN_DIR_IN 0x00
320#define ALC_PIN_DIR_OUT 0x01
321#define ALC_PIN_DIR_INOUT 0x02
322#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
323#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100324
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200325/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100326 * For each direction the minimum and maximum values are given.
327 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200328static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100329 { 0, 2 }, /* ALC_PIN_DIR_IN */
330 { 3, 4 }, /* ALC_PIN_DIR_OUT */
331 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200332 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
333 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100334};
335#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
336#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
337#define alc_pin_mode_n_items(_dir) \
338 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
339
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200340static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200342{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100343 unsigned int item_num = uinfo->value.enumerated.item;
344 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
345
346 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200347 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100348 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
349
350 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
351 item_num = alc_pin_mode_min(dir);
352 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200353 return 0;
354}
355
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200356static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200358{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100359 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
361 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100362 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200363 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200364 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
365 AC_VERB_GET_PIN_WIDGET_CONTROL,
366 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200367
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100368 /* Find enumerated value for current pinctl setting */
369 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200370 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100371 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200372 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100373 return 0;
374}
375
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200376static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
377 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100378{
379 signed int change;
380 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
381 hda_nid_t nid = kcontrol->private_value & 0xffff;
382 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
383 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200384 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
385 AC_VERB_GET_PIN_WIDGET_CONTROL,
386 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100387
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200388 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100389 val = alc_pin_mode_min(dir);
390
391 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100392 if (change) {
393 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200394 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200395 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100396
397 /* Also enable the retasking pin's input/output as required
398 * for the requested pin mode. Enum values of 2 or less are
399 * input modes.
400 *
401 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200402 * reduces noise slightly (particularly on input) so we'll
403 * do it. However, having both input and output buffers
404 * enabled simultaneously doesn't seem to be problematic if
405 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100406 */
407 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200408 snd_hda_codec_write(codec, nid, 0,
409 AC_VERB_SET_AMP_GAIN_MUTE,
410 AMP_OUT_MUTE);
411 snd_hda_codec_write(codec, nid, 0,
412 AC_VERB_SET_AMP_GAIN_MUTE,
413 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100414 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200415 snd_hda_codec_write(codec, nid, 0,
416 AC_VERB_SET_AMP_GAIN_MUTE,
417 AMP_IN_MUTE(0));
418 snd_hda_codec_write(codec, nid, 0,
419 AC_VERB_SET_AMP_GAIN_MUTE,
420 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100421 }
422 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200423 return change;
424}
425
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200427 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428 .info = alc_pin_mode_info, \
429 .get = alc_pin_mode_get, \
430 .put = alc_pin_mode_put, \
431 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100432
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100433/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
434 * together using a mask with more than one bit set. This control is
435 * currently used only by the ALC260 test model. At this stage they are not
436 * needed for any "production" models.
437 */
438#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100441{
442 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
443 uinfo->count = 1;
444 uinfo->value.integer.min = 0;
445 uinfo->value.integer.max = 1;
446 return 0;
447}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100450{
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 hda_nid_t nid = kcontrol->private_value & 0xffff;
453 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
454 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455 unsigned int val = snd_hda_codec_read(codec, nid, 0,
456 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100457
458 *valp = (val & mask) != 0;
459 return 0;
460}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100463{
464 signed int change;
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 hda_nid_t nid = kcontrol->private_value & 0xffff;
467 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
468 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
470 AC_VERB_GET_GPIO_DATA,
471 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100472
473 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200474 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
475 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100476 gpio_data &= ~mask;
477 else
478 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200479 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100480
481 return change;
482}
483#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
484 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
485 .info = alc_gpio_data_info, \
486 .get = alc_gpio_data_get, \
487 .put = alc_gpio_data_put, \
488 .private_value = nid | (mask<<16) }
489#endif /* CONFIG_SND_DEBUG */
490
Jonathan Woithe92621f12006-02-28 11:47:47 +0100491/* A switch control to allow the enabling of the digital IO pins on the
492 * ALC260. This is incredibly simplistic; the intention of this control is
493 * to provide something in the test model allowing digital outputs to be
494 * identified if present. If models are found which can utilise these
495 * outputs a more complete mixer control can be devised for those models if
496 * necessary.
497 */
498#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100501{
502 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
503 uinfo->count = 1;
504 uinfo->value.integer.min = 0;
505 uinfo->value.integer.max = 1;
506 return 0;
507}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200508static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
509 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100510{
511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
512 hda_nid_t nid = kcontrol->private_value & 0xffff;
513 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
514 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515 unsigned int val = snd_hda_codec_read(codec, nid, 0,
516 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100517
518 *valp = (val & mask) != 0;
519 return 0;
520}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200521static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
522 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100523{
524 signed int change;
525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
526 hda_nid_t nid = kcontrol->private_value & 0xffff;
527 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
528 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
530 AC_VERB_GET_DIGI_CONVERT,
531 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100532
533 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100535 if (val==0)
536 ctrl_data &= ~mask;
537 else
538 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
540 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100541
542 return change;
543}
544#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
545 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
546 .info = alc_spdif_ctrl_info, \
547 .get = alc_spdif_ctrl_get, \
548 .put = alc_spdif_ctrl_put, \
549 .private_value = nid | (mask<<16) }
550#endif /* CONFIG_SND_DEBUG */
551
Kailang Yangdf694da2005-12-05 19:42:22 +0100552/*
553 * set up from the preset table
554 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555static void setup_preset(struct alc_spec *spec,
556 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100557{
558 int i;
559
560 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
561 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
563 i++)
564 spec->init_verbs[spec->num_init_verbs++] =
565 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100566
567 spec->channel_mode = preset->channel_mode;
568 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200569 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100570
571 spec->multiout.max_channels = spec->channel_mode[0].channels;
572
573 spec->multiout.num_dacs = preset->num_dacs;
574 spec->multiout.dac_nids = preset->dac_nids;
575 spec->multiout.dig_out_nid = preset->dig_out_nid;
576 spec->multiout.hp_nid = preset->hp_nid;
577
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200578 spec->num_mux_defs = preset->num_mux_defs;
579 if (! spec->num_mux_defs)
580 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100581 spec->input_mux = preset->input_mux;
582
583 spec->num_adc_nids = preset->num_adc_nids;
584 spec->adc_nids = preset->adc_nids;
585 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100586
587 spec->unsol_event = preset->unsol_event;
588 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100589}
590
Takashi Iwai41e41f12005-06-08 14:48:49 +0200591/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200592 * ALC880 3-stack model
593 *
594 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
596 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 */
598
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200599static hda_nid_t alc880_dac_nids[4] = {
600 /* front, rear, clfe, rear_surr */
601 0x02, 0x05, 0x04, 0x03
602};
603
604static hda_nid_t alc880_adc_nids[3] = {
605 /* ADC0-2 */
606 0x07, 0x08, 0x09,
607};
608
609/* The datasheet says the node 0x07 is connected from inputs,
610 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100611 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200613static hda_nid_t alc880_adc_nids_alt[2] = {
614 /* ADC1-2 */
615 0x08, 0x09,
616};
617
618#define ALC880_DIGOUT_NID 0x06
619#define ALC880_DIGIN_NID 0x0a
620
621static struct hda_input_mux alc880_capture_source = {
622 .num_items = 4,
623 .items = {
624 { "Mic", 0x0 },
625 { "Front Mic", 0x3 },
626 { "Line", 0x2 },
627 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200629};
630
631/* channel source setting (2/6 channel selection for 3-stack) */
632/* 2ch mode */
633static struct hda_verb alc880_threestack_ch2_init[] = {
634 /* set line-in to input, mute it */
635 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
636 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
637 /* set mic-in to input vref 80%, mute it */
638 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
639 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 { } /* end */
641};
642
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200643/* 6ch mode */
644static struct hda_verb alc880_threestack_ch6_init[] = {
645 /* set line-in to output, unmute it */
646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
648 /* set mic-in to output, unmute it */
649 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
650 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
651 { } /* end */
652};
653
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100654static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200655 { 2, alc880_threestack_ch2_init },
656 { 6, alc880_threestack_ch6_init },
657};
658
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100659static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200660 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100661 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200662 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100663 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200664 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
665 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100666 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
667 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
669 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
670 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
671 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
674 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
675 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
676 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
677 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200679 {
680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
681 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100682 .info = alc_ch_mode_info,
683 .get = alc_ch_mode_get,
684 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200685 },
686 { } /* end */
687};
688
689/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100690static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200691 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
692 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
693 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
694 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
695 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
696 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
697 {
698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
699 /* The multiple "Capture Source" controls confuse alsamixer
700 * So call somewhat different..
701 * FIXME: the controls appear in the "playback" view!
702 */
703 /* .name = "Capture Source", */
704 .name = "Input Source",
705 .count = 3,
706 .info = alc_mux_enum_info,
707 .get = alc_mux_enum_get,
708 .put = alc_mux_enum_put,
709 },
710 { } /* end */
711};
712
713/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100714static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200715 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
716 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
717 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
718 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 {
720 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
721 /* The multiple "Capture Source" controls confuse alsamixer
722 * So call somewhat different..
723 * FIXME: the controls appear in the "playback" view!
724 */
725 /* .name = "Capture Source", */
726 .name = "Input Source",
727 .count = 2,
728 .info = alc_mux_enum_info,
729 .get = alc_mux_enum_get,
730 .put = alc_mux_enum_put,
731 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 { } /* end */
733};
734
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200735
736
737/*
738 * ALC880 5-stack model
739 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200740 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
741 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200742 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
743 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
744 */
745
746/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100747static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200748 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100749 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 { } /* end */
751};
752
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200753/* channel source setting (6/8 channel selection for 5-stack) */
754/* 6ch mode */
755static struct hda_verb alc880_fivestack_ch6_init[] = {
756 /* set line-in to input, mute it */
757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
758 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200759 { } /* end */
760};
761
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200762/* 8ch mode */
763static struct hda_verb alc880_fivestack_ch8_init[] = {
764 /* set line-in to output, unmute it */
765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
767 { } /* end */
768};
769
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100770static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200771 { 6, alc880_fivestack_ch6_init },
772 { 8, alc880_fivestack_ch8_init },
773};
774
775
776/*
777 * ALC880 6-stack model
778 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
780 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200781 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
782 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
783 */
784
785static hda_nid_t alc880_6st_dac_nids[4] = {
786 /* front, rear, clfe, rear_surr */
787 0x02, 0x03, 0x04, 0x05
788};
789
790static struct hda_input_mux alc880_6stack_capture_source = {
791 .num_items = 4,
792 .items = {
793 { "Mic", 0x0 },
794 { "Front Mic", 0x1 },
795 { "Line", 0x2 },
796 { "CD", 0x4 },
797 },
798};
799
800/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100801static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200802 { 8, NULL },
803};
804
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100805static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100809 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200810 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
811 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100812 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
813 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200814 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100815 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200816 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
817 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
824 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
825 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200826 {
827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
828 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100829 .info = alc_ch_mode_info,
830 .get = alc_ch_mode_get,
831 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200832 },
833 { } /* end */
834};
835
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200836
837/*
838 * ALC880 W810 model
839 *
840 * W810 has rear IO for:
841 * Front (DAC 02)
842 * Surround (DAC 03)
843 * Center/LFE (DAC 04)
844 * Digital out (06)
845 *
846 * The system also has a pair of internal speakers, and a headphone jack.
847 * These are both connected to Line2 on the codec, hence to DAC 02.
848 *
849 * There is a variable resistor to control the speaker or headphone
850 * volume. This is a hardware-only device without a software API.
851 *
852 * Plugging headphones in will disable the internal speakers. This is
853 * implemented in hardware, not via the driver using jack sense. In
854 * a similar fashion, plugging into the rear socket marked "front" will
855 * disable both the speakers and headphones.
856 *
857 * For input, there's a microphone jack, and an "audio in" jack.
858 * These may not do anything useful with this driver yet, because I
859 * haven't setup any initialization verbs for these yet...
860 */
861
862static hda_nid_t alc880_w810_dac_nids[3] = {
863 /* front, rear/surround, clfe */
864 0x02, 0x03, 0x04
865};
866
867/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100868static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200869 { 6, NULL }
870};
871
872/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100873static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100875 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
879 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100880 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
881 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
883 { } /* end */
884};
885
886
887/*
888 * Z710V model
889 *
890 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200891 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
892 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200893 */
894
895static hda_nid_t alc880_z71v_dac_nids[1] = {
896 0x02
897};
898#define ALC880_Z71V_HP_DAC 0x03
899
900/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100901static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200902 { 2, NULL }
903};
904
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100905static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200908 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100909 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
914 { } /* end */
915};
916
917
918/* FIXME! */
919/*
920 * ALC880 F1734 model
921 *
922 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
923 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
924 */
925
926static hda_nid_t alc880_f1734_dac_nids[1] = {
927 0x03
928};
929#define ALC880_F1734_HP_DAC 0x02
930
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100931static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100933 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200934 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100935 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
939 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200940 { } /* end */
941};
942
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200943
944/* FIXME! */
945/*
946 * ALC880 ASUS model
947 *
948 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
949 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
950 * Mic = 0x18, Line = 0x1a
951 */
952
953#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
954#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
955
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100956static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100958 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200959 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100960 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200961 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
962 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100963 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
964 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200971 {
972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
973 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100974 .info = alc_ch_mode_info,
975 .get = alc_ch_mode_get,
976 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200977 },
978 { } /* end */
979};
980
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200981/* FIXME! */
982/*
983 * ALC880 ASUS W1V model
984 *
985 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
986 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
987 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
988 */
989
990/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100991static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200992 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
993 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200994 { } /* end */
995};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200996
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200997/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100998static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200999 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1000 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1001 { } /* end */
1002};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001003
Kailang Yangdf694da2005-12-05 19:42:22 +01001004/* TCL S700 */
1005static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1007 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1009 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1010 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1013 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1014 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1015 {
1016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1017 /* The multiple "Capture Source" controls confuse alsamixer
1018 * So call somewhat different..
1019 * FIXME: the controls appear in the "playback" view!
1020 */
1021 /* .name = "Capture Source", */
1022 .name = "Input Source",
1023 .count = 1,
1024 .info = alc_mux_enum_info,
1025 .get = alc_mux_enum_get,
1026 .put = alc_mux_enum_put,
1027 },
1028 { } /* end */
1029};
1030
Kailang Yangccc656c2006-10-17 12:32:26 +02001031/* Uniwill */
1032static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1033 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1034 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1035 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1036 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1037 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1038 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1039 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1040 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1047 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1048 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1049 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1050 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1051 {
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1053 .name = "Channel Mode",
1054 .info = alc_ch_mode_info,
1055 .get = alc_ch_mode_get,
1056 .put = alc_ch_mode_put,
1057 },
1058 { } /* end */
1059};
1060
1061static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1062 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1063 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1064 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1065 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1068 { } /* end */
1069};
1070
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 */
1074static int alc_build_controls(struct hda_codec *codec)
1075{
1076 struct alc_spec *spec = codec->spec;
1077 int err;
1078 int i;
1079
1080 for (i = 0; i < spec->num_mixers; i++) {
1081 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1082 if (err < 0)
1083 return err;
1084 }
1085
1086 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001087 err = snd_hda_create_spdif_out_ctls(codec,
1088 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 if (err < 0)
1090 return err;
1091 }
1092 if (spec->dig_in_nid) {
1093 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1094 if (err < 0)
1095 return err;
1096 }
1097 return 0;
1098}
1099
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001100
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101/*
1102 * initialize the codec volumes, etc
1103 */
1104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001105/*
1106 * generic initialization of ADC, input mixers and output mixers
1107 */
1108static struct hda_verb alc880_volume_init_verbs[] = {
1109 /*
1110 * Unmute ADC0-2 and set the default input to mic-in
1111 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001112 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001114 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001116 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001119 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1120 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001121 * Note: PASD motherboards uses the Line In 2 as the input for front
1122 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001124 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001131 /*
1132 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001134 /* set vol=0 to output mixers */
1135 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1138 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1139 /* set up input amps for analog loopback */
1140 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1148 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149
1150 { }
1151};
1152
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001153/*
1154 * 3-stack pin configuration:
1155 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1156 */
1157static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1158 /*
1159 * preset connection lists of input pins
1160 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1161 */
1162 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1163 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1164 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1165
1166 /*
1167 * Set pin mode and muting
1168 */
1169 /* set front pin widgets 0x14 for output */
1170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1171 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1172 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1175 /* Mic2 (as headphone out) for HP output */
1176 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1177 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1178 /* Line In pin widget for input */
1179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1180 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1181 /* Line2 (as front mic) pin widget for input and vref at 80% */
1182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1184 /* CD pin widget for input */
1185 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1186
1187 { }
1188};
1189
1190/*
1191 * 5-stack pin configuration:
1192 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1193 * line-in/side = 0x1a, f-mic = 0x1b
1194 */
1195static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1196 /*
1197 * preset connection lists of input pins
1198 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1199 */
1200 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1201 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1202
1203 /*
1204 * Set pin mode and muting
1205 */
1206 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1209 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1210 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001211 /* unmute pins for output (no gain on this amp) */
1212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1214 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1215 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1216
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001219 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1220 /* Mic2 (as headphone out) for HP output */
1221 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001223 /* Line In pin widget for input */
1224 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1226 /* Line2 (as front mic) pin widget for input and vref at 80% */
1227 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1228 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1229 /* CD pin widget for input */
1230 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231
1232 { }
1233};
1234
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001235/*
1236 * W810 pin configuration:
1237 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1238 */
1239static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 /* hphone/speaker input selector: front DAC */
1241 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1242
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1244 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1247 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1248 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1249
1250 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001251 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 { }
1254};
1255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256/*
1257 * Z71V pin configuration:
1258 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1259 */
1260static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001265
Takashi Iwai16ded522005-06-10 19:58:24 +02001266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001268 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001269 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001270
1271 { }
1272};
1273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001274/*
1275 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001276 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1277 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001278 */
1279static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1280 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1281
Takashi Iwai16ded522005-06-10 19:58:24 +02001282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001286 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001287 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001288 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001289 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1290
Takashi Iwai16ded522005-06-10 19:58:24 +02001291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001293 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001295 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001297 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001298 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001299 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1300
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001301 { }
1302};
Takashi Iwai16ded522005-06-10 19:58:24 +02001303
Kailang Yangccc656c2006-10-17 12:32:26 +02001304/*
1305 * Uniwill pin configuration:
1306 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1307 * line = 0x1a
1308 */
1309static struct hda_verb alc880_uniwill_init_verbs[] = {
1310 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1311
1312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1315 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1317 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1318 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1319 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1326
1327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1328 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1329 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1333 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1334 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1335 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1336
1337 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1338 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1339
1340 { }
1341};
1342
1343/*
1344* Uniwill P53
1345* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1346 */
1347static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1348 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1349
1350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1355 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1360 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1362
1363 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1364 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1365 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1366 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1367 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1368 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1369
1370 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1371 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1372
1373 { }
1374};
1375
1376/* toggle speaker-output according to the hp-jack state */
1377static void alc880_uniwill_automute(struct hda_codec *codec)
1378{
1379 unsigned int present;
1380
1381 present = snd_hda_codec_read(codec, 0x14, 0,
1382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1383 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1384 0x80, present ? 0x80 : 0);
1385 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1386 0x80, present ? 0x80 : 0);
1387 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1388 0x80, present ? 0x80 : 0);
1389 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1390 0x80, present ? 0x80 : 0);
1391
1392 present = snd_hda_codec_read(codec, 0x18, 0,
1393 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1394 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1395 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1396}
1397
1398static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1399 unsigned int res)
1400{
1401 /* Looks like the unsol event is incompatible with the standard
1402 * definition. 4bit tag is placed at 28 bit!
1403 */
1404 if ((res >> 28) == ALC880_HP_EVENT ||
1405 (res >> 28) == ALC880_MIC_EVENT)
1406 alc880_uniwill_automute(codec);
1407}
1408
1409static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1410{
1411 unsigned int present;
1412
1413 present = snd_hda_codec_read(codec, 0x14, 0,
1414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1415
1416 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1417 0x80, present ? 0x80 : 0);
1418 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1419 0x80, present ? 0x80 : 0);
1420}
1421
1422static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1423{
1424 unsigned int present;
1425
1426 present = snd_hda_codec_read(codec, 0x21, 0,
1427 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1428
1429 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1430 0x7f, present);
1431 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1432 0x7f, present);
1433
1434 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1435 0x7f, present);
1436 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1437 0x7f, present);
1438
1439}
1440static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1441 unsigned int res)
1442{
1443 /* Looks like the unsol event is incompatible with the standard
1444 * definition. 4bit tag is placed at 28 bit!
1445 */
1446 if ((res >> 28) == ALC880_HP_EVENT)
1447 alc880_uniwill_p53_hp_automute(codec);
1448 if ((res >> 28) == ALC880_DCVOL_EVENT)
1449 alc880_uniwill_p53_dcvol_automute(codec);
1450}
1451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001452/* FIXME! */
1453/*
1454 * F1734 pin configuration:
1455 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1456 */
1457static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1458 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1459 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1460 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1461 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1462
1463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467
1468 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1469 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1470 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1471 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1476 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001477
1478 { }
1479};
1480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001481/* FIXME! */
1482/*
1483 * ASUS pin configuration:
1484 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1485 */
1486static struct hda_verb alc880_pin_asus_init_verbs[] = {
1487 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1488 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1489 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1490 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1491
1492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500
1501 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1503 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1510
1511 { }
1512};
1513
1514/* Enable GPIO mask and set output */
1515static struct hda_verb alc880_gpio1_init_verbs[] = {
1516 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1517 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1518 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001519
1520 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001521};
1522
1523/* Enable GPIO mask and set output */
1524static struct hda_verb alc880_gpio2_init_verbs[] = {
1525 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1526 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1527 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001528
1529 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001530};
1531
Kailang Yangdf694da2005-12-05 19:42:22 +01001532/* Clevo m520g init */
1533static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1534 /* headphone output */
1535 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1536 /* line-out */
1537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1539 /* Line-in */
1540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1542 /* CD */
1543 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1544 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1545 /* Mic1 (rear panel) */
1546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1548 /* Mic2 (front panel) */
1549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1550 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1551 /* headphone */
1552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1554 /* change to EAPD mode */
1555 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1556 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1557
1558 { }
1559};
1560
1561static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001562 /* change to EAPD mode */
1563 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1564 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1565
Kailang Yangdf694da2005-12-05 19:42:22 +01001566 /* Headphone output */
1567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1568 /* Front output*/
1569 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1570 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1571
1572 /* Line In pin widget for input */
1573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1574 /* CD pin widget for input */
1575 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1576 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1577 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1578
1579 /* change to EAPD mode */
1580 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1581 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1582
1583 { }
1584};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001585
1586/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001587 * LG m1 express dual
1588 *
1589 * Pin assignment:
1590 * Rear Line-In/Out (blue): 0x14
1591 * Build-in Mic-In: 0x15
1592 * Speaker-out: 0x17
1593 * HP-Out (green): 0x1b
1594 * Mic-In/Out (red): 0x19
1595 * SPDIF-Out: 0x1e
1596 */
1597
1598/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1599static hda_nid_t alc880_lg_dac_nids[3] = {
1600 0x05, 0x02, 0x03
1601};
1602
1603/* seems analog CD is not working */
1604static struct hda_input_mux alc880_lg_capture_source = {
1605 .num_items = 3,
1606 .items = {
1607 { "Mic", 0x1 },
1608 { "Line", 0x5 },
1609 { "Internal Mic", 0x6 },
1610 },
1611};
1612
1613/* 2,4,6 channel modes */
1614static struct hda_verb alc880_lg_ch2_init[] = {
1615 /* set line-in and mic-in to input */
1616 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1617 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1618 { }
1619};
1620
1621static struct hda_verb alc880_lg_ch4_init[] = {
1622 /* set line-in to out and mic-in to input */
1623 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1624 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1625 { }
1626};
1627
1628static struct hda_verb alc880_lg_ch6_init[] = {
1629 /* set line-in and mic-in to output */
1630 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1631 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1632 { }
1633};
1634
1635static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1636 { 2, alc880_lg_ch2_init },
1637 { 4, alc880_lg_ch4_init },
1638 { 6, alc880_lg_ch6_init },
1639};
1640
1641static struct snd_kcontrol_new alc880_lg_mixer[] = {
1642 /* FIXME: it's not really "master" but front channels */
1643 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1644 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1645 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1646 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1647 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1648 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1649 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1650 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1653 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1654 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1655 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1656 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1657 {
1658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1659 .name = "Channel Mode",
1660 .info = alc_ch_mode_info,
1661 .get = alc_ch_mode_get,
1662 .put = alc_ch_mode_put,
1663 },
1664 { } /* end */
1665};
1666
1667static struct hda_verb alc880_lg_init_verbs[] = {
1668 /* set capture source to mic-in */
1669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1670 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1671 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1672 /* mute all amp mixer inputs */
1673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1676 /* line-in to input */
1677 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1679 /* built-in mic */
1680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1682 /* speaker-out */
1683 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1685 /* mic-in to input */
1686 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1689 /* HP-out */
1690 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1692 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693 /* jack sense */
1694 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1695 { }
1696};
1697
1698/* toggle speaker-output according to the hp-jack state */
1699static void alc880_lg_automute(struct hda_codec *codec)
1700{
1701 unsigned int present;
1702
1703 present = snd_hda_codec_read(codec, 0x1b, 0,
1704 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1705 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1706 0x80, present ? 0x80 : 0);
1707 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1708 0x80, present ? 0x80 : 0);
1709}
1710
1711static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1712{
1713 /* Looks like the unsol event is incompatible with the standard
1714 * definition. 4bit tag is placed at 28 bit!
1715 */
1716 if ((res >> 28) == 0x01)
1717 alc880_lg_automute(codec);
1718}
1719
1720/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001721 * LG LW20
1722 *
1723 * Pin assignment:
1724 * Speaker-out: 0x14
1725 * Mic-In: 0x18
1726 * Built-in Mic-In: 0x19 (?)
1727 * HP-Out: 0x1b
1728 * SPDIF-Out: 0x1e
1729 */
1730
1731/* seems analog CD is not working */
1732static struct hda_input_mux alc880_lg_lw_capture_source = {
1733 .num_items = 2,
1734 .items = {
1735 { "Mic", 0x0 },
1736 { "Internal Mic", 0x1 },
1737 },
1738};
1739
1740static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1741 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1742 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1745 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1746 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1747 { } /* end */
1748};
1749
1750static struct hda_verb alc880_lg_lw_init_verbs[] = {
1751 /* set capture source to mic-in */
1752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1756 /* speaker-out */
1757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759 /* HP-out */
1760 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1761 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 /* mic-in to input */
1764 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1765 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1766 /* built-in mic */
1767 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1768 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1769 /* jack sense */
1770 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1771 { }
1772};
1773
1774/* toggle speaker-output according to the hp-jack state */
1775static void alc880_lg_lw_automute(struct hda_codec *codec)
1776{
1777 unsigned int present;
1778
1779 present = snd_hda_codec_read(codec, 0x1b, 0,
1780 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1781 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1782 0x80, present ? 0x80 : 0);
1783 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1784 0x80, present ? 0x80 : 0);
1785}
1786
1787static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1788{
1789 /* Looks like the unsol event is incompatible with the standard
1790 * definition. 4bit tag is placed at 28 bit!
1791 */
1792 if ((res >> 28) == 0x01)
1793 alc880_lg_lw_automute(codec);
1794}
1795
1796/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001797 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001798 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001799
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800static int alc_init(struct hda_codec *codec)
1801{
1802 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803 unsigned int i;
1804
1805 for (i = 0; i < spec->num_init_verbs; i++)
1806 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001807
1808 if (spec->init_hook)
1809 spec->init_hook(codec);
1810
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811 return 0;
1812}
1813
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001814static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1815{
1816 struct alc_spec *spec = codec->spec;
1817
1818 if (spec->unsol_event)
1819 spec->unsol_event(codec, res);
1820}
1821
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822#ifdef CONFIG_PM
1823/*
1824 * resume
1825 */
1826static int alc_resume(struct hda_codec *codec)
1827{
1828 struct alc_spec *spec = codec->spec;
1829 int i;
1830
1831 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 if (spec->multiout.dig_out_nid)
1835 snd_hda_resume_spdif_out(codec);
1836 if (spec->dig_in_nid)
1837 snd_hda_resume_spdif_in(codec);
1838
1839 return 0;
1840}
1841#endif
1842
1843/*
1844 * Analog playback callbacks
1845 */
1846static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1847 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001848 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849{
1850 struct alc_spec *spec = codec->spec;
1851 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1852}
1853
1854static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1855 struct hda_codec *codec,
1856 unsigned int stream_tag,
1857 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001858 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859{
1860 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001861 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1862 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863}
1864
1865static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1866 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001867 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868{
1869 struct alc_spec *spec = codec->spec;
1870 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1871}
1872
1873/*
1874 * Digital out
1875 */
1876static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1877 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001878 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879{
1880 struct alc_spec *spec = codec->spec;
1881 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1882}
1883
1884static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1885 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001886 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887{
1888 struct alc_spec *spec = codec->spec;
1889 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1890}
1891
1892/*
1893 * Analog capture
1894 */
1895static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1896 struct hda_codec *codec,
1897 unsigned int stream_tag,
1898 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001899 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900{
1901 struct alc_spec *spec = codec->spec;
1902
1903 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1904 stream_tag, 0, format);
1905 return 0;
1906}
1907
1908static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1909 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001910 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911{
1912 struct alc_spec *spec = codec->spec;
1913
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001914 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1915 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 return 0;
1917}
1918
1919
1920/*
1921 */
1922static struct hda_pcm_stream alc880_pcm_analog_playback = {
1923 .substreams = 1,
1924 .channels_min = 2,
1925 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001926 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 .ops = {
1928 .open = alc880_playback_pcm_open,
1929 .prepare = alc880_playback_pcm_prepare,
1930 .cleanup = alc880_playback_pcm_cleanup
1931 },
1932};
1933
1934static struct hda_pcm_stream alc880_pcm_analog_capture = {
1935 .substreams = 2,
1936 .channels_min = 2,
1937 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001938 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 .ops = {
1940 .prepare = alc880_capture_pcm_prepare,
1941 .cleanup = alc880_capture_pcm_cleanup
1942 },
1943};
1944
1945static struct hda_pcm_stream alc880_pcm_digital_playback = {
1946 .substreams = 1,
1947 .channels_min = 2,
1948 .channels_max = 2,
1949 /* NID is set in alc_build_pcms */
1950 .ops = {
1951 .open = alc880_dig_playback_pcm_open,
1952 .close = alc880_dig_playback_pcm_close
1953 },
1954};
1955
1956static struct hda_pcm_stream alc880_pcm_digital_capture = {
1957 .substreams = 1,
1958 .channels_min = 2,
1959 .channels_max = 2,
1960 /* NID is set in alc_build_pcms */
1961};
1962
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001963/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1964static struct hda_pcm_stream alc_pcm_null_playback = {
1965 .substreams = 0,
1966 .channels_min = 0,
1967 .channels_max = 0,
1968};
1969
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970static int alc_build_pcms(struct hda_codec *codec)
1971{
1972 struct alc_spec *spec = codec->spec;
1973 struct hda_pcm *info = spec->pcm_rec;
1974 int i;
1975
1976 codec->num_pcms = 1;
1977 codec->pcm_info = info;
1978
1979 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001980 if (spec->stream_analog_playback) {
1981 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1982 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1983 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1984 }
1985 if (spec->stream_analog_capture) {
1986 snd_assert(spec->adc_nids, return -EINVAL);
1987 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1988 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1989 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990
Takashi Iwai4a471b72005-12-07 13:56:29 +01001991 if (spec->channel_mode) {
1992 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1993 for (i = 0; i < spec->num_channel_mode; i++) {
1994 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1995 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1996 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997 }
1998 }
1999
Takashi Iwaie08a0072006-09-07 17:52:14 +02002000 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002002 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002003 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002005 if (spec->multiout.dig_out_nid &&
2006 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2008 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2009 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002010 if (spec->dig_in_nid &&
2011 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2013 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2014 }
2015 }
2016
Takashi Iwaie08a0072006-09-07 17:52:14 +02002017 /* If the use of more than one ADC is requested for the current
2018 * model, configure a second analog capture-only PCM.
2019 */
2020 /* Additional Analaog capture for index #2 */
2021 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2022 spec->adc_nids) {
2023 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002024 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002025 info->name = spec->stream_name_analog;
2026 /* No playback stream for second PCM */
2027 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2028 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2029 if (spec->stream_analog_capture) {
2030 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2031 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2032 }
2033 }
2034
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035 return 0;
2036}
2037
2038static void alc_free(struct hda_codec *codec)
2039{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002040 struct alc_spec *spec = codec->spec;
2041 unsigned int i;
2042
2043 if (! spec)
2044 return;
2045
2046 if (spec->kctl_alloc) {
2047 for (i = 0; i < spec->num_kctl_used; i++)
2048 kfree(spec->kctl_alloc[i].name);
2049 kfree(spec->kctl_alloc);
2050 }
2051 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052}
2053
2054/*
2055 */
2056static struct hda_codec_ops alc_patch_ops = {
2057 .build_controls = alc_build_controls,
2058 .build_pcms = alc_build_pcms,
2059 .init = alc_init,
2060 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002061 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062#ifdef CONFIG_PM
2063 .resume = alc_resume,
2064#endif
2065};
2066
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002067
2068/*
2069 * Test configuration for debugging
2070 *
2071 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2072 * enum controls.
2073 */
2074#ifdef CONFIG_SND_DEBUG
2075static hda_nid_t alc880_test_dac_nids[4] = {
2076 0x02, 0x03, 0x04, 0x05
2077};
2078
2079static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002080 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002081 .items = {
2082 { "In-1", 0x0 },
2083 { "In-2", 0x1 },
2084 { "In-3", 0x2 },
2085 { "In-4", 0x3 },
2086 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002087 { "Front", 0x5 },
2088 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002089 },
2090};
2091
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002092static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002093 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002094 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002095 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002096 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002097};
2098
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002099static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2100 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002101{
2102 static char *texts[] = {
2103 "N/A", "Line Out", "HP Out",
2104 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2105 };
2106 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2107 uinfo->count = 1;
2108 uinfo->value.enumerated.items = 8;
2109 if (uinfo->value.enumerated.item >= 8)
2110 uinfo->value.enumerated.item = 7;
2111 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2112 return 0;
2113}
2114
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002115static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2116 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002117{
2118 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2119 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2120 unsigned int pin_ctl, item = 0;
2121
2122 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2123 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2124 if (pin_ctl & AC_PINCTL_OUT_EN) {
2125 if (pin_ctl & AC_PINCTL_HP_EN)
2126 item = 2;
2127 else
2128 item = 1;
2129 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2130 switch (pin_ctl & AC_PINCTL_VREFEN) {
2131 case AC_PINCTL_VREF_HIZ: item = 3; break;
2132 case AC_PINCTL_VREF_50: item = 4; break;
2133 case AC_PINCTL_VREF_GRD: item = 5; break;
2134 case AC_PINCTL_VREF_80: item = 6; break;
2135 case AC_PINCTL_VREF_100: item = 7; break;
2136 }
2137 }
2138 ucontrol->value.enumerated.item[0] = item;
2139 return 0;
2140}
2141
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002142static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2143 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002144{
2145 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2146 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2147 static unsigned int ctls[] = {
2148 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2149 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2150 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2151 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2152 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2153 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2154 };
2155 unsigned int old_ctl, new_ctl;
2156
2157 old_ctl = snd_hda_codec_read(codec, nid, 0,
2158 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2159 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2160 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002161 snd_hda_codec_write(codec, nid, 0,
2162 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002164 (ucontrol->value.enumerated.item[0] >= 3 ?
2165 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002166 return 1;
2167 }
2168 return 0;
2169}
2170
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002171static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2172 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002173{
2174 static char *texts[] = {
2175 "Front", "Surround", "CLFE", "Side"
2176 };
2177 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2178 uinfo->count = 1;
2179 uinfo->value.enumerated.items = 4;
2180 if (uinfo->value.enumerated.item >= 4)
2181 uinfo->value.enumerated.item = 3;
2182 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2183 return 0;
2184}
2185
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002186static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2187 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002188{
2189 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2190 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2191 unsigned int sel;
2192
2193 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2194 ucontrol->value.enumerated.item[0] = sel & 3;
2195 return 0;
2196}
2197
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002198static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2199 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002200{
2201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2202 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2203 unsigned int sel;
2204
2205 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2206 if (ucontrol->value.enumerated.item[0] != sel) {
2207 sel = ucontrol->value.enumerated.item[0] & 3;
2208 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2209 return 1;
2210 }
2211 return 0;
2212}
2213
2214#define PIN_CTL_TEST(xname,nid) { \
2215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2216 .name = xname, \
2217 .info = alc_test_pin_ctl_info, \
2218 .get = alc_test_pin_ctl_get, \
2219 .put = alc_test_pin_ctl_put, \
2220 .private_value = nid \
2221 }
2222
2223#define PIN_SRC_TEST(xname,nid) { \
2224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2225 .name = xname, \
2226 .info = alc_test_pin_src_info, \
2227 .get = alc_test_pin_src_get, \
2228 .put = alc_test_pin_src_put, \
2229 .private_value = nid \
2230 }
2231
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002232static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2234 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2235 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2236 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2238 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2239 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2240 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002241 PIN_CTL_TEST("Front Pin Mode", 0x14),
2242 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2243 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2244 PIN_CTL_TEST("Side Pin Mode", 0x17),
2245 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2246 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2247 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2248 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2249 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2250 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2251 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2252 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2253 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2254 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2255 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2256 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2257 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2258 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2259 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2260 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2261 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2262 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002263 {
2264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2265 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002266 .info = alc_ch_mode_info,
2267 .get = alc_ch_mode_get,
2268 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002269 },
2270 { } /* end */
2271};
2272
2273static struct hda_verb alc880_test_init_verbs[] = {
2274 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002283 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2287 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002288 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002293 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2296 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002298 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2302 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2303 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002304 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002305 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2306 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002309 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002311 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002313 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002314 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002315 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002316 /* Analog input/passthru */
2317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002322 { }
2323};
2324#endif
2325
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326/*
2327 */
2328
2329static struct hda_board_config alc880_cfg_tbl[] = {
2330 /* Back 3 jack, front 2 jack */
2331 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002332 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2333 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2334 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2335 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2336 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2337 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2338 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2339 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2340 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2341 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2342 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2343 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2344 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2345 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2346 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2347 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2348 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2349 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002350 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
2351 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002352 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002353 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002354 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2355 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2356 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2357 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2358 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2359 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2360 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2361 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2362 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2363 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2364 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2365 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2366 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002367 /* TCL S700 */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002368 { .modelname = "tcl", .config = ALC880_TCL_S700 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002369 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370
2371 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002372 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002373 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002374 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375
2376 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2377 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002378 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe3c2005-08-15 20:01:40 +02002379 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Takashi Iwai5a053d02006-07-25 14:51:15 +02002380
2381 /* Clevo laptops */
2382 { .modelname = "clevo", .config = ALC880_CLEVO },
2383 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2384 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2385 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2386 .config = ALC880_CLEVO }, /* Clevo m665n */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002387
2388 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002389 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2390 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2391 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392
2393 /* Back 5 jack, front 2 jack */
2394 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002395 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2396 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2397 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2398 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002399 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400
2401 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2402 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002403 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2404 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2405 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2406 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2407 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2408 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2409 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2410 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002411 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002412 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2413 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002414 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002415 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002416 /* note subvendor = 0 below */
2417 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418
2419 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002420 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002422 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002423 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002424
Takashi Iwaib6482d42005-06-27 15:32:43 +02002425 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002426 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002427 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002428 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002429 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002430
2431 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002432 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2433 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2434 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2435 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002436 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2437 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2438 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2439 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002440 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002441 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002442 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Takashi Iwai16ded522005-06-10 19:58:24 +02002443
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002444 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002445 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2446 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2447 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2448 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002449 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002450 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
Danny Tholenf5a5ffa2006-08-08 18:59:07 +02002451 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
Takashi Iwai16ded522005-06-10 19:58:24 +02002452 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2453 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2454 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2455 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002456 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
Takashi Iwai16ded522005-06-10 19:58:24 +02002457 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002458 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
Takashi Iwai84f34302006-03-21 19:12:53 +01002459 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002460 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002461 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002462
2463 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
Kailang Yangccc656c2006-10-17 12:32:26 +02002464 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2465 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9070, .config = ALC880_UNIWILL },
2466 { .pci_subvendor = 0x1734, .pci_subdevice = 0x10ac, .config = ALC880_UNIWILL },
2467 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9077, .config = ALC880_UNIWILL_P53 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002468
2469 { .modelname = "F1734", .config = ALC880_F1734 },
2470 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002471 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002472
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002473 { .modelname = "lg", .config = ALC880_LG },
2474 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
Takashi Iwai886da862006-05-02 18:17:57 +02002475 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002476
Takashi Iwaid6815182006-03-23 16:06:23 +01002477 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2478 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
Takashi Iwaicd417d42006-09-06 16:03:11 +02002479 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
Takashi Iwaid6815182006-03-23 16:06:23 +01002480
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002481#ifdef CONFIG_SND_DEBUG
2482 { .modelname = "test", .config = ALC880_TEST },
2483#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002484 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002485
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486 {}
2487};
2488
Takashi Iwai16ded522005-06-10 19:58:24 +02002489/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002490 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002491 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002492static struct alc_config_preset alc880_presets[] = {
2493 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494 .mixers = { alc880_three_stack_mixer },
2495 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002496 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002497 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002498 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2499 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002500 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002501 .input_mux = &alc880_capture_source,
2502 },
2503 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 .mixers = { alc880_three_stack_mixer },
2505 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002506 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002507 .dac_nids = alc880_dac_nids,
2508 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002509 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2510 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002511 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002512 .input_mux = &alc880_capture_source,
2513 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002514 [ALC880_TCL_S700] = {
2515 .mixers = { alc880_tcl_s700_mixer },
2516 .init_verbs = { alc880_volume_init_verbs,
2517 alc880_pin_tcl_S700_init_verbs,
2518 alc880_gpio2_init_verbs },
2519 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2520 .dac_nids = alc880_dac_nids,
2521 .hp_nid = 0x03,
2522 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2523 .channel_mode = alc880_2_jack_modes,
2524 .input_mux = &alc880_capture_source,
2525 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002526 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002527 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2528 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002529 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2530 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002531 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2532 .channel_mode = alc880_fivestack_modes,
2533 .input_mux = &alc880_capture_source,
2534 },
2535 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002536 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2537 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002538 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2539 .dac_nids = alc880_dac_nids,
2540 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002541 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2542 .channel_mode = alc880_fivestack_modes,
2543 .input_mux = &alc880_capture_source,
2544 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002545 [ALC880_6ST] = {
2546 .mixers = { alc880_six_stack_mixer },
2547 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2548 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2549 .dac_nids = alc880_6st_dac_nids,
2550 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2551 .channel_mode = alc880_sixstack_modes,
2552 .input_mux = &alc880_6stack_capture_source,
2553 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002554 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 .mixers = { alc880_six_stack_mixer },
2556 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002557 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2558 .dac_nids = alc880_6st_dac_nids,
2559 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002560 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2561 .channel_mode = alc880_sixstack_modes,
2562 .input_mux = &alc880_6stack_capture_source,
2563 },
2564 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002565 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002566 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2567 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002568 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2569 .dac_nids = alc880_w810_dac_nids,
2570 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002571 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2572 .channel_mode = alc880_w810_modes,
2573 .input_mux = &alc880_capture_source,
2574 },
2575 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002576 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002577 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002578 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2579 .dac_nids = alc880_z71v_dac_nids,
2580 .dig_out_nid = ALC880_DIGOUT_NID,
2581 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002582 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2583 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002584 .input_mux = &alc880_capture_source,
2585 },
2586 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587 .mixers = { alc880_f1734_mixer },
2588 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2589 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2590 .dac_nids = alc880_f1734_dac_nids,
2591 .hp_nid = 0x02,
2592 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2593 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002594 .input_mux = &alc880_capture_source,
2595 },
2596 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 .mixers = { alc880_asus_mixer },
2598 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2599 alc880_gpio1_init_verbs },
2600 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2601 .dac_nids = alc880_asus_dac_nids,
2602 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2603 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002604 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002605 .input_mux = &alc880_capture_source,
2606 },
2607 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608 .mixers = { alc880_asus_mixer },
2609 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2610 alc880_gpio1_init_verbs },
2611 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2612 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002613 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2615 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002616 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002617 .input_mux = &alc880_capture_source,
2618 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002619 [ALC880_ASUS_DIG2] = {
2620 .mixers = { alc880_asus_mixer },
2621 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2622 alc880_gpio2_init_verbs }, /* use GPIO2 */
2623 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2624 .dac_nids = alc880_asus_dac_nids,
2625 .dig_out_nid = ALC880_DIGOUT_NID,
2626 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2627 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002628 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002629 .input_mux = &alc880_capture_source,
2630 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002631 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2633 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2634 alc880_gpio1_init_verbs },
2635 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2636 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002637 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2639 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002640 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002641 .input_mux = &alc880_capture_source,
2642 },
2643 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002644 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002645 .init_verbs = { alc880_volume_init_verbs,
2646 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002647 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2648 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002649 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2651 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002652 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002653 .input_mux = &alc880_capture_source,
2654 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002655 [ALC880_UNIWILL] = {
2656 .mixers = { alc880_uniwill_mixer },
2657 .init_verbs = { alc880_volume_init_verbs,
2658 alc880_uniwill_init_verbs },
2659 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2660 .dac_nids = alc880_asus_dac_nids,
2661 .dig_out_nid = ALC880_DIGOUT_NID,
2662 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2663 .channel_mode = alc880_threestack_modes,
2664 .need_dac_fix = 1,
2665 .input_mux = &alc880_capture_source,
2666 .unsol_event = alc880_uniwill_unsol_event,
2667 .init_hook = alc880_uniwill_automute,
2668 },
2669 [ALC880_UNIWILL_P53] = {
2670 .mixers = { alc880_uniwill_p53_mixer },
2671 .init_verbs = { alc880_volume_init_verbs,
2672 alc880_uniwill_p53_init_verbs },
2673 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2674 .dac_nids = alc880_asus_dac_nids,
2675 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2676 .channel_mode = alc880_w810_modes,
2677 .input_mux = &alc880_capture_source,
2678 .unsol_event = alc880_uniwill_p53_unsol_event,
2679 .init_hook = alc880_uniwill_p53_hp_automute,
2680 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002681 [ALC880_CLEVO] = {
2682 .mixers = { alc880_three_stack_mixer },
2683 .init_verbs = { alc880_volume_init_verbs,
2684 alc880_pin_clevo_init_verbs },
2685 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2686 .dac_nids = alc880_dac_nids,
2687 .hp_nid = 0x03,
2688 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2689 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002690 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002691 .input_mux = &alc880_capture_source,
2692 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002693 [ALC880_LG] = {
2694 .mixers = { alc880_lg_mixer },
2695 .init_verbs = { alc880_volume_init_verbs,
2696 alc880_lg_init_verbs },
2697 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2698 .dac_nids = alc880_lg_dac_nids,
2699 .dig_out_nid = ALC880_DIGOUT_NID,
2700 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2701 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002702 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002703 .input_mux = &alc880_lg_capture_source,
2704 .unsol_event = alc880_lg_unsol_event,
2705 .init_hook = alc880_lg_automute,
2706 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002707 [ALC880_LG_LW] = {
2708 .mixers = { alc880_lg_lw_mixer },
2709 .init_verbs = { alc880_volume_init_verbs,
2710 alc880_lg_lw_init_verbs },
2711 .num_dacs = 1,
2712 .dac_nids = alc880_dac_nids,
2713 .dig_out_nid = ALC880_DIGOUT_NID,
2714 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2715 .channel_mode = alc880_2_jack_modes,
2716 .input_mux = &alc880_lg_lw_capture_source,
2717 .unsol_event = alc880_lg_lw_unsol_event,
2718 .init_hook = alc880_lg_lw_automute,
2719 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002720#ifdef CONFIG_SND_DEBUG
2721 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 .mixers = { alc880_test_mixer },
2723 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2725 .dac_nids = alc880_test_dac_nids,
2726 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002727 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2728 .channel_mode = alc880_test_modes,
2729 .input_mux = &alc880_test_capture_source,
2730 },
2731#endif
2732};
2733
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734/*
2735 * Automatic parse of I/O pins from the BIOS configuration
2736 */
2737
2738#define NUM_CONTROL_ALLOC 32
2739#define NUM_VERB_ALLOC 32
2740
2741enum {
2742 ALC_CTL_WIDGET_VOL,
2743 ALC_CTL_WIDGET_MUTE,
2744 ALC_CTL_BIND_MUTE,
2745};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002746static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2748 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002749 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750};
2751
2752/* add dynamic controls */
2753static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2754{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002755 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002756
2757 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2758 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2759
2760 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2761 if (! knew)
2762 return -ENOMEM;
2763 if (spec->kctl_alloc) {
2764 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2765 kfree(spec->kctl_alloc);
2766 }
2767 spec->kctl_alloc = knew;
2768 spec->num_kctl_alloc = num;
2769 }
2770
2771 knew = &spec->kctl_alloc[spec->num_kctl_used];
2772 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002773 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 if (! knew->name)
2775 return -ENOMEM;
2776 knew->private_value = val;
2777 spec->num_kctl_used++;
2778 return 0;
2779}
2780
2781#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2782#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2783#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2784#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2785#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2786#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2787#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2788#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2789#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2790#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2791#define ALC880_PIN_CD_NID 0x1c
2792
2793/* fill in the dac_nids table from the parsed pin configuration */
2794static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2795{
2796 hda_nid_t nid;
2797 int assigned[4];
2798 int i, j;
2799
2800 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002801 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802
2803 /* check the pins hardwired to audio widget */
2804 for (i = 0; i < cfg->line_outs; i++) {
2805 nid = cfg->line_out_pins[i];
2806 if (alc880_is_fixed_pin(nid)) {
2807 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002808 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002809 assigned[idx] = 1;
2810 }
2811 }
2812 /* left pins can be connect to any audio widget */
2813 for (i = 0; i < cfg->line_outs; i++) {
2814 nid = cfg->line_out_pins[i];
2815 if (alc880_is_fixed_pin(nid))
2816 continue;
2817 /* search for an empty channel */
2818 for (j = 0; j < cfg->line_outs; j++) {
2819 if (! assigned[j]) {
2820 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2821 assigned[j] = 1;
2822 break;
2823 }
2824 }
2825 }
2826 spec->multiout.num_dacs = cfg->line_outs;
2827 return 0;
2828}
2829
2830/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002831static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2832 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833{
2834 char name[32];
2835 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2836 hda_nid_t nid;
2837 int i, err;
2838
2839 for (i = 0; i < cfg->line_outs; i++) {
2840 if (! spec->multiout.dac_nids[i])
2841 continue;
2842 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2843 if (i == 2) {
2844 /* Center/LFE */
2845 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2846 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2847 return err;
2848 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2849 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2850 return err;
2851 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2852 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2853 return err;
2854 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2855 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2856 return err;
2857 } else {
2858 sprintf(name, "%s Playback Volume", chname[i]);
2859 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2860 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2861 return err;
2862 sprintf(name, "%s Playback Switch", chname[i]);
2863 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2864 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2865 return err;
2866 }
2867 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868 return 0;
2869}
2870
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002871/* add playback controls for speaker and HP outputs */
2872static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2873 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002874{
2875 hda_nid_t nid;
2876 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002877 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002878
2879 if (! pin)
2880 return 0;
2881
2882 if (alc880_is_fixed_pin(pin)) {
2883 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002884 /* specify the DAC as the extra output */
2885 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002886 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002887 else
2888 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002889 /* control HP volume/switch on the output mixer amp */
2890 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002891 sprintf(name, "%s Playback Volume", pfx);
2892 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002893 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2894 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002895 sprintf(name, "%s Playback Switch", pfx);
2896 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002897 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2898 return err;
2899 } else if (alc880_is_multi_pin(pin)) {
2900 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002902 sprintf(name, "%s Playback Switch", pfx);
2903 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002904 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2905 return err;
2906 }
2907 return 0;
2908}
2909
2910/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002911static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2912 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913{
2914 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002915 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916
2917 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002918 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002919 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002920 return err;
2921 sprintf(name, "%s Playback Switch", ctlname);
2922 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002923 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002924 return err;
2925 return 0;
2926}
2927
2928/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002929static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2930 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002931{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002932 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002933 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934
2935 for (i = 0; i < AUTO_PIN_LAST; i++) {
2936 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002937 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002938 err = new_analog_input(spec, cfg->input_pins[i],
2939 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002940 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002941 if (err < 0)
2942 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002943 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002944 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2945 imux->num_items++;
2946 }
2947 }
2948 return 0;
2949}
2950
Kailang Yangdf694da2005-12-05 19:42:22 +01002951static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2952 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002953 int dac_idx)
2954{
2955 /* set as output */
2956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2957 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2958 /* need the manual connection? */
2959 if (alc880_is_multi_pin(nid)) {
2960 struct alc_spec *spec = codec->spec;
2961 int idx = alc880_multi_pin_idx(nid);
2962 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2963 AC_VERB_SET_CONNECT_SEL,
2964 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2965 }
2966}
2967
2968static void alc880_auto_init_multi_out(struct hda_codec *codec)
2969{
2970 struct alc_spec *spec = codec->spec;
2971 int i;
2972
2973 for (i = 0; i < spec->autocfg.line_outs; i++) {
2974 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2975 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2976 }
2977}
2978
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002979static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002980{
2981 struct alc_spec *spec = codec->spec;
2982 hda_nid_t pin;
2983
Takashi Iwai82bc9552006-03-21 11:24:42 +01002984 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002985 if (pin) /* connect to front */
2986 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002987 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002988 if (pin) /* connect to front */
2989 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2990}
2991
2992static void alc880_auto_init_analog_input(struct hda_codec *codec)
2993{
2994 struct alc_spec *spec = codec->spec;
2995 int i;
2996
2997 for (i = 0; i < AUTO_PIN_LAST; i++) {
2998 hda_nid_t nid = spec->autocfg.input_pins[i];
2999 if (alc880_is_input_pin(nid)) {
3000 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3001 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3002 if (nid != ALC880_PIN_CD_NID)
3003 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3004 AMP_OUT_MUTE);
3005 }
3006 }
3007}
3008
3009/* parse the BIOS configuration and set up the alc_spec */
3010/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3011static int alc880_parse_auto_config(struct hda_codec *codec)
3012{
3013 struct alc_spec *spec = codec->spec;
3014 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003015 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003016
Kailang Yangdf694da2005-12-05 19:42:22 +01003017 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3018 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003020 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003022
3023 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
3024 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01003025 (err = alc880_auto_create_extra_out(spec,
3026 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003027 "Speaker")) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003028 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003029 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003030 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3031 return err;
3032
3033 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3034
3035 if (spec->autocfg.dig_out_pin)
3036 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3037 if (spec->autocfg.dig_in_pin)
3038 spec->dig_in_nid = ALC880_DIGIN_NID;
3039
3040 if (spec->kctl_alloc)
3041 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3042
3043 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3044
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003045 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046 spec->input_mux = &spec->private_imux;
3047
3048 return 1;
3049}
3050
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003051/* additional initialization for auto-configuration model */
3052static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003055 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003056 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057}
3058
3059/*
3060 * OK, here we have finally the patch for ALC880
3061 */
3062
Linus Torvalds1da177e2005-04-16 15:20:36 -07003063static int patch_alc880(struct hda_codec *codec)
3064{
3065 struct alc_spec *spec;
3066 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003067 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003069 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003070 if (spec == NULL)
3071 return -ENOMEM;
3072
3073 codec->spec = spec;
3074
3075 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02003076 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003077 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3078 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003080 }
3081
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 if (board_config == ALC880_AUTO) {
3083 /* automatic parse from the BIOS config */
3084 err = alc880_parse_auto_config(codec);
3085 if (err < 0) {
3086 alc_free(codec);
3087 return err;
3088 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003089 printk(KERN_INFO
3090 "hda_codec: Cannot set up configuration "
3091 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003092 board_config = ALC880_3ST;
3093 }
3094 }
3095
Kailang Yangdf694da2005-12-05 19:42:22 +01003096 if (board_config != ALC880_AUTO)
3097 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003098
3099 spec->stream_name_analog = "ALC880 Analog";
3100 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3101 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3102
3103 spec->stream_name_digital = "ALC880 Digital";
3104 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3105 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 if (! spec->adc_nids && spec->input_mux) {
3108 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003109 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3111 if (wcap != AC_WID_AUD_IN) {
3112 spec->adc_nids = alc880_adc_nids_alt;
3113 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3114 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3115 spec->num_mixers++;
3116 } else {
3117 spec->adc_nids = alc880_adc_nids;
3118 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3119 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3120 spec->num_mixers++;
3121 }
3122 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123
3124 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003126 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127
3128 return 0;
3129}
3130
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131
Linus Torvalds1da177e2005-04-16 15:20:36 -07003132/*
3133 * ALC260 support
3134 */
3135
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136static hda_nid_t alc260_dac_nids[1] = {
3137 /* front */
3138 0x02,
3139};
3140
3141static hda_nid_t alc260_adc_nids[1] = {
3142 /* ADC0 */
3143 0x04,
3144};
3145
Kailang Yangdf694da2005-12-05 19:42:22 +01003146static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003147 /* ADC1 */
3148 0x05,
3149};
3150
Kailang Yangdf694da2005-12-05 19:42:22 +01003151static hda_nid_t alc260_hp_adc_nids[2] = {
3152 /* ADC1, 0 */
3153 0x05, 0x04
3154};
3155
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003156/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3157 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3158 */
3159static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003160 /* ADC0, ADC1 */
3161 0x04, 0x05
3162};
3163
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003164#define ALC260_DIGOUT_NID 0x03
3165#define ALC260_DIGIN_NID 0x06
3166
3167static struct hda_input_mux alc260_capture_source = {
3168 .num_items = 4,
3169 .items = {
3170 { "Mic", 0x0 },
3171 { "Front Mic", 0x1 },
3172 { "Line", 0x2 },
3173 { "CD", 0x4 },
3174 },
3175};
3176
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003177/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003178 * headphone jack and the internal CD lines since these are the only pins at
3179 * which audio can appear. For flexibility, also allow the option of
3180 * recording the mixer output on the second ADC (ADC0 doesn't have a
3181 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003182 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003183static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3184 {
3185 .num_items = 3,
3186 .items = {
3187 { "Mic/Line", 0x0 },
3188 { "CD", 0x4 },
3189 { "Headphone", 0x2 },
3190 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003191 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003192 {
3193 .num_items = 4,
3194 .items = {
3195 { "Mic/Line", 0x0 },
3196 { "CD", 0x4 },
3197 { "Headphone", 0x2 },
3198 { "Mixer", 0x5 },
3199 },
3200 },
3201
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003202};
3203
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003204/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3205 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003206 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003207static struct hda_input_mux alc260_acer_capture_sources[2] = {
3208 {
3209 .num_items = 4,
3210 .items = {
3211 { "Mic", 0x0 },
3212 { "Line", 0x2 },
3213 { "CD", 0x4 },
3214 { "Headphone", 0x5 },
3215 },
3216 },
3217 {
3218 .num_items = 5,
3219 .items = {
3220 { "Mic", 0x0 },
3221 { "Line", 0x2 },
3222 { "CD", 0x4 },
3223 { "Headphone", 0x6 },
3224 { "Mixer", 0x5 },
3225 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003226 },
3227};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228/*
3229 * This is just place-holder, so there's something for alc_build_pcms to look
3230 * at when it calculates the maximum number of channels. ALC260 has no mixer
3231 * element which allows changing the channel mode, so the verb list is
3232 * never used.
3233 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003234static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003235 { 2, NULL },
3236};
3237
Kailang Yangdf694da2005-12-05 19:42:22 +01003238
3239/* Mixer combinations
3240 *
3241 * basic: base_output + input + pc_beep + capture
3242 * HP: base_output + input + capture_alt
3243 * HP_3013: hp_3013 + input + capture
3244 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003245 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003246 */
3247
3248static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003249 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003250 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003251 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3252 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3253 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3254 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3255 { } /* end */
3256};
3257
3258static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3260 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3261 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3262 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3264 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3265 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3266 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003267 { } /* end */
3268};
3269
Kailang Yangdf694da2005-12-05 19:42:22 +01003270static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3271 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3272 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3273 { } /* end */
3274};
3275
3276static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3277 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3278 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3279 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3280 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3281 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3282 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3283 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3284 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003285 { } /* end */
3286};
3287
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003288/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3289 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3290 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003291static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003293 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003294 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003295 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3296 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3297 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3298 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003299 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003300 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3301 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3302 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003303 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003304 { } /* end */
3305};
3306
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003307/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3308 * versions of the ALC260 don't act on requests to enable mic bias from NID
3309 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3310 * datasheet doesn't mention this restriction. At this stage it's not clear
3311 * whether this behaviour is intentional or is a hardware bug in chip
3312 * revisions available in early 2006. Therefore for now allow the
3313 * "Headphone Jack Mode" control to span all choices, but if it turns out
3314 * that the lack of mic bias for this NID is intentional we could change the
3315 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3316 *
3317 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3318 * don't appear to make the mic bias available from the "line" jack, even
3319 * though the NID used for this jack (0x14) can supply it. The theory is
3320 * that perhaps Acer have included blocking capacitors between the ALC260
3321 * and the output jack. If this turns out to be the case for all such
3322 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3323 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3324 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003325static struct snd_kcontrol_new alc260_acer_mixer[] = {
3326 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3327 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003328 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003329 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3330 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3332 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3333 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3334 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3335 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3336 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3337 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3338 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3339 { } /* end */
3340};
3341
Kailang Yangdf694da2005-12-05 19:42:22 +01003342/* capture mixer elements */
3343static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003344 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3345 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003346 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3347 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003348 {
3349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003350 /* The multiple "Capture Source" controls confuse alsamixer
3351 * So call somewhat different..
3352 * FIXME: the controls appear in the "playback" view!
3353 */
3354 /* .name = "Capture Source", */
3355 .name = "Input Source",
3356 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003357 .info = alc_mux_enum_info,
3358 .get = alc_mux_enum_get,
3359 .put = alc_mux_enum_put,
3360 },
3361 { } /* end */
3362};
3363
Kailang Yangdf694da2005-12-05 19:42:22 +01003364static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3365 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3366 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3367 {
3368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3369 /* The multiple "Capture Source" controls confuse alsamixer
3370 * So call somewhat different..
3371 * FIXME: the controls appear in the "playback" view!
3372 */
3373 /* .name = "Capture Source", */
3374 .name = "Input Source",
3375 .count = 1,
3376 .info = alc_mux_enum_info,
3377 .get = alc_mux_enum_get,
3378 .put = alc_mux_enum_put,
3379 },
3380 { } /* end */
3381};
3382
3383/*
3384 * initialization verbs
3385 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386static struct hda_verb alc260_init_verbs[] = {
3387 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003392 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003394 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003395 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003397 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003398 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003399 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003400 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003402 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003403 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003404 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3405 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003406 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003407 /* set connection select to line in (default select for this ADC) */
3408 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003409 /* mute capture amp left and right */
3410 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3411 /* set connection select to line in (default select for this ADC) */
3412 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003413 /* set vol=0 Line-Out mixer amp left and right */
3414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3415 /* unmute pin widget amp left and right (no gain on this amp) */
3416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3417 /* set vol=0 HP mixer amp left and right */
3418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3419 /* unmute pin widget amp left and right (no gain on this amp) */
3420 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3421 /* set vol=0 Mono mixer amp left and right */
3422 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3423 /* unmute pin widget amp left and right (no gain on this amp) */
3424 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3425 /* unmute LINE-2 out pin */
3426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003427 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003428 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003430 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003432 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003434 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003435 /* mute Front out path */
3436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3437 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3438 /* mute Headphone out path */
3439 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3441 /* mute Mono out path */
3442 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3443 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003444 { }
3445};
3446
Takashi Iwai474167d2006-05-17 17:17:43 +02003447#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003448static struct hda_verb alc260_hp_init_verbs[] = {
3449 /* Headphone and output */
3450 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3451 /* mono output */
3452 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3453 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3454 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3455 /* Mic2 (front panel) pin widget for input and vref at 80% */
3456 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3457 /* Line In pin widget for input */
3458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3459 /* Line-2 pin widget for output */
3460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3461 /* CD pin widget for input */
3462 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3463 /* unmute amp left and right */
3464 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3465 /* set connection select to line in (default select for this ADC) */
3466 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3467 /* unmute Line-Out mixer amp left and right (volume = 0) */
3468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3469 /* mute pin widget amp left and right (no gain on this amp) */
3470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3471 /* unmute HP mixer amp left and right (volume = 0) */
3472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3473 /* mute pin widget amp left and right (no gain on this amp) */
3474 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3475 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3476 /* unmute CD */
3477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3478 /* unmute Line In */
3479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3480 /* unmute Mic */
3481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3482 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3483 /* Unmute Front out path */
3484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3486 /* Unmute Headphone out path */
3487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3489 /* Unmute Mono out path */
3490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3492 { }
3493};
Takashi Iwai474167d2006-05-17 17:17:43 +02003494#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003495
3496static struct hda_verb alc260_hp_3013_init_verbs[] = {
3497 /* Line out and output */
3498 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3499 /* mono output */
3500 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3501 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3502 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3503 /* Mic2 (front panel) pin widget for input and vref at 80% */
3504 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3505 /* Line In pin widget for input */
3506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3507 /* Headphone pin widget for output */
3508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3509 /* CD pin widget for input */
3510 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3511 /* unmute amp left and right */
3512 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3513 /* set connection select to line in (default select for this ADC) */
3514 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3515 /* unmute Line-Out mixer amp left and right (volume = 0) */
3516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3517 /* mute pin widget amp left and right (no gain on this amp) */
3518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3519 /* unmute HP mixer amp left and right (volume = 0) */
3520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3521 /* mute pin widget amp left and right (no gain on this amp) */
3522 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3523 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3524 /* unmute CD */
3525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3526 /* unmute Line In */
3527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3528 /* unmute Mic */
3529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3530 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3531 /* Unmute Front out path */
3532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3534 /* Unmute Headphone out path */
3535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3537 /* Unmute Mono out path */
3538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3540 { }
3541};
3542
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003543/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003544 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3545 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003546 */
3547static struct hda_verb alc260_fujitsu_init_verbs[] = {
3548 /* Disable all GPIOs */
3549 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3550 /* Internal speaker is connected to headphone pin */
3551 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3552 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003554 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3555 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3556 /* Ensure all other unused pins are disabled and muted. */
3557 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003559 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003560 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003561 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003562 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3563 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003565
Jonathan Woithef7ace402006-02-28 11:46:14 +01003566 /* Disable digital (SPDIF) pins */
3567 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3568 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003569
Jonathan Woithef7ace402006-02-28 11:46:14 +01003570 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3571 * when acting as an output.
3572 */
3573 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3574
3575 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3577 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3579 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3581 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3582 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3583 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3584 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003585
Jonathan Woithef7ace402006-02-28 11:46:14 +01003586 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3587 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3588 /* Unmute Line1 pin widget output buffer since it starts as an output.
3589 * If the pin mode is changed by the user the pin mode control will
3590 * take care of enabling the pin's input/output buffers as needed.
3591 * Therefore there's no need to enable the input buffer at this
3592 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003593 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003595 /* Unmute input buffer of pin widget used for Line-in (no equiv
3596 * mixer ctrl)
3597 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003598 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003599
Jonathan Woithef7ace402006-02-28 11:46:14 +01003600 /* Mute capture amp left and right */
3601 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3602 /* Set ADC connection select to match default mixer setting - line
3603 * in (on mic1 pin)
3604 */
3605 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003606
Jonathan Woithef7ace402006-02-28 11:46:14 +01003607 /* Do the same for the second ADC: mute capture input amp and
3608 * set ADC connection to line in (on mic1 pin)
3609 */
3610 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3611 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003612
Jonathan Woithef7ace402006-02-28 11:46:14 +01003613 /* Mute all inputs to mixer widget (even unconnected ones) */
3614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003622
3623 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003624};
3625
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003626/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3627 * similar laptops (adapted from Fujitsu init verbs).
3628 */
3629static struct hda_verb alc260_acer_init_verbs[] = {
3630 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3631 * the headphone jack. Turn this on and rely on the standard mute
3632 * methods whenever the user wants to turn these outputs off.
3633 */
3634 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3635 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3636 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3637 /* Internal speaker/Headphone jack is connected to Line-out pin */
3638 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3639 /* Internal microphone/Mic jack is connected to Mic1 pin */
3640 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3641 /* Line In jack is connected to Line1 pin */
3642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3643 /* Ensure all other unused pins are disabled and muted. */
3644 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3645 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3646 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3647 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3648 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3649 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3652 /* Disable digital (SPDIF) pins */
3653 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3654 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3655
3656 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3657 * bus when acting as outputs.
3658 */
3659 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3660 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3661
3662 /* Start with output sum widgets muted and their output gains at min */
3663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3665 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3666 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3669 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3671 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3672
3673 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3674 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3675 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3676 * inputs. If the pin mode is changed by the user the pin mode control
3677 * will take care of enabling the pin's input/output buffers as needed.
3678 * Therefore there's no need to enable the input buffer at this
3679 * stage.
3680 */
3681 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683
3684 /* Mute capture amp left and right */
3685 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3686 /* Set ADC connection select to match default mixer setting - mic
3687 * (on mic1 pin)
3688 */
3689 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3690
3691 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003692 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003693 */
3694 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003695 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003696
3697 /* Mute all inputs to mixer widget (even unconnected ones) */
3698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3704 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3705 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3706
3707 { }
3708};
3709
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003710/* Test configuration for debugging, modelled after the ALC880 test
3711 * configuration.
3712 */
3713#ifdef CONFIG_SND_DEBUG
3714static hda_nid_t alc260_test_dac_nids[1] = {
3715 0x02,
3716};
3717static hda_nid_t alc260_test_adc_nids[2] = {
3718 0x04, 0x05,
3719};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003720/* For testing the ALC260, each input MUX needs its own definition since
3721 * the signal assignments are different. This assumes that the first ADC
3722 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003723 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003724static struct hda_input_mux alc260_test_capture_sources[2] = {
3725 {
3726 .num_items = 7,
3727 .items = {
3728 { "MIC1 pin", 0x0 },
3729 { "MIC2 pin", 0x1 },
3730 { "LINE1 pin", 0x2 },
3731 { "LINE2 pin", 0x3 },
3732 { "CD pin", 0x4 },
3733 { "LINE-OUT pin", 0x5 },
3734 { "HP-OUT pin", 0x6 },
3735 },
3736 },
3737 {
3738 .num_items = 8,
3739 .items = {
3740 { "MIC1 pin", 0x0 },
3741 { "MIC2 pin", 0x1 },
3742 { "LINE1 pin", 0x2 },
3743 { "LINE2 pin", 0x3 },
3744 { "CD pin", 0x4 },
3745 { "Mixer", 0x5 },
3746 { "LINE-OUT pin", 0x6 },
3747 { "HP-OUT pin", 0x7 },
3748 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003749 },
3750};
3751static struct snd_kcontrol_new alc260_test_mixer[] = {
3752 /* Output driver widgets */
3753 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3754 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3755 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3756 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3757 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3758 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3759
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003760 /* Modes for retasking pin widgets
3761 * Note: the ALC260 doesn't seem to act on requests to enable mic
3762 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3763 * mention this restriction. At this stage it's not clear whether
3764 * this behaviour is intentional or is a hardware bug in chip
3765 * revisions available at least up until early 2006. Therefore for
3766 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3767 * choices, but if it turns out that the lack of mic bias for these
3768 * NIDs is intentional we could change their modes from
3769 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3770 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003771 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3772 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3773 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3774 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3775 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3776 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3777
3778 /* Loopback mixer controls */
3779 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3780 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3781 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3782 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3783 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3784 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3785 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3786 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3787 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3788 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3789 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3790 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3791 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3792 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3793 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3794 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003795
3796 /* Controls for GPIO pins, assuming they are configured as outputs */
3797 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3798 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3799 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3800 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3801
Jonathan Woithe92621f12006-02-28 11:47:47 +01003802 /* Switches to allow the digital IO pins to be enabled. The datasheet
3803 * is ambigious as to which NID is which; testing on laptops which
3804 * make this output available should provide clarification.
3805 */
3806 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3807 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3808
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003809 { } /* end */
3810};
3811static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003812 /* Enable all GPIOs as outputs with an initial value of 0 */
3813 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3814 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3815 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3816
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003817 /* Enable retasking pins as output, initially without power amp */
3818 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3819 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3822 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3824
Jonathan Woithe92621f12006-02-28 11:47:47 +01003825 /* Disable digital (SPDIF) pins initially, but users can enable
3826 * them via a mixer switch. In the case of SPDIF-out, this initverb
3827 * payload also sets the generation to 0, output to be in "consumer"
3828 * PCM format, copyright asserted, no pre-emphasis and no validity
3829 * control.
3830 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003831 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3832 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3833
Jonathan Woithef7ace402006-02-28 11:46:14 +01003834 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003835 * OUT1 sum bus when acting as an output.
3836 */
3837 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3838 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3839 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3840 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3841
3842 /* Start with output sum widgets muted and their output gains at min */
3843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3849 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3850 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3852
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003853 /* Unmute retasking pin widget output buffers since the default
3854 * state appears to be output. As the pin mode is changed by the
3855 * user the pin mode control will take care of enabling the pin's
3856 * input/output buffers as needed.
3857 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003858 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3859 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3862 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3863 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3864 /* Also unmute the mono-out pin widget */
3865 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3866
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003867 /* Mute capture amp left and right */
3868 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003869 /* Set ADC connection select to match default mixer setting (mic1
3870 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003871 */
3872 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3873
3874 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003875 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003876 */
3877 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3878 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3879
3880 /* Mute all inputs to mixer widget (even unconnected ones) */
3881 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3882 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3889
3890 { }
3891};
3892#endif
3893
Linus Torvalds1da177e2005-04-16 15:20:36 -07003894static struct hda_pcm_stream alc260_pcm_analog_playback = {
3895 .substreams = 1,
3896 .channels_min = 2,
3897 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003898};
3899
3900static struct hda_pcm_stream alc260_pcm_analog_capture = {
3901 .substreams = 1,
3902 .channels_min = 2,
3903 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003904};
3905
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003906#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3907#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3908
Kailang Yangdf694da2005-12-05 19:42:22 +01003909/*
3910 * for BIOS auto-configuration
3911 */
3912
3913static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3914 const char *pfx)
3915{
3916 hda_nid_t nid_vol;
3917 unsigned long vol_val, sw_val;
3918 char name[32];
3919 int err;
3920
3921 if (nid >= 0x0f && nid < 0x11) {
3922 nid_vol = nid - 0x7;
3923 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3924 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3925 } else if (nid == 0x11) {
3926 nid_vol = nid - 0x7;
3927 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3928 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3929 } else if (nid >= 0x12 && nid <= 0x15) {
3930 nid_vol = 0x08;
3931 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3932 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3933 } else
3934 return 0; /* N/A */
3935
3936 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3937 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3938 return err;
3939 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3940 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3941 return err;
3942 return 1;
3943}
3944
3945/* add playback controls from the parsed DAC table */
3946static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3947 const struct auto_pin_cfg *cfg)
3948{
3949 hda_nid_t nid;
3950 int err;
3951
3952 spec->multiout.num_dacs = 1;
3953 spec->multiout.dac_nids = spec->private_dac_nids;
3954 spec->multiout.dac_nids[0] = 0x02;
3955
3956 nid = cfg->line_out_pins[0];
3957 if (nid) {
3958 err = alc260_add_playback_controls(spec, nid, "Front");
3959 if (err < 0)
3960 return err;
3961 }
3962
Takashi Iwai82bc9552006-03-21 11:24:42 +01003963 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003964 if (nid) {
3965 err = alc260_add_playback_controls(spec, nid, "Speaker");
3966 if (err < 0)
3967 return err;
3968 }
3969
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003970 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003971 if (nid) {
3972 err = alc260_add_playback_controls(spec, nid, "Headphone");
3973 if (err < 0)
3974 return err;
3975 }
3976 return 0;
3977}
3978
3979/* create playback/capture controls for input pins */
3980static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3981 const struct auto_pin_cfg *cfg)
3982{
Kailang Yangdf694da2005-12-05 19:42:22 +01003983 struct hda_input_mux *imux = &spec->private_imux;
3984 int i, err, idx;
3985
3986 for (i = 0; i < AUTO_PIN_LAST; i++) {
3987 if (cfg->input_pins[i] >= 0x12) {
3988 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003989 err = new_analog_input(spec, cfg->input_pins[i],
3990 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003991 if (err < 0)
3992 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003993 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003994 imux->items[imux->num_items].index = idx;
3995 imux->num_items++;
3996 }
3997 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3998 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003999 err = new_analog_input(spec, cfg->input_pins[i],
4000 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004001 if (err < 0)
4002 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004003 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004004 imux->items[imux->num_items].index = idx;
4005 imux->num_items++;
4006 }
4007 }
4008 return 0;
4009}
4010
4011static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4012 hda_nid_t nid, int pin_type,
4013 int sel_idx)
4014{
4015 /* set as output */
4016 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4017 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4018 /* need the manual connection? */
4019 if (nid >= 0x12) {
4020 int idx = nid - 0x12;
4021 snd_hda_codec_write(codec, idx + 0x0b, 0,
4022 AC_VERB_SET_CONNECT_SEL, sel_idx);
4023
4024 }
4025}
4026
4027static void alc260_auto_init_multi_out(struct hda_codec *codec)
4028{
4029 struct alc_spec *spec = codec->spec;
4030 hda_nid_t nid;
4031
4032 nid = spec->autocfg.line_out_pins[0];
4033 if (nid)
4034 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4035
Takashi Iwai82bc9552006-03-21 11:24:42 +01004036 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004037 if (nid)
4038 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4039
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004040 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004041 if (nid)
4042 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4043}
4044
4045#define ALC260_PIN_CD_NID 0x16
4046static void alc260_auto_init_analog_input(struct hda_codec *codec)
4047{
4048 struct alc_spec *spec = codec->spec;
4049 int i;
4050
4051 for (i = 0; i < AUTO_PIN_LAST; i++) {
4052 hda_nid_t nid = spec->autocfg.input_pins[i];
4053 if (nid >= 0x12) {
4054 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4055 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4056 if (nid != ALC260_PIN_CD_NID)
4057 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4058 AMP_OUT_MUTE);
4059 }
4060 }
4061}
4062
4063/*
4064 * generic initialization of ADC, input mixers and output mixers
4065 */
4066static struct hda_verb alc260_volume_init_verbs[] = {
4067 /*
4068 * Unmute ADC0-1 and set the default input to mic-in
4069 */
4070 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4072 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4073 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4074
4075 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4076 * mixer widget
4077 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4078 * mic (mic 2)
4079 */
4080 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4086
4087 /*
4088 * Set up output mixers (0x08 - 0x0a)
4089 */
4090 /* set vol=0 to output mixers */
4091 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4093 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4094 /* set up input amps for analog loopback */
4095 /* Amp Indices: DAC = 0, mixer = 1 */
4096 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4100 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4101 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4102
4103 { }
4104};
4105
4106static int alc260_parse_auto_config(struct hda_codec *codec)
4107{
4108 struct alc_spec *spec = codec->spec;
4109 unsigned int wcap;
4110 int err;
4111 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4112
4113 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4114 alc260_ignore)) < 0)
4115 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004116 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4117 return err;
4118 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004119 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004120 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004121 return err;
4122
4123 spec->multiout.max_channels = 2;
4124
4125 if (spec->autocfg.dig_out_pin)
4126 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4127 if (spec->kctl_alloc)
4128 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4129
4130 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4131
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004132 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004133 spec->input_mux = &spec->private_imux;
4134
4135 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004136 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004137 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4138 if (wcap != AC_WID_AUD_IN) {
4139 spec->adc_nids = alc260_adc_nids_alt;
4140 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4141 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004142 } else {
4143 spec->adc_nids = alc260_adc_nids;
4144 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4145 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004146 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004147 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004148
4149 return 1;
4150}
4151
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004152/* additional initialization for auto-configuration model */
4153static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004154{
Kailang Yangdf694da2005-12-05 19:42:22 +01004155 alc260_auto_init_multi_out(codec);
4156 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004157}
4158
4159/*
4160 * ALC260 configurations
4161 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004162static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01004163 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01004164 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
4165 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai3206b9c2006-05-10 16:33:11 +02004166 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
4167 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02004168 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
4169 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01004170 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
4171 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02004172 { .modelname = "hp", .config = ALC260_HP },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004173 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
Takashi Iwai25b6c432006-08-08 13:01:14 +02004174 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004175 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
Takashi Iwai766a6c32006-05-26 14:58:29 +02004176 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004177 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
4178 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
4179 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
4180 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
4181 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
4182 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004183 { .modelname = "acer", .config = ALC260_ACER },
4184 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004185#ifdef CONFIG_SND_DEBUG
4186 { .modelname = "test", .config = ALC260_TEST },
4187#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004188 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02004189 {}
4190};
4191
Kailang Yangdf694da2005-12-05 19:42:22 +01004192static struct alc_config_preset alc260_presets[] = {
4193 [ALC260_BASIC] = {
4194 .mixers = { alc260_base_output_mixer,
4195 alc260_input_mixer,
4196 alc260_pc_beep_mixer,
4197 alc260_capture_mixer },
4198 .init_verbs = { alc260_init_verbs },
4199 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4200 .dac_nids = alc260_dac_nids,
4201 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4202 .adc_nids = alc260_adc_nids,
4203 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4204 .channel_mode = alc260_modes,
4205 .input_mux = &alc260_capture_source,
4206 },
4207 [ALC260_HP] = {
4208 .mixers = { alc260_base_output_mixer,
4209 alc260_input_mixer,
4210 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004211 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004212 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4213 .dac_nids = alc260_dac_nids,
4214 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4215 .adc_nids = alc260_hp_adc_nids,
4216 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4217 .channel_mode = alc260_modes,
4218 .input_mux = &alc260_capture_source,
4219 },
4220 [ALC260_HP_3013] = {
4221 .mixers = { alc260_hp_3013_mixer,
4222 alc260_input_mixer,
4223 alc260_capture_alt_mixer },
4224 .init_verbs = { alc260_hp_3013_init_verbs },
4225 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4226 .dac_nids = alc260_dac_nids,
4227 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4228 .adc_nids = alc260_hp_adc_nids,
4229 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4230 .channel_mode = alc260_modes,
4231 .input_mux = &alc260_capture_source,
4232 },
4233 [ALC260_FUJITSU_S702X] = {
4234 .mixers = { alc260_fujitsu_mixer,
4235 alc260_capture_mixer },
4236 .init_verbs = { alc260_fujitsu_init_verbs },
4237 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4238 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004239 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4240 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004241 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4242 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004243 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4244 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004245 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004246 [ALC260_ACER] = {
4247 .mixers = { alc260_acer_mixer,
4248 alc260_capture_mixer },
4249 .init_verbs = { alc260_acer_init_verbs },
4250 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4251 .dac_nids = alc260_dac_nids,
4252 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4253 .adc_nids = alc260_dual_adc_nids,
4254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4255 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004256 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4257 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004258 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004259#ifdef CONFIG_SND_DEBUG
4260 [ALC260_TEST] = {
4261 .mixers = { alc260_test_mixer,
4262 alc260_capture_mixer },
4263 .init_verbs = { alc260_test_init_verbs },
4264 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4265 .dac_nids = alc260_test_dac_nids,
4266 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4267 .adc_nids = alc260_test_adc_nids,
4268 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4269 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004270 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4271 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004272 },
4273#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004274};
4275
Linus Torvalds1da177e2005-04-16 15:20:36 -07004276static int patch_alc260(struct hda_codec *codec)
4277{
4278 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004279 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004280
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004281 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004282 if (spec == NULL)
4283 return -ENOMEM;
4284
4285 codec->spec = spec;
4286
Takashi Iwai16ded522005-06-10 19:58:24 +02004287 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4288 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004289 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4290 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004291 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004292 }
4293
Kailang Yangdf694da2005-12-05 19:42:22 +01004294 if (board_config == ALC260_AUTO) {
4295 /* automatic parse from the BIOS config */
4296 err = alc260_parse_auto_config(codec);
4297 if (err < 0) {
4298 alc_free(codec);
4299 return err;
4300 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004301 printk(KERN_INFO
4302 "hda_codec: Cannot set up configuration "
4303 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004304 board_config = ALC260_BASIC;
4305 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004306 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307
Kailang Yangdf694da2005-12-05 19:42:22 +01004308 if (board_config != ALC260_AUTO)
4309 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004310
4311 spec->stream_name_analog = "ALC260 Analog";
4312 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4313 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4314
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004315 spec->stream_name_digital = "ALC260 Digital";
4316 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4317 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4318
Linus Torvalds1da177e2005-04-16 15:20:36 -07004319 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004320 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004321 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004322
4323 return 0;
4324}
4325
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326
Linus Torvalds1da177e2005-04-16 15:20:36 -07004327/*
4328 * ALC882 support
4329 *
4330 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4331 * configuration. Each pin widget can choose any input DACs and a mixer.
4332 * Each ADC is connected from a mixer of all inputs. This makes possible
4333 * 6-channel independent captures.
4334 *
4335 * In addition, an independent DAC for the multi-playback (not used in this
4336 * driver yet).
4337 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004338#define ALC882_DIGOUT_NID 0x06
4339#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004340
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004341static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004342 { 8, NULL }
4343};
4344
4345static hda_nid_t alc882_dac_nids[4] = {
4346 /* front, rear, clfe, rear_surr */
4347 0x02, 0x03, 0x04, 0x05
4348};
4349
Kailang Yangdf694da2005-12-05 19:42:22 +01004350/* identical with ALC880 */
4351#define alc882_adc_nids alc880_adc_nids
4352#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004353
4354/* input MUX */
4355/* FIXME: should be a matrix-type input source selection */
4356
4357static struct hda_input_mux alc882_capture_source = {
4358 .num_items = 4,
4359 .items = {
4360 { "Mic", 0x0 },
4361 { "Front Mic", 0x1 },
4362 { "Line", 0x2 },
4363 { "CD", 0x4 },
4364 },
4365};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366#define alc882_mux_enum_info alc_mux_enum_info
4367#define alc882_mux_enum_get alc_mux_enum_get
4368
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004369static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004370{
4371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4372 struct alc_spec *spec = codec->spec;
4373 const struct hda_input_mux *imux = spec->input_mux;
4374 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4375 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4376 hda_nid_t nid = capture_mixers[adc_idx];
4377 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4378 unsigned int i, idx;
4379
4380 idx = ucontrol->value.enumerated.item[0];
4381 if (idx >= imux->num_items)
4382 idx = imux->num_items - 1;
4383 if (*cur_val == idx && ! codec->in_resume)
4384 return 0;
4385 for (i = 0; i < imux->num_items; i++) {
4386 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4387 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4388 v | (imux->items[i].index << 8));
4389 }
4390 *cur_val = idx;
4391 return 1;
4392}
4393
Kailang Yangdf694da2005-12-05 19:42:22 +01004394/*
4395 * 6ch mode
4396 */
4397static struct hda_verb alc882_sixstack_ch6_init[] = {
4398 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4400 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4401 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4402 { } /* end */
4403};
4404
4405/*
4406 * 8ch mode
4407 */
4408static struct hda_verb alc882_sixstack_ch8_init[] = {
4409 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4410 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4411 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4412 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4413 { } /* end */
4414};
4415
4416static struct hda_channel_mode alc882_sixstack_modes[2] = {
4417 { 6, alc882_sixstack_ch6_init },
4418 { 8, alc882_sixstack_ch8_init },
4419};
4420
Linus Torvalds1da177e2005-04-16 15:20:36 -07004421/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4422 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4423 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004424static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004425 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004426 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004427 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004428 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004429 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4430 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004431 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4432 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004433 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004434 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4436 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4437 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4438 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4439 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4444 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4445 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004446 { } /* end */
4447};
4448
Kailang Yangdf694da2005-12-05 19:42:22 +01004449static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4450 {
4451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4452 .name = "Channel Mode",
4453 .info = alc_ch_mode_info,
4454 .get = alc_ch_mode_get,
4455 .put = alc_ch_mode_put,
4456 },
4457 { } /* end */
4458};
4459
Linus Torvalds1da177e2005-04-16 15:20:36 -07004460static struct hda_verb alc882_init_verbs[] = {
4461 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004465 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004469 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004473 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004474 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004477
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004479 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004481 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004482 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004483 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004486 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004487 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004488 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004489 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004491 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004492 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004493 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004495 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004496 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4497 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004498 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4500 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004501 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4503 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004507 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004509
4510 /* FIXME: use matrix-type input source selection */
4511 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4512 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004517 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004522 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4527 /* ADC1: mute amp left and right */
4528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004529 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004530 /* ADC2: mute amp left and right */
4531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004533 /* ADC3: mute amp left and right */
4534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004535 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004536
4537 { }
4538};
4539
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004540static struct hda_verb alc882_eapd_verbs[] = {
4541 /* change to EAPD mode */
4542 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Tobin Davisc07584c2006-10-13 12:32:16 +02004543 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004544 { }
4545};
4546
Kailang Yangdf694da2005-12-05 19:42:22 +01004547/*
4548 * generic initialization of ADC, input mixers and output mixers
4549 */
4550static struct hda_verb alc882_auto_init_verbs[] = {
4551 /*
4552 * Unmute ADC0-2 and set the default input to mic-in
4553 */
4554 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4556 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4558 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4559 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4560
4561 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4562 * mixer widget
4563 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4564 * mic (mic 2)
4565 */
4566 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4572
4573 /*
4574 * Set up output mixers (0x0c - 0x0f)
4575 */
4576 /* set vol=0 to output mixers */
4577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4579 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4580 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4581 /* set up input amps for analog loopback */
4582 /* Amp Indices: DAC = 0, mixer = 1 */
4583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4591 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4592 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4593
4594 /* FIXME: use matrix-type input source selection */
4595 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4596 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4601 /* Input mixer2 */
4602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4606 /* Input mixer3 */
4607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4611
4612 { }
4613};
4614
4615/* capture mixer elements */
4616static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4617 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4618 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4619 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4620 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4621 {
4622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4623 /* The multiple "Capture Source" controls confuse alsamixer
4624 * So call somewhat different..
4625 * FIXME: the controls appear in the "playback" view!
4626 */
4627 /* .name = "Capture Source", */
4628 .name = "Input Source",
4629 .count = 2,
4630 .info = alc882_mux_enum_info,
4631 .get = alc882_mux_enum_get,
4632 .put = alc882_mux_enum_put,
4633 },
4634 { } /* end */
4635};
4636
4637static struct snd_kcontrol_new alc882_capture_mixer[] = {
4638 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4639 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4640 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4641 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4642 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4643 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4644 {
4645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4646 /* The multiple "Capture Source" controls confuse alsamixer
4647 * So call somewhat different..
4648 * FIXME: the controls appear in the "playback" view!
4649 */
4650 /* .name = "Capture Source", */
4651 .name = "Input Source",
4652 .count = 3,
4653 .info = alc882_mux_enum_info,
4654 .get = alc882_mux_enum_get,
4655 .put = alc882_mux_enum_put,
4656 },
4657 { } /* end */
4658};
4659
4660/* pcm configuration: identiacal with ALC880 */
4661#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4662#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4663#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4664#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4665
4666/*
4667 * configuration and preset
4668 */
4669static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004670 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4671 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004672 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4673 .config = ALC882_6ST_DIG }, /* MSI */
4674 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4675 .config = ALC882_6ST_DIG }, /* Foxconn */
4676 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4677 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004678 { .modelname = "arima", .config = ALC882_ARIMA },
4679 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4680 .config = ALC882_ARIMA }, /* Arima W820Di1 */
Takashi Iwai1494a922006-01-31 10:58:46 +01004681 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004682 {}
4683};
4684
4685static struct alc_config_preset alc882_presets[] = {
4686 [ALC882_3ST_DIG] = {
4687 .mixers = { alc882_base_mixer },
4688 .init_verbs = { alc882_init_verbs },
4689 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4690 .dac_nids = alc882_dac_nids,
4691 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004692 .dig_in_nid = ALC882_DIGIN_NID,
4693 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4694 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004695 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004696 .input_mux = &alc882_capture_source,
4697 },
4698 [ALC882_6ST_DIG] = {
4699 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4700 .init_verbs = { alc882_init_verbs },
4701 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4702 .dac_nids = alc882_dac_nids,
4703 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004704 .dig_in_nid = ALC882_DIGIN_NID,
4705 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4706 .channel_mode = alc882_sixstack_modes,
4707 .input_mux = &alc882_capture_source,
4708 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004709 [ALC882_ARIMA] = {
4710 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4711 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4712 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4713 .dac_nids = alc882_dac_nids,
4714 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4715 .channel_mode = alc882_sixstack_modes,
4716 .input_mux = &alc882_capture_source,
4717 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004718};
4719
4720
4721/*
4722 * BIOS auto configuration
4723 */
4724static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4725 hda_nid_t nid, int pin_type,
4726 int dac_idx)
4727{
4728 /* set as output */
4729 struct alc_spec *spec = codec->spec;
4730 int idx;
4731
4732 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4733 idx = 4;
4734 else
4735 idx = spec->multiout.dac_nids[dac_idx] - 2;
4736
4737 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4738 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4740
4741}
4742
4743static void alc882_auto_init_multi_out(struct hda_codec *codec)
4744{
4745 struct alc_spec *spec = codec->spec;
4746 int i;
4747
4748 for (i = 0; i <= HDA_SIDE; i++) {
4749 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4750 if (nid)
4751 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4752 }
4753}
4754
4755static void alc882_auto_init_hp_out(struct hda_codec *codec)
4756{
4757 struct alc_spec *spec = codec->spec;
4758 hda_nid_t pin;
4759
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004760 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004761 if (pin) /* connect to front */
4762 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4763}
4764
4765#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4766#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4767
4768static void alc882_auto_init_analog_input(struct hda_codec *codec)
4769{
4770 struct alc_spec *spec = codec->spec;
4771 int i;
4772
4773 for (i = 0; i < AUTO_PIN_LAST; i++) {
4774 hda_nid_t nid = spec->autocfg.input_pins[i];
4775 if (alc882_is_input_pin(nid)) {
4776 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4777 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4778 if (nid != ALC882_PIN_CD_NID)
4779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4780 AMP_OUT_MUTE);
4781 }
4782 }
4783}
4784
4785/* almost identical with ALC880 parser... */
4786static int alc882_parse_auto_config(struct hda_codec *codec)
4787{
4788 struct alc_spec *spec = codec->spec;
4789 int err = alc880_parse_auto_config(codec);
4790
4791 if (err < 0)
4792 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004793 else if (err > 0)
4794 /* hack - override the init verbs */
4795 spec->init_verbs[0] = alc882_auto_init_verbs;
4796 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004797}
4798
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004799/* additional initialization for auto-configuration model */
4800static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004801{
Kailang Yangdf694da2005-12-05 19:42:22 +01004802 alc882_auto_init_multi_out(codec);
4803 alc882_auto_init_hp_out(codec);
4804 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004805}
4806
Linus Torvalds1da177e2005-04-16 15:20:36 -07004807static int patch_alc882(struct hda_codec *codec)
4808{
4809 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004810 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004811
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004812 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004813 if (spec == NULL)
4814 return -ENOMEM;
4815
Linus Torvalds1da177e2005-04-16 15:20:36 -07004816 codec->spec = spec;
4817
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004819
Kailang Yangdf694da2005-12-05 19:42:22 +01004820 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004821 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4822 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004823 board_config = ALC882_AUTO;
4824 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004825
Kailang Yangdf694da2005-12-05 19:42:22 +01004826 if (board_config == ALC882_AUTO) {
4827 /* automatic parse from the BIOS config */
4828 err = alc882_parse_auto_config(codec);
4829 if (err < 0) {
4830 alc_free(codec);
4831 return err;
4832 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004833 printk(KERN_INFO
4834 "hda_codec: Cannot set up configuration "
4835 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004836 board_config = ALC882_3ST_DIG;
4837 }
4838 }
4839
4840 if (board_config != ALC882_AUTO)
4841 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004842
4843 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004844 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4845 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004846
4847 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004848 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4849 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004850
Kailang Yangdf694da2005-12-05 19:42:22 +01004851 if (! spec->adc_nids && spec->input_mux) {
4852 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004853 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004854 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4855 if (wcap != AC_WID_AUD_IN) {
4856 spec->adc_nids = alc882_adc_nids_alt;
4857 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4858 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4859 spec->num_mixers++;
4860 } else {
4861 spec->adc_nids = alc882_adc_nids;
4862 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4863 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4864 spec->num_mixers++;
4865 }
4866 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004867
4868 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004869 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004870 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004871
4872 return 0;
4873}
4874
4875/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004876 * ALC883 support
4877 *
4878 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4879 * configuration. Each pin widget can choose any input DACs and a mixer.
4880 * Each ADC is connected from a mixer of all inputs. This makes possible
4881 * 6-channel independent captures.
4882 *
4883 * In addition, an independent DAC for the multi-playback (not used in this
4884 * driver yet).
4885 */
4886#define ALC883_DIGOUT_NID 0x06
4887#define ALC883_DIGIN_NID 0x0a
4888
4889static hda_nid_t alc883_dac_nids[4] = {
4890 /* front, rear, clfe, rear_surr */
4891 0x02, 0x04, 0x03, 0x05
4892};
4893
4894static hda_nid_t alc883_adc_nids[2] = {
4895 /* ADC1-2 */
4896 0x08, 0x09,
4897};
4898/* input MUX */
4899/* FIXME: should be a matrix-type input source selection */
4900
4901static struct hda_input_mux alc883_capture_source = {
4902 .num_items = 4,
4903 .items = {
4904 { "Mic", 0x0 },
4905 { "Front Mic", 0x1 },
4906 { "Line", 0x2 },
4907 { "CD", 0x4 },
4908 },
4909};
4910#define alc883_mux_enum_info alc_mux_enum_info
4911#define alc883_mux_enum_get alc_mux_enum_get
4912
4913static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4914 struct snd_ctl_elem_value *ucontrol)
4915{
4916 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4917 struct alc_spec *spec = codec->spec;
4918 const struct hda_input_mux *imux = spec->input_mux;
4919 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4920 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4921 hda_nid_t nid = capture_mixers[adc_idx];
4922 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4923 unsigned int i, idx;
4924
4925 idx = ucontrol->value.enumerated.item[0];
4926 if (idx >= imux->num_items)
4927 idx = imux->num_items - 1;
4928 if (*cur_val == idx && ! codec->in_resume)
4929 return 0;
4930 for (i = 0; i < imux->num_items; i++) {
4931 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4932 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4933 v | (imux->items[i].index << 8));
4934 }
4935 *cur_val = idx;
4936 return 1;
4937}
4938/*
4939 * 2ch mode
4940 */
4941static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4942 { 2, NULL }
4943};
4944
4945/*
4946 * 2ch mode
4947 */
4948static struct hda_verb alc883_3ST_ch2_init[] = {
4949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4951 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4952 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4953 { } /* end */
4954};
4955
4956/*
4957 * 6ch mode
4958 */
4959static struct hda_verb alc883_3ST_ch6_init[] = {
4960 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4961 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4962 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4963 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4964 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4965 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4966 { } /* end */
4967};
4968
4969static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4970 { 2, alc883_3ST_ch2_init },
4971 { 6, alc883_3ST_ch6_init },
4972};
4973
4974/*
4975 * 6ch mode
4976 */
4977static struct hda_verb alc883_sixstack_ch6_init[] = {
4978 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4979 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4980 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4981 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4982 { } /* end */
4983};
4984
4985/*
4986 * 8ch mode
4987 */
4988static struct hda_verb alc883_sixstack_ch8_init[] = {
4989 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4990 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4991 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4992 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4993 { } /* end */
4994};
4995
4996static struct hda_channel_mode alc883_sixstack_modes[2] = {
4997 { 6, alc883_sixstack_ch6_init },
4998 { 8, alc883_sixstack_ch8_init },
4999};
5000
5001/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5002 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5003 */
5004
5005static struct snd_kcontrol_new alc883_base_mixer[] = {
5006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5007 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5008 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5009 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5010 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5012 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5013 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5014 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5015 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5017 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5018 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5023 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5024 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5025 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5026 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5027 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5028 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5029 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5030 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5031 {
5032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5033 /* .name = "Capture Source", */
5034 .name = "Input Source",
5035 .count = 2,
5036 .info = alc883_mux_enum_info,
5037 .get = alc883_mux_enum_get,
5038 .put = alc883_mux_enum_put,
5039 },
5040 { } /* end */
5041};
5042
5043static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5045 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5054 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5055 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5056 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5057 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5058 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5059 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5060 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5061 {
5062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5063 /* .name = "Capture Source", */
5064 .name = "Input Source",
5065 .count = 2,
5066 .info = alc883_mux_enum_info,
5067 .get = alc883_mux_enum_get,
5068 .put = alc883_mux_enum_put,
5069 },
5070 { } /* end */
5071};
5072
5073static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5075 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5076 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5077 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5078 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5079 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5080 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5081 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5083 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5084 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5085 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5086 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5087 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5089 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5090 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5091 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5092 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5093 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5094 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5095 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5096 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5097 {
5098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5099 /* .name = "Capture Source", */
5100 .name = "Input Source",
5101 .count = 2,
5102 .info = alc883_mux_enum_info,
5103 .get = alc883_mux_enum_get,
5104 .put = alc883_mux_enum_put,
5105 },
5106 { } /* end */
5107};
5108
Tobin Davisc07584c2006-10-13 12:32:16 +02005109static snd_kcontrol_new_t alc883_fivestack_mixer[] = {
5110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5111 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5113 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5116 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5117 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5127 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5128 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5129 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5130 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5131
5132 {
5133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5134 /* .name = "Capture Source", */
5135 .name = "Input Source",
5136 .count = 1,
5137 .info = alc883_mux_enum_info,
5138 .get = alc883_mux_enum_get,
5139 .put = alc883_mux_enum_put,
5140 },
5141 { } /* end */
5142};
5143
Kailang Yangccc656c2006-10-17 12:32:26 +02005144static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5147 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5149 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5155 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5162 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5163 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5164 {
5165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5166 /* .name = "Capture Source", */
5167 .name = "Input Source",
5168 .count = 2,
5169 .info = alc883_mux_enum_info,
5170 .get = alc883_mux_enum_get,
5171 .put = alc883_mux_enum_put,
5172 },
5173 { } /* end */
5174};
5175
5176static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5179 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5180 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5181 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5188 {
5189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5190 /* .name = "Capture Source", */
5191 .name = "Input Source",
5192 .count = 2,
5193 .info = alc883_mux_enum_info,
5194 .get = alc883_mux_enum_get,
5195 .put = alc883_mux_enum_put,
5196 },
5197 { } /* end */
5198};
5199
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005200static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5201 {
5202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5203 .name = "Channel Mode",
5204 .info = alc_ch_mode_info,
5205 .get = alc_ch_mode_get,
5206 .put = alc_ch_mode_put,
5207 },
5208 { } /* end */
5209};
5210
5211static struct hda_verb alc883_init_verbs[] = {
5212 /* ADC1: mute amp left and right */
5213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5214 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5215 /* ADC2: mute amp left and right */
5216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5217 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5218 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5222 /* Rear mixer */
5223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5226 /* CLFE mixer */
5227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5230 /* Side mixer */
5231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5234
5235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5240
5241 /* Front Pin: output 0 (0x0c) */
5242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5243 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5245 /* Rear Pin: output 1 (0x0d) */
5246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5249 /* CLFE Pin: output 2 (0x0e) */
5250 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5252 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5253 /* Side Pin: output 3 (0x0f) */
5254 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5255 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5256 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5257 /* Mic (rear) pin: input vref at 80% */
5258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5259 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5260 /* Front Mic pin: input vref at 80% */
5261 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5262 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5263 /* Line In pin: input */
5264 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5266 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5267 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5268 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5269 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5270 /* CD pin widget for input */
5271 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5272
5273 /* FIXME: use matrix-type input source selection */
5274 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5275 /* Input mixer2 */
5276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5280 /* Input mixer3 */
5281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5285 { }
5286};
5287
Kailang Yangccc656c2006-10-17 12:32:26 +02005288static struct hda_verb alc883_tagra_verbs[] = {
5289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5291
5292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5294
5295 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5296 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5297 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5298
5299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5300 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5301 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5302 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5303
5304 { } /* end */
5305};
5306
5307/* toggle speaker-output according to the hp-jack state */
5308static void alc883_tagra_automute(struct hda_codec *codec)
5309{
5310 unsigned int present;
5311
5312 present = snd_hda_codec_read(codec, 0x14, 0,
5313 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5314 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5315 0x80, present ? 0x80 : 0);
5316 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5317 0x80, present ? 0x80 : 0);
5318 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5319}
5320
5321static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5322{
5323 if ((res >> 26) == ALC880_HP_EVENT)
5324 alc883_tagra_automute(codec);
5325}
5326
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005327/*
5328 * generic initialization of ADC, input mixers and output mixers
5329 */
5330static struct hda_verb alc883_auto_init_verbs[] = {
5331 /*
5332 * Unmute ADC0-2 and set the default input to mic-in
5333 */
5334 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5336 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5338
5339 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5340 * mixer widget
5341 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5342 * mic (mic 2)
5343 */
5344 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5350
5351 /*
5352 * Set up output mixers (0x0c - 0x0f)
5353 */
5354 /* set vol=0 to output mixers */
5355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5358 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5359 /* set up input amps for analog loopback */
5360 /* Amp Indices: DAC = 0, mixer = 1 */
5361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5368 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5369 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5370 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5371
5372 /* FIXME: use matrix-type input source selection */
5373 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5374 /* Input mixer1 */
5375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5378 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5379 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5380 /* Input mixer2 */
5381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5384 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5386
5387 { }
5388};
5389
5390/* capture mixer elements */
5391static struct snd_kcontrol_new alc883_capture_mixer[] = {
5392 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5393 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5394 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5395 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5396 {
5397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5398 /* The multiple "Capture Source" controls confuse alsamixer
5399 * So call somewhat different..
5400 * FIXME: the controls appear in the "playback" view!
5401 */
5402 /* .name = "Capture Source", */
5403 .name = "Input Source",
5404 .count = 2,
5405 .info = alc882_mux_enum_info,
5406 .get = alc882_mux_enum_get,
5407 .put = alc882_mux_enum_put,
5408 },
5409 { } /* end */
5410};
5411
5412/* pcm configuration: identiacal with ALC880 */
5413#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5414#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5415#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5416#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5417
5418/*
5419 * configuration and preset
5420 */
5421static struct hda_board_config alc883_cfg_tbl[] = {
5422 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005423 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5424 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5425 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5426 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5427 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
Kailang Yangccc656c2006-10-17 12:32:26 +02005428 .config = ALC883_3ST_6ch },
5429 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
5430 .config = ALC883_3ST_6ch }, /* D102GGC */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005431 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005432 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5433 .config = ALC883_6ST_DIG }, /* MSI */
Leonard Norrgårde22a9a82007-01-01 19:00:54 +02005434 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
5435 .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005436 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5437 .config = ALC883_6ST_DIG }, /* Foxconn */
Kailang Yangccc656c2006-10-17 12:32:26 +02005438 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7187,
5439 .config = ALC883_6ST_DIG }, /* MSI */
5440 { .modelname = "targa-dig", .config = ALC883_TARGA_DIG },
5441 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
5442 .config = ALC883_TARGA_DIG }, /* MSI */
5443 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fcc,
5444 .config = ALC883_TARGA_DIG }, /* MSI */
5445 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc1,
5446 .config = ALC883_TARGA_DIG }, /* MSI */
5447 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc3,
5448 .config = ALC883_TARGA_DIG }, /* MSI */
5449 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
5450 .config = ALC883_TARGA_DIG }, /* MSI */
5451 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4319,
5452 .config = ALC883_TARGA_DIG }, /* MSI */
5453 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3ef9,
5454 .config = ALC883_TARGA_DIG }, /* MSI */
5455 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4324,
5456 .config = ALC883_TARGA_DIG }, /* MSI */
5457 { .modelname = "targa-2ch-dig", .config = ALC883_TARGA_2ch_DIG },
5458 { .pci_subvendor = 0x1462, .pci_subdevice = 0x0579,
5459 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5460 { .pci_subvendor = 0x1462, .pci_subdevice = 0xa422,
5461 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5462 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3b7f,
5463 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005464 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02005465 { .modelname = "acer", .config = ALC883_ACER },
5466 { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
5467 .config = ALC883_ACER },
Tobin Davis7a997952006-09-26 15:30:10 +02005468 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
5469 .config = ALC883_ACER },
5470 { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
5471 .config = ALC883_ACER },
Tobin Davisc07584c2006-10-13 12:32:16 +02005472 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
Takashi Iwai35f60832006-10-13 12:46:10 +02005473 .modelname = "medion", .config = ALC883_MEDION },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005474 { .modelname = "auto", .config = ALC883_AUTO },
5475 {}
5476};
5477
5478static struct alc_config_preset alc883_presets[] = {
5479 [ALC883_3ST_2ch_DIG] = {
5480 .mixers = { alc883_3ST_2ch_mixer },
5481 .init_verbs = { alc883_init_verbs },
5482 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5483 .dac_nids = alc883_dac_nids,
5484 .dig_out_nid = ALC883_DIGOUT_NID,
5485 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5486 .adc_nids = alc883_adc_nids,
5487 .dig_in_nid = ALC883_DIGIN_NID,
5488 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5489 .channel_mode = alc883_3ST_2ch_modes,
5490 .input_mux = &alc883_capture_source,
5491 },
5492 [ALC883_3ST_6ch_DIG] = {
5493 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5494 .init_verbs = { alc883_init_verbs },
5495 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5496 .dac_nids = alc883_dac_nids,
5497 .dig_out_nid = ALC883_DIGOUT_NID,
5498 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5499 .adc_nids = alc883_adc_nids,
5500 .dig_in_nid = ALC883_DIGIN_NID,
5501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5502 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005503 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005504 .input_mux = &alc883_capture_source,
5505 },
5506 [ALC883_3ST_6ch] = {
5507 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5508 .init_verbs = { alc883_init_verbs },
5509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5510 .dac_nids = alc883_dac_nids,
5511 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5512 .adc_nids = alc883_adc_nids,
5513 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5514 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005515 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005516 .input_mux = &alc883_capture_source,
5517 },
5518 [ALC883_6ST_DIG] = {
5519 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5520 .init_verbs = { alc883_init_verbs },
5521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5522 .dac_nids = alc883_dac_nids,
5523 .dig_out_nid = ALC883_DIGOUT_NID,
5524 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5525 .adc_nids = alc883_adc_nids,
5526 .dig_in_nid = ALC883_DIGIN_NID,
5527 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5528 .channel_mode = alc883_sixstack_modes,
5529 .input_mux = &alc883_capture_source,
5530 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005531 [ALC883_TARGA_DIG] = {
5532 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5533 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5535 .dac_nids = alc883_dac_nids,
5536 .dig_out_nid = ALC883_DIGOUT_NID,
5537 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5538 .adc_nids = alc883_adc_nids,
5539 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5540 .channel_mode = alc883_3ST_6ch_modes,
5541 .need_dac_fix = 1,
5542 .input_mux = &alc883_capture_source,
5543 .unsol_event = alc883_tagra_unsol_event,
5544 .init_hook = alc883_tagra_automute,
5545 },
5546 [ALC883_TARGA_2ch_DIG] = {
5547 .mixers = { alc883_tagra_2ch_mixer},
5548 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5549 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5550 .dac_nids = alc883_dac_nids,
5551 .dig_out_nid = ALC883_DIGOUT_NID,
5552 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5553 .adc_nids = alc883_adc_nids,
5554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5555 .channel_mode = alc883_3ST_2ch_modes,
5556 .input_mux = &alc883_capture_source,
5557 .unsol_event = alc883_tagra_unsol_event,
5558 .init_hook = alc883_tagra_automute,
5559 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005560 [ALC888_DEMO_BOARD] = {
5561 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5562 .init_verbs = { alc883_init_verbs },
5563 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5564 .dac_nids = alc883_dac_nids,
5565 .dig_out_nid = ALC883_DIGOUT_NID,
5566 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5567 .adc_nids = alc883_adc_nids,
5568 .dig_in_nid = ALC883_DIGIN_NID,
5569 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5570 .channel_mode = alc883_sixstack_modes,
5571 .input_mux = &alc883_capture_source,
5572 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02005573 [ALC883_ACER] = {
5574 .mixers = { alc883_base_mixer,
5575 alc883_chmode_mixer },
5576 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5577 * and the headphone jack. Turn this on and rely on the
5578 * standard mute methods whenever the user wants to turn
5579 * these outputs off.
5580 */
5581 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5582 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5583 .dac_nids = alc883_dac_nids,
5584 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5585 .adc_nids = alc883_adc_nids,
5586 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5587 .channel_mode = alc883_3ST_2ch_modes,
5588 .input_mux = &alc883_capture_source,
5589 },
Tobin Davisc07584c2006-10-13 12:32:16 +02005590 [ALC883_MEDION] = {
5591 .mixers = { alc883_fivestack_mixer,
5592 alc883_chmode_mixer },
5593 .init_verbs = { alc883_init_verbs,
5594 alc882_eapd_verbs },
5595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5596 .dac_nids = alc883_dac_nids,
5597 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5598 .adc_nids = alc883_adc_nids,
5599 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5600 .channel_mode = alc883_sixstack_modes,
5601 .input_mux = &alc883_capture_source,
5602 }
5603
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005604};
5605
5606
5607/*
5608 * BIOS auto configuration
5609 */
5610static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5611 hda_nid_t nid, int pin_type,
5612 int dac_idx)
5613{
5614 /* set as output */
5615 struct alc_spec *spec = codec->spec;
5616 int idx;
5617
5618 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5619 idx = 4;
5620 else
5621 idx = spec->multiout.dac_nids[dac_idx] - 2;
5622
5623 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5624 pin_type);
5625 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5626 AMP_OUT_UNMUTE);
5627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5628
5629}
5630
5631static void alc883_auto_init_multi_out(struct hda_codec *codec)
5632{
5633 struct alc_spec *spec = codec->spec;
5634 int i;
5635
5636 for (i = 0; i <= HDA_SIDE; i++) {
5637 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5638 if (nid)
5639 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5640 }
5641}
5642
5643static void alc883_auto_init_hp_out(struct hda_codec *codec)
5644{
5645 struct alc_spec *spec = codec->spec;
5646 hda_nid_t pin;
5647
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005648 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005649 if (pin) /* connect to front */
5650 /* use dac 0 */
5651 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5652}
5653
5654#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5655#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5656
5657static void alc883_auto_init_analog_input(struct hda_codec *codec)
5658{
5659 struct alc_spec *spec = codec->spec;
5660 int i;
5661
5662 for (i = 0; i < AUTO_PIN_LAST; i++) {
5663 hda_nid_t nid = spec->autocfg.input_pins[i];
5664 if (alc883_is_input_pin(nid)) {
5665 snd_hda_codec_write(codec, nid, 0,
5666 AC_VERB_SET_PIN_WIDGET_CONTROL,
5667 (i <= AUTO_PIN_FRONT_MIC ?
5668 PIN_VREF80 : PIN_IN));
5669 if (nid != ALC883_PIN_CD_NID)
5670 snd_hda_codec_write(codec, nid, 0,
5671 AC_VERB_SET_AMP_GAIN_MUTE,
5672 AMP_OUT_MUTE);
5673 }
5674 }
5675}
5676
5677/* almost identical with ALC880 parser... */
5678static int alc883_parse_auto_config(struct hda_codec *codec)
5679{
5680 struct alc_spec *spec = codec->spec;
5681 int err = alc880_parse_auto_config(codec);
5682
5683 if (err < 0)
5684 return err;
5685 else if (err > 0)
5686 /* hack - override the init verbs */
5687 spec->init_verbs[0] = alc883_auto_init_verbs;
5688 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5689 spec->num_mixers++;
5690 return err;
5691}
5692
5693/* additional initialization for auto-configuration model */
5694static void alc883_auto_init(struct hda_codec *codec)
5695{
5696 alc883_auto_init_multi_out(codec);
5697 alc883_auto_init_hp_out(codec);
5698 alc883_auto_init_analog_input(codec);
5699}
5700
5701static int patch_alc883(struct hda_codec *codec)
5702{
5703 struct alc_spec *spec;
5704 int err, board_config;
5705
5706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5707 if (spec == NULL)
5708 return -ENOMEM;
5709
5710 codec->spec = spec;
5711
5712 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5713 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5714 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5715 "trying auto-probe from BIOS...\n");
5716 board_config = ALC883_AUTO;
5717 }
5718
5719 if (board_config == ALC883_AUTO) {
5720 /* automatic parse from the BIOS config */
5721 err = alc883_parse_auto_config(codec);
5722 if (err < 0) {
5723 alc_free(codec);
5724 return err;
5725 } else if (! err) {
5726 printk(KERN_INFO
5727 "hda_codec: Cannot set up configuration "
5728 "from BIOS. Using base mode...\n");
5729 board_config = ALC883_3ST_2ch_DIG;
5730 }
5731 }
5732
5733 if (board_config != ALC883_AUTO)
5734 setup_preset(spec, &alc883_presets[board_config]);
5735
5736 spec->stream_name_analog = "ALC883 Analog";
5737 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5738 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5739
5740 spec->stream_name_digital = "ALC883 Digital";
5741 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5742 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5743
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005744 if (! spec->adc_nids && spec->input_mux) {
5745 spec->adc_nids = alc883_adc_nids;
5746 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5747 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005748
5749 codec->patch_ops = alc_patch_ops;
5750 if (board_config == ALC883_AUTO)
5751 spec->init_hook = alc883_auto_init;
5752
5753 return 0;
5754}
5755
5756/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005757 * ALC262 support
5758 */
5759
5760#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5761#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5762
5763#define alc262_dac_nids alc260_dac_nids
5764#define alc262_adc_nids alc882_adc_nids
5765#define alc262_adc_nids_alt alc882_adc_nids_alt
5766
5767#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005768#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005769
5770static struct snd_kcontrol_new alc262_base_mixer[] = {
5771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5772 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5778 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5781 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5782 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5783 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5785 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5786 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005787 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005788};
5789
Kailang Yangccc656c2006-10-17 12:32:26 +02005790static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
5791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5792 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5801 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5802 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5803 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
5804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5805 { } /* end */
5806};
5807
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005808static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5810 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5812 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5813 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5814
5815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5817 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5818 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5823 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5824 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5825 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5826 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5827 { } /* end */
5828};
5829
Kailang Yangdf694da2005-12-05 19:42:22 +01005830#define alc262_capture_mixer alc882_capture_mixer
5831#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5832
5833/*
5834 * generic initialization of ADC, input mixers and output mixers
5835 */
5836static struct hda_verb alc262_init_verbs[] = {
5837 /*
5838 * Unmute ADC0-2 and set the default input to mic-in
5839 */
5840 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5842 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5844 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5845 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5846
5847 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5848 * mixer widget
5849 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5850 * mic (mic 2)
5851 */
5852 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5858
5859 /*
5860 * Set up output mixers (0x0c - 0x0e)
5861 */
5862 /* set vol=0 to output mixers */
5863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5866 /* set up input amps for analog loopback */
5867 /* Amp Indices: DAC = 0, mixer = 1 */
5868 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5871 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5873 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5874
5875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5877 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5878 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5880 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5881
5882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5884 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5886 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5887
5888 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5890
5891 /* FIXME: use matrix-type input source selection */
5892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5893 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5898 /* Input mixer2 */
5899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5903 /* Input mixer3 */
5904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5908
5909 { }
5910};
5911
Kailang Yangccc656c2006-10-17 12:32:26 +02005912static struct hda_verb alc262_hippo_unsol_verbs[] = {
5913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5915 {}
5916};
5917
5918static struct hda_verb alc262_hippo1_unsol_verbs[] = {
5919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5920 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5922
5923 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5924 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5925 {}
5926};
5927
5928/* mute/unmute internal speaker according to the hp jack and mute state */
5929static void alc262_hippo_automute(struct hda_codec *codec, int force)
5930{
5931 struct alc_spec *spec = codec->spec;
5932 unsigned int mute;
5933
5934 if (force || ! spec->sense_updated) {
5935 unsigned int present;
5936 /* need to execute and sync at first */
5937 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
5938 present = snd_hda_codec_read(codec, 0x15, 0,
5939 AC_VERB_GET_PIN_SENSE, 0);
5940 spec->jack_present = (present & 0x80000000) != 0;
5941 spec->sense_updated = 1;
5942 }
5943 if (spec->jack_present) {
5944 /* mute internal speaker */
5945 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5946 0x80, 0x80);
5947 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5948 0x80, 0x80);
5949 } else {
5950 /* unmute internal speaker if necessary */
5951 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
5952 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5953 0x80, mute & 0x80);
5954 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
5955 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5956 0x80, mute & 0x80);
5957 }
5958}
5959
5960/* unsolicited event for HP jack sensing */
5961static void alc262_hippo_unsol_event(struct hda_codec *codec,
5962 unsigned int res)
5963{
5964 if ((res >> 26) != ALC880_HP_EVENT)
5965 return;
5966 alc262_hippo_automute(codec, 1);
5967}
5968
5969static void alc262_hippo1_automute(struct hda_codec *codec, int force)
5970{
5971 struct alc_spec *spec = codec->spec;
5972 unsigned int mute;
5973
5974 if (force || ! spec->sense_updated) {
5975 unsigned int present;
5976 /* need to execute and sync at first */
5977 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
5978 present = snd_hda_codec_read(codec, 0x1b, 0,
5979 AC_VERB_GET_PIN_SENSE, 0);
5980 spec->jack_present = (present & 0x80000000) != 0;
5981 spec->sense_updated = 1;
5982 }
5983 if (spec->jack_present) {
5984 /* mute internal speaker */
5985 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5986 0x80, 0x80);
5987 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5988 0x80, 0x80);
5989 } else {
5990 /* unmute internal speaker if necessary */
5991 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
5992 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5993 0x80, mute & 0x80);
5994 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
5995 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5996 0x80, mute & 0x80);
5997 }
5998}
5999
6000/* unsolicited event for HP jack sensing */
6001static void alc262_hippo1_unsol_event(struct hda_codec *codec,
6002 unsigned int res)
6003{
6004 if ((res >> 26) != ALC880_HP_EVENT)
6005 return;
6006 alc262_hippo1_automute(codec, 1);
6007}
6008
Takashi Iwai834be882006-03-01 14:16:17 +01006009/*
6010 * fujitsu model
6011 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
6012 */
6013
6014#define ALC_HP_EVENT 0x37
6015
6016static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
6017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
6018 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6019 {}
6020};
6021
6022static struct hda_input_mux alc262_fujitsu_capture_source = {
6023 .num_items = 2,
6024 .items = {
6025 { "Mic", 0x0 },
6026 { "CD", 0x4 },
6027 },
6028};
6029
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006030static struct hda_input_mux alc262_HP_capture_source = {
6031 .num_items = 5,
6032 .items = {
6033 { "Mic", 0x0 },
6034 { "Front Mic", 0x3 },
6035 { "Line", 0x2 },
6036 { "CD", 0x4 },
6037 { "AUX IN", 0x6 },
6038 },
6039};
6040
Takashi Iwai834be882006-03-01 14:16:17 +01006041/* mute/unmute internal speaker according to the hp jack and mute state */
6042static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6043{
6044 struct alc_spec *spec = codec->spec;
6045 unsigned int mute;
6046
6047 if (force || ! spec->sense_updated) {
6048 unsigned int present;
6049 /* need to execute and sync at first */
6050 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6051 present = snd_hda_codec_read(codec, 0x14, 0,
6052 AC_VERB_GET_PIN_SENSE, 0);
6053 spec->jack_present = (present & 0x80000000) != 0;
6054 spec->sense_updated = 1;
6055 }
6056 if (spec->jack_present) {
6057 /* mute internal speaker */
6058 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6059 0x80, 0x80);
6060 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6061 0x80, 0x80);
6062 } else {
6063 /* unmute internal speaker if necessary */
6064 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6065 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6066 0x80, mute & 0x80);
6067 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6068 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6069 0x80, mute & 0x80);
6070 }
6071}
6072
6073/* unsolicited event for HP jack sensing */
6074static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6075 unsigned int res)
6076{
6077 if ((res >> 26) != ALC_HP_EVENT)
6078 return;
6079 alc262_fujitsu_automute(codec, 1);
6080}
6081
6082/* bind volumes of both NID 0x0c and 0x0d */
6083static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6084 struct snd_ctl_elem_value *ucontrol)
6085{
6086 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6087 long *valp = ucontrol->value.integer.value;
6088 int change;
6089
6090 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6091 0x7f, valp[0] & 0x7f);
6092 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6093 0x7f, valp[1] & 0x7f);
6094 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6095 0x7f, valp[0] & 0x7f);
6096 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6097 0x7f, valp[1] & 0x7f);
6098 return change;
6099}
6100
6101/* bind hp and internal speaker mute (with plug check) */
6102static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6103 struct snd_ctl_elem_value *ucontrol)
6104{
6105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6106 long *valp = ucontrol->value.integer.value;
6107 int change;
6108
6109 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6110 0x80, valp[0] ? 0 : 0x80);
6111 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6112 0x80, valp[1] ? 0 : 0x80);
6113 if (change || codec->in_resume)
6114 alc262_fujitsu_automute(codec, codec->in_resume);
6115 return change;
6116}
6117
6118static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6119 {
6120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6121 .name = "Master Playback Volume",
6122 .info = snd_hda_mixer_amp_volume_info,
6123 .get = snd_hda_mixer_amp_volume_get,
6124 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02006125 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01006126 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6127 },
6128 {
6129 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6130 .name = "Master Playback Switch",
6131 .info = snd_hda_mixer_amp_switch_info,
6132 .get = snd_hda_mixer_amp_switch_get,
6133 .put = alc262_fujitsu_master_sw_put,
6134 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6135 },
6136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6141 { } /* end */
6142};
6143
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006144/* additional init verbs for Benq laptops */
6145static struct hda_verb alc262_EAPD_verbs[] = {
6146 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6147 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6148 {}
6149};
6150
Kailang Yangdf694da2005-12-05 19:42:22 +01006151/* add playback controls from the parsed DAC table */
6152static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6153{
6154 hda_nid_t nid;
6155 int err;
6156
6157 spec->multiout.num_dacs = 1; /* only use one dac */
6158 spec->multiout.dac_nids = spec->private_dac_nids;
6159 spec->multiout.dac_nids[0] = 2;
6160
6161 nid = cfg->line_out_pins[0];
6162 if (nid) {
6163 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6164 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6165 return err;
6166 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6167 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6168 return err;
6169 }
6170
Takashi Iwai82bc9552006-03-21 11:24:42 +01006171 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006172 if (nid) {
6173 if (nid == 0x16) {
6174 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6175 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6176 return err;
6177 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6178 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6179 return err;
6180 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006181 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6182 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6183 return err;
6184 }
6185 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006186 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006187 if (nid) {
6188 /* spec->multiout.hp_nid = 2; */
6189 if (nid == 0x16) {
6190 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6191 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6192 return err;
6193 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6194 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6195 return err;
6196 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006197 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6198 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6199 return err;
6200 }
6201 }
6202 return 0;
6203}
6204
6205/* identical with ALC880 */
6206#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6207
6208/*
6209 * generic initialization of ADC, input mixers and output mixers
6210 */
6211static struct hda_verb alc262_volume_init_verbs[] = {
6212 /*
6213 * Unmute ADC0-2 and set the default input to mic-in
6214 */
6215 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6217 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6219 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6221
6222 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6223 * mixer widget
6224 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6225 * mic (mic 2)
6226 */
6227 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6233
6234 /*
6235 * Set up output mixers (0x0c - 0x0f)
6236 */
6237 /* set vol=0 to output mixers */
6238 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6241
6242 /* set up input amps for analog loopback */
6243 /* Amp Indices: DAC = 0, mixer = 1 */
6244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6250
6251 /* FIXME: use matrix-type input source selection */
6252 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6253 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6258 /* Input mixer2 */
6259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6263 /* Input mixer3 */
6264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6268
6269 { }
6270};
6271
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006272static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6273 /*
6274 * Unmute ADC0-2 and set the default input to mic-in
6275 */
6276 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6282
6283 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6284 * mixer widget
6285 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6286 * mic (mic 2)
6287 */
6288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6296
6297 /*
6298 * Set up output mixers (0x0c - 0x0e)
6299 */
6300 /* set vol=0 to output mixers */
6301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6304
6305 /* set up input amps for analog loopback */
6306 /* Amp Indices: DAC = 0, mixer = 1 */
6307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6313
6314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6317
6318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6320
6321 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6323
6324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6325 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6328 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6329
6330 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6334 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6335 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6336
6337
6338 /* FIXME: use matrix-type input source selection */
6339 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6340 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6345 /* Input mixer2 */
6346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6350 /* Input mixer3 */
6351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6355
6356 { }
6357};
6358
Kailang Yangdf694da2005-12-05 19:42:22 +01006359/* pcm configuration: identiacal with ALC880 */
6360#define alc262_pcm_analog_playback alc880_pcm_analog_playback
6361#define alc262_pcm_analog_capture alc880_pcm_analog_capture
6362#define alc262_pcm_digital_playback alc880_pcm_digital_playback
6363#define alc262_pcm_digital_capture alc880_pcm_digital_capture
6364
6365/*
6366 * BIOS auto configuration
6367 */
6368static int alc262_parse_auto_config(struct hda_codec *codec)
6369{
6370 struct alc_spec *spec = codec->spec;
6371 int err;
6372 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6373
6374 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6375 alc262_ignore)) < 0)
6376 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006377 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 return 0; /* can't find valid BIOS pin config */
6379 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6380 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6381 return err;
6382
6383 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6384
6385 if (spec->autocfg.dig_out_pin)
6386 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6387 if (spec->autocfg.dig_in_pin)
6388 spec->dig_in_nid = ALC262_DIGIN_NID;
6389
6390 if (spec->kctl_alloc)
6391 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6392
6393 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006394 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006395 spec->input_mux = &spec->private_imux;
6396
6397 return 1;
6398}
6399
6400#define alc262_auto_init_multi_out alc882_auto_init_multi_out
6401#define alc262_auto_init_hp_out alc882_auto_init_hp_out
6402#define alc262_auto_init_analog_input alc882_auto_init_analog_input
6403
6404
6405/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006406static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006407{
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 alc262_auto_init_multi_out(codec);
6409 alc262_auto_init_hp_out(codec);
6410 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006411}
6412
6413/*
6414 * configuration and preset
6415 */
6416static struct hda_board_config alc262_cfg_tbl[] = {
6417 { .modelname = "basic", .config = ALC262_BASIC },
Kailang Yangccc656c2006-10-17 12:32:26 +02006418 { .modelname = "hippo",
6419 .pci_subvendor =0x1002, .pci_subdevice = 0x437b,
6420 .config = ALC262_HIPPO},
6421 { .modelname = "hippo_1",
6422 .pci_subvendor =0x17ff, .pci_subdevice = 0x058f,
6423 .config = ALC262_HIPPO_1},
Takashi Iwai834be882006-03-01 14:16:17 +01006424 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006425 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
6426 .config = ALC262_FUJITSU },
Takashi Iwai6d177ba72006-07-25 14:51:15 +02006427 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
John W. Linville282e0c82006-11-06 12:01:53 +01006428 { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006429 .config = ALC262_HP_BPC }, /* xw4400 */
Takashi Iwaiefeccac2006-10-24 14:57:52 +02006430 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
6431 .config = ALC262_HP_BPC }, /* q965 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006432 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
6433 .config = ALC262_HP_BPC }, /* xw6400 */
6434 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
6435 .config = ALC262_HP_BPC }, /* xw8400 */
6436 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
6437 .config = ALC262_HP_BPC }, /* xw9400 */
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006438 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
6439 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
6440 .config = ALC262_BENQ_ED8 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006441 { .modelname = "auto", .config = ALC262_AUTO },
6442 {}
6443};
6444
6445static struct alc_config_preset alc262_presets[] = {
6446 [ALC262_BASIC] = {
6447 .mixers = { alc262_base_mixer },
6448 .init_verbs = { alc262_init_verbs },
6449 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6450 .dac_nids = alc262_dac_nids,
6451 .hp_nid = 0x03,
6452 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6453 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006454 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01006455 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006456 [ALC262_HIPPO] = {
6457 .mixers = { alc262_base_mixer },
6458 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
6459 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6460 .dac_nids = alc262_dac_nids,
6461 .hp_nid = 0x03,
6462 .dig_out_nid = ALC262_DIGOUT_NID,
6463 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6464 .channel_mode = alc262_modes,
6465 .input_mux = &alc262_capture_source,
6466 .unsol_event = alc262_hippo_unsol_event,
6467 },
6468 [ALC262_HIPPO_1] = {
6469 .mixers = { alc262_hippo1_mixer },
6470 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
6471 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6472 .dac_nids = alc262_dac_nids,
6473 .hp_nid = 0x02,
6474 .dig_out_nid = ALC262_DIGOUT_NID,
6475 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6476 .channel_mode = alc262_modes,
6477 .input_mux = &alc262_capture_source,
6478 .unsol_event = alc262_hippo1_unsol_event,
6479 },
Takashi Iwai834be882006-03-01 14:16:17 +01006480 [ALC262_FUJITSU] = {
6481 .mixers = { alc262_fujitsu_mixer },
6482 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
6483 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6484 .dac_nids = alc262_dac_nids,
6485 .hp_nid = 0x03,
6486 .dig_out_nid = ALC262_DIGOUT_NID,
6487 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6488 .channel_mode = alc262_modes,
6489 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006490 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01006491 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006492 [ALC262_HP_BPC] = {
6493 .mixers = { alc262_HP_BPC_mixer },
6494 .init_verbs = { alc262_HP_BPC_init_verbs },
6495 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6496 .dac_nids = alc262_dac_nids,
6497 .hp_nid = 0x03,
6498 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6499 .channel_mode = alc262_modes,
6500 .input_mux = &alc262_HP_capture_source,
6501 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006502 [ALC262_BENQ_ED8] = {
6503 .mixers = { alc262_base_mixer },
6504 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
6505 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6506 .dac_nids = alc262_dac_nids,
6507 .hp_nid = 0x03,
6508 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6509 .channel_mode = alc262_modes,
6510 .input_mux = &alc262_capture_source,
6511 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006512};
6513
6514static int patch_alc262(struct hda_codec *codec)
6515{
6516 struct alc_spec *spec;
6517 int board_config;
6518 int err;
6519
6520 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6521 if (spec == NULL)
6522 return -ENOMEM;
6523
6524 codec->spec = spec;
6525#if 0
6526 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6527 {
6528 int tmp;
6529 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6530 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6531 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6532 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6533 }
6534#endif
6535
6536 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006537
Kailang Yangdf694da2005-12-05 19:42:22 +01006538 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006539 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6540 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006541 board_config = ALC262_AUTO;
6542 }
6543
6544 if (board_config == ALC262_AUTO) {
6545 /* automatic parse from the BIOS config */
6546 err = alc262_parse_auto_config(codec);
6547 if (err < 0) {
6548 alc_free(codec);
6549 return err;
6550 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006551 printk(KERN_INFO
6552 "hda_codec: Cannot set up configuration "
6553 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006554 board_config = ALC262_BASIC;
6555 }
6556 }
6557
6558 if (board_config != ALC262_AUTO)
6559 setup_preset(spec, &alc262_presets[board_config]);
6560
6561 spec->stream_name_analog = "ALC262 Analog";
6562 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6563 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6564
6565 spec->stream_name_digital = "ALC262 Digital";
6566 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6567 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6568
6569 if (! spec->adc_nids && spec->input_mux) {
6570 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006571 unsigned int wcap = get_wcaps(codec, 0x07);
6572
Kailang Yangdf694da2005-12-05 19:42:22 +01006573 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6574 if (wcap != AC_WID_AUD_IN) {
6575 spec->adc_nids = alc262_adc_nids_alt;
6576 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6577 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6578 spec->num_mixers++;
6579 } else {
6580 spec->adc_nids = alc262_adc_nids;
6581 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6582 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6583 spec->num_mixers++;
6584 }
6585 }
6586
6587 codec->patch_ops = alc_patch_ops;
6588 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006589 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01006590
Kailang Yangdf694da2005-12-05 19:42:22 +01006591 return 0;
6592}
6593
Kailang Yangdf694da2005-12-05 19:42:22 +01006594/*
6595 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6596 */
6597
6598/*
6599 * set the path ways for 2 channel output
6600 * need to set the codec line out and mic 1 pin widgets to inputs
6601 */
6602static struct hda_verb alc861_threestack_ch2_init[] = {
6603 /* set pin widget 1Ah (line in) for input */
6604 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6605 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6606 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6607
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6609#if 0
6610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6611 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6612#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006613 { } /* end */
6614};
6615/*
6616 * 6ch mode
6617 * need to set the codec line out and mic 1 pin widgets to outputs
6618 */
6619static struct hda_verb alc861_threestack_ch6_init[] = {
6620 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6621 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6622 /* set pin widget 18h (mic1) for output (CLFE)*/
6623 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6624
6625 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006626 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006627
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006628 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6629#if 0
6630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6632#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006633 { } /* end */
6634};
6635
6636static struct hda_channel_mode alc861_threestack_modes[2] = {
6637 { 2, alc861_threestack_ch2_init },
6638 { 6, alc861_threestack_ch6_init },
6639};
Takashi Iwai22309c32006-08-09 16:57:28 +02006640/* Set mic1 as input and unmute the mixer */
6641static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6642 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6643 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6644 { } /* end */
6645};
6646/* Set mic1 as output and mute mixer */
6647static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6648 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6650 { } /* end */
6651};
6652
6653static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6654 { 2, alc861_uniwill_m31_ch2_init },
6655 { 4, alc861_uniwill_m31_ch4_init },
6656};
Kailang Yangdf694da2005-12-05 19:42:22 +01006657
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006658/* Set mic1 and line-in as input and unmute the mixer */
6659static struct hda_verb alc861_asus_ch2_init[] = {
6660 /* set pin widget 1Ah (line in) for input */
6661 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6662 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6663 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6664
6665 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6666#if 0
6667 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6668 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6669#endif
6670 { } /* end */
6671};
6672/* Set mic1 nad line-in as output and mute mixer */
6673static struct hda_verb alc861_asus_ch6_init[] = {
6674 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6675 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6676 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6677 /* set pin widget 18h (mic1) for output (CLFE)*/
6678 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6679 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6680 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6681 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6682
6683 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6684#if 0
6685 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6686 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6687#endif
6688 { } /* end */
6689};
6690
6691static struct hda_channel_mode alc861_asus_modes[2] = {
6692 { 2, alc861_asus_ch2_init },
6693 { 6, alc861_asus_ch6_init },
6694};
6695
Kailang Yangdf694da2005-12-05 19:42:22 +01006696/* patch-ALC861 */
6697
6698static struct snd_kcontrol_new alc861_base_mixer[] = {
6699 /* output mixer control */
6700 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6701 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6702 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6703 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6704 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6705
6706 /*Input mixer control */
6707 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6708 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6709 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6710 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6711 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6712 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6714 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6715 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6716 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6717
6718 /* Capture mixer control */
6719 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6720 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6721 {
6722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6723 .name = "Capture Source",
6724 .count = 1,
6725 .info = alc_mux_enum_info,
6726 .get = alc_mux_enum_get,
6727 .put = alc_mux_enum_put,
6728 },
6729 { } /* end */
6730};
6731
6732static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6733 /* output mixer control */
6734 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6735 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6736 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6737 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6738 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6739
6740 /* Input mixer control */
6741 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6742 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6743 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6744 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6745 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6746 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6747 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6748 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6749 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6750 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6751
6752 /* Capture mixer control */
6753 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6754 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6755 {
6756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6757 .name = "Capture Source",
6758 .count = 1,
6759 .info = alc_mux_enum_info,
6760 .get = alc_mux_enum_get,
6761 .put = alc_mux_enum_put,
6762 },
6763 {
6764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6765 .name = "Channel Mode",
6766 .info = alc_ch_mode_info,
6767 .get = alc_ch_mode_get,
6768 .put = alc_ch_mode_put,
6769 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6770 },
6771 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02006772};
6773
6774static snd_kcontrol_new_t alc861_toshiba_mixer[] = {
6775 /* output mixer control */
6776 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6778 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6779
6780 /*Capture mixer control */
6781 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6782 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6783 {
6784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6785 .name = "Capture Source",
6786 .count = 1,
6787 .info = alc_mux_enum_info,
6788 .get = alc_mux_enum_get,
6789 .put = alc_mux_enum_put,
6790 },
6791
6792 { } /* end */
6793};
6794
Takashi Iwai22309c32006-08-09 16:57:28 +02006795static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6796 /* output mixer control */
6797 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6798 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6799 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6800 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6801 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6802
6803 /* Input mixer control */
6804 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6805 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6806 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6807 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6808 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6809 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6811 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6813 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6814
6815 /* Capture mixer control */
6816 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6817 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6818 {
6819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6820 .name = "Capture Source",
6821 .count = 1,
6822 .info = alc_mux_enum_info,
6823 .get = alc_mux_enum_get,
6824 .put = alc_mux_enum_put,
6825 },
6826 {
6827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6828 .name = "Channel Mode",
6829 .info = alc_ch_mode_info,
6830 .get = alc_ch_mode_get,
6831 .put = alc_ch_mode_put,
6832 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6833 },
6834 { } /* end */
6835};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006836
6837static struct snd_kcontrol_new alc861_asus_mixer[] = {
6838 /* output mixer control */
6839 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6840 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6841 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6842 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6843 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6844
6845 /* Input mixer control */
6846 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6847 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6848 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6849 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6850 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6851 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6853 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6854 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
6856
6857 /* Capture mixer control */
6858 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6859 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6860 {
6861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6862 .name = "Capture Source",
6863 .count = 1,
6864 .info = alc_mux_enum_info,
6865 .get = alc_mux_enum_get,
6866 .put = alc_mux_enum_put,
6867 },
6868 {
6869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6870 .name = "Channel Mode",
6871 .info = alc_ch_mode_info,
6872 .get = alc_ch_mode_get,
6873 .put = alc_ch_mode_put,
6874 .private_value = ARRAY_SIZE(alc861_asus_modes),
6875 },
6876 { }
6877};
6878
Kailang Yangdf694da2005-12-05 19:42:22 +01006879
6880/*
6881 * generic initialization of ADC, input mixers and output mixers
6882 */
6883static struct hda_verb alc861_base_init_verbs[] = {
6884 /*
6885 * Unmute ADC0 and set the default input to mic-in
6886 */
6887 /* port-A for surround (rear panel) */
6888 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6889 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6890 /* port-B for mic-in (rear panel) with vref */
6891 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6892 /* port-C for line-in (rear panel) */
6893 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6894 /* port-D for Front */
6895 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6896 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6897 /* port-E for HP out (front panel) */
6898 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6899 /* route front PCM to HP */
6900 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6901 /* port-F for mic-in (front panel) with vref */
6902 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6903 /* port-G for CLFE (rear panel) */
6904 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6905 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6906 /* port-H for side (rear panel) */
6907 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6908 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6909 /* CD-in */
6910 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6911 /* route front mic to ADC1*/
6912 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6913 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6914
6915 /* Unmute DAC0~3 & spdif out*/
6916 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6917 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6918 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6919 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6921
6922 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6923 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6924 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6925 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6926 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6927
6928 /* Unmute Stereo Mixer 15 */
6929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6933
6934 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6936 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6941 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6944
6945 { }
6946};
6947
6948static struct hda_verb alc861_threestack_init_verbs[] = {
6949 /*
6950 * Unmute ADC0 and set the default input to mic-in
6951 */
6952 /* port-A for surround (rear panel) */
6953 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6954 /* port-B for mic-in (rear panel) with vref */
6955 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6956 /* port-C for line-in (rear panel) */
6957 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6958 /* port-D for Front */
6959 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6960 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6961 /* port-E for HP out (front panel) */
6962 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6963 /* route front PCM to HP */
6964 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6965 /* port-F for mic-in (front panel) with vref */
6966 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6967 /* port-G for CLFE (rear panel) */
6968 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6969 /* port-H for side (rear panel) */
6970 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6971 /* CD-in */
6972 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6973 /* route front mic to ADC1*/
6974 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6976 /* Unmute DAC0~3 & spdif out*/
6977 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6978 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6979 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6980 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6982
6983 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6984 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6985 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6986 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6987 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6988
6989 /* Unmute Stereo Mixer 15 */
6990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6992 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6994
6995 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6996 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6997 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6998 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6999 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7000 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7001 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7005 { }
7006};
Takashi Iwai22309c32006-08-09 16:57:28 +02007007
7008static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7009 /*
7010 * Unmute ADC0 and set the default input to mic-in
7011 */
7012 /* port-A for surround (rear panel) */
7013 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7014 /* port-B for mic-in (rear panel) with vref */
7015 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7016 /* port-C for line-in (rear panel) */
7017 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7018 /* port-D for Front */
7019 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7020 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7021 /* port-E for HP out (front panel) */
7022 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
7023 /* route front PCM to HP */
7024 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
7025 /* port-F for mic-in (front panel) with vref */
7026 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7027 /* port-G for CLFE (rear panel) */
7028 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7029 /* port-H for side (rear panel) */
7030 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7031 /* CD-in */
7032 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7033 /* route front mic to ADC1*/
7034 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7036 /* Unmute DAC0~3 & spdif out*/
7037 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7038 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7039 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7040 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7042
7043 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7044 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7045 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7046 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7047 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7048
7049 /* Unmute Stereo Mixer 15 */
7050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7054
7055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7059 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7061 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7065 { }
7066};
7067
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007068static struct hda_verb alc861_asus_init_verbs[] = {
7069 /*
7070 * Unmute ADC0 and set the default input to mic-in
7071 */
7072 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
7073 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7074 /* route front PCM to HP */
7075 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
7076 /* port-B for mic-in (rear panel) with vref */
7077 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7078 /* port-C for line-in (rear panel) */
7079 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7080 /* port-D for Front */
7081 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7082 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7083 /* port-E for HP out (front panel) */
7084 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
7085 /* route front PCM to HP */
7086 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
7087 /* port-F for mic-in (front panel) with vref */
7088 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7089 /* port-G for CLFE (rear panel) */
7090 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7091 /* port-H for side (rear panel) */
7092 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7093 /* CD-in */
7094 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7095 /* route front mic to ADC1*/
7096 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7098 /* Unmute DAC0~3 & spdif out*/
7099 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7100 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7101 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7102 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7104 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7105 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7106 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7107 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7108 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7109
7110 /* Unmute Stereo Mixer 15 */
7111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
7115
7116 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7119 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
7125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7126 { }
7127};
7128
7129
Kailang Yangdf694da2005-12-05 19:42:22 +01007130/*
7131 * generic initialization of ADC, input mixers and output mixers
7132 */
7133static struct hda_verb alc861_auto_init_verbs[] = {
7134 /*
7135 * Unmute ADC0 and set the default input to mic-in
7136 */
7137// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7138 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7139
7140 /* Unmute DAC0~3 & spdif out*/
7141 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7142 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7143 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7144 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7146
7147 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7148 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7149 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7150 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7151 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7152
7153 /* Unmute Stereo Mixer 15 */
7154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7158
7159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7161 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7162 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7163 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7165 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7166 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7167
7168 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7169 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7171 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7172 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7174 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7176
7177 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7178
7179 { }
7180};
7181
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007182static struct hda_verb alc861_toshiba_init_verbs[] = {
7183 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7184
7185 { }
7186};
7187
7188/* toggle speaker-output according to the hp-jack state */
7189static void alc861_toshiba_automute(struct hda_codec *codec)
7190{
7191 unsigned int present;
7192
7193 present = snd_hda_codec_read(codec, 0x0f, 0,
7194 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7195 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7196 0x80, present ? 0x80 : 0);
7197 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7198 0x80, present ? 0x80 : 0);
7199 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7200 0x80, present ? 0 : 0x80);
7201 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7202 0x80, present ? 0 : 0x80);
7203}
7204
7205static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7206 unsigned int res)
7207{
7208 /* Looks like the unsol event is incompatible with the standard
7209 * definition. 6bit tag is placed at 26 bit!
7210 */
7211 if ((res >> 26) == ALC880_HP_EVENT)
7212 alc861_toshiba_automute(codec);
7213}
7214
Kailang Yangdf694da2005-12-05 19:42:22 +01007215/* pcm configuration: identiacal with ALC880 */
7216#define alc861_pcm_analog_playback alc880_pcm_analog_playback
7217#define alc861_pcm_analog_capture alc880_pcm_analog_capture
7218#define alc861_pcm_digital_playback alc880_pcm_digital_playback
7219#define alc861_pcm_digital_capture alc880_pcm_digital_capture
7220
7221
7222#define ALC861_DIGOUT_NID 0x07
7223
7224static struct hda_channel_mode alc861_8ch_modes[1] = {
7225 { 8, NULL }
7226};
7227
7228static hda_nid_t alc861_dac_nids[4] = {
7229 /* front, surround, clfe, side */
7230 0x03, 0x06, 0x05, 0x04
7231};
7232
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007233static hda_nid_t alc660_dac_nids[3] = {
7234 /* front, clfe, surround */
7235 0x03, 0x05, 0x06
7236};
7237
Kailang Yangdf694da2005-12-05 19:42:22 +01007238static hda_nid_t alc861_adc_nids[1] = {
7239 /* ADC0-2 */
7240 0x08,
7241};
7242
7243static struct hda_input_mux alc861_capture_source = {
7244 .num_items = 5,
7245 .items = {
7246 { "Mic", 0x0 },
7247 { "Front Mic", 0x3 },
7248 { "Line", 0x1 },
7249 { "CD", 0x4 },
7250 { "Mixer", 0x5 },
7251 },
7252};
7253
7254/* fill in the dac_nids table from the parsed pin configuration */
7255static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7256{
7257 int i;
7258 hda_nid_t nid;
7259
7260 spec->multiout.dac_nids = spec->private_dac_nids;
7261 for (i = 0; i < cfg->line_outs; i++) {
7262 nid = cfg->line_out_pins[i];
7263 if (nid) {
7264 if (i >= ARRAY_SIZE(alc861_dac_nids))
7265 continue;
7266 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7267 }
7268 }
7269 spec->multiout.num_dacs = cfg->line_outs;
7270 return 0;
7271}
7272
7273/* add playback controls from the parsed DAC table */
7274static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7275 const struct auto_pin_cfg *cfg)
7276{
7277 char name[32];
7278 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7279 hda_nid_t nid;
7280 int i, idx, err;
7281
7282 for (i = 0; i < cfg->line_outs; i++) {
7283 nid = spec->multiout.dac_nids[i];
7284 if (! nid)
7285 continue;
7286 if (nid == 0x05) {
7287 /* Center/LFE */
7288 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7289 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7290 return err;
7291 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7292 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7293 return err;
7294 } else {
7295 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7296 if (nid == alc861_dac_nids[idx])
7297 break;
7298 sprintf(name, "%s Playback Switch", chname[idx]);
7299 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7300 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7301 return err;
7302 }
7303 }
7304 return 0;
7305}
7306
7307static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7308{
7309 int err;
7310 hda_nid_t nid;
7311
7312 if (! pin)
7313 return 0;
7314
7315 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7316 nid = 0x03;
7317 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7318 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7319 return err;
7320 spec->multiout.hp_nid = nid;
7321 }
7322 return 0;
7323}
7324
7325/* create playback/capture controls for input pins */
7326static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7327{
Kailang Yangdf694da2005-12-05 19:42:22 +01007328 struct hda_input_mux *imux = &spec->private_imux;
7329 int i, err, idx, idx1;
7330
7331 for (i = 0; i < AUTO_PIN_LAST; i++) {
7332 switch(cfg->input_pins[i]) {
7333 case 0x0c:
7334 idx1 = 1;
7335 idx = 2; // Line In
7336 break;
7337 case 0x0f:
7338 idx1 = 2;
7339 idx = 2; // Line In
7340 break;
7341 case 0x0d:
7342 idx1 = 0;
7343 idx = 1; // Mic In
7344 break;
7345 case 0x10:
7346 idx1 = 3;
7347 idx = 1; // Mic In
7348 break;
7349 case 0x11:
7350 idx1 = 4;
7351 idx = 0; // CD
7352 break;
7353 default:
7354 continue;
7355 }
7356
Takashi Iwai4a471b72005-12-07 13:56:29 +01007357 err = new_analog_input(spec, cfg->input_pins[i],
7358 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01007359 if (err < 0)
7360 return err;
7361
Takashi Iwai4a471b72005-12-07 13:56:29 +01007362 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01007363 imux->items[imux->num_items].index = idx1;
7364 imux->num_items++;
7365 }
7366 return 0;
7367}
7368
7369static struct snd_kcontrol_new alc861_capture_mixer[] = {
7370 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7371 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7372
7373 {
7374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7375 /* The multiple "Capture Source" controls confuse alsamixer
7376 * So call somewhat different..
7377 *FIXME: the controls appear in the "playback" view!
7378 */
7379 /* .name = "Capture Source", */
7380 .name = "Input Source",
7381 .count = 1,
7382 .info = alc_mux_enum_info,
7383 .get = alc_mux_enum_get,
7384 .put = alc_mux_enum_put,
7385 },
7386 { } /* end */
7387};
7388
7389static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7390 int pin_type, int dac_idx)
7391{
7392 /* set as output */
7393
7394 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7395 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
7396
7397}
7398
7399static void alc861_auto_init_multi_out(struct hda_codec *codec)
7400{
7401 struct alc_spec *spec = codec->spec;
7402 int i;
7403
7404 for (i = 0; i < spec->autocfg.line_outs; i++) {
7405 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7406 if (nid)
7407 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
7408 }
7409}
7410
7411static void alc861_auto_init_hp_out(struct hda_codec *codec)
7412{
7413 struct alc_spec *spec = codec->spec;
7414 hda_nid_t pin;
7415
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007416 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007417 if (pin) /* connect to front */
7418 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
7419}
7420
7421static void alc861_auto_init_analog_input(struct hda_codec *codec)
7422{
7423 struct alc_spec *spec = codec->spec;
7424 int i;
7425
7426 for (i = 0; i < AUTO_PIN_LAST; i++) {
7427 hda_nid_t nid = spec->autocfg.input_pins[i];
7428 if ((nid>=0x0c) && (nid <=0x11)) {
7429 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7430 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
7431 }
7432 }
7433}
7434
7435/* parse the BIOS configuration and set up the alc_spec */
7436/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
7437static int alc861_parse_auto_config(struct hda_codec *codec)
7438{
7439 struct alc_spec *spec = codec->spec;
7440 int err;
7441 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7442
7443 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7444 alc861_ignore)) < 0)
7445 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01007446 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007447 return 0; /* can't find valid BIOS pin config */
7448
7449 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
7450 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007451 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
Kailang Yangdf694da2005-12-05 19:42:22 +01007452 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
7453 return err;
7454
7455 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7456
7457 if (spec->autocfg.dig_out_pin)
7458 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
7459
7460 if (spec->kctl_alloc)
7461 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7462
7463 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
7464
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007465 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007466 spec->input_mux = &spec->private_imux;
7467
7468 spec->adc_nids = alc861_adc_nids;
7469 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
7470 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
7471 spec->num_mixers++;
7472
7473 return 1;
7474}
7475
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007476/* additional initialization for auto-configuration model */
7477static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007478{
Kailang Yangdf694da2005-12-05 19:42:22 +01007479 alc861_auto_init_multi_out(codec);
7480 alc861_auto_init_hp_out(codec);
7481 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007482}
7483
7484
7485/*
7486 * configuration and preset
7487 */
7488static struct hda_board_config alc861_cfg_tbl[] = {
7489 { .modelname = "3stack", .config = ALC861_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007490 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
7491 .config = ALC861_3ST },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007492 { .modelname = "3stack-660", .config = ALC660_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007493 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
7494 .config = ALC660_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01007495 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
7496 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
Takashi Iwai22309c32006-08-09 16:57:28 +02007497 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
7498 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
7499 .config = ALC861_UNIWILL_M31 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007500 { .modelname = "toshiba", .config = ALC861_TOSHIBA },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007501 { .pci_subvendor = 0x1179, .pci_subdevice = 0xff10,
7502 .config = ALC861_TOSHIBA },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007503 { .modelname = "asus", .config = ALC861_ASUS},
7504 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1393,
7505 .config = ALC861_ASUS },
7506 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1338,
7507 .config = ALC861_ASUS },
Kailang Yangdf694da2005-12-05 19:42:22 +01007508 { .modelname = "auto", .config = ALC861_AUTO },
7509 {}
7510};
7511
7512static struct alc_config_preset alc861_presets[] = {
7513 [ALC861_3ST] = {
7514 .mixers = { alc861_3ST_mixer },
7515 .init_verbs = { alc861_threestack_init_verbs },
7516 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7517 .dac_nids = alc861_dac_nids,
7518 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7519 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007520 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007521 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7522 .adc_nids = alc861_adc_nids,
7523 .input_mux = &alc861_capture_source,
7524 },
7525 [ALC861_3ST_DIG] = {
7526 .mixers = { alc861_base_mixer },
7527 .init_verbs = { alc861_threestack_init_verbs },
7528 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7529 .dac_nids = alc861_dac_nids,
7530 .dig_out_nid = ALC861_DIGOUT_NID,
7531 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7532 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007533 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007534 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7535 .adc_nids = alc861_adc_nids,
7536 .input_mux = &alc861_capture_source,
7537 },
7538 [ALC861_6ST_DIG] = {
7539 .mixers = { alc861_base_mixer },
7540 .init_verbs = { alc861_base_init_verbs },
7541 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7542 .dac_nids = alc861_dac_nids,
7543 .dig_out_nid = ALC861_DIGOUT_NID,
7544 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
7545 .channel_mode = alc861_8ch_modes,
7546 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7547 .adc_nids = alc861_adc_nids,
7548 .input_mux = &alc861_capture_source,
7549 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007550 [ALC660_3ST] = {
7551 .mixers = { alc861_3ST_mixer },
7552 .init_verbs = { alc861_threestack_init_verbs },
7553 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
7554 .dac_nids = alc660_dac_nids,
7555 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7556 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007557 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007558 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7559 .adc_nids = alc861_adc_nids,
7560 .input_mux = &alc861_capture_source,
7561 },
Takashi Iwai22309c32006-08-09 16:57:28 +02007562 [ALC861_UNIWILL_M31] = {
7563 .mixers = { alc861_uniwill_m31_mixer },
7564 .init_verbs = { alc861_uniwill_m31_init_verbs },
7565 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7566 .dac_nids = alc861_dac_nids,
7567 .dig_out_nid = ALC861_DIGOUT_NID,
7568 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
7569 .channel_mode = alc861_uniwill_m31_modes,
7570 .need_dac_fix = 1,
7571 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7572 .adc_nids = alc861_adc_nids,
7573 .input_mux = &alc861_capture_source,
7574 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007575 [ALC861_TOSHIBA] = {
7576 .mixers = { alc861_toshiba_mixer },
7577 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
7578 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7579 .dac_nids = alc861_dac_nids,
7580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7581 .channel_mode = alc883_3ST_2ch_modes,
7582 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7583 .adc_nids = alc861_adc_nids,
7584 .input_mux = &alc861_capture_source,
7585 .unsol_event = alc861_toshiba_unsol_event,
7586 .init_hook = alc861_toshiba_automute,
7587 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007588 [ALC861_ASUS] = {
7589 .mixers = { alc861_asus_mixer },
7590 .init_verbs = { alc861_asus_init_verbs },
7591 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7592 .dac_nids = alc861_dac_nids,
7593 .dig_out_nid = ALC861_DIGOUT_NID,
7594 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
7595 .channel_mode = alc861_asus_modes,
7596 .need_dac_fix = 1,
7597 .hp_nid = 0x06,
7598 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7599 .adc_nids = alc861_adc_nids,
7600 .input_mux = &alc861_capture_source,
7601 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007602};
7603
7604
7605static int patch_alc861(struct hda_codec *codec)
7606{
7607 struct alc_spec *spec;
7608 int board_config;
7609 int err;
7610
7611 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
7612 if (spec == NULL)
7613 return -ENOMEM;
7614
7615 codec->spec = spec;
7616
7617 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007618
Kailang Yangdf694da2005-12-05 19:42:22 +01007619 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007620 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
7621 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007622 board_config = ALC861_AUTO;
7623 }
7624
7625 if (board_config == ALC861_AUTO) {
7626 /* automatic parse from the BIOS config */
7627 err = alc861_parse_auto_config(codec);
7628 if (err < 0) {
7629 alc_free(codec);
7630 return err;
7631 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007632 printk(KERN_INFO
7633 "hda_codec: Cannot set up configuration "
7634 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007635 board_config = ALC861_3ST_DIG;
7636 }
7637 }
7638
7639 if (board_config != ALC861_AUTO)
7640 setup_preset(spec, &alc861_presets[board_config]);
7641
7642 spec->stream_name_analog = "ALC861 Analog";
7643 spec->stream_analog_playback = &alc861_pcm_analog_playback;
7644 spec->stream_analog_capture = &alc861_pcm_analog_capture;
7645
7646 spec->stream_name_digital = "ALC861 Digital";
7647 spec->stream_digital_playback = &alc861_pcm_digital_playback;
7648 spec->stream_digital_capture = &alc861_pcm_digital_capture;
7649
7650 codec->patch_ops = alc_patch_ops;
7651 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007652 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01007653
7654 return 0;
7655}
7656
7657/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07007658 * patch entries
7659 */
7660struct hda_codec_preset snd_hda_preset_realtek[] = {
7661 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007662 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007663 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
7664 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007665 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007666 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007667 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
7668 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
7669 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007670 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007671 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007672 { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007673 {} /* terminator */
7674};