blob: 991f1079116bbbc41564577dbb139dfcc1c61812 [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 Woithe7cf51e42006-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
35
36/* ALC880 board config type */
37enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ALC880_3ST,
39 ALC880_3ST_DIG,
40 ALC880_5ST,
41 ALC880_5ST_DIG,
42 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020043 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020044 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020045 ALC880_6ST_DIG,
46 ALC880_F1734,
47 ALC880_ASUS,
48 ALC880_ASUS_DIG,
49 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010050 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020051 ALC880_UNIWILL_DIG,
Kailang Yangdf694da2005-12-05 19:42:22 +010052 ALC880_CLEVO,
53 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010054 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010055 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020056#ifdef CONFIG_SND_DEBUG
57 ALC880_TEST,
58#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020060 ALC880_MODEL_LAST /* last tag */
61};
62
63/* ALC260 models */
64enum {
65 ALC260_BASIC,
66 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC260_HP_3013,
68 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010069 ALC260_ACER,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010070#ifdef CONFIG_SND_DEBUG
71 ALC260_TEST,
72#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020074 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Kailang Yangdf694da2005-12-05 19:42:22 +010077/* ALC262 models */
78enum {
79 ALC262_BASIC,
Takashi Iwai834be882006-03-01 14:16:17 +010080 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020081 ALC262_HP_BPC,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020082 ALC262_BENQ_ED8,
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC262_AUTO,
84 ALC262_MODEL_LAST /* last tag */
85};
86
87/* ALC861 models */
88enum {
89 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020090 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +010091 ALC861_3ST_DIG,
92 ALC861_6ST_DIG,
93 ALC861_AUTO,
94 ALC861_MODEL_LAST,
95};
96
97/* ALC882 models */
98enum {
99 ALC882_3ST_DIG,
100 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200101 ALC882_ARIMA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100102 ALC882_AUTO,
103 ALC882_MODEL_LAST,
104};
105
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200106/* ALC883 models */
107enum {
108 ALC883_3ST_2ch_DIG,
109 ALC883_3ST_6ch_DIG,
110 ALC883_3ST_6ch,
111 ALC883_6ST_DIG,
112 ALC888_DEMO_BOARD,
113 ALC883_AUTO,
114 ALC883_MODEL_LAST,
115};
116
Kailang Yangdf694da2005-12-05 19:42:22 +0100117/* for GPIO Poll */
118#define GPIO_MASK 0x03
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120struct alc_spec {
121 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100122 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 unsigned int num_mixers;
124
Kailang Yangdf694da2005-12-05 19:42:22 +0100125 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200126 * don't forget NULL
127 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200128 */
129 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Takashi Iwai16ded522005-06-10 19:58:24 +0200131 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 struct hda_pcm_stream *stream_analog_playback;
133 struct hda_pcm_stream *stream_analog_capture;
134
Takashi Iwai16ded522005-06-10 19:58:24 +0200135 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 struct hda_pcm_stream *stream_digital_playback;
137 struct hda_pcm_stream *stream_digital_capture;
138
139 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200140 struct hda_multi_out multiout; /* playback set-up
141 * max_channels, dacs must be set
142 * dig_out_nid and hp_nid are optional
143 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145 /* capture */
146 unsigned int num_adc_nids;
147 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200148 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200151 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 const struct hda_input_mux *input_mux;
153 unsigned int cur_mux[3];
154
155 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100156 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200158 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100161 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200162
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200163 /* dynamic controls, init_verbs and input_mux */
164 struct auto_pin_cfg autocfg;
165 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100166 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200167 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100168 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100169
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100170 /* hooks */
171 void (*init_hook)(struct hda_codec *codec);
172 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
173
Takashi Iwai834be882006-03-01 14:16:17 +0100174 /* for pin sensing */
175 unsigned int sense_updated: 1;
176 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100177};
178
179/*
180 * configuration template - to be copied to the spec instance
181 */
182struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200183 struct snd_kcontrol_new *mixers[5]; /* should be identical size
184 * with spec
185 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100186 const struct hda_verb *init_verbs[5];
187 unsigned int num_dacs;
188 hda_nid_t *dac_nids;
189 hda_nid_t dig_out_nid; /* optional */
190 hda_nid_t hp_nid; /* optional */
191 unsigned int num_adc_nids;
192 hda_nid_t *adc_nids;
193 hda_nid_t dig_in_nid;
194 unsigned int num_channel_mode;
195 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200196 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200197 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100198 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100199 void (*unsol_event)(struct hda_codec *, unsigned int);
200 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201};
202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204/*
205 * input MUX handling
206 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200207static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
208 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209{
210 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
211 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200212 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
213 if (mux_idx >= spec->num_mux_defs)
214 mux_idx = 0;
215 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216}
217
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
219 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220{
221 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
222 struct alc_spec *spec = codec->spec;
223 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
224
225 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
226 return 0;
227}
228
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200229static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231{
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
233 struct alc_spec *spec = codec->spec;
234 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200235 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
236 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200237 spec->adc_nids[adc_idx],
238 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239}
240
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242/*
243 * channel mode setting
244 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200245static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100250 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
251 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252}
253
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200254static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256{
257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
258 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100259 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200260 spec->num_channel_mode,
261 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262}
263
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200264static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
265 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266{
267 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
268 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200269 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
270 spec->num_channel_mode,
271 &spec->multiout.max_channels);
272 if (! err && spec->need_dac_fix)
273 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
274 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275}
276
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100278 * Control the mode of pin widget settings via the mixer. "pc" is used
279 * instead of "%" to avoid consequences of accidently treating the % as
280 * being part of a format specifier. Maximum allowed length of a value is
281 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100282 *
283 * Note: some retasking pin complexes seem to ignore requests for input
284 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
285 * are requested. Therefore order this list so that this behaviour will not
286 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200287 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
288 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200289 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100290static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100291 "Mic 50pc bias", "Mic 80pc bias",
292 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100293};
294static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100295 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100296};
297/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200298 * in the pin being assumed to be exclusively an input or an output pin. In
299 * addition, "input" pins may or may not process the mic bias option
300 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
301 * accept requests for bias as of chip versions up to March 2006) and/or
302 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100303 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200304#define ALC_PIN_DIR_IN 0x00
305#define ALC_PIN_DIR_OUT 0x01
306#define ALC_PIN_DIR_INOUT 0x02
307#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
308#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100309
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200310/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100311 * For each direction the minimum and maximum values are given.
312 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100314 { 0, 2 }, /* ALC_PIN_DIR_IN */
315 { 3, 4 }, /* ALC_PIN_DIR_OUT */
316 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200317 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
318 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100319};
320#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
321#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
322#define alc_pin_mode_n_items(_dir) \
323 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
324
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200325static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200327{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100328 unsigned int item_num = uinfo->value.enumerated.item;
329 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
330
331 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200332 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100333 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
334
335 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
336 item_num = alc_pin_mode_min(dir);
337 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200338 return 0;
339}
340
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200341static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
342 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200343{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100344 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
346 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100347 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200348 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200349 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
350 AC_VERB_GET_PIN_WIDGET_CONTROL,
351 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200352
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100353 /* Find enumerated value for current pinctl setting */
354 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200355 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100358 return 0;
359}
360
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200361static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
362 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100363{
364 signed int change;
365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
366 hda_nid_t nid = kcontrol->private_value & 0xffff;
367 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
368 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
370 AC_VERB_GET_PIN_WIDGET_CONTROL,
371 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374 val = alc_pin_mode_min(dir);
375
376 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100377 if (change) {
378 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200379 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200380 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100381
382 /* Also enable the retasking pin's input/output as required
383 * for the requested pin mode. Enum values of 2 or less are
384 * input modes.
385 *
386 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200387 * reduces noise slightly (particularly on input) so we'll
388 * do it. However, having both input and output buffers
389 * enabled simultaneously doesn't seem to be problematic if
390 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100391 */
392 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200393 snd_hda_codec_write(codec, nid, 0,
394 AC_VERB_SET_AMP_GAIN_MUTE,
395 AMP_OUT_MUTE);
396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
398 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100399 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200400 snd_hda_codec_write(codec, nid, 0,
401 AC_VERB_SET_AMP_GAIN_MUTE,
402 AMP_IN_MUTE(0));
403 snd_hda_codec_write(codec, nid, 0,
404 AC_VERB_SET_AMP_GAIN_MUTE,
405 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100406 }
407 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200408 return change;
409}
410
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200412 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 .info = alc_pin_mode_info, \
414 .get = alc_pin_mode_get, \
415 .put = alc_pin_mode_put, \
416 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100417
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100418/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
419 * together using a mask with more than one bit set. This control is
420 * currently used only by the ALC260 test model. At this stage they are not
421 * needed for any "production" models.
422 */
423#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100426{
427 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
428 uinfo->count = 1;
429 uinfo->value.integer.min = 0;
430 uinfo->value.integer.max = 1;
431 return 0;
432}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100435{
436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
437 hda_nid_t nid = kcontrol->private_value & 0xffff;
438 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
439 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440 unsigned int val = snd_hda_codec_read(codec, nid, 0,
441 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100442
443 *valp = (val & mask) != 0;
444 return 0;
445}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100448{
449 signed int change;
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 hda_nid_t nid = kcontrol->private_value & 0xffff;
452 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
453 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200454 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
455 AC_VERB_GET_GPIO_DATA,
456 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100457
458 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
460 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100461 gpio_data &= ~mask;
462 else
463 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100465
466 return change;
467}
468#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
469 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
470 .info = alc_gpio_data_info, \
471 .get = alc_gpio_data_get, \
472 .put = alc_gpio_data_put, \
473 .private_value = nid | (mask<<16) }
474#endif /* CONFIG_SND_DEBUG */
475
Jonathan Woithe92621f12006-02-28 11:47:47 +0100476/* A switch control to allow the enabling of the digital IO pins on the
477 * ALC260. This is incredibly simplistic; the intention of this control is
478 * to provide something in the test model allowing digital outputs to be
479 * identified if present. If models are found which can utilise these
480 * outputs a more complete mixer control can be devised for those models if
481 * necessary.
482 */
483#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200484static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100486{
487 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
488 uinfo->count = 1;
489 uinfo->value.integer.min = 0;
490 uinfo->value.integer.max = 1;
491 return 0;
492}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200493static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
494 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100495{
496 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
497 hda_nid_t nid = kcontrol->private_value & 0xffff;
498 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
499 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200500 unsigned int val = snd_hda_codec_read(codec, nid, 0,
501 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100502
503 *valp = (val & mask) != 0;
504 return 0;
505}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200506static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100508{
509 signed int change;
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 hda_nid_t nid = kcontrol->private_value & 0xffff;
512 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
513 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
515 AC_VERB_GET_DIGI_CONVERT,
516 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100517
518 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200519 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100520 if (val==0)
521 ctrl_data &= ~mask;
522 else
523 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
525 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100526
527 return change;
528}
529#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
530 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
531 .info = alc_spdif_ctrl_info, \
532 .get = alc_spdif_ctrl_get, \
533 .put = alc_spdif_ctrl_put, \
534 .private_value = nid | (mask<<16) }
535#endif /* CONFIG_SND_DEBUG */
536
Kailang Yangdf694da2005-12-05 19:42:22 +0100537/*
538 * set up from the preset table
539 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540static void setup_preset(struct alc_spec *spec,
541 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100542{
543 int i;
544
545 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
546 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
548 i++)
549 spec->init_verbs[spec->num_init_verbs++] =
550 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100551
552 spec->channel_mode = preset->channel_mode;
553 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200554 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100555
556 spec->multiout.max_channels = spec->channel_mode[0].channels;
557
558 spec->multiout.num_dacs = preset->num_dacs;
559 spec->multiout.dac_nids = preset->dac_nids;
560 spec->multiout.dig_out_nid = preset->dig_out_nid;
561 spec->multiout.hp_nid = preset->hp_nid;
562
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200563 spec->num_mux_defs = preset->num_mux_defs;
564 if (! spec->num_mux_defs)
565 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100566 spec->input_mux = preset->input_mux;
567
568 spec->num_adc_nids = preset->num_adc_nids;
569 spec->adc_nids = preset->adc_nids;
570 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100571
572 spec->unsol_event = preset->unsol_event;
573 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100574}
575
Takashi Iwai41e41f12005-06-08 14:48:49 +0200576/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200577 * ALC880 3-stack model
578 *
579 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200580 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
581 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 */
583
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200584static hda_nid_t alc880_dac_nids[4] = {
585 /* front, rear, clfe, rear_surr */
586 0x02, 0x05, 0x04, 0x03
587};
588
589static hda_nid_t alc880_adc_nids[3] = {
590 /* ADC0-2 */
591 0x07, 0x08, 0x09,
592};
593
594/* The datasheet says the node 0x07 is connected from inputs,
595 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100596 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200598static hda_nid_t alc880_adc_nids_alt[2] = {
599 /* ADC1-2 */
600 0x08, 0x09,
601};
602
603#define ALC880_DIGOUT_NID 0x06
604#define ALC880_DIGIN_NID 0x0a
605
606static struct hda_input_mux alc880_capture_source = {
607 .num_items = 4,
608 .items = {
609 { "Mic", 0x0 },
610 { "Front Mic", 0x3 },
611 { "Line", 0x2 },
612 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200614};
615
616/* channel source setting (2/6 channel selection for 3-stack) */
617/* 2ch mode */
618static struct hda_verb alc880_threestack_ch2_init[] = {
619 /* set line-in to input, mute it */
620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
622 /* set mic-in to input vref 80%, mute it */
623 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
624 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 { } /* end */
626};
627
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200628/* 6ch mode */
629static struct hda_verb alc880_threestack_ch6_init[] = {
630 /* set line-in to output, unmute it */
631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
633 /* set mic-in to output, unmute it */
634 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
635 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
636 { } /* end */
637};
638
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100639static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200640 { 2, alc880_threestack_ch2_init },
641 { 6, alc880_threestack_ch6_init },
642};
643
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100644static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200645 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100646 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200647 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100648 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
650 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100651 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
652 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
654 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
661 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
662 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200664 {
665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
666 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100667 .info = alc_ch_mode_info,
668 .get = alc_ch_mode_get,
669 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200670 },
671 { } /* end */
672};
673
674/* capture mixer elements */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100675static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200676 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
678 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
679 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
680 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
681 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
682 {
683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
684 /* The multiple "Capture Source" controls confuse alsamixer
685 * So call somewhat different..
686 * FIXME: the controls appear in the "playback" view!
687 */
688 /* .name = "Capture Source", */
689 .name = "Input Source",
690 .count = 3,
691 .info = alc_mux_enum_info,
692 .get = alc_mux_enum_get,
693 .put = alc_mux_enum_put,
694 },
695 { } /* end */
696};
697
698/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100699static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200700 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
701 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
702 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
703 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 {
705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
706 /* The multiple "Capture Source" controls confuse alsamixer
707 * So call somewhat different..
708 * FIXME: the controls appear in the "playback" view!
709 */
710 /* .name = "Capture Source", */
711 .name = "Input Source",
712 .count = 2,
713 .info = alc_mux_enum_info,
714 .get = alc_mux_enum_get,
715 .put = alc_mux_enum_put,
716 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 { } /* end */
718};
719
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200720
721
722/*
723 * ALC880 5-stack model
724 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200725 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
726 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200727 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
728 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
729 */
730
731/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100732static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200733 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100734 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 { } /* end */
736};
737
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200738/* channel source setting (6/8 channel selection for 5-stack) */
739/* 6ch mode */
740static struct hda_verb alc880_fivestack_ch6_init[] = {
741 /* set line-in to input, mute it */
742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200744 { } /* end */
745};
746
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200747/* 8ch mode */
748static struct hda_verb alc880_fivestack_ch8_init[] = {
749 /* set line-in to output, unmute it */
750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
752 { } /* end */
753};
754
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100755static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200756 { 6, alc880_fivestack_ch6_init },
757 { 8, alc880_fivestack_ch8_init },
758};
759
760
761/*
762 * ALC880 6-stack model
763 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200764 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
765 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200766 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
767 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
768 */
769
770static hda_nid_t alc880_6st_dac_nids[4] = {
771 /* front, rear, clfe, rear_surr */
772 0x02, 0x03, 0x04, 0x05
773};
774
775static struct hda_input_mux alc880_6stack_capture_source = {
776 .num_items = 4,
777 .items = {
778 { "Mic", 0x0 },
779 { "Front Mic", 0x1 },
780 { "Line", 0x2 },
781 { "CD", 0x4 },
782 },
783};
784
785/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100786static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200787 { 8, NULL },
788};
789
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100790static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
796 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100797 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
798 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200799 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100800 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
802 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
803 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
804 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
809 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
810 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200811 {
812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
813 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100814 .info = alc_ch_mode_info,
815 .get = alc_ch_mode_get,
816 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200817 },
818 { } /* end */
819};
820
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200821
822/*
823 * ALC880 W810 model
824 *
825 * W810 has rear IO for:
826 * Front (DAC 02)
827 * Surround (DAC 03)
828 * Center/LFE (DAC 04)
829 * Digital out (06)
830 *
831 * The system also has a pair of internal speakers, and a headphone jack.
832 * These are both connected to Line2 on the codec, hence to DAC 02.
833 *
834 * There is a variable resistor to control the speaker or headphone
835 * volume. This is a hardware-only device without a software API.
836 *
837 * Plugging headphones in will disable the internal speakers. This is
838 * implemented in hardware, not via the driver using jack sense. In
839 * a similar fashion, plugging into the rear socket marked "front" will
840 * disable both the speakers and headphones.
841 *
842 * For input, there's a microphone jack, and an "audio in" jack.
843 * These may not do anything useful with this driver yet, because I
844 * haven't setup any initialization verbs for these yet...
845 */
846
847static hda_nid_t alc880_w810_dac_nids[3] = {
848 /* front, rear/surround, clfe */
849 0x02, 0x03, 0x04
850};
851
852/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100853static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200854 { 6, NULL }
855};
856
857/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100858static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100862 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
868 { } /* end */
869};
870
871
872/*
873 * Z710V model
874 *
875 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200876 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
877 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200878 */
879
880static hda_nid_t alc880_z71v_dac_nids[1] = {
881 0x02
882};
883#define ALC880_Z71V_HP_DAC 0x03
884
885/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100886static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200887 { 2, NULL }
888};
889
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100890static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200893 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100894 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200895 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
899 { } /* end */
900};
901
902
903/* FIXME! */
904/*
905 * ALC880 F1734 model
906 *
907 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
908 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
909 */
910
911static hda_nid_t alc880_f1734_dac_nids[1] = {
912 0x03
913};
914#define ALC880_F1734_HP_DAC 0x02
915
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100916static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100918 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200919 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100920 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200925 { } /* end */
926};
927
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200928
929/* FIXME! */
930/*
931 * ALC880 ASUS model
932 *
933 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
934 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
935 * Mic = 0x18, Line = 0x1a
936 */
937
938#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
939#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
940
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100941static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200942 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100943 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200944 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100945 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200946 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
947 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100948 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
949 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200956 {
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
958 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100959 .info = alc_ch_mode_info,
960 .get = alc_ch_mode_get,
961 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200962 },
963 { } /* end */
964};
965
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200966/* FIXME! */
967/*
968 * ALC880 ASUS W1V model
969 *
970 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
971 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
972 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
973 */
974
975/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100976static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200977 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
978 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200979 { } /* end */
980};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200981
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200982/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100983static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200984 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
985 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
986 { } /* end */
987};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200988
Kailang Yangdf694da2005-12-05 19:42:22 +0100989/* TCL S700 */
990static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
995 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1000 {
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1002 /* The multiple "Capture Source" controls confuse alsamixer
1003 * So call somewhat different..
1004 * FIXME: the controls appear in the "playback" view!
1005 */
1006 /* .name = "Capture Source", */
1007 .name = "Input Source",
1008 .count = 1,
1009 .info = alc_mux_enum_info,
1010 .get = alc_mux_enum_get,
1011 .put = alc_mux_enum_put,
1012 },
1013 { } /* end */
1014};
1015
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001017 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 */
1019static int alc_build_controls(struct hda_codec *codec)
1020{
1021 struct alc_spec *spec = codec->spec;
1022 int err;
1023 int i;
1024
1025 for (i = 0; i < spec->num_mixers; i++) {
1026 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1027 if (err < 0)
1028 return err;
1029 }
1030
1031 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001032 err = snd_hda_create_spdif_out_ctls(codec,
1033 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 if (err < 0)
1035 return err;
1036 }
1037 if (spec->dig_in_nid) {
1038 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1039 if (err < 0)
1040 return err;
1041 }
1042 return 0;
1043}
1044
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001045
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046/*
1047 * initialize the codec volumes, etc
1048 */
1049
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001050/*
1051 * generic initialization of ADC, input mixers and output mixers
1052 */
1053static struct hda_verb alc880_volume_init_verbs[] = {
1054 /*
1055 * Unmute ADC0-2 and set the default input to mic-in
1056 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001064 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1065 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001066 * Note: PASD motherboards uses the Line In 2 as the input for front
1067 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001076 /*
1077 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001079 /* set vol=0 to output mixers */
1080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 /* set up input amps for analog loopback */
1085 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094
1095 { }
1096};
1097
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001098/*
1099 * 3-stack pin configuration:
1100 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1101 */
1102static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1103 /*
1104 * preset connection lists of input pins
1105 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1106 */
1107 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1108 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1109 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1110
1111 /*
1112 * Set pin mode and muting
1113 */
1114 /* set front pin widgets 0x14 for output */
1115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1117 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1120 /* Mic2 (as headphone out) for HP output */
1121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1123 /* Line In pin widget for input */
1124 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1126 /* Line2 (as front mic) pin widget for input and vref at 80% */
1127 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1129 /* CD pin widget for input */
1130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1131
1132 { }
1133};
1134
1135/*
1136 * 5-stack pin configuration:
1137 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1138 * line-in/side = 0x1a, f-mic = 0x1b
1139 */
1140static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1141 /*
1142 * preset connection lists of input pins
1143 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1144 */
1145 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1146 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1147
1148 /*
1149 * Set pin mode and muting
1150 */
1151 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1154 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1155 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156 /* unmute pins for output (no gain on this amp) */
1157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1161
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1165 /* Mic2 (as headphone out) for HP output */
1166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001168 /* Line In pin widget for input */
1169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1171 /* Line2 (as front mic) pin widget for input and vref at 80% */
1172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1174 /* CD pin widget for input */
1175 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176
1177 { }
1178};
1179
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001180/*
1181 * W810 pin configuration:
1182 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1183 */
1184static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 /* hphone/speaker input selector: front DAC */
1186 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1187
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1193 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1194
1195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 { }
1199};
1200
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001201/*
1202 * Z71V pin configuration:
1203 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1204 */
1205static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001210
Takashi Iwai16ded522005-06-10 19:58:24 +02001211 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001214 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001215
1216 { }
1217};
1218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001219/*
1220 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001221 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1222 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001223 */
1224static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1225 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1226
Takashi Iwai16ded522005-06-10 19:58:24 +02001227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001233 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001234 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1235
Takashi Iwai16ded522005-06-10 19:58:24 +02001236 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001237 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001238 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001239 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001244 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001246 { }
1247};
Takashi Iwai16ded522005-06-10 19:58:24 +02001248
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249/* FIXME! */
1250/*
1251 * F1734 pin configuration:
1252 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1253 */
1254static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1255 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1256 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1257 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1258 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1259
1260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1264
1265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001274
1275 { }
1276};
1277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001278/* FIXME! */
1279/*
1280 * ASUS pin configuration:
1281 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1282 */
1283static struct hda_verb alc880_pin_asus_init_verbs[] = {
1284 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1285 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1286 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1287 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1288
1289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1297
1298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1299 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1307
1308 { }
1309};
1310
1311/* Enable GPIO mask and set output */
1312static struct hda_verb alc880_gpio1_init_verbs[] = {
1313 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1314 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1315 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001316
1317 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001318};
1319
1320/* Enable GPIO mask and set output */
1321static struct hda_verb alc880_gpio2_init_verbs[] = {
1322 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1323 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1324 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001325
1326 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001327};
1328
Kailang Yangdf694da2005-12-05 19:42:22 +01001329/* Clevo m520g init */
1330static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1331 /* headphone output */
1332 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1333 /* line-out */
1334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1336 /* Line-in */
1337 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1339 /* CD */
1340 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1341 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1342 /* Mic1 (rear panel) */
1343 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 /* Mic2 (front panel) */
1346 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 /* headphone */
1349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 /* change to EAPD mode */
1352 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1353 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1354
1355 { }
1356};
1357
1358static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001359 /* change to EAPD mode */
1360 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1361 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1362
Kailang Yangdf694da2005-12-05 19:42:22 +01001363 /* Headphone output */
1364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1365 /* Front output*/
1366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1367 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1368
1369 /* Line In pin widget for input */
1370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 /* CD pin widget for input */
1372 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1375
1376 /* change to EAPD mode */
1377 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1378 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1379
1380 { }
1381};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001382
1383/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001384 * LG m1 express dual
1385 *
1386 * Pin assignment:
1387 * Rear Line-In/Out (blue): 0x14
1388 * Build-in Mic-In: 0x15
1389 * Speaker-out: 0x17
1390 * HP-Out (green): 0x1b
1391 * Mic-In/Out (red): 0x19
1392 * SPDIF-Out: 0x1e
1393 */
1394
1395/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1396static hda_nid_t alc880_lg_dac_nids[3] = {
1397 0x05, 0x02, 0x03
1398};
1399
1400/* seems analog CD is not working */
1401static struct hda_input_mux alc880_lg_capture_source = {
1402 .num_items = 3,
1403 .items = {
1404 { "Mic", 0x1 },
1405 { "Line", 0x5 },
1406 { "Internal Mic", 0x6 },
1407 },
1408};
1409
1410/* 2,4,6 channel modes */
1411static struct hda_verb alc880_lg_ch2_init[] = {
1412 /* set line-in and mic-in to input */
1413 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1414 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1415 { }
1416};
1417
1418static struct hda_verb alc880_lg_ch4_init[] = {
1419 /* set line-in to out and mic-in to input */
1420 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1421 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1422 { }
1423};
1424
1425static struct hda_verb alc880_lg_ch6_init[] = {
1426 /* set line-in and mic-in to output */
1427 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1428 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1429 { }
1430};
1431
1432static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1433 { 2, alc880_lg_ch2_init },
1434 { 4, alc880_lg_ch4_init },
1435 { 6, alc880_lg_ch6_init },
1436};
1437
1438static struct snd_kcontrol_new alc880_lg_mixer[] = {
1439 /* FIXME: it's not really "master" but front channels */
1440 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1445 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1447 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1453 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1454 {
1455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1456 .name = "Channel Mode",
1457 .info = alc_ch_mode_info,
1458 .get = alc_ch_mode_get,
1459 .put = alc_ch_mode_put,
1460 },
1461 { } /* end */
1462};
1463
1464static struct hda_verb alc880_lg_init_verbs[] = {
1465 /* set capture source to mic-in */
1466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1469 /* mute all amp mixer inputs */
1470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1473 /* line-in to input */
1474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1476 /* built-in mic */
1477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 /* speaker-out */
1480 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1481 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 /* mic-in to input */
1483 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1484 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1486 /* HP-out */
1487 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1490 /* jack sense */
1491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1492 { }
1493};
1494
1495/* toggle speaker-output according to the hp-jack state */
1496static void alc880_lg_automute(struct hda_codec *codec)
1497{
1498 unsigned int present;
1499
1500 present = snd_hda_codec_read(codec, 0x1b, 0,
1501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1502 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1503 0x80, present ? 0x80 : 0);
1504 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1505 0x80, present ? 0x80 : 0);
1506}
1507
1508static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1509{
1510 /* Looks like the unsol event is incompatible with the standard
1511 * definition. 4bit tag is placed at 28 bit!
1512 */
1513 if ((res >> 28) == 0x01)
1514 alc880_lg_automute(codec);
1515}
1516
1517/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001518 * LG LW20
1519 *
1520 * Pin assignment:
1521 * Speaker-out: 0x14
1522 * Mic-In: 0x18
1523 * Built-in Mic-In: 0x19 (?)
1524 * HP-Out: 0x1b
1525 * SPDIF-Out: 0x1e
1526 */
1527
1528/* seems analog CD is not working */
1529static struct hda_input_mux alc880_lg_lw_capture_source = {
1530 .num_items = 2,
1531 .items = {
1532 { "Mic", 0x0 },
1533 { "Internal Mic", 0x1 },
1534 },
1535};
1536
1537static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1538 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1539 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1540 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1543 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1544 { } /* end */
1545};
1546
1547static struct hda_verb alc880_lg_lw_init_verbs[] = {
1548 /* set capture source to mic-in */
1549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1553 /* speaker-out */
1554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1556 /* HP-out */
1557 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1560 /* mic-in to input */
1561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1563 /* built-in mic */
1564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1566 /* jack sense */
1567 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1568 { }
1569};
1570
1571/* toggle speaker-output according to the hp-jack state */
1572static void alc880_lg_lw_automute(struct hda_codec *codec)
1573{
1574 unsigned int present;
1575
1576 present = snd_hda_codec_read(codec, 0x1b, 0,
1577 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1578 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1579 0x80, present ? 0x80 : 0);
1580 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1581 0x80, present ? 0x80 : 0);
1582}
1583
1584static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1585{
1586 /* Looks like the unsol event is incompatible with the standard
1587 * definition. 4bit tag is placed at 28 bit!
1588 */
1589 if ((res >> 28) == 0x01)
1590 alc880_lg_lw_automute(codec);
1591}
1592
1593/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001594 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001595 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001596
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597static int alc_init(struct hda_codec *codec)
1598{
1599 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001600 unsigned int i;
1601
1602 for (i = 0; i < spec->num_init_verbs; i++)
1603 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001604
1605 if (spec->init_hook)
1606 spec->init_hook(codec);
1607
Linus Torvalds1da177e2005-04-16 15:20:36 -07001608 return 0;
1609}
1610
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001611static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1612{
1613 struct alc_spec *spec = codec->spec;
1614
1615 if (spec->unsol_event)
1616 spec->unsol_event(codec, res);
1617}
1618
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619#ifdef CONFIG_PM
1620/*
1621 * resume
1622 */
1623static int alc_resume(struct hda_codec *codec)
1624{
1625 struct alc_spec *spec = codec->spec;
1626 int i;
1627
1628 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001629 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631 if (spec->multiout.dig_out_nid)
1632 snd_hda_resume_spdif_out(codec);
1633 if (spec->dig_in_nid)
1634 snd_hda_resume_spdif_in(codec);
1635
1636 return 0;
1637}
1638#endif
1639
1640/*
1641 * Analog playback callbacks
1642 */
1643static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1644 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001645 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646{
1647 struct alc_spec *spec = codec->spec;
1648 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1649}
1650
1651static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1652 struct hda_codec *codec,
1653 unsigned int stream_tag,
1654 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001655 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656{
1657 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001658 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1659 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660}
1661
1662static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1663 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001664 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665{
1666 struct alc_spec *spec = codec->spec;
1667 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1668}
1669
1670/*
1671 * Digital out
1672 */
1673static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1674 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001675 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676{
1677 struct alc_spec *spec = codec->spec;
1678 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1679}
1680
1681static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1682 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001683 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684{
1685 struct alc_spec *spec = codec->spec;
1686 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1687}
1688
1689/*
1690 * Analog capture
1691 */
1692static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1693 struct hda_codec *codec,
1694 unsigned int stream_tag,
1695 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001696 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697{
1698 struct alc_spec *spec = codec->spec;
1699
1700 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1701 stream_tag, 0, format);
1702 return 0;
1703}
1704
1705static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1706 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001707 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708{
1709 struct alc_spec *spec = codec->spec;
1710
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001711 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1712 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 return 0;
1714}
1715
1716
1717/*
1718 */
1719static struct hda_pcm_stream alc880_pcm_analog_playback = {
1720 .substreams = 1,
1721 .channels_min = 2,
1722 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001723 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 .ops = {
1725 .open = alc880_playback_pcm_open,
1726 .prepare = alc880_playback_pcm_prepare,
1727 .cleanup = alc880_playback_pcm_cleanup
1728 },
1729};
1730
1731static struct hda_pcm_stream alc880_pcm_analog_capture = {
1732 .substreams = 2,
1733 .channels_min = 2,
1734 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001735 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 .ops = {
1737 .prepare = alc880_capture_pcm_prepare,
1738 .cleanup = alc880_capture_pcm_cleanup
1739 },
1740};
1741
1742static struct hda_pcm_stream alc880_pcm_digital_playback = {
1743 .substreams = 1,
1744 .channels_min = 2,
1745 .channels_max = 2,
1746 /* NID is set in alc_build_pcms */
1747 .ops = {
1748 .open = alc880_dig_playback_pcm_open,
1749 .close = alc880_dig_playback_pcm_close
1750 },
1751};
1752
1753static struct hda_pcm_stream alc880_pcm_digital_capture = {
1754 .substreams = 1,
1755 .channels_min = 2,
1756 .channels_max = 2,
1757 /* NID is set in alc_build_pcms */
1758};
1759
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001760/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1761static struct hda_pcm_stream alc_pcm_null_playback = {
1762 .substreams = 0,
1763 .channels_min = 0,
1764 .channels_max = 0,
1765};
1766
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767static int alc_build_pcms(struct hda_codec *codec)
1768{
1769 struct alc_spec *spec = codec->spec;
1770 struct hda_pcm *info = spec->pcm_rec;
1771 int i;
1772
1773 codec->num_pcms = 1;
1774 codec->pcm_info = info;
1775
1776 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001777 if (spec->stream_analog_playback) {
1778 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1779 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1781 }
1782 if (spec->stream_analog_capture) {
1783 snd_assert(spec->adc_nids, return -EINVAL);
1784 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1785 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1786 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001787
Takashi Iwai4a471b72005-12-07 13:56:29 +01001788 if (spec->channel_mode) {
1789 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1790 for (i = 0; i < spec->num_channel_mode; i++) {
1791 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1792 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1793 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794 }
1795 }
1796
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001797 /* If the use of more than one ADC is requested for the current
1798 * model, configure a second analog capture-only PCM.
1799 */
1800 if (spec->num_adc_nids > 1) {
1801 codec->num_pcms++;
1802 info++;
1803 info->name = spec->stream_name_analog;
1804 /* No playback stream for second PCM */
1805 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1806 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1807 if (spec->stream_analog_capture) {
1808 snd_assert(spec->adc_nids, return -EINVAL);
1809 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1810 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1811 }
1812 }
1813
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1815 codec->num_pcms++;
1816 info++;
1817 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001818 if (spec->multiout.dig_out_nid &&
1819 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1821 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1822 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001823 if (spec->dig_in_nid &&
1824 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1826 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1827 }
1828 }
1829
1830 return 0;
1831}
1832
1833static void alc_free(struct hda_codec *codec)
1834{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835 struct alc_spec *spec = codec->spec;
1836 unsigned int i;
1837
1838 if (! spec)
1839 return;
1840
1841 if (spec->kctl_alloc) {
1842 for (i = 0; i < spec->num_kctl_used; i++)
1843 kfree(spec->kctl_alloc[i].name);
1844 kfree(spec->kctl_alloc);
1845 }
1846 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847}
1848
1849/*
1850 */
1851static struct hda_codec_ops alc_patch_ops = {
1852 .build_controls = alc_build_controls,
1853 .build_pcms = alc_build_pcms,
1854 .init = alc_init,
1855 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001856 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857#ifdef CONFIG_PM
1858 .resume = alc_resume,
1859#endif
1860};
1861
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001862
1863/*
1864 * Test configuration for debugging
1865 *
1866 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1867 * enum controls.
1868 */
1869#ifdef CONFIG_SND_DEBUG
1870static hda_nid_t alc880_test_dac_nids[4] = {
1871 0x02, 0x03, 0x04, 0x05
1872};
1873
1874static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001875 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001876 .items = {
1877 { "In-1", 0x0 },
1878 { "In-2", 0x1 },
1879 { "In-3", 0x2 },
1880 { "In-4", 0x3 },
1881 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001882 { "Front", 0x5 },
1883 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001884 },
1885};
1886
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001887static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001888 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001889 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001890 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001891 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001892};
1893
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001894static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1895 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001896{
1897 static char *texts[] = {
1898 "N/A", "Line Out", "HP Out",
1899 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1900 };
1901 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1902 uinfo->count = 1;
1903 uinfo->value.enumerated.items = 8;
1904 if (uinfo->value.enumerated.item >= 8)
1905 uinfo->value.enumerated.item = 7;
1906 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1907 return 0;
1908}
1909
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001910static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1911 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001912{
1913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1914 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1915 unsigned int pin_ctl, item = 0;
1916
1917 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1918 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1919 if (pin_ctl & AC_PINCTL_OUT_EN) {
1920 if (pin_ctl & AC_PINCTL_HP_EN)
1921 item = 2;
1922 else
1923 item = 1;
1924 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1925 switch (pin_ctl & AC_PINCTL_VREFEN) {
1926 case AC_PINCTL_VREF_HIZ: item = 3; break;
1927 case AC_PINCTL_VREF_50: item = 4; break;
1928 case AC_PINCTL_VREF_GRD: item = 5; break;
1929 case AC_PINCTL_VREF_80: item = 6; break;
1930 case AC_PINCTL_VREF_100: item = 7; break;
1931 }
1932 }
1933 ucontrol->value.enumerated.item[0] = item;
1934 return 0;
1935}
1936
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001937static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001939{
1940 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1941 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1942 static unsigned int ctls[] = {
1943 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1944 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1945 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1949 };
1950 unsigned int old_ctl, new_ctl;
1951
1952 old_ctl = snd_hda_codec_read(codec, nid, 0,
1953 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1954 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1955 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001956 snd_hda_codec_write(codec, nid, 0,
1957 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001958 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001959 (ucontrol->value.enumerated.item[0] >= 3 ?
1960 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001961 return 1;
1962 }
1963 return 0;
1964}
1965
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001966static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001968{
1969 static char *texts[] = {
1970 "Front", "Surround", "CLFE", "Side"
1971 };
1972 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1973 uinfo->count = 1;
1974 uinfo->value.enumerated.items = 4;
1975 if (uinfo->value.enumerated.item >= 4)
1976 uinfo->value.enumerated.item = 3;
1977 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1978 return 0;
1979}
1980
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001981static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001983{
1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1985 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1986 unsigned int sel;
1987
1988 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1989 ucontrol->value.enumerated.item[0] = sel & 3;
1990 return 0;
1991}
1992
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001993static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001995{
1996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1997 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1998 unsigned int sel;
1999
2000 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2001 if (ucontrol->value.enumerated.item[0] != sel) {
2002 sel = ucontrol->value.enumerated.item[0] & 3;
2003 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2004 return 1;
2005 }
2006 return 0;
2007}
2008
2009#define PIN_CTL_TEST(xname,nid) { \
2010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2011 .name = xname, \
2012 .info = alc_test_pin_ctl_info, \
2013 .get = alc_test_pin_ctl_get, \
2014 .put = alc_test_pin_ctl_put, \
2015 .private_value = nid \
2016 }
2017
2018#define PIN_SRC_TEST(xname,nid) { \
2019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2020 .name = xname, \
2021 .info = alc_test_pin_src_info, \
2022 .get = alc_test_pin_src_get, \
2023 .put = alc_test_pin_src_put, \
2024 .private_value = nid \
2025 }
2026
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002027static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2029 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2030 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2031 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002032 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2033 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2034 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2035 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002036 PIN_CTL_TEST("Front Pin Mode", 0x14),
2037 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2038 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2039 PIN_CTL_TEST("Side Pin Mode", 0x17),
2040 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2041 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2042 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2043 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2044 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2045 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2046 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2047 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2048 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2049 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2050 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2051 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2052 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2053 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2054 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2055 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002058 {
2059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2060 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002061 .info = alc_ch_mode_info,
2062 .get = alc_ch_mode_get,
2063 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002064 },
2065 { } /* end */
2066};
2067
2068static struct hda_verb alc880_test_init_verbs[] = {
2069 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002078 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002083 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002088 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002089 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002093 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2098 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002099 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002104 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002106 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002110 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002111 /* Analog input/passthru */
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002117 { }
2118};
2119#endif
2120
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121/*
2122 */
2123
2124static struct hda_board_config alc880_cfg_tbl[] = {
2125 /* Back 3 jack, front 2 jack */
2126 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002127 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002159 /* TCL S700 */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002160 { .modelname = "tcl", .config = ALC880_TCL_S700 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002161 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002162
2163 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002164 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002165 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002166 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167
2168 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2169 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002170 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe32005-08-15 20:01:40 +02002171 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Takashi Iwai5a053d02006-07-25 14:51:15 +02002172
2173 /* Clevo laptops */
2174 { .modelname = "clevo", .config = ALC880_CLEVO },
2175 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2176 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2177 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2178 .config = ALC880_CLEVO }, /* Clevo m665n */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179
2180 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002181 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2183 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184
2185 /* Back 5 jack, front 2 jack */
2186 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002187 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2188 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2189 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2190 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002191 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192
2193 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2194 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002195 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2196 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2197 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2198 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2199 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002203 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002204 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2205 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002206 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002207 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002208 /* note subvendor = 0 below */
2209 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210
2211 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002212 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002214 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002215 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002216
Takashi Iwaib6482d42005-06-27 15:32:43 +02002217 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002218 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002220 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002221 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002222
2223 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002224 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2225 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2226 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2227 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002228 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2229 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002232 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002233 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002234 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Takashi Iwai16ded522005-06-10 19:58:24 +02002235
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002237 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2238 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2239 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2240 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002241 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002247 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
Takashi Iwai16ded522005-06-10 19:58:24 +02002248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002249 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
Takashi Iwai84f34302006-03-21 19:12:53 +01002250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002251 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002252 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002253
2254 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2255 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2256
2257 { .modelname = "F1734", .config = ALC880_F1734 },
2258 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002259 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002260
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002261 { .modelname = "lg", .config = ALC880_LG },
2262 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
Takashi Iwai886da862006-05-02 18:17:57 +02002263 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002264
Takashi Iwaid6815182006-03-23 16:06:23 +01002265 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2266 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2267
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002268#ifdef CONFIG_SND_DEBUG
2269 { .modelname = "test", .config = ALC880_TEST },
2270#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002271 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002272
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 {}
2274};
2275
Takashi Iwai16ded522005-06-10 19:58:24 +02002276/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002277 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002278 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002279static struct alc_config_preset alc880_presets[] = {
2280 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002281 .mixers = { alc880_three_stack_mixer },
2282 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2286 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002287 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 .input_mux = &alc880_capture_source,
2289 },
2290 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291 .mixers = { alc880_three_stack_mixer },
2292 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002293 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002294 .dac_nids = alc880_dac_nids,
2295 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002296 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2297 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002298 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002299 .input_mux = &alc880_capture_source,
2300 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002301 [ALC880_TCL_S700] = {
2302 .mixers = { alc880_tcl_s700_mixer },
2303 .init_verbs = { alc880_volume_init_verbs,
2304 alc880_pin_tcl_S700_init_verbs,
2305 alc880_gpio2_init_verbs },
2306 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2307 .dac_nids = alc880_dac_nids,
2308 .hp_nid = 0x03,
2309 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2310 .channel_mode = alc880_2_jack_modes,
2311 .input_mux = &alc880_capture_source,
2312 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002313 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002314 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2315 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002316 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2317 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002318 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2319 .channel_mode = alc880_fivestack_modes,
2320 .input_mux = &alc880_capture_source,
2321 },
2322 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2324 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002325 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2326 .dac_nids = alc880_dac_nids,
2327 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002328 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2329 .channel_mode = alc880_fivestack_modes,
2330 .input_mux = &alc880_capture_source,
2331 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002332 [ALC880_6ST] = {
2333 .mixers = { alc880_six_stack_mixer },
2334 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2335 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2336 .dac_nids = alc880_6st_dac_nids,
2337 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2338 .channel_mode = alc880_sixstack_modes,
2339 .input_mux = &alc880_6stack_capture_source,
2340 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002341 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002342 .mixers = { alc880_six_stack_mixer },
2343 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002344 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2345 .dac_nids = alc880_6st_dac_nids,
2346 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002347 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2348 .channel_mode = alc880_sixstack_modes,
2349 .input_mux = &alc880_6stack_capture_source,
2350 },
2351 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002353 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2354 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002355 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2356 .dac_nids = alc880_w810_dac_nids,
2357 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002358 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2359 .channel_mode = alc880_w810_modes,
2360 .input_mux = &alc880_capture_source,
2361 },
2362 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002363 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002364 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002365 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2366 .dac_nids = alc880_z71v_dac_nids,
2367 .dig_out_nid = ALC880_DIGOUT_NID,
2368 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002369 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2370 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002371 .input_mux = &alc880_capture_source,
2372 },
2373 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374 .mixers = { alc880_f1734_mixer },
2375 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2376 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2377 .dac_nids = alc880_f1734_dac_nids,
2378 .hp_nid = 0x02,
2379 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2380 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002381 .input_mux = &alc880_capture_source,
2382 },
2383 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002384 .mixers = { alc880_asus_mixer },
2385 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2386 alc880_gpio1_init_verbs },
2387 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2388 .dac_nids = alc880_asus_dac_nids,
2389 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2390 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002391 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002392 .input_mux = &alc880_capture_source,
2393 },
2394 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002395 .mixers = { alc880_asus_mixer },
2396 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2397 alc880_gpio1_init_verbs },
2398 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2399 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002400 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002401 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2402 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002403 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002404 .input_mux = &alc880_capture_source,
2405 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002406 [ALC880_ASUS_DIG2] = {
2407 .mixers = { alc880_asus_mixer },
2408 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2409 alc880_gpio2_init_verbs }, /* use GPIO2 */
2410 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2411 .dac_nids = alc880_asus_dac_nids,
2412 .dig_out_nid = ALC880_DIGOUT_NID,
2413 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2414 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002415 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002416 .input_mux = &alc880_capture_source,
2417 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002418 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002419 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2420 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2421 alc880_gpio1_init_verbs },
2422 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2423 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002424 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002425 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2426 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002427 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002428 .input_mux = &alc880_capture_source,
2429 },
2430 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002431 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002432 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2433 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2434 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002435 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002436 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2437 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002438 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002439 .input_mux = &alc880_capture_source,
2440 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002441 [ALC880_CLEVO] = {
2442 .mixers = { alc880_three_stack_mixer },
2443 .init_verbs = { alc880_volume_init_verbs,
2444 alc880_pin_clevo_init_verbs },
2445 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2446 .dac_nids = alc880_dac_nids,
2447 .hp_nid = 0x03,
2448 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2449 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002450 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002451 .input_mux = &alc880_capture_source,
2452 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002453 [ALC880_LG] = {
2454 .mixers = { alc880_lg_mixer },
2455 .init_verbs = { alc880_volume_init_verbs,
2456 alc880_lg_init_verbs },
2457 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2458 .dac_nids = alc880_lg_dac_nids,
2459 .dig_out_nid = ALC880_DIGOUT_NID,
2460 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2461 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002462 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002463 .input_mux = &alc880_lg_capture_source,
2464 .unsol_event = alc880_lg_unsol_event,
2465 .init_hook = alc880_lg_automute,
2466 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002467 [ALC880_LG_LW] = {
2468 .mixers = { alc880_lg_lw_mixer },
2469 .init_verbs = { alc880_volume_init_verbs,
2470 alc880_lg_lw_init_verbs },
2471 .num_dacs = 1,
2472 .dac_nids = alc880_dac_nids,
2473 .dig_out_nid = ALC880_DIGOUT_NID,
2474 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2475 .channel_mode = alc880_2_jack_modes,
2476 .input_mux = &alc880_lg_lw_capture_source,
2477 .unsol_event = alc880_lg_lw_unsol_event,
2478 .init_hook = alc880_lg_lw_automute,
2479 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002480#ifdef CONFIG_SND_DEBUG
2481 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002482 .mixers = { alc880_test_mixer },
2483 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002484 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2485 .dac_nids = alc880_test_dac_nids,
2486 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002487 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2488 .channel_mode = alc880_test_modes,
2489 .input_mux = &alc880_test_capture_source,
2490 },
2491#endif
2492};
2493
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494/*
2495 * Automatic parse of I/O pins from the BIOS configuration
2496 */
2497
2498#define NUM_CONTROL_ALLOC 32
2499#define NUM_VERB_ALLOC 32
2500
2501enum {
2502 ALC_CTL_WIDGET_VOL,
2503 ALC_CTL_WIDGET_MUTE,
2504 ALC_CTL_BIND_MUTE,
2505};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002506static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002507 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2508 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002509 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510};
2511
2512/* add dynamic controls */
2513static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2514{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002515 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002516
2517 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2518 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2519
2520 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2521 if (! knew)
2522 return -ENOMEM;
2523 if (spec->kctl_alloc) {
2524 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2525 kfree(spec->kctl_alloc);
2526 }
2527 spec->kctl_alloc = knew;
2528 spec->num_kctl_alloc = num;
2529 }
2530
2531 knew = &spec->kctl_alloc[spec->num_kctl_used];
2532 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002533 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002534 if (! knew->name)
2535 return -ENOMEM;
2536 knew->private_value = val;
2537 spec->num_kctl_used++;
2538 return 0;
2539}
2540
2541#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2542#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2543#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2544#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2545#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2546#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2547#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2548#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2549#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2550#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2551#define ALC880_PIN_CD_NID 0x1c
2552
2553/* fill in the dac_nids table from the parsed pin configuration */
2554static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2555{
2556 hda_nid_t nid;
2557 int assigned[4];
2558 int i, j;
2559
2560 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002561 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002562
2563 /* check the pins hardwired to audio widget */
2564 for (i = 0; i < cfg->line_outs; i++) {
2565 nid = cfg->line_out_pins[i];
2566 if (alc880_is_fixed_pin(nid)) {
2567 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002568 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 assigned[idx] = 1;
2570 }
2571 }
2572 /* left pins can be connect to any audio widget */
2573 for (i = 0; i < cfg->line_outs; i++) {
2574 nid = cfg->line_out_pins[i];
2575 if (alc880_is_fixed_pin(nid))
2576 continue;
2577 /* search for an empty channel */
2578 for (j = 0; j < cfg->line_outs; j++) {
2579 if (! assigned[j]) {
2580 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2581 assigned[j] = 1;
2582 break;
2583 }
2584 }
2585 }
2586 spec->multiout.num_dacs = cfg->line_outs;
2587 return 0;
2588}
2589
2590/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002591static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2592 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002593{
2594 char name[32];
2595 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2596 hda_nid_t nid;
2597 int i, err;
2598
2599 for (i = 0; i < cfg->line_outs; i++) {
2600 if (! spec->multiout.dac_nids[i])
2601 continue;
2602 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2603 if (i == 2) {
2604 /* Center/LFE */
2605 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2606 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2607 return err;
2608 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2609 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2610 return err;
2611 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2612 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2613 return err;
2614 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2615 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2616 return err;
2617 } else {
2618 sprintf(name, "%s Playback Volume", chname[i]);
2619 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2620 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2621 return err;
2622 sprintf(name, "%s Playback Switch", chname[i]);
2623 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2624 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2625 return err;
2626 }
2627 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002628 return 0;
2629}
2630
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002631/* add playback controls for speaker and HP outputs */
2632static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2633 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634{
2635 hda_nid_t nid;
2636 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002637 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638
2639 if (! pin)
2640 return 0;
2641
2642 if (alc880_is_fixed_pin(pin)) {
2643 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002644 /* specify the DAC as the extra output */
2645 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002646 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002647 else
2648 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649 /* control HP volume/switch on the output mixer amp */
2650 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002651 sprintf(name, "%s Playback Volume", pfx);
2652 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002653 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2654 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002655 sprintf(name, "%s Playback Switch", pfx);
2656 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2658 return err;
2659 } else if (alc880_is_multi_pin(pin)) {
2660 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002662 sprintf(name, "%s Playback Switch", pfx);
2663 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2665 return err;
2666 }
2667 return 0;
2668}
2669
2670/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002671static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2672 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673{
2674 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002675 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676
2677 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002679 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 return err;
2681 sprintf(name, "%s Playback Switch", ctlname);
2682 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002683 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 return err;
2685 return 0;
2686}
2687
2688/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002689static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2690 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002692 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002693 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694
2695 for (i = 0; i < AUTO_PIN_LAST; i++) {
2696 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002697 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002698 err = new_analog_input(spec, cfg->input_pins[i],
2699 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002700 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701 if (err < 0)
2702 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002703 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2705 imux->num_items++;
2706 }
2707 }
2708 return 0;
2709}
2710
Kailang Yangdf694da2005-12-05 19:42:22 +01002711static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2712 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713 int dac_idx)
2714{
2715 /* set as output */
2716 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2717 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2718 /* need the manual connection? */
2719 if (alc880_is_multi_pin(nid)) {
2720 struct alc_spec *spec = codec->spec;
2721 int idx = alc880_multi_pin_idx(nid);
2722 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2723 AC_VERB_SET_CONNECT_SEL,
2724 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2725 }
2726}
2727
2728static void alc880_auto_init_multi_out(struct hda_codec *codec)
2729{
2730 struct alc_spec *spec = codec->spec;
2731 int i;
2732
2733 for (i = 0; i < spec->autocfg.line_outs; i++) {
2734 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2735 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2736 }
2737}
2738
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002739static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002740{
2741 struct alc_spec *spec = codec->spec;
2742 hda_nid_t pin;
2743
Takashi Iwai82bc9552006-03-21 11:24:42 +01002744 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002745 if (pin) /* connect to front */
2746 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 pin = spec->autocfg.hp_pin;
2748 if (pin) /* connect to front */
2749 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2750}
2751
2752static void alc880_auto_init_analog_input(struct hda_codec *codec)
2753{
2754 struct alc_spec *spec = codec->spec;
2755 int i;
2756
2757 for (i = 0; i < AUTO_PIN_LAST; i++) {
2758 hda_nid_t nid = spec->autocfg.input_pins[i];
2759 if (alc880_is_input_pin(nid)) {
2760 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2761 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2762 if (nid != ALC880_PIN_CD_NID)
2763 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2764 AMP_OUT_MUTE);
2765 }
2766 }
2767}
2768
2769/* parse the BIOS configuration and set up the alc_spec */
2770/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2771static int alc880_parse_auto_config(struct hda_codec *codec)
2772{
2773 struct alc_spec *spec = codec->spec;
2774 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002775 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776
Kailang Yangdf694da2005-12-05 19:42:22 +01002777 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2778 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002780 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002782
2783 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2784 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002785 (err = alc880_auto_create_extra_out(spec,
2786 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002787 "Speaker")) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002788 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002789 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002790 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2791 return err;
2792
2793 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2794
2795 if (spec->autocfg.dig_out_pin)
2796 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2797 if (spec->autocfg.dig_in_pin)
2798 spec->dig_in_nid = ALC880_DIGIN_NID;
2799
2800 if (spec->kctl_alloc)
2801 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2802
2803 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2804
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002805 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002806 spec->input_mux = &spec->private_imux;
2807
2808 return 1;
2809}
2810
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002811/* additional initialization for auto-configuration model */
2812static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002813{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002814 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002815 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002816 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002817}
2818
2819/*
2820 * OK, here we have finally the patch for ALC880
2821 */
2822
Linus Torvalds1da177e2005-04-16 15:20:36 -07002823static int patch_alc880(struct hda_codec *codec)
2824{
2825 struct alc_spec *spec;
2826 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002827 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002829 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002830 if (spec == NULL)
2831 return -ENOMEM;
2832
2833 codec->spec = spec;
2834
2835 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002836 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002837 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2838 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 }
2841
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002842 if (board_config == ALC880_AUTO) {
2843 /* automatic parse from the BIOS config */
2844 err = alc880_parse_auto_config(codec);
2845 if (err < 0) {
2846 alc_free(codec);
2847 return err;
2848 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002849 printk(KERN_INFO
2850 "hda_codec: Cannot set up configuration "
2851 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852 board_config = ALC880_3ST;
2853 }
2854 }
2855
Kailang Yangdf694da2005-12-05 19:42:22 +01002856 if (board_config != ALC880_AUTO)
2857 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002858
2859 spec->stream_name_analog = "ALC880 Analog";
2860 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2861 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2862
2863 spec->stream_name_digital = "ALC880 Digital";
2864 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2865 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2866
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002867 if (! spec->adc_nids && spec->input_mux) {
2868 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002869 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002870 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2871 if (wcap != AC_WID_AUD_IN) {
2872 spec->adc_nids = alc880_adc_nids_alt;
2873 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2874 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2875 spec->num_mixers++;
2876 } else {
2877 spec->adc_nids = alc880_adc_nids;
2878 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2879 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2880 spec->num_mixers++;
2881 }
2882 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002883
2884 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002885 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002886 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887
2888 return 0;
2889}
2890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892/*
2893 * ALC260 support
2894 */
2895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002896static hda_nid_t alc260_dac_nids[1] = {
2897 /* front */
2898 0x02,
2899};
2900
2901static hda_nid_t alc260_adc_nids[1] = {
2902 /* ADC0 */
2903 0x04,
2904};
2905
Kailang Yangdf694da2005-12-05 19:42:22 +01002906static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002907 /* ADC1 */
2908 0x05,
2909};
2910
Kailang Yangdf694da2005-12-05 19:42:22 +01002911static hda_nid_t alc260_hp_adc_nids[2] = {
2912 /* ADC1, 0 */
2913 0x05, 0x04
2914};
2915
Jonathan Woithed57fdac2006-02-28 11:38:35 +01002916/* NIDs used when simultaneous access to both ADCs makes sense. Note that
2917 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2918 */
2919static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002920 /* ADC0, ADC1 */
2921 0x04, 0x05
2922};
2923
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002924#define ALC260_DIGOUT_NID 0x03
2925#define ALC260_DIGIN_NID 0x06
2926
2927static struct hda_input_mux alc260_capture_source = {
2928 .num_items = 4,
2929 .items = {
2930 { "Mic", 0x0 },
2931 { "Front Mic", 0x1 },
2932 { "Line", 0x2 },
2933 { "CD", 0x4 },
2934 },
2935};
2936
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01002937/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002938 * headphone jack and the internal CD lines since these are the only pins at
2939 * which audio can appear. For flexibility, also allow the option of
2940 * recording the mixer output on the second ADC (ADC0 doesn't have a
2941 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002942 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002943static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2944 {
2945 .num_items = 3,
2946 .items = {
2947 { "Mic/Line", 0x0 },
2948 { "CD", 0x4 },
2949 { "Headphone", 0x2 },
2950 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002951 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002952 {
2953 .num_items = 4,
2954 .items = {
2955 { "Mic/Line", 0x0 },
2956 { "CD", 0x4 },
2957 { "Headphone", 0x2 },
2958 { "Mixer", 0x5 },
2959 },
2960 },
2961
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002962};
2963
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002964/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2965 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002966 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002967static struct hda_input_mux alc260_acer_capture_sources[2] = {
2968 {
2969 .num_items = 4,
2970 .items = {
2971 { "Mic", 0x0 },
2972 { "Line", 0x2 },
2973 { "CD", 0x4 },
2974 { "Headphone", 0x5 },
2975 },
2976 },
2977 {
2978 .num_items = 5,
2979 .items = {
2980 { "Mic", 0x0 },
2981 { "Line", 0x2 },
2982 { "CD", 0x4 },
2983 { "Headphone", 0x6 },
2984 { "Mixer", 0x5 },
2985 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002986 },
2987};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002988/*
2989 * This is just place-holder, so there's something for alc_build_pcms to look
2990 * at when it calculates the maximum number of channels. ALC260 has no mixer
2991 * element which allows changing the channel mode, so the verb list is
2992 * never used.
2993 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002994static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002995 { 2, NULL },
2996};
2997
Kailang Yangdf694da2005-12-05 19:42:22 +01002998
2999/* Mixer combinations
3000 *
3001 * basic: base_output + input + pc_beep + capture
3002 * HP: base_output + input + capture_alt
3003 * HP_3013: hp_3013 + input + capture
3004 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003005 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003006 */
3007
3008static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003009 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003010 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3012 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3013 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3014 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3015 { } /* end */
3016};
3017
3018static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3020 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3021 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3022 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3024 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3026 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003027 { } /* end */
3028};
3029
Kailang Yangdf694da2005-12-05 19:42:22 +01003030static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3031 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3032 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3033 { } /* end */
3034};
3035
3036static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3037 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3038 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3039 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3040 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3043 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003045 { } /* end */
3046};
3047
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003048/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3049 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3050 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003051static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003053 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003054 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003055 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3056 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3057 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3058 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003059 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003060 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3061 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3062 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003063 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003064 { } /* end */
3065};
3066
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003067/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3068 * versions of the ALC260 don't act on requests to enable mic bias from NID
3069 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3070 * datasheet doesn't mention this restriction. At this stage it's not clear
3071 * whether this behaviour is intentional or is a hardware bug in chip
3072 * revisions available in early 2006. Therefore for now allow the
3073 * "Headphone Jack Mode" control to span all choices, but if it turns out
3074 * that the lack of mic bias for this NID is intentional we could change the
3075 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3076 *
3077 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3078 * don't appear to make the mic bias available from the "line" jack, even
3079 * though the NID used for this jack (0x14) can supply it. The theory is
3080 * that perhaps Acer have included blocking capacitors between the ALC260
3081 * and the output jack. If this turns out to be the case for all such
3082 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3083 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3084 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003085static struct snd_kcontrol_new alc260_acer_mixer[] = {
3086 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3087 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003088 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003089 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3090 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3092 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3093 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3094 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3095 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3096 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3097 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3098 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3099 { } /* end */
3100};
3101
Kailang Yangdf694da2005-12-05 19:42:22 +01003102/* capture mixer elements */
3103static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003104 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3105 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003106 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3107 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003108 {
3109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003110 /* The multiple "Capture Source" controls confuse alsamixer
3111 * So call somewhat different..
3112 * FIXME: the controls appear in the "playback" view!
3113 */
3114 /* .name = "Capture Source", */
3115 .name = "Input Source",
3116 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003117 .info = alc_mux_enum_info,
3118 .get = alc_mux_enum_get,
3119 .put = alc_mux_enum_put,
3120 },
3121 { } /* end */
3122};
3123
Kailang Yangdf694da2005-12-05 19:42:22 +01003124static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3125 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3126 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3127 {
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 /* The multiple "Capture Source" controls confuse alsamixer
3130 * So call somewhat different..
3131 * FIXME: the controls appear in the "playback" view!
3132 */
3133 /* .name = "Capture Source", */
3134 .name = "Input Source",
3135 .count = 1,
3136 .info = alc_mux_enum_info,
3137 .get = alc_mux_enum_get,
3138 .put = alc_mux_enum_put,
3139 },
3140 { } /* end */
3141};
3142
3143/*
3144 * initialization verbs
3145 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003146static struct hda_verb alc260_init_verbs[] = {
3147 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003149 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003150 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003151 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003152 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003153 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003154 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003155 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003158 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003159 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003160 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003161 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003162 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003163 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003164 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3165 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003166 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167 /* set connection select to line in (default select for this ADC) */
3168 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003169 /* mute capture amp left and right */
3170 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3171 /* set connection select to line in (default select for this ADC) */
3172 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003173 /* set vol=0 Line-Out mixer amp left and right */
3174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3175 /* unmute pin widget amp left and right (no gain on this amp) */
3176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177 /* set vol=0 HP mixer amp left and right */
3178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3179 /* unmute pin widget amp left and right (no gain on this amp) */
3180 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3181 /* set vol=0 Mono mixer amp left and right */
3182 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3183 /* unmute pin widget amp left and right (no gain on this amp) */
3184 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 /* unmute LINE-2 out pin */
3186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003187 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003188 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003190 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003192 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003194 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003195 /* mute Front out path */
3196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3198 /* mute Headphone out path */
3199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3201 /* mute Mono out path */
3202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3203 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204 { }
3205};
3206
Takashi Iwai474167d2006-05-17 17:17:43 +02003207#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003208static struct hda_verb alc260_hp_init_verbs[] = {
3209 /* Headphone and output */
3210 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3211 /* mono output */
3212 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3213 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3214 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3215 /* Mic2 (front panel) pin widget for input and vref at 80% */
3216 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3217 /* Line In pin widget for input */
3218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3219 /* Line-2 pin widget for output */
3220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3221 /* CD pin widget for input */
3222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3223 /* unmute amp left and right */
3224 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3225 /* set connection select to line in (default select for this ADC) */
3226 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3227 /* unmute Line-Out mixer amp left and right (volume = 0) */
3228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3229 /* mute pin widget amp left and right (no gain on this amp) */
3230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3231 /* unmute HP mixer amp left and right (volume = 0) */
3232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3233 /* mute pin widget amp left and right (no gain on this amp) */
3234 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3235 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3236 /* unmute CD */
3237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3238 /* unmute Line In */
3239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3240 /* unmute Mic */
3241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3242 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3243 /* Unmute Front out path */
3244 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3246 /* Unmute Headphone out path */
3247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3249 /* Unmute Mono out path */
3250 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3251 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3252 { }
3253};
Takashi Iwai474167d2006-05-17 17:17:43 +02003254#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003255
3256static struct hda_verb alc260_hp_3013_init_verbs[] = {
3257 /* Line out and output */
3258 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3259 /* mono output */
3260 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3261 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3262 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3263 /* Mic2 (front panel) pin widget for input and vref at 80% */
3264 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3265 /* Line In pin widget for input */
3266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3267 /* Headphone pin widget for output */
3268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3269 /* CD pin widget for input */
3270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3271 /* unmute amp left and right */
3272 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3273 /* set connection select to line in (default select for this ADC) */
3274 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3275 /* unmute Line-Out mixer amp left and right (volume = 0) */
3276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3277 /* mute pin widget amp left and right (no gain on this amp) */
3278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3279 /* unmute HP mixer amp left and right (volume = 0) */
3280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3281 /* mute pin widget amp left and right (no gain on this amp) */
3282 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3283 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3284 /* unmute CD */
3285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3286 /* unmute Line In */
3287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3288 /* unmute Mic */
3289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3290 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3291 /* Unmute Front out path */
3292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3294 /* Unmute Headphone out path */
3295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3297 /* Unmute Mono out path */
3298 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300 { }
3301};
3302
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003303/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003304 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3305 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003306 */
3307static struct hda_verb alc260_fujitsu_init_verbs[] = {
3308 /* Disable all GPIOs */
3309 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3310 /* Internal speaker is connected to headphone pin */
3311 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3312 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003314 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3315 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3316 /* Ensure all other unused pins are disabled and muted. */
3317 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003319 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003320 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003321 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003322 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003325
Jonathan Woithef7ace402006-02-28 11:46:14 +01003326 /* Disable digital (SPDIF) pins */
3327 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3328 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003329
Jonathan Woithef7ace402006-02-28 11:46:14 +01003330 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3331 * when acting as an output.
3332 */
3333 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3334
3335 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003345
Jonathan Woithef7ace402006-02-28 11:46:14 +01003346 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3347 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3348 /* Unmute Line1 pin widget output buffer since it starts as an output.
3349 * If the pin mode is changed by the user the pin mode control will
3350 * take care of enabling the pin's input/output buffers as needed.
3351 * Therefore there's no need to enable the input buffer at this
3352 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003353 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003355 /* Unmute input buffer of pin widget used for Line-in (no equiv
3356 * mixer ctrl)
3357 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003358 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003359
Jonathan Woithef7ace402006-02-28 11:46:14 +01003360 /* Mute capture amp left and right */
3361 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3362 /* Set ADC connection select to match default mixer setting - line
3363 * in (on mic1 pin)
3364 */
3365 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003366
Jonathan Woithef7ace402006-02-28 11:46:14 +01003367 /* Do the same for the second ADC: mute capture input amp and
3368 * set ADC connection to line in (on mic1 pin)
3369 */
3370 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3371 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003372
Jonathan Woithef7ace402006-02-28 11:46:14 +01003373 /* Mute all inputs to mixer widget (even unconnected ones) */
3374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003382
3383 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003384};
3385
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003386/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3387 * similar laptops (adapted from Fujitsu init verbs).
3388 */
3389static struct hda_verb alc260_acer_init_verbs[] = {
3390 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3391 * the headphone jack. Turn this on and rely on the standard mute
3392 * methods whenever the user wants to turn these outputs off.
3393 */
3394 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3395 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3396 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3397 /* Internal speaker/Headphone jack is connected to Line-out pin */
3398 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3399 /* Internal microphone/Mic jack is connected to Mic1 pin */
3400 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3401 /* Line In jack is connected to Line1 pin */
3402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3403 /* Ensure all other unused pins are disabled and muted. */
3404 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3405 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3406 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3407 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3408 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3409 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3410 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3412 /* Disable digital (SPDIF) pins */
3413 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3414 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3415
3416 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3417 * bus when acting as outputs.
3418 */
3419 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3420 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3421
3422 /* Start with output sum widgets muted and their output gains at min */
3423 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3429 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3430 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3432
3433 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3435 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3436 * inputs. If the pin mode is changed by the user the pin mode control
3437 * will take care of enabling the pin's input/output buffers as needed.
3438 * Therefore there's no need to enable the input buffer at this
3439 * stage.
3440 */
3441 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3443
3444 /* Mute capture amp left and right */
3445 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3446 /* Set ADC connection select to match default mixer setting - mic
3447 * (on mic1 pin)
3448 */
3449 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3450
3451 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003452 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003453 */
3454 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003455 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003456
3457 /* Mute all inputs to mixer widget (even unconnected ones) */
3458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3466
3467 { }
3468};
3469
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003470/* Test configuration for debugging, modelled after the ALC880 test
3471 * configuration.
3472 */
3473#ifdef CONFIG_SND_DEBUG
3474static hda_nid_t alc260_test_dac_nids[1] = {
3475 0x02,
3476};
3477static hda_nid_t alc260_test_adc_nids[2] = {
3478 0x04, 0x05,
3479};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003480/* For testing the ALC260, each input MUX needs its own definition since
3481 * the signal assignments are different. This assumes that the first ADC
3482 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003483 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003484static struct hda_input_mux alc260_test_capture_sources[2] = {
3485 {
3486 .num_items = 7,
3487 .items = {
3488 { "MIC1 pin", 0x0 },
3489 { "MIC2 pin", 0x1 },
3490 { "LINE1 pin", 0x2 },
3491 { "LINE2 pin", 0x3 },
3492 { "CD pin", 0x4 },
3493 { "LINE-OUT pin", 0x5 },
3494 { "HP-OUT pin", 0x6 },
3495 },
3496 },
3497 {
3498 .num_items = 8,
3499 .items = {
3500 { "MIC1 pin", 0x0 },
3501 { "MIC2 pin", 0x1 },
3502 { "LINE1 pin", 0x2 },
3503 { "LINE2 pin", 0x3 },
3504 { "CD pin", 0x4 },
3505 { "Mixer", 0x5 },
3506 { "LINE-OUT pin", 0x6 },
3507 { "HP-OUT pin", 0x7 },
3508 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003509 },
3510};
3511static struct snd_kcontrol_new alc260_test_mixer[] = {
3512 /* Output driver widgets */
3513 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3514 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3515 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3516 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3517 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3518 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3519
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003520 /* Modes for retasking pin widgets
3521 * Note: the ALC260 doesn't seem to act on requests to enable mic
3522 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3523 * mention this restriction. At this stage it's not clear whether
3524 * this behaviour is intentional or is a hardware bug in chip
3525 * revisions available at least up until early 2006. Therefore for
3526 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3527 * choices, but if it turns out that the lack of mic bias for these
3528 * NIDs is intentional we could change their modes from
3529 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3530 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003531 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3532 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3533 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3534 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3535 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3536 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3537
3538 /* Loopback mixer controls */
3539 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3540 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3541 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3542 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3543 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3544 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3545 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3546 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3547 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3548 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3549 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3550 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3551 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3552 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3553 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3554 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003555
3556 /* Controls for GPIO pins, assuming they are configured as outputs */
3557 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3558 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3559 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3560 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3561
Jonathan Woithe92621f12006-02-28 11:47:47 +01003562 /* Switches to allow the digital IO pins to be enabled. The datasheet
3563 * is ambigious as to which NID is which; testing on laptops which
3564 * make this output available should provide clarification.
3565 */
3566 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3567 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3568
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003569 { } /* end */
3570};
3571static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003572 /* Enable all GPIOs as outputs with an initial value of 0 */
3573 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3574 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3575 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3576
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003577 /* Enable retasking pins as output, initially without power amp */
3578 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3579 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3583 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3584
Jonathan Woithe92621f12006-02-28 11:47:47 +01003585 /* Disable digital (SPDIF) pins initially, but users can enable
3586 * them via a mixer switch. In the case of SPDIF-out, this initverb
3587 * payload also sets the generation to 0, output to be in "consumer"
3588 * PCM format, copyright asserted, no pre-emphasis and no validity
3589 * control.
3590 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003591 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3592 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3593
Jonathan Woithef7ace402006-02-28 11:46:14 +01003594 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003595 * OUT1 sum bus when acting as an output.
3596 */
3597 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3598 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3599 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3600 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3601
3602 /* Start with output sum widgets muted and their output gains at min */
3603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3609 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3612
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003613 /* Unmute retasking pin widget output buffers since the default
3614 * state appears to be output. As the pin mode is changed by the
3615 * user the pin mode control will take care of enabling the pin's
3616 * input/output buffers as needed.
3617 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003618 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3619 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3623 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 /* Also unmute the mono-out pin widget */
3625 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3626
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003627 /* Mute capture amp left and right */
3628 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003629 /* Set ADC connection select to match default mixer setting (mic1
3630 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003631 */
3632 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3633
3634 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003635 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003636 */
3637 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3638 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3639
3640 /* Mute all inputs to mixer widget (even unconnected ones) */
3641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3649
3650 { }
3651};
3652#endif
3653
Linus Torvalds1da177e2005-04-16 15:20:36 -07003654static struct hda_pcm_stream alc260_pcm_analog_playback = {
3655 .substreams = 1,
3656 .channels_min = 2,
3657 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003658};
3659
3660static struct hda_pcm_stream alc260_pcm_analog_capture = {
3661 .substreams = 1,
3662 .channels_min = 2,
3663 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664};
3665
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003666#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3667#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3668
Kailang Yangdf694da2005-12-05 19:42:22 +01003669/*
3670 * for BIOS auto-configuration
3671 */
3672
3673static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3674 const char *pfx)
3675{
3676 hda_nid_t nid_vol;
3677 unsigned long vol_val, sw_val;
3678 char name[32];
3679 int err;
3680
3681 if (nid >= 0x0f && nid < 0x11) {
3682 nid_vol = nid - 0x7;
3683 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3684 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3685 } else if (nid == 0x11) {
3686 nid_vol = nid - 0x7;
3687 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3688 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3689 } else if (nid >= 0x12 && nid <= 0x15) {
3690 nid_vol = 0x08;
3691 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3692 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3693 } else
3694 return 0; /* N/A */
3695
3696 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3697 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3698 return err;
3699 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3700 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3701 return err;
3702 return 1;
3703}
3704
3705/* add playback controls from the parsed DAC table */
3706static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3707 const struct auto_pin_cfg *cfg)
3708{
3709 hda_nid_t nid;
3710 int err;
3711
3712 spec->multiout.num_dacs = 1;
3713 spec->multiout.dac_nids = spec->private_dac_nids;
3714 spec->multiout.dac_nids[0] = 0x02;
3715
3716 nid = cfg->line_out_pins[0];
3717 if (nid) {
3718 err = alc260_add_playback_controls(spec, nid, "Front");
3719 if (err < 0)
3720 return err;
3721 }
3722
Takashi Iwai82bc9552006-03-21 11:24:42 +01003723 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003724 if (nid) {
3725 err = alc260_add_playback_controls(spec, nid, "Speaker");
3726 if (err < 0)
3727 return err;
3728 }
3729
3730 nid = cfg->hp_pin;
3731 if (nid) {
3732 err = alc260_add_playback_controls(spec, nid, "Headphone");
3733 if (err < 0)
3734 return err;
3735 }
3736 return 0;
3737}
3738
3739/* create playback/capture controls for input pins */
3740static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3741 const struct auto_pin_cfg *cfg)
3742{
Kailang Yangdf694da2005-12-05 19:42:22 +01003743 struct hda_input_mux *imux = &spec->private_imux;
3744 int i, err, idx;
3745
3746 for (i = 0; i < AUTO_PIN_LAST; i++) {
3747 if (cfg->input_pins[i] >= 0x12) {
3748 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003749 err = new_analog_input(spec, cfg->input_pins[i],
3750 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003751 if (err < 0)
3752 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003753 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003754 imux->items[imux->num_items].index = idx;
3755 imux->num_items++;
3756 }
3757 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3758 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003759 err = new_analog_input(spec, cfg->input_pins[i],
3760 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003761 if (err < 0)
3762 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003763 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003764 imux->items[imux->num_items].index = idx;
3765 imux->num_items++;
3766 }
3767 }
3768 return 0;
3769}
3770
3771static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3772 hda_nid_t nid, int pin_type,
3773 int sel_idx)
3774{
3775 /* set as output */
3776 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3777 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3778 /* need the manual connection? */
3779 if (nid >= 0x12) {
3780 int idx = nid - 0x12;
3781 snd_hda_codec_write(codec, idx + 0x0b, 0,
3782 AC_VERB_SET_CONNECT_SEL, sel_idx);
3783
3784 }
3785}
3786
3787static void alc260_auto_init_multi_out(struct hda_codec *codec)
3788{
3789 struct alc_spec *spec = codec->spec;
3790 hda_nid_t nid;
3791
3792 nid = spec->autocfg.line_out_pins[0];
3793 if (nid)
3794 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3795
Takashi Iwai82bc9552006-03-21 11:24:42 +01003796 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003797 if (nid)
3798 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3799
3800 nid = spec->autocfg.hp_pin;
3801 if (nid)
3802 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3803}
3804
3805#define ALC260_PIN_CD_NID 0x16
3806static void alc260_auto_init_analog_input(struct hda_codec *codec)
3807{
3808 struct alc_spec *spec = codec->spec;
3809 int i;
3810
3811 for (i = 0; i < AUTO_PIN_LAST; i++) {
3812 hda_nid_t nid = spec->autocfg.input_pins[i];
3813 if (nid >= 0x12) {
3814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3815 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3816 if (nid != ALC260_PIN_CD_NID)
3817 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3818 AMP_OUT_MUTE);
3819 }
3820 }
3821}
3822
3823/*
3824 * generic initialization of ADC, input mixers and output mixers
3825 */
3826static struct hda_verb alc260_volume_init_verbs[] = {
3827 /*
3828 * Unmute ADC0-1 and set the default input to mic-in
3829 */
3830 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3832 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3833 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3834
3835 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3836 * mixer widget
3837 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3838 * mic (mic 2)
3839 */
3840 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3846
3847 /*
3848 * Set up output mixers (0x08 - 0x0a)
3849 */
3850 /* set vol=0 to output mixers */
3851 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3853 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3854 /* set up input amps for analog loopback */
3855 /* Amp Indices: DAC = 0, mixer = 1 */
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3862
3863 { }
3864};
3865
3866static int alc260_parse_auto_config(struct hda_codec *codec)
3867{
3868 struct alc_spec *spec = codec->spec;
3869 unsigned int wcap;
3870 int err;
3871 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3872
3873 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3874 alc260_ignore)) < 0)
3875 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003876 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3877 return err;
3878 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003879 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003880 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003881 return err;
3882
3883 spec->multiout.max_channels = 2;
3884
3885 if (spec->autocfg.dig_out_pin)
3886 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3887 if (spec->kctl_alloc)
3888 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3889
3890 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3891
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003892 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01003893 spec->input_mux = &spec->private_imux;
3894
3895 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003896 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003897 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3898 if (wcap != AC_WID_AUD_IN) {
3899 spec->adc_nids = alc260_adc_nids_alt;
3900 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3901 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003902 } else {
3903 spec->adc_nids = alc260_adc_nids;
3904 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3905 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003906 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003907 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003908
3909 return 1;
3910}
3911
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003912/* additional initialization for auto-configuration model */
3913static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01003914{
Kailang Yangdf694da2005-12-05 19:42:22 +01003915 alc260_auto_init_multi_out(codec);
3916 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01003917}
3918
3919/*
3920 * ALC260 configurations
3921 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003922static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003923 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003924 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3925 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai3206b9c2006-05-10 16:33:11 +02003926 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3927 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02003928 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3929 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01003930 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3931 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02003932 { .modelname = "hp", .config = ALC260_HP },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003933 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003934 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3935 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
Takashi Iwai766a6c32006-05-26 14:58:29 +02003936 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003937 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3938 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3941 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3942 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003943 { .modelname = "acer", .config = ALC260_ACER },
3944 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003945#ifdef CONFIG_SND_DEBUG
3946 { .modelname = "test", .config = ALC260_TEST },
3947#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003948 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003949 {}
3950};
3951
Kailang Yangdf694da2005-12-05 19:42:22 +01003952static struct alc_config_preset alc260_presets[] = {
3953 [ALC260_BASIC] = {
3954 .mixers = { alc260_base_output_mixer,
3955 alc260_input_mixer,
3956 alc260_pc_beep_mixer,
3957 alc260_capture_mixer },
3958 .init_verbs = { alc260_init_verbs },
3959 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3960 .dac_nids = alc260_dac_nids,
3961 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3962 .adc_nids = alc260_adc_nids,
3963 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3964 .channel_mode = alc260_modes,
3965 .input_mux = &alc260_capture_source,
3966 },
3967 [ALC260_HP] = {
3968 .mixers = { alc260_base_output_mixer,
3969 alc260_input_mixer,
3970 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02003971 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01003972 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3973 .dac_nids = alc260_dac_nids,
3974 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3975 .adc_nids = alc260_hp_adc_nids,
3976 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3977 .channel_mode = alc260_modes,
3978 .input_mux = &alc260_capture_source,
3979 },
3980 [ALC260_HP_3013] = {
3981 .mixers = { alc260_hp_3013_mixer,
3982 alc260_input_mixer,
3983 alc260_capture_alt_mixer },
3984 .init_verbs = { alc260_hp_3013_init_verbs },
3985 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3986 .dac_nids = alc260_dac_nids,
3987 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3988 .adc_nids = alc260_hp_adc_nids,
3989 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3990 .channel_mode = alc260_modes,
3991 .input_mux = &alc260_capture_source,
3992 },
3993 [ALC260_FUJITSU_S702X] = {
3994 .mixers = { alc260_fujitsu_mixer,
3995 alc260_capture_mixer },
3996 .init_verbs = { alc260_fujitsu_init_verbs },
3997 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3998 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003999 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4000 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004001 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4002 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004003 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4004 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004005 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004006 [ALC260_ACER] = {
4007 .mixers = { alc260_acer_mixer,
4008 alc260_capture_mixer },
4009 .init_verbs = { alc260_acer_init_verbs },
4010 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4011 .dac_nids = alc260_dac_nids,
4012 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4013 .adc_nids = alc260_dual_adc_nids,
4014 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4015 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004016 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4017 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004018 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004019#ifdef CONFIG_SND_DEBUG
4020 [ALC260_TEST] = {
4021 .mixers = { alc260_test_mixer,
4022 alc260_capture_mixer },
4023 .init_verbs = { alc260_test_init_verbs },
4024 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4025 .dac_nids = alc260_test_dac_nids,
4026 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4027 .adc_nids = alc260_test_adc_nids,
4028 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4029 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004030 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4031 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004032 },
4033#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004034};
4035
Linus Torvalds1da177e2005-04-16 15:20:36 -07004036static int patch_alc260(struct hda_codec *codec)
4037{
4038 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004039 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004040
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004041 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004042 if (spec == NULL)
4043 return -ENOMEM;
4044
4045 codec->spec = spec;
4046
Takashi Iwai16ded522005-06-10 19:58:24 +02004047 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4048 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004049 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4050 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004051 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004052 }
4053
Kailang Yangdf694da2005-12-05 19:42:22 +01004054 if (board_config == ALC260_AUTO) {
4055 /* automatic parse from the BIOS config */
4056 err = alc260_parse_auto_config(codec);
4057 if (err < 0) {
4058 alc_free(codec);
4059 return err;
4060 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004061 printk(KERN_INFO
4062 "hda_codec: Cannot set up configuration "
4063 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004064 board_config = ALC260_BASIC;
4065 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004066 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004067
Kailang Yangdf694da2005-12-05 19:42:22 +01004068 if (board_config != ALC260_AUTO)
4069 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004070
4071 spec->stream_name_analog = "ALC260 Analog";
4072 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4073 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4074
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004075 spec->stream_name_digital = "ALC260 Digital";
4076 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4077 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4078
Linus Torvalds1da177e2005-04-16 15:20:36 -07004079 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004080 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004081 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004082
4083 return 0;
4084}
4085
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086
Linus Torvalds1da177e2005-04-16 15:20:36 -07004087/*
4088 * ALC882 support
4089 *
4090 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4091 * configuration. Each pin widget can choose any input DACs and a mixer.
4092 * Each ADC is connected from a mixer of all inputs. This makes possible
4093 * 6-channel independent captures.
4094 *
4095 * In addition, an independent DAC for the multi-playback (not used in this
4096 * driver yet).
4097 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004098#define ALC882_DIGOUT_NID 0x06
4099#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004100
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004101static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004102 { 8, NULL }
4103};
4104
4105static hda_nid_t alc882_dac_nids[4] = {
4106 /* front, rear, clfe, rear_surr */
4107 0x02, 0x03, 0x04, 0x05
4108};
4109
Kailang Yangdf694da2005-12-05 19:42:22 +01004110/* identical with ALC880 */
4111#define alc882_adc_nids alc880_adc_nids
4112#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004113
4114/* input MUX */
4115/* FIXME: should be a matrix-type input source selection */
4116
4117static struct hda_input_mux alc882_capture_source = {
4118 .num_items = 4,
4119 .items = {
4120 { "Mic", 0x0 },
4121 { "Front Mic", 0x1 },
4122 { "Line", 0x2 },
4123 { "CD", 0x4 },
4124 },
4125};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004126#define alc882_mux_enum_info alc_mux_enum_info
4127#define alc882_mux_enum_get alc_mux_enum_get
4128
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004129static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004130{
4131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4132 struct alc_spec *spec = codec->spec;
4133 const struct hda_input_mux *imux = spec->input_mux;
4134 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4135 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4136 hda_nid_t nid = capture_mixers[adc_idx];
4137 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4138 unsigned int i, idx;
4139
4140 idx = ucontrol->value.enumerated.item[0];
4141 if (idx >= imux->num_items)
4142 idx = imux->num_items - 1;
4143 if (*cur_val == idx && ! codec->in_resume)
4144 return 0;
4145 for (i = 0; i < imux->num_items; i++) {
4146 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4147 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4148 v | (imux->items[i].index << 8));
4149 }
4150 *cur_val = idx;
4151 return 1;
4152}
4153
Kailang Yangdf694da2005-12-05 19:42:22 +01004154/*
4155 * 6ch mode
4156 */
4157static struct hda_verb alc882_sixstack_ch6_init[] = {
4158 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4159 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4160 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4161 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4162 { } /* end */
4163};
4164
4165/*
4166 * 8ch mode
4167 */
4168static struct hda_verb alc882_sixstack_ch8_init[] = {
4169 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4170 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4171 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4172 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4173 { } /* end */
4174};
4175
4176static struct hda_channel_mode alc882_sixstack_modes[2] = {
4177 { 6, alc882_sixstack_ch6_init },
4178 { 8, alc882_sixstack_ch8_init },
4179};
4180
Linus Torvalds1da177e2005-04-16 15:20:36 -07004181/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4182 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4183 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004184static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004187 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004188 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004193 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004194 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4204 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4205 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004206 { } /* end */
4207};
4208
Kailang Yangdf694da2005-12-05 19:42:22 +01004209static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4210 {
4211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4212 .name = "Channel Mode",
4213 .info = alc_ch_mode_info,
4214 .get = alc_ch_mode_get,
4215 .put = alc_ch_mode_put,
4216 },
4217 { } /* end */
4218};
4219
Linus Torvalds1da177e2005-04-16 15:20:36 -07004220static struct hda_verb alc882_init_verbs[] = {
4221 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004225 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004229 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004233 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004234 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4235 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004238 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004241 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004246 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004247 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004248 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004249 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004251 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004252 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004253 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004254 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4257 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004258 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4260 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004261 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4263 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4264 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4265 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4266 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004267 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004268 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004269
4270 /* FIXME: use matrix-type input source selection */
4271 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4272 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004277 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004282 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4287 /* ADC1: mute amp left and right */
4288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004289 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004290 /* ADC2: mute amp left and right */
4291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004293 /* ADC3: mute amp left and right */
4294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004295 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004296
4297 { }
4298};
4299
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004300static struct hda_verb alc882_eapd_verbs[] = {
4301 /* change to EAPD mode */
4302 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4303 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4304 { }
4305};
4306
Kailang Yangdf694da2005-12-05 19:42:22 +01004307/*
4308 * generic initialization of ADC, input mixers and output mixers
4309 */
4310static struct hda_verb alc882_auto_init_verbs[] = {
4311 /*
4312 * Unmute ADC0-2 and set the default input to mic-in
4313 */
4314 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4316 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4318 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4320
4321 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4322 * mixer widget
4323 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4324 * mic (mic 2)
4325 */
4326 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4332
4333 /*
4334 * Set up output mixers (0x0c - 0x0f)
4335 */
4336 /* set vol=0 to output mixers */
4337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4341 /* set up input amps for analog loopback */
4342 /* Amp Indices: DAC = 0, mixer = 1 */
4343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4351 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4352 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4353
4354 /* FIXME: use matrix-type input source selection */
4355 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4356 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4361 /* Input mixer2 */
4362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4366 /* Input mixer3 */
4367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4371
4372 { }
4373};
4374
4375/* capture mixer elements */
4376static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4377 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4378 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4379 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4380 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4381 {
4382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4383 /* The multiple "Capture Source" controls confuse alsamixer
4384 * So call somewhat different..
4385 * FIXME: the controls appear in the "playback" view!
4386 */
4387 /* .name = "Capture Source", */
4388 .name = "Input Source",
4389 .count = 2,
4390 .info = alc882_mux_enum_info,
4391 .get = alc882_mux_enum_get,
4392 .put = alc882_mux_enum_put,
4393 },
4394 { } /* end */
4395};
4396
4397static struct snd_kcontrol_new alc882_capture_mixer[] = {
4398 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4399 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4400 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4401 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4402 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4403 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4404 {
4405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4406 /* The multiple "Capture Source" controls confuse alsamixer
4407 * So call somewhat different..
4408 * FIXME: the controls appear in the "playback" view!
4409 */
4410 /* .name = "Capture Source", */
4411 .name = "Input Source",
4412 .count = 3,
4413 .info = alc882_mux_enum_info,
4414 .get = alc882_mux_enum_get,
4415 .put = alc882_mux_enum_put,
4416 },
4417 { } /* end */
4418};
4419
4420/* pcm configuration: identiacal with ALC880 */
4421#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4422#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4423#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4424#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4425
4426/*
4427 * configuration and preset
4428 */
4429static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004430 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4431 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004432 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4433 .config = ALC882_6ST_DIG }, /* MSI */
4434 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4435 .config = ALC882_6ST_DIG }, /* Foxconn */
4436 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4437 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004438 { .modelname = "arima", .config = ALC882_ARIMA },
4439 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4440 .config = ALC882_ARIMA }, /* Arima W820Di1 */
Takashi Iwai1494a922006-01-31 10:58:46 +01004441 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004442 {}
4443};
4444
4445static struct alc_config_preset alc882_presets[] = {
4446 [ALC882_3ST_DIG] = {
4447 .mixers = { alc882_base_mixer },
4448 .init_verbs = { alc882_init_verbs },
4449 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4450 .dac_nids = alc882_dac_nids,
4451 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004452 .dig_in_nid = ALC882_DIGIN_NID,
4453 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4454 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004455 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004456 .input_mux = &alc882_capture_source,
4457 },
4458 [ALC882_6ST_DIG] = {
4459 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4460 .init_verbs = { alc882_init_verbs },
4461 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4462 .dac_nids = alc882_dac_nids,
4463 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004464 .dig_in_nid = ALC882_DIGIN_NID,
4465 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4466 .channel_mode = alc882_sixstack_modes,
4467 .input_mux = &alc882_capture_source,
4468 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004469 [ALC882_ARIMA] = {
4470 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4471 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4472 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4473 .dac_nids = alc882_dac_nids,
4474 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4475 .channel_mode = alc882_sixstack_modes,
4476 .input_mux = &alc882_capture_source,
4477 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004478};
4479
4480
4481/*
4482 * BIOS auto configuration
4483 */
4484static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4485 hda_nid_t nid, int pin_type,
4486 int dac_idx)
4487{
4488 /* set as output */
4489 struct alc_spec *spec = codec->spec;
4490 int idx;
4491
4492 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4493 idx = 4;
4494 else
4495 idx = spec->multiout.dac_nids[dac_idx] - 2;
4496
4497 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4500
4501}
4502
4503static void alc882_auto_init_multi_out(struct hda_codec *codec)
4504{
4505 struct alc_spec *spec = codec->spec;
4506 int i;
4507
4508 for (i = 0; i <= HDA_SIDE; i++) {
4509 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4510 if (nid)
4511 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4512 }
4513}
4514
4515static void alc882_auto_init_hp_out(struct hda_codec *codec)
4516{
4517 struct alc_spec *spec = codec->spec;
4518 hda_nid_t pin;
4519
4520 pin = spec->autocfg.hp_pin;
4521 if (pin) /* connect to front */
4522 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4523}
4524
4525#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4526#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4527
4528static void alc882_auto_init_analog_input(struct hda_codec *codec)
4529{
4530 struct alc_spec *spec = codec->spec;
4531 int i;
4532
4533 for (i = 0; i < AUTO_PIN_LAST; i++) {
4534 hda_nid_t nid = spec->autocfg.input_pins[i];
4535 if (alc882_is_input_pin(nid)) {
4536 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4537 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4538 if (nid != ALC882_PIN_CD_NID)
4539 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4540 AMP_OUT_MUTE);
4541 }
4542 }
4543}
4544
4545/* almost identical with ALC880 parser... */
4546static int alc882_parse_auto_config(struct hda_codec *codec)
4547{
4548 struct alc_spec *spec = codec->spec;
4549 int err = alc880_parse_auto_config(codec);
4550
4551 if (err < 0)
4552 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004553 else if (err > 0)
4554 /* hack - override the init verbs */
4555 spec->init_verbs[0] = alc882_auto_init_verbs;
4556 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004557}
4558
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004559/* additional initialization for auto-configuration model */
4560static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004561{
Kailang Yangdf694da2005-12-05 19:42:22 +01004562 alc882_auto_init_multi_out(codec);
4563 alc882_auto_init_hp_out(codec);
4564 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004565}
4566
Linus Torvalds1da177e2005-04-16 15:20:36 -07004567static int patch_alc882(struct hda_codec *codec)
4568{
4569 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004570 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004571
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004572 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004573 if (spec == NULL)
4574 return -ENOMEM;
4575
Linus Torvalds1da177e2005-04-16 15:20:36 -07004576 codec->spec = spec;
4577
Kailang Yangdf694da2005-12-05 19:42:22 +01004578 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004579
Kailang Yangdf694da2005-12-05 19:42:22 +01004580 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004581 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4582 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004583 board_config = ALC882_AUTO;
4584 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585
Kailang Yangdf694da2005-12-05 19:42:22 +01004586 if (board_config == ALC882_AUTO) {
4587 /* automatic parse from the BIOS config */
4588 err = alc882_parse_auto_config(codec);
4589 if (err < 0) {
4590 alc_free(codec);
4591 return err;
4592 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004593 printk(KERN_INFO
4594 "hda_codec: Cannot set up configuration "
4595 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004596 board_config = ALC882_3ST_DIG;
4597 }
4598 }
4599
4600 if (board_config != ALC882_AUTO)
4601 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004602
4603 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004604 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4605 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004606
4607 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004608 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4609 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004610
Kailang Yangdf694da2005-12-05 19:42:22 +01004611 if (! spec->adc_nids && spec->input_mux) {
4612 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004613 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004614 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4615 if (wcap != AC_WID_AUD_IN) {
4616 spec->adc_nids = alc882_adc_nids_alt;
4617 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4618 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4619 spec->num_mixers++;
4620 } else {
4621 spec->adc_nids = alc882_adc_nids;
4622 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4623 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4624 spec->num_mixers++;
4625 }
4626 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004627
4628 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004629 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004630 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004631
4632 return 0;
4633}
4634
4635/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004636 * ALC883 support
4637 *
4638 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4639 * configuration. Each pin widget can choose any input DACs and a mixer.
4640 * Each ADC is connected from a mixer of all inputs. This makes possible
4641 * 6-channel independent captures.
4642 *
4643 * In addition, an independent DAC for the multi-playback (not used in this
4644 * driver yet).
4645 */
4646#define ALC883_DIGOUT_NID 0x06
4647#define ALC883_DIGIN_NID 0x0a
4648
4649static hda_nid_t alc883_dac_nids[4] = {
4650 /* front, rear, clfe, rear_surr */
4651 0x02, 0x04, 0x03, 0x05
4652};
4653
4654static hda_nid_t alc883_adc_nids[2] = {
4655 /* ADC1-2 */
4656 0x08, 0x09,
4657};
4658/* input MUX */
4659/* FIXME: should be a matrix-type input source selection */
4660
4661static struct hda_input_mux alc883_capture_source = {
4662 .num_items = 4,
4663 .items = {
4664 { "Mic", 0x0 },
4665 { "Front Mic", 0x1 },
4666 { "Line", 0x2 },
4667 { "CD", 0x4 },
4668 },
4669};
4670#define alc883_mux_enum_info alc_mux_enum_info
4671#define alc883_mux_enum_get alc_mux_enum_get
4672
4673static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4674 struct snd_ctl_elem_value *ucontrol)
4675{
4676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4677 struct alc_spec *spec = codec->spec;
4678 const struct hda_input_mux *imux = spec->input_mux;
4679 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4680 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4681 hda_nid_t nid = capture_mixers[adc_idx];
4682 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4683 unsigned int i, idx;
4684
4685 idx = ucontrol->value.enumerated.item[0];
4686 if (idx >= imux->num_items)
4687 idx = imux->num_items - 1;
4688 if (*cur_val == idx && ! codec->in_resume)
4689 return 0;
4690 for (i = 0; i < imux->num_items; i++) {
4691 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4692 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4693 v | (imux->items[i].index << 8));
4694 }
4695 *cur_val = idx;
4696 return 1;
4697}
4698/*
4699 * 2ch mode
4700 */
4701static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4702 { 2, NULL }
4703};
4704
4705/*
4706 * 2ch mode
4707 */
4708static struct hda_verb alc883_3ST_ch2_init[] = {
4709 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4710 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4711 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4712 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4713 { } /* end */
4714};
4715
4716/*
4717 * 6ch mode
4718 */
4719static struct hda_verb alc883_3ST_ch6_init[] = {
4720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4722 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4723 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4724 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4725 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4726 { } /* end */
4727};
4728
4729static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4730 { 2, alc883_3ST_ch2_init },
4731 { 6, alc883_3ST_ch6_init },
4732};
4733
4734/*
4735 * 6ch mode
4736 */
4737static struct hda_verb alc883_sixstack_ch6_init[] = {
4738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4742 { } /* end */
4743};
4744
4745/*
4746 * 8ch mode
4747 */
4748static struct hda_verb alc883_sixstack_ch8_init[] = {
4749 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4750 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4751 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4752 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4753 { } /* end */
4754};
4755
4756static struct hda_channel_mode alc883_sixstack_modes[2] = {
4757 { 6, alc883_sixstack_ch6_init },
4758 { 8, alc883_sixstack_ch8_init },
4759};
4760
4761/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4762 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4763 */
4764
4765static struct snd_kcontrol_new alc883_base_mixer[] = {
4766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4769 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4772 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4773 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4774 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4775 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4777 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4778 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4785 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4786 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4787 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4788 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4789 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4790 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4791 {
4792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4793 /* .name = "Capture Source", */
4794 .name = "Input Source",
4795 .count = 2,
4796 .info = alc883_mux_enum_info,
4797 .get = alc883_mux_enum_get,
4798 .put = alc883_mux_enum_put,
4799 },
4800 { } /* end */
4801};
4802
4803static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4804 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4805 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4815 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4816 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4817 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4818 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4819 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4820 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4821 {
4822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4823 /* .name = "Capture Source", */
4824 .name = "Input Source",
4825 .count = 2,
4826 .info = alc883_mux_enum_info,
4827 .get = alc883_mux_enum_get,
4828 .put = alc883_mux_enum_put,
4829 },
4830 { } /* end */
4831};
4832
4833static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4835 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4836 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4837 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4838 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4839 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4840 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4841 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4849 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4850 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4851 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4852 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4853 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4854 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4855 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4856 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4857 {
4858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4859 /* .name = "Capture Source", */
4860 .name = "Input Source",
4861 .count = 2,
4862 .info = alc883_mux_enum_info,
4863 .get = alc883_mux_enum_get,
4864 .put = alc883_mux_enum_put,
4865 },
4866 { } /* end */
4867};
4868
4869static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4870 {
4871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4872 .name = "Channel Mode",
4873 .info = alc_ch_mode_info,
4874 .get = alc_ch_mode_get,
4875 .put = alc_ch_mode_put,
4876 },
4877 { } /* end */
4878};
4879
4880static struct hda_verb alc883_init_verbs[] = {
4881 /* ADC1: mute amp left and right */
4882 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4883 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4884 /* ADC2: mute amp left and right */
4885 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4887 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4891 /* Rear mixer */
4892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4895 /* CLFE mixer */
4896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4899 /* Side mixer */
4900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4903
4904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4909
4910 /* Front Pin: output 0 (0x0c) */
4911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4913 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4914 /* Rear Pin: output 1 (0x0d) */
4915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4917 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4918 /* CLFE Pin: output 2 (0x0e) */
4919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4921 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4922 /* Side Pin: output 3 (0x0f) */
4923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4925 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4926 /* Mic (rear) pin: input vref at 80% */
4927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4929 /* Front Mic pin: input vref at 80% */
4930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4932 /* Line In pin: input */
4933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4935 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4939 /* CD pin widget for input */
4940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4941
4942 /* FIXME: use matrix-type input source selection */
4943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4944 /* Input mixer2 */
4945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4949 /* Input mixer3 */
4950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4954 { }
4955};
4956
4957/*
4958 * generic initialization of ADC, input mixers and output mixers
4959 */
4960static struct hda_verb alc883_auto_init_verbs[] = {
4961 /*
4962 * Unmute ADC0-2 and set the default input to mic-in
4963 */
4964 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4966 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4968
4969 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4970 * mixer widget
4971 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4972 * mic (mic 2)
4973 */
4974 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4980
4981 /*
4982 * Set up output mixers (0x0c - 0x0f)
4983 */
4984 /* set vol=0 to output mixers */
4985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4989 /* set up input amps for analog loopback */
4990 /* Amp Indices: DAC = 0, mixer = 1 */
4991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4993 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4995 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4999 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5000 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5001
5002 /* FIXME: use matrix-type input source selection */
5003 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5004 /* Input mixer1 */
5005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5008 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5010 /* Input mixer2 */
5011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5014 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5016
5017 { }
5018};
5019
5020/* capture mixer elements */
5021static struct snd_kcontrol_new alc883_capture_mixer[] = {
5022 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5023 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5024 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5025 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5026 {
5027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5028 /* The multiple "Capture Source" controls confuse alsamixer
5029 * So call somewhat different..
5030 * FIXME: the controls appear in the "playback" view!
5031 */
5032 /* .name = "Capture Source", */
5033 .name = "Input Source",
5034 .count = 2,
5035 .info = alc882_mux_enum_info,
5036 .get = alc882_mux_enum_get,
5037 .put = alc882_mux_enum_put,
5038 },
5039 { } /* end */
5040};
5041
5042/* pcm configuration: identiacal with ALC880 */
5043#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5044#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5045#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5046#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5047
5048/*
5049 * configuration and preset
5050 */
5051static struct hda_board_config alc883_cfg_tbl[] = {
5052 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005053 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5054 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5055 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5056 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5057 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5058 .config = ALC883_3ST_6ch },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005059 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005060 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5061 .config = ALC883_6ST_DIG }, /* MSI */
5062 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5063 .config = ALC883_6ST_DIG }, /* Foxconn */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005064 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005065 { .modelname = "auto", .config = ALC883_AUTO },
5066 {}
5067};
5068
5069static struct alc_config_preset alc883_presets[] = {
5070 [ALC883_3ST_2ch_DIG] = {
5071 .mixers = { alc883_3ST_2ch_mixer },
5072 .init_verbs = { alc883_init_verbs },
5073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5074 .dac_nids = alc883_dac_nids,
5075 .dig_out_nid = ALC883_DIGOUT_NID,
5076 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5077 .adc_nids = alc883_adc_nids,
5078 .dig_in_nid = ALC883_DIGIN_NID,
5079 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5080 .channel_mode = alc883_3ST_2ch_modes,
5081 .input_mux = &alc883_capture_source,
5082 },
5083 [ALC883_3ST_6ch_DIG] = {
5084 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5085 .init_verbs = { alc883_init_verbs },
5086 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5087 .dac_nids = alc883_dac_nids,
5088 .dig_out_nid = ALC883_DIGOUT_NID,
5089 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5090 .adc_nids = alc883_adc_nids,
5091 .dig_in_nid = ALC883_DIGIN_NID,
5092 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5093 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005094 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005095 .input_mux = &alc883_capture_source,
5096 },
5097 [ALC883_3ST_6ch] = {
5098 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5099 .init_verbs = { alc883_init_verbs },
5100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5101 .dac_nids = alc883_dac_nids,
5102 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5103 .adc_nids = alc883_adc_nids,
5104 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5105 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005106 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005107 .input_mux = &alc883_capture_source,
5108 },
5109 [ALC883_6ST_DIG] = {
5110 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5111 .init_verbs = { alc883_init_verbs },
5112 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5113 .dac_nids = alc883_dac_nids,
5114 .dig_out_nid = ALC883_DIGOUT_NID,
5115 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5116 .adc_nids = alc883_adc_nids,
5117 .dig_in_nid = ALC883_DIGIN_NID,
5118 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5119 .channel_mode = alc883_sixstack_modes,
5120 .input_mux = &alc883_capture_source,
5121 },
5122 [ALC888_DEMO_BOARD] = {
5123 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5124 .init_verbs = { alc883_init_verbs },
5125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5126 .dac_nids = alc883_dac_nids,
5127 .dig_out_nid = ALC883_DIGOUT_NID,
5128 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5129 .adc_nids = alc883_adc_nids,
5130 .dig_in_nid = ALC883_DIGIN_NID,
5131 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5132 .channel_mode = alc883_sixstack_modes,
5133 .input_mux = &alc883_capture_source,
5134 },
5135};
5136
5137
5138/*
5139 * BIOS auto configuration
5140 */
5141static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5142 hda_nid_t nid, int pin_type,
5143 int dac_idx)
5144{
5145 /* set as output */
5146 struct alc_spec *spec = codec->spec;
5147 int idx;
5148
5149 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5150 idx = 4;
5151 else
5152 idx = spec->multiout.dac_nids[dac_idx] - 2;
5153
5154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5155 pin_type);
5156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5157 AMP_OUT_UNMUTE);
5158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5159
5160}
5161
5162static void alc883_auto_init_multi_out(struct hda_codec *codec)
5163{
5164 struct alc_spec *spec = codec->spec;
5165 int i;
5166
5167 for (i = 0; i <= HDA_SIDE; i++) {
5168 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5169 if (nid)
5170 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5171 }
5172}
5173
5174static void alc883_auto_init_hp_out(struct hda_codec *codec)
5175{
5176 struct alc_spec *spec = codec->spec;
5177 hda_nid_t pin;
5178
5179 pin = spec->autocfg.hp_pin;
5180 if (pin) /* connect to front */
5181 /* use dac 0 */
5182 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5183}
5184
5185#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5186#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5187
5188static void alc883_auto_init_analog_input(struct hda_codec *codec)
5189{
5190 struct alc_spec *spec = codec->spec;
5191 int i;
5192
5193 for (i = 0; i < AUTO_PIN_LAST; i++) {
5194 hda_nid_t nid = spec->autocfg.input_pins[i];
5195 if (alc883_is_input_pin(nid)) {
5196 snd_hda_codec_write(codec, nid, 0,
5197 AC_VERB_SET_PIN_WIDGET_CONTROL,
5198 (i <= AUTO_PIN_FRONT_MIC ?
5199 PIN_VREF80 : PIN_IN));
5200 if (nid != ALC883_PIN_CD_NID)
5201 snd_hda_codec_write(codec, nid, 0,
5202 AC_VERB_SET_AMP_GAIN_MUTE,
5203 AMP_OUT_MUTE);
5204 }
5205 }
5206}
5207
5208/* almost identical with ALC880 parser... */
5209static int alc883_parse_auto_config(struct hda_codec *codec)
5210{
5211 struct alc_spec *spec = codec->spec;
5212 int err = alc880_parse_auto_config(codec);
5213
5214 if (err < 0)
5215 return err;
5216 else if (err > 0)
5217 /* hack - override the init verbs */
5218 spec->init_verbs[0] = alc883_auto_init_verbs;
5219 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5220 spec->num_mixers++;
5221 return err;
5222}
5223
5224/* additional initialization for auto-configuration model */
5225static void alc883_auto_init(struct hda_codec *codec)
5226{
5227 alc883_auto_init_multi_out(codec);
5228 alc883_auto_init_hp_out(codec);
5229 alc883_auto_init_analog_input(codec);
5230}
5231
5232static int patch_alc883(struct hda_codec *codec)
5233{
5234 struct alc_spec *spec;
5235 int err, board_config;
5236
5237 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5238 if (spec == NULL)
5239 return -ENOMEM;
5240
5241 codec->spec = spec;
5242
5243 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5244 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5245 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5246 "trying auto-probe from BIOS...\n");
5247 board_config = ALC883_AUTO;
5248 }
5249
5250 if (board_config == ALC883_AUTO) {
5251 /* automatic parse from the BIOS config */
5252 err = alc883_parse_auto_config(codec);
5253 if (err < 0) {
5254 alc_free(codec);
5255 return err;
5256 } else if (! err) {
5257 printk(KERN_INFO
5258 "hda_codec: Cannot set up configuration "
5259 "from BIOS. Using base mode...\n");
5260 board_config = ALC883_3ST_2ch_DIG;
5261 }
5262 }
5263
5264 if (board_config != ALC883_AUTO)
5265 setup_preset(spec, &alc883_presets[board_config]);
5266
5267 spec->stream_name_analog = "ALC883 Analog";
5268 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5269 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5270
5271 spec->stream_name_digital = "ALC883 Digital";
5272 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5273 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5274
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005275 if (! spec->adc_nids && spec->input_mux) {
5276 spec->adc_nids = alc883_adc_nids;
5277 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5278 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005279
5280 codec->patch_ops = alc_patch_ops;
5281 if (board_config == ALC883_AUTO)
5282 spec->init_hook = alc883_auto_init;
5283
5284 return 0;
5285}
5286
5287/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005288 * ALC262 support
5289 */
5290
5291#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5292#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5293
5294#define alc262_dac_nids alc260_dac_nids
5295#define alc262_adc_nids alc882_adc_nids
5296#define alc262_adc_nids_alt alc882_adc_nids_alt
5297
5298#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005299#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005300
5301static struct snd_kcontrol_new alc262_base_mixer[] = {
5302 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5303 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5304 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5305 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5306 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5307 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5310 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5311 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5312 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5313 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5315 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5316 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5317 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005318 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005319};
5320
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005321static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5323 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5325 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5327
5328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5330 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5331 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5334 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5335 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5336 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5337 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5338 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5339 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5340 { } /* end */
5341};
5342
Kailang Yangdf694da2005-12-05 19:42:22 +01005343#define alc262_capture_mixer alc882_capture_mixer
5344#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5345
5346/*
5347 * generic initialization of ADC, input mixers and output mixers
5348 */
5349static struct hda_verb alc262_init_verbs[] = {
5350 /*
5351 * Unmute ADC0-2 and set the default input to mic-in
5352 */
5353 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5357 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5359
5360 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5361 * mixer widget
5362 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5363 * mic (mic 2)
5364 */
5365 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5371
5372 /*
5373 * Set up output mixers (0x0c - 0x0e)
5374 */
5375 /* set vol=0 to output mixers */
5376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 /* set up input amps for analog loopback */
5380 /* Amp Indices: DAC = 0, mixer = 1 */
5381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5387
5388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5392 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5393 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5394
5395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5397 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5399 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5400
5401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5402 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5403
5404 /* FIXME: use matrix-type input source selection */
5405 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5406 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5411 /* Input mixer2 */
5412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5416 /* Input mixer3 */
5417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5421
5422 { }
5423};
5424
Takashi Iwai834be882006-03-01 14:16:17 +01005425/*
5426 * fujitsu model
5427 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5428 */
5429
5430#define ALC_HP_EVENT 0x37
5431
5432static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5433 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5435 {}
5436};
5437
5438static struct hda_input_mux alc262_fujitsu_capture_source = {
5439 .num_items = 2,
5440 .items = {
5441 { "Mic", 0x0 },
5442 { "CD", 0x4 },
5443 },
5444};
5445
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005446static struct hda_input_mux alc262_HP_capture_source = {
5447 .num_items = 5,
5448 .items = {
5449 { "Mic", 0x0 },
5450 { "Front Mic", 0x3 },
5451 { "Line", 0x2 },
5452 { "CD", 0x4 },
5453 { "AUX IN", 0x6 },
5454 },
5455};
5456
Takashi Iwai834be882006-03-01 14:16:17 +01005457/* mute/unmute internal speaker according to the hp jack and mute state */
5458static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5459{
5460 struct alc_spec *spec = codec->spec;
5461 unsigned int mute;
5462
5463 if (force || ! spec->sense_updated) {
5464 unsigned int present;
5465 /* need to execute and sync at first */
5466 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5467 present = snd_hda_codec_read(codec, 0x14, 0,
5468 AC_VERB_GET_PIN_SENSE, 0);
5469 spec->jack_present = (present & 0x80000000) != 0;
5470 spec->sense_updated = 1;
5471 }
5472 if (spec->jack_present) {
5473 /* mute internal speaker */
5474 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5475 0x80, 0x80);
5476 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5477 0x80, 0x80);
5478 } else {
5479 /* unmute internal speaker if necessary */
5480 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5481 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5482 0x80, mute & 0x80);
5483 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5484 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5485 0x80, mute & 0x80);
5486 }
5487}
5488
5489/* unsolicited event for HP jack sensing */
5490static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5491 unsigned int res)
5492{
5493 if ((res >> 26) != ALC_HP_EVENT)
5494 return;
5495 alc262_fujitsu_automute(codec, 1);
5496}
5497
5498/* bind volumes of both NID 0x0c and 0x0d */
5499static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5500 struct snd_ctl_elem_value *ucontrol)
5501{
5502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5503 long *valp = ucontrol->value.integer.value;
5504 int change;
5505
5506 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5507 0x7f, valp[0] & 0x7f);
5508 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5509 0x7f, valp[1] & 0x7f);
5510 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5511 0x7f, valp[0] & 0x7f);
5512 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5513 0x7f, valp[1] & 0x7f);
5514 return change;
5515}
5516
5517/* bind hp and internal speaker mute (with plug check) */
5518static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5519 struct snd_ctl_elem_value *ucontrol)
5520{
5521 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5522 long *valp = ucontrol->value.integer.value;
5523 int change;
5524
5525 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5526 0x80, valp[0] ? 0 : 0x80);
5527 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5528 0x80, valp[1] ? 0 : 0x80);
5529 if (change || codec->in_resume)
5530 alc262_fujitsu_automute(codec, codec->in_resume);
5531 return change;
5532}
5533
5534static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5535 {
5536 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5537 .name = "Master Playback Volume",
5538 .info = snd_hda_mixer_amp_volume_info,
5539 .get = snd_hda_mixer_amp_volume_get,
5540 .put = alc262_fujitsu_master_vol_put,
5541 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5542 },
5543 {
5544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5545 .name = "Master Playback Switch",
5546 .info = snd_hda_mixer_amp_switch_info,
5547 .get = snd_hda_mixer_amp_switch_get,
5548 .put = alc262_fujitsu_master_sw_put,
5549 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5550 },
5551 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5552 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5553 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5556 { } /* end */
5557};
5558
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005559/* additional init verbs for Benq laptops */
5560static struct hda_verb alc262_EAPD_verbs[] = {
5561 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5562 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5563 {}
5564};
5565
Kailang Yangdf694da2005-12-05 19:42:22 +01005566/* add playback controls from the parsed DAC table */
5567static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5568{
5569 hda_nid_t nid;
5570 int err;
5571
5572 spec->multiout.num_dacs = 1; /* only use one dac */
5573 spec->multiout.dac_nids = spec->private_dac_nids;
5574 spec->multiout.dac_nids[0] = 2;
5575
5576 nid = cfg->line_out_pins[0];
5577 if (nid) {
5578 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5579 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5580 return err;
5581 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5582 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5583 return err;
5584 }
5585
Takashi Iwai82bc9552006-03-21 11:24:42 +01005586 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005587 if (nid) {
5588 if (nid == 0x16) {
5589 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5590 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5591 return err;
5592 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5593 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5594 return err;
5595 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005596 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5597 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5598 return err;
5599 }
5600 }
5601 nid = cfg->hp_pin;
5602 if (nid) {
5603 /* spec->multiout.hp_nid = 2; */
5604 if (nid == 0x16) {
5605 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5606 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5607 return err;
5608 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5609 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5610 return err;
5611 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005612 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5613 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5614 return err;
5615 }
5616 }
5617 return 0;
5618}
5619
5620/* identical with ALC880 */
5621#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5622
5623/*
5624 * generic initialization of ADC, input mixers and output mixers
5625 */
5626static struct hda_verb alc262_volume_init_verbs[] = {
5627 /*
5628 * Unmute ADC0-2 and set the default input to mic-in
5629 */
5630 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5634 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5636
5637 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5638 * mixer widget
5639 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5640 * mic (mic 2)
5641 */
5642 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5648
5649 /*
5650 * Set up output mixers (0x0c - 0x0f)
5651 */
5652 /* set vol=0 to output mixers */
5653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5656
5657 /* set up input amps for analog loopback */
5658 /* Amp Indices: DAC = 0, mixer = 1 */
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5665
5666 /* FIXME: use matrix-type input source selection */
5667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5673 /* Input mixer2 */
5674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5678 /* Input mixer3 */
5679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5683
5684 { }
5685};
5686
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005687static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5688 /*
5689 * Unmute ADC0-2 and set the default input to mic-in
5690 */
5691 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5693 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5695 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5697
5698 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5699 * mixer widget
5700 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5701 * mic (mic 2)
5702 */
5703 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5711
5712 /*
5713 * Set up output mixers (0x0c - 0x0e)
5714 */
5715 /* set vol=0 to output mixers */
5716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5719
5720 /* set up input amps for analog loopback */
5721 /* Amp Indices: DAC = 0, mixer = 1 */
5722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5728
5729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5732
5733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5735
5736 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5738
5739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5743 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5744
5745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5749 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5750 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5751
5752
5753 /* FIXME: use matrix-type input source selection */
5754 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5755 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5760 /* Input mixer2 */
5761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5765 /* Input mixer3 */
5766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5770
5771 { }
5772};
5773
Kailang Yangdf694da2005-12-05 19:42:22 +01005774/* pcm configuration: identiacal with ALC880 */
5775#define alc262_pcm_analog_playback alc880_pcm_analog_playback
5776#define alc262_pcm_analog_capture alc880_pcm_analog_capture
5777#define alc262_pcm_digital_playback alc880_pcm_digital_playback
5778#define alc262_pcm_digital_capture alc880_pcm_digital_capture
5779
5780/*
5781 * BIOS auto configuration
5782 */
5783static int alc262_parse_auto_config(struct hda_codec *codec)
5784{
5785 struct alc_spec *spec = codec->spec;
5786 int err;
5787 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5788
5789 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5790 alc262_ignore)) < 0)
5791 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005792 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005793 return 0; /* can't find valid BIOS pin config */
5794 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5795 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5796 return err;
5797
5798 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5799
5800 if (spec->autocfg.dig_out_pin)
5801 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5802 if (spec->autocfg.dig_in_pin)
5803 spec->dig_in_nid = ALC262_DIGIN_NID;
5804
5805 if (spec->kctl_alloc)
5806 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5807
5808 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005809 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005810 spec->input_mux = &spec->private_imux;
5811
5812 return 1;
5813}
5814
5815#define alc262_auto_init_multi_out alc882_auto_init_multi_out
5816#define alc262_auto_init_hp_out alc882_auto_init_hp_out
5817#define alc262_auto_init_analog_input alc882_auto_init_analog_input
5818
5819
5820/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005821static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005822{
Kailang Yangdf694da2005-12-05 19:42:22 +01005823 alc262_auto_init_multi_out(codec);
5824 alc262_auto_init_hp_out(codec);
5825 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005826}
5827
5828/*
5829 * configuration and preset
5830 */
5831static struct hda_board_config alc262_cfg_tbl[] = {
5832 { .modelname = "basic", .config = ALC262_BASIC },
Takashi Iwai834be882006-03-01 14:16:17 +01005833 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005834 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5835 .config = ALC262_FUJITSU },
Takashi Iwai6d177ba2006-07-25 14:51:15 +02005836 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005837 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5838 .config = ALC262_HP_BPC }, /* xw4400 */
5839 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5840 .config = ALC262_HP_BPC }, /* xw6400 */
5841 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5842 .config = ALC262_HP_BPC }, /* xw8400 */
5843 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5844 .config = ALC262_HP_BPC }, /* xw9400 */
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005845 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5846 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5847 .config = ALC262_BENQ_ED8 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005848 { .modelname = "auto", .config = ALC262_AUTO },
5849 {}
5850};
5851
5852static struct alc_config_preset alc262_presets[] = {
5853 [ALC262_BASIC] = {
5854 .mixers = { alc262_base_mixer },
5855 .init_verbs = { alc262_init_verbs },
5856 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5857 .dac_nids = alc262_dac_nids,
5858 .hp_nid = 0x03,
5859 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5860 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005861 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 },
Takashi Iwai834be882006-03-01 14:16:17 +01005863 [ALC262_FUJITSU] = {
5864 .mixers = { alc262_fujitsu_mixer },
5865 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5866 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5867 .dac_nids = alc262_dac_nids,
5868 .hp_nid = 0x03,
5869 .dig_out_nid = ALC262_DIGOUT_NID,
5870 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5871 .channel_mode = alc262_modes,
5872 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005873 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01005874 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005875 [ALC262_HP_BPC] = {
5876 .mixers = { alc262_HP_BPC_mixer },
5877 .init_verbs = { alc262_HP_BPC_init_verbs },
5878 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5879 .dac_nids = alc262_dac_nids,
5880 .hp_nid = 0x03,
5881 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5882 .channel_mode = alc262_modes,
5883 .input_mux = &alc262_HP_capture_source,
5884 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005885 [ALC262_BENQ_ED8] = {
5886 .mixers = { alc262_base_mixer },
5887 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5888 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5889 .dac_nids = alc262_dac_nids,
5890 .hp_nid = 0x03,
5891 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5892 .channel_mode = alc262_modes,
5893 .input_mux = &alc262_capture_source,
5894 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005895};
5896
5897static int patch_alc262(struct hda_codec *codec)
5898{
5899 struct alc_spec *spec;
5900 int board_config;
5901 int err;
5902
5903 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5904 if (spec == NULL)
5905 return -ENOMEM;
5906
5907 codec->spec = spec;
5908#if 0
5909 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5910 {
5911 int tmp;
5912 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5913 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5914 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5915 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5916 }
5917#endif
5918
5919 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005920
Kailang Yangdf694da2005-12-05 19:42:22 +01005921 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005922 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5923 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005924 board_config = ALC262_AUTO;
5925 }
5926
5927 if (board_config == ALC262_AUTO) {
5928 /* automatic parse from the BIOS config */
5929 err = alc262_parse_auto_config(codec);
5930 if (err < 0) {
5931 alc_free(codec);
5932 return err;
5933 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005934 printk(KERN_INFO
5935 "hda_codec: Cannot set up configuration "
5936 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005937 board_config = ALC262_BASIC;
5938 }
5939 }
5940
5941 if (board_config != ALC262_AUTO)
5942 setup_preset(spec, &alc262_presets[board_config]);
5943
5944 spec->stream_name_analog = "ALC262 Analog";
5945 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5946 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5947
5948 spec->stream_name_digital = "ALC262 Digital";
5949 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5950 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5951
5952 if (! spec->adc_nids && spec->input_mux) {
5953 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005954 unsigned int wcap = get_wcaps(codec, 0x07);
5955
Kailang Yangdf694da2005-12-05 19:42:22 +01005956 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5957 if (wcap != AC_WID_AUD_IN) {
5958 spec->adc_nids = alc262_adc_nids_alt;
5959 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5960 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5961 spec->num_mixers++;
5962 } else {
5963 spec->adc_nids = alc262_adc_nids;
5964 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5965 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5966 spec->num_mixers++;
5967 }
5968 }
5969
5970 codec->patch_ops = alc_patch_ops;
5971 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005972 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01005973
Kailang Yangdf694da2005-12-05 19:42:22 +01005974 return 0;
5975}
5976
Kailang Yangdf694da2005-12-05 19:42:22 +01005977/*
5978 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5979 */
5980
5981/*
5982 * set the path ways for 2 channel output
5983 * need to set the codec line out and mic 1 pin widgets to inputs
5984 */
5985static struct hda_verb alc861_threestack_ch2_init[] = {
5986 /* set pin widget 1Ah (line in) for input */
5987 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5988 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5989 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5990
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005991 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5992#if 0
5993 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
5995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005996 { } /* end */
5997};
5998/*
5999 * 6ch mode
6000 * need to set the codec line out and mic 1 pin widgets to outputs
6001 */
6002static struct hda_verb alc861_threestack_ch6_init[] = {
6003 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6004 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6005 /* set pin widget 18h (mic1) for output (CLFE)*/
6006 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6007
6008 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006009 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006010
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006011 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6012#if 0
6013 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6014 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6015#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006016 { } /* end */
6017};
6018
6019static struct hda_channel_mode alc861_threestack_modes[2] = {
6020 { 2, alc861_threestack_ch2_init },
6021 { 6, alc861_threestack_ch6_init },
6022};
6023
6024/* patch-ALC861 */
6025
6026static struct snd_kcontrol_new alc861_base_mixer[] = {
6027 /* output mixer control */
6028 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6031 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6032 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6033
6034 /*Input mixer control */
6035 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6036 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6037 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6038 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6039 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6040 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6042 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6043 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6045
6046 /* Capture mixer control */
6047 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6048 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6049 {
6050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6051 .name = "Capture Source",
6052 .count = 1,
6053 .info = alc_mux_enum_info,
6054 .get = alc_mux_enum_get,
6055 .put = alc_mux_enum_put,
6056 },
6057 { } /* end */
6058};
6059
6060static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6061 /* output mixer control */
6062 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6063 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6065 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6066 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6067
6068 /* Input mixer control */
6069 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6070 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6071 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6072 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6073 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6074 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6076 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6079
6080 /* Capture mixer control */
6081 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6082 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6083 {
6084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6085 .name = "Capture Source",
6086 .count = 1,
6087 .info = alc_mux_enum_info,
6088 .get = alc_mux_enum_get,
6089 .put = alc_mux_enum_put,
6090 },
6091 {
6092 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6093 .name = "Channel Mode",
6094 .info = alc_ch_mode_info,
6095 .get = alc_ch_mode_get,
6096 .put = alc_ch_mode_put,
6097 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6098 },
6099 { } /* end */
6100};
6101
6102/*
6103 * generic initialization of ADC, input mixers and output mixers
6104 */
6105static struct hda_verb alc861_base_init_verbs[] = {
6106 /*
6107 * Unmute ADC0 and set the default input to mic-in
6108 */
6109 /* port-A for surround (rear panel) */
6110 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6111 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6112 /* port-B for mic-in (rear panel) with vref */
6113 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6114 /* port-C for line-in (rear panel) */
6115 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6116 /* port-D for Front */
6117 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6118 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6119 /* port-E for HP out (front panel) */
6120 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6121 /* route front PCM to HP */
6122 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6123 /* port-F for mic-in (front panel) with vref */
6124 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6125 /* port-G for CLFE (rear panel) */
6126 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6127 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6128 /* port-H for side (rear panel) */
6129 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6130 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6131 /* CD-in */
6132 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6133 /* route front mic to ADC1*/
6134 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6136
6137 /* Unmute DAC0~3 & spdif out*/
6138 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6139 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6141 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6143
6144 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6145 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6146 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6147 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6148 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6149
6150 /* Unmute Stereo Mixer 15 */
6151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6155
6156 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6158 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6159 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6160 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6164 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6165 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6166
6167 { }
6168};
6169
6170static struct hda_verb alc861_threestack_init_verbs[] = {
6171 /*
6172 * Unmute ADC0 and set the default input to mic-in
6173 */
6174 /* port-A for surround (rear panel) */
6175 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6176 /* port-B for mic-in (rear panel) with vref */
6177 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6178 /* port-C for line-in (rear panel) */
6179 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6180 /* port-D for Front */
6181 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6182 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6183 /* port-E for HP out (front panel) */
6184 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6185 /* route front PCM to HP */
6186 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6187 /* port-F for mic-in (front panel) with vref */
6188 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6189 /* port-G for CLFE (rear panel) */
6190 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6191 /* port-H for side (rear panel) */
6192 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6193 /* CD-in */
6194 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6195 /* route front mic to ADC1*/
6196 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6198 /* Unmute DAC0~3 & spdif out*/
6199 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6200 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6201 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6204
6205 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6206 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6207 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6208 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6209 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6210
6211 /* Unmute Stereo Mixer 15 */
6212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6216
6217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6218 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6222 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6227 { }
6228};
6229/*
6230 * generic initialization of ADC, input mixers and output mixers
6231 */
6232static struct hda_verb alc861_auto_init_verbs[] = {
6233 /*
6234 * Unmute ADC0 and set the default input to mic-in
6235 */
6236// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6238
6239 /* Unmute DAC0~3 & spdif out*/
6240 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6241 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6243 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6245
6246 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6247 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6248 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6249 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6250 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6251
6252 /* Unmute Stereo Mixer 15 */
6253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6257
6258 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6260 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6266
6267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6275
6276 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6277
6278 { }
6279};
6280
6281/* pcm configuration: identiacal with ALC880 */
6282#define alc861_pcm_analog_playback alc880_pcm_analog_playback
6283#define alc861_pcm_analog_capture alc880_pcm_analog_capture
6284#define alc861_pcm_digital_playback alc880_pcm_digital_playback
6285#define alc861_pcm_digital_capture alc880_pcm_digital_capture
6286
6287
6288#define ALC861_DIGOUT_NID 0x07
6289
6290static struct hda_channel_mode alc861_8ch_modes[1] = {
6291 { 8, NULL }
6292};
6293
6294static hda_nid_t alc861_dac_nids[4] = {
6295 /* front, surround, clfe, side */
6296 0x03, 0x06, 0x05, 0x04
6297};
6298
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006299static hda_nid_t alc660_dac_nids[3] = {
6300 /* front, clfe, surround */
6301 0x03, 0x05, 0x06
6302};
6303
Kailang Yangdf694da2005-12-05 19:42:22 +01006304static hda_nid_t alc861_adc_nids[1] = {
6305 /* ADC0-2 */
6306 0x08,
6307};
6308
6309static struct hda_input_mux alc861_capture_source = {
6310 .num_items = 5,
6311 .items = {
6312 { "Mic", 0x0 },
6313 { "Front Mic", 0x3 },
6314 { "Line", 0x1 },
6315 { "CD", 0x4 },
6316 { "Mixer", 0x5 },
6317 },
6318};
6319
6320/* fill in the dac_nids table from the parsed pin configuration */
6321static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6322{
6323 int i;
6324 hda_nid_t nid;
6325
6326 spec->multiout.dac_nids = spec->private_dac_nids;
6327 for (i = 0; i < cfg->line_outs; i++) {
6328 nid = cfg->line_out_pins[i];
6329 if (nid) {
6330 if (i >= ARRAY_SIZE(alc861_dac_nids))
6331 continue;
6332 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6333 }
6334 }
6335 spec->multiout.num_dacs = cfg->line_outs;
6336 return 0;
6337}
6338
6339/* add playback controls from the parsed DAC table */
6340static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6341 const struct auto_pin_cfg *cfg)
6342{
6343 char name[32];
6344 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6345 hda_nid_t nid;
6346 int i, idx, err;
6347
6348 for (i = 0; i < cfg->line_outs; i++) {
6349 nid = spec->multiout.dac_nids[i];
6350 if (! nid)
6351 continue;
6352 if (nid == 0x05) {
6353 /* Center/LFE */
6354 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6355 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6356 return err;
6357 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6358 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6359 return err;
6360 } else {
6361 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6362 if (nid == alc861_dac_nids[idx])
6363 break;
6364 sprintf(name, "%s Playback Switch", chname[idx]);
6365 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6366 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6367 return err;
6368 }
6369 }
6370 return 0;
6371}
6372
6373static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6374{
6375 int err;
6376 hda_nid_t nid;
6377
6378 if (! pin)
6379 return 0;
6380
6381 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6382 nid = 0x03;
6383 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6384 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6385 return err;
6386 spec->multiout.hp_nid = nid;
6387 }
6388 return 0;
6389}
6390
6391/* create playback/capture controls for input pins */
6392static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6393{
Kailang Yangdf694da2005-12-05 19:42:22 +01006394 struct hda_input_mux *imux = &spec->private_imux;
6395 int i, err, idx, idx1;
6396
6397 for (i = 0; i < AUTO_PIN_LAST; i++) {
6398 switch(cfg->input_pins[i]) {
6399 case 0x0c:
6400 idx1 = 1;
6401 idx = 2; // Line In
6402 break;
6403 case 0x0f:
6404 idx1 = 2;
6405 idx = 2; // Line In
6406 break;
6407 case 0x0d:
6408 idx1 = 0;
6409 idx = 1; // Mic In
6410 break;
6411 case 0x10:
6412 idx1 = 3;
6413 idx = 1; // Mic In
6414 break;
6415 case 0x11:
6416 idx1 = 4;
6417 idx = 0; // CD
6418 break;
6419 default:
6420 continue;
6421 }
6422
Takashi Iwai4a471b72005-12-07 13:56:29 +01006423 err = new_analog_input(spec, cfg->input_pins[i],
6424 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01006425 if (err < 0)
6426 return err;
6427
Takashi Iwai4a471b72005-12-07 13:56:29 +01006428 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006429 imux->items[imux->num_items].index = idx1;
6430 imux->num_items++;
6431 }
6432 return 0;
6433}
6434
6435static struct snd_kcontrol_new alc861_capture_mixer[] = {
6436 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6437 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6438
6439 {
6440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6441 /* The multiple "Capture Source" controls confuse alsamixer
6442 * So call somewhat different..
6443 *FIXME: the controls appear in the "playback" view!
6444 */
6445 /* .name = "Capture Source", */
6446 .name = "Input Source",
6447 .count = 1,
6448 .info = alc_mux_enum_info,
6449 .get = alc_mux_enum_get,
6450 .put = alc_mux_enum_put,
6451 },
6452 { } /* end */
6453};
6454
6455static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6456 int pin_type, int dac_idx)
6457{
6458 /* set as output */
6459
6460 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6461 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6462
6463}
6464
6465static void alc861_auto_init_multi_out(struct hda_codec *codec)
6466{
6467 struct alc_spec *spec = codec->spec;
6468 int i;
6469
6470 for (i = 0; i < spec->autocfg.line_outs; i++) {
6471 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6472 if (nid)
6473 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6474 }
6475}
6476
6477static void alc861_auto_init_hp_out(struct hda_codec *codec)
6478{
6479 struct alc_spec *spec = codec->spec;
6480 hda_nid_t pin;
6481
6482 pin = spec->autocfg.hp_pin;
6483 if (pin) /* connect to front */
6484 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6485}
6486
6487static void alc861_auto_init_analog_input(struct hda_codec *codec)
6488{
6489 struct alc_spec *spec = codec->spec;
6490 int i;
6491
6492 for (i = 0; i < AUTO_PIN_LAST; i++) {
6493 hda_nid_t nid = spec->autocfg.input_pins[i];
6494 if ((nid>=0x0c) && (nid <=0x11)) {
6495 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6496 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6497 }
6498 }
6499}
6500
6501/* parse the BIOS configuration and set up the alc_spec */
6502/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6503static int alc861_parse_auto_config(struct hda_codec *codec)
6504{
6505 struct alc_spec *spec = codec->spec;
6506 int err;
6507 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6508
6509 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6510 alc861_ignore)) < 0)
6511 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006512 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006513 return 0; /* can't find valid BIOS pin config */
6514
6515 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6516 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6517 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6518 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6519 return err;
6520
6521 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6522
6523 if (spec->autocfg.dig_out_pin)
6524 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6525
6526 if (spec->kctl_alloc)
6527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6528
6529 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6530
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006531 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006532 spec->input_mux = &spec->private_imux;
6533
6534 spec->adc_nids = alc861_adc_nids;
6535 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6536 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6537 spec->num_mixers++;
6538
6539 return 1;
6540}
6541
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006542/* additional initialization for auto-configuration model */
6543static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006544{
Kailang Yangdf694da2005-12-05 19:42:22 +01006545 alc861_auto_init_multi_out(codec);
6546 alc861_auto_init_hp_out(codec);
6547 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006548}
6549
6550
6551/*
6552 * configuration and preset
6553 */
6554static struct hda_board_config alc861_cfg_tbl[] = {
6555 { .modelname = "3stack", .config = ALC861_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006556 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6557 .config = ALC861_3ST },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006558 { .modelname = "3stack-660", .config = ALC660_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006559 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6560 .config = ALC660_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01006561 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6562 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6563 { .modelname = "auto", .config = ALC861_AUTO },
6564 {}
6565};
6566
6567static struct alc_config_preset alc861_presets[] = {
6568 [ALC861_3ST] = {
6569 .mixers = { alc861_3ST_mixer },
6570 .init_verbs = { alc861_threestack_init_verbs },
6571 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6572 .dac_nids = alc861_dac_nids,
6573 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6574 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006575 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006576 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6577 .adc_nids = alc861_adc_nids,
6578 .input_mux = &alc861_capture_source,
6579 },
6580 [ALC861_3ST_DIG] = {
6581 .mixers = { alc861_base_mixer },
6582 .init_verbs = { alc861_threestack_init_verbs },
6583 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6584 .dac_nids = alc861_dac_nids,
6585 .dig_out_nid = ALC861_DIGOUT_NID,
6586 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6587 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006588 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006589 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6590 .adc_nids = alc861_adc_nids,
6591 .input_mux = &alc861_capture_source,
6592 },
6593 [ALC861_6ST_DIG] = {
6594 .mixers = { alc861_base_mixer },
6595 .init_verbs = { alc861_base_init_verbs },
6596 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6597 .dac_nids = alc861_dac_nids,
6598 .dig_out_nid = ALC861_DIGOUT_NID,
6599 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6600 .channel_mode = alc861_8ch_modes,
6601 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6602 .adc_nids = alc861_adc_nids,
6603 .input_mux = &alc861_capture_source,
6604 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006605 [ALC660_3ST] = {
6606 .mixers = { alc861_3ST_mixer },
6607 .init_verbs = { alc861_threestack_init_verbs },
6608 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6609 .dac_nids = alc660_dac_nids,
6610 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6611 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006612 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006613 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6614 .adc_nids = alc861_adc_nids,
6615 .input_mux = &alc861_capture_source,
6616 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006617};
6618
6619
6620static int patch_alc861(struct hda_codec *codec)
6621{
6622 struct alc_spec *spec;
6623 int board_config;
6624 int err;
6625
6626 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6627 if (spec == NULL)
6628 return -ENOMEM;
6629
6630 codec->spec = spec;
6631
6632 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006633
Kailang Yangdf694da2005-12-05 19:42:22 +01006634 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6636 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006637 board_config = ALC861_AUTO;
6638 }
6639
6640 if (board_config == ALC861_AUTO) {
6641 /* automatic parse from the BIOS config */
6642 err = alc861_parse_auto_config(codec);
6643 if (err < 0) {
6644 alc_free(codec);
6645 return err;
6646 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006647 printk(KERN_INFO
6648 "hda_codec: Cannot set up configuration "
6649 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006650 board_config = ALC861_3ST_DIG;
6651 }
6652 }
6653
6654 if (board_config != ALC861_AUTO)
6655 setup_preset(spec, &alc861_presets[board_config]);
6656
6657 spec->stream_name_analog = "ALC861 Analog";
6658 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6659 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6660
6661 spec->stream_name_digital = "ALC861 Digital";
6662 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6663 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6664
6665 codec->patch_ops = alc_patch_ops;
6666 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006667 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01006668
6669 return 0;
6670}
6671
6672/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006673 * patch entries
6674 */
6675struct hda_codec_preset snd_hda_preset_realtek[] = {
6676 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006678 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6679 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006680 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006681 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006682 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6683 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6684 .patch = patch_alc861 },
6685 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6686 .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006687 {} /* terminator */
6688};