blob: 543980d89b83c564335cc6d0bfaab814428a4822 [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>
9 *
10 * This driver is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This driver is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <sound/driver.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
34
35/* ALC880 board config type */
36enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 ALC880_3ST,
38 ALC880_3ST_DIG,
39 ALC880_5ST,
40 ALC880_5ST_DIG,
41 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020042 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020043 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020044 ALC880_6ST_DIG,
45 ALC880_F1734,
46 ALC880_ASUS,
47 ALC880_ASUS_DIG,
48 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010049 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_UNIWILL_DIG,
Kailang Yangdf694da2005-12-05 19:42:22 +010051 ALC880_CLEVO,
52 ALC880_TCL_S700,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020053#ifdef CONFIG_SND_DEBUG
54 ALC880_TEST,
55#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010056 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_MODEL_LAST /* last tag */
58};
59
60/* ALC260 models */
61enum {
62 ALC260_BASIC,
63 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010064 ALC260_HP_3013,
65 ALC260_FUJITSU_S702X,
66 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068};
69
Kailang Yangdf694da2005-12-05 19:42:22 +010070/* ALC262 models */
71enum {
72 ALC262_BASIC,
73 ALC262_AUTO,
74 ALC262_MODEL_LAST /* last tag */
75};
76
77/* ALC861 models */
78enum {
79 ALC861_3ST,
80 ALC861_3ST_DIG,
81 ALC861_6ST_DIG,
82 ALC861_AUTO,
83 ALC861_MODEL_LAST,
84};
85
86/* ALC882 models */
87enum {
88 ALC882_3ST_DIG,
89 ALC882_6ST_DIG,
90 ALC882_AUTO,
91 ALC882_MODEL_LAST,
92};
93
94/* for GPIO Poll */
95#define GPIO_MASK 0x03
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097struct alc_spec {
98 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +010099 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 unsigned int num_mixers;
101
Kailang Yangdf694da2005-12-05 19:42:22 +0100102 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200103 * don't forget NULL termination!
104 */
105 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Takashi Iwai16ded522005-06-10 19:58:24 +0200107 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 struct hda_pcm_stream *stream_analog_playback;
109 struct hda_pcm_stream *stream_analog_capture;
110
Takashi Iwai16ded522005-06-10 19:58:24 +0200111 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 struct hda_pcm_stream *stream_digital_playback;
113 struct hda_pcm_stream *stream_digital_capture;
114
115 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200116 struct hda_multi_out multiout; /* playback set-up
117 * max_channels, dacs must be set
118 * dig_out_nid and hp_nid are optional
119 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121 /* capture */
122 unsigned int num_adc_nids;
123 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200124 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126 /* capture source */
127 const struct hda_input_mux *input_mux;
128 unsigned int cur_mux[3];
129
130 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100131 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 int num_channel_mode;
133
134 /* PCM information */
Takashi Iwai16ded522005-06-10 19:58:24 +0200135 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200136
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200137 /* dynamic controls, init_verbs and input_mux */
138 struct auto_pin_cfg autocfg;
139 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100140 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200141 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100142 hda_nid_t private_dac_nids[5];
143};
144
145/*
146 * configuration template - to be copied to the spec instance
147 */
148struct alc_config_preset {
149 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
150 const struct hda_verb *init_verbs[5];
151 unsigned int num_dacs;
152 hda_nid_t *dac_nids;
153 hda_nid_t dig_out_nid; /* optional */
154 hda_nid_t hp_nid; /* optional */
155 unsigned int num_adc_nids;
156 hda_nid_t *adc_nids;
157 hda_nid_t dig_in_nid;
158 unsigned int num_channel_mode;
159 const struct hda_channel_mode *channel_mode;
160 const struct hda_input_mux *input_mux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161};
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164/*
165 * input MUX handling
166 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100167static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168{
169 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
170 struct alc_spec *spec = codec->spec;
171 return snd_hda_input_mux_info(spec->input_mux, uinfo);
172}
173
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100174static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
177 struct alc_spec *spec = codec->spec;
178 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
179
180 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
181 return 0;
182}
183
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100184static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
187 struct alc_spec *spec = codec->spec;
188 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
189 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
190 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
191}
192
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194/*
195 * channel mode setting
196 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100197static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198{
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100201 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
202 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203}
204
Kailang Yangdf694da2005-12-05 19:42:22 +0100205static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206{
207 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
208 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100209 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
210 spec->num_channel_mode, spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211}
212
Kailang Yangdf694da2005-12-05 19:42:22 +0100213static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214{
215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
216 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100217 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
218 spec->num_channel_mode, &spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}
220
221
222/*
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200223 * Control of pin widget settings via the mixer. Only boolean settings are
224 * supported, so VrefEn can't be controlled using these functions as they
225 * stand.
226 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100227static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200228{
229 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
230 uinfo->count = 1;
231 uinfo->value.integer.min = 0;
232 uinfo->value.integer.max = 1;
233 return 0;
234}
235
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100236static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200237{
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239 hda_nid_t nid = kcontrol->private_value & 0xffff;
240 long mask = (kcontrol->private_value >> 16) & 0xff;
241 long *valp = ucontrol->value.integer.value;
242
243 *valp = 0;
244 if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask)
245 *valp = 1;
246 return 0;
247}
248
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100249static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200250{
251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
252 hda_nid_t nid = kcontrol->private_value & 0xffff;
253 long mask = (kcontrol->private_value >> 16) & 0xff;
254 long *valp = ucontrol->value.integer.value;
255 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
256 int change = ((pinctl & mask)!=0) != *valp;
257
258 if (change)
259 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
260 *valp?(pinctl|mask):(pinctl&~mask));
261 return change;
262}
263
264#define ALC_PINCTL_SWITCH(xname, nid, mask) \
265 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
266 .info = alc_pinctl_switch_info, \
267 .get = alc_pinctl_switch_get, \
268 .put = alc_pinctl_switch_put, \
269 .private_value = (nid) | (mask<<16) }
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200270
Kailang Yangdf694da2005-12-05 19:42:22 +0100271
272/*
273 * set up from the preset table
274 */
275static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
276{
277 int i;
278
279 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
280 spec->mixers[spec->num_mixers++] = preset->mixers[i];
281 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
282 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
283
284 spec->channel_mode = preset->channel_mode;
285 spec->num_channel_mode = preset->num_channel_mode;
286
287 spec->multiout.max_channels = spec->channel_mode[0].channels;
288
289 spec->multiout.num_dacs = preset->num_dacs;
290 spec->multiout.dac_nids = preset->dac_nids;
291 spec->multiout.dig_out_nid = preset->dig_out_nid;
292 spec->multiout.hp_nid = preset->hp_nid;
293
294 spec->input_mux = preset->input_mux;
295
296 spec->num_adc_nids = preset->num_adc_nids;
297 spec->adc_nids = preset->adc_nids;
298 spec->dig_in_nid = preset->dig_in_nid;
299}
300
Takashi Iwai41e41f12005-06-08 14:48:49 +0200301/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200302 * ALC880 3-stack model
303 *
304 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
305 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
306 * HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 */
308
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200309static hda_nid_t alc880_dac_nids[4] = {
310 /* front, rear, clfe, rear_surr */
311 0x02, 0x05, 0x04, 0x03
312};
313
314static hda_nid_t alc880_adc_nids[3] = {
315 /* ADC0-2 */
316 0x07, 0x08, 0x09,
317};
318
319/* The datasheet says the node 0x07 is connected from inputs,
320 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100321 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200323static hda_nid_t alc880_adc_nids_alt[2] = {
324 /* ADC1-2 */
325 0x08, 0x09,
326};
327
328#define ALC880_DIGOUT_NID 0x06
329#define ALC880_DIGIN_NID 0x0a
330
331static struct hda_input_mux alc880_capture_source = {
332 .num_items = 4,
333 .items = {
334 { "Mic", 0x0 },
335 { "Front Mic", 0x3 },
336 { "Line", 0x2 },
337 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200339};
340
341/* channel source setting (2/6 channel selection for 3-stack) */
342/* 2ch mode */
343static struct hda_verb alc880_threestack_ch2_init[] = {
344 /* set line-in to input, mute it */
345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
347 /* set mic-in to input vref 80%, mute it */
348 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
349 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 { } /* end */
351};
352
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200353/* 6ch mode */
354static struct hda_verb alc880_threestack_ch6_init[] = {
355 /* set line-in to output, unmute it */
356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
358 /* set mic-in to output, unmute it */
359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
361 { } /* end */
362};
363
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100364static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200365 { 2, alc880_threestack_ch2_init },
366 { 6, alc880_threestack_ch6_init },
367};
368
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100369static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100373 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
386 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
387 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200389 {
390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
391 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100392 .info = alc_ch_mode_info,
393 .get = alc_ch_mode_get,
394 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200395 },
396 { } /* end */
397};
398
399/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100400static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200401 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
402 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
403 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
404 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
405 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
406 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
407 {
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 /* The multiple "Capture Source" controls confuse alsamixer
410 * So call somewhat different..
411 * FIXME: the controls appear in the "playback" view!
412 */
413 /* .name = "Capture Source", */
414 .name = "Input Source",
415 .count = 3,
416 .info = alc_mux_enum_info,
417 .get = alc_mux_enum_get,
418 .put = alc_mux_enum_put,
419 },
420 { } /* end */
421};
422
423/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100424static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200425 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
426 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
427 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
428 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 {
430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
431 /* The multiple "Capture Source" controls confuse alsamixer
432 * So call somewhat different..
433 * FIXME: the controls appear in the "playback" view!
434 */
435 /* .name = "Capture Source", */
436 .name = "Input Source",
437 .count = 2,
438 .info = alc_mux_enum_info,
439 .get = alc_mux_enum_get,
440 .put = alc_mux_enum_put,
441 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 { } /* end */
443};
444
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200445
446
447/*
448 * ALC880 5-stack model
449 *
450 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
451 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
452 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
453 */
454
455/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100456static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200457 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100458 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 { } /* end */
460};
461
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200462/* channel source setting (6/8 channel selection for 5-stack) */
463/* 6ch mode */
464static struct hda_verb alc880_fivestack_ch6_init[] = {
465 /* set line-in to input, mute it */
466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200468 { } /* end */
469};
470
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200471/* 8ch mode */
472static struct hda_verb alc880_fivestack_ch8_init[] = {
473 /* set line-in to output, unmute it */
474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
476 { } /* end */
477};
478
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100479static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200480 { 6, alc880_fivestack_ch6_init },
481 { 8, alc880_fivestack_ch8_init },
482};
483
484
485/*
486 * ALC880 6-stack model
487 *
488 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
489 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
490 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
491 */
492
493static hda_nid_t alc880_6st_dac_nids[4] = {
494 /* front, rear, clfe, rear_surr */
495 0x02, 0x03, 0x04, 0x05
496};
497
498static struct hda_input_mux alc880_6stack_capture_source = {
499 .num_items = 4,
500 .items = {
501 { "Mic", 0x0 },
502 { "Front Mic", 0x1 },
503 { "Line", 0x2 },
504 { "CD", 0x4 },
505 },
506};
507
508/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100509static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200510 { 8, NULL },
511};
512
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100513static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100517 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200518 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100520 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
521 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200522 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100523 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
526 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
527 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
532 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
533 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200534 {
535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
536 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100537 .info = alc_ch_mode_info,
538 .get = alc_ch_mode_get,
539 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200540 },
541 { } /* end */
542};
543
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200544
545/*
546 * ALC880 W810 model
547 *
548 * W810 has rear IO for:
549 * Front (DAC 02)
550 * Surround (DAC 03)
551 * Center/LFE (DAC 04)
552 * Digital out (06)
553 *
554 * The system also has a pair of internal speakers, and a headphone jack.
555 * These are both connected to Line2 on the codec, hence to DAC 02.
556 *
557 * There is a variable resistor to control the speaker or headphone
558 * volume. This is a hardware-only device without a software API.
559 *
560 * Plugging headphones in will disable the internal speakers. This is
561 * implemented in hardware, not via the driver using jack sense. In
562 * a similar fashion, plugging into the rear socket marked "front" will
563 * disable both the speakers and headphones.
564 *
565 * For input, there's a microphone jack, and an "audio in" jack.
566 * These may not do anything useful with this driver yet, because I
567 * haven't setup any initialization verbs for these yet...
568 */
569
570static hda_nid_t alc880_w810_dac_nids[3] = {
571 /* front, rear/surround, clfe */
572 0x02, 0x03, 0x04
573};
574
575/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100576static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200577 { 6, NULL }
578};
579
580/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100581static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200584 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100585 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200586 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
587 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100588 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
589 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
591 { } /* end */
592};
593
594
595/*
596 * Z710V model
597 *
598 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
599 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
600 */
601
602static hda_nid_t alc880_z71v_dac_nids[1] = {
603 0x02
604};
605#define ALC880_Z71V_HP_DAC 0x03
606
607/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100608static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200609 { 2, NULL }
610};
611
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100612static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
621 { } /* end */
622};
623
624
625/* FIXME! */
626/*
627 * ALC880 F1734 model
628 *
629 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
630 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
631 */
632
633static hda_nid_t alc880_f1734_dac_nids[1] = {
634 0x03
635};
636#define ALC880_F1734_HP_DAC 0x02
637
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100638static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100640 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200641 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100642 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200647 { } /* end */
648};
649
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200650
651/* FIXME! */
652/*
653 * ALC880 ASUS model
654 *
655 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
656 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
657 * Mic = 0x18, Line = 0x1a
658 */
659
660#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
661#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
662
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100663static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100665 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100667 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100670 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200678 {
679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
680 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100681 .info = alc_ch_mode_info,
682 .get = alc_ch_mode_get,
683 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200684 },
685 { } /* end */
686};
687
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200688/* FIXME! */
689/*
690 * ALC880 ASUS W1V model
691 *
692 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
693 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
694 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
695 */
696
697/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100698static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200699 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
700 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200701 { } /* end */
702};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200703
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200704/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100705static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200706 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
707 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
708 { } /* end */
709};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200710
Kailang Yangdf694da2005-12-05 19:42:22 +0100711/* TCL S700 */
712static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
714 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
717 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
720 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
721 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
722 {
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
724 /* The multiple "Capture Source" controls confuse alsamixer
725 * So call somewhat different..
726 * FIXME: the controls appear in the "playback" view!
727 */
728 /* .name = "Capture Source", */
729 .name = "Input Source",
730 .count = 1,
731 .info = alc_mux_enum_info,
732 .get = alc_mux_enum_get,
733 .put = alc_mux_enum_put,
734 },
735 { } /* end */
736};
737
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200739 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 */
741static int alc_build_controls(struct hda_codec *codec)
742{
743 struct alc_spec *spec = codec->spec;
744 int err;
745 int i;
746
747 for (i = 0; i < spec->num_mixers; i++) {
748 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
749 if (err < 0)
750 return err;
751 }
752
753 if (spec->multiout.dig_out_nid) {
754 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
755 if (err < 0)
756 return err;
757 }
758 if (spec->dig_in_nid) {
759 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
760 if (err < 0)
761 return err;
762 }
763 return 0;
764}
765
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200766
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767/*
768 * initialize the codec volumes, etc
769 */
770
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200771/*
772 * generic initialization of ADC, input mixers and output mixers
773 */
774static struct hda_verb alc880_volume_init_verbs[] = {
775 /*
776 * Unmute ADC0-2 and set the default input to mic-in
777 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200778 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200782 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200785 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
786 * mixer widget
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 * Note: PASD motherboards uses the Line In 2 as the input for front panel
788 * mic (mic 2)
789 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200790 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200797 /*
798 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200800 /* set vol=0 to output mixers */
801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
805 /* set up input amps for analog loopback */
806 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +0200807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815
816 { }
817};
818
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200819/*
820 * 3-stack pin configuration:
821 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
822 */
823static struct hda_verb alc880_pin_3stack_init_verbs[] = {
824 /*
825 * preset connection lists of input pins
826 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
827 */
828 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
829 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
830 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
831
832 /*
833 * Set pin mode and muting
834 */
835 /* set front pin widgets 0x14 for output */
836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
838 /* Mic1 (rear panel) pin widget for input and vref at 80% */
839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
841 /* Mic2 (as headphone out) for HP output */
842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
844 /* Line In pin widget for input */
845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
846 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
847 /* Line2 (as front mic) pin widget for input and vref at 80% */
848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
849 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
850 /* CD pin widget for input */
851 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
852
853 { }
854};
855
856/*
857 * 5-stack pin configuration:
858 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
859 * line-in/side = 0x1a, f-mic = 0x1b
860 */
861static struct hda_verb alc880_pin_5stack_init_verbs[] = {
862 /*
863 * preset connection lists of input pins
864 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
865 */
866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
867 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
868
869 /*
870 * Set pin mode and muting
871 */
872 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +0200873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
876 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200877 /* unmute pins for output (no gain on this amp) */
878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
882
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +0200884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
886 /* Mic2 (as headphone out) for HP output */
887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +0200888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200889 /* Line In pin widget for input */
890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
892 /* Line2 (as front mic) pin widget for input and vref at 80% */
893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
895 /* CD pin widget for input */
896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897
898 { }
899};
900
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200901/*
902 * W810 pin configuration:
903 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
904 */
905static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 /* hphone/speaker input selector: front DAC */
907 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
908
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
915
916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +0200917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 { }
920};
921
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200922/*
923 * Z71V pin configuration:
924 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
925 */
926static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200927 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +0200929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200931
Takashi Iwai16ded522005-06-10 19:58:24 +0200932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +0200934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200936
937 { }
938};
939
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200940/*
941 * 6-stack pin configuration:
942 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
943 * line = 0x1a, HP = 0x1b
944 */
945static struct hda_verb alc880_pin_6stack_init_verbs[] = {
946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
947
Takashi Iwai16ded522005-06-10 19:58:24 +0200948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200954 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
956
Takashi Iwai16ded522005-06-10 19:58:24 +0200957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +0200964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
966
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200967 { }
968};
Takashi Iwai16ded522005-06-10 19:58:24 +0200969
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200970/* FIXME! */
971/*
972 * F1734 pin configuration:
973 * HP = 0x14, speaker-out = 0x15, mic = 0x18
974 */
975static struct hda_verb alc880_pin_f1734_init_verbs[] = {
976 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
977 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
978 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
979 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
980
981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
985
986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
988 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
989 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
992 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
994 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +0200995
996 { }
997};
998
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200999/* FIXME! */
1000/*
1001 * ASUS pin configuration:
1002 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1003 */
1004static struct hda_verb alc880_pin_asus_init_verbs[] = {
1005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1006 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1007 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1009
1010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1014 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1018
1019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1025 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1028
1029 { }
1030};
1031
1032/* Enable GPIO mask and set output */
1033static struct hda_verb alc880_gpio1_init_verbs[] = {
1034 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1035 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1036 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001037
1038 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001039};
1040
1041/* Enable GPIO mask and set output */
1042static struct hda_verb alc880_gpio2_init_verbs[] = {
1043 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1044 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1045 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001046
1047 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001048};
1049
Kailang Yangdf694da2005-12-05 19:42:22 +01001050/* Clevo m520g init */
1051static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1052 /* headphone output */
1053 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1054 /* line-out */
1055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1057 /* Line-in */
1058 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1060 /* CD */
1061 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1062 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1063 /* Mic1 (rear panel) */
1064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1066 /* Mic2 (front panel) */
1067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1069 /* headphone */
1070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1072 /* change to EAPD mode */
1073 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1074 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1075
1076 { }
1077};
1078
1079static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1080 /* Headphone output */
1081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1082 /* Front output*/
1083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1084 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1085
1086 /* Line In pin widget for input */
1087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1088 /* CD pin widget for input */
1089 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1090 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1092
1093 /* change to EAPD mode */
1094 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1095 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1096
1097 { }
1098};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001099
1100/*
1101 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001102
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103static int alc_init(struct hda_codec *codec)
1104{
1105 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001106 unsigned int i;
1107
1108 for (i = 0; i < spec->num_init_verbs; i++)
1109 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 return 0;
1111}
1112
1113#ifdef CONFIG_PM
1114/*
1115 * resume
1116 */
1117static int alc_resume(struct hda_codec *codec)
1118{
1119 struct alc_spec *spec = codec->spec;
1120 int i;
1121
1122 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001123 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 if (spec->multiout.dig_out_nid)
1126 snd_hda_resume_spdif_out(codec);
1127 if (spec->dig_in_nid)
1128 snd_hda_resume_spdif_in(codec);
1129
1130 return 0;
1131}
1132#endif
1133
1134/*
1135 * Analog playback callbacks
1136 */
1137static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1138 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001139 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140{
1141 struct alc_spec *spec = codec->spec;
1142 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1143}
1144
1145static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1146 struct hda_codec *codec,
1147 unsigned int stream_tag,
1148 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001149 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150{
1151 struct alc_spec *spec = codec->spec;
1152 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1153 format, substream);
1154}
1155
1156static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1157 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001158 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159{
1160 struct alc_spec *spec = codec->spec;
1161 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1162}
1163
1164/*
1165 * Digital out
1166 */
1167static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1168 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001169 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170{
1171 struct alc_spec *spec = codec->spec;
1172 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1173}
1174
1175static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1176 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001177 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178{
1179 struct alc_spec *spec = codec->spec;
1180 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1181}
1182
1183/*
1184 * Analog capture
1185 */
1186static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1187 struct hda_codec *codec,
1188 unsigned int stream_tag,
1189 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001190 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191{
1192 struct alc_spec *spec = codec->spec;
1193
1194 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1195 stream_tag, 0, format);
1196 return 0;
1197}
1198
1199static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1200 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001201 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202{
1203 struct alc_spec *spec = codec->spec;
1204
1205 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1206 return 0;
1207}
1208
1209
1210/*
1211 */
1212static struct hda_pcm_stream alc880_pcm_analog_playback = {
1213 .substreams = 1,
1214 .channels_min = 2,
1215 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001216 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 .ops = {
1218 .open = alc880_playback_pcm_open,
1219 .prepare = alc880_playback_pcm_prepare,
1220 .cleanup = alc880_playback_pcm_cleanup
1221 },
1222};
1223
1224static struct hda_pcm_stream alc880_pcm_analog_capture = {
1225 .substreams = 2,
1226 .channels_min = 2,
1227 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001228 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 .ops = {
1230 .prepare = alc880_capture_pcm_prepare,
1231 .cleanup = alc880_capture_pcm_cleanup
1232 },
1233};
1234
1235static struct hda_pcm_stream alc880_pcm_digital_playback = {
1236 .substreams = 1,
1237 .channels_min = 2,
1238 .channels_max = 2,
1239 /* NID is set in alc_build_pcms */
1240 .ops = {
1241 .open = alc880_dig_playback_pcm_open,
1242 .close = alc880_dig_playback_pcm_close
1243 },
1244};
1245
1246static struct hda_pcm_stream alc880_pcm_digital_capture = {
1247 .substreams = 1,
1248 .channels_min = 2,
1249 .channels_max = 2,
1250 /* NID is set in alc_build_pcms */
1251};
1252
1253static int alc_build_pcms(struct hda_codec *codec)
1254{
1255 struct alc_spec *spec = codec->spec;
1256 struct hda_pcm *info = spec->pcm_rec;
1257 int i;
1258
1259 codec->num_pcms = 1;
1260 codec->pcm_info = info;
1261
1262 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001263 if (spec->stream_analog_playback) {
1264 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1265 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1266 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1267 }
1268 if (spec->stream_analog_capture) {
1269 snd_assert(spec->adc_nids, return -EINVAL);
1270 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1271 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1272 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273
Takashi Iwai4a471b72005-12-07 13:56:29 +01001274 if (spec->channel_mode) {
1275 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1276 for (i = 0; i < spec->num_channel_mode; i++) {
1277 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1278 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1279 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 }
1281 }
1282
1283 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1284 codec->num_pcms++;
1285 info++;
1286 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001287 if (spec->multiout.dig_out_nid &&
1288 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1290 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1291 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001292 if (spec->dig_in_nid &&
1293 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1295 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1296 }
1297 }
1298
1299 return 0;
1300}
1301
1302static void alc_free(struct hda_codec *codec)
1303{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304 struct alc_spec *spec = codec->spec;
1305 unsigned int i;
1306
1307 if (! spec)
1308 return;
1309
1310 if (spec->kctl_alloc) {
1311 for (i = 0; i < spec->num_kctl_used; i++)
1312 kfree(spec->kctl_alloc[i].name);
1313 kfree(spec->kctl_alloc);
1314 }
1315 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316}
1317
1318/*
1319 */
1320static struct hda_codec_ops alc_patch_ops = {
1321 .build_controls = alc_build_controls,
1322 .build_pcms = alc_build_pcms,
1323 .init = alc_init,
1324 .free = alc_free,
1325#ifdef CONFIG_PM
1326 .resume = alc_resume,
1327#endif
1328};
1329
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001330
1331/*
1332 * Test configuration for debugging
1333 *
1334 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1335 * enum controls.
1336 */
1337#ifdef CONFIG_SND_DEBUG
1338static hda_nid_t alc880_test_dac_nids[4] = {
1339 0x02, 0x03, 0x04, 0x05
1340};
1341
1342static struct hda_input_mux alc880_test_capture_source = {
1343 .num_items = 5,
1344 .items = {
1345 { "In-1", 0x0 },
1346 { "In-2", 0x1 },
1347 { "In-3", 0x2 },
1348 { "In-4", 0x3 },
1349 { "CD", 0x4 },
1350 },
1351};
1352
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001353static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001354 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001355 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001356 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001357 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001358};
1359
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001360static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001361{
1362 static char *texts[] = {
1363 "N/A", "Line Out", "HP Out",
1364 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1365 };
1366 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1367 uinfo->count = 1;
1368 uinfo->value.enumerated.items = 8;
1369 if (uinfo->value.enumerated.item >= 8)
1370 uinfo->value.enumerated.item = 7;
1371 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1372 return 0;
1373}
1374
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001375static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001376{
1377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1378 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1379 unsigned int pin_ctl, item = 0;
1380
1381 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1382 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1383 if (pin_ctl & AC_PINCTL_OUT_EN) {
1384 if (pin_ctl & AC_PINCTL_HP_EN)
1385 item = 2;
1386 else
1387 item = 1;
1388 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1389 switch (pin_ctl & AC_PINCTL_VREFEN) {
1390 case AC_PINCTL_VREF_HIZ: item = 3; break;
1391 case AC_PINCTL_VREF_50: item = 4; break;
1392 case AC_PINCTL_VREF_GRD: item = 5; break;
1393 case AC_PINCTL_VREF_80: item = 6; break;
1394 case AC_PINCTL_VREF_100: item = 7; break;
1395 }
1396 }
1397 ucontrol->value.enumerated.item[0] = item;
1398 return 0;
1399}
1400
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001401static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001402{
1403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1404 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1405 static unsigned int ctls[] = {
1406 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1407 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1408 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1409 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1410 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1411 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1412 };
1413 unsigned int old_ctl, new_ctl;
1414
1415 old_ctl = snd_hda_codec_read(codec, nid, 0,
1416 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1417 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1418 if (old_ctl != new_ctl) {
1419 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1420 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1421 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1422 return 1;
1423 }
1424 return 0;
1425}
1426
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001427static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001428{
1429 static char *texts[] = {
1430 "Front", "Surround", "CLFE", "Side"
1431 };
1432 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1433 uinfo->count = 1;
1434 uinfo->value.enumerated.items = 4;
1435 if (uinfo->value.enumerated.item >= 4)
1436 uinfo->value.enumerated.item = 3;
1437 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1438 return 0;
1439}
1440
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001441static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001442{
1443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1444 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1445 unsigned int sel;
1446
1447 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1448 ucontrol->value.enumerated.item[0] = sel & 3;
1449 return 0;
1450}
1451
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001452static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001453{
1454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1455 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1456 unsigned int sel;
1457
1458 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1459 if (ucontrol->value.enumerated.item[0] != sel) {
1460 sel = ucontrol->value.enumerated.item[0] & 3;
1461 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1462 return 1;
1463 }
1464 return 0;
1465}
1466
1467#define PIN_CTL_TEST(xname,nid) { \
1468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1469 .name = xname, \
1470 .info = alc_test_pin_ctl_info, \
1471 .get = alc_test_pin_ctl_get, \
1472 .put = alc_test_pin_ctl_put, \
1473 .private_value = nid \
1474 }
1475
1476#define PIN_SRC_TEST(xname,nid) { \
1477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1478 .name = xname, \
1479 .info = alc_test_pin_src_info, \
1480 .get = alc_test_pin_src_get, \
1481 .put = alc_test_pin_src_put, \
1482 .private_value = nid \
1483 }
1484
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001485static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1488 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1489 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1492 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1493 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001494 PIN_CTL_TEST("Front Pin Mode", 0x14),
1495 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1496 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1497 PIN_CTL_TEST("Side Pin Mode", 0x17),
1498 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1499 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1500 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1501 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1502 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1503 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1504 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1505 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1506 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1507 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1508 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1509 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1510 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1511 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1512 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1513 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001516 {
1517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1518 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001519 .info = alc_ch_mode_info,
1520 .get = alc_ch_mode_get,
1521 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001522 },
1523 { } /* end */
1524};
1525
1526static struct hda_verb alc880_test_init_verbs[] = {
1527 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001536 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001541 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001546 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001551 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02001552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02001554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001557 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02001558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001562 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02001563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001569 /* Analog input/passthru */
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001575 { }
1576};
1577#endif
1578
Linus Torvalds1da177e2005-04-16 15:20:36 -07001579/*
1580 */
1581
1582static struct hda_board_config alc880_cfg_tbl[] = {
1583 /* Back 3 jack, front 2 jack */
1584 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001585 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1586 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1587 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1588 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1589 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1590 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1591 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1592 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1593 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1594 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1595 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1596 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1597 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1598 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1599 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1600 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1601 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1602 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1603 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1604 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1605 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1606 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1607 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1608 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1609 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1610 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1611 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1612 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1613 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1614 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1615 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1616 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01001617 /* TCL S700 */
1618 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619
1620 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02001621 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001622 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02001623 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624
1625 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1626 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001627 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe3c2005-08-15 20:01:40 +02001628 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01001629 /* Clevo m520G NB */
1630 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631
1632 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02001633 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1634 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1635 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636
1637 /* Back 5 jack, front 2 jack */
1638 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001639 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1640 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1641 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1642 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001643 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644
1645 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1646 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001647 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1648 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1649 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1650 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1651 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1652 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1653 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1654 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001655 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwai7a318a72005-06-28 14:16:21 +02001656 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02001657 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001658 /* note subvendor = 0 below */
1659 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660
1661 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02001662 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001664 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02001665 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001666
Takashi Iwaib6482d42005-06-27 15:32:43 +02001667 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01001668 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01001669 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02001670 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Takashi Iwaib6482d42005-06-27 15:32:43 +02001671
1672 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001673 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1674 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1675 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1676 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01001677 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
1678 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
1679 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
1680 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01001681 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001682
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02001684 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1685 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1686 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1687 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02001688 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001689 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1690 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1691 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1692 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1693 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1694 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Kailang Yangdf694da2005-12-05 19:42:22 +01001695 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001696
1697 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1698 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1699
1700 { .modelname = "F1734", .config = ALC880_F1734 },
1701 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001702 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001703
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001704#ifdef CONFIG_SND_DEBUG
1705 { .modelname = "test", .config = ALC880_TEST },
1706#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01001707 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001708
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 {}
1710};
1711
Takashi Iwai16ded522005-06-10 19:58:24 +02001712/*
Kailang Yangdf694da2005-12-05 19:42:22 +01001713 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02001714 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001715static struct alc_config_preset alc880_presets[] = {
1716 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717 .mixers = { alc880_three_stack_mixer },
1718 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001719 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02001720 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001721 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1722 .channel_mode = alc880_threestack_modes,
1723 .input_mux = &alc880_capture_source,
1724 },
1725 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001726 .mixers = { alc880_three_stack_mixer },
1727 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 .dac_nids = alc880_dac_nids,
1730 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001731 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1732 .channel_mode = alc880_threestack_modes,
1733 .input_mux = &alc880_capture_source,
1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001735 [ALC880_TCL_S700] = {
1736 .mixers = { alc880_tcl_s700_mixer },
1737 .init_verbs = { alc880_volume_init_verbs,
1738 alc880_pin_tcl_S700_init_verbs,
1739 alc880_gpio2_init_verbs },
1740 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1741 .dac_nids = alc880_dac_nids,
1742 .hp_nid = 0x03,
1743 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1744 .channel_mode = alc880_2_jack_modes,
1745 .input_mux = &alc880_capture_source,
1746 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001747 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1749 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001750 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1751 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001752 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1753 .channel_mode = alc880_fivestack_modes,
1754 .input_mux = &alc880_capture_source,
1755 },
1756 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001757 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1758 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001759 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1760 .dac_nids = alc880_dac_nids,
1761 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001762 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1763 .channel_mode = alc880_fivestack_modes,
1764 .input_mux = &alc880_capture_source,
1765 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02001766 [ALC880_6ST] = {
1767 .mixers = { alc880_six_stack_mixer },
1768 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1769 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1770 .dac_nids = alc880_6st_dac_nids,
1771 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1772 .channel_mode = alc880_sixstack_modes,
1773 .input_mux = &alc880_6stack_capture_source,
1774 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001775 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001776 .mixers = { alc880_six_stack_mixer },
1777 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001778 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1779 .dac_nids = alc880_6st_dac_nids,
1780 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001781 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1782 .channel_mode = alc880_sixstack_modes,
1783 .input_mux = &alc880_6stack_capture_source,
1784 },
1785 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001786 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001787 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1788 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001789 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1790 .dac_nids = alc880_w810_dac_nids,
1791 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001792 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1793 .channel_mode = alc880_w810_modes,
1794 .input_mux = &alc880_capture_source,
1795 },
1796 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001797 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001798 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001799 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1800 .dac_nids = alc880_z71v_dac_nids,
1801 .dig_out_nid = ALC880_DIGOUT_NID,
1802 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1804 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001805 .input_mux = &alc880_capture_source,
1806 },
1807 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 .mixers = { alc880_f1734_mixer },
1809 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1810 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1811 .dac_nids = alc880_f1734_dac_nids,
1812 .hp_nid = 0x02,
1813 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1814 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 .input_mux = &alc880_capture_source,
1816 },
1817 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818 .mixers = { alc880_asus_mixer },
1819 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1820 alc880_gpio1_init_verbs },
1821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1822 .dac_nids = alc880_asus_dac_nids,
1823 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1824 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 .input_mux = &alc880_capture_source,
1826 },
1827 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001828 .mixers = { alc880_asus_mixer },
1829 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1830 alc880_gpio1_init_verbs },
1831 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1832 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001833 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1835 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001836 .input_mux = &alc880_capture_source,
1837 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001838 [ALC880_ASUS_DIG2] = {
1839 .mixers = { alc880_asus_mixer },
1840 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1841 alc880_gpio2_init_verbs }, /* use GPIO2 */
1842 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1843 .dac_nids = alc880_asus_dac_nids,
1844 .dig_out_nid = ALC880_DIGOUT_NID,
1845 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1846 .channel_mode = alc880_asus_modes,
1847 .input_mux = &alc880_capture_source,
1848 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001849 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001850 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1851 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1852 alc880_gpio1_init_verbs },
1853 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1854 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001855 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001856 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1857 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001858 .input_mux = &alc880_capture_source,
1859 },
1860 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001861 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001862 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1863 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1864 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001865 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001866 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1867 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001868 .input_mux = &alc880_capture_source,
1869 },
Kailang Yangdf694da2005-12-05 19:42:22 +01001870 [ALC880_CLEVO] = {
1871 .mixers = { alc880_three_stack_mixer },
1872 .init_verbs = { alc880_volume_init_verbs,
1873 alc880_pin_clevo_init_verbs },
1874 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1875 .dac_nids = alc880_dac_nids,
1876 .hp_nid = 0x03,
1877 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1878 .channel_mode = alc880_threestack_modes,
1879 .input_mux = &alc880_capture_source,
1880 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001881#ifdef CONFIG_SND_DEBUG
1882 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883 .mixers = { alc880_test_mixer },
1884 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001885 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1886 .dac_nids = alc880_test_dac_nids,
1887 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001888 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1889 .channel_mode = alc880_test_modes,
1890 .input_mux = &alc880_test_capture_source,
1891 },
1892#endif
1893};
1894
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895/*
1896 * Automatic parse of I/O pins from the BIOS configuration
1897 */
1898
1899#define NUM_CONTROL_ALLOC 32
1900#define NUM_VERB_ALLOC 32
1901
1902enum {
1903 ALC_CTL_WIDGET_VOL,
1904 ALC_CTL_WIDGET_MUTE,
1905 ALC_CTL_BIND_MUTE,
1906};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001907static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001908 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1909 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01001910 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911};
1912
1913/* add dynamic controls */
1914static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1915{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001916 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001917
1918 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1919 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1920
1921 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1922 if (! knew)
1923 return -ENOMEM;
1924 if (spec->kctl_alloc) {
1925 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1926 kfree(spec->kctl_alloc);
1927 }
1928 spec->kctl_alloc = knew;
1929 spec->num_kctl_alloc = num;
1930 }
1931
1932 knew = &spec->kctl_alloc[spec->num_kctl_used];
1933 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07001934 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001935 if (! knew->name)
1936 return -ENOMEM;
1937 knew->private_value = val;
1938 spec->num_kctl_used++;
1939 return 0;
1940}
1941
1942#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1943#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1944#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1945#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1946#define alc880_is_input_pin(nid) ((nid) >= 0x18)
1947#define alc880_input_pin_idx(nid) ((nid) - 0x18)
1948#define alc880_idx_to_dac(nid) ((nid) + 0x02)
1949#define alc880_dac_to_idx(nid) ((nid) - 0x02)
1950#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1951#define alc880_idx_to_selector(nid) ((nid) + 0x10)
1952#define ALC880_PIN_CD_NID 0x1c
1953
1954/* fill in the dac_nids table from the parsed pin configuration */
1955static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1956{
1957 hda_nid_t nid;
1958 int assigned[4];
1959 int i, j;
1960
1961 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001962 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001963
1964 /* check the pins hardwired to audio widget */
1965 for (i = 0; i < cfg->line_outs; i++) {
1966 nid = cfg->line_out_pins[i];
1967 if (alc880_is_fixed_pin(nid)) {
1968 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01001969 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001970 assigned[idx] = 1;
1971 }
1972 }
1973 /* left pins can be connect to any audio widget */
1974 for (i = 0; i < cfg->line_outs; i++) {
1975 nid = cfg->line_out_pins[i];
1976 if (alc880_is_fixed_pin(nid))
1977 continue;
1978 /* search for an empty channel */
1979 for (j = 0; j < cfg->line_outs; j++) {
1980 if (! assigned[j]) {
1981 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1982 assigned[j] = 1;
1983 break;
1984 }
1985 }
1986 }
1987 spec->multiout.num_dacs = cfg->line_outs;
1988 return 0;
1989}
1990
1991/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01001992static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
1993 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001994{
1995 char name[32];
1996 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1997 hda_nid_t nid;
1998 int i, err;
1999
2000 for (i = 0; i < cfg->line_outs; i++) {
2001 if (! spec->multiout.dac_nids[i])
2002 continue;
2003 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2004 if (i == 2) {
2005 /* Center/LFE */
2006 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2007 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2008 return err;
2009 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2010 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2011 return err;
2012 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2013 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2014 return err;
2015 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2016 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2017 return err;
2018 } else {
2019 sprintf(name, "%s Playback Volume", chname[i]);
2020 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2021 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2022 return err;
2023 sprintf(name, "%s Playback Switch", chname[i]);
2024 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2025 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2026 return err;
2027 }
2028 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002029 return 0;
2030}
2031
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002032/* add playback controls for speaker and HP outputs */
2033static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2034 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002035{
2036 hda_nid_t nid;
2037 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002038 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002039
2040 if (! pin)
2041 return 0;
2042
2043 if (alc880_is_fixed_pin(pin)) {
2044 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2045 if (! spec->multiout.dac_nids[0]) {
2046 /* use this as the primary output */
2047 spec->multiout.dac_nids[0] = nid;
2048 if (! spec->multiout.num_dacs)
2049 spec->multiout.num_dacs = 1;
2050 } else
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002051 /* specify the DAC as the extra output */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002052 spec->multiout.hp_nid = nid;
2053 /* control HP volume/switch on the output mixer amp */
2054 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002055 sprintf(name, "%s Playback Volume", pfx);
2056 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002057 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2058 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002059 sprintf(name, "%s Playback Switch", pfx);
2060 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002061 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2062 return err;
2063 } else if (alc880_is_multi_pin(pin)) {
2064 /* set manual connection */
2065 if (! spec->multiout.dac_nids[0]) {
2066 /* use this as the primary output */
2067 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
2068 if (! spec->multiout.num_dacs)
2069 spec->multiout.num_dacs = 1;
2070 }
2071 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002072 sprintf(name, "%s Playback Switch", pfx);
2073 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002074 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2075 return err;
2076 }
2077 return 0;
2078}
2079
2080/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002081static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2082 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083{
2084 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002085 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002086
2087 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002089 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 return err;
2091 sprintf(name, "%s Playback Switch", ctlname);
2092 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002093 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002094 return err;
2095 return 0;
2096}
2097
2098/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002099static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2100 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002103 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002104
2105 for (i = 0; i < AUTO_PIN_LAST; i++) {
2106 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002107 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002108 err = new_analog_input(spec, cfg->input_pins[i],
2109 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002110 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002111 if (err < 0)
2112 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002113 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2115 imux->num_items++;
2116 }
2117 }
2118 return 0;
2119}
2120
Kailang Yangdf694da2005-12-05 19:42:22 +01002121static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2122 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002123 int dac_idx)
2124{
2125 /* set as output */
2126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2127 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2128 /* need the manual connection? */
2129 if (alc880_is_multi_pin(nid)) {
2130 struct alc_spec *spec = codec->spec;
2131 int idx = alc880_multi_pin_idx(nid);
2132 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2133 AC_VERB_SET_CONNECT_SEL,
2134 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2135 }
2136}
2137
2138static void alc880_auto_init_multi_out(struct hda_codec *codec)
2139{
2140 struct alc_spec *spec = codec->spec;
2141 int i;
2142
2143 for (i = 0; i < spec->autocfg.line_outs; i++) {
2144 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2145 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2146 }
2147}
2148
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002149static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002150{
2151 struct alc_spec *spec = codec->spec;
2152 hda_nid_t pin;
2153
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002154 pin = spec->autocfg.speaker_pin;
2155 if (pin) /* connect to front */
2156 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157 pin = spec->autocfg.hp_pin;
2158 if (pin) /* connect to front */
2159 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2160}
2161
2162static void alc880_auto_init_analog_input(struct hda_codec *codec)
2163{
2164 struct alc_spec *spec = codec->spec;
2165 int i;
2166
2167 for (i = 0; i < AUTO_PIN_LAST; i++) {
2168 hda_nid_t nid = spec->autocfg.input_pins[i];
2169 if (alc880_is_input_pin(nid)) {
2170 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2171 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2172 if (nid != ALC880_PIN_CD_NID)
2173 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2174 AMP_OUT_MUTE);
2175 }
2176 }
2177}
2178
2179/* parse the BIOS configuration and set up the alc_spec */
2180/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2181static int alc880_parse_auto_config(struct hda_codec *codec)
2182{
2183 struct alc_spec *spec = codec->spec;
2184 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002185 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002186
Kailang Yangdf694da2005-12-05 19:42:22 +01002187 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2188 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002190 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
2191 ! spec->autocfg.hp_pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002193
2194 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2195 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002196 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2197 "Speaker")) < 0 ||
2198 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2199 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002200 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2201 return err;
2202
2203 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2204
2205 if (spec->autocfg.dig_out_pin)
2206 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2207 if (spec->autocfg.dig_in_pin)
2208 spec->dig_in_nid = ALC880_DIGIN_NID;
2209
2210 if (spec->kctl_alloc)
2211 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2212
2213 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2214
2215 spec->input_mux = &spec->private_imux;
2216
2217 return 1;
2218}
2219
2220/* init callback for auto-configuration model -- overriding the default init */
2221static int alc880_auto_init(struct hda_codec *codec)
2222{
2223 alc_init(codec);
2224 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002225 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 alc880_auto_init_analog_input(codec);
2227 return 0;
2228}
2229
2230/*
2231 * OK, here we have finally the patch for ALC880
2232 */
2233
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234static int patch_alc880(struct hda_codec *codec)
2235{
2236 struct alc_spec *spec;
2237 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002238 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002240 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 if (spec == NULL)
2242 return -ENOMEM;
2243
2244 codec->spec = spec;
2245
2246 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002247 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2249 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 }
2251
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252 if (board_config == ALC880_AUTO) {
2253 /* automatic parse from the BIOS config */
2254 err = alc880_parse_auto_config(codec);
2255 if (err < 0) {
2256 alc_free(codec);
2257 return err;
2258 } else if (! err) {
2259 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2260 board_config = ALC880_3ST;
2261 }
2262 }
2263
Kailang Yangdf694da2005-12-05 19:42:22 +01002264 if (board_config != ALC880_AUTO)
2265 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266
2267 spec->stream_name_analog = "ALC880 Analog";
2268 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2269 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2270
2271 spec->stream_name_digital = "ALC880 Digital";
2272 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2273 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 if (! spec->adc_nids && spec->input_mux) {
2276 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002277 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2279 if (wcap != AC_WID_AUD_IN) {
2280 spec->adc_nids = alc880_adc_nids_alt;
2281 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2282 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2283 spec->num_mixers++;
2284 } else {
2285 spec->adc_nids = alc880_adc_nids;
2286 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2287 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2288 spec->num_mixers++;
2289 }
2290 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291
2292 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002293 if (board_config == ALC880_AUTO)
2294 codec->patch_ops.init = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295
2296 return 0;
2297}
2298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300/*
2301 * ALC260 support
2302 */
2303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002304static hda_nid_t alc260_dac_nids[1] = {
2305 /* front */
2306 0x02,
2307};
2308
2309static hda_nid_t alc260_adc_nids[1] = {
2310 /* ADC0 */
2311 0x04,
2312};
2313
Kailang Yangdf694da2005-12-05 19:42:22 +01002314static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002315 /* ADC1 */
2316 0x05,
2317};
2318
Kailang Yangdf694da2005-12-05 19:42:22 +01002319static hda_nid_t alc260_hp_adc_nids[2] = {
2320 /* ADC1, 0 */
2321 0x05, 0x04
2322};
2323
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324#define ALC260_DIGOUT_NID 0x03
2325#define ALC260_DIGIN_NID 0x06
2326
2327static struct hda_input_mux alc260_capture_source = {
2328 .num_items = 4,
2329 .items = {
2330 { "Mic", 0x0 },
2331 { "Front Mic", 0x1 },
2332 { "Line", 0x2 },
2333 { "CD", 0x4 },
2334 },
2335};
2336
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002337/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
2338 * and the internal CD lines.
2339 */
2340static struct hda_input_mux alc260_fujitsu_capture_source = {
2341 .num_items = 2,
2342 .items = {
2343 { "Mic/Line", 0x0 },
2344 { "CD", 0x4 },
2345 },
2346};
2347
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348/*
2349 * This is just place-holder, so there's something for alc_build_pcms to look
2350 * at when it calculates the maximum number of channels. ALC260 has no mixer
2351 * element which allows changing the channel mode, so the verb list is
2352 * never used.
2353 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002354static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355 { 2, NULL },
2356};
2357
Kailang Yangdf694da2005-12-05 19:42:22 +01002358
2359/* Mixer combinations
2360 *
2361 * basic: base_output + input + pc_beep + capture
2362 * HP: base_output + input + capture_alt
2363 * HP_3013: hp_3013 + input + capture
2364 * fujitsu: fujitsu + capture
2365 */
2366
2367static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002368 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002369 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002370 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2371 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2372 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2373 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2374 { } /* end */
2375};
2376
2377static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2379 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2381 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2383 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 { } /* end */
2387};
2388
Kailang Yangdf694da2005-12-05 19:42:22 +01002389static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2390 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2391 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2392 { } /* end */
2393};
2394
2395static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2396 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2397 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2398 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2399 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2400 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2402 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2403 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002404 { } /* end */
2405};
2406
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002407static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002408 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002409 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002410 ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),
2411 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2412 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2413 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2414 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2415 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2416 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2417 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002418 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002419 { } /* end */
2420};
2421
2422/* capture mixer elements */
2423static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002424 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2425 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002426 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2427 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002428 {
2429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01002430 /* The multiple "Capture Source" controls confuse alsamixer
2431 * So call somewhat different..
2432 * FIXME: the controls appear in the "playback" view!
2433 */
2434 /* .name = "Capture Source", */
2435 .name = "Input Source",
2436 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002437 .info = alc_mux_enum_info,
2438 .get = alc_mux_enum_get,
2439 .put = alc_mux_enum_put,
2440 },
2441 { } /* end */
2442};
2443
Kailang Yangdf694da2005-12-05 19:42:22 +01002444static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2445 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2446 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2447 {
2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2449 /* The multiple "Capture Source" controls confuse alsamixer
2450 * So call somewhat different..
2451 * FIXME: the controls appear in the "playback" view!
2452 */
2453 /* .name = "Capture Source", */
2454 .name = "Input Source",
2455 .count = 1,
2456 .info = alc_mux_enum_info,
2457 .get = alc_mux_enum_get,
2458 .put = alc_mux_enum_put,
2459 },
2460 { } /* end */
2461};
2462
2463/*
2464 * initialization verbs
2465 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466static struct hda_verb alc260_init_verbs[] = {
2467 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002472 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002474 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02002476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477 /* select line-out */
2478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2479 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02002480 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02002482 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02002484 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2485 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02002486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 /* set connection select to line in (default select for this ADC) */
2488 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02002489 /* mute capture amp left and right */
2490 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2491 /* set connection select to line in (default select for this ADC) */
2492 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02002493 /* set vol=0 Line-Out mixer amp left and right */
2494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2495 /* unmute pin widget amp left and right (no gain on this amp) */
2496 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 /* set vol=0 HP mixer amp left and right */
2498 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2499 /* unmute pin widget amp left and right (no gain on this amp) */
2500 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 /* set vol=0 Mono mixer amp left and right */
2502 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2503 /* unmute pin widget amp left and right (no gain on this amp) */
2504 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2505 /* unmute LINE-2 out pin */
2506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002508 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02002509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002510 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02002511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002512 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02002513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002515 /* mute Front out path */
2516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2518 /* mute Headphone out path */
2519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2521 /* mute Mono out path */
2522 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 { }
2525};
2526
Kailang Yangdf694da2005-12-05 19:42:22 +01002527static struct hda_verb alc260_hp_init_verbs[] = {
2528 /* Headphone and output */
2529 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2530 /* mono output */
2531 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2532 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2533 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2534 /* Mic2 (front panel) pin widget for input and vref at 80% */
2535 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2536 /* Line In pin widget for input */
2537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2538 /* Line-2 pin widget for output */
2539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2540 /* CD pin widget for input */
2541 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2542 /* unmute amp left and right */
2543 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2544 /* set connection select to line in (default select for this ADC) */
2545 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2546 /* unmute Line-Out mixer amp left and right (volume = 0) */
2547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2548 /* mute pin widget amp left and right (no gain on this amp) */
2549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2550 /* unmute HP mixer amp left and right (volume = 0) */
2551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2552 /* mute pin widget amp left and right (no gain on this amp) */
2553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2554 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2555 /* unmute CD */
2556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2557 /* unmute Line In */
2558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2559 /* unmute Mic */
2560 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2561 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2562 /* Unmute Front out path */
2563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2564 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2565 /* Unmute Headphone out path */
2566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2568 /* Unmute Mono out path */
2569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2570 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2571 { }
2572};
2573
2574static struct hda_verb alc260_hp_3013_init_verbs[] = {
2575 /* Line out and output */
2576 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2577 /* mono output */
2578 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2579 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2581 /* Mic2 (front panel) pin widget for input and vref at 80% */
2582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2583 /* Line In pin widget for input */
2584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2585 /* Headphone pin widget for output */
2586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2587 /* CD pin widget for input */
2588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2589 /* unmute amp left and right */
2590 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2591 /* set connection select to line in (default select for this ADC) */
2592 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2593 /* unmute Line-Out mixer amp left and right (volume = 0) */
2594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2595 /* mute pin widget amp left and right (no gain on this amp) */
2596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2597 /* unmute HP mixer amp left and right (volume = 0) */
2598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2599 /* mute pin widget amp left and right (no gain on this amp) */
2600 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2601 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2602 /* unmute CD */
2603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2604 /* unmute Line In */
2605 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2606 /* unmute Mic */
2607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2608 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2609 /* Unmute Front out path */
2610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2612 /* Unmute Headphone out path */
2613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2615 /* Unmute Mono out path */
2616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2617 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2618 { }
2619};
2620
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002621/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2622 * laptops.
2623 */
2624static struct hda_verb alc260_fujitsu_init_verbs[] = {
2625 /* Disable all GPIOs */
2626 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2627 /* Internal speaker is connected to headphone pin */
2628 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2629 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2631 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2632 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2633 /* Ensure all other unused pins are disabled and muted.
2634 * Note: trying to set widget 0x15 to anything blocks all audio
2635 * output for some reason, so just leave that at the default.
2636 */
2637 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2638 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2639 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2640 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2641 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2642 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2643 /* Disable digital (SPDIF) pins */
2644 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2645 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2646
2647 /* Start with mixer outputs muted */
2648 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2650 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2651
2652 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2653 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2654 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
2655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2656 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
2657 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2658
2659 /* Mute capture amp left and right */
2660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2661 /* Set ADC connection select to line in (on mic1 pin) */
2662 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2663
2664 /* Mute all inputs to mixer widget (even unconnected ones) */
2665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01002673
2674 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002675};
2676
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677static struct hda_pcm_stream alc260_pcm_analog_playback = {
2678 .substreams = 1,
2679 .channels_min = 2,
2680 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681};
2682
2683static struct hda_pcm_stream alc260_pcm_analog_capture = {
2684 .substreams = 1,
2685 .channels_min = 2,
2686 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002687};
2688
Takashi Iwaia3bcba32005-12-06 19:05:29 +01002689#define alc260_pcm_digital_playback alc880_pcm_digital_playback
2690#define alc260_pcm_digital_capture alc880_pcm_digital_capture
2691
Kailang Yangdf694da2005-12-05 19:42:22 +01002692/*
2693 * for BIOS auto-configuration
2694 */
2695
2696static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
2697 const char *pfx)
2698{
2699 hda_nid_t nid_vol;
2700 unsigned long vol_val, sw_val;
2701 char name[32];
2702 int err;
2703
2704 if (nid >= 0x0f && nid < 0x11) {
2705 nid_vol = nid - 0x7;
2706 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2707 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2708 } else if (nid == 0x11) {
2709 nid_vol = nid - 0x7;
2710 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
2711 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
2712 } else if (nid >= 0x12 && nid <= 0x15) {
2713 nid_vol = 0x08;
2714 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2715 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2716 } else
2717 return 0; /* N/A */
2718
2719 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
2720 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
2721 return err;
2722 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
2723 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
2724 return err;
2725 return 1;
2726}
2727
2728/* add playback controls from the parsed DAC table */
2729static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
2730 const struct auto_pin_cfg *cfg)
2731{
2732 hda_nid_t nid;
2733 int err;
2734
2735 spec->multiout.num_dacs = 1;
2736 spec->multiout.dac_nids = spec->private_dac_nids;
2737 spec->multiout.dac_nids[0] = 0x02;
2738
2739 nid = cfg->line_out_pins[0];
2740 if (nid) {
2741 err = alc260_add_playback_controls(spec, nid, "Front");
2742 if (err < 0)
2743 return err;
2744 }
2745
2746 nid = cfg->speaker_pin;
2747 if (nid) {
2748 err = alc260_add_playback_controls(spec, nid, "Speaker");
2749 if (err < 0)
2750 return err;
2751 }
2752
2753 nid = cfg->hp_pin;
2754 if (nid) {
2755 err = alc260_add_playback_controls(spec, nid, "Headphone");
2756 if (err < 0)
2757 return err;
2758 }
2759 return 0;
2760}
2761
2762/* create playback/capture controls for input pins */
2763static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
2764 const struct auto_pin_cfg *cfg)
2765{
Kailang Yangdf694da2005-12-05 19:42:22 +01002766 struct hda_input_mux *imux = &spec->private_imux;
2767 int i, err, idx;
2768
2769 for (i = 0; i < AUTO_PIN_LAST; i++) {
2770 if (cfg->input_pins[i] >= 0x12) {
2771 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002772 err = new_analog_input(spec, cfg->input_pins[i],
2773 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01002774 if (err < 0)
2775 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002776 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01002777 imux->items[imux->num_items].index = idx;
2778 imux->num_items++;
2779 }
2780 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
2781 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002782 err = new_analog_input(spec, cfg->input_pins[i],
2783 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01002784 if (err < 0)
2785 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002786 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01002787 imux->items[imux->num_items].index = idx;
2788 imux->num_items++;
2789 }
2790 }
2791 return 0;
2792}
2793
2794static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
2795 hda_nid_t nid, int pin_type,
2796 int sel_idx)
2797{
2798 /* set as output */
2799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2801 /* need the manual connection? */
2802 if (nid >= 0x12) {
2803 int idx = nid - 0x12;
2804 snd_hda_codec_write(codec, idx + 0x0b, 0,
2805 AC_VERB_SET_CONNECT_SEL, sel_idx);
2806
2807 }
2808}
2809
2810static void alc260_auto_init_multi_out(struct hda_codec *codec)
2811{
2812 struct alc_spec *spec = codec->spec;
2813 hda_nid_t nid;
2814
2815 nid = spec->autocfg.line_out_pins[0];
2816 if (nid)
2817 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2818
2819 nid = spec->autocfg.speaker_pin;
2820 if (nid)
2821 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2822
2823 nid = spec->autocfg.hp_pin;
2824 if (nid)
2825 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2826}
2827
2828#define ALC260_PIN_CD_NID 0x16
2829static void alc260_auto_init_analog_input(struct hda_codec *codec)
2830{
2831 struct alc_spec *spec = codec->spec;
2832 int i;
2833
2834 for (i = 0; i < AUTO_PIN_LAST; i++) {
2835 hda_nid_t nid = spec->autocfg.input_pins[i];
2836 if (nid >= 0x12) {
2837 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2838 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2839 if (nid != ALC260_PIN_CD_NID)
2840 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2841 AMP_OUT_MUTE);
2842 }
2843 }
2844}
2845
2846/*
2847 * generic initialization of ADC, input mixers and output mixers
2848 */
2849static struct hda_verb alc260_volume_init_verbs[] = {
2850 /*
2851 * Unmute ADC0-1 and set the default input to mic-in
2852 */
2853 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2854 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2855 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2856 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2857
2858 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2859 * mixer widget
2860 * Note: PASD motherboards uses the Line In 2 as the input for front panel
2861 * mic (mic 2)
2862 */
2863 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2867 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2868 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2869
2870 /*
2871 * Set up output mixers (0x08 - 0x0a)
2872 */
2873 /* set vol=0 to output mixers */
2874 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2876 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2877 /* set up input amps for analog loopback */
2878 /* Amp Indices: DAC = 0, mixer = 1 */
2879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2883 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2884 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2885
2886 { }
2887};
2888
2889static int alc260_parse_auto_config(struct hda_codec *codec)
2890{
2891 struct alc_spec *spec = codec->spec;
2892 unsigned int wcap;
2893 int err;
2894 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
2895
2896 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2897 alc260_ignore)) < 0)
2898 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002899 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
2900 return err;
2901 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01002902 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01002903 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01002904 return err;
2905
2906 spec->multiout.max_channels = 2;
2907
2908 if (spec->autocfg.dig_out_pin)
2909 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
2910 if (spec->kctl_alloc)
2911 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2912
2913 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
2914
2915 spec->input_mux = &spec->private_imux;
2916
2917 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01002918 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01002919 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2920 if (wcap != AC_WID_AUD_IN) {
2921 spec->adc_nids = alc260_adc_nids_alt;
2922 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
2923 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01002924 } else {
2925 spec->adc_nids = alc260_adc_nids;
2926 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2927 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01002928 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002929 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01002930
2931 return 1;
2932}
2933
2934/* init callback for auto-configuration model -- overriding the default init */
2935static int alc260_auto_init(struct hda_codec *codec)
2936{
2937 alc_init(codec);
2938 alc260_auto_init_multi_out(codec);
2939 alc260_auto_init_analog_input(codec);
2940 return 0;
2941}
2942
2943/*
2944 * ALC260 configurations
2945 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002946static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01002947 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01002948 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
2949 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai16ded522005-06-10 19:58:24 +02002950 { .modelname = "hp", .config = ALC260_HP },
Kailang Yangdf694da2005-12-05 19:42:22 +01002951 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
2952 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
2953 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
2954 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
2955 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
2956 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
2957 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
2958 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
2959 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
2960 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02002961 {}
2962};
2963
Kailang Yangdf694da2005-12-05 19:42:22 +01002964static struct alc_config_preset alc260_presets[] = {
2965 [ALC260_BASIC] = {
2966 .mixers = { alc260_base_output_mixer,
2967 alc260_input_mixer,
2968 alc260_pc_beep_mixer,
2969 alc260_capture_mixer },
2970 .init_verbs = { alc260_init_verbs },
2971 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2972 .dac_nids = alc260_dac_nids,
2973 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
2974 .adc_nids = alc260_adc_nids,
2975 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2976 .channel_mode = alc260_modes,
2977 .input_mux = &alc260_capture_source,
2978 },
2979 [ALC260_HP] = {
2980 .mixers = { alc260_base_output_mixer,
2981 alc260_input_mixer,
2982 alc260_capture_alt_mixer },
2983 .init_verbs = { alc260_hp_init_verbs },
2984 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2985 .dac_nids = alc260_dac_nids,
2986 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
2987 .adc_nids = alc260_hp_adc_nids,
2988 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2989 .channel_mode = alc260_modes,
2990 .input_mux = &alc260_capture_source,
2991 },
2992 [ALC260_HP_3013] = {
2993 .mixers = { alc260_hp_3013_mixer,
2994 alc260_input_mixer,
2995 alc260_capture_alt_mixer },
2996 .init_verbs = { alc260_hp_3013_init_verbs },
2997 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2998 .dac_nids = alc260_dac_nids,
2999 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3000 .adc_nids = alc260_hp_adc_nids,
3001 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3002 .channel_mode = alc260_modes,
3003 .input_mux = &alc260_capture_source,
3004 },
3005 [ALC260_FUJITSU_S702X] = {
3006 .mixers = { alc260_fujitsu_mixer,
3007 alc260_capture_mixer },
3008 .init_verbs = { alc260_fujitsu_init_verbs },
3009 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3010 .dac_nids = alc260_dac_nids,
3011 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3012 .adc_nids = alc260_adc_nids,
3013 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3014 .channel_mode = alc260_modes,
3015 .input_mux = &alc260_fujitsu_capture_source,
3016 },
3017};
3018
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019static int patch_alc260(struct hda_codec *codec)
3020{
3021 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01003022 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003024 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025 if (spec == NULL)
3026 return -ENOMEM;
3027
3028 codec->spec = spec;
3029
Takashi Iwai16ded522005-06-10 19:58:24 +02003030 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3031 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3032 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01003033 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02003034 }
3035
Kailang Yangdf694da2005-12-05 19:42:22 +01003036 if (board_config == ALC260_AUTO) {
3037 /* automatic parse from the BIOS config */
3038 err = alc260_parse_auto_config(codec);
3039 if (err < 0) {
3040 alc_free(codec);
3041 return err;
3042 } else if (! err) {
3043 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3044 board_config = ALC260_BASIC;
3045 }
Takashi Iwai16ded522005-06-10 19:58:24 +02003046 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003047
Kailang Yangdf694da2005-12-05 19:42:22 +01003048 if (board_config != ALC260_AUTO)
3049 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003050
3051 spec->stream_name_analog = "ALC260 Analog";
3052 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3053 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3054
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003055 spec->stream_name_digital = "ALC260 Digital";
3056 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3057 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3058
Linus Torvalds1da177e2005-04-16 15:20:36 -07003059 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01003060 if (board_config == ALC260_AUTO)
3061 codec->patch_ops.init = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003062
3063 return 0;
3064}
3065
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066
Linus Torvalds1da177e2005-04-16 15:20:36 -07003067/*
3068 * ALC882 support
3069 *
3070 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3071 * configuration. Each pin widget can choose any input DACs and a mixer.
3072 * Each ADC is connected from a mixer of all inputs. This makes possible
3073 * 6-channel independent captures.
3074 *
3075 * In addition, an independent DAC for the multi-playback (not used in this
3076 * driver yet).
3077 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003078#define ALC882_DIGOUT_NID 0x06
3079#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07003080
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003081static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082 { 8, NULL }
3083};
3084
3085static hda_nid_t alc882_dac_nids[4] = {
3086 /* front, rear, clfe, rear_surr */
3087 0x02, 0x03, 0x04, 0x05
3088};
3089
Kailang Yangdf694da2005-12-05 19:42:22 +01003090/* identical with ALC880 */
3091#define alc882_adc_nids alc880_adc_nids
3092#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093
3094/* input MUX */
3095/* FIXME: should be a matrix-type input source selection */
3096
3097static struct hda_input_mux alc882_capture_source = {
3098 .num_items = 4,
3099 .items = {
3100 { "Mic", 0x0 },
3101 { "Front Mic", 0x1 },
3102 { "Line", 0x2 },
3103 { "CD", 0x4 },
3104 },
3105};
3106
3107#define alc882_mux_enum_info alc_mux_enum_info
3108#define alc882_mux_enum_get alc_mux_enum_get
3109
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003110static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003111{
3112 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3113 struct alc_spec *spec = codec->spec;
3114 const struct hda_input_mux *imux = spec->input_mux;
3115 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3116 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3117 hda_nid_t nid = capture_mixers[adc_idx];
3118 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3119 unsigned int i, idx;
3120
3121 idx = ucontrol->value.enumerated.item[0];
3122 if (idx >= imux->num_items)
3123 idx = imux->num_items - 1;
3124 if (*cur_val == idx && ! codec->in_resume)
3125 return 0;
3126 for (i = 0; i < imux->num_items; i++) {
3127 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3128 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3129 v | (imux->items[i].index << 8));
3130 }
3131 *cur_val = idx;
3132 return 1;
3133}
3134
Kailang Yangdf694da2005-12-05 19:42:22 +01003135/*
3136 * 6ch mode
3137 */
3138static struct hda_verb alc882_sixstack_ch6_init[] = {
3139 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3140 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3141 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3142 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3143 { } /* end */
3144};
3145
3146/*
3147 * 8ch mode
3148 */
3149static struct hda_verb alc882_sixstack_ch8_init[] = {
3150 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3151 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3152 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3153 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3154 { } /* end */
3155};
3156
3157static struct hda_channel_mode alc882_sixstack_modes[2] = {
3158 { 6, alc882_sixstack_ch6_init },
3159 { 8, alc882_sixstack_ch8_init },
3160};
3161
Linus Torvalds1da177e2005-04-16 15:20:36 -07003162/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3163 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3164 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003165static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003166 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003167 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003168 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003169 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003170 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3171 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003172 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3173 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003174 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003175 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3184 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3185 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
3186 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
3187 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3188 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3189 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3190 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3191 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3192 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3193 {
3194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3195 /* .name = "Capture Source", */
3196 .name = "Input Source",
3197 .count = 3,
3198 .info = alc882_mux_enum_info,
3199 .get = alc882_mux_enum_get,
3200 .put = alc882_mux_enum_put,
3201 },
3202 { } /* end */
3203};
3204
Kailang Yangdf694da2005-12-05 19:42:22 +01003205static struct snd_kcontrol_new alc882_chmode_mixer[] = {
3206 {
3207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3208 .name = "Channel Mode",
3209 .info = alc_ch_mode_info,
3210 .get = alc_ch_mode_get,
3211 .put = alc_ch_mode_put,
3212 },
3213 { } /* end */
3214};
3215
Linus Torvalds1da177e2005-04-16 15:20:36 -07003216static struct hda_verb alc882_init_verbs[] = {
3217 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003221 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003225 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003229 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003230 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003233
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003234 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003241 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003243 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003245 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003246 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003247 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003251 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3253 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3256 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3259 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3262 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003263 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003264 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003265
3266 /* FIXME: use matrix-type input source selection */
3267 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3268 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02003269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003273 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003278 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3280 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3283 /* ADC1: mute amp left and right */
3284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003285 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003286 /* ADC2: mute amp left and right */
3287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003288 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003289 /* ADC3: mute amp left and right */
3290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003291 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003292
3293 { }
3294};
3295
Kailang Yangdf694da2005-12-05 19:42:22 +01003296/*
3297 * generic initialization of ADC, input mixers and output mixers
3298 */
3299static struct hda_verb alc882_auto_init_verbs[] = {
3300 /*
3301 * Unmute ADC0-2 and set the default input to mic-in
3302 */
3303 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3307 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3309
3310 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3311 * mixer widget
3312 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3313 * mic (mic 2)
3314 */
3315 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3321
3322 /*
3323 * Set up output mixers (0x0c - 0x0f)
3324 */
3325 /* set vol=0 to output mixers */
3326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3330 /* set up input amps for analog loopback */
3331 /* Amp Indices: DAC = 0, mixer = 1 */
3332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3340 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3341 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3342
3343 /* FIXME: use matrix-type input source selection */
3344 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3345 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3350 /* Input mixer2 */
3351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3355 /* Input mixer3 */
3356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3360
3361 { }
3362};
3363
3364/* capture mixer elements */
3365static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
3366 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3367 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3368 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
3369 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
3370 {
3371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3372 /* The multiple "Capture Source" controls confuse alsamixer
3373 * So call somewhat different..
3374 * FIXME: the controls appear in the "playback" view!
3375 */
3376 /* .name = "Capture Source", */
3377 .name = "Input Source",
3378 .count = 2,
3379 .info = alc882_mux_enum_info,
3380 .get = alc882_mux_enum_get,
3381 .put = alc882_mux_enum_put,
3382 },
3383 { } /* end */
3384};
3385
3386static struct snd_kcontrol_new alc882_capture_mixer[] = {
3387 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3388 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3389 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3390 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3391 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3392 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3393 {
3394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3395 /* The multiple "Capture Source" controls confuse alsamixer
3396 * So call somewhat different..
3397 * FIXME: the controls appear in the "playback" view!
3398 */
3399 /* .name = "Capture Source", */
3400 .name = "Input Source",
3401 .count = 3,
3402 .info = alc882_mux_enum_info,
3403 .get = alc882_mux_enum_get,
3404 .put = alc882_mux_enum_put,
3405 },
3406 { } /* end */
3407};
3408
3409/* pcm configuration: identiacal with ALC880 */
3410#define alc882_pcm_analog_playback alc880_pcm_analog_playback
3411#define alc882_pcm_analog_capture alc880_pcm_analog_capture
3412#define alc882_pcm_digital_playback alc880_pcm_digital_playback
3413#define alc882_pcm_digital_capture alc880_pcm_digital_capture
3414
3415/*
3416 * configuration and preset
3417 */
3418static struct hda_board_config alc882_cfg_tbl[] = {
3419 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
3420 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
3421 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
3422 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
3423 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
3424 { .modelname = "auto", .config = ALC861_AUTO },
3425 {}
3426};
3427
3428static struct alc_config_preset alc882_presets[] = {
3429 [ALC882_3ST_DIG] = {
3430 .mixers = { alc882_base_mixer },
3431 .init_verbs = { alc882_init_verbs },
3432 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3433 .dac_nids = alc882_dac_nids,
3434 .dig_out_nid = ALC882_DIGOUT_NID,
3435 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3436 .adc_nids = alc882_adc_nids,
3437 .dig_in_nid = ALC882_DIGIN_NID,
3438 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3439 .channel_mode = alc882_ch_modes,
3440 .input_mux = &alc882_capture_source,
3441 },
3442 [ALC882_6ST_DIG] = {
3443 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3444 .init_verbs = { alc882_init_verbs },
3445 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3446 .dac_nids = alc882_dac_nids,
3447 .dig_out_nid = ALC882_DIGOUT_NID,
3448 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3449 .adc_nids = alc882_adc_nids,
3450 .dig_in_nid = ALC882_DIGIN_NID,
3451 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3452 .channel_mode = alc882_sixstack_modes,
3453 .input_mux = &alc882_capture_source,
3454 },
3455};
3456
3457
3458/*
3459 * BIOS auto configuration
3460 */
3461static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
3462 hda_nid_t nid, int pin_type,
3463 int dac_idx)
3464{
3465 /* set as output */
3466 struct alc_spec *spec = codec->spec;
3467 int idx;
3468
3469 if (spec->multiout.dac_nids[dac_idx] == 0x25)
3470 idx = 4;
3471 else
3472 idx = spec->multiout.dac_nids[dac_idx] - 2;
3473
3474 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3476 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
3477
3478}
3479
3480static void alc882_auto_init_multi_out(struct hda_codec *codec)
3481{
3482 struct alc_spec *spec = codec->spec;
3483 int i;
3484
3485 for (i = 0; i <= HDA_SIDE; i++) {
3486 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3487 if (nid)
3488 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3489 }
3490}
3491
3492static void alc882_auto_init_hp_out(struct hda_codec *codec)
3493{
3494 struct alc_spec *spec = codec->spec;
3495 hda_nid_t pin;
3496
3497 pin = spec->autocfg.hp_pin;
3498 if (pin) /* connect to front */
3499 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
3500}
3501
3502#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
3503#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
3504
3505static void alc882_auto_init_analog_input(struct hda_codec *codec)
3506{
3507 struct alc_spec *spec = codec->spec;
3508 int i;
3509
3510 for (i = 0; i < AUTO_PIN_LAST; i++) {
3511 hda_nid_t nid = spec->autocfg.input_pins[i];
3512 if (alc882_is_input_pin(nid)) {
3513 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3514 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3515 if (nid != ALC882_PIN_CD_NID)
3516 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3517 AMP_OUT_MUTE);
3518 }
3519 }
3520}
3521
3522/* almost identical with ALC880 parser... */
3523static int alc882_parse_auto_config(struct hda_codec *codec)
3524{
3525 struct alc_spec *spec = codec->spec;
3526 int err = alc880_parse_auto_config(codec);
3527
3528 if (err < 0)
3529 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01003530 else if (err > 0)
3531 /* hack - override the init verbs */
3532 spec->init_verbs[0] = alc882_auto_init_verbs;
3533 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003534}
3535
3536/* init callback for auto-configuration model -- overriding the default init */
3537static int alc882_auto_init(struct hda_codec *codec)
3538{
3539 alc_init(codec);
3540 alc882_auto_init_multi_out(codec);
3541 alc882_auto_init_hp_out(codec);
3542 alc882_auto_init_analog_input(codec);
3543 return 0;
3544}
3545
3546/*
3547 * ALC882 Headphone poll in 3.5.1a or 3.5.2
3548 */
3549
Linus Torvalds1da177e2005-04-16 15:20:36 -07003550static int patch_alc882(struct hda_codec *codec)
3551{
3552 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01003553 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003555 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003556 if (spec == NULL)
3557 return -ENOMEM;
3558
Linus Torvalds1da177e2005-04-16 15:20:36 -07003559 codec->spec = spec;
3560
Kailang Yangdf694da2005-12-05 19:42:22 +01003561 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003562
Kailang Yangdf694da2005-12-05 19:42:22 +01003563 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
3564 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
3565 board_config = ALC882_AUTO;
3566 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003567
Kailang Yangdf694da2005-12-05 19:42:22 +01003568 if (board_config == ALC882_AUTO) {
3569 /* automatic parse from the BIOS config */
3570 err = alc882_parse_auto_config(codec);
3571 if (err < 0) {
3572 alc_free(codec);
3573 return err;
3574 } else if (! err) {
3575 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3576 board_config = ALC882_3ST_DIG;
3577 }
3578 }
3579
3580 if (board_config != ALC882_AUTO)
3581 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003582
3583 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01003584 spec->stream_analog_playback = &alc882_pcm_analog_playback;
3585 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003586
3587 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01003588 spec->stream_digital_playback = &alc882_pcm_digital_playback;
3589 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003590
Kailang Yangdf694da2005-12-05 19:42:22 +01003591 if (! spec->adc_nids && spec->input_mux) {
3592 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003593 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003594 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3595 if (wcap != AC_WID_AUD_IN) {
3596 spec->adc_nids = alc882_adc_nids_alt;
3597 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
3598 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
3599 spec->num_mixers++;
3600 } else {
3601 spec->adc_nids = alc882_adc_nids;
3602 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
3603 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
3604 spec->num_mixers++;
3605 }
3606 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003607
3608 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01003609 if (board_config == ALC882_AUTO)
3610 codec->patch_ops.init = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611
3612 return 0;
3613}
3614
3615/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003616 * ALC262 support
3617 */
3618
3619#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
3620#define ALC262_DIGIN_NID ALC880_DIGIN_NID
3621
3622#define alc262_dac_nids alc260_dac_nids
3623#define alc262_adc_nids alc882_adc_nids
3624#define alc262_adc_nids_alt alc882_adc_nids_alt
3625
3626#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01003627#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01003628
3629static struct snd_kcontrol_new alc262_base_mixer[] = {
3630 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3631 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3640 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
3641 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
3642 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
3643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3644 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3645 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
3646 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3647 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3648 {
3649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3650 .name = "Capture Source",
3651 .count = 1,
3652 .info = alc882_mux_enum_info,
3653 .get = alc882_mux_enum_get,
3654 .put = alc882_mux_enum_put,
3655 },
3656 { } /* end */
3657};
3658
3659#define alc262_capture_mixer alc882_capture_mixer
3660#define alc262_capture_alt_mixer alc882_capture_alt_mixer
3661
3662/*
3663 * generic initialization of ADC, input mixers and output mixers
3664 */
3665static struct hda_verb alc262_init_verbs[] = {
3666 /*
3667 * Unmute ADC0-2 and set the default input to mic-in
3668 */
3669 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3671 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3673 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3675
3676 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3677 * mixer widget
3678 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3679 * mic (mic 2)
3680 */
3681 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3687
3688 /*
3689 * Set up output mixers (0x0c - 0x0e)
3690 */
3691 /* set vol=0 to output mixers */
3692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3693 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3695 /* set up input amps for analog loopback */
3696 /* Amp Indices: DAC = 0, mixer = 1 */
3697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3703
3704 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3709 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3710
3711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3714 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3716
3717 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3718 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3719
3720 /* FIXME: use matrix-type input source selection */
3721 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3722 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3723 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3727 /* Input mixer2 */
3728 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3732 /* Input mixer3 */
3733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3737
3738 { }
3739};
3740
3741/* add playback controls from the parsed DAC table */
3742static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
3743{
3744 hda_nid_t nid;
3745 int err;
3746
3747 spec->multiout.num_dacs = 1; /* only use one dac */
3748 spec->multiout.dac_nids = spec->private_dac_nids;
3749 spec->multiout.dac_nids[0] = 2;
3750
3751 nid = cfg->line_out_pins[0];
3752 if (nid) {
3753 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
3754 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3755 return err;
3756 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
3757 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3758 return err;
3759 }
3760
3761 nid = cfg->speaker_pin;
3762 if (nid) {
3763 if (nid == 0x16) {
3764 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
3765 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
3766 return err;
3767 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
3768 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
3769 return err;
3770 } else {
3771 if (! cfg->line_out_pins[0])
3772 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
3773 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3774 return err;
3775 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
3776 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3777 return err;
3778 }
3779 }
3780 nid = cfg->hp_pin;
3781 if (nid) {
3782 /* spec->multiout.hp_nid = 2; */
3783 if (nid == 0x16) {
3784 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
3785 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
3786 return err;
3787 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
3788 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
3789 return err;
3790 } else {
3791 if (! cfg->line_out_pins[0])
3792 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
3793 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3794 return err;
3795 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
3796 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3797 return err;
3798 }
3799 }
3800 return 0;
3801}
3802
3803/* identical with ALC880 */
3804#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
3805
3806/*
3807 * generic initialization of ADC, input mixers and output mixers
3808 */
3809static struct hda_verb alc262_volume_init_verbs[] = {
3810 /*
3811 * Unmute ADC0-2 and set the default input to mic-in
3812 */
3813 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3815 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3816 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3817 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3818 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3819
3820 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3821 * mixer widget
3822 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3823 * mic (mic 2)
3824 */
3825 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3831
3832 /*
3833 * Set up output mixers (0x0c - 0x0f)
3834 */
3835 /* set vol=0 to output mixers */
3836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3839
3840 /* set up input amps for analog loopback */
3841 /* Amp Indices: DAC = 0, mixer = 1 */
3842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3845 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3848
3849 /* FIXME: use matrix-type input source selection */
3850 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3851 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3856 /* Input mixer2 */
3857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3861 /* Input mixer3 */
3862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3866
3867 { }
3868};
3869
3870/* pcm configuration: identiacal with ALC880 */
3871#define alc262_pcm_analog_playback alc880_pcm_analog_playback
3872#define alc262_pcm_analog_capture alc880_pcm_analog_capture
3873#define alc262_pcm_digital_playback alc880_pcm_digital_playback
3874#define alc262_pcm_digital_capture alc880_pcm_digital_capture
3875
3876/*
3877 * BIOS auto configuration
3878 */
3879static int alc262_parse_auto_config(struct hda_codec *codec)
3880{
3881 struct alc_spec *spec = codec->spec;
3882 int err;
3883 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3884
3885 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3886 alc262_ignore)) < 0)
3887 return err;
3888 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
3889 ! spec->autocfg.hp_pin)
3890 return 0; /* can't find valid BIOS pin config */
3891 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
3892 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3893 return err;
3894
3895 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3896
3897 if (spec->autocfg.dig_out_pin)
3898 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
3899 if (spec->autocfg.dig_in_pin)
3900 spec->dig_in_nid = ALC262_DIGIN_NID;
3901
3902 if (spec->kctl_alloc)
3903 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3904
3905 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
3906 spec->input_mux = &spec->private_imux;
3907
3908 return 1;
3909}
3910
3911#define alc262_auto_init_multi_out alc882_auto_init_multi_out
3912#define alc262_auto_init_hp_out alc882_auto_init_hp_out
3913#define alc262_auto_init_analog_input alc882_auto_init_analog_input
3914
3915
3916/* init callback for auto-configuration model -- overriding the default init */
3917static int alc262_auto_init(struct hda_codec *codec)
3918{
3919 alc_init(codec);
3920 alc262_auto_init_multi_out(codec);
3921 alc262_auto_init_hp_out(codec);
3922 alc262_auto_init_analog_input(codec);
3923 return 0;
3924}
3925
3926/*
3927 * configuration and preset
3928 */
3929static struct hda_board_config alc262_cfg_tbl[] = {
3930 { .modelname = "basic", .config = ALC262_BASIC },
3931 { .modelname = "auto", .config = ALC262_AUTO },
3932 {}
3933};
3934
3935static struct alc_config_preset alc262_presets[] = {
3936 [ALC262_BASIC] = {
3937 .mixers = { alc262_base_mixer },
3938 .init_verbs = { alc262_init_verbs },
3939 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
3940 .dac_nids = alc262_dac_nids,
3941 .hp_nid = 0x03,
3942 .num_channel_mode = ARRAY_SIZE(alc262_modes),
3943 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003944 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01003945 },
3946};
3947
3948static int patch_alc262(struct hda_codec *codec)
3949{
3950 struct alc_spec *spec;
3951 int board_config;
3952 int err;
3953
3954 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
3955 if (spec == NULL)
3956 return -ENOMEM;
3957
3958 codec->spec = spec;
3959#if 0
3960 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
3961 {
3962 int tmp;
3963 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
3964 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
3965 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
3966 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
3967 }
3968#endif
3969
3970 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
3971 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
3972 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
3973 board_config = ALC262_AUTO;
3974 }
3975
3976 if (board_config == ALC262_AUTO) {
3977 /* automatic parse from the BIOS config */
3978 err = alc262_parse_auto_config(codec);
3979 if (err < 0) {
3980 alc_free(codec);
3981 return err;
3982 } else if (! err) {
3983 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3984 board_config = ALC262_BASIC;
3985 }
3986 }
3987
3988 if (board_config != ALC262_AUTO)
3989 setup_preset(spec, &alc262_presets[board_config]);
3990
3991 spec->stream_name_analog = "ALC262 Analog";
3992 spec->stream_analog_playback = &alc262_pcm_analog_playback;
3993 spec->stream_analog_capture = &alc262_pcm_analog_capture;
3994
3995 spec->stream_name_digital = "ALC262 Digital";
3996 spec->stream_digital_playback = &alc262_pcm_digital_playback;
3997 spec->stream_digital_capture = &alc262_pcm_digital_capture;
3998
3999 if (! spec->adc_nids && spec->input_mux) {
4000 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004001 unsigned int wcap = get_wcaps(codec, 0x07);
4002
Kailang Yangdf694da2005-12-05 19:42:22 +01004003 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4004 if (wcap != AC_WID_AUD_IN) {
4005 spec->adc_nids = alc262_adc_nids_alt;
4006 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
4007 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
4008 spec->num_mixers++;
4009 } else {
4010 spec->adc_nids = alc262_adc_nids;
4011 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
4012 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
4013 spec->num_mixers++;
4014 }
4015 }
4016
4017 codec->patch_ops = alc_patch_ops;
4018 if (board_config == ALC262_AUTO)
4019 codec->patch_ops.init = alc262_auto_init;
4020
4021 return 0;
4022}
4023
4024
4025/*
4026 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4027 */
4028
4029/*
4030 * set the path ways for 2 channel output
4031 * need to set the codec line out and mic 1 pin widgets to inputs
4032 */
4033static struct hda_verb alc861_threestack_ch2_init[] = {
4034 /* set pin widget 1Ah (line in) for input */
4035 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4036 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4037 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4038
4039 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4040 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4041 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4042 { } /* end */
4043};
4044/*
4045 * 6ch mode
4046 * need to set the codec line out and mic 1 pin widgets to outputs
4047 */
4048static struct hda_verb alc861_threestack_ch6_init[] = {
4049 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4050 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4051 /* set pin widget 18h (mic1) for output (CLFE)*/
4052 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4053
4054 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4055 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4056
4057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4058 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4059 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4060 { } /* end */
4061};
4062
4063static struct hda_channel_mode alc861_threestack_modes[2] = {
4064 { 2, alc861_threestack_ch2_init },
4065 { 6, alc861_threestack_ch6_init },
4066};
4067
4068/* patch-ALC861 */
4069
4070static struct snd_kcontrol_new alc861_base_mixer[] = {
4071 /* output mixer control */
4072 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4073 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4074 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4075 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4076 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
4077
4078 /*Input mixer control */
4079 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4080 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4081 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4082 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4083 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4084 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4086 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4087 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4089
4090 /* Capture mixer control */
4091 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4092 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4093 {
4094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4095 .name = "Capture Source",
4096 .count = 1,
4097 .info = alc_mux_enum_info,
4098 .get = alc_mux_enum_get,
4099 .put = alc_mux_enum_put,
4100 },
4101 { } /* end */
4102};
4103
4104static struct snd_kcontrol_new alc861_3ST_mixer[] = {
4105 /* output mixer control */
4106 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4107 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4108 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4109 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4110 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4111
4112 /* Input mixer control */
4113 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4114 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4115 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4116 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4117 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4118 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4120 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4123
4124 /* Capture mixer control */
4125 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4126 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4127 {
4128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4129 .name = "Capture Source",
4130 .count = 1,
4131 .info = alc_mux_enum_info,
4132 .get = alc_mux_enum_get,
4133 .put = alc_mux_enum_put,
4134 },
4135 {
4136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4137 .name = "Channel Mode",
4138 .info = alc_ch_mode_info,
4139 .get = alc_ch_mode_get,
4140 .put = alc_ch_mode_put,
4141 .private_value = ARRAY_SIZE(alc861_threestack_modes),
4142 },
4143 { } /* end */
4144};
4145
4146/*
4147 * generic initialization of ADC, input mixers and output mixers
4148 */
4149static struct hda_verb alc861_base_init_verbs[] = {
4150 /*
4151 * Unmute ADC0 and set the default input to mic-in
4152 */
4153 /* port-A for surround (rear panel) */
4154 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4155 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
4156 /* port-B for mic-in (rear panel) with vref */
4157 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4158 /* port-C for line-in (rear panel) */
4159 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4160 /* port-D for Front */
4161 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4162 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4163 /* port-E for HP out (front panel) */
4164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4165 /* route front PCM to HP */
4166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4167 /* port-F for mic-in (front panel) with vref */
4168 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4169 /* port-G for CLFE (rear panel) */
4170 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4171 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
4172 /* port-H for side (rear panel) */
4173 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4174 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
4175 /* CD-in */
4176 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4177 /* route front mic to ADC1*/
4178 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4179 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4180
4181 /* Unmute DAC0~3 & spdif out*/
4182 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4183 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4184 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4185 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4187
4188 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4189 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4190 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4191 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4192 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4193
4194 /* Unmute Stereo Mixer 15 */
4195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4199
4200 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4201 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4202 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4204 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4206 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4209 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4210
4211 { }
4212};
4213
4214static struct hda_verb alc861_threestack_init_verbs[] = {
4215 /*
4216 * Unmute ADC0 and set the default input to mic-in
4217 */
4218 /* port-A for surround (rear panel) */
4219 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4220 /* port-B for mic-in (rear panel) with vref */
4221 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4222 /* port-C for line-in (rear panel) */
4223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4224 /* port-D for Front */
4225 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4226 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4227 /* port-E for HP out (front panel) */
4228 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4229 /* route front PCM to HP */
4230 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4231 /* port-F for mic-in (front panel) with vref */
4232 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4233 /* port-G for CLFE (rear panel) */
4234 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4235 /* port-H for side (rear panel) */
4236 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4237 /* CD-in */
4238 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4239 /* route front mic to ADC1*/
4240 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4242 /* Unmute DAC0~3 & spdif out*/
4243 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4248
4249 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4250 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4251 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4252 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4253 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4254
4255 /* Unmute Stereo Mixer 15 */
4256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4260
4261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4262 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4271 { }
4272};
4273/*
4274 * generic initialization of ADC, input mixers and output mixers
4275 */
4276static struct hda_verb alc861_auto_init_verbs[] = {
4277 /*
4278 * Unmute ADC0 and set the default input to mic-in
4279 */
4280// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4282
4283 /* Unmute DAC0~3 & spdif out*/
4284 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4285 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4286 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4287 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4289
4290 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4291 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4292 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4293 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4294 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4295
4296 /* Unmute Stereo Mixer 15 */
4297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
4301
4302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4303 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4305 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4308 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4310
4311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4319
4320 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
4321
4322 { }
4323};
4324
4325/* pcm configuration: identiacal with ALC880 */
4326#define alc861_pcm_analog_playback alc880_pcm_analog_playback
4327#define alc861_pcm_analog_capture alc880_pcm_analog_capture
4328#define alc861_pcm_digital_playback alc880_pcm_digital_playback
4329#define alc861_pcm_digital_capture alc880_pcm_digital_capture
4330
4331
4332#define ALC861_DIGOUT_NID 0x07
4333
4334static struct hda_channel_mode alc861_8ch_modes[1] = {
4335 { 8, NULL }
4336};
4337
4338static hda_nid_t alc861_dac_nids[4] = {
4339 /* front, surround, clfe, side */
4340 0x03, 0x06, 0x05, 0x04
4341};
4342
4343static hda_nid_t alc861_adc_nids[1] = {
4344 /* ADC0-2 */
4345 0x08,
4346};
4347
4348static struct hda_input_mux alc861_capture_source = {
4349 .num_items = 5,
4350 .items = {
4351 { "Mic", 0x0 },
4352 { "Front Mic", 0x3 },
4353 { "Line", 0x1 },
4354 { "CD", 0x4 },
4355 { "Mixer", 0x5 },
4356 },
4357};
4358
4359/* fill in the dac_nids table from the parsed pin configuration */
4360static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4361{
4362 int i;
4363 hda_nid_t nid;
4364
4365 spec->multiout.dac_nids = spec->private_dac_nids;
4366 for (i = 0; i < cfg->line_outs; i++) {
4367 nid = cfg->line_out_pins[i];
4368 if (nid) {
4369 if (i >= ARRAY_SIZE(alc861_dac_nids))
4370 continue;
4371 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
4372 }
4373 }
4374 spec->multiout.num_dacs = cfg->line_outs;
4375 return 0;
4376}
4377
4378/* add playback controls from the parsed DAC table */
4379static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
4380 const struct auto_pin_cfg *cfg)
4381{
4382 char name[32];
4383 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
4384 hda_nid_t nid;
4385 int i, idx, err;
4386
4387 for (i = 0; i < cfg->line_outs; i++) {
4388 nid = spec->multiout.dac_nids[i];
4389 if (! nid)
4390 continue;
4391 if (nid == 0x05) {
4392 /* Center/LFE */
4393 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
4394 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
4395 return err;
4396 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
4397 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4398 return err;
4399 } else {
4400 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
4401 if (nid == alc861_dac_nids[idx])
4402 break;
4403 sprintf(name, "%s Playback Switch", chname[idx]);
4404 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4405 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4406 return err;
4407 }
4408 }
4409 return 0;
4410}
4411
4412static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
4413{
4414 int err;
4415 hda_nid_t nid;
4416
4417 if (! pin)
4418 return 0;
4419
4420 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
4421 nid = 0x03;
4422 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4423 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4424 return err;
4425 spec->multiout.hp_nid = nid;
4426 }
4427 return 0;
4428}
4429
4430/* create playback/capture controls for input pins */
4431static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4432{
Kailang Yangdf694da2005-12-05 19:42:22 +01004433 struct hda_input_mux *imux = &spec->private_imux;
4434 int i, err, idx, idx1;
4435
4436 for (i = 0; i < AUTO_PIN_LAST; i++) {
4437 switch(cfg->input_pins[i]) {
4438 case 0x0c:
4439 idx1 = 1;
4440 idx = 2; // Line In
4441 break;
4442 case 0x0f:
4443 idx1 = 2;
4444 idx = 2; // Line In
4445 break;
4446 case 0x0d:
4447 idx1 = 0;
4448 idx = 1; // Mic In
4449 break;
4450 case 0x10:
4451 idx1 = 3;
4452 idx = 1; // Mic In
4453 break;
4454 case 0x11:
4455 idx1 = 4;
4456 idx = 0; // CD
4457 break;
4458 default:
4459 continue;
4460 }
4461
Takashi Iwai4a471b72005-12-07 13:56:29 +01004462 err = new_analog_input(spec, cfg->input_pins[i],
4463 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01004464 if (err < 0)
4465 return err;
4466
Takashi Iwai4a471b72005-12-07 13:56:29 +01004467 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004468 imux->items[imux->num_items].index = idx1;
4469 imux->num_items++;
4470 }
4471 return 0;
4472}
4473
4474static struct snd_kcontrol_new alc861_capture_mixer[] = {
4475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4477
4478 {
4479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4480 /* The multiple "Capture Source" controls confuse alsamixer
4481 * So call somewhat different..
4482 *FIXME: the controls appear in the "playback" view!
4483 */
4484 /* .name = "Capture Source", */
4485 .name = "Input Source",
4486 .count = 1,
4487 .info = alc_mux_enum_info,
4488 .get = alc_mux_enum_get,
4489 .put = alc_mux_enum_put,
4490 },
4491 { } /* end */
4492};
4493
4494static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
4495 int pin_type, int dac_idx)
4496{
4497 /* set as output */
4498
4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4500 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4501
4502}
4503
4504static void alc861_auto_init_multi_out(struct hda_codec *codec)
4505{
4506 struct alc_spec *spec = codec->spec;
4507 int i;
4508
4509 for (i = 0; i < spec->autocfg.line_outs; i++) {
4510 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4511 if (nid)
4512 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
4513 }
4514}
4515
4516static void alc861_auto_init_hp_out(struct hda_codec *codec)
4517{
4518 struct alc_spec *spec = codec->spec;
4519 hda_nid_t pin;
4520
4521 pin = spec->autocfg.hp_pin;
4522 if (pin) /* connect to front */
4523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
4524}
4525
4526static void alc861_auto_init_analog_input(struct hda_codec *codec)
4527{
4528 struct alc_spec *spec = codec->spec;
4529 int i;
4530
4531 for (i = 0; i < AUTO_PIN_LAST; i++) {
4532 hda_nid_t nid = spec->autocfg.input_pins[i];
4533 if ((nid>=0x0c) && (nid <=0x11)) {
4534 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4535 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4536 }
4537 }
4538}
4539
4540/* parse the BIOS configuration and set up the alc_spec */
4541/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
4542static int alc861_parse_auto_config(struct hda_codec *codec)
4543{
4544 struct alc_spec *spec = codec->spec;
4545 int err;
4546 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
4547
4548 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4549 alc861_ignore)) < 0)
4550 return err;
4551 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4552 ! spec->autocfg.hp_pin)
4553 return 0; /* can't find valid BIOS pin config */
4554
4555 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
4556 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4557 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
4558 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4559 return err;
4560
4561 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4562
4563 if (spec->autocfg.dig_out_pin)
4564 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
4565
4566 if (spec->kctl_alloc)
4567 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4568
4569 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
4570
4571 spec->input_mux = &spec->private_imux;
4572
4573 spec->adc_nids = alc861_adc_nids;
4574 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
4575 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
4576 spec->num_mixers++;
4577
4578 return 1;
4579}
4580
4581/* init callback for auto-configuration model -- overriding the default init */
4582static int alc861_auto_init(struct hda_codec *codec)
4583{
4584 alc_init(codec);
4585 alc861_auto_init_multi_out(codec);
4586 alc861_auto_init_hp_out(codec);
4587 alc861_auto_init_analog_input(codec);
4588
4589 return 0;
4590}
4591
4592
4593/*
4594 * configuration and preset
4595 */
4596static struct hda_board_config alc861_cfg_tbl[] = {
4597 { .modelname = "3stack", .config = ALC861_3ST },
4598 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
4599 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
4600 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
4601 { .modelname = "auto", .config = ALC861_AUTO },
4602 {}
4603};
4604
4605static struct alc_config_preset alc861_presets[] = {
4606 [ALC861_3ST] = {
4607 .mixers = { alc861_3ST_mixer },
4608 .init_verbs = { alc861_threestack_init_verbs },
4609 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4610 .dac_nids = alc861_dac_nids,
4611 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4612 .channel_mode = alc861_threestack_modes,
4613 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4614 .adc_nids = alc861_adc_nids,
4615 .input_mux = &alc861_capture_source,
4616 },
4617 [ALC861_3ST_DIG] = {
4618 .mixers = { alc861_base_mixer },
4619 .init_verbs = { alc861_threestack_init_verbs },
4620 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4621 .dac_nids = alc861_dac_nids,
4622 .dig_out_nid = ALC861_DIGOUT_NID,
4623 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4624 .channel_mode = alc861_threestack_modes,
4625 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4626 .adc_nids = alc861_adc_nids,
4627 .input_mux = &alc861_capture_source,
4628 },
4629 [ALC861_6ST_DIG] = {
4630 .mixers = { alc861_base_mixer },
4631 .init_verbs = { alc861_base_init_verbs },
4632 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4633 .dac_nids = alc861_dac_nids,
4634 .dig_out_nid = ALC861_DIGOUT_NID,
4635 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
4636 .channel_mode = alc861_8ch_modes,
4637 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4638 .adc_nids = alc861_adc_nids,
4639 .input_mux = &alc861_capture_source,
4640 },
4641};
4642
4643
4644static int patch_alc861(struct hda_codec *codec)
4645{
4646 struct alc_spec *spec;
4647 int board_config;
4648 int err;
4649
4650 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4651 if (spec == NULL)
4652 return -ENOMEM;
4653
4654 codec->spec = spec;
4655
4656 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
4657 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
4658 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
4659 board_config = ALC861_AUTO;
4660 }
4661
4662 if (board_config == ALC861_AUTO) {
4663 /* automatic parse from the BIOS config */
4664 err = alc861_parse_auto_config(codec);
4665 if (err < 0) {
4666 alc_free(codec);
4667 return err;
4668 } else if (! err) {
4669 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4670 board_config = ALC861_3ST_DIG;
4671 }
4672 }
4673
4674 if (board_config != ALC861_AUTO)
4675 setup_preset(spec, &alc861_presets[board_config]);
4676
4677 spec->stream_name_analog = "ALC861 Analog";
4678 spec->stream_analog_playback = &alc861_pcm_analog_playback;
4679 spec->stream_analog_capture = &alc861_pcm_analog_capture;
4680
4681 spec->stream_name_digital = "ALC861 Digital";
4682 spec->stream_digital_playback = &alc861_pcm_digital_playback;
4683 spec->stream_digital_capture = &alc861_pcm_digital_capture;
4684
4685 codec->patch_ops = alc_patch_ops;
4686 if (board_config == ALC861_AUTO)
4687 codec->patch_ops.init = alc861_auto_init;
4688
4689 return 0;
4690}
4691
4692/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07004693 * patch entries
4694 */
4695struct hda_codec_preset snd_hda_preset_realtek[] = {
4696 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004697 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07004698 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
4699 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004700 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
4701 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4702 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07004703 {} /* terminator */
4704};