blob: de145d102d9ffc199866c770c7eb52b438c48629 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
35
36/* ALC880 board config type */
37enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ALC880_3ST,
39 ALC880_3ST_DIG,
40 ALC880_5ST,
41 ALC880_5ST_DIG,
42 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020043 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020044 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020045 ALC880_6ST_DIG,
46 ALC880_F1734,
47 ALC880_ASUS,
48 ALC880_ASUS_DIG,
49 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010050 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020051 ALC880_UNIWILL_DIG,
Kailang Yangdf694da2005-12-05 19:42:22 +010052 ALC880_CLEVO,
53 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010054 ALC880_LG,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020055#ifdef CONFIG_SND_DEBUG
56 ALC880_TEST,
57#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020059 ALC880_MODEL_LAST /* last tag */
60};
61
62/* ALC260 models */
63enum {
64 ALC260_BASIC,
65 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC260_HP_3013,
67 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010068 ALC260_ACER,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010069#ifdef CONFIG_SND_DEBUG
70 ALC260_TEST,
71#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010072 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020073 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070074};
75
Kailang Yangdf694da2005-12-05 19:42:22 +010076/* ALC262 models */
77enum {
78 ALC262_BASIC,
Takashi Iwai834be882006-03-01 14:16:17 +010079 ALC262_FUJITSU,
Kailang Yangdf694da2005-12-05 19:42:22 +010080 ALC262_AUTO,
81 ALC262_MODEL_LAST /* last tag */
82};
83
84/* ALC861 models */
85enum {
86 ALC861_3ST,
87 ALC861_3ST_DIG,
88 ALC861_6ST_DIG,
89 ALC861_AUTO,
90 ALC861_MODEL_LAST,
91};
92
93/* ALC882 models */
94enum {
95 ALC882_3ST_DIG,
96 ALC882_6ST_DIG,
97 ALC882_AUTO,
98 ALC882_MODEL_LAST,
99};
100
101/* for GPIO Poll */
102#define GPIO_MASK 0x03
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104struct alc_spec {
105 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 unsigned int num_mixers;
108
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200110 * don't forget NULL termination!
111 */
112 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Takashi Iwai16ded522005-06-10 19:58:24 +0200114 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 struct hda_pcm_stream *stream_analog_playback;
116 struct hda_pcm_stream *stream_analog_capture;
117
Takashi Iwai16ded522005-06-10 19:58:24 +0200118 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 struct hda_pcm_stream *stream_digital_playback;
120 struct hda_pcm_stream *stream_digital_capture;
121
122 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200123 struct hda_multi_out multiout; /* playback set-up
124 * max_channels, dacs must be set
125 * dig_out_nid and hp_nid are optional
126 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 /* capture */
129 unsigned int num_adc_nids;
130 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200131 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 /* capture source */
134 const struct hda_input_mux *input_mux;
135 unsigned int cur_mux[3];
136
137 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100138 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 int num_channel_mode;
140
141 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100142 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200143
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200144 /* dynamic controls, init_verbs and input_mux */
145 struct auto_pin_cfg autocfg;
146 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100147 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200148 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100149 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100150
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100151 /* hooks */
152 void (*init_hook)(struct hda_codec *codec);
153 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
154
Takashi Iwai834be882006-03-01 14:16:17 +0100155 /* for pin sensing */
156 unsigned int sense_updated: 1;
157 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100158};
159
160/*
161 * configuration template - to be copied to the spec instance
162 */
163struct alc_config_preset {
164 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
165 const struct hda_verb *init_verbs[5];
166 unsigned int num_dacs;
167 hda_nid_t *dac_nids;
168 hda_nid_t dig_out_nid; /* optional */
169 hda_nid_t hp_nid; /* optional */
170 unsigned int num_adc_nids;
171 hda_nid_t *adc_nids;
172 hda_nid_t dig_in_nid;
173 unsigned int num_channel_mode;
174 const struct hda_channel_mode *channel_mode;
175 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100176 void (*unsol_event)(struct hda_codec *, unsigned int);
177 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178};
179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181/*
182 * input MUX handling
183 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100184static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
187 struct alc_spec *spec = codec->spec;
188 return snd_hda_input_mux_info(spec->input_mux, uinfo);
189}
190
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100191static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
193 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
194 struct alc_spec *spec = codec->spec;
195 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
196
197 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
198 return 0;
199}
200
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100201static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202{
203 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
204 struct alc_spec *spec = codec->spec;
205 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
206 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
207 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
208}
209
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211/*
212 * channel mode setting
213 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100214static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215{
216 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
217 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100218 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
219 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220}
221
Kailang Yangdf694da2005-12-05 19:42:22 +0100222static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223{
224 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
225 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100226 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
227 spec->num_channel_mode, spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228}
229
Kailang Yangdf694da2005-12-05 19:42:22 +0100230static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231{
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
233 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100234 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
235 spec->num_channel_mode, &spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236}
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100239 * Control the mode of pin widget settings via the mixer. "pc" is used
240 * instead of "%" to avoid consequences of accidently treating the % as
241 * being part of a format specifier. Maximum allowed length of a value is
242 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100243 *
244 * Note: some retasking pin complexes seem to ignore requests for input
245 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
246 * are requested. Therefore order this list so that this behaviour will not
247 * cause problems when mixer clients move through the enum sequentially.
248 * NIDs 0x0f and 0x10 have been observed to have this behaviour.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200249 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100250static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100251 "Mic 50pc bias", "Mic 80pc bias",
252 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100253};
254static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100255 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100256};
257/* The control can present all 5 options, or it can limit the options based
258 * in the pin being assumed to be exclusively an input or an output pin.
259 */
260#define ALC_PIN_DIR_IN 0x00
261#define ALC_PIN_DIR_OUT 0x01
262#define ALC_PIN_DIR_INOUT 0x02
263
264/* Info about the pin modes supported by the three different pin directions.
265 * For each direction the minimum and maximum values are given.
266 */
267static signed char alc_pin_mode_dir_info[3][2] = {
268 { 0, 2 }, /* ALC_PIN_DIR_IN */
269 { 3, 4 }, /* ALC_PIN_DIR_OUT */
270 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
271};
272#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
273#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
274#define alc_pin_mode_n_items(_dir) \
275 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
276
277static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200278{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100279 unsigned int item_num = uinfo->value.enumerated.item;
280 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
281
282 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200283 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100284 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
285
286 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
287 item_num = alc_pin_mode_min(dir);
288 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200289 return 0;
290}
291
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100292static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200293{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100294 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200295 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
296 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100297 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200298 long *valp = ucontrol->value.integer.value;
299 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200300
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100301 /* Find enumerated value for current pinctl setting */
302 i = alc_pin_mode_min(dir);
303 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
304 i++;
305 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
306 return 0;
307}
308
309static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
310{
311 signed int change;
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 hda_nid_t nid = kcontrol->private_value & 0xffff;
314 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
315 long val = *ucontrol->value.integer.value;
316 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
317
318 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
319 val = alc_pin_mode_min(dir);
320
321 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100322 if (change) {
323 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200324 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100325 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100326
327 /* Also enable the retasking pin's input/output as required
328 * for the requested pin mode. Enum values of 2 or less are
329 * input modes.
330 *
331 * Dynamically switching the input/output buffers probably
332 * reduces noise slightly, particularly on input. However,
333 * havingboth input and output buffers enabled
334 * simultaneously doesn't seem to be problematic.
335 */
336 if (val <= 2) {
337 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
338 AMP_OUT_MUTE);
339 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
340 AMP_IN_UNMUTE(0));
341 } else {
342 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
343 AMP_IN_MUTE(0));
344 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
345 AMP_OUT_UNMUTE);
346 }
347 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200348 return change;
349}
350
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100351#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200352 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100353 .info = alc_pin_mode_info, \
354 .get = alc_pin_mode_get, \
355 .put = alc_pin_mode_put, \
356 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100357
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100358/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
359 * together using a mask with more than one bit set. This control is
360 * currently used only by the ALC260 test model. At this stage they are not
361 * needed for any "production" models.
362 */
363#ifdef CONFIG_SND_DEBUG
364static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
365{
366 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
367 uinfo->count = 1;
368 uinfo->value.integer.min = 0;
369 uinfo->value.integer.max = 1;
370 return 0;
371}
372static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
373{
374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
375 hda_nid_t nid = kcontrol->private_value & 0xffff;
376 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
377 long *valp = ucontrol->value.integer.value;
378 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
379
380 *valp = (val & mask) != 0;
381 return 0;
382}
383static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
384{
385 signed int change;
386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
387 hda_nid_t nid = kcontrol->private_value & 0xffff;
388 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
389 long val = *ucontrol->value.integer.value;
390 unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
391
392 /* Set/unset the masked GPIO bit(s) as needed */
393 change = (val==0?0:mask) != (gpio_data & mask);
394 if (val==0)
395 gpio_data &= ~mask;
396 else
397 gpio_data |= mask;
398 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
399
400 return change;
401}
402#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
403 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
404 .info = alc_gpio_data_info, \
405 .get = alc_gpio_data_get, \
406 .put = alc_gpio_data_put, \
407 .private_value = nid | (mask<<16) }
408#endif /* CONFIG_SND_DEBUG */
409
Jonathan Woithe92621f12006-02-28 11:47:47 +0100410/* A switch control to allow the enabling of the digital IO pins on the
411 * ALC260. This is incredibly simplistic; the intention of this control is
412 * to provide something in the test model allowing digital outputs to be
413 * identified if present. If models are found which can utilise these
414 * outputs a more complete mixer control can be devised for those models if
415 * necessary.
416 */
417#ifdef CONFIG_SND_DEBUG
418static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
419{
420 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
421 uinfo->count = 1;
422 uinfo->value.integer.min = 0;
423 uinfo->value.integer.max = 1;
424 return 0;
425}
426static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
427{
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 hda_nid_t nid = kcontrol->private_value & 0xffff;
430 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
431 long *valp = ucontrol->value.integer.value;
432 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
433
434 *valp = (val & mask) != 0;
435 return 0;
436}
437static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
438{
439 signed int change;
440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
441 hda_nid_t nid = kcontrol->private_value & 0xffff;
442 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
443 long val = *ucontrol->value.integer.value;
444 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
445
446 /* Set/unset the masked control bit(s) as needed */
447 change = (val==0?0:mask) != (ctrl_data & mask);
448 if (val==0)
449 ctrl_data &= ~mask;
450 else
451 ctrl_data |= mask;
452 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
453
454 return change;
455}
456#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
457 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
458 .info = alc_spdif_ctrl_info, \
459 .get = alc_spdif_ctrl_get, \
460 .put = alc_spdif_ctrl_put, \
461 .private_value = nid | (mask<<16) }
462#endif /* CONFIG_SND_DEBUG */
463
Kailang Yangdf694da2005-12-05 19:42:22 +0100464/*
465 * set up from the preset table
466 */
467static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
468{
469 int i;
470
471 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
472 spec->mixers[spec->num_mixers++] = preset->mixers[i];
473 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
474 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
475
476 spec->channel_mode = preset->channel_mode;
477 spec->num_channel_mode = preset->num_channel_mode;
478
479 spec->multiout.max_channels = spec->channel_mode[0].channels;
480
481 spec->multiout.num_dacs = preset->num_dacs;
482 spec->multiout.dac_nids = preset->dac_nids;
483 spec->multiout.dig_out_nid = preset->dig_out_nid;
484 spec->multiout.hp_nid = preset->hp_nid;
485
486 spec->input_mux = preset->input_mux;
487
488 spec->num_adc_nids = preset->num_adc_nids;
489 spec->adc_nids = preset->adc_nids;
490 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100491
492 spec->unsol_event = preset->unsol_event;
493 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100494}
495
Takashi Iwai41e41f12005-06-08 14:48:49 +0200496/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200497 * ALC880 3-stack model
498 *
499 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
500 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
501 * HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 */
503
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200504static hda_nid_t alc880_dac_nids[4] = {
505 /* front, rear, clfe, rear_surr */
506 0x02, 0x05, 0x04, 0x03
507};
508
509static hda_nid_t alc880_adc_nids[3] = {
510 /* ADC0-2 */
511 0x07, 0x08, 0x09,
512};
513
514/* The datasheet says the node 0x07 is connected from inputs,
515 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100516 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200518static hda_nid_t alc880_adc_nids_alt[2] = {
519 /* ADC1-2 */
520 0x08, 0x09,
521};
522
523#define ALC880_DIGOUT_NID 0x06
524#define ALC880_DIGIN_NID 0x0a
525
526static struct hda_input_mux alc880_capture_source = {
527 .num_items = 4,
528 .items = {
529 { "Mic", 0x0 },
530 { "Front Mic", 0x3 },
531 { "Line", 0x2 },
532 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200534};
535
536/* channel source setting (2/6 channel selection for 3-stack) */
537/* 2ch mode */
538static struct hda_verb alc880_threestack_ch2_init[] = {
539 /* set line-in to input, mute it */
540 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
541 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
542 /* set mic-in to input vref 80%, mute it */
543 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
544 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 { } /* end */
546};
547
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200548/* 6ch mode */
549static struct hda_verb alc880_threestack_ch6_init[] = {
550 /* set line-in to output, unmute it */
551 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
552 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
553 /* set mic-in to output, unmute it */
554 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
555 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
556 { } /* end */
557};
558
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100559static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200560 { 2, alc880_threestack_ch2_init },
561 { 6, alc880_threestack_ch6_init },
562};
563
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100564static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100566 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200567 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100568 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200569 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
570 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100571 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
572 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
579 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
580 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
581 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
582 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200584 {
585 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
586 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100587 .info = alc_ch_mode_info,
588 .get = alc_ch_mode_get,
589 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200590 },
591 { } /* end */
592};
593
594/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100595static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200596 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
597 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
598 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
599 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
600 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
601 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
602 {
603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
604 /* The multiple "Capture Source" controls confuse alsamixer
605 * So call somewhat different..
606 * FIXME: the controls appear in the "playback" view!
607 */
608 /* .name = "Capture Source", */
609 .name = "Input Source",
610 .count = 3,
611 .info = alc_mux_enum_info,
612 .get = alc_mux_enum_get,
613 .put = alc_mux_enum_put,
614 },
615 { } /* end */
616};
617
618/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100619static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200620 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
621 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
622 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
623 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 {
625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
626 /* The multiple "Capture Source" controls confuse alsamixer
627 * So call somewhat different..
628 * FIXME: the controls appear in the "playback" view!
629 */
630 /* .name = "Capture Source", */
631 .name = "Input Source",
632 .count = 2,
633 .info = alc_mux_enum_info,
634 .get = alc_mux_enum_get,
635 .put = alc_mux_enum_put,
636 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 { } /* end */
638};
639
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200640
641
642/*
643 * ALC880 5-stack model
644 *
645 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
646 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
647 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
648 */
649
650/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100651static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200652 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100653 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 { } /* end */
655};
656
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200657/* channel source setting (6/8 channel selection for 5-stack) */
658/* 6ch mode */
659static struct hda_verb alc880_fivestack_ch6_init[] = {
660 /* set line-in to input, mute it */
661 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
662 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200663 { } /* end */
664};
665
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200666/* 8ch mode */
667static struct hda_verb alc880_fivestack_ch8_init[] = {
668 /* set line-in to output, unmute it */
669 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
670 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
671 { } /* end */
672};
673
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100674static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200675 { 6, alc880_fivestack_ch6_init },
676 { 8, alc880_fivestack_ch8_init },
677};
678
679
680/*
681 * ALC880 6-stack model
682 *
683 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
684 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
685 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
686 */
687
688static hda_nid_t alc880_6st_dac_nids[4] = {
689 /* front, rear, clfe, rear_surr */
690 0x02, 0x03, 0x04, 0x05
691};
692
693static struct hda_input_mux alc880_6stack_capture_source = {
694 .num_items = 4,
695 .items = {
696 { "Mic", 0x0 },
697 { "Front Mic", 0x1 },
698 { "Line", 0x2 },
699 { "CD", 0x4 },
700 },
701};
702
703/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100704static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200705 { 8, NULL },
706};
707
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100708static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200709 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100710 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200711 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100712 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200713 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
714 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100715 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
716 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200717 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100718 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200719 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
720 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
725 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
727 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
728 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200729 {
730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
731 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100732 .info = alc_ch_mode_info,
733 .get = alc_ch_mode_get,
734 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200735 },
736 { } /* end */
737};
738
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200739
740/*
741 * ALC880 W810 model
742 *
743 * W810 has rear IO for:
744 * Front (DAC 02)
745 * Surround (DAC 03)
746 * Center/LFE (DAC 04)
747 * Digital out (06)
748 *
749 * The system also has a pair of internal speakers, and a headphone jack.
750 * These are both connected to Line2 on the codec, hence to DAC 02.
751 *
752 * There is a variable resistor to control the speaker or headphone
753 * volume. This is a hardware-only device without a software API.
754 *
755 * Plugging headphones in will disable the internal speakers. This is
756 * implemented in hardware, not via the driver using jack sense. In
757 * a similar fashion, plugging into the rear socket marked "front" will
758 * disable both the speakers and headphones.
759 *
760 * For input, there's a microphone jack, and an "audio in" jack.
761 * These may not do anything useful with this driver yet, because I
762 * haven't setup any initialization verbs for these yet...
763 */
764
765static hda_nid_t alc880_w810_dac_nids[3] = {
766 /* front, rear/surround, clfe */
767 0x02, 0x03, 0x04
768};
769
770/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100771static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200772 { 6, NULL }
773};
774
775/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100776static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200777 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100778 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200779 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100780 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200781 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
782 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100783 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
784 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
786 { } /* end */
787};
788
789
790/*
791 * Z710V model
792 *
793 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
794 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
795 */
796
797static hda_nid_t alc880_z71v_dac_nids[1] = {
798 0x02
799};
800#define ALC880_Z71V_HP_DAC 0x03
801
802/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100803static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200804 { 2, NULL }
805};
806
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100807static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200808 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100809 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200810 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100811 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200812 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
813 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
816 { } /* end */
817};
818
819
820/* FIXME! */
821/*
822 * ALC880 F1734 model
823 *
824 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
825 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
826 */
827
828static hda_nid_t alc880_f1734_dac_nids[1] = {
829 0x03
830};
831#define ALC880_F1734_HP_DAC 0x02
832
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100833static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200834 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100835 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200836 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100837 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200838 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
839 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200842 { } /* end */
843};
844
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200845
846/* FIXME! */
847/*
848 * ALC880 ASUS model
849 *
850 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
851 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
852 * Mic = 0x18, Line = 0x1a
853 */
854
855#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
856#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
857
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100858static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100862 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200873 {
874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
875 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100876 .info = alc_ch_mode_info,
877 .get = alc_ch_mode_get,
878 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200879 },
880 { } /* end */
881};
882
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200883/* FIXME! */
884/*
885 * ALC880 ASUS W1V model
886 *
887 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
888 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
889 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
890 */
891
892/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100893static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200894 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
895 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200896 { } /* end */
897};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200898
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200899/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100900static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200901 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
902 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
903 { } /* end */
904};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200905
Kailang Yangdf694da2005-12-05 19:42:22 +0100906/* TCL S700 */
907static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
909 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
910 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
911 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
912 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
915 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
916 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
917 {
918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
919 /* The multiple "Capture Source" controls confuse alsamixer
920 * So call somewhat different..
921 * FIXME: the controls appear in the "playback" view!
922 */
923 /* .name = "Capture Source", */
924 .name = "Input Source",
925 .count = 1,
926 .info = alc_mux_enum_info,
927 .get = alc_mux_enum_get,
928 .put = alc_mux_enum_put,
929 },
930 { } /* end */
931};
932
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200934 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 */
936static int alc_build_controls(struct hda_codec *codec)
937{
938 struct alc_spec *spec = codec->spec;
939 int err;
940 int i;
941
942 for (i = 0; i < spec->num_mixers; i++) {
943 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
944 if (err < 0)
945 return err;
946 }
947
948 if (spec->multiout.dig_out_nid) {
949 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
950 if (err < 0)
951 return err;
952 }
953 if (spec->dig_in_nid) {
954 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
955 if (err < 0)
956 return err;
957 }
958 return 0;
959}
960
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200961
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962/*
963 * initialize the codec volumes, etc
964 */
965
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200966/*
967 * generic initialization of ADC, input mixers and output mixers
968 */
969static struct hda_verb alc880_volume_init_verbs[] = {
970 /*
971 * Unmute ADC0-2 and set the default input to mic-in
972 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200973 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200975 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200976 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200977 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200980 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
981 * mixer widget
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982 * Note: PASD motherboards uses the Line In 2 as the input for front panel
983 * mic (mic 2)
984 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200985 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +0200986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200992 /*
993 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200995 /* set vol=0 to output mixers */
996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
997 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1000 /* set up input amps for analog loopback */
1001 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001004 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1005 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001006 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001008 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010
1011 { }
1012};
1013
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001014/*
1015 * 3-stack pin configuration:
1016 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1017 */
1018static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1019 /*
1020 * preset connection lists of input pins
1021 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1022 */
1023 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1024 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1025 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1026
1027 /*
1028 * Set pin mode and muting
1029 */
1030 /* set front pin widgets 0x14 for output */
1031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1033 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1034 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1036 /* Mic2 (as headphone out) for HP output */
1037 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1038 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1039 /* Line In pin widget for input */
1040 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1041 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1042 /* Line2 (as front mic) pin widget for input and vref at 80% */
1043 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1044 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1045 /* CD pin widget for input */
1046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1047
1048 { }
1049};
1050
1051/*
1052 * 5-stack pin configuration:
1053 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1054 * line-in/side = 0x1a, f-mic = 0x1b
1055 */
1056static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1057 /*
1058 * preset connection lists of input pins
1059 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1060 */
1061 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1062 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1063
1064 /*
1065 * Set pin mode and muting
1066 */
1067 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1070 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072 /* unmute pins for output (no gain on this amp) */
1073 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1076 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1077
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001079 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001080 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1081 /* Mic2 (as headphone out) for HP output */
1082 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001083 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001084 /* Line In pin widget for input */
1085 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1087 /* Line2 (as front mic) pin widget for input and vref at 80% */
1088 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1089 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1090 /* CD pin widget for input */
1091 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092
1093 { }
1094};
1095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001096/*
1097 * W810 pin configuration:
1098 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1099 */
1100static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 /* hphone/speaker input selector: front DAC */
1102 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1103
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1106 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1107 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1108 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1109 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1110
1111 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001112 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 { }
1115};
1116
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001117/*
1118 * Z71V pin configuration:
1119 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1120 */
1121static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001123 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001126
Takashi Iwai16ded522005-06-10 19:58:24 +02001127 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001131
1132 { }
1133};
1134
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001135/*
1136 * 6-stack pin configuration:
1137 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
1138 * line = 0x1a, HP = 0x1b
1139 */
1140static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1141 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1142
Takashi Iwai16ded522005-06-10 19:58:24 +02001143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001144 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001146 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001147 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001149 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001150 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1151
Takashi Iwai16ded522005-06-10 19:58:24 +02001152 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001153 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001154 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001156 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001158 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001160 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1161
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001162 { }
1163};
Takashi Iwai16ded522005-06-10 19:58:24 +02001164
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001165/* FIXME! */
1166/*
1167 * F1734 pin configuration:
1168 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1169 */
1170static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1171 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1172 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1173 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1174 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1175
1176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1177 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1180
1181 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1182 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1183 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1185 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1186 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1187 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1188 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1189 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001190
1191 { }
1192};
1193
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001194/* FIXME! */
1195/*
1196 * ASUS pin configuration:
1197 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1198 */
1199static struct hda_verb alc880_pin_asus_init_verbs[] = {
1200 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1201 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1202 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1203 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1204
1205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1209 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1211 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1213
1214 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1223
1224 { }
1225};
1226
1227/* Enable GPIO mask and set output */
1228static struct hda_verb alc880_gpio1_init_verbs[] = {
1229 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1230 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1231 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001232
1233 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001234};
1235
1236/* Enable GPIO mask and set output */
1237static struct hda_verb alc880_gpio2_init_verbs[] = {
1238 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1239 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1240 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001241
1242 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243};
1244
Kailang Yangdf694da2005-12-05 19:42:22 +01001245/* Clevo m520g init */
1246static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1247 /* headphone output */
1248 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1249 /* line-out */
1250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1252 /* Line-in */
1253 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1254 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1255 /* CD */
1256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1257 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1258 /* Mic1 (rear panel) */
1259 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1260 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1261 /* Mic2 (front panel) */
1262 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1263 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1264 /* headphone */
1265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1267 /* change to EAPD mode */
1268 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1269 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1270
1271 { }
1272};
1273
1274static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1275 /* Headphone output */
1276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1277 /* Front output*/
1278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1280
1281 /* Line In pin widget for input */
1282 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1283 /* CD pin widget for input */
1284 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1285 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1287
1288 /* change to EAPD mode */
1289 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1290 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1291
1292 { }
1293};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294
1295/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001296 * LG m1 express dual
1297 *
1298 * Pin assignment:
1299 * Rear Line-In/Out (blue): 0x14
1300 * Build-in Mic-In: 0x15
1301 * Speaker-out: 0x17
1302 * HP-Out (green): 0x1b
1303 * Mic-In/Out (red): 0x19
1304 * SPDIF-Out: 0x1e
1305 */
1306
1307/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1308static hda_nid_t alc880_lg_dac_nids[3] = {
1309 0x05, 0x02, 0x03
1310};
1311
1312/* seems analog CD is not working */
1313static struct hda_input_mux alc880_lg_capture_source = {
1314 .num_items = 3,
1315 .items = {
1316 { "Mic", 0x1 },
1317 { "Line", 0x5 },
1318 { "Internal Mic", 0x6 },
1319 },
1320};
1321
1322/* 2,4,6 channel modes */
1323static struct hda_verb alc880_lg_ch2_init[] = {
1324 /* set line-in and mic-in to input */
1325 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1326 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1327 { }
1328};
1329
1330static struct hda_verb alc880_lg_ch4_init[] = {
1331 /* set line-in to out and mic-in to input */
1332 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1333 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1334 { }
1335};
1336
1337static struct hda_verb alc880_lg_ch6_init[] = {
1338 /* set line-in and mic-in to output */
1339 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1340 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1341 { }
1342};
1343
1344static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1345 { 2, alc880_lg_ch2_init },
1346 { 4, alc880_lg_ch4_init },
1347 { 6, alc880_lg_ch6_init },
1348};
1349
1350static struct snd_kcontrol_new alc880_lg_mixer[] = {
1351 /* FIXME: it's not really "master" but front channels */
1352 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1353 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1354 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1355 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1356 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1357 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1358 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1359 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1362 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1363 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1364 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1365 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1366 {
1367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1368 .name = "Channel Mode",
1369 .info = alc_ch_mode_info,
1370 .get = alc_ch_mode_get,
1371 .put = alc_ch_mode_put,
1372 },
1373 { } /* end */
1374};
1375
1376static struct hda_verb alc880_lg_init_verbs[] = {
1377 /* set capture source to mic-in */
1378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1381 /* mute all amp mixer inputs */
1382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1385 /* line-in to input */
1386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1388 /* built-in mic */
1389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1391 /* speaker-out */
1392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 /* mic-in to input */
1395 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1396 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398 /* HP-out */
1399 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1401 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1402 /* jack sense */
1403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1404 { }
1405};
1406
1407/* toggle speaker-output according to the hp-jack state */
1408static void alc880_lg_automute(struct hda_codec *codec)
1409{
1410 unsigned int present;
1411
1412 present = snd_hda_codec_read(codec, 0x1b, 0,
1413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1414 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1415 0x80, present ? 0x80 : 0);
1416 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1417 0x80, present ? 0x80 : 0);
1418}
1419
1420static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1421{
1422 /* Looks like the unsol event is incompatible with the standard
1423 * definition. 4bit tag is placed at 28 bit!
1424 */
1425 if ((res >> 28) == 0x01)
1426 alc880_lg_automute(codec);
1427}
1428
1429/*
1430 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001431 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001432
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433static int alc_init(struct hda_codec *codec)
1434{
1435 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001436 unsigned int i;
1437
1438 for (i = 0; i < spec->num_init_verbs; i++)
1439 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001440
1441 if (spec->init_hook)
1442 spec->init_hook(codec);
1443
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 return 0;
1445}
1446
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001447static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1448{
1449 struct alc_spec *spec = codec->spec;
1450
1451 if (spec->unsol_event)
1452 spec->unsol_event(codec, res);
1453}
1454
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455#ifdef CONFIG_PM
1456/*
1457 * resume
1458 */
1459static int alc_resume(struct hda_codec *codec)
1460{
1461 struct alc_spec *spec = codec->spec;
1462 int i;
1463
1464 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 if (spec->multiout.dig_out_nid)
1468 snd_hda_resume_spdif_out(codec);
1469 if (spec->dig_in_nid)
1470 snd_hda_resume_spdif_in(codec);
1471
1472 return 0;
1473}
1474#endif
1475
1476/*
1477 * Analog playback callbacks
1478 */
1479static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1480 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001481 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482{
1483 struct alc_spec *spec = codec->spec;
1484 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1485}
1486
1487static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1488 struct hda_codec *codec,
1489 unsigned int stream_tag,
1490 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001491 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492{
1493 struct alc_spec *spec = codec->spec;
1494 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1495 format, substream);
1496}
1497
1498static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1499 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001500 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501{
1502 struct alc_spec *spec = codec->spec;
1503 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1504}
1505
1506/*
1507 * Digital out
1508 */
1509static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1510 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001511 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512{
1513 struct alc_spec *spec = codec->spec;
1514 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1515}
1516
1517static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1518 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001519 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520{
1521 struct alc_spec *spec = codec->spec;
1522 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1523}
1524
1525/*
1526 * Analog capture
1527 */
1528static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1529 struct hda_codec *codec,
1530 unsigned int stream_tag,
1531 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001532 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533{
1534 struct alc_spec *spec = codec->spec;
1535
1536 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1537 stream_tag, 0, format);
1538 return 0;
1539}
1540
1541static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1542 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001543 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544{
1545 struct alc_spec *spec = codec->spec;
1546
1547 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1548 return 0;
1549}
1550
1551
1552/*
1553 */
1554static struct hda_pcm_stream alc880_pcm_analog_playback = {
1555 .substreams = 1,
1556 .channels_min = 2,
1557 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001558 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .ops = {
1560 .open = alc880_playback_pcm_open,
1561 .prepare = alc880_playback_pcm_prepare,
1562 .cleanup = alc880_playback_pcm_cleanup
1563 },
1564};
1565
1566static struct hda_pcm_stream alc880_pcm_analog_capture = {
1567 .substreams = 2,
1568 .channels_min = 2,
1569 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001570 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571 .ops = {
1572 .prepare = alc880_capture_pcm_prepare,
1573 .cleanup = alc880_capture_pcm_cleanup
1574 },
1575};
1576
1577static struct hda_pcm_stream alc880_pcm_digital_playback = {
1578 .substreams = 1,
1579 .channels_min = 2,
1580 .channels_max = 2,
1581 /* NID is set in alc_build_pcms */
1582 .ops = {
1583 .open = alc880_dig_playback_pcm_open,
1584 .close = alc880_dig_playback_pcm_close
1585 },
1586};
1587
1588static struct hda_pcm_stream alc880_pcm_digital_capture = {
1589 .substreams = 1,
1590 .channels_min = 2,
1591 .channels_max = 2,
1592 /* NID is set in alc_build_pcms */
1593};
1594
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001595/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1596static struct hda_pcm_stream alc_pcm_null_playback = {
1597 .substreams = 0,
1598 .channels_min = 0,
1599 .channels_max = 0,
1600};
1601
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602static int alc_build_pcms(struct hda_codec *codec)
1603{
1604 struct alc_spec *spec = codec->spec;
1605 struct hda_pcm *info = spec->pcm_rec;
1606 int i;
1607
1608 codec->num_pcms = 1;
1609 codec->pcm_info = info;
1610
1611 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001612 if (spec->stream_analog_playback) {
1613 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1614 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1615 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1616 }
1617 if (spec->stream_analog_capture) {
1618 snd_assert(spec->adc_nids, return -EINVAL);
1619 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1620 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1621 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622
Takashi Iwai4a471b72005-12-07 13:56:29 +01001623 if (spec->channel_mode) {
1624 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1625 for (i = 0; i < spec->num_channel_mode; i++) {
1626 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1627 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1628 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629 }
1630 }
1631
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001632 /* If the use of more than one ADC is requested for the current
1633 * model, configure a second analog capture-only PCM.
1634 */
1635 if (spec->num_adc_nids > 1) {
1636 codec->num_pcms++;
1637 info++;
1638 info->name = spec->stream_name_analog;
1639 /* No playback stream for second PCM */
1640 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1641 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1642 if (spec->stream_analog_capture) {
1643 snd_assert(spec->adc_nids, return -EINVAL);
1644 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1645 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1646 }
1647 }
1648
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1650 codec->num_pcms++;
1651 info++;
1652 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001653 if (spec->multiout.dig_out_nid &&
1654 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1656 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1657 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001658 if (spec->dig_in_nid &&
1659 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1661 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1662 }
1663 }
1664
1665 return 0;
1666}
1667
1668static void alc_free(struct hda_codec *codec)
1669{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001670 struct alc_spec *spec = codec->spec;
1671 unsigned int i;
1672
1673 if (! spec)
1674 return;
1675
1676 if (spec->kctl_alloc) {
1677 for (i = 0; i < spec->num_kctl_used; i++)
1678 kfree(spec->kctl_alloc[i].name);
1679 kfree(spec->kctl_alloc);
1680 }
1681 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682}
1683
1684/*
1685 */
1686static struct hda_codec_ops alc_patch_ops = {
1687 .build_controls = alc_build_controls,
1688 .build_pcms = alc_build_pcms,
1689 .init = alc_init,
1690 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001691 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692#ifdef CONFIG_PM
1693 .resume = alc_resume,
1694#endif
1695};
1696
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001697
1698/*
1699 * Test configuration for debugging
1700 *
1701 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1702 * enum controls.
1703 */
1704#ifdef CONFIG_SND_DEBUG
1705static hda_nid_t alc880_test_dac_nids[4] = {
1706 0x02, 0x03, 0x04, 0x05
1707};
1708
1709static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001710 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001711 .items = {
1712 { "In-1", 0x0 },
1713 { "In-2", 0x1 },
1714 { "In-3", 0x2 },
1715 { "In-4", 0x3 },
1716 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001717 { "Front", 0x5 },
1718 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001719 },
1720};
1721
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001722static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001723 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001724 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001725 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001726 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001727};
1728
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001729static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001730{
1731 static char *texts[] = {
1732 "N/A", "Line Out", "HP Out",
1733 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1734 };
1735 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1736 uinfo->count = 1;
1737 uinfo->value.enumerated.items = 8;
1738 if (uinfo->value.enumerated.item >= 8)
1739 uinfo->value.enumerated.item = 7;
1740 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1741 return 0;
1742}
1743
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001744static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001745{
1746 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1747 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1748 unsigned int pin_ctl, item = 0;
1749
1750 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1751 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1752 if (pin_ctl & AC_PINCTL_OUT_EN) {
1753 if (pin_ctl & AC_PINCTL_HP_EN)
1754 item = 2;
1755 else
1756 item = 1;
1757 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1758 switch (pin_ctl & AC_PINCTL_VREFEN) {
1759 case AC_PINCTL_VREF_HIZ: item = 3; break;
1760 case AC_PINCTL_VREF_50: item = 4; break;
1761 case AC_PINCTL_VREF_GRD: item = 5; break;
1762 case AC_PINCTL_VREF_80: item = 6; break;
1763 case AC_PINCTL_VREF_100: item = 7; break;
1764 }
1765 }
1766 ucontrol->value.enumerated.item[0] = item;
1767 return 0;
1768}
1769
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001770static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001771{
1772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1773 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1774 static unsigned int ctls[] = {
1775 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1776 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1777 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1778 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1779 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1780 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1781 };
1782 unsigned int old_ctl, new_ctl;
1783
1784 old_ctl = snd_hda_codec_read(codec, nid, 0,
1785 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1786 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1787 if (old_ctl != new_ctl) {
1788 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1789 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1790 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1791 return 1;
1792 }
1793 return 0;
1794}
1795
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001796static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001797{
1798 static char *texts[] = {
1799 "Front", "Surround", "CLFE", "Side"
1800 };
1801 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1802 uinfo->count = 1;
1803 uinfo->value.enumerated.items = 4;
1804 if (uinfo->value.enumerated.item >= 4)
1805 uinfo->value.enumerated.item = 3;
1806 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1807 return 0;
1808}
1809
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001810static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001811{
1812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1813 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1814 unsigned int sel;
1815
1816 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1817 ucontrol->value.enumerated.item[0] = sel & 3;
1818 return 0;
1819}
1820
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001821static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001822{
1823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1824 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1825 unsigned int sel;
1826
1827 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1828 if (ucontrol->value.enumerated.item[0] != sel) {
1829 sel = ucontrol->value.enumerated.item[0] & 3;
1830 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1831 return 1;
1832 }
1833 return 0;
1834}
1835
1836#define PIN_CTL_TEST(xname,nid) { \
1837 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1838 .name = xname, \
1839 .info = alc_test_pin_ctl_info, \
1840 .get = alc_test_pin_ctl_get, \
1841 .put = alc_test_pin_ctl_put, \
1842 .private_value = nid \
1843 }
1844
1845#define PIN_SRC_TEST(xname,nid) { \
1846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1847 .name = xname, \
1848 .info = alc_test_pin_src_info, \
1849 .get = alc_test_pin_src_get, \
1850 .put = alc_test_pin_src_put, \
1851 .private_value = nid \
1852 }
1853
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001854static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001855 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1856 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1857 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1858 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001859 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1860 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1861 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1862 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001863 PIN_CTL_TEST("Front Pin Mode", 0x14),
1864 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1865 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1866 PIN_CTL_TEST("Side Pin Mode", 0x17),
1867 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1868 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1869 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1870 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1871 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1872 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1873 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1874 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1875 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1877 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1878 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1879 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1880 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1881 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1882 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001885 {
1886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1887 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001888 .info = alc_ch_mode_info,
1889 .get = alc_ch_mode_get,
1890 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001891 },
1892 { } /* end */
1893};
1894
1895static struct hda_verb alc880_test_init_verbs[] = {
1896 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1901 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001905 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1909 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001910 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1914 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001915 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1919 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001920 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02001921 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1922 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02001923 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1924 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001926 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02001927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001931 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02001932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001933 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001935 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001937 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02001938 /* Analog input/passthru */
1939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001944 { }
1945};
1946#endif
1947
Linus Torvalds1da177e2005-04-16 15:20:36 -07001948/*
1949 */
1950
1951static struct hda_board_config alc880_cfg_tbl[] = {
1952 /* Back 3 jack, front 2 jack */
1953 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02001954 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1955 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1956 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1957 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1958 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1959 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1960 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1961 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1962 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1963 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1964 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1965 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1966 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1967 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1968 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1969 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1970 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1971 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1972 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1973 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1974 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1975 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1976 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1977 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1978 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1979 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1980 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1981 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1982 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1983 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1984 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1985 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01001986 /* TCL S700 */
1987 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988
1989 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02001990 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02001991 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02001992 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993
1994 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1995 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02001996 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe32005-08-15 20:01:40 +02001997 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01001998 /* Clevo m520G NB */
1999 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000
2001 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002002 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2003 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2004 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005
2006 /* Back 5 jack, front 2 jack */
2007 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002008 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2009 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2010 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2011 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002012 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013
2014 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2015 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002016 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2017 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2018 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2019 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2020 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2021 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2022 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2023 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002024 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002025 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2026 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002027 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002028 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002029 /* note subvendor = 0 below */
2030 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031
2032 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002033 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002035 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002036 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002037
Takashi Iwaib6482d42005-06-27 15:32:43 +02002038 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002039 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002040 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002041 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002042 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002043
2044 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002045 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2046 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2047 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2048 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002049 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2050 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2051 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2052 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002053 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002054 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002055
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002056 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002057 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2058 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2059 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2060 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002061 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002062 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2063 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2064 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2065 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2066 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2067 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Kailang Yangdf694da2005-12-05 19:42:22 +01002068 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002069
2070 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2071 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2072
2073 { .modelname = "F1734", .config = ALC880_F1734 },
2074 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002075 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002076
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002077 { .modelname = "lg", .config = ALC880_LG },
2078 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2079
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002080#ifdef CONFIG_SND_DEBUG
2081 { .modelname = "test", .config = ALC880_TEST },
2082#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002083 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002084
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 {}
2086};
2087
Takashi Iwai16ded522005-06-10 19:58:24 +02002088/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002089 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002090 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002091static struct alc_config_preset alc880_presets[] = {
2092 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002093 .mixers = { alc880_three_stack_mixer },
2094 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002095 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002097 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2098 .channel_mode = alc880_threestack_modes,
2099 .input_mux = &alc880_capture_source,
2100 },
2101 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102 .mixers = { alc880_three_stack_mixer },
2103 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002104 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002105 .dac_nids = alc880_dac_nids,
2106 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002107 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2108 .channel_mode = alc880_threestack_modes,
2109 .input_mux = &alc880_capture_source,
2110 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002111 [ALC880_TCL_S700] = {
2112 .mixers = { alc880_tcl_s700_mixer },
2113 .init_verbs = { alc880_volume_init_verbs,
2114 alc880_pin_tcl_S700_init_verbs,
2115 alc880_gpio2_init_verbs },
2116 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2117 .dac_nids = alc880_dac_nids,
2118 .hp_nid = 0x03,
2119 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2120 .channel_mode = alc880_2_jack_modes,
2121 .input_mux = &alc880_capture_source,
2122 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002123 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2125 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002126 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2127 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002128 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2129 .channel_mode = alc880_fivestack_modes,
2130 .input_mux = &alc880_capture_source,
2131 },
2132 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002133 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2134 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002135 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2136 .dac_nids = alc880_dac_nids,
2137 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002138 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2139 .channel_mode = alc880_fivestack_modes,
2140 .input_mux = &alc880_capture_source,
2141 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002142 [ALC880_6ST] = {
2143 .mixers = { alc880_six_stack_mixer },
2144 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2145 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2146 .dac_nids = alc880_6st_dac_nids,
2147 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2148 .channel_mode = alc880_sixstack_modes,
2149 .input_mux = &alc880_6stack_capture_source,
2150 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002152 .mixers = { alc880_six_stack_mixer },
2153 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002154 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2155 .dac_nids = alc880_6st_dac_nids,
2156 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002157 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2158 .channel_mode = alc880_sixstack_modes,
2159 .input_mux = &alc880_6stack_capture_source,
2160 },
2161 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002162 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002163 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2164 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002165 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2166 .dac_nids = alc880_w810_dac_nids,
2167 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002168 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2169 .channel_mode = alc880_w810_modes,
2170 .input_mux = &alc880_capture_source,
2171 },
2172 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002174 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002175 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2176 .dac_nids = alc880_z71v_dac_nids,
2177 .dig_out_nid = ALC880_DIGOUT_NID,
2178 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2180 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002181 .input_mux = &alc880_capture_source,
2182 },
2183 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002184 .mixers = { alc880_f1734_mixer },
2185 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2186 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2187 .dac_nids = alc880_f1734_dac_nids,
2188 .hp_nid = 0x02,
2189 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2190 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002191 .input_mux = &alc880_capture_source,
2192 },
2193 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 .mixers = { alc880_asus_mixer },
2195 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2196 alc880_gpio1_init_verbs },
2197 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2198 .dac_nids = alc880_asus_dac_nids,
2199 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2200 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002201 .input_mux = &alc880_capture_source,
2202 },
2203 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204 .mixers = { alc880_asus_mixer },
2205 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2206 alc880_gpio1_init_verbs },
2207 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2208 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002209 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2211 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002212 .input_mux = &alc880_capture_source,
2213 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002214 [ALC880_ASUS_DIG2] = {
2215 .mixers = { alc880_asus_mixer },
2216 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2217 alc880_gpio2_init_verbs }, /* use GPIO2 */
2218 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2219 .dac_nids = alc880_asus_dac_nids,
2220 .dig_out_nid = ALC880_DIGOUT_NID,
2221 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2222 .channel_mode = alc880_asus_modes,
2223 .input_mux = &alc880_capture_source,
2224 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002225 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2227 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2228 alc880_gpio1_init_verbs },
2229 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2230 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002231 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2233 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002234 .input_mux = &alc880_capture_source,
2235 },
2236 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002237 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002238 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2239 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2240 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002241 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2243 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002244 .input_mux = &alc880_capture_source,
2245 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002246 [ALC880_CLEVO] = {
2247 .mixers = { alc880_three_stack_mixer },
2248 .init_verbs = { alc880_volume_init_verbs,
2249 alc880_pin_clevo_init_verbs },
2250 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2251 .dac_nids = alc880_dac_nids,
2252 .hp_nid = 0x03,
2253 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2254 .channel_mode = alc880_threestack_modes,
2255 .input_mux = &alc880_capture_source,
2256 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002257 [ALC880_LG] = {
2258 .mixers = { alc880_lg_mixer },
2259 .init_verbs = { alc880_volume_init_verbs,
2260 alc880_lg_init_verbs },
2261 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2262 .dac_nids = alc880_lg_dac_nids,
2263 .dig_out_nid = ALC880_DIGOUT_NID,
2264 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2265 .channel_mode = alc880_lg_ch_modes,
2266 .input_mux = &alc880_lg_capture_source,
2267 .unsol_event = alc880_lg_unsol_event,
2268 .init_hook = alc880_lg_automute,
2269 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002270#ifdef CONFIG_SND_DEBUG
2271 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002272 .mixers = { alc880_test_mixer },
2273 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2275 .dac_nids = alc880_test_dac_nids,
2276 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002277 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2278 .channel_mode = alc880_test_modes,
2279 .input_mux = &alc880_test_capture_source,
2280 },
2281#endif
2282};
2283
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284/*
2285 * Automatic parse of I/O pins from the BIOS configuration
2286 */
2287
2288#define NUM_CONTROL_ALLOC 32
2289#define NUM_VERB_ALLOC 32
2290
2291enum {
2292 ALC_CTL_WIDGET_VOL,
2293 ALC_CTL_WIDGET_MUTE,
2294 ALC_CTL_BIND_MUTE,
2295};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002296static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2298 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002299 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300};
2301
2302/* add dynamic controls */
2303static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2304{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002305 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002306
2307 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2308 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2309
2310 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2311 if (! knew)
2312 return -ENOMEM;
2313 if (spec->kctl_alloc) {
2314 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2315 kfree(spec->kctl_alloc);
2316 }
2317 spec->kctl_alloc = knew;
2318 spec->num_kctl_alloc = num;
2319 }
2320
2321 knew = &spec->kctl_alloc[spec->num_kctl_used];
2322 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002323 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324 if (! knew->name)
2325 return -ENOMEM;
2326 knew->private_value = val;
2327 spec->num_kctl_used++;
2328 return 0;
2329}
2330
2331#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2332#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2333#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2334#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2335#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2336#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2337#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2338#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2339#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2340#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2341#define ALC880_PIN_CD_NID 0x1c
2342
2343/* fill in the dac_nids table from the parsed pin configuration */
2344static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2345{
2346 hda_nid_t nid;
2347 int assigned[4];
2348 int i, j;
2349
2350 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002351 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352
2353 /* check the pins hardwired to audio widget */
2354 for (i = 0; i < cfg->line_outs; i++) {
2355 nid = cfg->line_out_pins[i];
2356 if (alc880_is_fixed_pin(nid)) {
2357 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002358 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359 assigned[idx] = 1;
2360 }
2361 }
2362 /* left pins can be connect to any audio widget */
2363 for (i = 0; i < cfg->line_outs; i++) {
2364 nid = cfg->line_out_pins[i];
2365 if (alc880_is_fixed_pin(nid))
2366 continue;
2367 /* search for an empty channel */
2368 for (j = 0; j < cfg->line_outs; j++) {
2369 if (! assigned[j]) {
2370 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2371 assigned[j] = 1;
2372 break;
2373 }
2374 }
2375 }
2376 spec->multiout.num_dacs = cfg->line_outs;
2377 return 0;
2378}
2379
2380/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002381static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2382 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002383{
2384 char name[32];
2385 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2386 hda_nid_t nid;
2387 int i, err;
2388
2389 for (i = 0; i < cfg->line_outs; i++) {
2390 if (! spec->multiout.dac_nids[i])
2391 continue;
2392 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2393 if (i == 2) {
2394 /* Center/LFE */
2395 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2396 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2397 return err;
2398 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2399 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2400 return err;
2401 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2402 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2403 return err;
2404 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2405 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2406 return err;
2407 } else {
2408 sprintf(name, "%s Playback Volume", chname[i]);
2409 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2410 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2411 return err;
2412 sprintf(name, "%s Playback Switch", chname[i]);
2413 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2414 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2415 return err;
2416 }
2417 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002418 return 0;
2419}
2420
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002421/* add playback controls for speaker and HP outputs */
2422static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2423 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424{
2425 hda_nid_t nid;
2426 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002427 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428
2429 if (! pin)
2430 return 0;
2431
2432 if (alc880_is_fixed_pin(pin)) {
2433 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002434 /* specify the DAC as the extra output */
2435 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002436 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002437 else
2438 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002439 /* control HP volume/switch on the output mixer amp */
2440 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002441 sprintf(name, "%s Playback Volume", pfx);
2442 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2444 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002445 sprintf(name, "%s Playback Switch", pfx);
2446 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002447 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2448 return err;
2449 } else if (alc880_is_multi_pin(pin)) {
2450 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002451 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002452 sprintf(name, "%s Playback Switch", pfx);
2453 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002454 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2455 return err;
2456 }
2457 return 0;
2458}
2459
2460/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002461static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2462 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002463{
2464 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002465 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002466
2467 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002468 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002469 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002470 return err;
2471 sprintf(name, "%s Playback Switch", ctlname);
2472 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002473 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002474 return err;
2475 return 0;
2476}
2477
2478/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002479static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2480 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002481{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002482 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002483 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484
2485 for (i = 0; i < AUTO_PIN_LAST; i++) {
2486 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002487 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002488 err = new_analog_input(spec, cfg->input_pins[i],
2489 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002490 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491 if (err < 0)
2492 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002493 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2495 imux->num_items++;
2496 }
2497 }
2498 return 0;
2499}
2500
Kailang Yangdf694da2005-12-05 19:42:22 +01002501static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2502 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002503 int dac_idx)
2504{
2505 /* set as output */
2506 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2508 /* need the manual connection? */
2509 if (alc880_is_multi_pin(nid)) {
2510 struct alc_spec *spec = codec->spec;
2511 int idx = alc880_multi_pin_idx(nid);
2512 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2513 AC_VERB_SET_CONNECT_SEL,
2514 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2515 }
2516}
2517
2518static void alc880_auto_init_multi_out(struct hda_codec *codec)
2519{
2520 struct alc_spec *spec = codec->spec;
2521 int i;
2522
2523 for (i = 0; i < spec->autocfg.line_outs; i++) {
2524 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2525 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2526 }
2527}
2528
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002529static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530{
2531 struct alc_spec *spec = codec->spec;
2532 hda_nid_t pin;
2533
Takashi Iwai82bc9552006-03-21 11:24:42 +01002534 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002535 if (pin) /* connect to front */
2536 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 pin = spec->autocfg.hp_pin;
2538 if (pin) /* connect to front */
2539 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2540}
2541
2542static void alc880_auto_init_analog_input(struct hda_codec *codec)
2543{
2544 struct alc_spec *spec = codec->spec;
2545 int i;
2546
2547 for (i = 0; i < AUTO_PIN_LAST; i++) {
2548 hda_nid_t nid = spec->autocfg.input_pins[i];
2549 if (alc880_is_input_pin(nid)) {
2550 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2551 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2552 if (nid != ALC880_PIN_CD_NID)
2553 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2554 AMP_OUT_MUTE);
2555 }
2556 }
2557}
2558
2559/* parse the BIOS configuration and set up the alc_spec */
2560/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2561static int alc880_parse_auto_config(struct hda_codec *codec)
2562{
2563 struct alc_spec *spec = codec->spec;
2564 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002565 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002566
Kailang Yangdf694da2005-12-05 19:42:22 +01002567 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2568 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002570 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002571 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002572
2573 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2574 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002575 (err = alc880_auto_create_extra_out(spec,
2576 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002577 "Speaker")) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002578 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002579 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002580 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2581 return err;
2582
2583 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2584
2585 if (spec->autocfg.dig_out_pin)
2586 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2587 if (spec->autocfg.dig_in_pin)
2588 spec->dig_in_nid = ALC880_DIGIN_NID;
2589
2590 if (spec->kctl_alloc)
2591 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2592
2593 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2594
2595 spec->input_mux = &spec->private_imux;
2596
2597 return 1;
2598}
2599
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002600/* additional initialization for auto-configuration model */
2601static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002602{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002603 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002604 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002605 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002606}
2607
2608/*
2609 * OK, here we have finally the patch for ALC880
2610 */
2611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612static int patch_alc880(struct hda_codec *codec)
2613{
2614 struct alc_spec *spec;
2615 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002616 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002618 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 if (spec == NULL)
2620 return -ENOMEM;
2621
2622 codec->spec = spec;
2623
2624 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002625 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002626 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2627 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 }
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 if (board_config == ALC880_AUTO) {
2631 /* automatic parse from the BIOS config */
2632 err = alc880_parse_auto_config(codec);
2633 if (err < 0) {
2634 alc_free(codec);
2635 return err;
2636 } else if (! err) {
2637 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2638 board_config = ALC880_3ST;
2639 }
2640 }
2641
Kailang Yangdf694da2005-12-05 19:42:22 +01002642 if (board_config != ALC880_AUTO)
2643 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644
2645 spec->stream_name_analog = "ALC880 Analog";
2646 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2647 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2648
2649 spec->stream_name_digital = "ALC880 Digital";
2650 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2651 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2652
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002653 if (! spec->adc_nids && spec->input_mux) {
2654 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002655 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2657 if (wcap != AC_WID_AUD_IN) {
2658 spec->adc_nids = alc880_adc_nids_alt;
2659 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2660 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2661 spec->num_mixers++;
2662 } else {
2663 spec->adc_nids = alc880_adc_nids;
2664 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2665 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2666 spec->num_mixers++;
2667 }
2668 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669
2670 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002672 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673
2674 return 0;
2675}
2676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678/*
2679 * ALC260 support
2680 */
2681
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682static hda_nid_t alc260_dac_nids[1] = {
2683 /* front */
2684 0x02,
2685};
2686
2687static hda_nid_t alc260_adc_nids[1] = {
2688 /* ADC0 */
2689 0x04,
2690};
2691
Kailang Yangdf694da2005-12-05 19:42:22 +01002692static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 /* ADC1 */
2694 0x05,
2695};
2696
Kailang Yangdf694da2005-12-05 19:42:22 +01002697static hda_nid_t alc260_hp_adc_nids[2] = {
2698 /* ADC1, 0 */
2699 0x05, 0x04
2700};
2701
Jonathan Woithed57fdac2006-02-28 11:38:35 +01002702/* NIDs used when simultaneous access to both ADCs makes sense. Note that
2703 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2704 */
2705static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002706 /* ADC0, ADC1 */
2707 0x04, 0x05
2708};
2709
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710#define ALC260_DIGOUT_NID 0x03
2711#define ALC260_DIGIN_NID 0x06
2712
2713static struct hda_input_mux alc260_capture_source = {
2714 .num_items = 4,
2715 .items = {
2716 { "Mic", 0x0 },
2717 { "Front Mic", 0x1 },
2718 { "Line", 0x2 },
2719 { "CD", 0x4 },
2720 },
2721};
2722
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01002723/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2724 * headphone jack and the internal CD lines.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002725 */
2726static struct hda_input_mux alc260_fujitsu_capture_source = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002727 .num_items = 3,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002728 .items = {
2729 { "Mic/Line", 0x0 },
2730 { "CD", 0x4 },
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002731 { "Headphone", 0x2 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002732 },
2733};
2734
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002735/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
2736 * the Fujitsu S702x, but jacks are marked differently. We won't allow
2737 * retasking the Headphone jack, so it won't be available here.
2738 */
2739static struct hda_input_mux alc260_acer_capture_source = {
2740 .num_items = 3,
2741 .items = {
2742 { "Mic", 0x0 },
2743 { "Line", 0x2 },
2744 { "CD", 0x4 },
2745 },
2746};
2747
Linus Torvalds1da177e2005-04-16 15:20:36 -07002748/*
2749 * This is just place-holder, so there's something for alc_build_pcms to look
2750 * at when it calculates the maximum number of channels. ALC260 has no mixer
2751 * element which allows changing the channel mode, so the verb list is
2752 * never used.
2753 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002754static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 { 2, NULL },
2756};
2757
Kailang Yangdf694da2005-12-05 19:42:22 +01002758
2759/* Mixer combinations
2760 *
2761 * basic: base_output + input + pc_beep + capture
2762 * HP: base_output + input + capture_alt
2763 * HP_3013: hp_3013 + input + capture
2764 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002765 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01002766 */
2767
2768static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002769 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002770 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002771 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2772 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2773 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2774 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2775 { } /* end */
2776};
2777
2778static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2780 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2781 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2782 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2784 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2785 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2786 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 { } /* end */
2788};
2789
Kailang Yangdf694da2005-12-05 19:42:22 +01002790static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2791 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2792 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2793 { } /* end */
2794};
2795
2796static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2797 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2798 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2800 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2801 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2803 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2804 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 { } /* end */
2806};
2807
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002808static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002809 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002810 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002811 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002812 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2813 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2815 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002816 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002817 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2818 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2819 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002820 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002821 { } /* end */
2822};
2823
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002824static struct snd_kcontrol_new alc260_acer_mixer[] = {
2825 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2826 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
2827 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2828 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2830 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2831 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
2832 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2833 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2834 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2835 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2836 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2837 { } /* end */
2838};
2839
Kailang Yangdf694da2005-12-05 19:42:22 +01002840/* capture mixer elements */
2841static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002842 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2843 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002844 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2845 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002846 {
2847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01002848 /* The multiple "Capture Source" controls confuse alsamixer
2849 * So call somewhat different..
2850 * FIXME: the controls appear in the "playback" view!
2851 */
2852 /* .name = "Capture Source", */
2853 .name = "Input Source",
2854 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002855 .info = alc_mux_enum_info,
2856 .get = alc_mux_enum_get,
2857 .put = alc_mux_enum_put,
2858 },
2859 { } /* end */
2860};
2861
Kailang Yangdf694da2005-12-05 19:42:22 +01002862static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2863 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2864 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2865 {
2866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2867 /* The multiple "Capture Source" controls confuse alsamixer
2868 * So call somewhat different..
2869 * FIXME: the controls appear in the "playback" view!
2870 */
2871 /* .name = "Capture Source", */
2872 .name = "Input Source",
2873 .count = 1,
2874 .info = alc_mux_enum_info,
2875 .get = alc_mux_enum_get,
2876 .put = alc_mux_enum_put,
2877 },
2878 { } /* end */
2879};
2880
2881/*
2882 * initialization verbs
2883 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884static struct hda_verb alc260_init_verbs[] = {
2885 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02002888 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002889 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002890 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002891 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002892 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02002894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002895 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01002896 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002897 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02002898 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02002900 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002901 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02002902 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2903 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02002904 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002905 /* set connection select to line in (default select for this ADC) */
2906 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02002907 /* mute capture amp left and right */
2908 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2909 /* set connection select to line in (default select for this ADC) */
2910 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02002911 /* set vol=0 Line-Out mixer amp left and right */
2912 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2913 /* unmute pin widget amp left and right (no gain on this amp) */
2914 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 /* set vol=0 HP mixer amp left and right */
2916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2917 /* unmute pin widget amp left and right (no gain on this amp) */
2918 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 /* set vol=0 Mono mixer amp left and right */
2920 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2921 /* unmute pin widget amp left and right (no gain on this amp) */
2922 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2923 /* unmute LINE-2 out pin */
2924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002926 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02002927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002928 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02002929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002930 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02002931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002933 /* mute Front out path */
2934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2936 /* mute Headphone out path */
2937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2939 /* mute Mono out path */
2940 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2941 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002942 { }
2943};
2944
Kailang Yangdf694da2005-12-05 19:42:22 +01002945static struct hda_verb alc260_hp_init_verbs[] = {
2946 /* Headphone and output */
2947 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2948 /* mono output */
2949 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2950 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2951 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2952 /* Mic2 (front panel) pin widget for input and vref at 80% */
2953 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2954 /* Line In pin widget for input */
2955 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2956 /* Line-2 pin widget for output */
2957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2958 /* CD pin widget for input */
2959 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2960 /* unmute amp left and right */
2961 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2962 /* set connection select to line in (default select for this ADC) */
2963 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2964 /* unmute Line-Out mixer amp left and right (volume = 0) */
2965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2966 /* mute pin widget amp left and right (no gain on this amp) */
2967 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2968 /* unmute HP mixer amp left and right (volume = 0) */
2969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2970 /* mute pin widget amp left and right (no gain on this amp) */
2971 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2972 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2973 /* unmute CD */
2974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2975 /* unmute Line In */
2976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2977 /* unmute Mic */
2978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2979 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2980 /* Unmute Front out path */
2981 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2982 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2983 /* Unmute Headphone out path */
2984 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2986 /* Unmute Mono out path */
2987 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2988 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2989 { }
2990};
2991
2992static struct hda_verb alc260_hp_3013_init_verbs[] = {
2993 /* Line out and output */
2994 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2995 /* mono output */
2996 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2997 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2998 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2999 /* Mic2 (front panel) pin widget for input and vref at 80% */
3000 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3001 /* Line In pin widget for input */
3002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3003 /* Headphone pin widget for output */
3004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3005 /* CD pin widget for input */
3006 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3007 /* unmute amp left and right */
3008 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3009 /* set connection select to line in (default select for this ADC) */
3010 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3011 /* unmute Line-Out mixer amp left and right (volume = 0) */
3012 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3013 /* mute pin widget amp left and right (no gain on this amp) */
3014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3015 /* unmute HP mixer amp left and right (volume = 0) */
3016 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3017 /* mute pin widget amp left and right (no gain on this amp) */
3018 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3019 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3020 /* unmute CD */
3021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3022 /* unmute Line In */
3023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3024 /* unmute Mic */
3025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3026 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3027 /* Unmute Front out path */
3028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3030 /* Unmute Headphone out path */
3031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3033 /* Unmute Mono out path */
3034 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3036 { }
3037};
3038
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003039/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3040 * laptops.
3041 */
3042static struct hda_verb alc260_fujitsu_init_verbs[] = {
3043 /* Disable all GPIOs */
3044 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3045 /* Internal speaker is connected to headphone pin */
3046 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3047 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003049 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3051 /* Ensure all other unused pins are disabled and muted. */
3052 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003054 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003055 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003056 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003057 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3058 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003060
Jonathan Woithef7ace402006-02-28 11:46:14 +01003061 /* Disable digital (SPDIF) pins */
3062 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3063 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003064
Jonathan Woithef7ace402006-02-28 11:46:14 +01003065 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3066 * when acting as an output.
3067 */
3068 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3069
3070 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3077 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3078 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003080
Jonathan Woithef7ace402006-02-28 11:46:14 +01003081 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3082 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3083 /* Unmute Line1 pin widget output buffer since it starts as an output.
3084 * If the pin mode is changed by the user the pin mode control will
3085 * take care of enabling the pin's input/output buffers as needed.
3086 * Therefore there's no need to enable the input buffer at this
3087 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003088 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003089 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003090 /* Unmute input buffer of pin widget used for Line-in (no equiv
3091 * mixer ctrl)
3092 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003093 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003094
Jonathan Woithef7ace402006-02-28 11:46:14 +01003095 /* Mute capture amp left and right */
3096 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3097 /* Set ADC connection select to match default mixer setting - line
3098 * in (on mic1 pin)
3099 */
3100 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003101
Jonathan Woithef7ace402006-02-28 11:46:14 +01003102 /* Do the same for the second ADC: mute capture input amp and
3103 * set ADC connection to line in (on mic1 pin)
3104 */
3105 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3106 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003107
Jonathan Woithef7ace402006-02-28 11:46:14 +01003108 /* Mute all inputs to mixer widget (even unconnected ones) */
3109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003117
3118 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003119};
3120
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003121/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3122 * similar laptops (adapted from Fujitsu init verbs).
3123 */
3124static struct hda_verb alc260_acer_init_verbs[] = {
3125 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3126 * the headphone jack. Turn this on and rely on the standard mute
3127 * methods whenever the user wants to turn these outputs off.
3128 */
3129 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3130 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3131 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3132 /* Internal speaker/Headphone jack is connected to Line-out pin */
3133 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3134 /* Internal microphone/Mic jack is connected to Mic1 pin */
3135 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3136 /* Line In jack is connected to Line1 pin */
3137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3138 /* Ensure all other unused pins are disabled and muted. */
3139 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3140 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3141 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3142 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3143 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3144 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3146 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3147 /* Disable digital (SPDIF) pins */
3148 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3149 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3150
3151 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3152 * bus when acting as outputs.
3153 */
3154 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3155 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3156
3157 /* Start with output sum widgets muted and their output gains at min */
3158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3167
3168 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3170 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3171 * inputs. If the pin mode is changed by the user the pin mode control
3172 * will take care of enabling the pin's input/output buffers as needed.
3173 * Therefore there's no need to enable the input buffer at this
3174 * stage.
3175 */
3176 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3177 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3178
3179 /* Mute capture amp left and right */
3180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3181 /* Set ADC connection select to match default mixer setting - mic
3182 * (on mic1 pin)
3183 */
3184 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3185
3186 /* Do similar with the second ADC: mute capture input amp and
3187 * set ADC connection to line (on line1 pin)
3188 */
3189 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3190 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3191
3192 /* Mute all inputs to mixer widget (even unconnected ones) */
3193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3201
3202 { }
3203};
3204
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003205/* Test configuration for debugging, modelled after the ALC880 test
3206 * configuration.
3207 */
3208#ifdef CONFIG_SND_DEBUG
3209static hda_nid_t alc260_test_dac_nids[1] = {
3210 0x02,
3211};
3212static hda_nid_t alc260_test_adc_nids[2] = {
3213 0x04, 0x05,
3214};
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003215/* This is a bit messy since the two input muxes in the ALC260 have slight
3216 * variations in their signal assignments. The ideal way to deal with this
3217 * is to extend alc_spec.input_mux to allow a different input MUX for each
3218 * ADC. For the purposes of the test model it's sufficient to just list
3219 * both options for affected signal indices. The separate input mux
3220 * functionality only needs to be considered if a model comes along which
3221 * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
3222 * record.
3223 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003224static struct hda_input_mux alc260_test_capture_source = {
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003225 .num_items = 8,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003226 .items = {
3227 { "MIC1 pin", 0x0 },
3228 { "MIC2 pin", 0x1 },
3229 { "LINE1 pin", 0x2 },
3230 { "LINE2 pin", 0x3 },
3231 { "CD pin", 0x4 },
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003232 { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
3233 { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
3234 { "HP-OUT pin (cap2 only)", 0x7 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003235 },
3236};
3237static struct snd_kcontrol_new alc260_test_mixer[] = {
3238 /* Output driver widgets */
3239 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3240 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3241 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3242 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3243 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3244 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3245
3246 /* Modes for retasking pin widgets */
3247 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3248 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3249 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3250 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3251 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3252 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3253
3254 /* Loopback mixer controls */
3255 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3256 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3257 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3258 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3259 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3260 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3261 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3262 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3263 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3264 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3265 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3266 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3267 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3268 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3269 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3270 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003271
3272 /* Controls for GPIO pins, assuming they are configured as outputs */
3273 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3274 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3275 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3276 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3277
Jonathan Woithe92621f12006-02-28 11:47:47 +01003278 /* Switches to allow the digital IO pins to be enabled. The datasheet
3279 * is ambigious as to which NID is which; testing on laptops which
3280 * make this output available should provide clarification.
3281 */
3282 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3283 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3284
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003285 { } /* end */
3286};
3287static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003288 /* Enable all GPIOs as outputs with an initial value of 0 */
3289 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3290 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3291 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3292
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003293 /* Enable retasking pins as output, initially without power amp */
3294 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3295 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3298 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3299 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3300
Jonathan Woithe92621f12006-02-28 11:47:47 +01003301 /* Disable digital (SPDIF) pins initially, but users can enable
3302 * them via a mixer switch. In the case of SPDIF-out, this initverb
3303 * payload also sets the generation to 0, output to be in "consumer"
3304 * PCM format, copyright asserted, no pre-emphasis and no validity
3305 * control.
3306 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003307 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3308 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3309
Jonathan Woithef7ace402006-02-28 11:46:14 +01003310 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003311 * OUT1 sum bus when acting as an output.
3312 */
3313 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3314 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3315 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3316 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3317
3318 /* Start with output sum widgets muted and their output gains at min */
3319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3321 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3325 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3326 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3327 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3328
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003329 /* Unmute retasking pin widget output buffers since the default
3330 * state appears to be output. As the pin mode is changed by the
3331 * user the pin mode control will take care of enabling the pin's
3332 * input/output buffers as needed.
3333 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003334 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3338 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3339 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3340 /* Also unmute the mono-out pin widget */
3341 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3342
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003343 /* Mute capture amp left and right */
3344 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003345 /* Set ADC connection select to match default mixer setting (mic1
3346 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003347 */
3348 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3349
3350 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003351 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003352 */
3353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3354 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3355
3356 /* Mute all inputs to mixer widget (even unconnected ones) */
3357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3365
3366 { }
3367};
3368#endif
3369
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370static struct hda_pcm_stream alc260_pcm_analog_playback = {
3371 .substreams = 1,
3372 .channels_min = 2,
3373 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374};
3375
3376static struct hda_pcm_stream alc260_pcm_analog_capture = {
3377 .substreams = 1,
3378 .channels_min = 2,
3379 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003380};
3381
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003382#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3383#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3384
Kailang Yangdf694da2005-12-05 19:42:22 +01003385/*
3386 * for BIOS auto-configuration
3387 */
3388
3389static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3390 const char *pfx)
3391{
3392 hda_nid_t nid_vol;
3393 unsigned long vol_val, sw_val;
3394 char name[32];
3395 int err;
3396
3397 if (nid >= 0x0f && nid < 0x11) {
3398 nid_vol = nid - 0x7;
3399 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3400 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3401 } else if (nid == 0x11) {
3402 nid_vol = nid - 0x7;
3403 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3404 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3405 } else if (nid >= 0x12 && nid <= 0x15) {
3406 nid_vol = 0x08;
3407 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3408 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3409 } else
3410 return 0; /* N/A */
3411
3412 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3413 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3414 return err;
3415 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3416 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3417 return err;
3418 return 1;
3419}
3420
3421/* add playback controls from the parsed DAC table */
3422static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3423 const struct auto_pin_cfg *cfg)
3424{
3425 hda_nid_t nid;
3426 int err;
3427
3428 spec->multiout.num_dacs = 1;
3429 spec->multiout.dac_nids = spec->private_dac_nids;
3430 spec->multiout.dac_nids[0] = 0x02;
3431
3432 nid = cfg->line_out_pins[0];
3433 if (nid) {
3434 err = alc260_add_playback_controls(spec, nid, "Front");
3435 if (err < 0)
3436 return err;
3437 }
3438
Takashi Iwai82bc9552006-03-21 11:24:42 +01003439 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003440 if (nid) {
3441 err = alc260_add_playback_controls(spec, nid, "Speaker");
3442 if (err < 0)
3443 return err;
3444 }
3445
3446 nid = cfg->hp_pin;
3447 if (nid) {
3448 err = alc260_add_playback_controls(spec, nid, "Headphone");
3449 if (err < 0)
3450 return err;
3451 }
3452 return 0;
3453}
3454
3455/* create playback/capture controls for input pins */
3456static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3457 const struct auto_pin_cfg *cfg)
3458{
Kailang Yangdf694da2005-12-05 19:42:22 +01003459 struct hda_input_mux *imux = &spec->private_imux;
3460 int i, err, idx;
3461
3462 for (i = 0; i < AUTO_PIN_LAST; i++) {
3463 if (cfg->input_pins[i] >= 0x12) {
3464 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003465 err = new_analog_input(spec, cfg->input_pins[i],
3466 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003467 if (err < 0)
3468 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003469 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003470 imux->items[imux->num_items].index = idx;
3471 imux->num_items++;
3472 }
3473 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3474 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003475 err = new_analog_input(spec, cfg->input_pins[i],
3476 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003477 if (err < 0)
3478 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003479 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003480 imux->items[imux->num_items].index = idx;
3481 imux->num_items++;
3482 }
3483 }
3484 return 0;
3485}
3486
3487static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3488 hda_nid_t nid, int pin_type,
3489 int sel_idx)
3490{
3491 /* set as output */
3492 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3493 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3494 /* need the manual connection? */
3495 if (nid >= 0x12) {
3496 int idx = nid - 0x12;
3497 snd_hda_codec_write(codec, idx + 0x0b, 0,
3498 AC_VERB_SET_CONNECT_SEL, sel_idx);
3499
3500 }
3501}
3502
3503static void alc260_auto_init_multi_out(struct hda_codec *codec)
3504{
3505 struct alc_spec *spec = codec->spec;
3506 hda_nid_t nid;
3507
3508 nid = spec->autocfg.line_out_pins[0];
3509 if (nid)
3510 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3511
Takashi Iwai82bc9552006-03-21 11:24:42 +01003512 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003513 if (nid)
3514 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3515
3516 nid = spec->autocfg.hp_pin;
3517 if (nid)
3518 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3519}
3520
3521#define ALC260_PIN_CD_NID 0x16
3522static void alc260_auto_init_analog_input(struct hda_codec *codec)
3523{
3524 struct alc_spec *spec = codec->spec;
3525 int i;
3526
3527 for (i = 0; i < AUTO_PIN_LAST; i++) {
3528 hda_nid_t nid = spec->autocfg.input_pins[i];
3529 if (nid >= 0x12) {
3530 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3531 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3532 if (nid != ALC260_PIN_CD_NID)
3533 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3534 AMP_OUT_MUTE);
3535 }
3536 }
3537}
3538
3539/*
3540 * generic initialization of ADC, input mixers and output mixers
3541 */
3542static struct hda_verb alc260_volume_init_verbs[] = {
3543 /*
3544 * Unmute ADC0-1 and set the default input to mic-in
3545 */
3546 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3547 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3548 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3549 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3550
3551 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3552 * mixer widget
3553 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3554 * mic (mic 2)
3555 */
3556 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3560 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3561 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3562
3563 /*
3564 * Set up output mixers (0x08 - 0x0a)
3565 */
3566 /* set vol=0 to output mixers */
3567 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3568 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3570 /* set up input amps for analog loopback */
3571 /* Amp Indices: DAC = 0, mixer = 1 */
3572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3578
3579 { }
3580};
3581
3582static int alc260_parse_auto_config(struct hda_codec *codec)
3583{
3584 struct alc_spec *spec = codec->spec;
3585 unsigned int wcap;
3586 int err;
3587 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3588
3589 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3590 alc260_ignore)) < 0)
3591 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003592 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3593 return err;
3594 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003595 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003596 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003597 return err;
3598
3599 spec->multiout.max_channels = 2;
3600
3601 if (spec->autocfg.dig_out_pin)
3602 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3603 if (spec->kctl_alloc)
3604 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3605
3606 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3607
3608 spec->input_mux = &spec->private_imux;
3609
3610 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003611 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003612 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3613 if (wcap != AC_WID_AUD_IN) {
3614 spec->adc_nids = alc260_adc_nids_alt;
3615 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3616 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003617 } else {
3618 spec->adc_nids = alc260_adc_nids;
3619 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3620 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003621 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003622 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003623
3624 return 1;
3625}
3626
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003627/* additional initialization for auto-configuration model */
3628static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01003629{
Kailang Yangdf694da2005-12-05 19:42:22 +01003630 alc260_auto_init_multi_out(codec);
3631 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01003632}
3633
3634/*
3635 * ALC260 configurations
3636 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003637static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003638 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003639 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3640 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01003641 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3642 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02003643 { .modelname = "hp", .config = ALC260_HP },
Kailang Yangdf694da2005-12-05 19:42:22 +01003644 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3645 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3646 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
3647 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3648 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3649 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3650 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3651 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3652 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003653 { .modelname = "acer", .config = ALC260_ACER },
3654 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003655#ifdef CONFIG_SND_DEBUG
3656 { .modelname = "test", .config = ALC260_TEST },
3657#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003658 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003659 {}
3660};
3661
Kailang Yangdf694da2005-12-05 19:42:22 +01003662static struct alc_config_preset alc260_presets[] = {
3663 [ALC260_BASIC] = {
3664 .mixers = { alc260_base_output_mixer,
3665 alc260_input_mixer,
3666 alc260_pc_beep_mixer,
3667 alc260_capture_mixer },
3668 .init_verbs = { alc260_init_verbs },
3669 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3670 .dac_nids = alc260_dac_nids,
3671 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3672 .adc_nids = alc260_adc_nids,
3673 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3674 .channel_mode = alc260_modes,
3675 .input_mux = &alc260_capture_source,
3676 },
3677 [ALC260_HP] = {
3678 .mixers = { alc260_base_output_mixer,
3679 alc260_input_mixer,
3680 alc260_capture_alt_mixer },
3681 .init_verbs = { alc260_hp_init_verbs },
3682 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3683 .dac_nids = alc260_dac_nids,
3684 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3685 .adc_nids = alc260_hp_adc_nids,
3686 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3687 .channel_mode = alc260_modes,
3688 .input_mux = &alc260_capture_source,
3689 },
3690 [ALC260_HP_3013] = {
3691 .mixers = { alc260_hp_3013_mixer,
3692 alc260_input_mixer,
3693 alc260_capture_alt_mixer },
3694 .init_verbs = { alc260_hp_3013_init_verbs },
3695 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3696 .dac_nids = alc260_dac_nids,
3697 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3698 .adc_nids = alc260_hp_adc_nids,
3699 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3700 .channel_mode = alc260_modes,
3701 .input_mux = &alc260_capture_source,
3702 },
3703 [ALC260_FUJITSU_S702X] = {
3704 .mixers = { alc260_fujitsu_mixer,
3705 alc260_capture_mixer },
3706 .init_verbs = { alc260_fujitsu_init_verbs },
3707 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3708 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003709 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3710 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01003711 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3712 .channel_mode = alc260_modes,
3713 .input_mux = &alc260_fujitsu_capture_source,
3714 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003715 [ALC260_ACER] = {
3716 .mixers = { alc260_acer_mixer,
3717 alc260_capture_mixer },
3718 .init_verbs = { alc260_acer_init_verbs },
3719 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3720 .dac_nids = alc260_dac_nids,
3721 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3722 .adc_nids = alc260_dual_adc_nids,
3723 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3724 .channel_mode = alc260_modes,
3725 .input_mux = &alc260_acer_capture_source,
3726 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003727#ifdef CONFIG_SND_DEBUG
3728 [ALC260_TEST] = {
3729 .mixers = { alc260_test_mixer,
3730 alc260_capture_mixer },
3731 .init_verbs = { alc260_test_init_verbs },
3732 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3733 .dac_nids = alc260_test_dac_nids,
3734 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3735 .adc_nids = alc260_test_adc_nids,
3736 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3737 .channel_mode = alc260_modes,
3738 .input_mux = &alc260_test_capture_source,
3739 },
3740#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003741};
3742
Linus Torvalds1da177e2005-04-16 15:20:36 -07003743static int patch_alc260(struct hda_codec *codec)
3744{
3745 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01003746 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003747
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003748 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003749 if (spec == NULL)
3750 return -ENOMEM;
3751
3752 codec->spec = spec;
3753
Takashi Iwai16ded522005-06-10 19:58:24 +02003754 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3755 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3756 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01003757 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02003758 }
3759
Kailang Yangdf694da2005-12-05 19:42:22 +01003760 if (board_config == ALC260_AUTO) {
3761 /* automatic parse from the BIOS config */
3762 err = alc260_parse_auto_config(codec);
3763 if (err < 0) {
3764 alc_free(codec);
3765 return err;
3766 } else if (! err) {
3767 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3768 board_config = ALC260_BASIC;
3769 }
Takashi Iwai16ded522005-06-10 19:58:24 +02003770 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003771
Kailang Yangdf694da2005-12-05 19:42:22 +01003772 if (board_config != ALC260_AUTO)
3773 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003774
3775 spec->stream_name_analog = "ALC260 Analog";
3776 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3777 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3778
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003779 spec->stream_name_digital = "ALC260 Digital";
3780 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3781 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3782
Linus Torvalds1da177e2005-04-16 15:20:36 -07003783 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01003784 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003785 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003786
3787 return 0;
3788}
3789
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003790
Linus Torvalds1da177e2005-04-16 15:20:36 -07003791/*
3792 * ALC882 support
3793 *
3794 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3795 * configuration. Each pin widget can choose any input DACs and a mixer.
3796 * Each ADC is connected from a mixer of all inputs. This makes possible
3797 * 6-channel independent captures.
3798 *
3799 * In addition, an independent DAC for the multi-playback (not used in this
3800 * driver yet).
3801 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003802#define ALC882_DIGOUT_NID 0x06
3803#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07003804
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003805static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003806 { 8, NULL }
3807};
3808
3809static hda_nid_t alc882_dac_nids[4] = {
3810 /* front, rear, clfe, rear_surr */
3811 0x02, 0x03, 0x04, 0x05
3812};
3813
Kailang Yangdf694da2005-12-05 19:42:22 +01003814/* identical with ALC880 */
3815#define alc882_adc_nids alc880_adc_nids
3816#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07003817
3818/* input MUX */
3819/* FIXME: should be a matrix-type input source selection */
3820
3821static struct hda_input_mux alc882_capture_source = {
3822 .num_items = 4,
3823 .items = {
3824 { "Mic", 0x0 },
3825 { "Front Mic", 0x1 },
3826 { "Line", 0x2 },
3827 { "CD", 0x4 },
3828 },
3829};
3830
3831#define alc882_mux_enum_info alc_mux_enum_info
3832#define alc882_mux_enum_get alc_mux_enum_get
3833
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003834static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003835{
3836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3837 struct alc_spec *spec = codec->spec;
3838 const struct hda_input_mux *imux = spec->input_mux;
3839 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3840 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3841 hda_nid_t nid = capture_mixers[adc_idx];
3842 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3843 unsigned int i, idx;
3844
3845 idx = ucontrol->value.enumerated.item[0];
3846 if (idx >= imux->num_items)
3847 idx = imux->num_items - 1;
3848 if (*cur_val == idx && ! codec->in_resume)
3849 return 0;
3850 for (i = 0; i < imux->num_items; i++) {
3851 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3852 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3853 v | (imux->items[i].index << 8));
3854 }
3855 *cur_val = idx;
3856 return 1;
3857}
3858
Kailang Yangdf694da2005-12-05 19:42:22 +01003859/*
3860 * 6ch mode
3861 */
3862static struct hda_verb alc882_sixstack_ch6_init[] = {
3863 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3864 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3865 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3866 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3867 { } /* end */
3868};
3869
3870/*
3871 * 8ch mode
3872 */
3873static struct hda_verb alc882_sixstack_ch8_init[] = {
3874 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3875 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3876 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3877 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3878 { } /* end */
3879};
3880
3881static struct hda_channel_mode alc882_sixstack_modes[2] = {
3882 { 6, alc882_sixstack_ch6_init },
3883 { 8, alc882_sixstack_ch8_init },
3884};
3885
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3887 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3888 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003889static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003890 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003891 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003892 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003893 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003896 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3897 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02003898 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003899 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3907 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3908 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3909 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
3910 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
3911 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3912 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3913 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3914 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3915 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3916 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3917 {
3918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3919 /* .name = "Capture Source", */
3920 .name = "Input Source",
3921 .count = 3,
3922 .info = alc882_mux_enum_info,
3923 .get = alc882_mux_enum_get,
3924 .put = alc882_mux_enum_put,
3925 },
3926 { } /* end */
3927};
3928
Kailang Yangdf694da2005-12-05 19:42:22 +01003929static struct snd_kcontrol_new alc882_chmode_mixer[] = {
3930 {
3931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3932 .name = "Channel Mode",
3933 .info = alc_ch_mode_info,
3934 .get = alc_ch_mode_get,
3935 .put = alc_ch_mode_put,
3936 },
3937 { } /* end */
3938};
3939
Linus Torvalds1da177e2005-04-16 15:20:36 -07003940static struct hda_verb alc882_init_verbs[] = {
3941 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003945 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3947 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3948 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003949 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003953 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02003954 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3955 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3956 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003957
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003961 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003962 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003967 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003968 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02003971 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02003972 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003973 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003974 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3977 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003979 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3980 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003981 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3983 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3985 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3986 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003989
3990 /* FIXME: use matrix-type input source selection */
3991 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3992 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02003993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3996 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003997 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4000 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004002 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4007 /* ADC1: mute amp left and right */
4008 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004009 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004010 /* ADC2: mute amp left and right */
4011 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004012 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004013 /* ADC3: mute amp left and right */
4014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004015 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004016
4017 { }
4018};
4019
Kailang Yangdf694da2005-12-05 19:42:22 +01004020/*
4021 * generic initialization of ADC, input mixers and output mixers
4022 */
4023static struct hda_verb alc882_auto_init_verbs[] = {
4024 /*
4025 * Unmute ADC0-2 and set the default input to mic-in
4026 */
4027 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4029 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4030 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4031 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4033
4034 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4035 * mixer widget
4036 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4037 * mic (mic 2)
4038 */
4039 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4045
4046 /*
4047 * Set up output mixers (0x0c - 0x0f)
4048 */
4049 /* set vol=0 to output mixers */
4050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4054 /* set up input amps for analog loopback */
4055 /* Amp Indices: DAC = 0, mixer = 1 */
4056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4057 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4058 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4059 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4062 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4063 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4064 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4065 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4066
4067 /* FIXME: use matrix-type input source selection */
4068 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4069 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4074 /* Input mixer2 */
4075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4078 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4079 /* Input mixer3 */
4080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4084
4085 { }
4086};
4087
4088/* capture mixer elements */
4089static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4090 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4091 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4092 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4093 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4094 {
4095 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4096 /* The multiple "Capture Source" controls confuse alsamixer
4097 * So call somewhat different..
4098 * FIXME: the controls appear in the "playback" view!
4099 */
4100 /* .name = "Capture Source", */
4101 .name = "Input Source",
4102 .count = 2,
4103 .info = alc882_mux_enum_info,
4104 .get = alc882_mux_enum_get,
4105 .put = alc882_mux_enum_put,
4106 },
4107 { } /* end */
4108};
4109
4110static struct snd_kcontrol_new alc882_capture_mixer[] = {
4111 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4112 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4113 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4114 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4115 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4116 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4117 {
4118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4119 /* The multiple "Capture Source" controls confuse alsamixer
4120 * So call somewhat different..
4121 * FIXME: the controls appear in the "playback" view!
4122 */
4123 /* .name = "Capture Source", */
4124 .name = "Input Source",
4125 .count = 3,
4126 .info = alc882_mux_enum_info,
4127 .get = alc882_mux_enum_get,
4128 .put = alc882_mux_enum_put,
4129 },
4130 { } /* end */
4131};
4132
4133/* pcm configuration: identiacal with ALC880 */
4134#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4135#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4136#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4137#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4138
4139/*
4140 * configuration and preset
4141 */
4142static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004143 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4144 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01004145 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
4146 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
4147 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
Takashi Iwai1494a922006-01-31 10:58:46 +01004148 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004149 {}
4150};
4151
4152static struct alc_config_preset alc882_presets[] = {
4153 [ALC882_3ST_DIG] = {
4154 .mixers = { alc882_base_mixer },
4155 .init_verbs = { alc882_init_verbs },
4156 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4157 .dac_nids = alc882_dac_nids,
4158 .dig_out_nid = ALC882_DIGOUT_NID,
4159 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4160 .adc_nids = alc882_adc_nids,
4161 .dig_in_nid = ALC882_DIGIN_NID,
4162 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4163 .channel_mode = alc882_ch_modes,
4164 .input_mux = &alc882_capture_source,
4165 },
4166 [ALC882_6ST_DIG] = {
4167 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4168 .init_verbs = { alc882_init_verbs },
4169 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4170 .dac_nids = alc882_dac_nids,
4171 .dig_out_nid = ALC882_DIGOUT_NID,
4172 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4173 .adc_nids = alc882_adc_nids,
4174 .dig_in_nid = ALC882_DIGIN_NID,
4175 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4176 .channel_mode = alc882_sixstack_modes,
4177 .input_mux = &alc882_capture_source,
4178 },
4179};
4180
4181
4182/*
4183 * BIOS auto configuration
4184 */
4185static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4186 hda_nid_t nid, int pin_type,
4187 int dac_idx)
4188{
4189 /* set as output */
4190 struct alc_spec *spec = codec->spec;
4191 int idx;
4192
4193 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4194 idx = 4;
4195 else
4196 idx = spec->multiout.dac_nids[dac_idx] - 2;
4197
4198 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4199 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4200 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4201
4202}
4203
4204static void alc882_auto_init_multi_out(struct hda_codec *codec)
4205{
4206 struct alc_spec *spec = codec->spec;
4207 int i;
4208
4209 for (i = 0; i <= HDA_SIDE; i++) {
4210 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4211 if (nid)
4212 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4213 }
4214}
4215
4216static void alc882_auto_init_hp_out(struct hda_codec *codec)
4217{
4218 struct alc_spec *spec = codec->spec;
4219 hda_nid_t pin;
4220
4221 pin = spec->autocfg.hp_pin;
4222 if (pin) /* connect to front */
4223 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4224}
4225
4226#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4227#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4228
4229static void alc882_auto_init_analog_input(struct hda_codec *codec)
4230{
4231 struct alc_spec *spec = codec->spec;
4232 int i;
4233
4234 for (i = 0; i < AUTO_PIN_LAST; i++) {
4235 hda_nid_t nid = spec->autocfg.input_pins[i];
4236 if (alc882_is_input_pin(nid)) {
4237 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4238 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4239 if (nid != ALC882_PIN_CD_NID)
4240 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4241 AMP_OUT_MUTE);
4242 }
4243 }
4244}
4245
4246/* almost identical with ALC880 parser... */
4247static int alc882_parse_auto_config(struct hda_codec *codec)
4248{
4249 struct alc_spec *spec = codec->spec;
4250 int err = alc880_parse_auto_config(codec);
4251
4252 if (err < 0)
4253 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004254 else if (err > 0)
4255 /* hack - override the init verbs */
4256 spec->init_verbs[0] = alc882_auto_init_verbs;
4257 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004258}
4259
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004260/* additional initialization for auto-configuration model */
4261static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004262{
Kailang Yangdf694da2005-12-05 19:42:22 +01004263 alc882_auto_init_multi_out(codec);
4264 alc882_auto_init_hp_out(codec);
4265 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004266}
4267
4268/*
4269 * ALC882 Headphone poll in 3.5.1a or 3.5.2
4270 */
4271
Linus Torvalds1da177e2005-04-16 15:20:36 -07004272static int patch_alc882(struct hda_codec *codec)
4273{
4274 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004275 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004276
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004277 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004278 if (spec == NULL)
4279 return -ENOMEM;
4280
Linus Torvalds1da177e2005-04-16 15:20:36 -07004281 codec->spec = spec;
4282
Kailang Yangdf694da2005-12-05 19:42:22 +01004283 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284
Kailang Yangdf694da2005-12-05 19:42:22 +01004285 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4286 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
4287 board_config = ALC882_AUTO;
4288 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289
Kailang Yangdf694da2005-12-05 19:42:22 +01004290 if (board_config == ALC882_AUTO) {
4291 /* automatic parse from the BIOS config */
4292 err = alc882_parse_auto_config(codec);
4293 if (err < 0) {
4294 alc_free(codec);
4295 return err;
4296 } else if (! err) {
4297 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4298 board_config = ALC882_3ST_DIG;
4299 }
4300 }
4301
4302 if (board_config != ALC882_AUTO)
4303 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004304
4305 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004306 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4307 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004308
4309 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004310 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4311 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004312
Kailang Yangdf694da2005-12-05 19:42:22 +01004313 if (! spec->adc_nids && spec->input_mux) {
4314 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004315 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004316 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4317 if (wcap != AC_WID_AUD_IN) {
4318 spec->adc_nids = alc882_adc_nids_alt;
4319 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4320 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4321 spec->num_mixers++;
4322 } else {
4323 spec->adc_nids = alc882_adc_nids;
4324 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4325 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4326 spec->num_mixers++;
4327 }
4328 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004329
4330 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004331 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004332 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004333
4334 return 0;
4335}
4336
4337/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004338 * ALC262 support
4339 */
4340
4341#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
4342#define ALC262_DIGIN_NID ALC880_DIGIN_NID
4343
4344#define alc262_dac_nids alc260_dac_nids
4345#define alc262_adc_nids alc882_adc_nids
4346#define alc262_adc_nids_alt alc882_adc_nids_alt
4347
4348#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004349#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01004350
4351static struct snd_kcontrol_new alc262_base_mixer[] = {
4352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4353 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4360 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
4361 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
4362 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
4363 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
4364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
4365 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4366 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4367 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004368 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01004369};
4370
Kailang Yangdf694da2005-12-05 19:42:22 +01004371#define alc262_capture_mixer alc882_capture_mixer
4372#define alc262_capture_alt_mixer alc882_capture_alt_mixer
4373
4374/*
4375 * generic initialization of ADC, input mixers and output mixers
4376 */
4377static struct hda_verb alc262_init_verbs[] = {
4378 /*
4379 * Unmute ADC0-2 and set the default input to mic-in
4380 */
4381 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4383 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4385 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4387
4388 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4389 * mixer widget
4390 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4391 * mic (mic 2)
4392 */
4393 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4399
4400 /*
4401 * Set up output mixers (0x0c - 0x0e)
4402 */
4403 /* set vol=0 to output mixers */
4404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4407 /* set up input amps for analog loopback */
4408 /* Amp Indices: DAC = 0, mixer = 1 */
4409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4415
4416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4418 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4421 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4422
4423 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4426 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4427 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4428
4429 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4431
4432 /* FIXME: use matrix-type input source selection */
4433 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4434 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4439 /* Input mixer2 */
4440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4444 /* Input mixer3 */
4445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4449
4450 { }
4451};
4452
Takashi Iwai834be882006-03-01 14:16:17 +01004453/*
4454 * fujitsu model
4455 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
4456 */
4457
4458#define ALC_HP_EVENT 0x37
4459
4460static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
4461 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
4462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4463 {}
4464};
4465
4466static struct hda_input_mux alc262_fujitsu_capture_source = {
4467 .num_items = 2,
4468 .items = {
4469 { "Mic", 0x0 },
4470 { "CD", 0x4 },
4471 },
4472};
4473
4474/* mute/unmute internal speaker according to the hp jack and mute state */
4475static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
4476{
4477 struct alc_spec *spec = codec->spec;
4478 unsigned int mute;
4479
4480 if (force || ! spec->sense_updated) {
4481 unsigned int present;
4482 /* need to execute and sync at first */
4483 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
4484 present = snd_hda_codec_read(codec, 0x14, 0,
4485 AC_VERB_GET_PIN_SENSE, 0);
4486 spec->jack_present = (present & 0x80000000) != 0;
4487 spec->sense_updated = 1;
4488 }
4489 if (spec->jack_present) {
4490 /* mute internal speaker */
4491 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4492 0x80, 0x80);
4493 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4494 0x80, 0x80);
4495 } else {
4496 /* unmute internal speaker if necessary */
4497 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
4498 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4499 0x80, mute & 0x80);
4500 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
4501 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4502 0x80, mute & 0x80);
4503 }
4504}
4505
4506/* unsolicited event for HP jack sensing */
4507static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
4508 unsigned int res)
4509{
4510 if ((res >> 26) != ALC_HP_EVENT)
4511 return;
4512 alc262_fujitsu_automute(codec, 1);
4513}
4514
4515/* bind volumes of both NID 0x0c and 0x0d */
4516static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
4517 struct snd_ctl_elem_value *ucontrol)
4518{
4519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4520 long *valp = ucontrol->value.integer.value;
4521 int change;
4522
4523 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
4524 0x7f, valp[0] & 0x7f);
4525 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
4526 0x7f, valp[1] & 0x7f);
4527 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
4528 0x7f, valp[0] & 0x7f);
4529 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
4530 0x7f, valp[1] & 0x7f);
4531 return change;
4532}
4533
4534/* bind hp and internal speaker mute (with plug check) */
4535static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
4536 struct snd_ctl_elem_value *ucontrol)
4537{
4538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4539 long *valp = ucontrol->value.integer.value;
4540 int change;
4541
4542 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
4543 0x80, valp[0] ? 0 : 0x80);
4544 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
4545 0x80, valp[1] ? 0 : 0x80);
4546 if (change || codec->in_resume)
4547 alc262_fujitsu_automute(codec, codec->in_resume);
4548 return change;
4549}
4550
4551static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
4552 {
4553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4554 .name = "Master Playback Volume",
4555 .info = snd_hda_mixer_amp_volume_info,
4556 .get = snd_hda_mixer_amp_volume_get,
4557 .put = alc262_fujitsu_master_vol_put,
4558 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
4559 },
4560 {
4561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4562 .name = "Master Playback Switch",
4563 .info = snd_hda_mixer_amp_switch_info,
4564 .get = snd_hda_mixer_amp_switch_get,
4565 .put = alc262_fujitsu_master_sw_put,
4566 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
4567 },
4568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4570 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4573 { } /* end */
4574};
4575
Kailang Yangdf694da2005-12-05 19:42:22 +01004576/* add playback controls from the parsed DAC table */
4577static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4578{
4579 hda_nid_t nid;
4580 int err;
4581
4582 spec->multiout.num_dacs = 1; /* only use one dac */
4583 spec->multiout.dac_nids = spec->private_dac_nids;
4584 spec->multiout.dac_nids[0] = 2;
4585
4586 nid = cfg->line_out_pins[0];
4587 if (nid) {
4588 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
4589 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4590 return err;
4591 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
4592 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4593 return err;
4594 }
4595
Takashi Iwai82bc9552006-03-21 11:24:42 +01004596 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004597 if (nid) {
4598 if (nid == 0x16) {
4599 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4600 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4601 return err;
4602 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4603 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4604 return err;
4605 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01004606 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4607 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4608 return err;
4609 }
4610 }
4611 nid = cfg->hp_pin;
4612 if (nid) {
4613 /* spec->multiout.hp_nid = 2; */
4614 if (nid == 0x16) {
4615 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4616 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4617 return err;
4618 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4619 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4620 return err;
4621 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01004622 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4623 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4624 return err;
4625 }
4626 }
4627 return 0;
4628}
4629
4630/* identical with ALC880 */
4631#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4632
4633/*
4634 * generic initialization of ADC, input mixers and output mixers
4635 */
4636static struct hda_verb alc262_volume_init_verbs[] = {
4637 /*
4638 * Unmute ADC0-2 and set the default input to mic-in
4639 */
4640 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4642 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4643 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4644 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4645 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4646
4647 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4648 * mixer widget
4649 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4650 * mic (mic 2)
4651 */
4652 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4658
4659 /*
4660 * Set up output mixers (0x0c - 0x0f)
4661 */
4662 /* set vol=0 to output mixers */
4663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4666
4667 /* set up input amps for analog loopback */
4668 /* Amp Indices: DAC = 0, mixer = 1 */
4669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4671 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4674 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4675
4676 /* FIXME: use matrix-type input source selection */
4677 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4678 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4679 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4680 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4681 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4683 /* Input mixer2 */
4684 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4685 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4686 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4688 /* Input mixer3 */
4689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4693
4694 { }
4695};
4696
4697/* pcm configuration: identiacal with ALC880 */
4698#define alc262_pcm_analog_playback alc880_pcm_analog_playback
4699#define alc262_pcm_analog_capture alc880_pcm_analog_capture
4700#define alc262_pcm_digital_playback alc880_pcm_digital_playback
4701#define alc262_pcm_digital_capture alc880_pcm_digital_capture
4702
4703/*
4704 * BIOS auto configuration
4705 */
4706static int alc262_parse_auto_config(struct hda_codec *codec)
4707{
4708 struct alc_spec *spec = codec->spec;
4709 int err;
4710 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4711
4712 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4713 alc262_ignore)) < 0)
4714 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004715 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01004716 return 0; /* can't find valid BIOS pin config */
4717 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4718 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4719 return err;
4720
4721 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4722
4723 if (spec->autocfg.dig_out_pin)
4724 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
4725 if (spec->autocfg.dig_in_pin)
4726 spec->dig_in_nid = ALC262_DIGIN_NID;
4727
4728 if (spec->kctl_alloc)
4729 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4730
4731 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
4732 spec->input_mux = &spec->private_imux;
4733
4734 return 1;
4735}
4736
4737#define alc262_auto_init_multi_out alc882_auto_init_multi_out
4738#define alc262_auto_init_hp_out alc882_auto_init_hp_out
4739#define alc262_auto_init_analog_input alc882_auto_init_analog_input
4740
4741
4742/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004743static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004744{
Kailang Yangdf694da2005-12-05 19:42:22 +01004745 alc262_auto_init_multi_out(codec);
4746 alc262_auto_init_hp_out(codec);
4747 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004748}
4749
4750/*
4751 * configuration and preset
4752 */
4753static struct hda_board_config alc262_cfg_tbl[] = {
4754 { .modelname = "basic", .config = ALC262_BASIC },
Takashi Iwai834be882006-03-01 14:16:17 +01004755 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
4756 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
Kailang Yangdf694da2005-12-05 19:42:22 +01004757 { .modelname = "auto", .config = ALC262_AUTO },
4758 {}
4759};
4760
4761static struct alc_config_preset alc262_presets[] = {
4762 [ALC262_BASIC] = {
4763 .mixers = { alc262_base_mixer },
4764 .init_verbs = { alc262_init_verbs },
4765 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4766 .dac_nids = alc262_dac_nids,
4767 .hp_nid = 0x03,
4768 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4769 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004770 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01004771 },
Takashi Iwai834be882006-03-01 14:16:17 +01004772 [ALC262_FUJITSU] = {
4773 .mixers = { alc262_fujitsu_mixer },
4774 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
4775 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4776 .dac_nids = alc262_dac_nids,
4777 .hp_nid = 0x03,
4778 .dig_out_nid = ALC262_DIGOUT_NID,
4779 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4780 .channel_mode = alc262_modes,
4781 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004782 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01004783 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004784};
4785
4786static int patch_alc262(struct hda_codec *codec)
4787{
4788 struct alc_spec *spec;
4789 int board_config;
4790 int err;
4791
4792 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4793 if (spec == NULL)
4794 return -ENOMEM;
4795
4796 codec->spec = spec;
4797#if 0
4798 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4799 {
4800 int tmp;
4801 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4802 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4803 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4804 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4805 }
4806#endif
4807
4808 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
4809 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4810 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
4811 board_config = ALC262_AUTO;
4812 }
4813
4814 if (board_config == ALC262_AUTO) {
4815 /* automatic parse from the BIOS config */
4816 err = alc262_parse_auto_config(codec);
4817 if (err < 0) {
4818 alc_free(codec);
4819 return err;
4820 } else if (! err) {
4821 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4822 board_config = ALC262_BASIC;
4823 }
4824 }
4825
4826 if (board_config != ALC262_AUTO)
4827 setup_preset(spec, &alc262_presets[board_config]);
4828
4829 spec->stream_name_analog = "ALC262 Analog";
4830 spec->stream_analog_playback = &alc262_pcm_analog_playback;
4831 spec->stream_analog_capture = &alc262_pcm_analog_capture;
4832
4833 spec->stream_name_digital = "ALC262 Digital";
4834 spec->stream_digital_playback = &alc262_pcm_digital_playback;
4835 spec->stream_digital_capture = &alc262_pcm_digital_capture;
4836
4837 if (! spec->adc_nids && spec->input_mux) {
4838 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004839 unsigned int wcap = get_wcaps(codec, 0x07);
4840
Kailang Yangdf694da2005-12-05 19:42:22 +01004841 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4842 if (wcap != AC_WID_AUD_IN) {
4843 spec->adc_nids = alc262_adc_nids_alt;
4844 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
4845 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
4846 spec->num_mixers++;
4847 } else {
4848 spec->adc_nids = alc262_adc_nids;
4849 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
4850 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
4851 spec->num_mixers++;
4852 }
4853 }
4854
4855 codec->patch_ops = alc_patch_ops;
4856 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004857 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01004858
Kailang Yangdf694da2005-12-05 19:42:22 +01004859 return 0;
4860}
4861
4862
4863/*
4864 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4865 */
4866
4867/*
4868 * set the path ways for 2 channel output
4869 * need to set the codec line out and mic 1 pin widgets to inputs
4870 */
4871static struct hda_verb alc861_threestack_ch2_init[] = {
4872 /* set pin widget 1Ah (line in) for input */
4873 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4874 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4875 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4876
4877 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4878 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4879 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4880 { } /* end */
4881};
4882/*
4883 * 6ch mode
4884 * need to set the codec line out and mic 1 pin widgets to outputs
4885 */
4886static struct hda_verb alc861_threestack_ch6_init[] = {
4887 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4888 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4889 /* set pin widget 18h (mic1) for output (CLFE)*/
4890 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4891
4892 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4893 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4894
4895 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4896 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4897 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4898 { } /* end */
4899};
4900
4901static struct hda_channel_mode alc861_threestack_modes[2] = {
4902 { 2, alc861_threestack_ch2_init },
4903 { 6, alc861_threestack_ch6_init },
4904};
4905
4906/* patch-ALC861 */
4907
4908static struct snd_kcontrol_new alc861_base_mixer[] = {
4909 /* output mixer control */
4910 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4911 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4912 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4914 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
4915
4916 /*Input mixer control */
4917 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4918 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4919 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4920 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4921 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4922 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4924 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4927
4928 /* Capture mixer control */
4929 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4930 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4931 {
4932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4933 .name = "Capture Source",
4934 .count = 1,
4935 .info = alc_mux_enum_info,
4936 .get = alc_mux_enum_get,
4937 .put = alc_mux_enum_put,
4938 },
4939 { } /* end */
4940};
4941
4942static struct snd_kcontrol_new alc861_3ST_mixer[] = {
4943 /* output mixer control */
4944 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4945 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4946 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4948 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4949
4950 /* Input mixer control */
4951 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4952 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4953 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4954 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4955 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4956 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4958 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4961
4962 /* Capture mixer control */
4963 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4964 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4965 {
4966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4967 .name = "Capture Source",
4968 .count = 1,
4969 .info = alc_mux_enum_info,
4970 .get = alc_mux_enum_get,
4971 .put = alc_mux_enum_put,
4972 },
4973 {
4974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4975 .name = "Channel Mode",
4976 .info = alc_ch_mode_info,
4977 .get = alc_ch_mode_get,
4978 .put = alc_ch_mode_put,
4979 .private_value = ARRAY_SIZE(alc861_threestack_modes),
4980 },
4981 { } /* end */
4982};
4983
4984/*
4985 * generic initialization of ADC, input mixers and output mixers
4986 */
4987static struct hda_verb alc861_base_init_verbs[] = {
4988 /*
4989 * Unmute ADC0 and set the default input to mic-in
4990 */
4991 /* port-A for surround (rear panel) */
4992 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4993 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
4994 /* port-B for mic-in (rear panel) with vref */
4995 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4996 /* port-C for line-in (rear panel) */
4997 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4998 /* port-D for Front */
4999 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5000 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5001 /* port-E for HP out (front panel) */
5002 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5003 /* route front PCM to HP */
5004 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5005 /* port-F for mic-in (front panel) with vref */
5006 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5007 /* port-G for CLFE (rear panel) */
5008 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5009 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
5010 /* port-H for side (rear panel) */
5011 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5012 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
5013 /* CD-in */
5014 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5015 /* route front mic to ADC1*/
5016 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5018
5019 /* Unmute DAC0~3 & spdif out*/
5020 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5021 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5022 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5023 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5025
5026 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5027 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5028 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5029 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5030 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5031
5032 /* Unmute Stereo Mixer 15 */
5033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5037
5038 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5039 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5041 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5048
5049 { }
5050};
5051
5052static struct hda_verb alc861_threestack_init_verbs[] = {
5053 /*
5054 * Unmute ADC0 and set the default input to mic-in
5055 */
5056 /* port-A for surround (rear panel) */
5057 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5058 /* port-B for mic-in (rear panel) with vref */
5059 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5060 /* port-C for line-in (rear panel) */
5061 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5062 /* port-D for Front */
5063 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5064 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5065 /* port-E for HP out (front panel) */
5066 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5067 /* route front PCM to HP */
5068 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5069 /* port-F for mic-in (front panel) with vref */
5070 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5071 /* port-G for CLFE (rear panel) */
5072 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5073 /* port-H for side (rear panel) */
5074 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5075 /* CD-in */
5076 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5077 /* route front mic to ADC1*/
5078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5080 /* Unmute DAC0~3 & spdif out*/
5081 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5082 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5083 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5084 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5086
5087 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5088 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5089 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5090 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5091 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5092
5093 /* Unmute Stereo Mixer 15 */
5094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5095 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5098
5099 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5100 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5101 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5102 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5103 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5104 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5105 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5106 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5109 { }
5110};
5111/*
5112 * generic initialization of ADC, input mixers and output mixers
5113 */
5114static struct hda_verb alc861_auto_init_verbs[] = {
5115 /*
5116 * Unmute ADC0 and set the default input to mic-in
5117 */
5118// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5120
5121 /* Unmute DAC0~3 & spdif out*/
5122 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5123 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5124 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5125 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5127
5128 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5129 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5130 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5131 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5132 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5133
5134 /* Unmute Stereo Mixer 15 */
5135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
5139
5140 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5141 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5142 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5143 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5144 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5148
5149 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5150 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5151 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5152 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5153 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5154 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5155 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5156 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5157
5158 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
5159
5160 { }
5161};
5162
5163/* pcm configuration: identiacal with ALC880 */
5164#define alc861_pcm_analog_playback alc880_pcm_analog_playback
5165#define alc861_pcm_analog_capture alc880_pcm_analog_capture
5166#define alc861_pcm_digital_playback alc880_pcm_digital_playback
5167#define alc861_pcm_digital_capture alc880_pcm_digital_capture
5168
5169
5170#define ALC861_DIGOUT_NID 0x07
5171
5172static struct hda_channel_mode alc861_8ch_modes[1] = {
5173 { 8, NULL }
5174};
5175
5176static hda_nid_t alc861_dac_nids[4] = {
5177 /* front, surround, clfe, side */
5178 0x03, 0x06, 0x05, 0x04
5179};
5180
5181static hda_nid_t alc861_adc_nids[1] = {
5182 /* ADC0-2 */
5183 0x08,
5184};
5185
5186static struct hda_input_mux alc861_capture_source = {
5187 .num_items = 5,
5188 .items = {
5189 { "Mic", 0x0 },
5190 { "Front Mic", 0x3 },
5191 { "Line", 0x1 },
5192 { "CD", 0x4 },
5193 { "Mixer", 0x5 },
5194 },
5195};
5196
5197/* fill in the dac_nids table from the parsed pin configuration */
5198static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5199{
5200 int i;
5201 hda_nid_t nid;
5202
5203 spec->multiout.dac_nids = spec->private_dac_nids;
5204 for (i = 0; i < cfg->line_outs; i++) {
5205 nid = cfg->line_out_pins[i];
5206 if (nid) {
5207 if (i >= ARRAY_SIZE(alc861_dac_nids))
5208 continue;
5209 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
5210 }
5211 }
5212 spec->multiout.num_dacs = cfg->line_outs;
5213 return 0;
5214}
5215
5216/* add playback controls from the parsed DAC table */
5217static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
5218 const struct auto_pin_cfg *cfg)
5219{
5220 char name[32];
5221 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
5222 hda_nid_t nid;
5223 int i, idx, err;
5224
5225 for (i = 0; i < cfg->line_outs; i++) {
5226 nid = spec->multiout.dac_nids[i];
5227 if (! nid)
5228 continue;
5229 if (nid == 0x05) {
5230 /* Center/LFE */
5231 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
5232 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
5233 return err;
5234 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
5235 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5236 return err;
5237 } else {
5238 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
5239 if (nid == alc861_dac_nids[idx])
5240 break;
5241 sprintf(name, "%s Playback Switch", chname[idx]);
5242 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
5243 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5244 return err;
5245 }
5246 }
5247 return 0;
5248}
5249
5250static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
5251{
5252 int err;
5253 hda_nid_t nid;
5254
5255 if (! pin)
5256 return 0;
5257
5258 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
5259 nid = 0x03;
5260 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5261 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5262 return err;
5263 spec->multiout.hp_nid = nid;
5264 }
5265 return 0;
5266}
5267
5268/* create playback/capture controls for input pins */
5269static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5270{
Kailang Yangdf694da2005-12-05 19:42:22 +01005271 struct hda_input_mux *imux = &spec->private_imux;
5272 int i, err, idx, idx1;
5273
5274 for (i = 0; i < AUTO_PIN_LAST; i++) {
5275 switch(cfg->input_pins[i]) {
5276 case 0x0c:
5277 idx1 = 1;
5278 idx = 2; // Line In
5279 break;
5280 case 0x0f:
5281 idx1 = 2;
5282 idx = 2; // Line In
5283 break;
5284 case 0x0d:
5285 idx1 = 0;
5286 idx = 1; // Mic In
5287 break;
5288 case 0x10:
5289 idx1 = 3;
5290 idx = 1; // Mic In
5291 break;
5292 case 0x11:
5293 idx1 = 4;
5294 idx = 0; // CD
5295 break;
5296 default:
5297 continue;
5298 }
5299
Takashi Iwai4a471b72005-12-07 13:56:29 +01005300 err = new_analog_input(spec, cfg->input_pins[i],
5301 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01005302 if (err < 0)
5303 return err;
5304
Takashi Iwai4a471b72005-12-07 13:56:29 +01005305 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 imux->items[imux->num_items].index = idx1;
5307 imux->num_items++;
5308 }
5309 return 0;
5310}
5311
5312static struct snd_kcontrol_new alc861_capture_mixer[] = {
5313 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5314 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5315
5316 {
5317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5318 /* The multiple "Capture Source" controls confuse alsamixer
5319 * So call somewhat different..
5320 *FIXME: the controls appear in the "playback" view!
5321 */
5322 /* .name = "Capture Source", */
5323 .name = "Input Source",
5324 .count = 1,
5325 .info = alc_mux_enum_info,
5326 .get = alc_mux_enum_get,
5327 .put = alc_mux_enum_put,
5328 },
5329 { } /* end */
5330};
5331
5332static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
5333 int pin_type, int dac_idx)
5334{
5335 /* set as output */
5336
5337 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
5338 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5339
5340}
5341
5342static void alc861_auto_init_multi_out(struct hda_codec *codec)
5343{
5344 struct alc_spec *spec = codec->spec;
5345 int i;
5346
5347 for (i = 0; i < spec->autocfg.line_outs; i++) {
5348 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5349 if (nid)
5350 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
5351 }
5352}
5353
5354static void alc861_auto_init_hp_out(struct hda_codec *codec)
5355{
5356 struct alc_spec *spec = codec->spec;
5357 hda_nid_t pin;
5358
5359 pin = spec->autocfg.hp_pin;
5360 if (pin) /* connect to front */
5361 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
5362}
5363
5364static void alc861_auto_init_analog_input(struct hda_codec *codec)
5365{
5366 struct alc_spec *spec = codec->spec;
5367 int i;
5368
5369 for (i = 0; i < AUTO_PIN_LAST; i++) {
5370 hda_nid_t nid = spec->autocfg.input_pins[i];
5371 if ((nid>=0x0c) && (nid <=0x11)) {
5372 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5373 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
5374 }
5375 }
5376}
5377
5378/* parse the BIOS configuration and set up the alc_spec */
5379/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
5380static int alc861_parse_auto_config(struct hda_codec *codec)
5381{
5382 struct alc_spec *spec = codec->spec;
5383 int err;
5384 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5385
5386 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5387 alc861_ignore)) < 0)
5388 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005389 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005390 return 0; /* can't find valid BIOS pin config */
5391
5392 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
5393 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5394 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
5395 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5396 return err;
5397
5398 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5399
5400 if (spec->autocfg.dig_out_pin)
5401 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
5402
5403 if (spec->kctl_alloc)
5404 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5405
5406 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
5407
5408 spec->input_mux = &spec->private_imux;
5409
5410 spec->adc_nids = alc861_adc_nids;
5411 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
5412 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
5413 spec->num_mixers++;
5414
5415 return 1;
5416}
5417
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005418/* additional initialization for auto-configuration model */
5419static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005420{
Kailang Yangdf694da2005-12-05 19:42:22 +01005421 alc861_auto_init_multi_out(codec);
5422 alc861_auto_init_hp_out(codec);
5423 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005424}
5425
5426
5427/*
5428 * configuration and preset
5429 */
5430static struct hda_board_config alc861_cfg_tbl[] = {
5431 { .modelname = "3stack", .config = ALC861_3ST },
5432 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
5433 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
5434 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
5435 { .modelname = "auto", .config = ALC861_AUTO },
5436 {}
5437};
5438
5439static struct alc_config_preset alc861_presets[] = {
5440 [ALC861_3ST] = {
5441 .mixers = { alc861_3ST_mixer },
5442 .init_verbs = { alc861_threestack_init_verbs },
5443 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5444 .dac_nids = alc861_dac_nids,
5445 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5446 .channel_mode = alc861_threestack_modes,
5447 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5448 .adc_nids = alc861_adc_nids,
5449 .input_mux = &alc861_capture_source,
5450 },
5451 [ALC861_3ST_DIG] = {
5452 .mixers = { alc861_base_mixer },
5453 .init_verbs = { alc861_threestack_init_verbs },
5454 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5455 .dac_nids = alc861_dac_nids,
5456 .dig_out_nid = ALC861_DIGOUT_NID,
5457 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5458 .channel_mode = alc861_threestack_modes,
5459 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5460 .adc_nids = alc861_adc_nids,
5461 .input_mux = &alc861_capture_source,
5462 },
5463 [ALC861_6ST_DIG] = {
5464 .mixers = { alc861_base_mixer },
5465 .init_verbs = { alc861_base_init_verbs },
5466 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5467 .dac_nids = alc861_dac_nids,
5468 .dig_out_nid = ALC861_DIGOUT_NID,
5469 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
5470 .channel_mode = alc861_8ch_modes,
5471 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5472 .adc_nids = alc861_adc_nids,
5473 .input_mux = &alc861_capture_source,
5474 },
5475};
5476
5477
5478static int patch_alc861(struct hda_codec *codec)
5479{
5480 struct alc_spec *spec;
5481 int board_config;
5482 int err;
5483
5484 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5485 if (spec == NULL)
5486 return -ENOMEM;
5487
5488 codec->spec = spec;
5489
5490 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
5491 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
5492 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
5493 board_config = ALC861_AUTO;
5494 }
5495
5496 if (board_config == ALC861_AUTO) {
5497 /* automatic parse from the BIOS config */
5498 err = alc861_parse_auto_config(codec);
5499 if (err < 0) {
5500 alc_free(codec);
5501 return err;
5502 } else if (! err) {
5503 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5504 board_config = ALC861_3ST_DIG;
5505 }
5506 }
5507
5508 if (board_config != ALC861_AUTO)
5509 setup_preset(spec, &alc861_presets[board_config]);
5510
5511 spec->stream_name_analog = "ALC861 Analog";
5512 spec->stream_analog_playback = &alc861_pcm_analog_playback;
5513 spec->stream_analog_capture = &alc861_pcm_analog_capture;
5514
5515 spec->stream_name_digital = "ALC861 Digital";
5516 spec->stream_digital_playback = &alc861_pcm_digital_playback;
5517 spec->stream_digital_capture = &alc861_pcm_digital_capture;
5518
5519 codec->patch_ops = alc_patch_ops;
5520 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005521 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01005522
5523 return 0;
5524}
5525
5526/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07005527 * patch entries
5528 */
5529struct hda_codec_preset snd_hda_preset_realtek[] = {
5530 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005531 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07005532 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
5533 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
5535 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5536 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07005537 {} /* terminator */
5538};