blob: ea4200a4ee428e636234322f8d786574e64acb39 [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 Iwaie9edcee2005-06-13 14:16:38 +020054#ifdef CONFIG_SND_DEBUG
55 ALC880_TEST,
56#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010057 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020058 ALC880_MODEL_LAST /* last tag */
59};
60
61/* ALC260 models */
62enum {
63 ALC260_BASIC,
64 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC260_HP_3013,
66 ALC260_FUJITSU_S702X,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010067#ifdef CONFIG_SND_DEBUG
68 ALC260_TEST,
69#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010070 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020071 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070072};
73
Kailang Yangdf694da2005-12-05 19:42:22 +010074/* ALC262 models */
75enum {
76 ALC262_BASIC,
77 ALC262_AUTO,
78 ALC262_MODEL_LAST /* last tag */
79};
80
81/* ALC861 models */
82enum {
83 ALC861_3ST,
84 ALC861_3ST_DIG,
85 ALC861_6ST_DIG,
86 ALC861_AUTO,
87 ALC861_MODEL_LAST,
88};
89
90/* ALC882 models */
91enum {
92 ALC882_3ST_DIG,
93 ALC882_6ST_DIG,
94 ALC882_AUTO,
95 ALC882_MODEL_LAST,
96};
97
98/* for GPIO Poll */
99#define GPIO_MASK 0x03
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101struct alc_spec {
102 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100103 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 unsigned int num_mixers;
105
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200107 * don't forget NULL termination!
108 */
109 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Takashi Iwai16ded522005-06-10 19:58:24 +0200111 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 struct hda_pcm_stream *stream_analog_playback;
113 struct hda_pcm_stream *stream_analog_capture;
114
Takashi Iwai16ded522005-06-10 19:58:24 +0200115 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 struct hda_pcm_stream *stream_digital_playback;
117 struct hda_pcm_stream *stream_digital_capture;
118
119 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200120 struct hda_multi_out multiout; /* playback set-up
121 * max_channels, dacs must be set
122 * dig_out_nid and hp_nid are optional
123 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
125 /* capture */
126 unsigned int num_adc_nids;
127 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200128 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
130 /* capture source */
131 const struct hda_input_mux *input_mux;
132 unsigned int cur_mux[3];
133
134 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100135 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 int num_channel_mode;
137
138 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100139 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200140
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200141 /* dynamic controls, init_verbs and input_mux */
142 struct auto_pin_cfg autocfg;
143 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100144 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200145 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 hda_nid_t private_dac_nids[5];
147};
148
149/*
150 * configuration template - to be copied to the spec instance
151 */
152struct alc_config_preset {
153 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
154 const struct hda_verb *init_verbs[5];
155 unsigned int num_dacs;
156 hda_nid_t *dac_nids;
157 hda_nid_t dig_out_nid; /* optional */
158 hda_nid_t hp_nid; /* optional */
159 unsigned int num_adc_nids;
160 hda_nid_t *adc_nids;
161 hda_nid_t dig_in_nid;
162 unsigned int num_channel_mode;
163 const struct hda_channel_mode *channel_mode;
164 const struct hda_input_mux *input_mux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165};
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168/*
169 * input MUX handling
170 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100171static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172{
173 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
174 struct alc_spec *spec = codec->spec;
175 return snd_hda_input_mux_info(spec->input_mux, uinfo);
176}
177
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100178static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179{
180 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
181 struct alc_spec *spec = codec->spec;
182 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
183
184 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
185 return 0;
186}
187
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100188static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
191 struct alc_spec *spec = codec->spec;
192 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
193 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
194 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
195}
196
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200197
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198/*
199 * channel mode setting
200 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100201static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202{
203 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
204 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100205 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
206 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207}
208
Kailang Yangdf694da2005-12-05 19:42:22 +0100209static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
211 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
212 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100213 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
214 spec->num_channel_mode, spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215}
216
Kailang Yangdf694da2005-12-05 19:42:22 +0100217static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218{
219 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
220 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100221 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
222 spec->num_channel_mode, &spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223}
224
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100226 * Control the mode of pin widget settings via the mixer. "pc" is used
227 * instead of "%" to avoid consequences of accidently treating the % as
228 * being part of a format specifier. Maximum allowed length of a value is
229 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100230 *
231 * Note: some retasking pin complexes seem to ignore requests for input
232 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
233 * are requested. Therefore order this list so that this behaviour will not
234 * cause problems when mixer clients move through the enum sequentially.
235 * NIDs 0x0f and 0x10 have been observed to have this behaviour.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200236 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100237static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100238 "Mic 50pc bias", "Mic 80pc bias",
239 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100240};
241static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100242 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100243};
244/* The control can present all 5 options, or it can limit the options based
245 * in the pin being assumed to be exclusively an input or an output pin.
246 */
247#define ALC_PIN_DIR_IN 0x00
248#define ALC_PIN_DIR_OUT 0x01
249#define ALC_PIN_DIR_INOUT 0x02
250
251/* Info about the pin modes supported by the three different pin directions.
252 * For each direction the minimum and maximum values are given.
253 */
254static signed char alc_pin_mode_dir_info[3][2] = {
255 { 0, 2 }, /* ALC_PIN_DIR_IN */
256 { 3, 4 }, /* ALC_PIN_DIR_OUT */
257 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
258};
259#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
260#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
261#define alc_pin_mode_n_items(_dir) \
262 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
263
264static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200265{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100266 unsigned int item_num = uinfo->value.enumerated.item;
267 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
268
269 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200270 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100271 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
272
273 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
274 item_num = alc_pin_mode_min(dir);
275 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200276 return 0;
277}
278
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100279static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200280{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100281 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
283 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100284 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200285 long *valp = ucontrol->value.integer.value;
286 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200287
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100288 /* Find enumerated value for current pinctl setting */
289 i = alc_pin_mode_min(dir);
290 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
291 i++;
292 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
293 return 0;
294}
295
296static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
297{
298 signed int change;
299 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
300 hda_nid_t nid = kcontrol->private_value & 0xffff;
301 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
302 long val = *ucontrol->value.integer.value;
303 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
304
305 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
306 val = alc_pin_mode_min(dir);
307
308 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200309 if (change)
310 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100311 alc_pin_mode_values[val]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200312 return change;
313}
314
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100315#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200316 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100317 .info = alc_pin_mode_info, \
318 .get = alc_pin_mode_get, \
319 .put = alc_pin_mode_put, \
320 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100321
322/*
323 * set up from the preset table
324 */
325static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
326{
327 int i;
328
329 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
330 spec->mixers[spec->num_mixers++] = preset->mixers[i];
331 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
332 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
333
334 spec->channel_mode = preset->channel_mode;
335 spec->num_channel_mode = preset->num_channel_mode;
336
337 spec->multiout.max_channels = spec->channel_mode[0].channels;
338
339 spec->multiout.num_dacs = preset->num_dacs;
340 spec->multiout.dac_nids = preset->dac_nids;
341 spec->multiout.dig_out_nid = preset->dig_out_nid;
342 spec->multiout.hp_nid = preset->hp_nid;
343
344 spec->input_mux = preset->input_mux;
345
346 spec->num_adc_nids = preset->num_adc_nids;
347 spec->adc_nids = preset->adc_nids;
348 spec->dig_in_nid = preset->dig_in_nid;
349}
350
Takashi Iwai41e41f12005-06-08 14:48:49 +0200351/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200352 * ALC880 3-stack model
353 *
354 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
355 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
356 * HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 */
358
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200359static hda_nid_t alc880_dac_nids[4] = {
360 /* front, rear, clfe, rear_surr */
361 0x02, 0x05, 0x04, 0x03
362};
363
364static hda_nid_t alc880_adc_nids[3] = {
365 /* ADC0-2 */
366 0x07, 0x08, 0x09,
367};
368
369/* The datasheet says the node 0x07 is connected from inputs,
370 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100371 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200373static hda_nid_t alc880_adc_nids_alt[2] = {
374 /* ADC1-2 */
375 0x08, 0x09,
376};
377
378#define ALC880_DIGOUT_NID 0x06
379#define ALC880_DIGIN_NID 0x0a
380
381static struct hda_input_mux alc880_capture_source = {
382 .num_items = 4,
383 .items = {
384 { "Mic", 0x0 },
385 { "Front Mic", 0x3 },
386 { "Line", 0x2 },
387 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200389};
390
391/* channel source setting (2/6 channel selection for 3-stack) */
392/* 2ch mode */
393static struct hda_verb alc880_threestack_ch2_init[] = {
394 /* set line-in to input, mute it */
395 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
396 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
397 /* set mic-in to input vref 80%, mute it */
398 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
399 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 { } /* end */
401};
402
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200403/* 6ch mode */
404static struct hda_verb alc880_threestack_ch6_init[] = {
405 /* set line-in to output, unmute it */
406 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
407 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
408 /* set mic-in to output, unmute it */
409 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
410 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
411 { } /* end */
412};
413
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100414static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200415 { 2, alc880_threestack_ch2_init },
416 { 6, alc880_threestack_ch6_init },
417};
418
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100419static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100421 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200422 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100423 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200424 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
425 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100426 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
427 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
434 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
436 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
437 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200439 {
440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
441 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100442 .info = alc_ch_mode_info,
443 .get = alc_ch_mode_get,
444 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200445 },
446 { } /* end */
447};
448
449/* capture mixer elements */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100450static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200451 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
452 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
453 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
454 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
455 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
456 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
457 {
458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
459 /* The multiple "Capture Source" controls confuse alsamixer
460 * So call somewhat different..
461 * FIXME: the controls appear in the "playback" view!
462 */
463 /* .name = "Capture Source", */
464 .name = "Input Source",
465 .count = 3,
466 .info = alc_mux_enum_info,
467 .get = alc_mux_enum_get,
468 .put = alc_mux_enum_put,
469 },
470 { } /* end */
471};
472
473/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100474static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
477 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
478 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 {
480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
481 /* The multiple "Capture Source" controls confuse alsamixer
482 * So call somewhat different..
483 * FIXME: the controls appear in the "playback" view!
484 */
485 /* .name = "Capture Source", */
486 .name = "Input Source",
487 .count = 2,
488 .info = alc_mux_enum_info,
489 .get = alc_mux_enum_get,
490 .put = alc_mux_enum_put,
491 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 { } /* end */
493};
494
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200495
496
497/*
498 * ALC880 5-stack model
499 *
500 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
501 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
502 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
503 */
504
505/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100506static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200507 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100508 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 { } /* end */
510};
511
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200512/* channel source setting (6/8 channel selection for 5-stack) */
513/* 6ch mode */
514static struct hda_verb alc880_fivestack_ch6_init[] = {
515 /* set line-in to input, mute it */
516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
517 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200518 { } /* end */
519};
520
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200521/* 8ch mode */
522static struct hda_verb alc880_fivestack_ch8_init[] = {
523 /* set line-in to output, unmute it */
524 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
525 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
526 { } /* end */
527};
528
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100529static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200530 { 6, alc880_fivestack_ch6_init },
531 { 8, alc880_fivestack_ch8_init },
532};
533
534
535/*
536 * ALC880 6-stack model
537 *
538 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
539 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
540 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
541 */
542
543static hda_nid_t alc880_6st_dac_nids[4] = {
544 /* front, rear, clfe, rear_surr */
545 0x02, 0x03, 0x04, 0x05
546};
547
548static struct hda_input_mux alc880_6stack_capture_source = {
549 .num_items = 4,
550 .items = {
551 { "Mic", 0x0 },
552 { "Front Mic", 0x1 },
553 { "Line", 0x2 },
554 { "CD", 0x4 },
555 },
556};
557
558/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100559static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200560 { 8, NULL },
561};
562
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100563static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200564 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100565 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100567 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200572 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100573 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
576 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
577 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
582 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
583 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200584 {
585 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
586 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100587 .info = alc_ch_mode_info,
588 .get = alc_ch_mode_get,
589 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200590 },
591 { } /* end */
592};
593
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200594
595/*
596 * ALC880 W810 model
597 *
598 * W810 has rear IO for:
599 * Front (DAC 02)
600 * Surround (DAC 03)
601 * Center/LFE (DAC 04)
602 * Digital out (06)
603 *
604 * The system also has a pair of internal speakers, and a headphone jack.
605 * These are both connected to Line2 on the codec, hence to DAC 02.
606 *
607 * There is a variable resistor to control the speaker or headphone
608 * volume. This is a hardware-only device without a software API.
609 *
610 * Plugging headphones in will disable the internal speakers. This is
611 * implemented in hardware, not via the driver using jack sense. In
612 * a similar fashion, plugging into the rear socket marked "front" will
613 * disable both the speakers and headphones.
614 *
615 * For input, there's a microphone jack, and an "audio in" jack.
616 * These may not do anything useful with this driver yet, because I
617 * haven't setup any initialization verbs for these yet...
618 */
619
620static hda_nid_t alc880_w810_dac_nids[3] = {
621 /* front, rear/surround, clfe */
622 0x02, 0x03, 0x04
623};
624
625/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100626static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200627 { 6, NULL }
628};
629
630/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100631static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200634 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100635 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200636 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
637 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100638 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
639 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
641 { } /* end */
642};
643
644
645/*
646 * Z710V model
647 *
648 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
649 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
650 */
651
652static hda_nid_t alc880_z71v_dac_nids[1] = {
653 0x02
654};
655#define ALC880_Z71V_HP_DAC 0x03
656
657/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100658static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200659 { 2, NULL }
660};
661
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100662static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200663 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100664 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200665 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100666 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
671 { } /* end */
672};
673
674
675/* FIXME! */
676/*
677 * ALC880 F1734 model
678 *
679 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
680 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
681 */
682
683static hda_nid_t alc880_f1734_dac_nids[1] = {
684 0x03
685};
686#define ALC880_F1734_HP_DAC 0x02
687
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100688static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200689 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100690 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200691 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100692 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200693 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
694 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200697 { } /* end */
698};
699
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200700
701/* FIXME! */
702/*
703 * ALC880 ASUS model
704 *
705 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
706 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
707 * Mic = 0x18, Line = 0x1a
708 */
709
710#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
711#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
712
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100713static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200714 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100715 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200716 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100717 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200718 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
719 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100720 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
721 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200722 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
723 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
724 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
725 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200728 {
729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
730 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100731 .info = alc_ch_mode_info,
732 .get = alc_ch_mode_get,
733 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200734 },
735 { } /* end */
736};
737
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200738/* FIXME! */
739/*
740 * ALC880 ASUS W1V model
741 *
742 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
743 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
744 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
745 */
746
747/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100748static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200749 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
750 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200751 { } /* end */
752};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200753
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200754/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100755static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200756 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
757 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
758 { } /* end */
759};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200760
Kailang Yangdf694da2005-12-05 19:42:22 +0100761/* TCL S700 */
762static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
763 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
764 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
767 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
770 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
771 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
772 {
773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
774 /* The multiple "Capture Source" controls confuse alsamixer
775 * So call somewhat different..
776 * FIXME: the controls appear in the "playback" view!
777 */
778 /* .name = "Capture Source", */
779 .name = "Input Source",
780 .count = 1,
781 .info = alc_mux_enum_info,
782 .get = alc_mux_enum_get,
783 .put = alc_mux_enum_put,
784 },
785 { } /* end */
786};
787
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200789 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 */
791static int alc_build_controls(struct hda_codec *codec)
792{
793 struct alc_spec *spec = codec->spec;
794 int err;
795 int i;
796
797 for (i = 0; i < spec->num_mixers; i++) {
798 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
799 if (err < 0)
800 return err;
801 }
802
803 if (spec->multiout.dig_out_nid) {
804 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
805 if (err < 0)
806 return err;
807 }
808 if (spec->dig_in_nid) {
809 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
810 if (err < 0)
811 return err;
812 }
813 return 0;
814}
815
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200816
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817/*
818 * initialize the codec volumes, etc
819 */
820
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200821/*
822 * generic initialization of ADC, input mixers and output mixers
823 */
824static struct hda_verb alc880_volume_init_verbs[] = {
825 /*
826 * Unmute ADC0-2 and set the default input to mic-in
827 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200828 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200830 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200832 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200833 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200835 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
836 * mixer widget
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 * Note: PASD motherboards uses the Line In 2 as the input for front panel
838 * mic (mic 2)
839 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200840 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200847 /*
848 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200850 /* set vol=0 to output mixers */
851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
854 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
855 /* set up input amps for analog loopback */
856 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +0200857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200863 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
864 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865
866 { }
867};
868
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200869/*
870 * 3-stack pin configuration:
871 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
872 */
873static struct hda_verb alc880_pin_3stack_init_verbs[] = {
874 /*
875 * preset connection lists of input pins
876 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
877 */
878 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
879 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
880 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
881
882 /*
883 * Set pin mode and muting
884 */
885 /* set front pin widgets 0x14 for output */
886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
888 /* Mic1 (rear panel) pin widget for input and vref at 80% */
889 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
891 /* Mic2 (as headphone out) for HP output */
892 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
894 /* Line In pin widget for input */
895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
897 /* Line2 (as front mic) pin widget for input and vref at 80% */
898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
900 /* CD pin widget for input */
901 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
902
903 { }
904};
905
906/*
907 * 5-stack pin configuration:
908 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
909 * line-in/side = 0x1a, f-mic = 0x1b
910 */
911static struct hda_verb alc880_pin_5stack_init_verbs[] = {
912 /*
913 * preset connection lists of input pins
914 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
915 */
916 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
917 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
918
919 /*
920 * Set pin mode and muting
921 */
922 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +0200923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
924 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
925 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
926 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200927 /* unmute pins for output (no gain on this amp) */
928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
930 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
932
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +0200934 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200935 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
936 /* Mic2 (as headphone out) for HP output */
937 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +0200938 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200939 /* Line In pin widget for input */
940 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
941 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
942 /* Line2 (as front mic) pin widget for input and vref at 80% */
943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
945 /* CD pin widget for input */
946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947
948 { }
949};
950
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200951/*
952 * W810 pin configuration:
953 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
954 */
955static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 /* hphone/speaker input selector: front DAC */
957 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
958
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
963 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
965
966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +0200967 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 { }
970};
971
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200972/*
973 * Z71V pin configuration:
974 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
975 */
976static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +0200979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200981
Takashi Iwai16ded522005-06-10 19:58:24 +0200982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200983 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +0200984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200985 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200986
987 { }
988};
989
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200990/*
991 * 6-stack pin configuration:
992 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
993 * line = 0x1a, HP = 0x1b
994 */
995static struct hda_verb alc880_pin_6stack_init_verbs[] = {
996 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
997
Takashi Iwai16ded522005-06-10 19:58:24 +0200998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200999 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001000 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001002 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001004 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001005 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1006
Takashi Iwai16ded522005-06-10 19:58:24 +02001007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001009 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001010 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001013 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001014 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001015 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1016
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001017 { }
1018};
Takashi Iwai16ded522005-06-10 19:58:24 +02001019
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001020/* FIXME! */
1021/*
1022 * F1734 pin configuration:
1023 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1024 */
1025static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1026 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1027 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1028 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1029 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1030
1031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1035
1036 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1037 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1038 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1039 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1040 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1041 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1042 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1043 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1044 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001045
1046 { }
1047};
1048
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001049/* FIXME! */
1050/*
1051 * ASUS pin configuration:
1052 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1053 */
1054static struct hda_verb alc880_pin_asus_init_verbs[] = {
1055 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1056 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1057 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1058 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1059
1060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1063 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1066 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1067 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1068
1069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1071 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1073 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1074 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1076 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1077 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1078
1079 { }
1080};
1081
1082/* Enable GPIO mask and set output */
1083static struct hda_verb alc880_gpio1_init_verbs[] = {
1084 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1085 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1086 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001087
1088 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001089};
1090
1091/* Enable GPIO mask and set output */
1092static struct hda_verb alc880_gpio2_init_verbs[] = {
1093 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1094 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1095 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001096
1097 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001098};
1099
Kailang Yangdf694da2005-12-05 19:42:22 +01001100/* Clevo m520g init */
1101static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1102 /* headphone output */
1103 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1104 /* line-out */
1105 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1107 /* Line-in */
1108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1109 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1110 /* CD */
1111 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1112 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1113 /* Mic1 (rear panel) */
1114 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1115 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1116 /* Mic2 (front panel) */
1117 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1118 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1119 /* headphone */
1120 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1121 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1122 /* change to EAPD mode */
1123 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1124 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1125
1126 { }
1127};
1128
1129static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1130 /* Headphone output */
1131 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1132 /* Front output*/
1133 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1134 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1135
1136 /* Line In pin widget for input */
1137 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1138 /* CD pin widget for input */
1139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1140 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1141 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1142
1143 /* change to EAPD mode */
1144 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1145 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1146
1147 { }
1148};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001149
1150/*
1151 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001152
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153static int alc_init(struct hda_codec *codec)
1154{
1155 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156 unsigned int i;
1157
1158 for (i = 0; i < spec->num_init_verbs; i++)
1159 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 return 0;
1161}
1162
1163#ifdef CONFIG_PM
1164/*
1165 * resume
1166 */
1167static int alc_resume(struct hda_codec *codec)
1168{
1169 struct alc_spec *spec = codec->spec;
1170 int i;
1171
1172 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001173 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 if (spec->multiout.dig_out_nid)
1176 snd_hda_resume_spdif_out(codec);
1177 if (spec->dig_in_nid)
1178 snd_hda_resume_spdif_in(codec);
1179
1180 return 0;
1181}
1182#endif
1183
1184/*
1185 * Analog playback callbacks
1186 */
1187static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1188 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001189 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190{
1191 struct alc_spec *spec = codec->spec;
1192 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1193}
1194
1195static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1196 struct hda_codec *codec,
1197 unsigned int stream_tag,
1198 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001199 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200{
1201 struct alc_spec *spec = codec->spec;
1202 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1203 format, substream);
1204}
1205
1206static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1207 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001208 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209{
1210 struct alc_spec *spec = codec->spec;
1211 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1212}
1213
1214/*
1215 * Digital out
1216 */
1217static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1218 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001219 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220{
1221 struct alc_spec *spec = codec->spec;
1222 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1223}
1224
1225static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1226 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001227 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228{
1229 struct alc_spec *spec = codec->spec;
1230 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1231}
1232
1233/*
1234 * Analog capture
1235 */
1236static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1237 struct hda_codec *codec,
1238 unsigned int stream_tag,
1239 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001240 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241{
1242 struct alc_spec *spec = codec->spec;
1243
1244 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1245 stream_tag, 0, format);
1246 return 0;
1247}
1248
1249static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1250 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001251 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252{
1253 struct alc_spec *spec = codec->spec;
1254
1255 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1256 return 0;
1257}
1258
1259
1260/*
1261 */
1262static struct hda_pcm_stream alc880_pcm_analog_playback = {
1263 .substreams = 1,
1264 .channels_min = 2,
1265 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 .ops = {
1268 .open = alc880_playback_pcm_open,
1269 .prepare = alc880_playback_pcm_prepare,
1270 .cleanup = alc880_playback_pcm_cleanup
1271 },
1272};
1273
1274static struct hda_pcm_stream alc880_pcm_analog_capture = {
1275 .substreams = 2,
1276 .channels_min = 2,
1277 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001278 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 .ops = {
1280 .prepare = alc880_capture_pcm_prepare,
1281 .cleanup = alc880_capture_pcm_cleanup
1282 },
1283};
1284
1285static struct hda_pcm_stream alc880_pcm_digital_playback = {
1286 .substreams = 1,
1287 .channels_min = 2,
1288 .channels_max = 2,
1289 /* NID is set in alc_build_pcms */
1290 .ops = {
1291 .open = alc880_dig_playback_pcm_open,
1292 .close = alc880_dig_playback_pcm_close
1293 },
1294};
1295
1296static struct hda_pcm_stream alc880_pcm_digital_capture = {
1297 .substreams = 1,
1298 .channels_min = 2,
1299 .channels_max = 2,
1300 /* NID is set in alc_build_pcms */
1301};
1302
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001303/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1304static struct hda_pcm_stream alc_pcm_null_playback = {
1305 .substreams = 0,
1306 .channels_min = 0,
1307 .channels_max = 0,
1308};
1309
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310static int alc_build_pcms(struct hda_codec *codec)
1311{
1312 struct alc_spec *spec = codec->spec;
1313 struct hda_pcm *info = spec->pcm_rec;
1314 int i;
1315
1316 codec->num_pcms = 1;
1317 codec->pcm_info = info;
1318
1319 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001320 if (spec->stream_analog_playback) {
1321 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1322 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1323 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1324 }
1325 if (spec->stream_analog_capture) {
1326 snd_assert(spec->adc_nids, return -EINVAL);
1327 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1328 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1329 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330
Takashi Iwai4a471b72005-12-07 13:56:29 +01001331 if (spec->channel_mode) {
1332 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1333 for (i = 0; i < spec->num_channel_mode; i++) {
1334 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1335 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1336 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 }
1338 }
1339
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001340 /* If the use of more than one ADC is requested for the current
1341 * model, configure a second analog capture-only PCM.
1342 */
1343 if (spec->num_adc_nids > 1) {
1344 codec->num_pcms++;
1345 info++;
1346 info->name = spec->stream_name_analog;
1347 /* No playback stream for second PCM */
1348 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1349 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1350 if (spec->stream_analog_capture) {
1351 snd_assert(spec->adc_nids, return -EINVAL);
1352 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1353 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1354 }
1355 }
1356
Linus Torvalds1da177e2005-04-16 15:20:36 -07001357 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1358 codec->num_pcms++;
1359 info++;
1360 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001361 if (spec->multiout.dig_out_nid &&
1362 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1364 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1365 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001366 if (spec->dig_in_nid &&
1367 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1369 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1370 }
1371 }
1372
1373 return 0;
1374}
1375
1376static void alc_free(struct hda_codec *codec)
1377{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001378 struct alc_spec *spec = codec->spec;
1379 unsigned int i;
1380
1381 if (! spec)
1382 return;
1383
1384 if (spec->kctl_alloc) {
1385 for (i = 0; i < spec->num_kctl_used; i++)
1386 kfree(spec->kctl_alloc[i].name);
1387 kfree(spec->kctl_alloc);
1388 }
1389 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390}
1391
1392/*
1393 */
1394static struct hda_codec_ops alc_patch_ops = {
1395 .build_controls = alc_build_controls,
1396 .build_pcms = alc_build_pcms,
1397 .init = alc_init,
1398 .free = alc_free,
1399#ifdef CONFIG_PM
1400 .resume = alc_resume,
1401#endif
1402};
1403
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001404
1405/*
1406 * Test configuration for debugging
1407 *
1408 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1409 * enum controls.
1410 */
1411#ifdef CONFIG_SND_DEBUG
1412static hda_nid_t alc880_test_dac_nids[4] = {
1413 0x02, 0x03, 0x04, 0x05
1414};
1415
1416static struct hda_input_mux alc880_test_capture_source = {
1417 .num_items = 5,
1418 .items = {
1419 { "In-1", 0x0 },
1420 { "In-2", 0x1 },
1421 { "In-3", 0x2 },
1422 { "In-4", 0x3 },
1423 { "CD", 0x4 },
1424 },
1425};
1426
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001427static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001428 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001429 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001430 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001431 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001432};
1433
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001434static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001435{
1436 static char *texts[] = {
1437 "N/A", "Line Out", "HP Out",
1438 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1439 };
1440 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1441 uinfo->count = 1;
1442 uinfo->value.enumerated.items = 8;
1443 if (uinfo->value.enumerated.item >= 8)
1444 uinfo->value.enumerated.item = 7;
1445 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1446 return 0;
1447}
1448
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001449static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001450{
1451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1452 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1453 unsigned int pin_ctl, item = 0;
1454
1455 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1456 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1457 if (pin_ctl & AC_PINCTL_OUT_EN) {
1458 if (pin_ctl & AC_PINCTL_HP_EN)
1459 item = 2;
1460 else
1461 item = 1;
1462 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1463 switch (pin_ctl & AC_PINCTL_VREFEN) {
1464 case AC_PINCTL_VREF_HIZ: item = 3; break;
1465 case AC_PINCTL_VREF_50: item = 4; break;
1466 case AC_PINCTL_VREF_GRD: item = 5; break;
1467 case AC_PINCTL_VREF_80: item = 6; break;
1468 case AC_PINCTL_VREF_100: item = 7; break;
1469 }
1470 }
1471 ucontrol->value.enumerated.item[0] = item;
1472 return 0;
1473}
1474
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001475static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001476{
1477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1478 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1479 static unsigned int ctls[] = {
1480 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1481 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1482 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1483 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1484 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1485 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1486 };
1487 unsigned int old_ctl, new_ctl;
1488
1489 old_ctl = snd_hda_codec_read(codec, nid, 0,
1490 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1491 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1492 if (old_ctl != new_ctl) {
1493 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1495 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1496 return 1;
1497 }
1498 return 0;
1499}
1500
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001501static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001502{
1503 static char *texts[] = {
1504 "Front", "Surround", "CLFE", "Side"
1505 };
1506 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1507 uinfo->count = 1;
1508 uinfo->value.enumerated.items = 4;
1509 if (uinfo->value.enumerated.item >= 4)
1510 uinfo->value.enumerated.item = 3;
1511 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1512 return 0;
1513}
1514
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001515static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001516{
1517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1518 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1519 unsigned int sel;
1520
1521 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1522 ucontrol->value.enumerated.item[0] = sel & 3;
1523 return 0;
1524}
1525
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001526static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001527{
1528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1529 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1530 unsigned int sel;
1531
1532 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1533 if (ucontrol->value.enumerated.item[0] != sel) {
1534 sel = ucontrol->value.enumerated.item[0] & 3;
1535 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1536 return 1;
1537 }
1538 return 0;
1539}
1540
1541#define PIN_CTL_TEST(xname,nid) { \
1542 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1543 .name = xname, \
1544 .info = alc_test_pin_ctl_info, \
1545 .get = alc_test_pin_ctl_get, \
1546 .put = alc_test_pin_ctl_put, \
1547 .private_value = nid \
1548 }
1549
1550#define PIN_SRC_TEST(xname,nid) { \
1551 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1552 .name = xname, \
1553 .info = alc_test_pin_src_info, \
1554 .get = alc_test_pin_src_get, \
1555 .put = alc_test_pin_src_put, \
1556 .private_value = nid \
1557 }
1558
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001559static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001560 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1561 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1562 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1563 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001564 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1565 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1566 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1567 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001568 PIN_CTL_TEST("Front Pin Mode", 0x14),
1569 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1570 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1571 PIN_CTL_TEST("Side Pin Mode", 0x17),
1572 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1573 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1574 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1575 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1576 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1577 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1578 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1579 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1580 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1581 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1582 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1583 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1584 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1585 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1586 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1587 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001590 {
1591 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1592 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001593 .info = alc_ch_mode_info,
1594 .get = alc_ch_mode_get,
1595 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001596 },
1597 { } /* end */
1598};
1599
1600static struct hda_verb alc880_test_init_verbs[] = {
1601 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1606 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1608 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001610 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1612 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1613 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1614 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001615 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1619 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001620 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1623 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1624 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001625 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02001626 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1627 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02001628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001631 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02001632 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1634 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1635 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001636 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02001637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001638 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001639 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001640 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001642 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001643 /* Analog input/passthru */
1644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001649 { }
1650};
1651#endif
1652
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653/*
1654 */
1655
1656static struct hda_board_config alc880_cfg_tbl[] = {
1657 /* Back 3 jack, front 2 jack */
1658 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001659 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1660 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1661 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1662 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1663 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1664 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1665 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1666 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1667 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1668 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1669 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1670 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1671 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1672 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1673 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1674 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1675 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1676 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1677 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1678 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1679 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1680 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1681 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1682 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1683 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1684 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1685 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1686 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1687 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1688 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1689 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1690 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01001691 /* TCL S700 */
1692 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693
1694 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02001695 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001696 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02001697 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698
1699 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1700 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001701 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe32005-08-15 20:01:40 +02001702 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01001703 /* Clevo m520G NB */
1704 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705
1706 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02001707 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1708 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1709 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710
1711 /* Back 5 jack, front 2 jack */
1712 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001713 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1714 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1715 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1716 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001717 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718
1719 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1720 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001721 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1722 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1723 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1724 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1725 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1726 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1727 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1728 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwai7a318a72005-06-28 14:16:21 +02001730 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02001731 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001732 /* note subvendor = 0 below */
1733 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734
1735 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02001736 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001738 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02001739 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001740
Takashi Iwaib6482d42005-06-27 15:32:43 +02001741 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01001742 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01001743 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02001744 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01001745 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02001746
1747 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001748 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1749 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1750 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1751 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01001752 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
1753 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
1754 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
1755 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01001756 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001757
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001758 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02001759 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1760 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1761 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1762 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02001763 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001764 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1765 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1766 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1767 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1768 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1769 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Kailang Yangdf694da2005-12-05 19:42:22 +01001770 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001771
1772 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1773 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1774
1775 { .modelname = "F1734", .config = ALC880_F1734 },
1776 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001777 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001778
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001779#ifdef CONFIG_SND_DEBUG
1780 { .modelname = "test", .config = ALC880_TEST },
1781#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01001782 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001783
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 {}
1785};
1786
Takashi Iwai16ded522005-06-10 19:58:24 +02001787/*
Kailang Yangdf694da2005-12-05 19:42:22 +01001788 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02001789 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001790static struct alc_config_preset alc880_presets[] = {
1791 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 .mixers = { alc880_three_stack_mixer },
1793 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001794 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02001795 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001796 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1797 .channel_mode = alc880_threestack_modes,
1798 .input_mux = &alc880_capture_source,
1799 },
1800 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001801 .mixers = { alc880_three_stack_mixer },
1802 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001803 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02001804 .dac_nids = alc880_dac_nids,
1805 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001806 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1807 .channel_mode = alc880_threestack_modes,
1808 .input_mux = &alc880_capture_source,
1809 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001810 [ALC880_TCL_S700] = {
1811 .mixers = { alc880_tcl_s700_mixer },
1812 .init_verbs = { alc880_volume_init_verbs,
1813 alc880_pin_tcl_S700_init_verbs,
1814 alc880_gpio2_init_verbs },
1815 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1816 .dac_nids = alc880_dac_nids,
1817 .hp_nid = 0x03,
1818 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1819 .channel_mode = alc880_2_jack_modes,
1820 .input_mux = &alc880_capture_source,
1821 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001822 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001823 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1824 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1826 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001827 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1828 .channel_mode = alc880_fivestack_modes,
1829 .input_mux = &alc880_capture_source,
1830 },
1831 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1833 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001834 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1835 .dac_nids = alc880_dac_nids,
1836 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001837 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1838 .channel_mode = alc880_fivestack_modes,
1839 .input_mux = &alc880_capture_source,
1840 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02001841 [ALC880_6ST] = {
1842 .mixers = { alc880_six_stack_mixer },
1843 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1844 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1845 .dac_nids = alc880_6st_dac_nids,
1846 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1847 .channel_mode = alc880_sixstack_modes,
1848 .input_mux = &alc880_6stack_capture_source,
1849 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001850 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001851 .mixers = { alc880_six_stack_mixer },
1852 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001853 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1854 .dac_nids = alc880_6st_dac_nids,
1855 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001856 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1857 .channel_mode = alc880_sixstack_modes,
1858 .input_mux = &alc880_6stack_capture_source,
1859 },
1860 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001862 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1863 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001864 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1865 .dac_nids = alc880_w810_dac_nids,
1866 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001867 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1868 .channel_mode = alc880_w810_modes,
1869 .input_mux = &alc880_capture_source,
1870 },
1871 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001872 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001873 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001874 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1875 .dac_nids = alc880_z71v_dac_nids,
1876 .dig_out_nid = ALC880_DIGOUT_NID,
1877 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1879 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001880 .input_mux = &alc880_capture_source,
1881 },
1882 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883 .mixers = { alc880_f1734_mixer },
1884 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1885 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1886 .dac_nids = alc880_f1734_dac_nids,
1887 .hp_nid = 0x02,
1888 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1889 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001890 .input_mux = &alc880_capture_source,
1891 },
1892 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001893 .mixers = { alc880_asus_mixer },
1894 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1895 alc880_gpio1_init_verbs },
1896 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1897 .dac_nids = alc880_asus_dac_nids,
1898 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1899 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001900 .input_mux = &alc880_capture_source,
1901 },
1902 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 .mixers = { alc880_asus_mixer },
1904 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1905 alc880_gpio1_init_verbs },
1906 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1907 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001908 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1910 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001911 .input_mux = &alc880_capture_source,
1912 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001913 [ALC880_ASUS_DIG2] = {
1914 .mixers = { alc880_asus_mixer },
1915 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1916 alc880_gpio2_init_verbs }, /* use GPIO2 */
1917 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1918 .dac_nids = alc880_asus_dac_nids,
1919 .dig_out_nid = ALC880_DIGOUT_NID,
1920 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1921 .channel_mode = alc880_asus_modes,
1922 .input_mux = &alc880_capture_source,
1923 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001924 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001925 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1926 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1927 alc880_gpio1_init_verbs },
1928 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1929 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001930 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1932 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001933 .input_mux = &alc880_capture_source,
1934 },
1935 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001936 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001937 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1938 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1939 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001940 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001941 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1942 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001943 .input_mux = &alc880_capture_source,
1944 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001945 [ALC880_CLEVO] = {
1946 .mixers = { alc880_three_stack_mixer },
1947 .init_verbs = { alc880_volume_init_verbs,
1948 alc880_pin_clevo_init_verbs },
1949 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1950 .dac_nids = alc880_dac_nids,
1951 .hp_nid = 0x03,
1952 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1953 .channel_mode = alc880_threestack_modes,
1954 .input_mux = &alc880_capture_source,
1955 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001956#ifdef CONFIG_SND_DEBUG
1957 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001958 .mixers = { alc880_test_mixer },
1959 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001960 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1961 .dac_nids = alc880_test_dac_nids,
1962 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001963 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1964 .channel_mode = alc880_test_modes,
1965 .input_mux = &alc880_test_capture_source,
1966 },
1967#endif
1968};
1969
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001970/*
1971 * Automatic parse of I/O pins from the BIOS configuration
1972 */
1973
1974#define NUM_CONTROL_ALLOC 32
1975#define NUM_VERB_ALLOC 32
1976
1977enum {
1978 ALC_CTL_WIDGET_VOL,
1979 ALC_CTL_WIDGET_MUTE,
1980 ALC_CTL_BIND_MUTE,
1981};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001982static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001983 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1984 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01001985 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001986};
1987
1988/* add dynamic controls */
1989static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1990{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001991 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001992
1993 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1994 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1995
1996 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1997 if (! knew)
1998 return -ENOMEM;
1999 if (spec->kctl_alloc) {
2000 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2001 kfree(spec->kctl_alloc);
2002 }
2003 spec->kctl_alloc = knew;
2004 spec->num_kctl_alloc = num;
2005 }
2006
2007 knew = &spec->kctl_alloc[spec->num_kctl_used];
2008 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002009 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002010 if (! knew->name)
2011 return -ENOMEM;
2012 knew->private_value = val;
2013 spec->num_kctl_used++;
2014 return 0;
2015}
2016
2017#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2018#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2019#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2020#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2021#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2022#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2023#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2024#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2025#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2026#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2027#define ALC880_PIN_CD_NID 0x1c
2028
2029/* fill in the dac_nids table from the parsed pin configuration */
2030static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2031{
2032 hda_nid_t nid;
2033 int assigned[4];
2034 int i, j;
2035
2036 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002037 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002038
2039 /* check the pins hardwired to audio widget */
2040 for (i = 0; i < cfg->line_outs; i++) {
2041 nid = cfg->line_out_pins[i];
2042 if (alc880_is_fixed_pin(nid)) {
2043 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002044 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045 assigned[idx] = 1;
2046 }
2047 }
2048 /* left pins can be connect to any audio widget */
2049 for (i = 0; i < cfg->line_outs; i++) {
2050 nid = cfg->line_out_pins[i];
2051 if (alc880_is_fixed_pin(nid))
2052 continue;
2053 /* search for an empty channel */
2054 for (j = 0; j < cfg->line_outs; j++) {
2055 if (! assigned[j]) {
2056 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2057 assigned[j] = 1;
2058 break;
2059 }
2060 }
2061 }
2062 spec->multiout.num_dacs = cfg->line_outs;
2063 return 0;
2064}
2065
2066/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002067static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2068 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069{
2070 char name[32];
2071 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2072 hda_nid_t nid;
2073 int i, err;
2074
2075 for (i = 0; i < cfg->line_outs; i++) {
2076 if (! spec->multiout.dac_nids[i])
2077 continue;
2078 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2079 if (i == 2) {
2080 /* Center/LFE */
2081 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2082 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2083 return err;
2084 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2085 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2086 return err;
2087 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2088 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2089 return err;
2090 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2091 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2092 return err;
2093 } else {
2094 sprintf(name, "%s Playback Volume", chname[i]);
2095 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2096 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2097 return err;
2098 sprintf(name, "%s Playback Switch", chname[i]);
2099 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2100 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2101 return err;
2102 }
2103 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002104 return 0;
2105}
2106
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002107/* add playback controls for speaker and HP outputs */
2108static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2109 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002110{
2111 hda_nid_t nid;
2112 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002113 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114
2115 if (! pin)
2116 return 0;
2117
2118 if (alc880_is_fixed_pin(pin)) {
2119 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2120 if (! spec->multiout.dac_nids[0]) {
2121 /* use this as the primary output */
2122 spec->multiout.dac_nids[0] = nid;
2123 if (! spec->multiout.num_dacs)
2124 spec->multiout.num_dacs = 1;
2125 } else
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002126 /* specify the DAC as the extra output */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002127 spec->multiout.hp_nid = nid;
2128 /* control HP volume/switch on the output mixer amp */
2129 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002130 sprintf(name, "%s Playback Volume", pfx);
2131 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002132 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2133 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002134 sprintf(name, "%s Playback Switch", pfx);
2135 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002136 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2137 return err;
2138 } else if (alc880_is_multi_pin(pin)) {
2139 /* set manual connection */
2140 if (! spec->multiout.dac_nids[0]) {
2141 /* use this as the primary output */
2142 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
2143 if (! spec->multiout.num_dacs)
2144 spec->multiout.num_dacs = 1;
2145 }
2146 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002147 sprintf(name, "%s Playback Switch", pfx);
2148 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002149 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2150 return err;
2151 }
2152 return 0;
2153}
2154
2155/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002156static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2157 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002158{
2159 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002160 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002161
2162 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002163 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002164 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002165 return err;
2166 sprintf(name, "%s Playback Switch", ctlname);
2167 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002168 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 return err;
2170 return 0;
2171}
2172
2173/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002174static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2175 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002177 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002178 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179
2180 for (i = 0; i < AUTO_PIN_LAST; i++) {
2181 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002182 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002183 err = new_analog_input(spec, cfg->input_pins[i],
2184 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002185 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002186 if (err < 0)
2187 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002188 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2190 imux->num_items++;
2191 }
2192 }
2193 return 0;
2194}
2195
Kailang Yangdf694da2005-12-05 19:42:22 +01002196static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2197 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 int dac_idx)
2199{
2200 /* set as output */
2201 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2202 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2203 /* need the manual connection? */
2204 if (alc880_is_multi_pin(nid)) {
2205 struct alc_spec *spec = codec->spec;
2206 int idx = alc880_multi_pin_idx(nid);
2207 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2208 AC_VERB_SET_CONNECT_SEL,
2209 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2210 }
2211}
2212
2213static void alc880_auto_init_multi_out(struct hda_codec *codec)
2214{
2215 struct alc_spec *spec = codec->spec;
2216 int i;
2217
2218 for (i = 0; i < spec->autocfg.line_outs; i++) {
2219 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2220 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2221 }
2222}
2223
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002224static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225{
2226 struct alc_spec *spec = codec->spec;
2227 hda_nid_t pin;
2228
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002229 pin = spec->autocfg.speaker_pin;
2230 if (pin) /* connect to front */
2231 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232 pin = spec->autocfg.hp_pin;
2233 if (pin) /* connect to front */
2234 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2235}
2236
2237static void alc880_auto_init_analog_input(struct hda_codec *codec)
2238{
2239 struct alc_spec *spec = codec->spec;
2240 int i;
2241
2242 for (i = 0; i < AUTO_PIN_LAST; i++) {
2243 hda_nid_t nid = spec->autocfg.input_pins[i];
2244 if (alc880_is_input_pin(nid)) {
2245 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2246 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2247 if (nid != ALC880_PIN_CD_NID)
2248 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2249 AMP_OUT_MUTE);
2250 }
2251 }
2252}
2253
2254/* parse the BIOS configuration and set up the alc_spec */
2255/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2256static int alc880_parse_auto_config(struct hda_codec *codec)
2257{
2258 struct alc_spec *spec = codec->spec;
2259 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002260 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002261
Kailang Yangdf694da2005-12-05 19:42:22 +01002262 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2263 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002264 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002265 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
2266 ! spec->autocfg.hp_pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002267 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002268
2269 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2270 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002271 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2272 "Speaker")) < 0 ||
2273 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2274 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2276 return err;
2277
2278 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2279
2280 if (spec->autocfg.dig_out_pin)
2281 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2282 if (spec->autocfg.dig_in_pin)
2283 spec->dig_in_nid = ALC880_DIGIN_NID;
2284
2285 if (spec->kctl_alloc)
2286 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2287
2288 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2289
2290 spec->input_mux = &spec->private_imux;
2291
2292 return 1;
2293}
2294
2295/* init callback for auto-configuration model -- overriding the default init */
2296static int alc880_auto_init(struct hda_codec *codec)
2297{
2298 alc_init(codec);
2299 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002300 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 alc880_auto_init_analog_input(codec);
2302 return 0;
2303}
2304
2305/*
2306 * OK, here we have finally the patch for ALC880
2307 */
2308
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309static int patch_alc880(struct hda_codec *codec)
2310{
2311 struct alc_spec *spec;
2312 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002313 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002315 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 if (spec == NULL)
2317 return -ENOMEM;
2318
2319 codec->spec = spec;
2320
2321 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002322 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2324 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 }
2326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327 if (board_config == ALC880_AUTO) {
2328 /* automatic parse from the BIOS config */
2329 err = alc880_parse_auto_config(codec);
2330 if (err < 0) {
2331 alc_free(codec);
2332 return err;
2333 } else if (! err) {
2334 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2335 board_config = ALC880_3ST;
2336 }
2337 }
2338
Kailang Yangdf694da2005-12-05 19:42:22 +01002339 if (board_config != ALC880_AUTO)
2340 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341
2342 spec->stream_name_analog = "ALC880 Analog";
2343 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2344 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2345
2346 spec->stream_name_digital = "ALC880 Digital";
2347 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2348 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2349
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002350 if (! spec->adc_nids && spec->input_mux) {
2351 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002352 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002353 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2354 if (wcap != AC_WID_AUD_IN) {
2355 spec->adc_nids = alc880_adc_nids_alt;
2356 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2357 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2358 spec->num_mixers++;
2359 } else {
2360 spec->adc_nids = alc880_adc_nids;
2361 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2362 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2363 spec->num_mixers++;
2364 }
2365 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366
2367 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002368 if (board_config == ALC880_AUTO)
2369 codec->patch_ops.init = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370
2371 return 0;
2372}
2373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375/*
2376 * ALC260 support
2377 */
2378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002379static hda_nid_t alc260_dac_nids[1] = {
2380 /* front */
2381 0x02,
2382};
2383
2384static hda_nid_t alc260_adc_nids[1] = {
2385 /* ADC0 */
2386 0x04,
2387};
2388
Kailang Yangdf694da2005-12-05 19:42:22 +01002389static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002390 /* ADC1 */
2391 0x05,
2392};
2393
Kailang Yangdf694da2005-12-05 19:42:22 +01002394static hda_nid_t alc260_hp_adc_nids[2] = {
2395 /* ADC1, 0 */
2396 0x05, 0x04
2397};
2398
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002399static hda_nid_t alc260_fujitsu_adc_nids[2] = {
2400 /* ADC0, ADC1 */
2401 0x04, 0x05
2402};
2403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002404#define ALC260_DIGOUT_NID 0x03
2405#define ALC260_DIGIN_NID 0x06
2406
2407static struct hda_input_mux alc260_capture_source = {
2408 .num_items = 4,
2409 .items = {
2410 { "Mic", 0x0 },
2411 { "Front Mic", 0x1 },
2412 { "Line", 0x2 },
2413 { "CD", 0x4 },
2414 },
2415};
2416
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002417/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
2418 * and the internal CD lines.
2419 */
2420static struct hda_input_mux alc260_fujitsu_capture_source = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002421 .num_items = 3,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002422 .items = {
2423 { "Mic/Line", 0x0 },
2424 { "CD", 0x4 },
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002425 { "Headphone", 0x2 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002426 },
2427};
2428
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429/*
2430 * This is just place-holder, so there's something for alc_build_pcms to look
2431 * at when it calculates the maximum number of channels. ALC260 has no mixer
2432 * element which allows changing the channel mode, so the verb list is
2433 * never used.
2434 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002435static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 { 2, NULL },
2437};
2438
Kailang Yangdf694da2005-12-05 19:42:22 +01002439
2440/* Mixer combinations
2441 *
2442 * basic: base_output + input + pc_beep + capture
2443 * HP: base_output + input + capture_alt
2444 * HP_3013: hp_3013 + input + capture
2445 * fujitsu: fujitsu + capture
2446 */
2447
2448static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002449 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002450 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002451 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2452 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2453 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2454 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2455 { } /* end */
2456};
2457
2458static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2460 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2461 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2462 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2463 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2464 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 { } /* end */
2468};
2469
Kailang Yangdf694da2005-12-05 19:42:22 +01002470static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2471 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2472 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2473 { } /* end */
2474};
2475
2476static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2477 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2478 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2479 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2480 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2481 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2483 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2484 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002485 { } /* end */
2486};
2487
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002488static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002490 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002491 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002492 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2493 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2494 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2495 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002496 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002497 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2498 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2499 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002500 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002501 { } /* end */
2502};
2503
2504/* capture mixer elements */
2505static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002506 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2507 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002508 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2509 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002510 {
2511 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01002512 /* The multiple "Capture Source" controls confuse alsamixer
2513 * So call somewhat different..
2514 * FIXME: the controls appear in the "playback" view!
2515 */
2516 /* .name = "Capture Source", */
2517 .name = "Input Source",
2518 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002519 .info = alc_mux_enum_info,
2520 .get = alc_mux_enum_get,
2521 .put = alc_mux_enum_put,
2522 },
2523 { } /* end */
2524};
2525
Kailang Yangdf694da2005-12-05 19:42:22 +01002526static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2527 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2528 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2529 {
2530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2531 /* The multiple "Capture Source" controls confuse alsamixer
2532 * So call somewhat different..
2533 * FIXME: the controls appear in the "playback" view!
2534 */
2535 /* .name = "Capture Source", */
2536 .name = "Input Source",
2537 .count = 1,
2538 .info = alc_mux_enum_info,
2539 .get = alc_mux_enum_get,
2540 .put = alc_mux_enum_put,
2541 },
2542 { } /* end */
2543};
2544
2545/*
2546 * initialization verbs
2547 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548static struct hda_verb alc260_init_verbs[] = {
2549 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002552 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002554 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002556 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02002558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01002560 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02002562 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02002564 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02002566 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2567 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02002568 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 /* set connection select to line in (default select for this ADC) */
2570 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02002571 /* mute capture amp left and right */
2572 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2573 /* set connection select to line in (default select for this ADC) */
2574 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02002575 /* set vol=0 Line-Out mixer amp left and right */
2576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2577 /* unmute pin widget amp left and right (no gain on this amp) */
2578 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2579 /* set vol=0 HP mixer amp left and right */
2580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2581 /* unmute pin widget amp left and right (no gain on this amp) */
2582 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2583 /* set vol=0 Mono mixer amp left and right */
2584 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2585 /* unmute pin widget amp left and right (no gain on this amp) */
2586 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2587 /* unmute LINE-2 out pin */
2588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002590 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02002591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002592 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02002593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002594 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02002595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002597 /* mute Front out path */
2598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2599 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2600 /* mute Headphone out path */
2601 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2602 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2603 /* mute Mono out path */
2604 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2605 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 { }
2607};
2608
Kailang Yangdf694da2005-12-05 19:42:22 +01002609static struct hda_verb alc260_hp_init_verbs[] = {
2610 /* Headphone and output */
2611 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2612 /* mono output */
2613 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2614 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2615 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2616 /* Mic2 (front panel) pin widget for input and vref at 80% */
2617 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2618 /* Line In pin widget for input */
2619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2620 /* Line-2 pin widget for output */
2621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2622 /* CD pin widget for input */
2623 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2624 /* unmute amp left and right */
2625 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2626 /* set connection select to line in (default select for this ADC) */
2627 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2628 /* unmute Line-Out mixer amp left and right (volume = 0) */
2629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2630 /* mute pin widget amp left and right (no gain on this amp) */
2631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2632 /* unmute HP mixer amp left and right (volume = 0) */
2633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2634 /* mute pin widget amp left and right (no gain on this amp) */
2635 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2636 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2637 /* unmute CD */
2638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2639 /* unmute Line In */
2640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2641 /* unmute Mic */
2642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2643 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2644 /* Unmute Front out path */
2645 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2647 /* Unmute Headphone out path */
2648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2650 /* Unmute Mono out path */
2651 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2653 { }
2654};
2655
2656static struct hda_verb alc260_hp_3013_init_verbs[] = {
2657 /* Line out and output */
2658 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2659 /* mono output */
2660 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2661 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2662 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2663 /* Mic2 (front panel) pin widget for input and vref at 80% */
2664 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2665 /* Line In pin widget for input */
2666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2667 /* Headphone pin widget for output */
2668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2669 /* CD pin widget for input */
2670 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2671 /* unmute amp left and right */
2672 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2673 /* set connection select to line in (default select for this ADC) */
2674 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2675 /* unmute Line-Out mixer amp left and right (volume = 0) */
2676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2677 /* mute pin widget amp left and right (no gain on this amp) */
2678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2679 /* unmute HP mixer amp left and right (volume = 0) */
2680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2681 /* mute pin widget amp left and right (no gain on this amp) */
2682 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2683 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2684 /* unmute CD */
2685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2686 /* unmute Line In */
2687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2688 /* unmute Mic */
2689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2690 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2691 /* Unmute Front out path */
2692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2694 /* Unmute Headphone out path */
2695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2697 /* Unmute Mono out path */
2698 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 { }
2701};
2702
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002703/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2704 * laptops.
2705 */
2706static struct hda_verb alc260_fujitsu_init_verbs[] = {
2707 /* Disable all GPIOs */
2708 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2709 /* Internal speaker is connected to headphone pin */
2710 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2711 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2713 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2714 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2715 /* Ensure all other unused pins are disabled and muted.
2716 * Note: trying to set widget 0x15 to anything blocks all audio
2717 * output for some reason, so just leave that at the default.
2718 */
2719 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2720 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2721 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2722 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2723 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2724 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2725 /* Disable digital (SPDIF) pins */
2726 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2727 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2728
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002729 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
2730 * when acting as an output.
2731 */
2732 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
2733
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01002734 /* Start with output sum widgets muted and their output gains at min */
2735 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2736 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2738 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2741 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2743 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002744
2745 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2746 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
2748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002749 /* Unmute Line1 pin widget input for when this pin is used as input
2750 * (no equiv mixer ctrl). Having input and output unmuted doesn't
2751 * seem to cause a problem.
2752 */
2753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002754 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
2755 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2756
2757 /* Mute capture amp left and right */
2758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002759 /* Set ADC connection select to match default mixer setting - line
2760 * in (on mic1 pin)
2761 */
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002762 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2763
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002764 /* Do the same for the second ADC: mute capture input amp and
2765 * set ADC connection to line in
2766 */
2767 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2768 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2769
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002770 /* Mute all inputs to mixer widget (even unconnected ones) */
2771 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2772 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2773 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2774 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2775 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2776 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2777 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01002779
2780 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002781};
2782
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01002783/* Test configuration for debugging, modelled after the ALC880 test
2784 * configuration.
2785 */
2786#ifdef CONFIG_SND_DEBUG
2787static hda_nid_t alc260_test_dac_nids[1] = {
2788 0x02,
2789};
2790static hda_nid_t alc260_test_adc_nids[2] = {
2791 0x04, 0x05,
2792};
2793static struct hda_input_mux alc260_test_capture_source = {
2794 .num_items = 7,
2795 .items = {
2796 { "MIC1 pin", 0x0 },
2797 { "MIC2 pin", 0x1 },
2798 { "LINE1 pin", 0x2 },
2799 { "LINE2 pin", 0x3 },
2800 { "CD pin", 0x4 },
2801 { "LINE-OUT pin", 0x5 },
2802 { "HP-OUT pin", 0x6 },
2803 },
2804};
2805static struct snd_kcontrol_new alc260_test_mixer[] = {
2806 /* Output driver widgets */
2807 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2808 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2809 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2810 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
2811 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2812 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
2813
2814 /* Modes for retasking pin widgets */
2815 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
2816 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
2817 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
2818 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
2819 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
2820 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
2821
2822 /* Loopback mixer controls */
2823 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
2824 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
2825 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
2826 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
2827 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
2828 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
2829 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
2830 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
2831 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2832 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2833 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2834 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2835 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
2836 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
2837 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
2838 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
2839 { } /* end */
2840};
2841static struct hda_verb alc260_test_init_verbs[] = {
2842 /* Disable all GPIOs */
2843 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2844 /* Enable retasking pins as output, initially without power amp */
2845 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2846 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2849 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2850 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2851
2852 /* Disable digital (SPDIF) pins for now */
2853 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2854 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2855
2856 /* Ensure mic1, mic2, line1 and line2 pin widget take input from the
2857 * OUT1 sum bus when acting as an output.
2858 */
2859 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
2860 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
2861 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
2862 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
2863
2864 /* Start with output sum widgets muted and their output gains at min */
2865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2874
2875 /* Unmute retasking pin widget output amp left/right (no mixer ctrl) */
2876 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2882 /* Also unmute the mono-out pin widget */
2883 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2884
2885 /* Also unmute the retasking pin input amps. Having the input and
2886 * output amps unmuted at the same time doesn't appear to cause any
2887 * trouble.
2888 */
2889 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2890 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2893 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2894 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2895
2896 /* Mute capture amp left and right */
2897 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2898 /* Set ADC connection select to match default mixer setting - line
2899 * in (on mic1 pin)
2900 */
2901 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2902
2903 /* Do the same for the second ADC: mute capture input amp and
2904 * set ADC connection to line in
2905 */
2906 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2907 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2908
2909 /* Mute all inputs to mixer widget (even unconnected ones) */
2910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2918
2919 { }
2920};
2921#endif
2922
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923static struct hda_pcm_stream alc260_pcm_analog_playback = {
2924 .substreams = 1,
2925 .channels_min = 2,
2926 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002927};
2928
2929static struct hda_pcm_stream alc260_pcm_analog_capture = {
2930 .substreams = 1,
2931 .channels_min = 2,
2932 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933};
2934
Takashi Iwaia3bcba32005-12-06 19:05:29 +01002935#define alc260_pcm_digital_playback alc880_pcm_digital_playback
2936#define alc260_pcm_digital_capture alc880_pcm_digital_capture
2937
Kailang Yangdf694da2005-12-05 19:42:22 +01002938/*
2939 * for BIOS auto-configuration
2940 */
2941
2942static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
2943 const char *pfx)
2944{
2945 hda_nid_t nid_vol;
2946 unsigned long vol_val, sw_val;
2947 char name[32];
2948 int err;
2949
2950 if (nid >= 0x0f && nid < 0x11) {
2951 nid_vol = nid - 0x7;
2952 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2953 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2954 } else if (nid == 0x11) {
2955 nid_vol = nid - 0x7;
2956 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
2957 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
2958 } else if (nid >= 0x12 && nid <= 0x15) {
2959 nid_vol = 0x08;
2960 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2961 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2962 } else
2963 return 0; /* N/A */
2964
2965 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
2966 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
2967 return err;
2968 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
2969 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
2970 return err;
2971 return 1;
2972}
2973
2974/* add playback controls from the parsed DAC table */
2975static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
2976 const struct auto_pin_cfg *cfg)
2977{
2978 hda_nid_t nid;
2979 int err;
2980
2981 spec->multiout.num_dacs = 1;
2982 spec->multiout.dac_nids = spec->private_dac_nids;
2983 spec->multiout.dac_nids[0] = 0x02;
2984
2985 nid = cfg->line_out_pins[0];
2986 if (nid) {
2987 err = alc260_add_playback_controls(spec, nid, "Front");
2988 if (err < 0)
2989 return err;
2990 }
2991
2992 nid = cfg->speaker_pin;
2993 if (nid) {
2994 err = alc260_add_playback_controls(spec, nid, "Speaker");
2995 if (err < 0)
2996 return err;
2997 }
2998
2999 nid = cfg->hp_pin;
3000 if (nid) {
3001 err = alc260_add_playback_controls(spec, nid, "Headphone");
3002 if (err < 0)
3003 return err;
3004 }
3005 return 0;
3006}
3007
3008/* create playback/capture controls for input pins */
3009static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3010 const struct auto_pin_cfg *cfg)
3011{
Kailang Yangdf694da2005-12-05 19:42:22 +01003012 struct hda_input_mux *imux = &spec->private_imux;
3013 int i, err, idx;
3014
3015 for (i = 0; i < AUTO_PIN_LAST; i++) {
3016 if (cfg->input_pins[i] >= 0x12) {
3017 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003018 err = new_analog_input(spec, cfg->input_pins[i],
3019 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003020 if (err < 0)
3021 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003022 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003023 imux->items[imux->num_items].index = idx;
3024 imux->num_items++;
3025 }
3026 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3027 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003028 err = new_analog_input(spec, cfg->input_pins[i],
3029 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003030 if (err < 0)
3031 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003032 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003033 imux->items[imux->num_items].index = idx;
3034 imux->num_items++;
3035 }
3036 }
3037 return 0;
3038}
3039
3040static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3041 hda_nid_t nid, int pin_type,
3042 int sel_idx)
3043{
3044 /* set as output */
3045 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3046 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3047 /* need the manual connection? */
3048 if (nid >= 0x12) {
3049 int idx = nid - 0x12;
3050 snd_hda_codec_write(codec, idx + 0x0b, 0,
3051 AC_VERB_SET_CONNECT_SEL, sel_idx);
3052
3053 }
3054}
3055
3056static void alc260_auto_init_multi_out(struct hda_codec *codec)
3057{
3058 struct alc_spec *spec = codec->spec;
3059 hda_nid_t nid;
3060
3061 nid = spec->autocfg.line_out_pins[0];
3062 if (nid)
3063 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3064
3065 nid = spec->autocfg.speaker_pin;
3066 if (nid)
3067 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3068
3069 nid = spec->autocfg.hp_pin;
3070 if (nid)
3071 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3072}
3073
3074#define ALC260_PIN_CD_NID 0x16
3075static void alc260_auto_init_analog_input(struct hda_codec *codec)
3076{
3077 struct alc_spec *spec = codec->spec;
3078 int i;
3079
3080 for (i = 0; i < AUTO_PIN_LAST; i++) {
3081 hda_nid_t nid = spec->autocfg.input_pins[i];
3082 if (nid >= 0x12) {
3083 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3084 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3085 if (nid != ALC260_PIN_CD_NID)
3086 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3087 AMP_OUT_MUTE);
3088 }
3089 }
3090}
3091
3092/*
3093 * generic initialization of ADC, input mixers and output mixers
3094 */
3095static struct hda_verb alc260_volume_init_verbs[] = {
3096 /*
3097 * Unmute ADC0-1 and set the default input to mic-in
3098 */
3099 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3100 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3101 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3102 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3103
3104 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3105 * mixer widget
3106 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3107 * mic (mic 2)
3108 */
3109 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3115
3116 /*
3117 * Set up output mixers (0x08 - 0x0a)
3118 */
3119 /* set vol=0 to output mixers */
3120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3122 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3123 /* set up input amps for analog loopback */
3124 /* Amp Indices: DAC = 0, mixer = 1 */
3125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3126 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3128 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3130 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3131
3132 { }
3133};
3134
3135static int alc260_parse_auto_config(struct hda_codec *codec)
3136{
3137 struct alc_spec *spec = codec->spec;
3138 unsigned int wcap;
3139 int err;
3140 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3141
3142 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3143 alc260_ignore)) < 0)
3144 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003145 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3146 return err;
3147 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003148 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003149 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003150 return err;
3151
3152 spec->multiout.max_channels = 2;
3153
3154 if (spec->autocfg.dig_out_pin)
3155 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3156 if (spec->kctl_alloc)
3157 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3158
3159 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3160
3161 spec->input_mux = &spec->private_imux;
3162
3163 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003164 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003165 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3166 if (wcap != AC_WID_AUD_IN) {
3167 spec->adc_nids = alc260_adc_nids_alt;
3168 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3169 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003170 } else {
3171 spec->adc_nids = alc260_adc_nids;
3172 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3173 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003174 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003175 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003176
3177 return 1;
3178}
3179
3180/* init callback for auto-configuration model -- overriding the default init */
3181static int alc260_auto_init(struct hda_codec *codec)
3182{
3183 alc_init(codec);
3184 alc260_auto_init_multi_out(codec);
3185 alc260_auto_init_analog_input(codec);
3186 return 0;
3187}
3188
3189/*
3190 * ALC260 configurations
3191 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003192static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003193 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003194 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3195 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai16ded522005-06-10 19:58:24 +02003196 { .modelname = "hp", .config = ALC260_HP },
Kailang Yangdf694da2005-12-05 19:42:22 +01003197 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3198 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3199 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
3200 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3201 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3202 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3203 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3204 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3205 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003206#ifdef CONFIG_SND_DEBUG
3207 { .modelname = "test", .config = ALC260_TEST },
3208#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003209 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003210 {}
3211};
3212
Kailang Yangdf694da2005-12-05 19:42:22 +01003213static struct alc_config_preset alc260_presets[] = {
3214 [ALC260_BASIC] = {
3215 .mixers = { alc260_base_output_mixer,
3216 alc260_input_mixer,
3217 alc260_pc_beep_mixer,
3218 alc260_capture_mixer },
3219 .init_verbs = { alc260_init_verbs },
3220 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3221 .dac_nids = alc260_dac_nids,
3222 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3223 .adc_nids = alc260_adc_nids,
3224 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3225 .channel_mode = alc260_modes,
3226 .input_mux = &alc260_capture_source,
3227 },
3228 [ALC260_HP] = {
3229 .mixers = { alc260_base_output_mixer,
3230 alc260_input_mixer,
3231 alc260_capture_alt_mixer },
3232 .init_verbs = { alc260_hp_init_verbs },
3233 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3234 .dac_nids = alc260_dac_nids,
3235 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3236 .adc_nids = alc260_hp_adc_nids,
3237 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3238 .channel_mode = alc260_modes,
3239 .input_mux = &alc260_capture_source,
3240 },
3241 [ALC260_HP_3013] = {
3242 .mixers = { alc260_hp_3013_mixer,
3243 alc260_input_mixer,
3244 alc260_capture_alt_mixer },
3245 .init_verbs = { alc260_hp_3013_init_verbs },
3246 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3247 .dac_nids = alc260_dac_nids,
3248 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3249 .adc_nids = alc260_hp_adc_nids,
3250 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3251 .channel_mode = alc260_modes,
3252 .input_mux = &alc260_capture_source,
3253 },
3254 [ALC260_FUJITSU_S702X] = {
3255 .mixers = { alc260_fujitsu_mixer,
3256 alc260_capture_mixer },
3257 .init_verbs = { alc260_fujitsu_init_verbs },
3258 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3259 .dac_nids = alc260_dac_nids,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003260 .num_adc_nids = ARRAY_SIZE(alc260_fujitsu_adc_nids),
3261 .adc_nids = alc260_fujitsu_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01003262 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3263 .channel_mode = alc260_modes,
3264 .input_mux = &alc260_fujitsu_capture_source,
3265 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003266#ifdef CONFIG_SND_DEBUG
3267 [ALC260_TEST] = {
3268 .mixers = { alc260_test_mixer,
3269 alc260_capture_mixer },
3270 .init_verbs = { alc260_test_init_verbs },
3271 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3272 .dac_nids = alc260_test_dac_nids,
3273 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3274 .adc_nids = alc260_test_adc_nids,
3275 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3276 .channel_mode = alc260_modes,
3277 .input_mux = &alc260_test_capture_source,
3278 },
3279#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003280};
3281
Linus Torvalds1da177e2005-04-16 15:20:36 -07003282static int patch_alc260(struct hda_codec *codec)
3283{
3284 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01003285 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003287 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003288 if (spec == NULL)
3289 return -ENOMEM;
3290
3291 codec->spec = spec;
3292
Takashi Iwai16ded522005-06-10 19:58:24 +02003293 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3294 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3295 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01003296 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02003297 }
3298
Kailang Yangdf694da2005-12-05 19:42:22 +01003299 if (board_config == ALC260_AUTO) {
3300 /* automatic parse from the BIOS config */
3301 err = alc260_parse_auto_config(codec);
3302 if (err < 0) {
3303 alc_free(codec);
3304 return err;
3305 } else if (! err) {
3306 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3307 board_config = ALC260_BASIC;
3308 }
Takashi Iwai16ded522005-06-10 19:58:24 +02003309 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003310
Kailang Yangdf694da2005-12-05 19:42:22 +01003311 if (board_config != ALC260_AUTO)
3312 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313
3314 spec->stream_name_analog = "ALC260 Analog";
3315 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3316 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3317
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003318 spec->stream_name_digital = "ALC260 Digital";
3319 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3320 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3321
Linus Torvalds1da177e2005-04-16 15:20:36 -07003322 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01003323 if (board_config == ALC260_AUTO)
3324 codec->patch_ops.init = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325
3326 return 0;
3327}
3328
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003329
Linus Torvalds1da177e2005-04-16 15:20:36 -07003330/*
3331 * ALC882 support
3332 *
3333 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3334 * configuration. Each pin widget can choose any input DACs and a mixer.
3335 * Each ADC is connected from a mixer of all inputs. This makes possible
3336 * 6-channel independent captures.
3337 *
3338 * In addition, an independent DAC for the multi-playback (not used in this
3339 * driver yet).
3340 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003341#define ALC882_DIGOUT_NID 0x06
3342#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07003343
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003344static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345 { 8, NULL }
3346};
3347
3348static hda_nid_t alc882_dac_nids[4] = {
3349 /* front, rear, clfe, rear_surr */
3350 0x02, 0x03, 0x04, 0x05
3351};
3352
Kailang Yangdf694da2005-12-05 19:42:22 +01003353/* identical with ALC880 */
3354#define alc882_adc_nids alc880_adc_nids
3355#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07003356
3357/* input MUX */
3358/* FIXME: should be a matrix-type input source selection */
3359
3360static struct hda_input_mux alc882_capture_source = {
3361 .num_items = 4,
3362 .items = {
3363 { "Mic", 0x0 },
3364 { "Front Mic", 0x1 },
3365 { "Line", 0x2 },
3366 { "CD", 0x4 },
3367 },
3368};
3369
3370#define alc882_mux_enum_info alc_mux_enum_info
3371#define alc882_mux_enum_get alc_mux_enum_get
3372
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003373static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374{
3375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3376 struct alc_spec *spec = codec->spec;
3377 const struct hda_input_mux *imux = spec->input_mux;
3378 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3379 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3380 hda_nid_t nid = capture_mixers[adc_idx];
3381 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3382 unsigned int i, idx;
3383
3384 idx = ucontrol->value.enumerated.item[0];
3385 if (idx >= imux->num_items)
3386 idx = imux->num_items - 1;
3387 if (*cur_val == idx && ! codec->in_resume)
3388 return 0;
3389 for (i = 0; i < imux->num_items; i++) {
3390 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3391 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3392 v | (imux->items[i].index << 8));
3393 }
3394 *cur_val = idx;
3395 return 1;
3396}
3397
Kailang Yangdf694da2005-12-05 19:42:22 +01003398/*
3399 * 6ch mode
3400 */
3401static struct hda_verb alc882_sixstack_ch6_init[] = {
3402 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3403 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3404 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3405 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3406 { } /* end */
3407};
3408
3409/*
3410 * 8ch mode
3411 */
3412static struct hda_verb alc882_sixstack_ch8_init[] = {
3413 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3414 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3415 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3416 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3417 { } /* end */
3418};
3419
3420static struct hda_channel_mode alc882_sixstack_modes[2] = {
3421 { 6, alc882_sixstack_ch6_init },
3422 { 8, alc882_sixstack_ch8_init },
3423};
3424
Linus Torvalds1da177e2005-04-16 15:20:36 -07003425/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3426 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3427 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003428static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003429 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003430 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003431 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003432 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003433 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3434 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003435 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3436 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003437 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003438 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3446 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3447 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3448 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
3449 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
3450 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3451 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3452 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3453 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3454 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3455 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3456 {
3457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3458 /* .name = "Capture Source", */
3459 .name = "Input Source",
3460 .count = 3,
3461 .info = alc882_mux_enum_info,
3462 .get = alc882_mux_enum_get,
3463 .put = alc882_mux_enum_put,
3464 },
3465 { } /* end */
3466};
3467
Kailang Yangdf694da2005-12-05 19:42:22 +01003468static struct snd_kcontrol_new alc882_chmode_mixer[] = {
3469 {
3470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3471 .name = "Channel Mode",
3472 .info = alc_ch_mode_info,
3473 .get = alc_ch_mode_get,
3474 .put = alc_ch_mode_put,
3475 },
3476 { } /* end */
3477};
3478
Linus Torvalds1da177e2005-04-16 15:20:36 -07003479static struct hda_verb alc882_init_verbs[] = {
3480 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003488 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3494 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3495 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003504 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003509 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003510 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003511 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003512 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003515 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3516 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003517 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003518 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3519 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003520 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003521 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3522 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3523 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3524 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3525 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003526 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003527 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003528
3529 /* FIXME: use matrix-type input source selection */
3530 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3531 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02003532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3535 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003536 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3539 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003541 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3546 /* ADC1: mute amp left and right */
3547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003548 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003549 /* ADC2: mute amp left and right */
3550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003551 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003552 /* ADC3: mute amp left and right */
3553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003554 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003555
3556 { }
3557};
3558
Kailang Yangdf694da2005-12-05 19:42:22 +01003559/*
3560 * generic initialization of ADC, input mixers and output mixers
3561 */
3562static struct hda_verb alc882_auto_init_verbs[] = {
3563 /*
3564 * Unmute ADC0-2 and set the default input to mic-in
3565 */
3566 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3568 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3570 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3572
3573 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3574 * mixer widget
3575 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3576 * mic (mic 2)
3577 */
3578 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3584
3585 /*
3586 * Set up output mixers (0x0c - 0x0f)
3587 */
3588 /* set vol=0 to output mixers */
3589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3593 /* set up input amps for analog loopback */
3594 /* Amp Indices: DAC = 0, mixer = 1 */
3595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3602 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3603 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3604 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3605
3606 /* FIXME: use matrix-type input source selection */
3607 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3608 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3613 /* Input mixer2 */
3614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3618 /* Input mixer3 */
3619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3623
3624 { }
3625};
3626
3627/* capture mixer elements */
3628static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
3629 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3630 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3631 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
3632 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
3633 {
3634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3635 /* The multiple "Capture Source" controls confuse alsamixer
3636 * So call somewhat different..
3637 * FIXME: the controls appear in the "playback" view!
3638 */
3639 /* .name = "Capture Source", */
3640 .name = "Input Source",
3641 .count = 2,
3642 .info = alc882_mux_enum_info,
3643 .get = alc882_mux_enum_get,
3644 .put = alc882_mux_enum_put,
3645 },
3646 { } /* end */
3647};
3648
3649static struct snd_kcontrol_new alc882_capture_mixer[] = {
3650 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3651 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3652 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3653 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3654 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3655 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3656 {
3657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3658 /* The multiple "Capture Source" controls confuse alsamixer
3659 * So call somewhat different..
3660 * FIXME: the controls appear in the "playback" view!
3661 */
3662 /* .name = "Capture Source", */
3663 .name = "Input Source",
3664 .count = 3,
3665 .info = alc882_mux_enum_info,
3666 .get = alc882_mux_enum_get,
3667 .put = alc882_mux_enum_put,
3668 },
3669 { } /* end */
3670};
3671
3672/* pcm configuration: identiacal with ALC880 */
3673#define alc882_pcm_analog_playback alc880_pcm_analog_playback
3674#define alc882_pcm_analog_capture alc880_pcm_analog_capture
3675#define alc882_pcm_digital_playback alc880_pcm_digital_playback
3676#define alc882_pcm_digital_capture alc880_pcm_digital_capture
3677
3678/*
3679 * configuration and preset
3680 */
3681static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01003682 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
3683 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01003684 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
3685 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
3686 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
Takashi Iwai1494a922006-01-31 10:58:46 +01003687 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01003688 {}
3689};
3690
3691static struct alc_config_preset alc882_presets[] = {
3692 [ALC882_3ST_DIG] = {
3693 .mixers = { alc882_base_mixer },
3694 .init_verbs = { alc882_init_verbs },
3695 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3696 .dac_nids = alc882_dac_nids,
3697 .dig_out_nid = ALC882_DIGOUT_NID,
3698 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3699 .adc_nids = alc882_adc_nids,
3700 .dig_in_nid = ALC882_DIGIN_NID,
3701 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3702 .channel_mode = alc882_ch_modes,
3703 .input_mux = &alc882_capture_source,
3704 },
3705 [ALC882_6ST_DIG] = {
3706 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3707 .init_verbs = { alc882_init_verbs },
3708 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3709 .dac_nids = alc882_dac_nids,
3710 .dig_out_nid = ALC882_DIGOUT_NID,
3711 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3712 .adc_nids = alc882_adc_nids,
3713 .dig_in_nid = ALC882_DIGIN_NID,
3714 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3715 .channel_mode = alc882_sixstack_modes,
3716 .input_mux = &alc882_capture_source,
3717 },
3718};
3719
3720
3721/*
3722 * BIOS auto configuration
3723 */
3724static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
3725 hda_nid_t nid, int pin_type,
3726 int dac_idx)
3727{
3728 /* set as output */
3729 struct alc_spec *spec = codec->spec;
3730 int idx;
3731
3732 if (spec->multiout.dac_nids[dac_idx] == 0x25)
3733 idx = 4;
3734 else
3735 idx = spec->multiout.dac_nids[dac_idx] - 2;
3736
3737 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3738 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
3740
3741}
3742
3743static void alc882_auto_init_multi_out(struct hda_codec *codec)
3744{
3745 struct alc_spec *spec = codec->spec;
3746 int i;
3747
3748 for (i = 0; i <= HDA_SIDE; i++) {
3749 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3750 if (nid)
3751 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3752 }
3753}
3754
3755static void alc882_auto_init_hp_out(struct hda_codec *codec)
3756{
3757 struct alc_spec *spec = codec->spec;
3758 hda_nid_t pin;
3759
3760 pin = spec->autocfg.hp_pin;
3761 if (pin) /* connect to front */
3762 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
3763}
3764
3765#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
3766#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
3767
3768static void alc882_auto_init_analog_input(struct hda_codec *codec)
3769{
3770 struct alc_spec *spec = codec->spec;
3771 int i;
3772
3773 for (i = 0; i < AUTO_PIN_LAST; i++) {
3774 hda_nid_t nid = spec->autocfg.input_pins[i];
3775 if (alc882_is_input_pin(nid)) {
3776 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3777 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3778 if (nid != ALC882_PIN_CD_NID)
3779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3780 AMP_OUT_MUTE);
3781 }
3782 }
3783}
3784
3785/* almost identical with ALC880 parser... */
3786static int alc882_parse_auto_config(struct hda_codec *codec)
3787{
3788 struct alc_spec *spec = codec->spec;
3789 int err = alc880_parse_auto_config(codec);
3790
3791 if (err < 0)
3792 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01003793 else if (err > 0)
3794 /* hack - override the init verbs */
3795 spec->init_verbs[0] = alc882_auto_init_verbs;
3796 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003797}
3798
3799/* init callback for auto-configuration model -- overriding the default init */
3800static int alc882_auto_init(struct hda_codec *codec)
3801{
3802 alc_init(codec);
3803 alc882_auto_init_multi_out(codec);
3804 alc882_auto_init_hp_out(codec);
3805 alc882_auto_init_analog_input(codec);
3806 return 0;
3807}
3808
3809/*
3810 * ALC882 Headphone poll in 3.5.1a or 3.5.2
3811 */
3812
Linus Torvalds1da177e2005-04-16 15:20:36 -07003813static int patch_alc882(struct hda_codec *codec)
3814{
3815 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01003816 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003817
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003818 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003819 if (spec == NULL)
3820 return -ENOMEM;
3821
Linus Torvalds1da177e2005-04-16 15:20:36 -07003822 codec->spec = spec;
3823
Kailang Yangdf694da2005-12-05 19:42:22 +01003824 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003825
Kailang Yangdf694da2005-12-05 19:42:22 +01003826 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
3827 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
3828 board_config = ALC882_AUTO;
3829 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003830
Kailang Yangdf694da2005-12-05 19:42:22 +01003831 if (board_config == ALC882_AUTO) {
3832 /* automatic parse from the BIOS config */
3833 err = alc882_parse_auto_config(codec);
3834 if (err < 0) {
3835 alc_free(codec);
3836 return err;
3837 } else if (! err) {
3838 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3839 board_config = ALC882_3ST_DIG;
3840 }
3841 }
3842
3843 if (board_config != ALC882_AUTO)
3844 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003845
3846 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01003847 spec->stream_analog_playback = &alc882_pcm_analog_playback;
3848 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003849
3850 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01003851 spec->stream_digital_playback = &alc882_pcm_digital_playback;
3852 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003853
Kailang Yangdf694da2005-12-05 19:42:22 +01003854 if (! spec->adc_nids && spec->input_mux) {
3855 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003856 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003857 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3858 if (wcap != AC_WID_AUD_IN) {
3859 spec->adc_nids = alc882_adc_nids_alt;
3860 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
3861 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
3862 spec->num_mixers++;
3863 } else {
3864 spec->adc_nids = alc882_adc_nids;
3865 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
3866 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
3867 spec->num_mixers++;
3868 }
3869 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003870
3871 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01003872 if (board_config == ALC882_AUTO)
3873 codec->patch_ops.init = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003874
3875 return 0;
3876}
3877
3878/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003879 * ALC262 support
3880 */
3881
3882#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
3883#define ALC262_DIGIN_NID ALC880_DIGIN_NID
3884
3885#define alc262_dac_nids alc260_dac_nids
3886#define alc262_adc_nids alc882_adc_nids
3887#define alc262_adc_nids_alt alc882_adc_nids_alt
3888
3889#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01003890#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01003891
3892static struct snd_kcontrol_new alc262_base_mixer[] = {
3893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3894 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3895 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3897 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3898 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3901 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3902 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3903 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
3904 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
3905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
3906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3907 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3908 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
3909 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3910 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3911 {
3912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3913 .name = "Capture Source",
3914 .count = 1,
3915 .info = alc882_mux_enum_info,
3916 .get = alc882_mux_enum_get,
3917 .put = alc882_mux_enum_put,
3918 },
3919 { } /* end */
3920};
3921
3922#define alc262_capture_mixer alc882_capture_mixer
3923#define alc262_capture_alt_mixer alc882_capture_alt_mixer
3924
3925/*
3926 * generic initialization of ADC, input mixers and output mixers
3927 */
3928static struct hda_verb alc262_init_verbs[] = {
3929 /*
3930 * Unmute ADC0-2 and set the default input to mic-in
3931 */
3932 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3934 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3936 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3938
3939 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3940 * mixer widget
3941 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3942 * mic (mic 2)
3943 */
3944 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3950
3951 /*
3952 * Set up output mixers (0x0c - 0x0e)
3953 */
3954 /* set vol=0 to output mixers */
3955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3958 /* set up input amps for analog loopback */
3959 /* Amp Indices: DAC = 0, mixer = 1 */
3960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3965 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3966
3967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3972 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3973
3974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3979
3980 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3982
3983 /* FIXME: use matrix-type input source selection */
3984 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3985 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3990 /* Input mixer2 */
3991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3995 /* Input mixer3 */
3996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4000
4001 { }
4002};
4003
4004/* add playback controls from the parsed DAC table */
4005static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4006{
4007 hda_nid_t nid;
4008 int err;
4009
4010 spec->multiout.num_dacs = 1; /* only use one dac */
4011 spec->multiout.dac_nids = spec->private_dac_nids;
4012 spec->multiout.dac_nids[0] = 2;
4013
4014 nid = cfg->line_out_pins[0];
4015 if (nid) {
4016 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
4017 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4018 return err;
4019 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
4020 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4021 return err;
4022 }
4023
4024 nid = cfg->speaker_pin;
4025 if (nid) {
4026 if (nid == 0x16) {
4027 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4028 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4029 return err;
4030 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4031 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4032 return err;
4033 } else {
4034 if (! cfg->line_out_pins[0])
4035 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4036 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4037 return err;
4038 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4039 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4040 return err;
4041 }
4042 }
4043 nid = cfg->hp_pin;
4044 if (nid) {
4045 /* spec->multiout.hp_nid = 2; */
4046 if (nid == 0x16) {
4047 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4048 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4049 return err;
4050 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4051 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4052 return err;
4053 } else {
4054 if (! cfg->line_out_pins[0])
4055 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4056 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4057 return err;
4058 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4059 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4060 return err;
4061 }
4062 }
4063 return 0;
4064}
4065
4066/* identical with ALC880 */
4067#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4068
4069/*
4070 * generic initialization of ADC, input mixers and output mixers
4071 */
4072static struct hda_verb alc262_volume_init_verbs[] = {
4073 /*
4074 * Unmute ADC0-2 and set the default input to mic-in
4075 */
4076 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4082
4083 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4084 * mixer widget
4085 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4086 * mic (mic 2)
4087 */
4088 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4094
4095 /*
4096 * Set up output mixers (0x0c - 0x0f)
4097 */
4098 /* set vol=0 to output mixers */
4099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4102
4103 /* set up input amps for analog loopback */
4104 /* Amp Indices: DAC = 0, mixer = 1 */
4105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4111
4112 /* FIXME: use matrix-type input source selection */
4113 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4114 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4119 /* Input mixer2 */
4120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4124 /* Input mixer3 */
4125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4129
4130 { }
4131};
4132
4133/* pcm configuration: identiacal with ALC880 */
4134#define alc262_pcm_analog_playback alc880_pcm_analog_playback
4135#define alc262_pcm_analog_capture alc880_pcm_analog_capture
4136#define alc262_pcm_digital_playback alc880_pcm_digital_playback
4137#define alc262_pcm_digital_capture alc880_pcm_digital_capture
4138
4139/*
4140 * BIOS auto configuration
4141 */
4142static int alc262_parse_auto_config(struct hda_codec *codec)
4143{
4144 struct alc_spec *spec = codec->spec;
4145 int err;
4146 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4147
4148 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4149 alc262_ignore)) < 0)
4150 return err;
4151 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4152 ! spec->autocfg.hp_pin)
4153 return 0; /* can't find valid BIOS pin config */
4154 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4155 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4156 return err;
4157
4158 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4159
4160 if (spec->autocfg.dig_out_pin)
4161 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
4162 if (spec->autocfg.dig_in_pin)
4163 spec->dig_in_nid = ALC262_DIGIN_NID;
4164
4165 if (spec->kctl_alloc)
4166 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4167
4168 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
4169 spec->input_mux = &spec->private_imux;
4170
4171 return 1;
4172}
4173
4174#define alc262_auto_init_multi_out alc882_auto_init_multi_out
4175#define alc262_auto_init_hp_out alc882_auto_init_hp_out
4176#define alc262_auto_init_analog_input alc882_auto_init_analog_input
4177
4178
4179/* init callback for auto-configuration model -- overriding the default init */
4180static int alc262_auto_init(struct hda_codec *codec)
4181{
4182 alc_init(codec);
4183 alc262_auto_init_multi_out(codec);
4184 alc262_auto_init_hp_out(codec);
4185 alc262_auto_init_analog_input(codec);
4186 return 0;
4187}
4188
4189/*
4190 * configuration and preset
4191 */
4192static struct hda_board_config alc262_cfg_tbl[] = {
4193 { .modelname = "basic", .config = ALC262_BASIC },
4194 { .modelname = "auto", .config = ALC262_AUTO },
4195 {}
4196};
4197
4198static struct alc_config_preset alc262_presets[] = {
4199 [ALC262_BASIC] = {
4200 .mixers = { alc262_base_mixer },
4201 .init_verbs = { alc262_init_verbs },
4202 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4203 .dac_nids = alc262_dac_nids,
4204 .hp_nid = 0x03,
4205 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4206 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004207 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01004208 },
4209};
4210
4211static int patch_alc262(struct hda_codec *codec)
4212{
4213 struct alc_spec *spec;
4214 int board_config;
4215 int err;
4216
4217 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4218 if (spec == NULL)
4219 return -ENOMEM;
4220
4221 codec->spec = spec;
4222#if 0
4223 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4224 {
4225 int tmp;
4226 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4227 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4228 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4229 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4230 }
4231#endif
4232
4233 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
4234 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4235 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
4236 board_config = ALC262_AUTO;
4237 }
4238
4239 if (board_config == ALC262_AUTO) {
4240 /* automatic parse from the BIOS config */
4241 err = alc262_parse_auto_config(codec);
4242 if (err < 0) {
4243 alc_free(codec);
4244 return err;
4245 } else if (! err) {
4246 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4247 board_config = ALC262_BASIC;
4248 }
4249 }
4250
4251 if (board_config != ALC262_AUTO)
4252 setup_preset(spec, &alc262_presets[board_config]);
4253
4254 spec->stream_name_analog = "ALC262 Analog";
4255 spec->stream_analog_playback = &alc262_pcm_analog_playback;
4256 spec->stream_analog_capture = &alc262_pcm_analog_capture;
4257
4258 spec->stream_name_digital = "ALC262 Digital";
4259 spec->stream_digital_playback = &alc262_pcm_digital_playback;
4260 spec->stream_digital_capture = &alc262_pcm_digital_capture;
4261
4262 if (! spec->adc_nids && spec->input_mux) {
4263 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004264 unsigned int wcap = get_wcaps(codec, 0x07);
4265
Kailang Yangdf694da2005-12-05 19:42:22 +01004266 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4267 if (wcap != AC_WID_AUD_IN) {
4268 spec->adc_nids = alc262_adc_nids_alt;
4269 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
4270 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
4271 spec->num_mixers++;
4272 } else {
4273 spec->adc_nids = alc262_adc_nids;
4274 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
4275 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
4276 spec->num_mixers++;
4277 }
4278 }
4279
4280 codec->patch_ops = alc_patch_ops;
4281 if (board_config == ALC262_AUTO)
4282 codec->patch_ops.init = alc262_auto_init;
4283
4284 return 0;
4285}
4286
4287
4288/*
4289 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4290 */
4291
4292/*
4293 * set the path ways for 2 channel output
4294 * need to set the codec line out and mic 1 pin widgets to inputs
4295 */
4296static struct hda_verb alc861_threestack_ch2_init[] = {
4297 /* set pin widget 1Ah (line in) for input */
4298 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4299 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4300 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4301
4302 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4305 { } /* end */
4306};
4307/*
4308 * 6ch mode
4309 * need to set the codec line out and mic 1 pin widgets to outputs
4310 */
4311static struct hda_verb alc861_threestack_ch6_init[] = {
4312 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4313 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4314 /* set pin widget 18h (mic1) for output (CLFE)*/
4315 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4316
4317 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4318 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4319
4320 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4321 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4322 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4323 { } /* end */
4324};
4325
4326static struct hda_channel_mode alc861_threestack_modes[2] = {
4327 { 2, alc861_threestack_ch2_init },
4328 { 6, alc861_threestack_ch6_init },
4329};
4330
4331/* patch-ALC861 */
4332
4333static struct snd_kcontrol_new alc861_base_mixer[] = {
4334 /* output mixer control */
4335 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4336 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4337 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4338 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4339 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
4340
4341 /*Input mixer control */
4342 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4343 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4344 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4345 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4346 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4347 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4349 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4352
4353 /* Capture mixer control */
4354 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4355 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4356 {
4357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4358 .name = "Capture Source",
4359 .count = 1,
4360 .info = alc_mux_enum_info,
4361 .get = alc_mux_enum_get,
4362 .put = alc_mux_enum_put,
4363 },
4364 { } /* end */
4365};
4366
4367static struct snd_kcontrol_new alc861_3ST_mixer[] = {
4368 /* output mixer control */
4369 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4370 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4371 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4372 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4373 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4374
4375 /* Input mixer control */
4376 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4377 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4378 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4379 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4380 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4381 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4383 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4386
4387 /* Capture mixer control */
4388 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4389 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4390 {
4391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4392 .name = "Capture Source",
4393 .count = 1,
4394 .info = alc_mux_enum_info,
4395 .get = alc_mux_enum_get,
4396 .put = alc_mux_enum_put,
4397 },
4398 {
4399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4400 .name = "Channel Mode",
4401 .info = alc_ch_mode_info,
4402 .get = alc_ch_mode_get,
4403 .put = alc_ch_mode_put,
4404 .private_value = ARRAY_SIZE(alc861_threestack_modes),
4405 },
4406 { } /* end */
4407};
4408
4409/*
4410 * generic initialization of ADC, input mixers and output mixers
4411 */
4412static struct hda_verb alc861_base_init_verbs[] = {
4413 /*
4414 * Unmute ADC0 and set the default input to mic-in
4415 */
4416 /* port-A for surround (rear panel) */
4417 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4418 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
4419 /* port-B for mic-in (rear panel) with vref */
4420 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4421 /* port-C for line-in (rear panel) */
4422 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4423 /* port-D for Front */
4424 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4425 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4426 /* port-E for HP out (front panel) */
4427 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4428 /* route front PCM to HP */
4429 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4430 /* port-F for mic-in (front panel) with vref */
4431 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4432 /* port-G for CLFE (rear panel) */
4433 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4434 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
4435 /* port-H for side (rear panel) */
4436 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4437 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
4438 /* CD-in */
4439 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4440 /* route front mic to ADC1*/
4441 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4443
4444 /* Unmute DAC0~3 & spdif out*/
4445 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4446 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4447 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4448 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4450
4451 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4452 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4453 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4454 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4455 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4456
4457 /* Unmute Stereo Mixer 15 */
4458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4462
4463 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4464 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4465 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4466 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4467 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4469 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4473
4474 { }
4475};
4476
4477static struct hda_verb alc861_threestack_init_verbs[] = {
4478 /*
4479 * Unmute ADC0 and set the default input to mic-in
4480 */
4481 /* port-A for surround (rear panel) */
4482 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4483 /* port-B for mic-in (rear panel) with vref */
4484 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4485 /* port-C for line-in (rear panel) */
4486 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4487 /* port-D for Front */
4488 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4489 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4490 /* port-E for HP out (front panel) */
4491 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4492 /* route front PCM to HP */
4493 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4494 /* port-F for mic-in (front panel) with vref */
4495 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4496 /* port-G for CLFE (rear panel) */
4497 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4498 /* port-H for side (rear panel) */
4499 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4500 /* CD-in */
4501 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4502 /* route front mic to ADC1*/
4503 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4505 /* Unmute DAC0~3 & spdif out*/
4506 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4507 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4508 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4509 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4511
4512 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4513 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4515 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4516 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4517
4518 /* Unmute Stereo Mixer 15 */
4519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4523
4524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4525 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4527 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4528 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4534 { }
4535};
4536/*
4537 * generic initialization of ADC, input mixers and output mixers
4538 */
4539static struct hda_verb alc861_auto_init_verbs[] = {
4540 /*
4541 * Unmute ADC0 and set the default input to mic-in
4542 */
4543// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4545
4546 /* Unmute DAC0~3 & spdif out*/
4547 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4548 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4549 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4550 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4552
4553 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4554 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4555 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4556 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4557 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4558
4559 /* Unmute Stereo Mixer 15 */
4560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
4564
4565 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4566 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4567 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4568 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4573
4574 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4578 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4579 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4580 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4581 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4582
4583 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
4584
4585 { }
4586};
4587
4588/* pcm configuration: identiacal with ALC880 */
4589#define alc861_pcm_analog_playback alc880_pcm_analog_playback
4590#define alc861_pcm_analog_capture alc880_pcm_analog_capture
4591#define alc861_pcm_digital_playback alc880_pcm_digital_playback
4592#define alc861_pcm_digital_capture alc880_pcm_digital_capture
4593
4594
4595#define ALC861_DIGOUT_NID 0x07
4596
4597static struct hda_channel_mode alc861_8ch_modes[1] = {
4598 { 8, NULL }
4599};
4600
4601static hda_nid_t alc861_dac_nids[4] = {
4602 /* front, surround, clfe, side */
4603 0x03, 0x06, 0x05, 0x04
4604};
4605
4606static hda_nid_t alc861_adc_nids[1] = {
4607 /* ADC0-2 */
4608 0x08,
4609};
4610
4611static struct hda_input_mux alc861_capture_source = {
4612 .num_items = 5,
4613 .items = {
4614 { "Mic", 0x0 },
4615 { "Front Mic", 0x3 },
4616 { "Line", 0x1 },
4617 { "CD", 0x4 },
4618 { "Mixer", 0x5 },
4619 },
4620};
4621
4622/* fill in the dac_nids table from the parsed pin configuration */
4623static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4624{
4625 int i;
4626 hda_nid_t nid;
4627
4628 spec->multiout.dac_nids = spec->private_dac_nids;
4629 for (i = 0; i < cfg->line_outs; i++) {
4630 nid = cfg->line_out_pins[i];
4631 if (nid) {
4632 if (i >= ARRAY_SIZE(alc861_dac_nids))
4633 continue;
4634 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
4635 }
4636 }
4637 spec->multiout.num_dacs = cfg->line_outs;
4638 return 0;
4639}
4640
4641/* add playback controls from the parsed DAC table */
4642static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
4643 const struct auto_pin_cfg *cfg)
4644{
4645 char name[32];
4646 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
4647 hda_nid_t nid;
4648 int i, idx, err;
4649
4650 for (i = 0; i < cfg->line_outs; i++) {
4651 nid = spec->multiout.dac_nids[i];
4652 if (! nid)
4653 continue;
4654 if (nid == 0x05) {
4655 /* Center/LFE */
4656 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
4657 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
4658 return err;
4659 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
4660 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4661 return err;
4662 } else {
4663 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
4664 if (nid == alc861_dac_nids[idx])
4665 break;
4666 sprintf(name, "%s Playback Switch", chname[idx]);
4667 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4668 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4669 return err;
4670 }
4671 }
4672 return 0;
4673}
4674
4675static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
4676{
4677 int err;
4678 hda_nid_t nid;
4679
4680 if (! pin)
4681 return 0;
4682
4683 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
4684 nid = 0x03;
4685 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4686 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4687 return err;
4688 spec->multiout.hp_nid = nid;
4689 }
4690 return 0;
4691}
4692
4693/* create playback/capture controls for input pins */
4694static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4695{
Kailang Yangdf694da2005-12-05 19:42:22 +01004696 struct hda_input_mux *imux = &spec->private_imux;
4697 int i, err, idx, idx1;
4698
4699 for (i = 0; i < AUTO_PIN_LAST; i++) {
4700 switch(cfg->input_pins[i]) {
4701 case 0x0c:
4702 idx1 = 1;
4703 idx = 2; // Line In
4704 break;
4705 case 0x0f:
4706 idx1 = 2;
4707 idx = 2; // Line In
4708 break;
4709 case 0x0d:
4710 idx1 = 0;
4711 idx = 1; // Mic In
4712 break;
4713 case 0x10:
4714 idx1 = 3;
4715 idx = 1; // Mic In
4716 break;
4717 case 0x11:
4718 idx1 = 4;
4719 idx = 0; // CD
4720 break;
4721 default:
4722 continue;
4723 }
4724
Takashi Iwai4a471b72005-12-07 13:56:29 +01004725 err = new_analog_input(spec, cfg->input_pins[i],
4726 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 if (err < 0)
4728 return err;
4729
Takashi Iwai4a471b72005-12-07 13:56:29 +01004730 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004731 imux->items[imux->num_items].index = idx1;
4732 imux->num_items++;
4733 }
4734 return 0;
4735}
4736
4737static struct snd_kcontrol_new alc861_capture_mixer[] = {
4738 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4739 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4740
4741 {
4742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4743 /* The multiple "Capture Source" controls confuse alsamixer
4744 * So call somewhat different..
4745 *FIXME: the controls appear in the "playback" view!
4746 */
4747 /* .name = "Capture Source", */
4748 .name = "Input Source",
4749 .count = 1,
4750 .info = alc_mux_enum_info,
4751 .get = alc_mux_enum_get,
4752 .put = alc_mux_enum_put,
4753 },
4754 { } /* end */
4755};
4756
4757static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
4758 int pin_type, int dac_idx)
4759{
4760 /* set as output */
4761
4762 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4763 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4764
4765}
4766
4767static void alc861_auto_init_multi_out(struct hda_codec *codec)
4768{
4769 struct alc_spec *spec = codec->spec;
4770 int i;
4771
4772 for (i = 0; i < spec->autocfg.line_outs; i++) {
4773 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4774 if (nid)
4775 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
4776 }
4777}
4778
4779static void alc861_auto_init_hp_out(struct hda_codec *codec)
4780{
4781 struct alc_spec *spec = codec->spec;
4782 hda_nid_t pin;
4783
4784 pin = spec->autocfg.hp_pin;
4785 if (pin) /* connect to front */
4786 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
4787}
4788
4789static void alc861_auto_init_analog_input(struct hda_codec *codec)
4790{
4791 struct alc_spec *spec = codec->spec;
4792 int i;
4793
4794 for (i = 0; i < AUTO_PIN_LAST; i++) {
4795 hda_nid_t nid = spec->autocfg.input_pins[i];
4796 if ((nid>=0x0c) && (nid <=0x11)) {
4797 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4798 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4799 }
4800 }
4801}
4802
4803/* parse the BIOS configuration and set up the alc_spec */
4804/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
4805static int alc861_parse_auto_config(struct hda_codec *codec)
4806{
4807 struct alc_spec *spec = codec->spec;
4808 int err;
4809 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
4810
4811 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4812 alc861_ignore)) < 0)
4813 return err;
4814 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4815 ! spec->autocfg.hp_pin)
4816 return 0; /* can't find valid BIOS pin config */
4817
4818 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
4819 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4820 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
4821 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4822 return err;
4823
4824 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4825
4826 if (spec->autocfg.dig_out_pin)
4827 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
4828
4829 if (spec->kctl_alloc)
4830 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4831
4832 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
4833
4834 spec->input_mux = &spec->private_imux;
4835
4836 spec->adc_nids = alc861_adc_nids;
4837 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
4838 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
4839 spec->num_mixers++;
4840
4841 return 1;
4842}
4843
4844/* init callback for auto-configuration model -- overriding the default init */
4845static int alc861_auto_init(struct hda_codec *codec)
4846{
4847 alc_init(codec);
4848 alc861_auto_init_multi_out(codec);
4849 alc861_auto_init_hp_out(codec);
4850 alc861_auto_init_analog_input(codec);
4851
4852 return 0;
4853}
4854
4855
4856/*
4857 * configuration and preset
4858 */
4859static struct hda_board_config alc861_cfg_tbl[] = {
4860 { .modelname = "3stack", .config = ALC861_3ST },
4861 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
4862 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
4863 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
4864 { .modelname = "auto", .config = ALC861_AUTO },
4865 {}
4866};
4867
4868static struct alc_config_preset alc861_presets[] = {
4869 [ALC861_3ST] = {
4870 .mixers = { alc861_3ST_mixer },
4871 .init_verbs = { alc861_threestack_init_verbs },
4872 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4873 .dac_nids = alc861_dac_nids,
4874 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4875 .channel_mode = alc861_threestack_modes,
4876 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4877 .adc_nids = alc861_adc_nids,
4878 .input_mux = &alc861_capture_source,
4879 },
4880 [ALC861_3ST_DIG] = {
4881 .mixers = { alc861_base_mixer },
4882 .init_verbs = { alc861_threestack_init_verbs },
4883 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4884 .dac_nids = alc861_dac_nids,
4885 .dig_out_nid = ALC861_DIGOUT_NID,
4886 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4887 .channel_mode = alc861_threestack_modes,
4888 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4889 .adc_nids = alc861_adc_nids,
4890 .input_mux = &alc861_capture_source,
4891 },
4892 [ALC861_6ST_DIG] = {
4893 .mixers = { alc861_base_mixer },
4894 .init_verbs = { alc861_base_init_verbs },
4895 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4896 .dac_nids = alc861_dac_nids,
4897 .dig_out_nid = ALC861_DIGOUT_NID,
4898 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
4899 .channel_mode = alc861_8ch_modes,
4900 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4901 .adc_nids = alc861_adc_nids,
4902 .input_mux = &alc861_capture_source,
4903 },
4904};
4905
4906
4907static int patch_alc861(struct hda_codec *codec)
4908{
4909 struct alc_spec *spec;
4910 int board_config;
4911 int err;
4912
4913 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4914 if (spec == NULL)
4915 return -ENOMEM;
4916
4917 codec->spec = spec;
4918
4919 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
4920 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
4921 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
4922 board_config = ALC861_AUTO;
4923 }
4924
4925 if (board_config == ALC861_AUTO) {
4926 /* automatic parse from the BIOS config */
4927 err = alc861_parse_auto_config(codec);
4928 if (err < 0) {
4929 alc_free(codec);
4930 return err;
4931 } else if (! err) {
4932 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4933 board_config = ALC861_3ST_DIG;
4934 }
4935 }
4936
4937 if (board_config != ALC861_AUTO)
4938 setup_preset(spec, &alc861_presets[board_config]);
4939
4940 spec->stream_name_analog = "ALC861 Analog";
4941 spec->stream_analog_playback = &alc861_pcm_analog_playback;
4942 spec->stream_analog_capture = &alc861_pcm_analog_capture;
4943
4944 spec->stream_name_digital = "ALC861 Digital";
4945 spec->stream_digital_playback = &alc861_pcm_digital_playback;
4946 spec->stream_digital_capture = &alc861_pcm_digital_capture;
4947
4948 codec->patch_ops = alc_patch_ops;
4949 if (board_config == ALC861_AUTO)
4950 codec->patch_ops.init = alc861_auto_init;
4951
4952 return 0;
4953}
4954
4955/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07004956 * patch entries
4957 */
4958struct hda_codec_preset snd_hda_preset_realtek[] = {
4959 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004960 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07004961 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
4962 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004963 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
4964 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4965 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07004966 {} /* terminator */
4967};