blob: a213c19ab06ced2517597d5cb35f32ba855c6acb [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 *
6 * Copyright (c) 2004 PeiSen Hou <pshou@realtek.com.tw>
7 * Takashi Iwai <tiwai@suse.de>
8 *
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <sound/driver.h>
25#include <linux/init.h>
26#include <linux/delay.h>
27#include <linux/slab.h>
28#include <linux/pci.h>
29#include <sound/core.h>
30#include "hda_codec.h"
31#include "hda_local.h"
32
33
34/* ALC880 board config type */
35enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 ALC880_3ST,
37 ALC880_3ST_DIG,
38 ALC880_5ST,
39 ALC880_5ST_DIG,
40 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020041 ALC880_Z71V,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020042 ALC880_AUTO,
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,
49 ALC880_UNIWILL_DIG,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020050#ifdef CONFIG_SND_DEBUG
51 ALC880_TEST,
52#endif
Takashi Iwai16ded522005-06-10 19:58:24 +020053 ALC880_MODEL_LAST /* last tag */
54};
55
56/* ALC260 models */
57enum {
58 ALC260_BASIC,
59 ALC260_HP,
Jonathan Woithea9430dd2005-09-16 19:12:48 +020060 ALC260_FUJITSU_S702x,
Takashi Iwai16ded522005-06-10 19:58:24 +020061 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070062};
63
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064/* amp values */
65#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
66#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
67#define AMP_OUT_MUTE 0xb080
68#define AMP_OUT_UNMUTE 0xb000
69#define AMP_OUT_ZERO 0xb000
70/* pinctl values */
71#define PIN_IN 0x20
72#define PIN_VREF80 0x24
73#define PIN_VREF50 0x21
74#define PIN_OUT 0x40
75#define PIN_HP 0xc0
Jonathan Woithea9430dd2005-09-16 19:12:48 +020076#define PIN_HP_AMP 0x80
Takashi Iwaie9edcee2005-06-13 14:16:38 +020077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078struct alc_spec {
79 /* codec parameterization */
Takashi Iwaie9edcee2005-06-13 14:16:38 +020080 snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 unsigned int num_mixers;
82
Takashi Iwaie9edcee2005-06-13 14:16:38 +020083 const struct hda_verb *init_verbs[3]; /* initialization verbs
84 * don't forget NULL termination!
85 */
86 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Takashi Iwai16ded522005-06-10 19:58:24 +020088 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 struct hda_pcm_stream *stream_analog_playback;
90 struct hda_pcm_stream *stream_analog_capture;
91
Takashi Iwai16ded522005-06-10 19:58:24 +020092 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 struct hda_pcm_stream *stream_digital_playback;
94 struct hda_pcm_stream *stream_digital_capture;
95
96 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +020097 struct hda_multi_out multiout; /* playback set-up
98 * max_channels, dacs must be set
99 * dig_out_nid and hp_nid are optional
100 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
102 /* capture */
103 unsigned int num_adc_nids;
104 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200105 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107 /* capture source */
108 const struct hda_input_mux *input_mux;
109 unsigned int cur_mux[3];
110
111 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100112 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 int num_channel_mode;
114
115 /* PCM information */
Takashi Iwai16ded522005-06-10 19:58:24 +0200116 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200117
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200118 /* dynamic controls, init_verbs and input_mux */
119 struct auto_pin_cfg autocfg;
120 unsigned int num_kctl_alloc, num_kctl_used;
121 snd_kcontrol_new_t *kctl_alloc;
122 struct hda_input_mux private_imux;
Takashi Iwaib0af0de2005-06-21 14:49:19 +0200123 hda_nid_t private_dac_nids[4];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124};
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127/*
128 * input MUX handling
129 */
130static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
131{
132 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
133 struct alc_spec *spec = codec->spec;
134 return snd_hda_input_mux_info(spec->input_mux, uinfo);
135}
136
137static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
138{
139 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
140 struct alc_spec *spec = codec->spec;
141 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
142
143 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
144 return 0;
145}
146
147static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
148{
149 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
150 struct alc_spec *spec = codec->spec;
151 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
152 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
153 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
154}
155
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157/*
158 * channel mode setting
159 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
161{
162 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
163 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100164 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
165 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166}
167
168static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
169{
170 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
171 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100172 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
173 spec->num_channel_mode, spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174}
175
176static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
177{
178 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
179 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100180 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
181 spec->num_channel_mode, &spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182}
183
184
185/*
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200186 * Control of pin widget settings via the mixer. Only boolean settings are
187 * supported, so VrefEn can't be controlled using these functions as they
188 * stand.
189 */
190static int alc_pinctl_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
191{
192 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
193 uinfo->count = 1;
194 uinfo->value.integer.min = 0;
195 uinfo->value.integer.max = 1;
196 return 0;
197}
198
199static int alc_pinctl_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
200{
201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
202 hda_nid_t nid = kcontrol->private_value & 0xffff;
203 long mask = (kcontrol->private_value >> 16) & 0xff;
204 long *valp = ucontrol->value.integer.value;
205
206 *valp = 0;
207 if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask)
208 *valp = 1;
209 return 0;
210}
211
212static int alc_pinctl_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
213{
214 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
215 hda_nid_t nid = kcontrol->private_value & 0xffff;
216 long mask = (kcontrol->private_value >> 16) & 0xff;
217 long *valp = ucontrol->value.integer.value;
218 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
219 int change = ((pinctl & mask)!=0) != *valp;
220
221 if (change)
222 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
223 *valp?(pinctl|mask):(pinctl&~mask));
224 return change;
225}
226
227#define ALC_PINCTL_SWITCH(xname, nid, mask) \
228 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
229 .info = alc_pinctl_switch_info, \
230 .get = alc_pinctl_switch_get, \
231 .put = alc_pinctl_switch_put, \
232 .private_value = (nid) | (mask<<16) }
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200233
Takashi Iwai41e41f12005-06-08 14:48:49 +0200234/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200235 * ALC880 3-stack model
236 *
237 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
238 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
239 * HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 */
241
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200242static hda_nid_t alc880_dac_nids[4] = {
243 /* front, rear, clfe, rear_surr */
244 0x02, 0x05, 0x04, 0x03
245};
246
247static hda_nid_t alc880_adc_nids[3] = {
248 /* ADC0-2 */
249 0x07, 0x08, 0x09,
250};
251
252/* The datasheet says the node 0x07 is connected from inputs,
253 * but it shows zero connection in the real implementation on some devices.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200255static hda_nid_t alc880_adc_nids_alt[2] = {
256 /* ADC1-2 */
257 0x08, 0x09,
258};
259
260#define ALC880_DIGOUT_NID 0x06
261#define ALC880_DIGIN_NID 0x0a
262
263static struct hda_input_mux alc880_capture_source = {
264 .num_items = 4,
265 .items = {
266 { "Mic", 0x0 },
267 { "Front Mic", 0x3 },
268 { "Line", 0x2 },
269 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200271};
272
273/* channel source setting (2/6 channel selection for 3-stack) */
274/* 2ch mode */
275static struct hda_verb alc880_threestack_ch2_init[] = {
276 /* set line-in to input, mute it */
277 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
278 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
279 /* set mic-in to input vref 80%, mute it */
280 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
281 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 { } /* end */
283};
284
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200285/* 6ch mode */
286static struct hda_verb alc880_threestack_ch6_init[] = {
287 /* set line-in to output, unmute it */
288 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
289 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
290 /* set mic-in to output, unmute it */
291 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
292 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
293 { } /* end */
294};
295
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100296static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200297 { 2, alc880_threestack_ch2_init },
298 { 6, alc880_threestack_ch6_init },
299};
300
301static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200302 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100303 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200304 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100305 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200306 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
307 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100308 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
309 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
311 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
312 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
313 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
316 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
317 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
318 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
319 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200321 {
322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
323 .name = "Channel Mode",
324 .info = alc880_ch_mode_info,
325 .get = alc880_ch_mode_get,
326 .put = alc880_ch_mode_put,
327 },
328 { } /* end */
329};
330
331/* capture mixer elements */
332static snd_kcontrol_new_t alc880_capture_mixer[] = {
333 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
334 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
335 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
336 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
337 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
338 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
339 {
340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
341 /* The multiple "Capture Source" controls confuse alsamixer
342 * So call somewhat different..
343 * FIXME: the controls appear in the "playback" view!
344 */
345 /* .name = "Capture Source", */
346 .name = "Input Source",
347 .count = 3,
348 .info = alc_mux_enum_info,
349 .get = alc_mux_enum_get,
350 .put = alc_mux_enum_put,
351 },
352 { } /* end */
353};
354
355/* capture mixer elements (in case NID 0x07 not available) */
356static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200357 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
358 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
359 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
360 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 {
362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
363 /* The multiple "Capture Source" controls confuse alsamixer
364 * So call somewhat different..
365 * FIXME: the controls appear in the "playback" view!
366 */
367 /* .name = "Capture Source", */
368 .name = "Input Source",
369 .count = 2,
370 .info = alc_mux_enum_info,
371 .get = alc_mux_enum_get,
372 .put = alc_mux_enum_put,
373 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 { } /* end */
375};
376
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200377
378
379/*
380 * ALC880 5-stack model
381 *
382 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
383 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
384 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
385 */
386
387/* additional mixers to alc880_three_stack_mixer */
388static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
389 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100390 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 { } /* end */
392};
393
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200394/* channel source setting (6/8 channel selection for 5-stack) */
395/* 6ch mode */
396static struct hda_verb alc880_fivestack_ch6_init[] = {
397 /* set line-in to input, mute it */
398 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
399 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200400 { } /* end */
401};
402
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200403/* 8ch mode */
404static struct hda_verb alc880_fivestack_ch8_init[] = {
405 /* set line-in to output, unmute it */
406 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
407 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
408 { } /* end */
409};
410
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100411static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200412 { 6, alc880_fivestack_ch6_init },
413 { 8, alc880_fivestack_ch8_init },
414};
415
416
417/*
418 * ALC880 6-stack model
419 *
420 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
421 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
422 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
423 */
424
425static hda_nid_t alc880_6st_dac_nids[4] = {
426 /* front, rear, clfe, rear_surr */
427 0x02, 0x03, 0x04, 0x05
428};
429
430static struct hda_input_mux alc880_6stack_capture_source = {
431 .num_items = 4,
432 .items = {
433 { "Mic", 0x0 },
434 { "Front Mic", 0x1 },
435 { "Line", 0x2 },
436 { "CD", 0x4 },
437 },
438};
439
440/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100441static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200442 { 8, NULL },
443};
444
Takashi Iwai16ded522005-06-10 19:58:24 +0200445static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
446 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100447 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200448 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100449 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200450 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
451 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100452 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
453 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200454 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100455 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
458 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
459 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
464 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
465 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200466 {
467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
468 .name = "Channel Mode",
469 .info = alc880_ch_mode_info,
470 .get = alc880_ch_mode_get,
471 .put = alc880_ch_mode_put,
472 },
473 { } /* end */
474};
475
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200476
477/*
478 * ALC880 W810 model
479 *
480 * W810 has rear IO for:
481 * Front (DAC 02)
482 * Surround (DAC 03)
483 * Center/LFE (DAC 04)
484 * Digital out (06)
485 *
486 * The system also has a pair of internal speakers, and a headphone jack.
487 * These are both connected to Line2 on the codec, hence to DAC 02.
488 *
489 * There is a variable resistor to control the speaker or headphone
490 * volume. This is a hardware-only device without a software API.
491 *
492 * Plugging headphones in will disable the internal speakers. This is
493 * implemented in hardware, not via the driver using jack sense. In
494 * a similar fashion, plugging into the rear socket marked "front" will
495 * disable both the speakers and headphones.
496 *
497 * For input, there's a microphone jack, and an "audio in" jack.
498 * These may not do anything useful with this driver yet, because I
499 * haven't setup any initialization verbs for these yet...
500 */
501
502static hda_nid_t alc880_w810_dac_nids[3] = {
503 /* front, rear/surround, clfe */
504 0x02, 0x03, 0x04
505};
506
507/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100508static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200509 { 6, NULL }
510};
511
512/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
513static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
514 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 Iwaie9edcee2005-06-13 14:16:38 +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 Iwaie9edcee2005-06-13 14:16:38 +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 Iwaie9edcee2005-06-13 14:16:38 +0200522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
523 { } /* end */
524};
525
526
527/*
528 * Z710V model
529 *
530 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
531 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
532 */
533
534static hda_nid_t alc880_z71v_dac_nids[1] = {
535 0x02
536};
537#define ALC880_Z71V_HP_DAC 0x03
538
539/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100540static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200541 { 2, NULL }
542};
543
544static snd_kcontrol_new_t alc880_z71v_mixer[] = {
545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100546 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200547 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100548 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200549 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
550 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
553 { } /* end */
554};
555
556
557/* FIXME! */
558/*
559 * ALC880 F1734 model
560 *
561 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
562 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
563 */
564
565static hda_nid_t alc880_f1734_dac_nids[1] = {
566 0x03
567};
568#define ALC880_F1734_HP_DAC 0x02
569
570static snd_kcontrol_new_t alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200571 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100572 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200573 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100574 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200579 { } /* end */
580};
581
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200582
583/* FIXME! */
584/*
585 * ALC880 ASUS model
586 *
587 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
588 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
589 * Mic = 0x18, Line = 0x1a
590 */
591
592#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
593#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
594
Takashi Iwai16ded522005-06-10 19:58:24 +0200595static snd_kcontrol_new_t alc880_asus_mixer[] = {
596 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100597 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200598 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100599 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200600 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
601 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100602 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
603 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200604 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
605 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
606 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
607 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200610 {
611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
612 .name = "Channel Mode",
613 .info = alc880_ch_mode_info,
614 .get = alc880_ch_mode_get,
615 .put = alc880_ch_mode_put,
616 },
617 { } /* end */
618};
619
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200620/* FIXME! */
621/*
622 * ALC880 ASUS W1V model
623 *
624 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
625 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
626 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
627 */
628
629/* additional mixers to alc880_asus_mixer */
Takashi Iwai16ded522005-06-10 19:58:24 +0200630static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200631 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
632 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200633 { } /* end */
634};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200635
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200636/* additional mixers to alc880_asus_mixer */
637static snd_kcontrol_new_t alc880_pcbeep_mixer[] = {
638 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
639 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
640 { } /* end */
641};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200642
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200644 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 */
646static int alc_build_controls(struct hda_codec *codec)
647{
648 struct alc_spec *spec = codec->spec;
649 int err;
650 int i;
651
652 for (i = 0; i < spec->num_mixers; i++) {
653 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
654 if (err < 0)
655 return err;
656 }
657
658 if (spec->multiout.dig_out_nid) {
659 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
660 if (err < 0)
661 return err;
662 }
663 if (spec->dig_in_nid) {
664 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
665 if (err < 0)
666 return err;
667 }
668 return 0;
669}
670
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200671
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672/*
673 * initialize the codec volumes, etc
674 */
675
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200676/*
677 * generic initialization of ADC, input mixers and output mixers
678 */
679static struct hda_verb alc880_volume_init_verbs[] = {
680 /*
681 * Unmute ADC0-2 and set the default input to mic-in
682 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200683 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200685 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200687 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200688 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200690 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
691 * mixer widget
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 * Note: PASD motherboards uses the Line In 2 as the input for front panel
693 * mic (mic 2)
694 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200695 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200702 /*
703 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200705 /* set vol=0 to output mixers */
706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
707 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
710 /* set up input amps for analog loopback */
711 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +0200712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
715 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +0200718 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
719 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720
721 { }
722};
723
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200724/*
725 * 3-stack pin configuration:
726 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
727 */
728static struct hda_verb alc880_pin_3stack_init_verbs[] = {
729 /*
730 * preset connection lists of input pins
731 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
732 */
733 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
734 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
735 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
736
737 /*
738 * Set pin mode and muting
739 */
740 /* set front pin widgets 0x14 for output */
741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
743 /* Mic1 (rear panel) pin widget for input and vref at 80% */
744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
746 /* Mic2 (as headphone out) for HP output */
747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
749 /* Line In pin widget for input */
750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
752 /* Line2 (as front mic) pin widget for input and vref at 80% */
753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
755 /* CD pin widget for input */
756 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
757
758 { }
759};
760
761/*
762 * 5-stack pin configuration:
763 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
764 * line-in/side = 0x1a, f-mic = 0x1b
765 */
766static struct hda_verb alc880_pin_5stack_init_verbs[] = {
767 /*
768 * preset connection lists of input pins
769 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
770 */
771 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
772 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
773
774 /*
775 * Set pin mode and muting
776 */
777 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +0200778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
780 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
781 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200782 /* unmute pins for output (no gain on this amp) */
783 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
785 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
787
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +0200789 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200790 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
791 /* Mic2 (as headphone out) for HP output */
792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +0200793 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200794 /* Line In pin widget for input */
795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
797 /* Line2 (as front mic) pin widget for input and vref at 80% */
798 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
799 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
800 /* CD pin widget for input */
801 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802
803 { }
804};
805
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200806/*
807 * W810 pin configuration:
808 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
809 */
810static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 /* hphone/speaker input selector: front DAC */
812 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
813
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
820
821 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +0200822 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 { }
825};
826
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200827/*
828 * Z71V pin configuration:
829 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
830 */
831static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200832 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200833 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +0200834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200836
Takashi Iwai16ded522005-06-10 19:58:24 +0200837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200838 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +0200839 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200840 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200841
842 { }
843};
844
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200845/*
846 * 6-stack pin configuration:
847 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
848 * line = 0x1a, HP = 0x1b
849 */
850static struct hda_verb alc880_pin_6stack_init_verbs[] = {
851 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
852
Takashi Iwai16ded522005-06-10 19:58:24 +0200853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200857 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200859 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200860 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
861
Takashi Iwai16ded522005-06-10 19:58:24 +0200862 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200863 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200864 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200868 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +0200869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +0200870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
871
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200872 { }
873};
Takashi Iwai16ded522005-06-10 19:58:24 +0200874
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200875/* FIXME! */
876/*
877 * F1734 pin configuration:
878 * HP = 0x14, speaker-out = 0x15, mic = 0x18
879 */
880static struct hda_verb alc880_pin_f1734_init_verbs[] = {
881 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
882 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
883 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
884 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
885
886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
890
891 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
893 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
897 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
898 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
899 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +0200900
901 { }
902};
903
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200904/* FIXME! */
905/*
906 * ASUS pin configuration:
907 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
908 */
909static struct hda_verb alc880_pin_asus_init_verbs[] = {
910 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
911 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
912 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
913 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
914
915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
921 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
922 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
923
924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
933
934 { }
935};
936
937/* Enable GPIO mask and set output */
938static struct hda_verb alc880_gpio1_init_verbs[] = {
939 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
940 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
941 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
942};
943
944/* Enable GPIO mask and set output */
945static struct hda_verb alc880_gpio2_init_verbs[] = {
946 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
947 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
948 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
949};
950
951
952/*
953 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200954
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955static int alc_init(struct hda_codec *codec)
956{
957 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200958 unsigned int i;
959
960 for (i = 0; i < spec->num_init_verbs; i++)
961 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 return 0;
963}
964
965#ifdef CONFIG_PM
966/*
967 * resume
968 */
969static int alc_resume(struct hda_codec *codec)
970{
971 struct alc_spec *spec = codec->spec;
972 int i;
973
974 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200975 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 if (spec->multiout.dig_out_nid)
978 snd_hda_resume_spdif_out(codec);
979 if (spec->dig_in_nid)
980 snd_hda_resume_spdif_in(codec);
981
982 return 0;
983}
984#endif
985
986/*
987 * Analog playback callbacks
988 */
989static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
990 struct hda_codec *codec,
991 snd_pcm_substream_t *substream)
992{
993 struct alc_spec *spec = codec->spec;
994 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
995}
996
997static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
998 struct hda_codec *codec,
999 unsigned int stream_tag,
1000 unsigned int format,
1001 snd_pcm_substream_t *substream)
1002{
1003 struct alc_spec *spec = codec->spec;
1004 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1005 format, substream);
1006}
1007
1008static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1009 struct hda_codec *codec,
1010 snd_pcm_substream_t *substream)
1011{
1012 struct alc_spec *spec = codec->spec;
1013 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1014}
1015
1016/*
1017 * Digital out
1018 */
1019static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1020 struct hda_codec *codec,
1021 snd_pcm_substream_t *substream)
1022{
1023 struct alc_spec *spec = codec->spec;
1024 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1025}
1026
1027static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1028 struct hda_codec *codec,
1029 snd_pcm_substream_t *substream)
1030{
1031 struct alc_spec *spec = codec->spec;
1032 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1033}
1034
1035/*
1036 * Analog capture
1037 */
1038static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1039 struct hda_codec *codec,
1040 unsigned int stream_tag,
1041 unsigned int format,
1042 snd_pcm_substream_t *substream)
1043{
1044 struct alc_spec *spec = codec->spec;
1045
1046 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1047 stream_tag, 0, format);
1048 return 0;
1049}
1050
1051static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1052 struct hda_codec *codec,
1053 snd_pcm_substream_t *substream)
1054{
1055 struct alc_spec *spec = codec->spec;
1056
1057 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1058 return 0;
1059}
1060
1061
1062/*
1063 */
1064static struct hda_pcm_stream alc880_pcm_analog_playback = {
1065 .substreams = 1,
1066 .channels_min = 2,
1067 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001068 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 .ops = {
1070 .open = alc880_playback_pcm_open,
1071 .prepare = alc880_playback_pcm_prepare,
1072 .cleanup = alc880_playback_pcm_cleanup
1073 },
1074};
1075
1076static struct hda_pcm_stream alc880_pcm_analog_capture = {
1077 .substreams = 2,
1078 .channels_min = 2,
1079 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001080 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081 .ops = {
1082 .prepare = alc880_capture_pcm_prepare,
1083 .cleanup = alc880_capture_pcm_cleanup
1084 },
1085};
1086
1087static struct hda_pcm_stream alc880_pcm_digital_playback = {
1088 .substreams = 1,
1089 .channels_min = 2,
1090 .channels_max = 2,
1091 /* NID is set in alc_build_pcms */
1092 .ops = {
1093 .open = alc880_dig_playback_pcm_open,
1094 .close = alc880_dig_playback_pcm_close
1095 },
1096};
1097
1098static struct hda_pcm_stream alc880_pcm_digital_capture = {
1099 .substreams = 1,
1100 .channels_min = 2,
1101 .channels_max = 2,
1102 /* NID is set in alc_build_pcms */
1103};
1104
1105static int alc_build_pcms(struct hda_codec *codec)
1106{
1107 struct alc_spec *spec = codec->spec;
1108 struct hda_pcm *info = spec->pcm_rec;
1109 int i;
1110
1111 codec->num_pcms = 1;
1112 codec->pcm_info = info;
1113
1114 info->name = spec->stream_name_analog;
1115 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001116 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001118 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119
1120 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1121 for (i = 0; i < spec->num_channel_mode; i++) {
1122 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1123 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1124 }
1125 }
1126
1127 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1128 codec->num_pcms++;
1129 info++;
1130 info->name = spec->stream_name_digital;
1131 if (spec->multiout.dig_out_nid) {
1132 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1133 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1134 }
1135 if (spec->dig_in_nid) {
1136 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1137 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1138 }
1139 }
1140
1141 return 0;
1142}
1143
1144static void alc_free(struct hda_codec *codec)
1145{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001146 struct alc_spec *spec = codec->spec;
1147 unsigned int i;
1148
1149 if (! spec)
1150 return;
1151
1152 if (spec->kctl_alloc) {
1153 for (i = 0; i < spec->num_kctl_used; i++)
1154 kfree(spec->kctl_alloc[i].name);
1155 kfree(spec->kctl_alloc);
1156 }
1157 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158}
1159
1160/*
1161 */
1162static struct hda_codec_ops alc_patch_ops = {
1163 .build_controls = alc_build_controls,
1164 .build_pcms = alc_build_pcms,
1165 .init = alc_init,
1166 .free = alc_free,
1167#ifdef CONFIG_PM
1168 .resume = alc_resume,
1169#endif
1170};
1171
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001172
1173/*
1174 * Test configuration for debugging
1175 *
1176 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1177 * enum controls.
1178 */
1179#ifdef CONFIG_SND_DEBUG
1180static hda_nid_t alc880_test_dac_nids[4] = {
1181 0x02, 0x03, 0x04, 0x05
1182};
1183
1184static struct hda_input_mux alc880_test_capture_source = {
1185 .num_items = 5,
1186 .items = {
1187 { "In-1", 0x0 },
1188 { "In-2", 0x1 },
1189 { "In-3", 0x2 },
1190 { "In-4", 0x3 },
1191 { "CD", 0x4 },
1192 },
1193};
1194
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001195static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001196 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001197 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001198 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001199 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001200};
1201
1202static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1203{
1204 static char *texts[] = {
1205 "N/A", "Line Out", "HP Out",
1206 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1207 };
1208 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1209 uinfo->count = 1;
1210 uinfo->value.enumerated.items = 8;
1211 if (uinfo->value.enumerated.item >= 8)
1212 uinfo->value.enumerated.item = 7;
1213 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1214 return 0;
1215}
1216
1217static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1218{
1219 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1220 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1221 unsigned int pin_ctl, item = 0;
1222
1223 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1224 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1225 if (pin_ctl & AC_PINCTL_OUT_EN) {
1226 if (pin_ctl & AC_PINCTL_HP_EN)
1227 item = 2;
1228 else
1229 item = 1;
1230 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1231 switch (pin_ctl & AC_PINCTL_VREFEN) {
1232 case AC_PINCTL_VREF_HIZ: item = 3; break;
1233 case AC_PINCTL_VREF_50: item = 4; break;
1234 case AC_PINCTL_VREF_GRD: item = 5; break;
1235 case AC_PINCTL_VREF_80: item = 6; break;
1236 case AC_PINCTL_VREF_100: item = 7; break;
1237 }
1238 }
1239 ucontrol->value.enumerated.item[0] = item;
1240 return 0;
1241}
1242
1243static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1244{
1245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1246 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1247 static unsigned int ctls[] = {
1248 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1249 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1250 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1251 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1252 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1253 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1254 };
1255 unsigned int old_ctl, new_ctl;
1256
1257 old_ctl = snd_hda_codec_read(codec, nid, 0,
1258 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1259 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1260 if (old_ctl != new_ctl) {
1261 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1262 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1263 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1264 return 1;
1265 }
1266 return 0;
1267}
1268
1269static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1270{
1271 static char *texts[] = {
1272 "Front", "Surround", "CLFE", "Side"
1273 };
1274 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1275 uinfo->count = 1;
1276 uinfo->value.enumerated.items = 4;
1277 if (uinfo->value.enumerated.item >= 4)
1278 uinfo->value.enumerated.item = 3;
1279 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1280 return 0;
1281}
1282
1283static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1284{
1285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1286 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1287 unsigned int sel;
1288
1289 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1290 ucontrol->value.enumerated.item[0] = sel & 3;
1291 return 0;
1292}
1293
1294static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1295{
1296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1297 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1298 unsigned int sel;
1299
1300 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1301 if (ucontrol->value.enumerated.item[0] != sel) {
1302 sel = ucontrol->value.enumerated.item[0] & 3;
1303 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1304 return 1;
1305 }
1306 return 0;
1307}
1308
1309#define PIN_CTL_TEST(xname,nid) { \
1310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1311 .name = xname, \
1312 .info = alc_test_pin_ctl_info, \
1313 .get = alc_test_pin_ctl_get, \
1314 .put = alc_test_pin_ctl_put, \
1315 .private_value = nid \
1316 }
1317
1318#define PIN_SRC_TEST(xname,nid) { \
1319 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1320 .name = xname, \
1321 .info = alc_test_pin_src_info, \
1322 .get = alc_test_pin_src_get, \
1323 .put = alc_test_pin_src_put, \
1324 .private_value = nid \
1325 }
1326
1327static snd_kcontrol_new_t alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001328 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1329 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1330 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1331 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001332 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1333 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1334 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1335 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001336 PIN_CTL_TEST("Front Pin Mode", 0x14),
1337 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1338 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1339 PIN_CTL_TEST("Side Pin Mode", 0x17),
1340 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1341 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1342 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1343 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1344 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1345 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1346 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1347 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1348 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1349 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1350 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1351 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1352 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1353 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1354 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1355 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001358 {
1359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1360 .name = "Channel Mode",
1361 .info = alc880_ch_mode_info,
1362 .get = alc880_ch_mode_get,
1363 .put = alc880_ch_mode_put,
1364 },
1365 { } /* end */
1366};
1367
1368static struct hda_verb alc880_test_init_verbs[] = {
1369 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1376 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001378 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001383 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1385 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1386 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1387 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001388 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1392 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001393 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02001394 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1395 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02001396 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1397 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1398 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001399 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02001400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1401 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1403 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001404 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02001405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001406 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001408 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001410 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001411 /* Analog input/passthru */
1412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001417 { }
1418};
1419#endif
1420
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421/*
1422 */
1423
1424static struct hda_board_config alc880_cfg_tbl[] = {
1425 /* Back 3 jack, front 2 jack */
1426 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001427 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1428 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1429 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1430 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1431 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1432 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1433 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1434 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1435 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1436 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1437 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1438 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1439 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1440 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1441 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1442 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1443 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1444 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1445 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1446 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1447 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1448 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1449 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1450 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1451 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1452 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1453 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1454 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1455 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1456 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1457 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1458 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459
1460 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02001461 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001462 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02001463 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464
1465 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1466 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001467 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe3c2005-08-15 20:01:40 +02001468 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469
1470 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02001471 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1472 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1473 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474
1475 /* Back 5 jack, front 2 jack */
1476 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001477 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1478 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1479 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1480 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001481 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482
1483 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1484 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001485 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1486 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1487 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1488 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1489 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1490 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1491 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1492 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001493 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwai7a318a72005-06-28 14:16:21 +02001494 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02001495 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001496 /* note subvendor = 0 below */
1497 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498
1499 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02001500 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001502 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02001503 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001504
Takashi Iwaib6482d42005-06-27 15:32:43 +02001505 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02001506 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Takashi Iwaib6482d42005-06-27 15:32:43 +02001507
1508 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001509 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1510 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1511 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1512 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1513
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001514 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02001515 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1516 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1517 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1518 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02001519 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02001520 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1521 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1522 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1523 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1524 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1525 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1526
1527 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1528 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1529
1530 { .modelname = "F1734", .config = ALC880_F1734 },
1531 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1532
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001533#ifdef CONFIG_SND_DEBUG
1534 { .modelname = "test", .config = ALC880_TEST },
1535#endif
1536
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 {}
1538};
1539
Takashi Iwai16ded522005-06-10 19:58:24 +02001540/*
1541 * configuration template - to be copied to the spec instance
1542 */
1543struct alc_config_preset {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001544 snd_kcontrol_new_t *mixers[4];
1545 const struct hda_verb *init_verbs[4];
Takashi Iwai16ded522005-06-10 19:58:24 +02001546 unsigned int num_dacs;
1547 hda_nid_t *dac_nids;
1548 hda_nid_t dig_out_nid; /* optional */
1549 hda_nid_t hp_nid; /* optional */
1550 unsigned int num_adc_nids;
1551 hda_nid_t *adc_nids;
1552 unsigned int num_channel_mode;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001553 const struct hda_channel_mode *channel_mode;
Takashi Iwai16ded522005-06-10 19:58:24 +02001554 const struct hda_input_mux *input_mux;
1555};
1556
1557static struct alc_config_preset alc880_presets[] = {
1558 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001559 .mixers = { alc880_three_stack_mixer },
1560 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001561 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02001562 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001563 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1564 .channel_mode = alc880_threestack_modes,
1565 .input_mux = &alc880_capture_source,
1566 },
1567 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001568 .mixers = { alc880_three_stack_mixer },
1569 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001570 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02001571 .dac_nids = alc880_dac_nids,
1572 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001573 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1574 .channel_mode = alc880_threestack_modes,
1575 .input_mux = &alc880_capture_source,
1576 },
1577 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001578 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1579 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001580 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1581 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001582 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1583 .channel_mode = alc880_fivestack_modes,
1584 .input_mux = &alc880_capture_source,
1585 },
1586 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001587 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1588 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001589 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1590 .dac_nids = alc880_dac_nids,
1591 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001592 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1593 .channel_mode = alc880_fivestack_modes,
1594 .input_mux = &alc880_capture_source,
1595 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02001596 [ALC880_6ST] = {
1597 .mixers = { alc880_six_stack_mixer },
1598 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1599 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1600 .dac_nids = alc880_6st_dac_nids,
1601 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1602 .channel_mode = alc880_sixstack_modes,
1603 .input_mux = &alc880_6stack_capture_source,
1604 },
Takashi Iwai16ded522005-06-10 19:58:24 +02001605 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001606 .mixers = { alc880_six_stack_mixer },
1607 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001608 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1609 .dac_nids = alc880_6st_dac_nids,
1610 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001611 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1612 .channel_mode = alc880_sixstack_modes,
1613 .input_mux = &alc880_6stack_capture_source,
1614 },
1615 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001616 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001617 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1618 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001619 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1620 .dac_nids = alc880_w810_dac_nids,
1621 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001622 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1623 .channel_mode = alc880_w810_modes,
1624 .input_mux = &alc880_capture_source,
1625 },
1626 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001627 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001628 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001629 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1630 .dac_nids = alc880_z71v_dac_nids,
1631 .dig_out_nid = ALC880_DIGOUT_NID,
1632 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001633 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1634 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001635 .input_mux = &alc880_capture_source,
1636 },
1637 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001638 .mixers = { alc880_f1734_mixer },
1639 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1640 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1641 .dac_nids = alc880_f1734_dac_nids,
1642 .hp_nid = 0x02,
1643 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1644 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001645 .input_mux = &alc880_capture_source,
1646 },
1647 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648 .mixers = { alc880_asus_mixer },
1649 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1650 alc880_gpio1_init_verbs },
1651 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1652 .dac_nids = alc880_asus_dac_nids,
1653 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1654 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001655 .input_mux = &alc880_capture_source,
1656 },
1657 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 .mixers = { alc880_asus_mixer },
1659 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1660 alc880_gpio1_init_verbs },
1661 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1662 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001663 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1665 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001666 .input_mux = &alc880_capture_source,
1667 },
1668 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001669 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1670 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1671 alc880_gpio1_init_verbs },
1672 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1673 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001674 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001675 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1676 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001677 .input_mux = &alc880_capture_source,
1678 },
1679 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001680 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001681 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1682 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1683 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02001684 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1686 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02001687 .input_mux = &alc880_capture_source,
1688 },
1689#ifdef CONFIG_SND_DEBUG
1690 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691 .mixers = { alc880_test_mixer },
1692 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02001693 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1694 .dac_nids = alc880_test_dac_nids,
1695 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02001696 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1697 .channel_mode = alc880_test_modes,
1698 .input_mux = &alc880_test_capture_source,
1699 },
1700#endif
1701};
1702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001703/*
1704 * Automatic parse of I/O pins from the BIOS configuration
1705 */
1706
1707#define NUM_CONTROL_ALLOC 32
1708#define NUM_VERB_ALLOC 32
1709
1710enum {
1711 ALC_CTL_WIDGET_VOL,
1712 ALC_CTL_WIDGET_MUTE,
1713 ALC_CTL_BIND_MUTE,
1714};
1715static snd_kcontrol_new_t alc880_control_templates[] = {
1716 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1717 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01001718 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001719};
1720
1721/* add dynamic controls */
1722static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1723{
1724 snd_kcontrol_new_t *knew;
1725
1726 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1727 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1728
1729 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1730 if (! knew)
1731 return -ENOMEM;
1732 if (spec->kctl_alloc) {
1733 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1734 kfree(spec->kctl_alloc);
1735 }
1736 spec->kctl_alloc = knew;
1737 spec->num_kctl_alloc = num;
1738 }
1739
1740 knew = &spec->kctl_alloc[spec->num_kctl_used];
1741 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07001742 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 if (! knew->name)
1744 return -ENOMEM;
1745 knew->private_value = val;
1746 spec->num_kctl_used++;
1747 return 0;
1748}
1749
1750#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1751#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1752#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1753#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1754#define alc880_is_input_pin(nid) ((nid) >= 0x18)
1755#define alc880_input_pin_idx(nid) ((nid) - 0x18)
1756#define alc880_idx_to_dac(nid) ((nid) + 0x02)
1757#define alc880_dac_to_idx(nid) ((nid) - 0x02)
1758#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1759#define alc880_idx_to_selector(nid) ((nid) + 0x10)
1760#define ALC880_PIN_CD_NID 0x1c
1761
1762/* fill in the dac_nids table from the parsed pin configuration */
1763static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1764{
1765 hda_nid_t nid;
1766 int assigned[4];
1767 int i, j;
1768
1769 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02001770 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001771
1772 /* check the pins hardwired to audio widget */
1773 for (i = 0; i < cfg->line_outs; i++) {
1774 nid = cfg->line_out_pins[i];
1775 if (alc880_is_fixed_pin(nid)) {
1776 int idx = alc880_fixed_pin_idx(nid);
1777 spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
1778 assigned[idx] = 1;
1779 }
1780 }
1781 /* left pins can be connect to any audio widget */
1782 for (i = 0; i < cfg->line_outs; i++) {
1783 nid = cfg->line_out_pins[i];
1784 if (alc880_is_fixed_pin(nid))
1785 continue;
1786 /* search for an empty channel */
1787 for (j = 0; j < cfg->line_outs; j++) {
1788 if (! assigned[j]) {
1789 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1790 assigned[j] = 1;
1791 break;
1792 }
1793 }
1794 }
1795 spec->multiout.num_dacs = cfg->line_outs;
1796 return 0;
1797}
1798
1799/* add playback controls from the parsed DAC table */
1800static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1801{
1802 char name[32];
1803 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1804 hda_nid_t nid;
1805 int i, err;
1806
1807 for (i = 0; i < cfg->line_outs; i++) {
1808 if (! spec->multiout.dac_nids[i])
1809 continue;
1810 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
1811 if (i == 2) {
1812 /* Center/LFE */
1813 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
1814 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1815 return err;
1816 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
1817 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1818 return err;
1819 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
1820 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
1821 return err;
1822 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
1823 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
1824 return err;
1825 } else {
1826 sprintf(name, "%s Playback Volume", chname[i]);
1827 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1828 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1829 return err;
1830 sprintf(name, "%s Playback Switch", chname[i]);
1831 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
1832 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1833 return err;
1834 }
1835 }
1836
1837 return 0;
1838}
1839
1840/* add playback controls for HP output */
1841static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
1842{
1843 hda_nid_t nid;
1844 int err;
1845
1846 if (! pin)
1847 return 0;
1848
1849 if (alc880_is_fixed_pin(pin)) {
1850 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
1851 if (! spec->multiout.dac_nids[0]) {
1852 /* use this as the primary output */
1853 spec->multiout.dac_nids[0] = nid;
1854 if (! spec->multiout.num_dacs)
1855 spec->multiout.num_dacs = 1;
1856 } else
1857 /* specify the DAC as the extra HP output */
1858 spec->multiout.hp_nid = nid;
1859 /* control HP volume/switch on the output mixer amp */
1860 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
1861 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
1862 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1863 return err;
1864 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
1865 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1866 return err;
1867 } else if (alc880_is_multi_pin(pin)) {
1868 /* set manual connection */
1869 if (! spec->multiout.dac_nids[0]) {
1870 /* use this as the primary output */
1871 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
1872 if (! spec->multiout.num_dacs)
1873 spec->multiout.num_dacs = 1;
1874 }
1875 /* we have only a switch on HP-out PIN */
1876 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
1877 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
1878 return err;
1879 }
1880 return 0;
1881}
1882
1883/* create input playback/capture controls for the given pin */
1884static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
1885{
1886 char name[32];
1887 int err, idx;
1888
1889 sprintf(name, "%s Playback Volume", ctlname);
1890 idx = alc880_input_pin_idx(pin);
1891 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1892 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1893 return err;
1894 sprintf(name, "%s Playback Switch", ctlname);
1895 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
1896 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1897 return err;
1898 return 0;
1899}
1900
1901/* create playback/capture controls for input pins */
1902static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1903{
1904 static char *labels[AUTO_PIN_LAST] = {
1905 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1906 };
1907 struct hda_input_mux *imux = &spec->private_imux;
1908 int i, err;
1909
1910 for (i = 0; i < AUTO_PIN_LAST; i++) {
1911 if (alc880_is_input_pin(cfg->input_pins[i])) {
1912 err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
1913 if (err < 0)
1914 return err;
1915 imux->items[imux->num_items].label = labels[i];
1916 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
1917 imux->num_items++;
1918 }
1919 }
1920 return 0;
1921}
1922
1923static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
1924 int dac_idx)
1925{
1926 /* set as output */
1927 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1928 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
1929 /* need the manual connection? */
1930 if (alc880_is_multi_pin(nid)) {
1931 struct alc_spec *spec = codec->spec;
1932 int idx = alc880_multi_pin_idx(nid);
1933 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
1934 AC_VERB_SET_CONNECT_SEL,
1935 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
1936 }
1937}
1938
1939static void alc880_auto_init_multi_out(struct hda_codec *codec)
1940{
1941 struct alc_spec *spec = codec->spec;
1942 int i;
1943
1944 for (i = 0; i < spec->autocfg.line_outs; i++) {
1945 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1946 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
1947 }
1948}
1949
1950static void alc880_auto_init_hp_out(struct hda_codec *codec)
1951{
1952 struct alc_spec *spec = codec->spec;
1953 hda_nid_t pin;
1954
1955 pin = spec->autocfg.hp_pin;
1956 if (pin) /* connect to front */
1957 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
1958}
1959
1960static void alc880_auto_init_analog_input(struct hda_codec *codec)
1961{
1962 struct alc_spec *spec = codec->spec;
1963 int i;
1964
1965 for (i = 0; i < AUTO_PIN_LAST; i++) {
1966 hda_nid_t nid = spec->autocfg.input_pins[i];
1967 if (alc880_is_input_pin(nid)) {
1968 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1969 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
1970 if (nid != ALC880_PIN_CD_NID)
1971 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1972 AMP_OUT_MUTE);
1973 }
1974 }
1975}
1976
1977/* parse the BIOS configuration and set up the alc_spec */
1978/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
1979static int alc880_parse_auto_config(struct hda_codec *codec)
1980{
1981 struct alc_spec *spec = codec->spec;
1982 int err;
1983
1984 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
1985 return err;
1986 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
1987 return err;
1988 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
1989 return 0; /* can't find valid BIOS pin config */
1990 if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1991 (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
1992 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
1993 return err;
1994
1995 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1996
1997 if (spec->autocfg.dig_out_pin)
1998 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
1999 if (spec->autocfg.dig_in_pin)
2000 spec->dig_in_nid = ALC880_DIGIN_NID;
2001
2002 if (spec->kctl_alloc)
2003 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2004
2005 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2006
2007 spec->input_mux = &spec->private_imux;
2008
2009 return 1;
2010}
2011
2012/* init callback for auto-configuration model -- overriding the default init */
2013static int alc880_auto_init(struct hda_codec *codec)
2014{
2015 alc_init(codec);
2016 alc880_auto_init_multi_out(codec);
2017 alc880_auto_init_hp_out(codec);
2018 alc880_auto_init_analog_input(codec);
2019 return 0;
2020}
2021
2022/*
2023 * OK, here we have finally the patch for ALC880
2024 */
2025
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026static int patch_alc880(struct hda_codec *codec)
2027{
2028 struct alc_spec *spec;
2029 int board_config;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030 int i, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002032 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 if (spec == NULL)
2034 return -ENOMEM;
2035
2036 codec->spec = spec;
2037
2038 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002039 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002040 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2041 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042 }
2043
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002044 if (board_config == ALC880_AUTO) {
2045 /* automatic parse from the BIOS config */
2046 err = alc880_parse_auto_config(codec);
2047 if (err < 0) {
2048 alc_free(codec);
2049 return err;
2050 } else if (! err) {
2051 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2052 board_config = ALC880_3ST;
2053 }
2054 }
2055
2056 if (board_config != ALC880_AUTO) {
2057 /* set up from the preset table */
2058 const struct alc_config_preset *preset;
2059
2060 preset = &alc880_presets[board_config];
2061
2062 for (i = 0; preset->mixers[i]; i++) {
2063 snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
2064 spec->mixers[spec->num_mixers++] = preset->mixers[i];
2065 }
2066 for (i = 0; preset->init_verbs[i]; i++) {
2067 snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
2068 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
2069 }
2070
2071 spec->channel_mode = preset->channel_mode;
2072 spec->num_channel_mode = preset->num_channel_mode;
2073
2074 spec->multiout.max_channels = spec->channel_mode[0].channels;
2075
2076 spec->multiout.num_dacs = preset->num_dacs;
2077 spec->multiout.dac_nids = preset->dac_nids;
2078 spec->multiout.dig_out_nid = preset->dig_out_nid;
2079 spec->multiout.hp_nid = preset->hp_nid;
2080
2081 spec->input_mux = preset->input_mux;
2082
2083 spec->num_adc_nids = preset->num_adc_nids;
2084 spec->adc_nids = preset->adc_nids;
2085 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086
2087 spec->stream_name_analog = "ALC880 Analog";
2088 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2089 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2090
2091 spec->stream_name_digital = "ALC880 Digital";
2092 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2093 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2094
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 if (! spec->adc_nids && spec->input_mux) {
2096 /* check whether NID 0x07 is valid */
2097 unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
2098 AC_PAR_AUDIO_WIDGET_CAP);
2099 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2100 if (wcap != AC_WID_AUD_IN) {
2101 spec->adc_nids = alc880_adc_nids_alt;
2102 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2103 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2104 spec->num_mixers++;
2105 } else {
2106 spec->adc_nids = alc880_adc_nids;
2107 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2108 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2109 spec->num_mixers++;
2110 }
2111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112
2113 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114 if (board_config == ALC880_AUTO)
2115 codec->patch_ops.init = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116
2117 return 0;
2118}
2119
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002120
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121/*
2122 * ALC260 support
2123 */
2124
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002125static hda_nid_t alc260_dac_nids[1] = {
2126 /* front */
2127 0x02,
2128};
2129
2130static hda_nid_t alc260_adc_nids[1] = {
2131 /* ADC0 */
2132 0x04,
2133};
2134
2135static hda_nid_t alc260_hp_adc_nids[1] = {
2136 /* ADC1 */
2137 0x05,
2138};
2139
2140#define ALC260_DIGOUT_NID 0x03
2141#define ALC260_DIGIN_NID 0x06
2142
2143static struct hda_input_mux alc260_capture_source = {
2144 .num_items = 4,
2145 .items = {
2146 { "Mic", 0x0 },
2147 { "Front Mic", 0x1 },
2148 { "Line", 0x2 },
2149 { "CD", 0x4 },
2150 },
2151};
2152
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002153/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
2154 * and the internal CD lines.
2155 */
2156static struct hda_input_mux alc260_fujitsu_capture_source = {
2157 .num_items = 2,
2158 .items = {
2159 { "Mic/Line", 0x0 },
2160 { "CD", 0x4 },
2161 },
2162};
2163
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164/*
2165 * This is just place-holder, so there's something for alc_build_pcms to look
2166 * at when it calculates the maximum number of channels. ALC260 has no mixer
2167 * element which allows changing the channel mode, so the verb list is
2168 * never used.
2169 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002170static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 { 2, NULL },
2172};
2173
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174static snd_kcontrol_new_t alc260_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002175 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002176 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2178 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2180 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2182 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2184 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2185 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2186 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002187 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002188 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002189 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002190 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2192 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2193 {
2194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2195 .name = "Capture Source",
2196 .info = alc_mux_enum_info,
2197 .get = alc_mux_enum_get,
2198 .put = alc_mux_enum_put,
2199 },
2200 { } /* end */
2201};
2202
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002203static snd_kcontrol_new_t alc260_hp_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002204 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002205 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002206 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2207 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2209 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2211 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002215 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002216 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002217 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002218 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2219 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2220 {
2221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2222 .name = "Capture Source",
2223 .info = alc_mux_enum_info,
2224 .get = alc_mux_enum_get,
2225 .put = alc_mux_enum_put,
2226 },
2227 { } /* end */
2228};
2229
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002230static snd_kcontrol_new_t alc260_fujitsu_mixer[] = {
2231 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002232 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002233 ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),
2234 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2235 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2237 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2239 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2240 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002241 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002242 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2243 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2244 {
2245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2246 .name = "Capture Source",
2247 .info = alc_mux_enum_info,
2248 .get = alc_mux_enum_get,
2249 .put = alc_mux_enum_put,
2250 },
2251 { } /* end */
2252};
2253
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254static struct hda_verb alc260_init_verbs[] = {
2255 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002260 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002262 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02002264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 /* select line-out */
2266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2267 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02002268 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02002270 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02002272 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2273 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 /* set connection select to line in (default select for this ADC) */
2276 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02002277 /* mute capture amp left and right */
2278 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2279 /* set connection select to line in (default select for this ADC) */
2280 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02002281 /* set vol=0 Line-Out mixer amp left and right */
2282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2283 /* unmute pin widget amp left and right (no gain on this amp) */
2284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2285 /* set vol=0 HP mixer amp left and right */
2286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2287 /* unmute pin widget amp left and right (no gain on this amp) */
2288 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2289 /* set vol=0 Mono mixer amp left and right */
2290 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2291 /* unmute pin widget amp left and right (no gain on this amp) */
2292 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2293 /* unmute LINE-2 out pin */
2294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002296 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02002297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002298 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02002299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002300 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02002301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002303 /* mute Front out path */
2304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2305 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2306 /* mute Headphone out path */
2307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2309 /* mute Mono out path */
2310 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2311 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 { }
2313};
2314
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002315/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2316 * laptops.
2317 */
2318static struct hda_verb alc260_fujitsu_init_verbs[] = {
2319 /* Disable all GPIOs */
2320 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2321 /* Internal speaker is connected to headphone pin */
2322 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2323 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2325 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2326 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2327 /* Ensure all other unused pins are disabled and muted.
2328 * Note: trying to set widget 0x15 to anything blocks all audio
2329 * output for some reason, so just leave that at the default.
2330 */
2331 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2332 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2333 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2334 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2335 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2336 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2337 /* Disable digital (SPDIF) pins */
2338 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2339 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2340
2341 /* Start with mixer outputs muted */
2342 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2345
2346 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2347 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2348 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
2349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2350 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
2351 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2352
2353 /* Mute capture amp left and right */
2354 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2355 /* Set ADC connection select to line in (on mic1 pin) */
2356 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2357
2358 /* Mute all inputs to mixer widget (even unconnected ones) */
2359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2367};
2368
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369static struct hda_pcm_stream alc260_pcm_analog_playback = {
2370 .substreams = 1,
2371 .channels_min = 2,
2372 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373};
2374
2375static struct hda_pcm_stream alc260_pcm_analog_capture = {
2376 .substreams = 1,
2377 .channels_min = 2,
2378 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379};
2380
Takashi Iwai16ded522005-06-10 19:58:24 +02002381static struct hda_board_config alc260_cfg_tbl[] = {
2382 { .modelname = "hp", .config = ALC260_HP },
2383 { .pci_subvendor = 0x103c, .config = ALC260_HP },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002384 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702x },
2385 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702x },
Takashi Iwai16ded522005-06-10 19:58:24 +02002386 {}
2387};
2388
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389static int patch_alc260(struct hda_codec *codec)
2390{
2391 struct alc_spec *spec;
Takashi Iwai16ded522005-06-10 19:58:24 +02002392 int board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002394 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 if (spec == NULL)
2396 return -ENOMEM;
2397
2398 codec->spec = spec;
2399
Takashi Iwai16ded522005-06-10 19:58:24 +02002400 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
2401 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
2402 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
2403 board_config = ALC260_BASIC;
2404 }
2405
2406 switch (board_config) {
2407 case ALC260_HP:
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408 spec->mixers[spec->num_mixers] = alc260_hp_mixer;
Takashi Iwai16ded522005-06-10 19:58:24 +02002409 spec->num_mixers++;
2410 break;
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002411 case ALC260_FUJITSU_S702x:
2412 spec->mixers[spec->num_mixers] = alc260_fujitsu_mixer;
2413 spec->num_mixers++;
2414 break;
Takashi Iwai16ded522005-06-10 19:58:24 +02002415 default:
2416 spec->mixers[spec->num_mixers] = alc260_base_mixer;
2417 spec->num_mixers++;
2418 break;
2419 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002421 if (board_config != ALC260_FUJITSU_S702x) {
2422 spec->init_verbs[0] = alc260_init_verbs;
2423 spec->num_init_verbs = 1;
2424 } else {
2425 spec->init_verbs[0] = alc260_fujitsu_init_verbs;
2426 spec->num_init_verbs = 1;
2427 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 spec->channel_mode = alc260_modes;
2430 spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
2431
2432 spec->stream_name_analog = "ALC260 Analog";
2433 spec->stream_analog_playback = &alc260_pcm_analog_playback;
2434 spec->stream_analog_capture = &alc260_pcm_analog_capture;
2435
2436 spec->multiout.max_channels = spec->channel_mode[0].channels;
2437 spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
2438 spec->multiout.dac_nids = alc260_dac_nids;
2439
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002440 if (board_config != ALC260_FUJITSU_S702x) {
2441 spec->input_mux = &alc260_capture_source;
2442 } else {
2443 spec->input_mux = &alc260_fujitsu_capture_source;
2444 }
Takashi Iwai16ded522005-06-10 19:58:24 +02002445 switch (board_config) {
2446 case ALC260_HP:
Takashi Iwai16ded522005-06-10 19:58:24 +02002447 spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
2448 spec->adc_nids = alc260_hp_adc_nids;
2449 break;
2450 default:
2451 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2452 spec->adc_nids = alc260_adc_nids;
2453 break;
2454 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455
2456 codec->patch_ops = alc_patch_ops;
2457
2458 return 0;
2459}
2460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002461
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462/*
2463 * ALC882 support
2464 *
2465 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
2466 * configuration. Each pin widget can choose any input DACs and a mixer.
2467 * Each ADC is connected from a mixer of all inputs. This makes possible
2468 * 6-channel independent captures.
2469 *
2470 * In addition, an independent DAC for the multi-playback (not used in this
2471 * driver yet).
2472 */
2473
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002474static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 { 8, NULL }
2476};
2477
2478static hda_nid_t alc882_dac_nids[4] = {
2479 /* front, rear, clfe, rear_surr */
2480 0x02, 0x03, 0x04, 0x05
2481};
2482
2483static hda_nid_t alc882_adc_nids[3] = {
2484 /* ADC0-2 */
2485 0x07, 0x08, 0x09,
2486};
2487
2488/* input MUX */
2489/* FIXME: should be a matrix-type input source selection */
2490
2491static struct hda_input_mux alc882_capture_source = {
2492 .num_items = 4,
2493 .items = {
2494 { "Mic", 0x0 },
2495 { "Front Mic", 0x1 },
2496 { "Line", 0x2 },
2497 { "CD", 0x4 },
2498 },
2499};
2500
2501#define alc882_mux_enum_info alc_mux_enum_info
2502#define alc882_mux_enum_get alc_mux_enum_get
2503
2504static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
2505{
2506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2507 struct alc_spec *spec = codec->spec;
2508 const struct hda_input_mux *imux = spec->input_mux;
2509 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2510 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
2511 hda_nid_t nid = capture_mixers[adc_idx];
2512 unsigned int *cur_val = &spec->cur_mux[adc_idx];
2513 unsigned int i, idx;
2514
2515 idx = ucontrol->value.enumerated.item[0];
2516 if (idx >= imux->num_items)
2517 idx = imux->num_items - 1;
2518 if (*cur_val == idx && ! codec->in_resume)
2519 return 0;
2520 for (i = 0; i < imux->num_items; i++) {
2521 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
2522 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2523 v | (imux->items[i].index << 8));
2524 }
2525 *cur_val = idx;
2526 return 1;
2527}
2528
2529/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
2530 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
2531 */
2532static snd_kcontrol_new_t alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002533 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002534 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002535 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002536 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002537 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2538 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002539 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2540 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002541 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002542 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2544 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2545 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2546 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2547 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2550 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2552 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
2553 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
2554 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
2555 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
2556 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
2557 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
2558 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
2559 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
2560 {
2561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2562 /* .name = "Capture Source", */
2563 .name = "Input Source",
2564 .count = 3,
2565 .info = alc882_mux_enum_info,
2566 .get = alc882_mux_enum_get,
2567 .put = alc882_mux_enum_put,
2568 },
2569 { } /* end */
2570};
2571
2572static struct hda_verb alc882_init_verbs[] = {
2573 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02002574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2575 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02002578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02002582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2583 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02002586 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2587 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2588 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002590 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02002591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02002592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002594 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02002595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02002596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02002599 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02002600 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002602 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02002603 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02002604 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002606 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002607 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2609 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002610 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2612 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002613 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2615 /* Line-2 In: Headphone output (output 0 - 0x0c) */
2616 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2617 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2618 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002620 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621
2622 /* FIXME: use matrix-type input source selection */
2623 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
2624 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02002625 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2627 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2632 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2639 /* ADC1: mute amp left and right */
2640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002641 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002642 /* ADC2: mute amp left and right */
2643 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002644 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002645 /* ADC3: mute amp left and right */
2646 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002647 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648
2649 { }
2650};
2651
2652static int patch_alc882(struct hda_codec *codec)
2653{
2654 struct alc_spec *spec;
2655
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002656 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 if (spec == NULL)
2658 return -ENOMEM;
2659
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 codec->spec = spec;
2661
2662 spec->mixers[spec->num_mixers] = alc882_base_mixer;
2663 spec->num_mixers++;
2664
2665 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2666 spec->dig_in_nid = ALC880_DIGIN_NID;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 spec->init_verbs[0] = alc882_init_verbs;
2668 spec->num_init_verbs = 1;
2669
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 spec->channel_mode = alc882_ch_modes;
2671 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
2672
2673 spec->stream_name_analog = "ALC882 Analog";
2674 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2675 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2676
2677 spec->stream_name_digital = "ALC882 Digital";
2678 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2679 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2680
2681 spec->multiout.max_channels = spec->channel_mode[0].channels;
2682 spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
2683 spec->multiout.dac_nids = alc882_dac_nids;
2684
2685 spec->input_mux = &alc882_capture_source;
2686 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
2687 spec->adc_nids = alc882_adc_nids;
2688
2689 codec->patch_ops = alc_patch_ops;
2690
2691 return 0;
2692}
2693
2694/*
2695 * patch entries
2696 */
2697struct hda_codec_preset snd_hda_preset_realtek[] = {
2698 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
2699 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
2700 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
2701 {} /* terminator */
2702};