blob: 18d105263feae7795bf965424bb3c5c81df13037 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
35
36/* ALC880 board config type */
37enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ALC880_3ST,
39 ALC880_3ST_DIG,
40 ALC880_5ST,
41 ALC880_5ST_DIG,
42 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020043 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020044 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020045 ALC880_6ST_DIG,
46 ALC880_F1734,
47 ALC880_ASUS,
48 ALC880_ASUS_DIG,
49 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010050 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020051 ALC880_UNIWILL_DIG,
Kailang Yangdf694da2005-12-05 19:42:22 +010052 ALC880_CLEVO,
53 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010054 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010055 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020056#ifdef CONFIG_SND_DEBUG
57 ALC880_TEST,
58#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020060 ALC880_MODEL_LAST /* last tag */
61};
62
63/* ALC260 models */
64enum {
65 ALC260_BASIC,
66 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC260_HP_3013,
68 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010069 ALC260_ACER,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010070#ifdef CONFIG_SND_DEBUG
71 ALC260_TEST,
72#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020074 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Kailang Yangdf694da2005-12-05 19:42:22 +010077/* ALC262 models */
78enum {
79 ALC262_BASIC,
Takashi Iwai834be882006-03-01 14:16:17 +010080 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020081 ALC262_HP_BPC,
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC262_AUTO,
83 ALC262_MODEL_LAST /* last tag */
84};
85
86/* ALC861 models */
87enum {
88 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020089 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +010090 ALC861_3ST_DIG,
91 ALC861_6ST_DIG,
92 ALC861_AUTO,
93 ALC861_MODEL_LAST,
94};
95
96/* ALC882 models */
97enum {
98 ALC882_3ST_DIG,
99 ALC882_6ST_DIG,
100 ALC882_AUTO,
101 ALC882_MODEL_LAST,
102};
103
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200104/* ALC883 models */
105enum {
106 ALC883_3ST_2ch_DIG,
107 ALC883_3ST_6ch_DIG,
108 ALC883_3ST_6ch,
109 ALC883_6ST_DIG,
110 ALC888_DEMO_BOARD,
111 ALC883_AUTO,
112 ALC883_MODEL_LAST,
113};
114
Kailang Yangdf694da2005-12-05 19:42:22 +0100115/* for GPIO Poll */
116#define GPIO_MASK 0x03
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118struct alc_spec {
119 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100120 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 unsigned int num_mixers;
122
Kailang Yangdf694da2005-12-05 19:42:22 +0100123 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200124 * don't forget NULL
125 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200126 */
127 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Takashi Iwai16ded522005-06-10 19:58:24 +0200129 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 struct hda_pcm_stream *stream_analog_playback;
131 struct hda_pcm_stream *stream_analog_capture;
132
Takashi Iwai16ded522005-06-10 19:58:24 +0200133 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 struct hda_pcm_stream *stream_digital_playback;
135 struct hda_pcm_stream *stream_digital_capture;
136
137 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200138 struct hda_multi_out multiout; /* playback set-up
139 * max_channels, dacs must be set
140 * dig_out_nid and hp_nid are optional
141 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143 /* capture */
144 unsigned int num_adc_nids;
145 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200146 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200149 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 const struct hda_input_mux *input_mux;
151 unsigned int cur_mux[3];
152
153 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100154 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 int num_channel_mode;
156
157 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100158 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200159
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200160 /* dynamic controls, init_verbs and input_mux */
161 struct auto_pin_cfg autocfg;
162 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100163 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200164 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100165 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100166
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100167 /* hooks */
168 void (*init_hook)(struct hda_codec *codec);
169 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
170
Takashi Iwai834be882006-03-01 14:16:17 +0100171 /* for pin sensing */
172 unsigned int sense_updated: 1;
173 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100174};
175
176/*
177 * configuration template - to be copied to the spec instance
178 */
179struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200180 struct snd_kcontrol_new *mixers[5]; /* should be identical size
181 * with spec
182 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100183 const struct hda_verb *init_verbs[5];
184 unsigned int num_dacs;
185 hda_nid_t *dac_nids;
186 hda_nid_t dig_out_nid; /* optional */
187 hda_nid_t hp_nid; /* optional */
188 unsigned int num_adc_nids;
189 hda_nid_t *adc_nids;
190 hda_nid_t dig_in_nid;
191 unsigned int num_channel_mode;
192 const struct hda_channel_mode *channel_mode;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200193 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100194 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100195 void (*unsol_event)(struct hda_codec *, unsigned int);
196 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197};
198
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200/*
201 * input MUX handling
202 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200203static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
204 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205{
206 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
207 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200208 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
209 if (mux_idx >= spec->num_mux_defs)
210 mux_idx = 0;
211 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212}
213
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200214static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
215 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216{
217 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
218 struct alc_spec *spec = codec->spec;
219 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
220
221 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
222 return 0;
223}
224
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200225static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227{
228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
229 struct alc_spec *spec = codec->spec;
230 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200231 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
232 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200233 spec->adc_nids[adc_idx],
234 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235}
236
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238/*
239 * channel mode setting
240 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200241static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
242 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243{
244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
245 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100246 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
247 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248}
249
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200250static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
251 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252{
253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
254 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100255 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256 spec->num_channel_mode,
257 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258}
259
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200260static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
261 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
264 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100265 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200266 spec->num_channel_mode,
267 &spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268}
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100271 * Control the mode of pin widget settings via the mixer. "pc" is used
272 * instead of "%" to avoid consequences of accidently treating the % as
273 * being part of a format specifier. Maximum allowed length of a value is
274 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100275 *
276 * Note: some retasking pin complexes seem to ignore requests for input
277 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
278 * are requested. Therefore order this list so that this behaviour will not
279 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200280 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
281 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200282 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100283static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100284 "Mic 50pc bias", "Mic 80pc bias",
285 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100286};
287static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100288 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100289};
290/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200291 * in the pin being assumed to be exclusively an input or an output pin. In
292 * addition, "input" pins may or may not process the mic bias option
293 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
294 * accept requests for bias as of chip versions up to March 2006) and/or
295 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100296 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200297#define ALC_PIN_DIR_IN 0x00
298#define ALC_PIN_DIR_OUT 0x01
299#define ALC_PIN_DIR_INOUT 0x02
300#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
301#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100302
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200303/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100304 * For each direction the minimum and maximum values are given.
305 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200306static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100307 { 0, 2 }, /* ALC_PIN_DIR_IN */
308 { 3, 4 }, /* ALC_PIN_DIR_OUT */
309 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200310 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
311 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100312};
313#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
314#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
315#define alc_pin_mode_n_items(_dir) \
316 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
317
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200318static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
319 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200320{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100321 unsigned int item_num = uinfo->value.enumerated.item;
322 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
323
324 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200325 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100326 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
327
328 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
329 item_num = alc_pin_mode_min(dir);
330 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200331 return 0;
332}
333
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200334static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
335 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200336{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100337 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
339 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100340 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200341 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200342 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
343 AC_VERB_GET_PIN_WIDGET_CONTROL,
344 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200345
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100346 /* Find enumerated value for current pinctl setting */
347 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200348 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100349 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200350 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100351 return 0;
352}
353
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200354static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
355 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356{
357 signed int change;
358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
359 hda_nid_t nid = kcontrol->private_value & 0xffff;
360 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
361 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200362 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
363 AC_VERB_GET_PIN_WIDGET_CONTROL,
364 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100367 val = alc_pin_mode_min(dir);
368
369 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100370 if (change) {
371 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200372 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100374
375 /* Also enable the retasking pin's input/output as required
376 * for the requested pin mode. Enum values of 2 or less are
377 * input modes.
378 *
379 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200380 * reduces noise slightly (particularly on input) so we'll
381 * do it. However, having both input and output buffers
382 * enabled simultaneously doesn't seem to be problematic if
383 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100384 */
385 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200386 snd_hda_codec_write(codec, nid, 0,
387 AC_VERB_SET_AMP_GAIN_MUTE,
388 AMP_OUT_MUTE);
389 snd_hda_codec_write(codec, nid, 0,
390 AC_VERB_SET_AMP_GAIN_MUTE,
391 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100392 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200393 snd_hda_codec_write(codec, nid, 0,
394 AC_VERB_SET_AMP_GAIN_MUTE,
395 AMP_IN_MUTE(0));
396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
398 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100399 }
400 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200401 return change;
402}
403
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100404#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200405 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100406 .info = alc_pin_mode_info, \
407 .get = alc_pin_mode_get, \
408 .put = alc_pin_mode_put, \
409 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100410
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100411/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
412 * together using a mask with more than one bit set. This control is
413 * currently used only by the ALC260 test model. At this stage they are not
414 * needed for any "production" models.
415 */
416#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100419{
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}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200426static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100428{
429 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
430 hda_nid_t nid = kcontrol->private_value & 0xffff;
431 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
432 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433 unsigned int val = snd_hda_codec_read(codec, nid, 0,
434 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100435
436 *valp = (val & mask) != 0;
437 return 0;
438}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100441{
442 signed int change;
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 hda_nid_t nid = kcontrol->private_value & 0xffff;
445 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
446 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
448 AC_VERB_GET_GPIO_DATA,
449 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100450
451 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200452 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
453 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100454 gpio_data &= ~mask;
455 else
456 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100458
459 return change;
460}
461#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
462 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
463 .info = alc_gpio_data_info, \
464 .get = alc_gpio_data_get, \
465 .put = alc_gpio_data_put, \
466 .private_value = nid | (mask<<16) }
467#endif /* CONFIG_SND_DEBUG */
468
Jonathan Woithe92621f12006-02-28 11:47:47 +0100469/* A switch control to allow the enabling of the digital IO pins on the
470 * ALC260. This is incredibly simplistic; the intention of this control is
471 * to provide something in the test model allowing digital outputs to be
472 * identified if present. If models are found which can utilise these
473 * outputs a more complete mixer control can be devised for those models if
474 * necessary.
475 */
476#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100479{
480 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
481 uinfo->count = 1;
482 uinfo->value.integer.min = 0;
483 uinfo->value.integer.max = 1;
484 return 0;
485}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100488{
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
490 hda_nid_t nid = kcontrol->private_value & 0xffff;
491 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
492 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200493 unsigned int val = snd_hda_codec_read(codec, nid, 0,
494 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100495
496 *valp = (val & mask) != 0;
497 return 0;
498}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100501{
502 signed int change;
503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
504 hda_nid_t nid = kcontrol->private_value & 0xffff;
505 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
506 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200507 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
508 AC_VERB_GET_DIGI_CONVERT,
509 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100510
511 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200512 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100513 if (val==0)
514 ctrl_data &= ~mask;
515 else
516 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200517 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
518 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100519
520 return change;
521}
522#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
523 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
524 .info = alc_spdif_ctrl_info, \
525 .get = alc_spdif_ctrl_get, \
526 .put = alc_spdif_ctrl_put, \
527 .private_value = nid | (mask<<16) }
528#endif /* CONFIG_SND_DEBUG */
529
Kailang Yangdf694da2005-12-05 19:42:22 +0100530/*
531 * set up from the preset table
532 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533static void setup_preset(struct alc_spec *spec,
534 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100535{
536 int i;
537
538 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
539 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
541 i++)
542 spec->init_verbs[spec->num_init_verbs++] =
543 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100544
545 spec->channel_mode = preset->channel_mode;
546 spec->num_channel_mode = preset->num_channel_mode;
547
548 spec->multiout.max_channels = spec->channel_mode[0].channels;
549
550 spec->multiout.num_dacs = preset->num_dacs;
551 spec->multiout.dac_nids = preset->dac_nids;
552 spec->multiout.dig_out_nid = preset->dig_out_nid;
553 spec->multiout.hp_nid = preset->hp_nid;
554
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200555 spec->num_mux_defs = preset->num_mux_defs;
556 if (! spec->num_mux_defs)
557 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100558 spec->input_mux = preset->input_mux;
559
560 spec->num_adc_nids = preset->num_adc_nids;
561 spec->adc_nids = preset->adc_nids;
562 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100563
564 spec->unsol_event = preset->unsol_event;
565 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100566}
567
Takashi Iwai41e41f12005-06-08 14:48:49 +0200568/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200569 * ALC880 3-stack model
570 *
571 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
573 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 */
575
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200576static hda_nid_t alc880_dac_nids[4] = {
577 /* front, rear, clfe, rear_surr */
578 0x02, 0x05, 0x04, 0x03
579};
580
581static hda_nid_t alc880_adc_nids[3] = {
582 /* ADC0-2 */
583 0x07, 0x08, 0x09,
584};
585
586/* The datasheet says the node 0x07 is connected from inputs,
587 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100588 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200590static hda_nid_t alc880_adc_nids_alt[2] = {
591 /* ADC1-2 */
592 0x08, 0x09,
593};
594
595#define ALC880_DIGOUT_NID 0x06
596#define ALC880_DIGIN_NID 0x0a
597
598static struct hda_input_mux alc880_capture_source = {
599 .num_items = 4,
600 .items = {
601 { "Mic", 0x0 },
602 { "Front Mic", 0x3 },
603 { "Line", 0x2 },
604 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200606};
607
608/* channel source setting (2/6 channel selection for 3-stack) */
609/* 2ch mode */
610static struct hda_verb alc880_threestack_ch2_init[] = {
611 /* set line-in to input, mute it */
612 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
613 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
614 /* set mic-in to input vref 80%, mute it */
615 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 { } /* end */
618};
619
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200620/* 6ch mode */
621static struct hda_verb alc880_threestack_ch6_init[] = {
622 /* set line-in to output, unmute it */
623 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
624 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
625 /* set mic-in to output, unmute it */
626 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
627 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
628 { } /* end */
629};
630
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100631static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200632 { 2, alc880_threestack_ch2_init },
633 { 6, alc880_threestack_ch6_init },
634};
635
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100636static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200637 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200639 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100640 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200641 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
642 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100643 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
644 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
653 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
654 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200656 {
657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
658 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100659 .info = alc_ch_mode_info,
660 .get = alc_ch_mode_get,
661 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200662 },
663 { } /* end */
664};
665
666/* capture mixer elements */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100667static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200668 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
669 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
670 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
671 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
672 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
673 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
674 {
675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
676 /* The multiple "Capture Source" controls confuse alsamixer
677 * So call somewhat different..
678 * FIXME: the controls appear in the "playback" view!
679 */
680 /* .name = "Capture Source", */
681 .name = "Input Source",
682 .count = 3,
683 .info = alc_mux_enum_info,
684 .get = alc_mux_enum_get,
685 .put = alc_mux_enum_put,
686 },
687 { } /* end */
688};
689
690/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100691static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200692 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
693 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
694 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
695 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 {
697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
698 /* The multiple "Capture Source" controls confuse alsamixer
699 * So call somewhat different..
700 * FIXME: the controls appear in the "playback" view!
701 */
702 /* .name = "Capture Source", */
703 .name = "Input Source",
704 .count = 2,
705 .info = alc_mux_enum_info,
706 .get = alc_mux_enum_get,
707 .put = alc_mux_enum_put,
708 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 { } /* end */
710};
711
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200712
713
714/*
715 * ALC880 5-stack model
716 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
718 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200719 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
720 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
721 */
722
723/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100724static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200725 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100726 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 { } /* end */
728};
729
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200730/* channel source setting (6/8 channel selection for 5-stack) */
731/* 6ch mode */
732static struct hda_verb alc880_fivestack_ch6_init[] = {
733 /* set line-in to input, mute it */
734 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
735 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200736 { } /* end */
737};
738
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200739/* 8ch mode */
740static struct hda_verb alc880_fivestack_ch8_init[] = {
741 /* set line-in to output, unmute it */
742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
744 { } /* end */
745};
746
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100747static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200748 { 6, alc880_fivestack_ch6_init },
749 { 8, alc880_fivestack_ch8_init },
750};
751
752
753/*
754 * ALC880 6-stack model
755 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200756 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
757 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200758 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
759 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
760 */
761
762static hda_nid_t alc880_6st_dac_nids[4] = {
763 /* front, rear, clfe, rear_surr */
764 0x02, 0x03, 0x04, 0x05
765};
766
767static struct hda_input_mux alc880_6stack_capture_source = {
768 .num_items = 4,
769 .items = {
770 { "Mic", 0x0 },
771 { "Front Mic", 0x1 },
772 { "Line", 0x2 },
773 { "CD", 0x4 },
774 },
775};
776
777/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100778static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200779 { 8, NULL },
780};
781
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100782static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100786 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
788 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200791 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100792 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
801 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
802 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200803 {
804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
805 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100806 .info = alc_ch_mode_info,
807 .get = alc_ch_mode_get,
808 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200809 },
810 { } /* end */
811};
812
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200813
814/*
815 * ALC880 W810 model
816 *
817 * W810 has rear IO for:
818 * Front (DAC 02)
819 * Surround (DAC 03)
820 * Center/LFE (DAC 04)
821 * Digital out (06)
822 *
823 * The system also has a pair of internal speakers, and a headphone jack.
824 * These are both connected to Line2 on the codec, hence to DAC 02.
825 *
826 * There is a variable resistor to control the speaker or headphone
827 * volume. This is a hardware-only device without a software API.
828 *
829 * Plugging headphones in will disable the internal speakers. This is
830 * implemented in hardware, not via the driver using jack sense. In
831 * a similar fashion, plugging into the rear socket marked "front" will
832 * disable both the speakers and headphones.
833 *
834 * For input, there's a microphone jack, and an "audio in" jack.
835 * These may not do anything useful with this driver yet, because I
836 * haven't setup any initialization verbs for these yet...
837 */
838
839static hda_nid_t alc880_w810_dac_nids[3] = {
840 /* front, rear/surround, clfe */
841 0x02, 0x03, 0x04
842};
843
844/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100845static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200846 { 6, NULL }
847};
848
849/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100850static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100852 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100854 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200855 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
860 { } /* end */
861};
862
863
864/*
865 * Z710V model
866 *
867 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200868 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
869 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200870 */
871
872static hda_nid_t alc880_z71v_dac_nids[1] = {
873 0x02
874};
875#define ALC880_Z71V_HP_DAC 0x03
876
877/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100878static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200879 { 2, NULL }
880};
881
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100882static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200885 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100886 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
891 { } /* end */
892};
893
894
895/* FIXME! */
896/*
897 * ALC880 F1734 model
898 *
899 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
900 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
901 */
902
903static hda_nid_t alc880_f1734_dac_nids[1] = {
904 0x03
905};
906#define ALC880_F1734_HP_DAC 0x02
907
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100908static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200909 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100910 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200911 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100912 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200917 { } /* end */
918};
919
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200920
921/* FIXME! */
922/*
923 * ALC880 ASUS model
924 *
925 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
926 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
927 * Mic = 0x18, Line = 0x1a
928 */
929
930#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
931#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
932
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100933static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100937 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200942 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
943 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
945 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200948 {
949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
950 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100951 .info = alc_ch_mode_info,
952 .get = alc_ch_mode_get,
953 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200954 },
955 { } /* end */
956};
957
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200958/* FIXME! */
959/*
960 * ALC880 ASUS W1V model
961 *
962 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
963 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
964 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
965 */
966
967/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100968static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200969 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
970 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200971 { } /* end */
972};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200973
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200974/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100975static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200976 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
977 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
978 { } /* end */
979};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200980
Kailang Yangdf694da2005-12-05 19:42:22 +0100981/* TCL S700 */
982static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
984 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
987 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
990 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
991 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
992 {
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
994 /* The multiple "Capture Source" controls confuse alsamixer
995 * So call somewhat different..
996 * FIXME: the controls appear in the "playback" view!
997 */
998 /* .name = "Capture Source", */
999 .name = "Input Source",
1000 .count = 1,
1001 .info = alc_mux_enum_info,
1002 .get = alc_mux_enum_get,
1003 .put = alc_mux_enum_put,
1004 },
1005 { } /* end */
1006};
1007
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001009 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 */
1011static int alc_build_controls(struct hda_codec *codec)
1012{
1013 struct alc_spec *spec = codec->spec;
1014 int err;
1015 int i;
1016
1017 for (i = 0; i < spec->num_mixers; i++) {
1018 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1019 if (err < 0)
1020 return err;
1021 }
1022
1023 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001024 err = snd_hda_create_spdif_out_ctls(codec,
1025 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 if (err < 0)
1027 return err;
1028 }
1029 if (spec->dig_in_nid) {
1030 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1031 if (err < 0)
1032 return err;
1033 }
1034 return 0;
1035}
1036
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038/*
1039 * initialize the codec volumes, etc
1040 */
1041
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042/*
1043 * generic initialization of ADC, input mixers and output mixers
1044 */
1045static struct hda_verb alc880_volume_init_verbs[] = {
1046 /*
1047 * Unmute ADC0-2 and set the default input to mic-in
1048 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001049 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001051 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001052 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001053 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001056 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1057 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001058 * Note: PASD motherboards uses the Line In 2 as the input for front
1059 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001068 /*
1069 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 /* set vol=0 to output mixers */
1072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1075 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1076 /* set up input amps for analog loopback */
1077 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086
1087 { }
1088};
1089
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001090/*
1091 * 3-stack pin configuration:
1092 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1093 */
1094static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1095 /*
1096 * preset connection lists of input pins
1097 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1098 */
1099 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1100 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1101 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1102
1103 /*
1104 * Set pin mode and muting
1105 */
1106 /* set front pin widgets 0x14 for output */
1107 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1109 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1110 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1111 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1112 /* Mic2 (as headphone out) for HP output */
1113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1115 /* Line In pin widget for input */
1116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1118 /* Line2 (as front mic) pin widget for input and vref at 80% */
1119 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1120 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1121 /* CD pin widget for input */
1122 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1123
1124 { }
1125};
1126
1127/*
1128 * 5-stack pin configuration:
1129 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1130 * line-in/side = 0x1a, f-mic = 0x1b
1131 */
1132static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1133 /*
1134 * preset connection lists of input pins
1135 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1136 */
1137 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1138 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1139
1140 /*
1141 * Set pin mode and muting
1142 */
1143 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1146 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1147 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148 /* unmute pins for output (no gain on this amp) */
1149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1151 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1152 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1153
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001155 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1157 /* Mic2 (as headphone out) for HP output */
1158 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001159 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001160 /* Line In pin widget for input */
1161 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1162 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1163 /* Line2 (as front mic) pin widget for input and vref at 80% */
1164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1165 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1166 /* CD pin widget for input */
1167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168
1169 { }
1170};
1171
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001172/*
1173 * W810 pin configuration:
1174 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1175 */
1176static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 /* hphone/speaker input selector: front DAC */
1178 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1179
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1185 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1186
1187 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001188 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 { }
1191};
1192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001193/*
1194 * Z71V pin configuration:
1195 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1196 */
1197static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001202
Takashi Iwai16ded522005-06-10 19:58:24 +02001203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001207
1208 { }
1209};
1210
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001211/*
1212 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001213 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1214 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001215 */
1216static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1217 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1218
Takashi Iwai16ded522005-06-10 19:58:24 +02001219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001223 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001225 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1227
Takashi Iwai16ded522005-06-10 19:58:24 +02001228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238 { }
1239};
Takashi Iwai16ded522005-06-10 19:58:24 +02001240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001241/* FIXME! */
1242/*
1243 * F1734 pin configuration:
1244 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1245 */
1246static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1247 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1248 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1249 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1250 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1251
1252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1256
1257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1259 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1260 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1261 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001266
1267 { }
1268};
1269
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001270/* FIXME! */
1271/*
1272 * ASUS pin configuration:
1273 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1274 */
1275static struct hda_verb alc880_pin_asus_init_verbs[] = {
1276 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1277 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1278 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1279 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1280
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1288 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1289
1290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1291 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1292 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1296 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1299
1300 { }
1301};
1302
1303/* Enable GPIO mask and set output */
1304static struct hda_verb alc880_gpio1_init_verbs[] = {
1305 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1306 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1307 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001308
1309 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001310};
1311
1312/* Enable GPIO mask and set output */
1313static struct hda_verb alc880_gpio2_init_verbs[] = {
1314 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1315 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1316 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001317
1318 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001319};
1320
Kailang Yangdf694da2005-12-05 19:42:22 +01001321/* Clevo m520g init */
1322static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1323 /* headphone output */
1324 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1325 /* line-out */
1326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1328 /* Line-in */
1329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1330 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1331 /* CD */
1332 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1333 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1334 /* Mic1 (rear panel) */
1335 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1337 /* Mic2 (front panel) */
1338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1340 /* headphone */
1341 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1342 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1343 /* change to EAPD mode */
1344 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1345 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1346
1347 { }
1348};
1349
1350static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1351 /* Headphone output */
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1353 /* Front output*/
1354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1356
1357 /* Line In pin widget for input */
1358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1359 /* CD pin widget for input */
1360 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1361 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1363
1364 /* change to EAPD mode */
1365 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1366 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1367
1368 { }
1369};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001370
1371/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001372 * LG m1 express dual
1373 *
1374 * Pin assignment:
1375 * Rear Line-In/Out (blue): 0x14
1376 * Build-in Mic-In: 0x15
1377 * Speaker-out: 0x17
1378 * HP-Out (green): 0x1b
1379 * Mic-In/Out (red): 0x19
1380 * SPDIF-Out: 0x1e
1381 */
1382
1383/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1384static hda_nid_t alc880_lg_dac_nids[3] = {
1385 0x05, 0x02, 0x03
1386};
1387
1388/* seems analog CD is not working */
1389static struct hda_input_mux alc880_lg_capture_source = {
1390 .num_items = 3,
1391 .items = {
1392 { "Mic", 0x1 },
1393 { "Line", 0x5 },
1394 { "Internal Mic", 0x6 },
1395 },
1396};
1397
1398/* 2,4,6 channel modes */
1399static struct hda_verb alc880_lg_ch2_init[] = {
1400 /* set line-in and mic-in to input */
1401 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1402 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1403 { }
1404};
1405
1406static struct hda_verb alc880_lg_ch4_init[] = {
1407 /* set line-in to out and mic-in to input */
1408 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1409 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1410 { }
1411};
1412
1413static struct hda_verb alc880_lg_ch6_init[] = {
1414 /* set line-in and mic-in to output */
1415 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1416 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1417 { }
1418};
1419
1420static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1421 { 2, alc880_lg_ch2_init },
1422 { 4, alc880_lg_ch4_init },
1423 { 6, alc880_lg_ch6_init },
1424};
1425
1426static struct snd_kcontrol_new alc880_lg_mixer[] = {
1427 /* FIXME: it's not really "master" but front channels */
1428 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1429 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1430 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1431 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1432 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1433 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1434 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1435 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1436 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1438 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1439 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1440 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1441 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1442 {
1443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1444 .name = "Channel Mode",
1445 .info = alc_ch_mode_info,
1446 .get = alc_ch_mode_get,
1447 .put = alc_ch_mode_put,
1448 },
1449 { } /* end */
1450};
1451
1452static struct hda_verb alc880_lg_init_verbs[] = {
1453 /* set capture source to mic-in */
1454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1457 /* mute all amp mixer inputs */
1458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1460 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1461 /* line-in to input */
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 /* built-in mic */
1465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 /* speaker-out */
1468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 /* mic-in to input */
1471 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1474 /* HP-out */
1475 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1478 /* jack sense */
1479 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1480 { }
1481};
1482
1483/* toggle speaker-output according to the hp-jack state */
1484static void alc880_lg_automute(struct hda_codec *codec)
1485{
1486 unsigned int present;
1487
1488 present = snd_hda_codec_read(codec, 0x1b, 0,
1489 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1490 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1491 0x80, present ? 0x80 : 0);
1492 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1493 0x80, present ? 0x80 : 0);
1494}
1495
1496static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1497{
1498 /* Looks like the unsol event is incompatible with the standard
1499 * definition. 4bit tag is placed at 28 bit!
1500 */
1501 if ((res >> 28) == 0x01)
1502 alc880_lg_automute(codec);
1503}
1504
1505/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001506 * LG LW20
1507 *
1508 * Pin assignment:
1509 * Speaker-out: 0x14
1510 * Mic-In: 0x18
1511 * Built-in Mic-In: 0x19 (?)
1512 * HP-Out: 0x1b
1513 * SPDIF-Out: 0x1e
1514 */
1515
1516/* seems analog CD is not working */
1517static struct hda_input_mux alc880_lg_lw_capture_source = {
1518 .num_items = 2,
1519 .items = {
1520 { "Mic", 0x0 },
1521 { "Internal Mic", 0x1 },
1522 },
1523};
1524
1525static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1526 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1527 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1530 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1531 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1532 { } /* end */
1533};
1534
1535static struct hda_verb alc880_lg_lw_init_verbs[] = {
1536 /* set capture source to mic-in */
1537 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1541 /* speaker-out */
1542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1543 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1544 /* HP-out */
1545 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1547 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1548 /* mic-in to input */
1549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1551 /* built-in mic */
1552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1554 /* jack sense */
1555 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1556 { }
1557};
1558
1559/* toggle speaker-output according to the hp-jack state */
1560static void alc880_lg_lw_automute(struct hda_codec *codec)
1561{
1562 unsigned int present;
1563
1564 present = snd_hda_codec_read(codec, 0x1b, 0,
1565 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1566 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1567 0x80, present ? 0x80 : 0);
1568 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1569 0x80, present ? 0x80 : 0);
1570}
1571
1572static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1573{
1574 /* Looks like the unsol event is incompatible with the standard
1575 * definition. 4bit tag is placed at 28 bit!
1576 */
1577 if ((res >> 28) == 0x01)
1578 alc880_lg_lw_automute(codec);
1579}
1580
1581/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001582 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001583 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001584
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585static int alc_init(struct hda_codec *codec)
1586{
1587 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001588 unsigned int i;
1589
1590 for (i = 0; i < spec->num_init_verbs; i++)
1591 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001592
1593 if (spec->init_hook)
1594 spec->init_hook(codec);
1595
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 return 0;
1597}
1598
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001599static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1600{
1601 struct alc_spec *spec = codec->spec;
1602
1603 if (spec->unsol_event)
1604 spec->unsol_event(codec, res);
1605}
1606
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607#ifdef CONFIG_PM
1608/*
1609 * resume
1610 */
1611static int alc_resume(struct hda_codec *codec)
1612{
1613 struct alc_spec *spec = codec->spec;
1614 int i;
1615
1616 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001617 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619 if (spec->multiout.dig_out_nid)
1620 snd_hda_resume_spdif_out(codec);
1621 if (spec->dig_in_nid)
1622 snd_hda_resume_spdif_in(codec);
1623
1624 return 0;
1625}
1626#endif
1627
1628/*
1629 * Analog playback callbacks
1630 */
1631static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1632 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001633 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634{
1635 struct alc_spec *spec = codec->spec;
1636 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1637}
1638
1639static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1640 struct hda_codec *codec,
1641 unsigned int stream_tag,
1642 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001643 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644{
1645 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001646 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1647 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648}
1649
1650static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1651 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001652 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653{
1654 struct alc_spec *spec = codec->spec;
1655 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1656}
1657
1658/*
1659 * Digital out
1660 */
1661static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1662 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001663 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664{
1665 struct alc_spec *spec = codec->spec;
1666 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1667}
1668
1669static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1670 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001671 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001672{
1673 struct alc_spec *spec = codec->spec;
1674 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1675}
1676
1677/*
1678 * Analog capture
1679 */
1680static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1681 struct hda_codec *codec,
1682 unsigned int stream_tag,
1683 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001684 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685{
1686 struct alc_spec *spec = codec->spec;
1687
1688 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1689 stream_tag, 0, format);
1690 return 0;
1691}
1692
1693static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1694 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001695 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696{
1697 struct alc_spec *spec = codec->spec;
1698
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001699 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1700 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 return 0;
1702}
1703
1704
1705/*
1706 */
1707static struct hda_pcm_stream alc880_pcm_analog_playback = {
1708 .substreams = 1,
1709 .channels_min = 2,
1710 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 .ops = {
1713 .open = alc880_playback_pcm_open,
1714 .prepare = alc880_playback_pcm_prepare,
1715 .cleanup = alc880_playback_pcm_cleanup
1716 },
1717};
1718
1719static struct hda_pcm_stream alc880_pcm_analog_capture = {
1720 .substreams = 2,
1721 .channels_min = 2,
1722 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001723 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 .ops = {
1725 .prepare = alc880_capture_pcm_prepare,
1726 .cleanup = alc880_capture_pcm_cleanup
1727 },
1728};
1729
1730static struct hda_pcm_stream alc880_pcm_digital_playback = {
1731 .substreams = 1,
1732 .channels_min = 2,
1733 .channels_max = 2,
1734 /* NID is set in alc_build_pcms */
1735 .ops = {
1736 .open = alc880_dig_playback_pcm_open,
1737 .close = alc880_dig_playback_pcm_close
1738 },
1739};
1740
1741static struct hda_pcm_stream alc880_pcm_digital_capture = {
1742 .substreams = 1,
1743 .channels_min = 2,
1744 .channels_max = 2,
1745 /* NID is set in alc_build_pcms */
1746};
1747
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001748/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1749static struct hda_pcm_stream alc_pcm_null_playback = {
1750 .substreams = 0,
1751 .channels_min = 0,
1752 .channels_max = 0,
1753};
1754
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755static int alc_build_pcms(struct hda_codec *codec)
1756{
1757 struct alc_spec *spec = codec->spec;
1758 struct hda_pcm *info = spec->pcm_rec;
1759 int i;
1760
1761 codec->num_pcms = 1;
1762 codec->pcm_info = info;
1763
1764 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001765 if (spec->stream_analog_playback) {
1766 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1767 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1768 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1769 }
1770 if (spec->stream_analog_capture) {
1771 snd_assert(spec->adc_nids, return -EINVAL);
1772 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1773 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1774 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775
Takashi Iwai4a471b72005-12-07 13:56:29 +01001776 if (spec->channel_mode) {
1777 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1778 for (i = 0; i < spec->num_channel_mode; i++) {
1779 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1781 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782 }
1783 }
1784
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001785 /* If the use of more than one ADC is requested for the current
1786 * model, configure a second analog capture-only PCM.
1787 */
1788 if (spec->num_adc_nids > 1) {
1789 codec->num_pcms++;
1790 info++;
1791 info->name = spec->stream_name_analog;
1792 /* No playback stream for second PCM */
1793 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1794 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1795 if (spec->stream_analog_capture) {
1796 snd_assert(spec->adc_nids, return -EINVAL);
1797 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1798 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1799 }
1800 }
1801
Linus Torvalds1da177e2005-04-16 15:20:36 -07001802 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1803 codec->num_pcms++;
1804 info++;
1805 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001806 if (spec->multiout.dig_out_nid &&
1807 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001808 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1809 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1810 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001811 if (spec->dig_in_nid &&
1812 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1814 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1815 }
1816 }
1817
1818 return 0;
1819}
1820
1821static void alc_free(struct hda_codec *codec)
1822{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001823 struct alc_spec *spec = codec->spec;
1824 unsigned int i;
1825
1826 if (! spec)
1827 return;
1828
1829 if (spec->kctl_alloc) {
1830 for (i = 0; i < spec->num_kctl_used; i++)
1831 kfree(spec->kctl_alloc[i].name);
1832 kfree(spec->kctl_alloc);
1833 }
1834 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835}
1836
1837/*
1838 */
1839static struct hda_codec_ops alc_patch_ops = {
1840 .build_controls = alc_build_controls,
1841 .build_pcms = alc_build_pcms,
1842 .init = alc_init,
1843 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001844 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845#ifdef CONFIG_PM
1846 .resume = alc_resume,
1847#endif
1848};
1849
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001850
1851/*
1852 * Test configuration for debugging
1853 *
1854 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1855 * enum controls.
1856 */
1857#ifdef CONFIG_SND_DEBUG
1858static hda_nid_t alc880_test_dac_nids[4] = {
1859 0x02, 0x03, 0x04, 0x05
1860};
1861
1862static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001863 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001864 .items = {
1865 { "In-1", 0x0 },
1866 { "In-2", 0x1 },
1867 { "In-3", 0x2 },
1868 { "In-4", 0x3 },
1869 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001870 { "Front", 0x5 },
1871 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001872 },
1873};
1874
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001875static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001876 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001877 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001878 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001879 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001880};
1881
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001882static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1883 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001884{
1885 static char *texts[] = {
1886 "N/A", "Line Out", "HP Out",
1887 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1888 };
1889 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1890 uinfo->count = 1;
1891 uinfo->value.enumerated.items = 8;
1892 if (uinfo->value.enumerated.item >= 8)
1893 uinfo->value.enumerated.item = 7;
1894 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1895 return 0;
1896}
1897
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001898static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1899 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001900{
1901 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1902 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1903 unsigned int pin_ctl, item = 0;
1904
1905 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1906 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1907 if (pin_ctl & AC_PINCTL_OUT_EN) {
1908 if (pin_ctl & AC_PINCTL_HP_EN)
1909 item = 2;
1910 else
1911 item = 1;
1912 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1913 switch (pin_ctl & AC_PINCTL_VREFEN) {
1914 case AC_PINCTL_VREF_HIZ: item = 3; break;
1915 case AC_PINCTL_VREF_50: item = 4; break;
1916 case AC_PINCTL_VREF_GRD: item = 5; break;
1917 case AC_PINCTL_VREF_80: item = 6; break;
1918 case AC_PINCTL_VREF_100: item = 7; break;
1919 }
1920 }
1921 ucontrol->value.enumerated.item[0] = item;
1922 return 0;
1923}
1924
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001925static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1926 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001927{
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1930 static unsigned int ctls[] = {
1931 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1932 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1933 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1934 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1935 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1936 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1937 };
1938 unsigned int old_ctl, new_ctl;
1939
1940 old_ctl = snd_hda_codec_read(codec, nid, 0,
1941 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1942 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1943 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001944 snd_hda_codec_write(codec, nid, 0,
1945 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001946 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001947 (ucontrol->value.enumerated.item[0] >= 3 ?
1948 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001949 return 1;
1950 }
1951 return 0;
1952}
1953
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001954static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1955 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001956{
1957 static char *texts[] = {
1958 "Front", "Surround", "CLFE", "Side"
1959 };
1960 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1961 uinfo->count = 1;
1962 uinfo->value.enumerated.items = 4;
1963 if (uinfo->value.enumerated.item >= 4)
1964 uinfo->value.enumerated.item = 3;
1965 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1966 return 0;
1967}
1968
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001969static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1970 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001971{
1972 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1973 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1974 unsigned int sel;
1975
1976 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1977 ucontrol->value.enumerated.item[0] = sel & 3;
1978 return 0;
1979}
1980
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001981static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001983{
1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1985 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1986 unsigned int sel;
1987
1988 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1989 if (ucontrol->value.enumerated.item[0] != sel) {
1990 sel = ucontrol->value.enumerated.item[0] & 3;
1991 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1992 return 1;
1993 }
1994 return 0;
1995}
1996
1997#define PIN_CTL_TEST(xname,nid) { \
1998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1999 .name = xname, \
2000 .info = alc_test_pin_ctl_info, \
2001 .get = alc_test_pin_ctl_get, \
2002 .put = alc_test_pin_ctl_put, \
2003 .private_value = nid \
2004 }
2005
2006#define PIN_SRC_TEST(xname,nid) { \
2007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2008 .name = xname, \
2009 .info = alc_test_pin_src_info, \
2010 .get = alc_test_pin_src_get, \
2011 .put = alc_test_pin_src_put, \
2012 .private_value = nid \
2013 }
2014
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002015static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2017 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2018 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2019 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002020 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2021 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2022 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2023 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002024 PIN_CTL_TEST("Front Pin Mode", 0x14),
2025 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2026 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2027 PIN_CTL_TEST("Side Pin Mode", 0x17),
2028 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2029 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2030 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2031 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2032 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2033 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2034 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2035 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2036 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2037 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2038 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2039 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2040 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2041 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2042 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2043 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002046 {
2047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2048 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002049 .info = alc_ch_mode_info,
2050 .get = alc_ch_mode_get,
2051 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002052 },
2053 { } /* end */
2054};
2055
2056static struct hda_verb alc880_test_init_verbs[] = {
2057 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2062 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2065 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002066 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2069 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2070 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002071 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2074 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2075 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002076 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002077 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2079 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002081 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002082 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2083 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2085 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2086 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002087 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002088 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2089 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2091 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002092 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002094 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002096 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002098 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002099 /* Analog input/passthru */
2100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002105 { }
2106};
2107#endif
2108
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109/*
2110 */
2111
2112static struct hda_board_config alc880_cfg_tbl[] = {
2113 /* Back 3 jack, front 2 jack */
2114 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002115 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2116 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2117 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2118 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2119 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2120 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2121 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2122 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2123 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2124 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2125 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2126 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2127 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002147 /* TCL S700 */
2148 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149
2150 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002151 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002152 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002153 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154
2155 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2156 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002157 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe32005-08-15 20:01:40 +02002158 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002159 /* Clevo m520G NB */
2160 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161
2162 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002163 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2164 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2165 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166
2167 /* Back 5 jack, front 2 jack */
2168 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002169 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2170 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2171 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2172 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002173 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174
2175 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2176 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002177 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2178 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2179 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2180 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2181 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2183 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2184 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002185 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002186 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2187 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002188 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002189 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002190 /* note subvendor = 0 below */
2191 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192
2193 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002194 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002196 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002197 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002198
Takashi Iwaib6482d42005-06-27 15:32:43 +02002199 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002200 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002201 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002202 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002203 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002204
2205 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002206 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2207 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2208 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2209 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002210 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2211 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2212 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2213 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002214 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002215 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002216 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Takashi Iwai16ded522005-06-10 19:58:24 +02002217
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002218 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2220 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2221 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2222 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002223 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002224 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2225 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2226 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2227 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2228 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2229 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai84f34302006-03-21 19:12:53 +01002230 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Kailang Yangdf694da2005-12-05 19:42:22 +01002231 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002232
2233 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2234 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2235
2236 { .modelname = "F1734", .config = ALC880_F1734 },
2237 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002238 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002239
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002240 { .modelname = "lg", .config = ALC880_LG },
2241 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
Takashi Iwai886da862006-05-02 18:17:57 +02002242 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002243
Takashi Iwaid6815182006-03-23 16:06:23 +01002244 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2245 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2246
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002247#ifdef CONFIG_SND_DEBUG
2248 { .modelname = "test", .config = ALC880_TEST },
2249#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002250 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002251
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 {}
2253};
2254
Takashi Iwai16ded522005-06-10 19:58:24 +02002255/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002256 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002258static struct alc_config_preset alc880_presets[] = {
2259 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260 .mixers = { alc880_three_stack_mixer },
2261 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002262 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002263 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2265 .channel_mode = alc880_threestack_modes,
2266 .input_mux = &alc880_capture_source,
2267 },
2268 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002269 .mixers = { alc880_three_stack_mixer },
2270 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 .dac_nids = alc880_dac_nids,
2273 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2275 .channel_mode = alc880_threestack_modes,
2276 .input_mux = &alc880_capture_source,
2277 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002278 [ALC880_TCL_S700] = {
2279 .mixers = { alc880_tcl_s700_mixer },
2280 .init_verbs = { alc880_volume_init_verbs,
2281 alc880_pin_tcl_S700_init_verbs,
2282 alc880_gpio2_init_verbs },
2283 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2284 .dac_nids = alc880_dac_nids,
2285 .hp_nid = 0x03,
2286 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2287 .channel_mode = alc880_2_jack_modes,
2288 .input_mux = &alc880_capture_source,
2289 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2292 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002293 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2294 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002295 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2296 .channel_mode = alc880_fivestack_modes,
2297 .input_mux = &alc880_capture_source,
2298 },
2299 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2301 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2303 .dac_nids = alc880_dac_nids,
2304 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002305 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2306 .channel_mode = alc880_fivestack_modes,
2307 .input_mux = &alc880_capture_source,
2308 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002309 [ALC880_6ST] = {
2310 .mixers = { alc880_six_stack_mixer },
2311 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2312 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2313 .dac_nids = alc880_6st_dac_nids,
2314 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2315 .channel_mode = alc880_sixstack_modes,
2316 .input_mux = &alc880_6stack_capture_source,
2317 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002318 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002319 .mixers = { alc880_six_stack_mixer },
2320 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002321 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2322 .dac_nids = alc880_6st_dac_nids,
2323 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002324 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2325 .channel_mode = alc880_sixstack_modes,
2326 .input_mux = &alc880_6stack_capture_source,
2327 },
2328 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002329 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002330 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2331 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002332 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2333 .dac_nids = alc880_w810_dac_nids,
2334 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002335 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2336 .channel_mode = alc880_w810_modes,
2337 .input_mux = &alc880_capture_source,
2338 },
2339 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002340 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002341 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002342 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2343 .dac_nids = alc880_z71v_dac_nids,
2344 .dig_out_nid = ALC880_DIGOUT_NID,
2345 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002346 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2347 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002348 .input_mux = &alc880_capture_source,
2349 },
2350 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351 .mixers = { alc880_f1734_mixer },
2352 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2353 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2354 .dac_nids = alc880_f1734_dac_nids,
2355 .hp_nid = 0x02,
2356 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2357 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002358 .input_mux = &alc880_capture_source,
2359 },
2360 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002361 .mixers = { alc880_asus_mixer },
2362 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2363 alc880_gpio1_init_verbs },
2364 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2365 .dac_nids = alc880_asus_dac_nids,
2366 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2367 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002368 .input_mux = &alc880_capture_source,
2369 },
2370 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371 .mixers = { alc880_asus_mixer },
2372 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2373 alc880_gpio1_init_verbs },
2374 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2375 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002376 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002377 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2378 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002379 .input_mux = &alc880_capture_source,
2380 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002381 [ALC880_ASUS_DIG2] = {
2382 .mixers = { alc880_asus_mixer },
2383 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2384 alc880_gpio2_init_verbs }, /* use GPIO2 */
2385 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2386 .dac_nids = alc880_asus_dac_nids,
2387 .dig_out_nid = ALC880_DIGOUT_NID,
2388 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2389 .channel_mode = alc880_asus_modes,
2390 .input_mux = &alc880_capture_source,
2391 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002392 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002393 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2394 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2395 alc880_gpio1_init_verbs },
2396 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2397 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002398 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002399 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2400 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002401 .input_mux = &alc880_capture_source,
2402 },
2403 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002404 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2406 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2407 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002408 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002409 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2410 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002411 .input_mux = &alc880_capture_source,
2412 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002413 [ALC880_CLEVO] = {
2414 .mixers = { alc880_three_stack_mixer },
2415 .init_verbs = { alc880_volume_init_verbs,
2416 alc880_pin_clevo_init_verbs },
2417 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2418 .dac_nids = alc880_dac_nids,
2419 .hp_nid = 0x03,
2420 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2421 .channel_mode = alc880_threestack_modes,
2422 .input_mux = &alc880_capture_source,
2423 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002424 [ALC880_LG] = {
2425 .mixers = { alc880_lg_mixer },
2426 .init_verbs = { alc880_volume_init_verbs,
2427 alc880_lg_init_verbs },
2428 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2429 .dac_nids = alc880_lg_dac_nids,
2430 .dig_out_nid = ALC880_DIGOUT_NID,
2431 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2432 .channel_mode = alc880_lg_ch_modes,
2433 .input_mux = &alc880_lg_capture_source,
2434 .unsol_event = alc880_lg_unsol_event,
2435 .init_hook = alc880_lg_automute,
2436 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002437 [ALC880_LG_LW] = {
2438 .mixers = { alc880_lg_lw_mixer },
2439 .init_verbs = { alc880_volume_init_verbs,
2440 alc880_lg_lw_init_verbs },
2441 .num_dacs = 1,
2442 .dac_nids = alc880_dac_nids,
2443 .dig_out_nid = ALC880_DIGOUT_NID,
2444 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2445 .channel_mode = alc880_2_jack_modes,
2446 .input_mux = &alc880_lg_lw_capture_source,
2447 .unsol_event = alc880_lg_lw_unsol_event,
2448 .init_hook = alc880_lg_lw_automute,
2449 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002450#ifdef CONFIG_SND_DEBUG
2451 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452 .mixers = { alc880_test_mixer },
2453 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002454 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2455 .dac_nids = alc880_test_dac_nids,
2456 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002457 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2458 .channel_mode = alc880_test_modes,
2459 .input_mux = &alc880_test_capture_source,
2460 },
2461#endif
2462};
2463
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002464/*
2465 * Automatic parse of I/O pins from the BIOS configuration
2466 */
2467
2468#define NUM_CONTROL_ALLOC 32
2469#define NUM_VERB_ALLOC 32
2470
2471enum {
2472 ALC_CTL_WIDGET_VOL,
2473 ALC_CTL_WIDGET_MUTE,
2474 ALC_CTL_BIND_MUTE,
2475};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002476static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002477 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2478 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002479 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480};
2481
2482/* add dynamic controls */
2483static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2484{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002485 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486
2487 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2488 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2489
2490 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2491 if (! knew)
2492 return -ENOMEM;
2493 if (spec->kctl_alloc) {
2494 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2495 kfree(spec->kctl_alloc);
2496 }
2497 spec->kctl_alloc = knew;
2498 spec->num_kctl_alloc = num;
2499 }
2500
2501 knew = &spec->kctl_alloc[spec->num_kctl_used];
2502 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002503 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 if (! knew->name)
2505 return -ENOMEM;
2506 knew->private_value = val;
2507 spec->num_kctl_used++;
2508 return 0;
2509}
2510
2511#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2512#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2513#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2514#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2515#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2516#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2517#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2518#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2519#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2520#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2521#define ALC880_PIN_CD_NID 0x1c
2522
2523/* fill in the dac_nids table from the parsed pin configuration */
2524static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2525{
2526 hda_nid_t nid;
2527 int assigned[4];
2528 int i, j;
2529
2530 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002531 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532
2533 /* check the pins hardwired to audio widget */
2534 for (i = 0; i < cfg->line_outs; i++) {
2535 nid = cfg->line_out_pins[i];
2536 if (alc880_is_fixed_pin(nid)) {
2537 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002538 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 assigned[idx] = 1;
2540 }
2541 }
2542 /* left pins can be connect to any audio widget */
2543 for (i = 0; i < cfg->line_outs; i++) {
2544 nid = cfg->line_out_pins[i];
2545 if (alc880_is_fixed_pin(nid))
2546 continue;
2547 /* search for an empty channel */
2548 for (j = 0; j < cfg->line_outs; j++) {
2549 if (! assigned[j]) {
2550 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2551 assigned[j] = 1;
2552 break;
2553 }
2554 }
2555 }
2556 spec->multiout.num_dacs = cfg->line_outs;
2557 return 0;
2558}
2559
2560/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002561static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2562 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002563{
2564 char name[32];
2565 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2566 hda_nid_t nid;
2567 int i, err;
2568
2569 for (i = 0; i < cfg->line_outs; i++) {
2570 if (! spec->multiout.dac_nids[i])
2571 continue;
2572 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2573 if (i == 2) {
2574 /* Center/LFE */
2575 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2576 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2577 return err;
2578 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2579 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2580 return err;
2581 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2582 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2583 return err;
2584 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2585 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2586 return err;
2587 } else {
2588 sprintf(name, "%s Playback Volume", chname[i]);
2589 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2590 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2591 return err;
2592 sprintf(name, "%s Playback Switch", chname[i]);
2593 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2594 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2595 return err;
2596 }
2597 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 return 0;
2599}
2600
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002601/* add playback controls for speaker and HP outputs */
2602static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2603 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002604{
2605 hda_nid_t nid;
2606 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002607 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608
2609 if (! pin)
2610 return 0;
2611
2612 if (alc880_is_fixed_pin(pin)) {
2613 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002614 /* specify the DAC as the extra output */
2615 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002617 else
2618 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 /* control HP volume/switch on the output mixer amp */
2620 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002621 sprintf(name, "%s Playback Volume", pfx);
2622 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002623 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2624 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002625 sprintf(name, "%s Playback Switch", pfx);
2626 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002627 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2628 return err;
2629 } else if (alc880_is_multi_pin(pin)) {
2630 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002631 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002632 sprintf(name, "%s Playback Switch", pfx);
2633 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2635 return err;
2636 }
2637 return 0;
2638}
2639
2640/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002641static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2642 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643{
2644 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002645 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002646
2647 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002649 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 return err;
2651 sprintf(name, "%s Playback Switch", ctlname);
2652 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002653 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 return err;
2655 return 0;
2656}
2657
2658/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002659static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2660 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002663 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664
2665 for (i = 0; i < AUTO_PIN_LAST; i++) {
2666 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002667 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002668 err = new_analog_input(spec, cfg->input_pins[i],
2669 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002670 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 if (err < 0)
2672 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002673 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2675 imux->num_items++;
2676 }
2677 }
2678 return 0;
2679}
2680
Kailang Yangdf694da2005-12-05 19:42:22 +01002681static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2682 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683 int dac_idx)
2684{
2685 /* set as output */
2686 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2687 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2688 /* need the manual connection? */
2689 if (alc880_is_multi_pin(nid)) {
2690 struct alc_spec *spec = codec->spec;
2691 int idx = alc880_multi_pin_idx(nid);
2692 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2693 AC_VERB_SET_CONNECT_SEL,
2694 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2695 }
2696}
2697
2698static void alc880_auto_init_multi_out(struct hda_codec *codec)
2699{
2700 struct alc_spec *spec = codec->spec;
2701 int i;
2702
2703 for (i = 0; i < spec->autocfg.line_outs; i++) {
2704 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2705 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2706 }
2707}
2708
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002709static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710{
2711 struct alc_spec *spec = codec->spec;
2712 hda_nid_t pin;
2713
Takashi Iwai82bc9552006-03-21 11:24:42 +01002714 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002715 if (pin) /* connect to front */
2716 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717 pin = spec->autocfg.hp_pin;
2718 if (pin) /* connect to front */
2719 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2720}
2721
2722static void alc880_auto_init_analog_input(struct hda_codec *codec)
2723{
2724 struct alc_spec *spec = codec->spec;
2725 int i;
2726
2727 for (i = 0; i < AUTO_PIN_LAST; i++) {
2728 hda_nid_t nid = spec->autocfg.input_pins[i];
2729 if (alc880_is_input_pin(nid)) {
2730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2731 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2732 if (nid != ALC880_PIN_CD_NID)
2733 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2734 AMP_OUT_MUTE);
2735 }
2736 }
2737}
2738
2739/* parse the BIOS configuration and set up the alc_spec */
2740/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2741static int alc880_parse_auto_config(struct hda_codec *codec)
2742{
2743 struct alc_spec *spec = codec->spec;
2744 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002745 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746
Kailang Yangdf694da2005-12-05 19:42:22 +01002747 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2748 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002749 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002750 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002751 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002752
2753 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2754 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002755 (err = alc880_auto_create_extra_out(spec,
2756 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002757 "Speaker")) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002758 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002759 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002760 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2761 return err;
2762
2763 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2764
2765 if (spec->autocfg.dig_out_pin)
2766 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2767 if (spec->autocfg.dig_in_pin)
2768 spec->dig_in_nid = ALC880_DIGIN_NID;
2769
2770 if (spec->kctl_alloc)
2771 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2772
2773 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2774
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002775 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 spec->input_mux = &spec->private_imux;
2777
2778 return 1;
2779}
2780
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002781/* additional initialization for auto-configuration model */
2782static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002785 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002787}
2788
2789/*
2790 * OK, here we have finally the patch for ALC880
2791 */
2792
Linus Torvalds1da177e2005-04-16 15:20:36 -07002793static int patch_alc880(struct hda_codec *codec)
2794{
2795 struct alc_spec *spec;
2796 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002797 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002799 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002800 if (spec == NULL)
2801 return -ENOMEM;
2802
2803 codec->spec = spec;
2804
2805 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002806 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002807 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2808 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002809 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002810 }
2811
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 if (board_config == ALC880_AUTO) {
2813 /* automatic parse from the BIOS config */
2814 err = alc880_parse_auto_config(codec);
2815 if (err < 0) {
2816 alc_free(codec);
2817 return err;
2818 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002819 printk(KERN_INFO
2820 "hda_codec: Cannot set up configuration "
2821 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 board_config = ALC880_3ST;
2823 }
2824 }
2825
Kailang Yangdf694da2005-12-05 19:42:22 +01002826 if (board_config != ALC880_AUTO)
2827 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828
2829 spec->stream_name_analog = "ALC880 Analog";
2830 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2831 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2832
2833 spec->stream_name_digital = "ALC880 Digital";
2834 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2835 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2836
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 if (! spec->adc_nids && spec->input_mux) {
2838 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002839 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002840 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2841 if (wcap != AC_WID_AUD_IN) {
2842 spec->adc_nids = alc880_adc_nids_alt;
2843 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2844 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2845 spec->num_mixers++;
2846 } else {
2847 spec->adc_nids = alc880_adc_nids;
2848 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2849 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2850 spec->num_mixers++;
2851 }
2852 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002853
2854 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002855 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002856 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857
2858 return 0;
2859}
2860
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862/*
2863 * ALC260 support
2864 */
2865
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866static hda_nid_t alc260_dac_nids[1] = {
2867 /* front */
2868 0x02,
2869};
2870
2871static hda_nid_t alc260_adc_nids[1] = {
2872 /* ADC0 */
2873 0x04,
2874};
2875
Kailang Yangdf694da2005-12-05 19:42:22 +01002876static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002877 /* ADC1 */
2878 0x05,
2879};
2880
Kailang Yangdf694da2005-12-05 19:42:22 +01002881static hda_nid_t alc260_hp_adc_nids[2] = {
2882 /* ADC1, 0 */
2883 0x05, 0x04
2884};
2885
Jonathan Woithed57fdac2006-02-28 11:38:35 +01002886/* NIDs used when simultaneous access to both ADCs makes sense. Note that
2887 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2888 */
2889static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002890 /* ADC0, ADC1 */
2891 0x04, 0x05
2892};
2893
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894#define ALC260_DIGOUT_NID 0x03
2895#define ALC260_DIGIN_NID 0x06
2896
2897static struct hda_input_mux alc260_capture_source = {
2898 .num_items = 4,
2899 .items = {
2900 { "Mic", 0x0 },
2901 { "Front Mic", 0x1 },
2902 { "Line", 0x2 },
2903 { "CD", 0x4 },
2904 },
2905};
2906
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01002907/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002908 * headphone jack and the internal CD lines since these are the only pins at
2909 * which audio can appear. For flexibility, also allow the option of
2910 * recording the mixer output on the second ADC (ADC0 doesn't have a
2911 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002912 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002913static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2914 {
2915 .num_items = 3,
2916 .items = {
2917 { "Mic/Line", 0x0 },
2918 { "CD", 0x4 },
2919 { "Headphone", 0x2 },
2920 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002921 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002922 {
2923 .num_items = 4,
2924 .items = {
2925 { "Mic/Line", 0x0 },
2926 { "CD", 0x4 },
2927 { "Headphone", 0x2 },
2928 { "Mixer", 0x5 },
2929 },
2930 },
2931
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002932};
2933
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002934/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2935 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002936 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002937static struct hda_input_mux alc260_acer_capture_sources[2] = {
2938 {
2939 .num_items = 4,
2940 .items = {
2941 { "Mic", 0x0 },
2942 { "Line", 0x2 },
2943 { "CD", 0x4 },
2944 { "Headphone", 0x5 },
2945 },
2946 },
2947 {
2948 .num_items = 5,
2949 .items = {
2950 { "Mic", 0x0 },
2951 { "Line", 0x2 },
2952 { "CD", 0x4 },
2953 { "Headphone", 0x6 },
2954 { "Mixer", 0x5 },
2955 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002956 },
2957};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958/*
2959 * This is just place-holder, so there's something for alc_build_pcms to look
2960 * at when it calculates the maximum number of channels. ALC260 has no mixer
2961 * element which allows changing the channel mode, so the verb list is
2962 * never used.
2963 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002964static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965 { 2, NULL },
2966};
2967
Kailang Yangdf694da2005-12-05 19:42:22 +01002968
2969/* Mixer combinations
2970 *
2971 * basic: base_output + input + pc_beep + capture
2972 * HP: base_output + input + capture_alt
2973 * HP_3013: hp_3013 + input + capture
2974 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002975 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01002976 */
2977
2978static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002979 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002980 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2982 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2983 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2984 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2985 { } /* end */
2986};
2987
2988static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002989 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2990 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2992 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2994 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997 { } /* end */
2998};
2999
Kailang Yangdf694da2005-12-05 19:42:22 +01003000static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3001 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3002 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3003 { } /* end */
3004};
3005
3006static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3007 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3008 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3009 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3010 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3013 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3014 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003015 { } /* end */
3016};
3017
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003018/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3019 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3020 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003021static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003023 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003024 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003025 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3026 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3027 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3028 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003029 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003030 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3031 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3032 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003033 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003034 { } /* end */
3035};
3036
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003037/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3038 * versions of the ALC260 don't act on requests to enable mic bias from NID
3039 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3040 * datasheet doesn't mention this restriction. At this stage it's not clear
3041 * whether this behaviour is intentional or is a hardware bug in chip
3042 * revisions available in early 2006. Therefore for now allow the
3043 * "Headphone Jack Mode" control to span all choices, but if it turns out
3044 * that the lack of mic bias for this NID is intentional we could change the
3045 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3046 *
3047 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3048 * don't appear to make the mic bias available from the "line" jack, even
3049 * though the NID used for this jack (0x14) can supply it. The theory is
3050 * that perhaps Acer have included blocking capacitors between the ALC260
3051 * and the output jack. If this turns out to be the case for all such
3052 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3053 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3054 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003055static struct snd_kcontrol_new alc260_acer_mixer[] = {
3056 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3057 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003058 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003059 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3060 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3062 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3063 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3064 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3065 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3066 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3067 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3068 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3069 { } /* end */
3070};
3071
Kailang Yangdf694da2005-12-05 19:42:22 +01003072/* capture mixer elements */
3073static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003074 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3075 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003076 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3077 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003078 {
3079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003080 /* The multiple "Capture Source" controls confuse alsamixer
3081 * So call somewhat different..
3082 * FIXME: the controls appear in the "playback" view!
3083 */
3084 /* .name = "Capture Source", */
3085 .name = "Input Source",
3086 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003087 .info = alc_mux_enum_info,
3088 .get = alc_mux_enum_get,
3089 .put = alc_mux_enum_put,
3090 },
3091 { } /* end */
3092};
3093
Kailang Yangdf694da2005-12-05 19:42:22 +01003094static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3095 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3096 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3097 {
3098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3099 /* The multiple "Capture Source" controls confuse alsamixer
3100 * So call somewhat different..
3101 * FIXME: the controls appear in the "playback" view!
3102 */
3103 /* .name = "Capture Source", */
3104 .name = "Input Source",
3105 .count = 1,
3106 .info = alc_mux_enum_info,
3107 .get = alc_mux_enum_get,
3108 .put = alc_mux_enum_put,
3109 },
3110 { } /* end */
3111};
3112
3113/*
3114 * initialization verbs
3115 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003116static struct hda_verb alc260_init_verbs[] = {
3117 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003119 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003120 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003121 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003122 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003128 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003129 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003131 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003132 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003134 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3135 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003137 /* set connection select to line in (default select for this ADC) */
3138 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 /* mute capture amp left and right */
3140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3141 /* set connection select to line in (default select for this ADC) */
3142 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003143 /* set vol=0 Line-Out mixer amp left and right */
3144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3145 /* unmute pin widget amp left and right (no gain on this amp) */
3146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3147 /* set vol=0 HP mixer amp left and right */
3148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3149 /* unmute pin widget amp left and right (no gain on this amp) */
3150 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3151 /* set vol=0 Mono mixer amp left and right */
3152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3153 /* unmute pin widget amp left and right (no gain on this amp) */
3154 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3155 /* unmute LINE-2 out pin */
3156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003158 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003160 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003162 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003164 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003165 /* mute Front out path */
3166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3168 /* mute Headphone out path */
3169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3171 /* mute Mono out path */
3172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003174 { }
3175};
3176
Takashi Iwai474167d2006-05-17 17:17:43 +02003177#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003178static struct hda_verb alc260_hp_init_verbs[] = {
3179 /* Headphone and output */
3180 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3181 /* mono output */
3182 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3183 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3184 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3185 /* Mic2 (front panel) pin widget for input and vref at 80% */
3186 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3187 /* Line In pin widget for input */
3188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3189 /* Line-2 pin widget for output */
3190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3191 /* CD pin widget for input */
3192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3193 /* unmute amp left and right */
3194 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3195 /* set connection select to line in (default select for this ADC) */
3196 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3197 /* unmute Line-Out mixer amp left and right (volume = 0) */
3198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3199 /* mute pin widget amp left and right (no gain on this amp) */
3200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3201 /* unmute HP mixer amp left and right (volume = 0) */
3202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3203 /* mute pin widget amp left and right (no gain on this amp) */
3204 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3205 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3206 /* unmute CD */
3207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3208 /* unmute Line In */
3209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3210 /* unmute Mic */
3211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3212 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3213 /* Unmute Front out path */
3214 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3216 /* Unmute Headphone out path */
3217 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3218 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3219 /* Unmute Mono out path */
3220 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3221 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3222 { }
3223};
Takashi Iwai474167d2006-05-17 17:17:43 +02003224#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003225
3226static struct hda_verb alc260_hp_3013_init_verbs[] = {
3227 /* Line out and output */
3228 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3229 /* mono output */
3230 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3231 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3232 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3233 /* Mic2 (front panel) pin widget for input and vref at 80% */
3234 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3235 /* Line In pin widget for input */
3236 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3237 /* Headphone pin widget for output */
3238 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3239 /* CD pin widget for input */
3240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3241 /* unmute amp left and right */
3242 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3243 /* set connection select to line in (default select for this ADC) */
3244 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3245 /* unmute Line-Out mixer amp left and right (volume = 0) */
3246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3247 /* mute pin widget amp left and right (no gain on this amp) */
3248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3249 /* unmute HP mixer amp left and right (volume = 0) */
3250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3251 /* mute pin widget amp left and right (no gain on this amp) */
3252 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3253 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3254 /* unmute CD */
3255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3256 /* unmute Line In */
3257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3258 /* unmute Mic */
3259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3260 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3261 /* Unmute Front out path */
3262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3264 /* Unmute Headphone out path */
3265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3267 /* Unmute Mono out path */
3268 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3269 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3270 { }
3271};
3272
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003273/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003274 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3275 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003276 */
3277static struct hda_verb alc260_fujitsu_init_verbs[] = {
3278 /* Disable all GPIOs */
3279 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3280 /* Internal speaker is connected to headphone pin */
3281 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3282 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003284 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3285 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3286 /* Ensure all other unused pins are disabled and muted. */
3287 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003289 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003290 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003291 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003292 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003295
Jonathan Woithef7ace402006-02-28 11:46:14 +01003296 /* Disable digital (SPDIF) pins */
3297 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3298 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003299
Jonathan Woithef7ace402006-02-28 11:46:14 +01003300 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3301 * when acting as an output.
3302 */
3303 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3304
3305 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3307 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3308 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3310 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3311 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3312 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3313 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3314 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003315
Jonathan Woithef7ace402006-02-28 11:46:14 +01003316 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3317 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3318 /* Unmute Line1 pin widget output buffer since it starts as an output.
3319 * If the pin mode is changed by the user the pin mode control will
3320 * take care of enabling the pin's input/output buffers as needed.
3321 * Therefore there's no need to enable the input buffer at this
3322 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003323 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003325 /* Unmute input buffer of pin widget used for Line-in (no equiv
3326 * mixer ctrl)
3327 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003328 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003329
Jonathan Woithef7ace402006-02-28 11:46:14 +01003330 /* Mute capture amp left and right */
3331 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3332 /* Set ADC connection select to match default mixer setting - line
3333 * in (on mic1 pin)
3334 */
3335 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003336
Jonathan Woithef7ace402006-02-28 11:46:14 +01003337 /* Do the same for the second ADC: mute capture input amp and
3338 * set ADC connection to line in (on mic1 pin)
3339 */
3340 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3341 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003342
Jonathan Woithef7ace402006-02-28 11:46:14 +01003343 /* Mute all inputs to mixer widget (even unconnected ones) */
3344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3346 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003352
3353 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003354};
3355
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003356/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3357 * similar laptops (adapted from Fujitsu init verbs).
3358 */
3359static struct hda_verb alc260_acer_init_verbs[] = {
3360 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3361 * the headphone jack. Turn this on and rely on the standard mute
3362 * methods whenever the user wants to turn these outputs off.
3363 */
3364 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3365 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3366 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3367 /* Internal speaker/Headphone jack is connected to Line-out pin */
3368 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3369 /* Internal microphone/Mic jack is connected to Mic1 pin */
3370 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3371 /* Line In jack is connected to Line1 pin */
3372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3373 /* Ensure all other unused pins are disabled and muted. */
3374 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3375 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3376 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3377 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3378 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3379 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3380 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3382 /* Disable digital (SPDIF) pins */
3383 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3384 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3385
3386 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3387 * bus when acting as outputs.
3388 */
3389 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3390 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3391
3392 /* Start with output sum widgets muted and their output gains at min */
3393 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3396 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3397 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3399 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3400 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3401 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3402
3403 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3405 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3406 * inputs. If the pin mode is changed by the user the pin mode control
3407 * will take care of enabling the pin's input/output buffers as needed.
3408 * Therefore there's no need to enable the input buffer at this
3409 * stage.
3410 */
3411 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3413
3414 /* Mute capture amp left and right */
3415 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3416 /* Set ADC connection select to match default mixer setting - mic
3417 * (on mic1 pin)
3418 */
3419 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3420
3421 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003422 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003423 */
3424 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003425 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003426
3427 /* Mute all inputs to mixer widget (even unconnected ones) */
3428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3436
3437 { }
3438};
3439
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003440/* Test configuration for debugging, modelled after the ALC880 test
3441 * configuration.
3442 */
3443#ifdef CONFIG_SND_DEBUG
3444static hda_nid_t alc260_test_dac_nids[1] = {
3445 0x02,
3446};
3447static hda_nid_t alc260_test_adc_nids[2] = {
3448 0x04, 0x05,
3449};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003450/* For testing the ALC260, each input MUX needs its own definition since
3451 * the signal assignments are different. This assumes that the first ADC
3452 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003453 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003454static struct hda_input_mux alc260_test_capture_sources[2] = {
3455 {
3456 .num_items = 7,
3457 .items = {
3458 { "MIC1 pin", 0x0 },
3459 { "MIC2 pin", 0x1 },
3460 { "LINE1 pin", 0x2 },
3461 { "LINE2 pin", 0x3 },
3462 { "CD pin", 0x4 },
3463 { "LINE-OUT pin", 0x5 },
3464 { "HP-OUT pin", 0x6 },
3465 },
3466 },
3467 {
3468 .num_items = 8,
3469 .items = {
3470 { "MIC1 pin", 0x0 },
3471 { "MIC2 pin", 0x1 },
3472 { "LINE1 pin", 0x2 },
3473 { "LINE2 pin", 0x3 },
3474 { "CD pin", 0x4 },
3475 { "Mixer", 0x5 },
3476 { "LINE-OUT pin", 0x6 },
3477 { "HP-OUT pin", 0x7 },
3478 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003479 },
3480};
3481static struct snd_kcontrol_new alc260_test_mixer[] = {
3482 /* Output driver widgets */
3483 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3484 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3485 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3486 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3487 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3488 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3489
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003490 /* Modes for retasking pin widgets
3491 * Note: the ALC260 doesn't seem to act on requests to enable mic
3492 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3493 * mention this restriction. At this stage it's not clear whether
3494 * this behaviour is intentional or is a hardware bug in chip
3495 * revisions available at least up until early 2006. Therefore for
3496 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3497 * choices, but if it turns out that the lack of mic bias for these
3498 * NIDs is intentional we could change their modes from
3499 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3500 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003501 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3502 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3503 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3504 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3505 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3506 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3507
3508 /* Loopback mixer controls */
3509 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3510 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3511 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3512 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3513 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3514 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3515 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3516 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3517 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3518 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3519 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3520 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3521 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3522 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3523 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3524 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003525
3526 /* Controls for GPIO pins, assuming they are configured as outputs */
3527 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3528 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3529 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3530 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3531
Jonathan Woithe92621f12006-02-28 11:47:47 +01003532 /* Switches to allow the digital IO pins to be enabled. The datasheet
3533 * is ambigious as to which NID is which; testing on laptops which
3534 * make this output available should provide clarification.
3535 */
3536 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3537 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3538
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003539 { } /* end */
3540};
3541static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003542 /* Enable all GPIOs as outputs with an initial value of 0 */
3543 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3544 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3545 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3546
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003547 /* Enable retasking pins as output, initially without power amp */
3548 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3549 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3552 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3553 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3554
Jonathan Woithe92621f12006-02-28 11:47:47 +01003555 /* Disable digital (SPDIF) pins initially, but users can enable
3556 * them via a mixer switch. In the case of SPDIF-out, this initverb
3557 * payload also sets the generation to 0, output to be in "consumer"
3558 * PCM format, copyright asserted, no pre-emphasis and no validity
3559 * control.
3560 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003561 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3562 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3563
Jonathan Woithef7ace402006-02-28 11:46:14 +01003564 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003565 * OUT1 sum bus when acting as an output.
3566 */
3567 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3568 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3569 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3570 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3571
3572 /* Start with output sum widgets muted and their output gains at min */
3573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3578 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3579 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3580 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3581 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3582
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003583 /* Unmute retasking pin widget output buffers since the default
3584 * state appears to be output. As the pin mode is changed by the
3585 * user the pin mode control will take care of enabling the pin's
3586 * input/output buffers as needed.
3587 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003588 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3592 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3593 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3594 /* Also unmute the mono-out pin widget */
3595 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3596
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003597 /* Mute capture amp left and right */
3598 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003599 /* Set ADC connection select to match default mixer setting (mic1
3600 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003601 */
3602 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3603
3604 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003605 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003606 */
3607 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3608 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3609
3610 /* Mute all inputs to mixer widget (even unconnected ones) */
3611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3619
3620 { }
3621};
3622#endif
3623
Linus Torvalds1da177e2005-04-16 15:20:36 -07003624static struct hda_pcm_stream alc260_pcm_analog_playback = {
3625 .substreams = 1,
3626 .channels_min = 2,
3627 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628};
3629
3630static struct hda_pcm_stream alc260_pcm_analog_capture = {
3631 .substreams = 1,
3632 .channels_min = 2,
3633 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003634};
3635
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003636#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3637#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3638
Kailang Yangdf694da2005-12-05 19:42:22 +01003639/*
3640 * for BIOS auto-configuration
3641 */
3642
3643static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3644 const char *pfx)
3645{
3646 hda_nid_t nid_vol;
3647 unsigned long vol_val, sw_val;
3648 char name[32];
3649 int err;
3650
3651 if (nid >= 0x0f && nid < 0x11) {
3652 nid_vol = nid - 0x7;
3653 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3654 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3655 } else if (nid == 0x11) {
3656 nid_vol = nid - 0x7;
3657 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3658 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3659 } else if (nid >= 0x12 && nid <= 0x15) {
3660 nid_vol = 0x08;
3661 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3662 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3663 } else
3664 return 0; /* N/A */
3665
3666 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3667 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3668 return err;
3669 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3670 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3671 return err;
3672 return 1;
3673}
3674
3675/* add playback controls from the parsed DAC table */
3676static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3677 const struct auto_pin_cfg *cfg)
3678{
3679 hda_nid_t nid;
3680 int err;
3681
3682 spec->multiout.num_dacs = 1;
3683 spec->multiout.dac_nids = spec->private_dac_nids;
3684 spec->multiout.dac_nids[0] = 0x02;
3685
3686 nid = cfg->line_out_pins[0];
3687 if (nid) {
3688 err = alc260_add_playback_controls(spec, nid, "Front");
3689 if (err < 0)
3690 return err;
3691 }
3692
Takashi Iwai82bc9552006-03-21 11:24:42 +01003693 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003694 if (nid) {
3695 err = alc260_add_playback_controls(spec, nid, "Speaker");
3696 if (err < 0)
3697 return err;
3698 }
3699
3700 nid = cfg->hp_pin;
3701 if (nid) {
3702 err = alc260_add_playback_controls(spec, nid, "Headphone");
3703 if (err < 0)
3704 return err;
3705 }
3706 return 0;
3707}
3708
3709/* create playback/capture controls for input pins */
3710static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3711 const struct auto_pin_cfg *cfg)
3712{
Kailang Yangdf694da2005-12-05 19:42:22 +01003713 struct hda_input_mux *imux = &spec->private_imux;
3714 int i, err, idx;
3715
3716 for (i = 0; i < AUTO_PIN_LAST; i++) {
3717 if (cfg->input_pins[i] >= 0x12) {
3718 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003719 err = new_analog_input(spec, cfg->input_pins[i],
3720 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003721 if (err < 0)
3722 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003723 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003724 imux->items[imux->num_items].index = idx;
3725 imux->num_items++;
3726 }
3727 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3728 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003729 err = new_analog_input(spec, cfg->input_pins[i],
3730 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003731 if (err < 0)
3732 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003733 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003734 imux->items[imux->num_items].index = idx;
3735 imux->num_items++;
3736 }
3737 }
3738 return 0;
3739}
3740
3741static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3742 hda_nid_t nid, int pin_type,
3743 int sel_idx)
3744{
3745 /* set as output */
3746 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3747 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3748 /* need the manual connection? */
3749 if (nid >= 0x12) {
3750 int idx = nid - 0x12;
3751 snd_hda_codec_write(codec, idx + 0x0b, 0,
3752 AC_VERB_SET_CONNECT_SEL, sel_idx);
3753
3754 }
3755}
3756
3757static void alc260_auto_init_multi_out(struct hda_codec *codec)
3758{
3759 struct alc_spec *spec = codec->spec;
3760 hda_nid_t nid;
3761
3762 nid = spec->autocfg.line_out_pins[0];
3763 if (nid)
3764 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3765
Takashi Iwai82bc9552006-03-21 11:24:42 +01003766 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003767 if (nid)
3768 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3769
3770 nid = spec->autocfg.hp_pin;
3771 if (nid)
3772 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3773}
3774
3775#define ALC260_PIN_CD_NID 0x16
3776static void alc260_auto_init_analog_input(struct hda_codec *codec)
3777{
3778 struct alc_spec *spec = codec->spec;
3779 int i;
3780
3781 for (i = 0; i < AUTO_PIN_LAST; i++) {
3782 hda_nid_t nid = spec->autocfg.input_pins[i];
3783 if (nid >= 0x12) {
3784 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3785 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3786 if (nid != ALC260_PIN_CD_NID)
3787 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3788 AMP_OUT_MUTE);
3789 }
3790 }
3791}
3792
3793/*
3794 * generic initialization of ADC, input mixers and output mixers
3795 */
3796static struct hda_verb alc260_volume_init_verbs[] = {
3797 /*
3798 * Unmute ADC0-1 and set the default input to mic-in
3799 */
3800 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3801 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3802 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3803 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3804
3805 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3806 * mixer widget
3807 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3808 * mic (mic 2)
3809 */
3810 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3812 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3816
3817 /*
3818 * Set up output mixers (0x08 - 0x0a)
3819 */
3820 /* set vol=0 to output mixers */
3821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3823 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3824 /* set up input amps for analog loopback */
3825 /* Amp Indices: DAC = 0, mixer = 1 */
3826 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3830 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3831 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3832
3833 { }
3834};
3835
3836static int alc260_parse_auto_config(struct hda_codec *codec)
3837{
3838 struct alc_spec *spec = codec->spec;
3839 unsigned int wcap;
3840 int err;
3841 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3842
3843 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3844 alc260_ignore)) < 0)
3845 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003846 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3847 return err;
3848 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003849 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003850 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003851 return err;
3852
3853 spec->multiout.max_channels = 2;
3854
3855 if (spec->autocfg.dig_out_pin)
3856 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3857 if (spec->kctl_alloc)
3858 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3859
3860 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3861
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003862 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01003863 spec->input_mux = &spec->private_imux;
3864
3865 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003866 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003867 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3868 if (wcap != AC_WID_AUD_IN) {
3869 spec->adc_nids = alc260_adc_nids_alt;
3870 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3871 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003872 } else {
3873 spec->adc_nids = alc260_adc_nids;
3874 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3875 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003876 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003877 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003878
3879 return 1;
3880}
3881
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003882/* additional initialization for auto-configuration model */
3883static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01003884{
Kailang Yangdf694da2005-12-05 19:42:22 +01003885 alc260_auto_init_multi_out(codec);
3886 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01003887}
3888
3889/*
3890 * ALC260 configurations
3891 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003892static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003893 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003894 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3895 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai3206b9c2006-05-10 16:33:11 +02003896 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3897 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02003898 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3899 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01003900 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3901 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02003902 { .modelname = "hp", .config = ALC260_HP },
Kailang Yangdf694da2005-12-05 19:42:22 +01003903 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3904 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
Takashi Iwai766a6c32006-05-26 14:58:29 +02003905 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003906 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3907 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3908 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3909 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3910 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3911 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003912 { .modelname = "acer", .config = ALC260_ACER },
3913 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003914#ifdef CONFIG_SND_DEBUG
3915 { .modelname = "test", .config = ALC260_TEST },
3916#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003917 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003918 {}
3919};
3920
Kailang Yangdf694da2005-12-05 19:42:22 +01003921static struct alc_config_preset alc260_presets[] = {
3922 [ALC260_BASIC] = {
3923 .mixers = { alc260_base_output_mixer,
3924 alc260_input_mixer,
3925 alc260_pc_beep_mixer,
3926 alc260_capture_mixer },
3927 .init_verbs = { alc260_init_verbs },
3928 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3929 .dac_nids = alc260_dac_nids,
3930 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3931 .adc_nids = alc260_adc_nids,
3932 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3933 .channel_mode = alc260_modes,
3934 .input_mux = &alc260_capture_source,
3935 },
3936 [ALC260_HP] = {
3937 .mixers = { alc260_base_output_mixer,
3938 alc260_input_mixer,
3939 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02003940 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01003941 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3942 .dac_nids = alc260_dac_nids,
3943 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3944 .adc_nids = alc260_hp_adc_nids,
3945 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3946 .channel_mode = alc260_modes,
3947 .input_mux = &alc260_capture_source,
3948 },
3949 [ALC260_HP_3013] = {
3950 .mixers = { alc260_hp_3013_mixer,
3951 alc260_input_mixer,
3952 alc260_capture_alt_mixer },
3953 .init_verbs = { alc260_hp_3013_init_verbs },
3954 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3955 .dac_nids = alc260_dac_nids,
3956 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3957 .adc_nids = alc260_hp_adc_nids,
3958 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3959 .channel_mode = alc260_modes,
3960 .input_mux = &alc260_capture_source,
3961 },
3962 [ALC260_FUJITSU_S702X] = {
3963 .mixers = { alc260_fujitsu_mixer,
3964 alc260_capture_mixer },
3965 .init_verbs = { alc260_fujitsu_init_verbs },
3966 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3967 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003968 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3969 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01003970 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3971 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003972 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
3973 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01003974 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003975 [ALC260_ACER] = {
3976 .mixers = { alc260_acer_mixer,
3977 alc260_capture_mixer },
3978 .init_verbs = { alc260_acer_init_verbs },
3979 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3980 .dac_nids = alc260_dac_nids,
3981 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3982 .adc_nids = alc260_dual_adc_nids,
3983 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3984 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003985 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
3986 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003987 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003988#ifdef CONFIG_SND_DEBUG
3989 [ALC260_TEST] = {
3990 .mixers = { alc260_test_mixer,
3991 alc260_capture_mixer },
3992 .init_verbs = { alc260_test_init_verbs },
3993 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3994 .dac_nids = alc260_test_dac_nids,
3995 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3996 .adc_nids = alc260_test_adc_nids,
3997 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3998 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003999 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4000 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004001 },
4002#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004003};
4004
Linus Torvalds1da177e2005-04-16 15:20:36 -07004005static int patch_alc260(struct hda_codec *codec)
4006{
4007 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004008 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004009
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004010 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004011 if (spec == NULL)
4012 return -ENOMEM;
4013
4014 codec->spec = spec;
4015
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4017 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004018 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4019 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004020 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 }
4022
Kailang Yangdf694da2005-12-05 19:42:22 +01004023 if (board_config == ALC260_AUTO) {
4024 /* automatic parse from the BIOS config */
4025 err = alc260_parse_auto_config(codec);
4026 if (err < 0) {
4027 alc_free(codec);
4028 return err;
4029 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004030 printk(KERN_INFO
4031 "hda_codec: Cannot set up configuration "
4032 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004033 board_config = ALC260_BASIC;
4034 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004036
Kailang Yangdf694da2005-12-05 19:42:22 +01004037 if (board_config != ALC260_AUTO)
4038 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004039
4040 spec->stream_name_analog = "ALC260 Analog";
4041 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4042 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4043
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004044 spec->stream_name_digital = "ALC260 Digital";
4045 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4046 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4047
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004049 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004050 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051
4052 return 0;
4053}
4054
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004055
Linus Torvalds1da177e2005-04-16 15:20:36 -07004056/*
4057 * ALC882 support
4058 *
4059 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4060 * configuration. Each pin widget can choose any input DACs and a mixer.
4061 * Each ADC is connected from a mixer of all inputs. This makes possible
4062 * 6-channel independent captures.
4063 *
4064 * In addition, an independent DAC for the multi-playback (not used in this
4065 * driver yet).
4066 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004067#define ALC882_DIGOUT_NID 0x06
4068#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004069
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004070static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004071 { 8, NULL }
4072};
4073
4074static hda_nid_t alc882_dac_nids[4] = {
4075 /* front, rear, clfe, rear_surr */
4076 0x02, 0x03, 0x04, 0x05
4077};
4078
Kailang Yangdf694da2005-12-05 19:42:22 +01004079/* identical with ALC880 */
4080#define alc882_adc_nids alc880_adc_nids
4081#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004082
4083/* input MUX */
4084/* FIXME: should be a matrix-type input source selection */
4085
4086static struct hda_input_mux alc882_capture_source = {
4087 .num_items = 4,
4088 .items = {
4089 { "Mic", 0x0 },
4090 { "Front Mic", 0x1 },
4091 { "Line", 0x2 },
4092 { "CD", 0x4 },
4093 },
4094};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004095#define alc882_mux_enum_info alc_mux_enum_info
4096#define alc882_mux_enum_get alc_mux_enum_get
4097
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004098static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004099{
4100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4101 struct alc_spec *spec = codec->spec;
4102 const struct hda_input_mux *imux = spec->input_mux;
4103 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4104 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4105 hda_nid_t nid = capture_mixers[adc_idx];
4106 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4107 unsigned int i, idx;
4108
4109 idx = ucontrol->value.enumerated.item[0];
4110 if (idx >= imux->num_items)
4111 idx = imux->num_items - 1;
4112 if (*cur_val == idx && ! codec->in_resume)
4113 return 0;
4114 for (i = 0; i < imux->num_items; i++) {
4115 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4116 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4117 v | (imux->items[i].index << 8));
4118 }
4119 *cur_val = idx;
4120 return 1;
4121}
4122
Kailang Yangdf694da2005-12-05 19:42:22 +01004123/*
4124 * 6ch mode
4125 */
4126static struct hda_verb alc882_sixstack_ch6_init[] = {
4127 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4128 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4129 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4130 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4131 { } /* end */
4132};
4133
4134/*
4135 * 8ch mode
4136 */
4137static struct hda_verb alc882_sixstack_ch8_init[] = {
4138 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4139 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4140 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4141 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4142 { } /* end */
4143};
4144
4145static struct hda_channel_mode alc882_sixstack_modes[2] = {
4146 { 6, alc882_sixstack_ch6_init },
4147 { 8, alc882_sixstack_ch8_init },
4148};
4149
Linus Torvalds1da177e2005-04-16 15:20:36 -07004150/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4151 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4152 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004153static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004154 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004155 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004156 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004157 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004158 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4159 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004160 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4161 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004162 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004163 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4165 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4166 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4167 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4168 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4171 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4172 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4173 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4174 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004175 { } /* end */
4176};
4177
Kailang Yangdf694da2005-12-05 19:42:22 +01004178static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4179 {
4180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4181 .name = "Channel Mode",
4182 .info = alc_ch_mode_info,
4183 .get = alc_ch_mode_get,
4184 .put = alc_ch_mode_put,
4185 },
4186 { } /* end */
4187};
4188
Linus Torvalds1da177e2005-04-16 15:20:36 -07004189static struct hda_verb alc882_init_verbs[] = {
4190 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4193 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004194 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4197 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004198 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4200 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004202 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4205 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004210 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004211 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004215 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004216 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004218 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004219 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004220 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004221 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004222 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004225 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4226 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4229 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004231 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4232 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4235 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004236 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004237 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004238
4239 /* FIXME: use matrix-type input source selection */
4240 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4241 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004246 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004251 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4256 /* ADC1: mute amp left and right */
4257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004258 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004259 /* ADC2: mute amp left and right */
4260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004261 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004262 /* ADC3: mute amp left and right */
4263 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004264 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004265
4266 { }
4267};
4268
Kailang Yangdf694da2005-12-05 19:42:22 +01004269/*
4270 * generic initialization of ADC, input mixers and output mixers
4271 */
4272static struct hda_verb alc882_auto_init_verbs[] = {
4273 /*
4274 * Unmute ADC0-2 and set the default input to mic-in
4275 */
4276 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4282
4283 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4284 * mixer widget
4285 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4286 * mic (mic 2)
4287 */
4288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4294
4295 /*
4296 * Set up output mixers (0x0c - 0x0f)
4297 */
4298 /* set vol=0 to output mixers */
4299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4303 /* set up input amps for analog loopback */
4304 /* Amp Indices: DAC = 0, mixer = 1 */
4305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4313 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4314 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4315
4316 /* FIXME: use matrix-type input source selection */
4317 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4318 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4323 /* Input mixer2 */
4324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4328 /* Input mixer3 */
4329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4333
4334 { }
4335};
4336
4337/* capture mixer elements */
4338static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4339 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4340 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4341 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4342 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4343 {
4344 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4345 /* The multiple "Capture Source" controls confuse alsamixer
4346 * So call somewhat different..
4347 * FIXME: the controls appear in the "playback" view!
4348 */
4349 /* .name = "Capture Source", */
4350 .name = "Input Source",
4351 .count = 2,
4352 .info = alc882_mux_enum_info,
4353 .get = alc882_mux_enum_get,
4354 .put = alc882_mux_enum_put,
4355 },
4356 { } /* end */
4357};
4358
4359static struct snd_kcontrol_new alc882_capture_mixer[] = {
4360 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4361 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4362 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4363 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4364 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4365 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4366 {
4367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4368 /* The multiple "Capture Source" controls confuse alsamixer
4369 * So call somewhat different..
4370 * FIXME: the controls appear in the "playback" view!
4371 */
4372 /* .name = "Capture Source", */
4373 .name = "Input Source",
4374 .count = 3,
4375 .info = alc882_mux_enum_info,
4376 .get = alc882_mux_enum_get,
4377 .put = alc882_mux_enum_put,
4378 },
4379 { } /* end */
4380};
4381
4382/* pcm configuration: identiacal with ALC880 */
4383#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4384#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4385#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4386#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4387
4388/*
4389 * configuration and preset
4390 */
4391static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004392 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4393 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004394 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4395 .config = ALC882_6ST_DIG }, /* MSI */
4396 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4397 .config = ALC882_6ST_DIG }, /* Foxconn */
4398 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4399 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
Takashi Iwai1494a922006-01-31 10:58:46 +01004400 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004401 {}
4402};
4403
4404static struct alc_config_preset alc882_presets[] = {
4405 [ALC882_3ST_DIG] = {
4406 .mixers = { alc882_base_mixer },
4407 .init_verbs = { alc882_init_verbs },
4408 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4409 .dac_nids = alc882_dac_nids,
4410 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004411 .dig_in_nid = ALC882_DIGIN_NID,
4412 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4413 .channel_mode = alc882_ch_modes,
4414 .input_mux = &alc882_capture_source,
4415 },
4416 [ALC882_6ST_DIG] = {
4417 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4418 .init_verbs = { alc882_init_verbs },
4419 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4420 .dac_nids = alc882_dac_nids,
4421 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004422 .dig_in_nid = ALC882_DIGIN_NID,
4423 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4424 .channel_mode = alc882_sixstack_modes,
4425 .input_mux = &alc882_capture_source,
4426 },
4427};
4428
4429
4430/*
4431 * BIOS auto configuration
4432 */
4433static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4434 hda_nid_t nid, int pin_type,
4435 int dac_idx)
4436{
4437 /* set as output */
4438 struct alc_spec *spec = codec->spec;
4439 int idx;
4440
4441 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4442 idx = 4;
4443 else
4444 idx = spec->multiout.dac_nids[dac_idx] - 2;
4445
4446 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4447 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4448 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4449
4450}
4451
4452static void alc882_auto_init_multi_out(struct hda_codec *codec)
4453{
4454 struct alc_spec *spec = codec->spec;
4455 int i;
4456
4457 for (i = 0; i <= HDA_SIDE; i++) {
4458 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4459 if (nid)
4460 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4461 }
4462}
4463
4464static void alc882_auto_init_hp_out(struct hda_codec *codec)
4465{
4466 struct alc_spec *spec = codec->spec;
4467 hda_nid_t pin;
4468
4469 pin = spec->autocfg.hp_pin;
4470 if (pin) /* connect to front */
4471 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4472}
4473
4474#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4475#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4476
4477static void alc882_auto_init_analog_input(struct hda_codec *codec)
4478{
4479 struct alc_spec *spec = codec->spec;
4480 int i;
4481
4482 for (i = 0; i < AUTO_PIN_LAST; i++) {
4483 hda_nid_t nid = spec->autocfg.input_pins[i];
4484 if (alc882_is_input_pin(nid)) {
4485 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4486 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4487 if (nid != ALC882_PIN_CD_NID)
4488 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4489 AMP_OUT_MUTE);
4490 }
4491 }
4492}
4493
4494/* almost identical with ALC880 parser... */
4495static int alc882_parse_auto_config(struct hda_codec *codec)
4496{
4497 struct alc_spec *spec = codec->spec;
4498 int err = alc880_parse_auto_config(codec);
4499
4500 if (err < 0)
4501 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004502 else if (err > 0)
4503 /* hack - override the init verbs */
4504 spec->init_verbs[0] = alc882_auto_init_verbs;
4505 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004506}
4507
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004508/* additional initialization for auto-configuration model */
4509static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004510{
Kailang Yangdf694da2005-12-05 19:42:22 +01004511 alc882_auto_init_multi_out(codec);
4512 alc882_auto_init_hp_out(codec);
4513 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004514}
4515
Linus Torvalds1da177e2005-04-16 15:20:36 -07004516static int patch_alc882(struct hda_codec *codec)
4517{
4518 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004519 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004520
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004521 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004522 if (spec == NULL)
4523 return -ENOMEM;
4524
Linus Torvalds1da177e2005-04-16 15:20:36 -07004525 codec->spec = spec;
4526
Kailang Yangdf694da2005-12-05 19:42:22 +01004527 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004528
Kailang Yangdf694da2005-12-05 19:42:22 +01004529 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004530 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4531 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004532 board_config = ALC882_AUTO;
4533 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004534
Kailang Yangdf694da2005-12-05 19:42:22 +01004535 if (board_config == ALC882_AUTO) {
4536 /* automatic parse from the BIOS config */
4537 err = alc882_parse_auto_config(codec);
4538 if (err < 0) {
4539 alc_free(codec);
4540 return err;
4541 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004542 printk(KERN_INFO
4543 "hda_codec: Cannot set up configuration "
4544 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004545 board_config = ALC882_3ST_DIG;
4546 }
4547 }
4548
4549 if (board_config != ALC882_AUTO)
4550 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004551
4552 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004553 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4554 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004555
4556 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004557 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4558 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559
Kailang Yangdf694da2005-12-05 19:42:22 +01004560 if (! spec->adc_nids && spec->input_mux) {
4561 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004562 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004563 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4564 if (wcap != AC_WID_AUD_IN) {
4565 spec->adc_nids = alc882_adc_nids_alt;
4566 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4567 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4568 spec->num_mixers++;
4569 } else {
4570 spec->adc_nids = alc882_adc_nids;
4571 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4572 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4573 spec->num_mixers++;
4574 }
4575 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004576
4577 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004578 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004579 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004580
4581 return 0;
4582}
4583
4584/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004585 * ALC883 support
4586 *
4587 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4588 * configuration. Each pin widget can choose any input DACs and a mixer.
4589 * Each ADC is connected from a mixer of all inputs. This makes possible
4590 * 6-channel independent captures.
4591 *
4592 * In addition, an independent DAC for the multi-playback (not used in this
4593 * driver yet).
4594 */
4595#define ALC883_DIGOUT_NID 0x06
4596#define ALC883_DIGIN_NID 0x0a
4597
4598static hda_nid_t alc883_dac_nids[4] = {
4599 /* front, rear, clfe, rear_surr */
4600 0x02, 0x04, 0x03, 0x05
4601};
4602
4603static hda_nid_t alc883_adc_nids[2] = {
4604 /* ADC1-2 */
4605 0x08, 0x09,
4606};
4607/* input MUX */
4608/* FIXME: should be a matrix-type input source selection */
4609
4610static struct hda_input_mux alc883_capture_source = {
4611 .num_items = 4,
4612 .items = {
4613 { "Mic", 0x0 },
4614 { "Front Mic", 0x1 },
4615 { "Line", 0x2 },
4616 { "CD", 0x4 },
4617 },
4618};
4619#define alc883_mux_enum_info alc_mux_enum_info
4620#define alc883_mux_enum_get alc_mux_enum_get
4621
4622static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4623 struct snd_ctl_elem_value *ucontrol)
4624{
4625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4626 struct alc_spec *spec = codec->spec;
4627 const struct hda_input_mux *imux = spec->input_mux;
4628 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4629 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4630 hda_nid_t nid = capture_mixers[adc_idx];
4631 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4632 unsigned int i, idx;
4633
4634 idx = ucontrol->value.enumerated.item[0];
4635 if (idx >= imux->num_items)
4636 idx = imux->num_items - 1;
4637 if (*cur_val == idx && ! codec->in_resume)
4638 return 0;
4639 for (i = 0; i < imux->num_items; i++) {
4640 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4641 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4642 v | (imux->items[i].index << 8));
4643 }
4644 *cur_val = idx;
4645 return 1;
4646}
4647/*
4648 * 2ch mode
4649 */
4650static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4651 { 2, NULL }
4652};
4653
4654/*
4655 * 2ch mode
4656 */
4657static struct hda_verb alc883_3ST_ch2_init[] = {
4658 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4660 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4661 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4662 { } /* end */
4663};
4664
4665/*
4666 * 6ch mode
4667 */
4668static struct hda_verb alc883_3ST_ch6_init[] = {
4669 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4670 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4671 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4672 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4673 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4674 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4675 { } /* end */
4676};
4677
4678static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4679 { 2, alc883_3ST_ch2_init },
4680 { 6, alc883_3ST_ch6_init },
4681};
4682
4683/*
4684 * 6ch mode
4685 */
4686static struct hda_verb alc883_sixstack_ch6_init[] = {
4687 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4688 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4689 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4690 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4691 { } /* end */
4692};
4693
4694/*
4695 * 8ch mode
4696 */
4697static struct hda_verb alc883_sixstack_ch8_init[] = {
4698 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4699 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4700 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4701 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4702 { } /* end */
4703};
4704
4705static struct hda_channel_mode alc883_sixstack_modes[2] = {
4706 { 6, alc883_sixstack_ch6_init },
4707 { 8, alc883_sixstack_ch8_init },
4708};
4709
4710/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4711 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4712 */
4713
4714static struct snd_kcontrol_new alc883_base_mixer[] = {
4715 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4716 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4717 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4718 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4719 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4720 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4721 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4722 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4723 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4724 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4726 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4727 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4732 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4733 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4734 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4735 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4736 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4737 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4738 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4739 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4740 {
4741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4742 /* .name = "Capture Source", */
4743 .name = "Input Source",
4744 .count = 2,
4745 .info = alc883_mux_enum_info,
4746 .get = alc883_mux_enum_get,
4747 .put = alc883_mux_enum_put,
4748 },
4749 { } /* end */
4750};
4751
4752static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4762 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4764 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4765 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4766 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4767 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4768 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4769 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4770 {
4771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4772 /* .name = "Capture Source", */
4773 .name = "Input Source",
4774 .count = 2,
4775 .info = alc883_mux_enum_info,
4776 .get = alc883_mux_enum_get,
4777 .put = alc883_mux_enum_put,
4778 },
4779 { } /* end */
4780};
4781
4782static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4786 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4788 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4800 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4801 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4802 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4803 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4804 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4805 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4806 {
4807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4808 /* .name = "Capture Source", */
4809 .name = "Input Source",
4810 .count = 2,
4811 .info = alc883_mux_enum_info,
4812 .get = alc883_mux_enum_get,
4813 .put = alc883_mux_enum_put,
4814 },
4815 { } /* end */
4816};
4817
4818static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4819 {
4820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4821 .name = "Channel Mode",
4822 .info = alc_ch_mode_info,
4823 .get = alc_ch_mode_get,
4824 .put = alc_ch_mode_put,
4825 },
4826 { } /* end */
4827};
4828
4829static struct hda_verb alc883_init_verbs[] = {
4830 /* ADC1: mute amp left and right */
4831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4832 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4833 /* ADC2: mute amp left and right */
4834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4835 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4836 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4840 /* Rear mixer */
4841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4843 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4844 /* CLFE mixer */
4845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4848 /* Side mixer */
4849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4852
4853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4858
4859 /* Front Pin: output 0 (0x0c) */
4860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4862 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4863 /* Rear Pin: output 1 (0x0d) */
4864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4867 /* CLFE Pin: output 2 (0x0e) */
4868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4870 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4871 /* Side Pin: output 3 (0x0f) */
4872 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4874 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4875 /* Mic (rear) pin: input vref at 80% */
4876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4878 /* Front Mic pin: input vref at 80% */
4879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4881 /* Line In pin: input */
4882 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4884 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4886 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4887 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4888 /* CD pin widget for input */
4889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4890
4891 /* FIXME: use matrix-type input source selection */
4892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4893 /* Input mixer2 */
4894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4898 /* Input mixer3 */
4899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4903 { }
4904};
4905
4906/*
4907 * generic initialization of ADC, input mixers and output mixers
4908 */
4909static struct hda_verb alc883_auto_init_verbs[] = {
4910 /*
4911 * Unmute ADC0-2 and set the default input to mic-in
4912 */
4913 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4914 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4915 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4917
4918 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4919 * mixer widget
4920 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4921 * mic (mic 2)
4922 */
4923 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4929
4930 /*
4931 * Set up output mixers (0x0c - 0x0f)
4932 */
4933 /* set vol=0 to output mixers */
4934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4938 /* set up input amps for analog loopback */
4939 /* Amp Indices: DAC = 0, mixer = 1 */
4940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4948 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4949 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4950
4951 /* FIXME: use matrix-type input source selection */
4952 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4953 /* Input mixer1 */
4954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4957 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4958 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4959 /* Input mixer2 */
4960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4963 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4965
4966 { }
4967};
4968
4969/* capture mixer elements */
4970static struct snd_kcontrol_new alc883_capture_mixer[] = {
4971 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4972 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4973 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4974 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4975 {
4976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4977 /* The multiple "Capture Source" controls confuse alsamixer
4978 * So call somewhat different..
4979 * FIXME: the controls appear in the "playback" view!
4980 */
4981 /* .name = "Capture Source", */
4982 .name = "Input Source",
4983 .count = 2,
4984 .info = alc882_mux_enum_info,
4985 .get = alc882_mux_enum_get,
4986 .put = alc882_mux_enum_put,
4987 },
4988 { } /* end */
4989};
4990
4991/* pcm configuration: identiacal with ALC880 */
4992#define alc883_pcm_analog_playback alc880_pcm_analog_playback
4993#define alc883_pcm_analog_capture alc880_pcm_analog_capture
4994#define alc883_pcm_digital_playback alc880_pcm_digital_playback
4995#define alc883_pcm_digital_capture alc880_pcm_digital_capture
4996
4997/*
4998 * configuration and preset
4999 */
5000static struct hda_board_config alc883_cfg_tbl[] = {
5001 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5002 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5003 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5004 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5005 .config = ALC883_6ST_DIG }, /* MSI */
5006 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5007 .config = ALC883_6ST_DIG }, /* Foxconn */
5008 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5009 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5010 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5011 .config = ALC883_3ST_6ch },
5012 { .modelname = "auto", .config = ALC883_AUTO },
5013 {}
5014};
5015
5016static struct alc_config_preset alc883_presets[] = {
5017 [ALC883_3ST_2ch_DIG] = {
5018 .mixers = { alc883_3ST_2ch_mixer },
5019 .init_verbs = { alc883_init_verbs },
5020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5021 .dac_nids = alc883_dac_nids,
5022 .dig_out_nid = ALC883_DIGOUT_NID,
5023 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5024 .adc_nids = alc883_adc_nids,
5025 .dig_in_nid = ALC883_DIGIN_NID,
5026 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5027 .channel_mode = alc883_3ST_2ch_modes,
5028 .input_mux = &alc883_capture_source,
5029 },
5030 [ALC883_3ST_6ch_DIG] = {
5031 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5032 .init_verbs = { alc883_init_verbs },
5033 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5034 .dac_nids = alc883_dac_nids,
5035 .dig_out_nid = ALC883_DIGOUT_NID,
5036 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5037 .adc_nids = alc883_adc_nids,
5038 .dig_in_nid = ALC883_DIGIN_NID,
5039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5040 .channel_mode = alc883_3ST_6ch_modes,
5041 .input_mux = &alc883_capture_source,
5042 },
5043 [ALC883_3ST_6ch] = {
5044 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5045 .init_verbs = { alc883_init_verbs },
5046 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5047 .dac_nids = alc883_dac_nids,
5048 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5049 .adc_nids = alc883_adc_nids,
5050 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5051 .channel_mode = alc883_3ST_6ch_modes,
5052 .input_mux = &alc883_capture_source,
5053 },
5054 [ALC883_6ST_DIG] = {
5055 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5056 .init_verbs = { alc883_init_verbs },
5057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5058 .dac_nids = alc883_dac_nids,
5059 .dig_out_nid = ALC883_DIGOUT_NID,
5060 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5061 .adc_nids = alc883_adc_nids,
5062 .dig_in_nid = ALC883_DIGIN_NID,
5063 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5064 .channel_mode = alc883_sixstack_modes,
5065 .input_mux = &alc883_capture_source,
5066 },
5067 [ALC888_DEMO_BOARD] = {
5068 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5069 .init_verbs = { alc883_init_verbs },
5070 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5071 .dac_nids = alc883_dac_nids,
5072 .dig_out_nid = ALC883_DIGOUT_NID,
5073 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5074 .adc_nids = alc883_adc_nids,
5075 .dig_in_nid = ALC883_DIGIN_NID,
5076 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5077 .channel_mode = alc883_sixstack_modes,
5078 .input_mux = &alc883_capture_source,
5079 },
5080};
5081
5082
5083/*
5084 * BIOS auto configuration
5085 */
5086static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5087 hda_nid_t nid, int pin_type,
5088 int dac_idx)
5089{
5090 /* set as output */
5091 struct alc_spec *spec = codec->spec;
5092 int idx;
5093
5094 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5095 idx = 4;
5096 else
5097 idx = spec->multiout.dac_nids[dac_idx] - 2;
5098
5099 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5100 pin_type);
5101 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5102 AMP_OUT_UNMUTE);
5103 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5104
5105}
5106
5107static void alc883_auto_init_multi_out(struct hda_codec *codec)
5108{
5109 struct alc_spec *spec = codec->spec;
5110 int i;
5111
5112 for (i = 0; i <= HDA_SIDE; i++) {
5113 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5114 if (nid)
5115 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5116 }
5117}
5118
5119static void alc883_auto_init_hp_out(struct hda_codec *codec)
5120{
5121 struct alc_spec *spec = codec->spec;
5122 hda_nid_t pin;
5123
5124 pin = spec->autocfg.hp_pin;
5125 if (pin) /* connect to front */
5126 /* use dac 0 */
5127 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5128}
5129
5130#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5131#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5132
5133static void alc883_auto_init_analog_input(struct hda_codec *codec)
5134{
5135 struct alc_spec *spec = codec->spec;
5136 int i;
5137
5138 for (i = 0; i < AUTO_PIN_LAST; i++) {
5139 hda_nid_t nid = spec->autocfg.input_pins[i];
5140 if (alc883_is_input_pin(nid)) {
5141 snd_hda_codec_write(codec, nid, 0,
5142 AC_VERB_SET_PIN_WIDGET_CONTROL,
5143 (i <= AUTO_PIN_FRONT_MIC ?
5144 PIN_VREF80 : PIN_IN));
5145 if (nid != ALC883_PIN_CD_NID)
5146 snd_hda_codec_write(codec, nid, 0,
5147 AC_VERB_SET_AMP_GAIN_MUTE,
5148 AMP_OUT_MUTE);
5149 }
5150 }
5151}
5152
5153/* almost identical with ALC880 parser... */
5154static int alc883_parse_auto_config(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
5157 int err = alc880_parse_auto_config(codec);
5158
5159 if (err < 0)
5160 return err;
5161 else if (err > 0)
5162 /* hack - override the init verbs */
5163 spec->init_verbs[0] = alc883_auto_init_verbs;
5164 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5165 spec->num_mixers++;
5166 return err;
5167}
5168
5169/* additional initialization for auto-configuration model */
5170static void alc883_auto_init(struct hda_codec *codec)
5171{
5172 alc883_auto_init_multi_out(codec);
5173 alc883_auto_init_hp_out(codec);
5174 alc883_auto_init_analog_input(codec);
5175}
5176
5177static int patch_alc883(struct hda_codec *codec)
5178{
5179 struct alc_spec *spec;
5180 int err, board_config;
5181
5182 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5183 if (spec == NULL)
5184 return -ENOMEM;
5185
5186 codec->spec = spec;
5187
5188 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5189 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5190 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5191 "trying auto-probe from BIOS...\n");
5192 board_config = ALC883_AUTO;
5193 }
5194
5195 if (board_config == ALC883_AUTO) {
5196 /* automatic parse from the BIOS config */
5197 err = alc883_parse_auto_config(codec);
5198 if (err < 0) {
5199 alc_free(codec);
5200 return err;
5201 } else if (! err) {
5202 printk(KERN_INFO
5203 "hda_codec: Cannot set up configuration "
5204 "from BIOS. Using base mode...\n");
5205 board_config = ALC883_3ST_2ch_DIG;
5206 }
5207 }
5208
5209 if (board_config != ALC883_AUTO)
5210 setup_preset(spec, &alc883_presets[board_config]);
5211
5212 spec->stream_name_analog = "ALC883 Analog";
5213 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5214 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5215
5216 spec->stream_name_digital = "ALC883 Digital";
5217 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5218 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5219
5220 spec->adc_nids = alc883_adc_nids;
5221 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5222
5223 codec->patch_ops = alc_patch_ops;
5224 if (board_config == ALC883_AUTO)
5225 spec->init_hook = alc883_auto_init;
5226
5227 return 0;
5228}
5229
5230/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005231 * ALC262 support
5232 */
5233
5234#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5235#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5236
5237#define alc262_dac_nids alc260_dac_nids
5238#define alc262_adc_nids alc882_adc_nids
5239#define alc262_adc_nids_alt alc882_adc_nids_alt
5240
5241#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005242#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005243
5244static struct snd_kcontrol_new alc262_base_mixer[] = {
5245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5246 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5247 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5248 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5250 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5253 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5254 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5255 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5256 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5257 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5259 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5260 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005261 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005262};
5263
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005264static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5265 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5266 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5268 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5269 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5270
5271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5276 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5277 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5278 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5279 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5280 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5281 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5282 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5283 { } /* end */
5284};
5285
Kailang Yangdf694da2005-12-05 19:42:22 +01005286#define alc262_capture_mixer alc882_capture_mixer
5287#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5288
5289/*
5290 * generic initialization of ADC, input mixers and output mixers
5291 */
5292static struct hda_verb alc262_init_verbs[] = {
5293 /*
5294 * Unmute ADC0-2 and set the default input to mic-in
5295 */
5296 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5298 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5300 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5302
5303 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5304 * mixer widget
5305 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5306 * mic (mic 2)
5307 */
5308 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5314
5315 /*
5316 * Set up output mixers (0x0c - 0x0e)
5317 */
5318 /* set vol=0 to output mixers */
5319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5322 /* set up input amps for analog loopback */
5323 /* Amp Indices: DAC = 0, mixer = 1 */
5324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5330
5331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5333 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5334 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5335 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5336 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5337
5338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5340 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5341 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5343
5344 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5345 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5346
5347 /* FIXME: use matrix-type input source selection */
5348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5349 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5354 /* Input mixer2 */
5355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5359 /* Input mixer3 */
5360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5364
5365 { }
5366};
5367
Takashi Iwai834be882006-03-01 14:16:17 +01005368/*
5369 * fujitsu model
5370 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5371 */
5372
5373#define ALC_HP_EVENT 0x37
5374
5375static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5378 {}
5379};
5380
5381static struct hda_input_mux alc262_fujitsu_capture_source = {
5382 .num_items = 2,
5383 .items = {
5384 { "Mic", 0x0 },
5385 { "CD", 0x4 },
5386 },
5387};
5388
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005389static struct hda_input_mux alc262_HP_capture_source = {
5390 .num_items = 5,
5391 .items = {
5392 { "Mic", 0x0 },
5393 { "Front Mic", 0x3 },
5394 { "Line", 0x2 },
5395 { "CD", 0x4 },
5396 { "AUX IN", 0x6 },
5397 },
5398};
5399
Takashi Iwai834be882006-03-01 14:16:17 +01005400/* mute/unmute internal speaker according to the hp jack and mute state */
5401static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5402{
5403 struct alc_spec *spec = codec->spec;
5404 unsigned int mute;
5405
5406 if (force || ! spec->sense_updated) {
5407 unsigned int present;
5408 /* need to execute and sync at first */
5409 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5410 present = snd_hda_codec_read(codec, 0x14, 0,
5411 AC_VERB_GET_PIN_SENSE, 0);
5412 spec->jack_present = (present & 0x80000000) != 0;
5413 spec->sense_updated = 1;
5414 }
5415 if (spec->jack_present) {
5416 /* mute internal speaker */
5417 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5418 0x80, 0x80);
5419 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5420 0x80, 0x80);
5421 } else {
5422 /* unmute internal speaker if necessary */
5423 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5424 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5425 0x80, mute & 0x80);
5426 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5427 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5428 0x80, mute & 0x80);
5429 }
5430}
5431
5432/* unsolicited event for HP jack sensing */
5433static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5434 unsigned int res)
5435{
5436 if ((res >> 26) != ALC_HP_EVENT)
5437 return;
5438 alc262_fujitsu_automute(codec, 1);
5439}
5440
5441/* bind volumes of both NID 0x0c and 0x0d */
5442static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5443 struct snd_ctl_elem_value *ucontrol)
5444{
5445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5446 long *valp = ucontrol->value.integer.value;
5447 int change;
5448
5449 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5450 0x7f, valp[0] & 0x7f);
5451 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5452 0x7f, valp[1] & 0x7f);
5453 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5454 0x7f, valp[0] & 0x7f);
5455 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5456 0x7f, valp[1] & 0x7f);
5457 return change;
5458}
5459
5460/* bind hp and internal speaker mute (with plug check) */
5461static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5462 struct snd_ctl_elem_value *ucontrol)
5463{
5464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5465 long *valp = ucontrol->value.integer.value;
5466 int change;
5467
5468 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5469 0x80, valp[0] ? 0 : 0x80);
5470 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5471 0x80, valp[1] ? 0 : 0x80);
5472 if (change || codec->in_resume)
5473 alc262_fujitsu_automute(codec, codec->in_resume);
5474 return change;
5475}
5476
5477static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5478 {
5479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5480 .name = "Master Playback Volume",
5481 .info = snd_hda_mixer_amp_volume_info,
5482 .get = snd_hda_mixer_amp_volume_get,
5483 .put = alc262_fujitsu_master_vol_put,
5484 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5485 },
5486 {
5487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5488 .name = "Master Playback Switch",
5489 .info = snd_hda_mixer_amp_switch_info,
5490 .get = snd_hda_mixer_amp_switch_get,
5491 .put = alc262_fujitsu_master_sw_put,
5492 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5493 },
5494 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5495 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5496 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5499 { } /* end */
5500};
5501
Kailang Yangdf694da2005-12-05 19:42:22 +01005502/* add playback controls from the parsed DAC table */
5503static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5504{
5505 hda_nid_t nid;
5506 int err;
5507
5508 spec->multiout.num_dacs = 1; /* only use one dac */
5509 spec->multiout.dac_nids = spec->private_dac_nids;
5510 spec->multiout.dac_nids[0] = 2;
5511
5512 nid = cfg->line_out_pins[0];
5513 if (nid) {
5514 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5515 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5516 return err;
5517 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5518 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5519 return err;
5520 }
5521
Takashi Iwai82bc9552006-03-21 11:24:42 +01005522 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005523 if (nid) {
5524 if (nid == 0x16) {
5525 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5526 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5527 return err;
5528 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5529 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5530 return err;
5531 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005532 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5533 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5534 return err;
5535 }
5536 }
5537 nid = cfg->hp_pin;
5538 if (nid) {
5539 /* spec->multiout.hp_nid = 2; */
5540 if (nid == 0x16) {
5541 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5542 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5543 return err;
5544 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5545 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5546 return err;
5547 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005548 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5549 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5550 return err;
5551 }
5552 }
5553 return 0;
5554}
5555
5556/* identical with ALC880 */
5557#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5558
5559/*
5560 * generic initialization of ADC, input mixers and output mixers
5561 */
5562static struct hda_verb alc262_volume_init_verbs[] = {
5563 /*
5564 * Unmute ADC0-2 and set the default input to mic-in
5565 */
5566 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5568 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5570 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5572
5573 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5574 * mixer widget
5575 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5576 * mic (mic 2)
5577 */
5578 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5584
5585 /*
5586 * Set up output mixers (0x0c - 0x0f)
5587 */
5588 /* set vol=0 to output mixers */
5589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5592
5593 /* set up input amps for analog loopback */
5594 /* Amp Indices: DAC = 0, mixer = 1 */
5595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5601
5602 /* FIXME: use matrix-type input source selection */
5603 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5604 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5609 /* Input mixer2 */
5610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5614 /* Input mixer3 */
5615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5619
5620 { }
5621};
5622
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005623static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5624 /*
5625 * Unmute ADC0-2 and set the default input to mic-in
5626 */
5627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5633
5634 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5635 * mixer widget
5636 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5637 * mic (mic 2)
5638 */
5639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5647
5648 /*
5649 * Set up output mixers (0x0c - 0x0e)
5650 */
5651 /* set vol=0 to output mixers */
5652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655
5656 /* set up input amps for analog loopback */
5657 /* Amp Indices: DAC = 0, mixer = 1 */
5658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5664
5665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5668
5669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5671
5672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5674
5675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5679 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5680
5681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5684 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5685 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5686 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5687
5688
5689 /* FIXME: use matrix-type input source selection */
5690 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5691 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5696 /* Input mixer2 */
5697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5701 /* Input mixer3 */
5702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5706
5707 { }
5708};
5709
Kailang Yangdf694da2005-12-05 19:42:22 +01005710/* pcm configuration: identiacal with ALC880 */
5711#define alc262_pcm_analog_playback alc880_pcm_analog_playback
5712#define alc262_pcm_analog_capture alc880_pcm_analog_capture
5713#define alc262_pcm_digital_playback alc880_pcm_digital_playback
5714#define alc262_pcm_digital_capture alc880_pcm_digital_capture
5715
5716/*
5717 * BIOS auto configuration
5718 */
5719static int alc262_parse_auto_config(struct hda_codec *codec)
5720{
5721 struct alc_spec *spec = codec->spec;
5722 int err;
5723 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5724
5725 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5726 alc262_ignore)) < 0)
5727 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005728 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005729 return 0; /* can't find valid BIOS pin config */
5730 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5731 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5732 return err;
5733
5734 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5735
5736 if (spec->autocfg.dig_out_pin)
5737 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5738 if (spec->autocfg.dig_in_pin)
5739 spec->dig_in_nid = ALC262_DIGIN_NID;
5740
5741 if (spec->kctl_alloc)
5742 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5743
5744 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005745 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005746 spec->input_mux = &spec->private_imux;
5747
5748 return 1;
5749}
5750
5751#define alc262_auto_init_multi_out alc882_auto_init_multi_out
5752#define alc262_auto_init_hp_out alc882_auto_init_hp_out
5753#define alc262_auto_init_analog_input alc882_auto_init_analog_input
5754
5755
5756/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005757static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005758{
Kailang Yangdf694da2005-12-05 19:42:22 +01005759 alc262_auto_init_multi_out(codec);
5760 alc262_auto_init_hp_out(codec);
5761 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005762}
5763
5764/*
5765 * configuration and preset
5766 */
5767static struct hda_board_config alc262_cfg_tbl[] = {
5768 { .modelname = "basic", .config = ALC262_BASIC },
Takashi Iwai834be882006-03-01 14:16:17 +01005769 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005770 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5771 .config = ALC262_FUJITSU },
5772 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5773 .config = ALC262_HP_BPC }, /* xw4400 */
5774 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5775 .config = ALC262_HP_BPC }, /* xw6400 */
5776 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5777 .config = ALC262_HP_BPC }, /* xw8400 */
5778 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5779 .config = ALC262_HP_BPC }, /* xw9400 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005780 { .modelname = "auto", .config = ALC262_AUTO },
5781 {}
5782};
5783
5784static struct alc_config_preset alc262_presets[] = {
5785 [ALC262_BASIC] = {
5786 .mixers = { alc262_base_mixer },
5787 .init_verbs = { alc262_init_verbs },
5788 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5789 .dac_nids = alc262_dac_nids,
5790 .hp_nid = 0x03,
5791 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5792 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005793 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01005794 },
Takashi Iwai834be882006-03-01 14:16:17 +01005795 [ALC262_FUJITSU] = {
5796 .mixers = { alc262_fujitsu_mixer },
5797 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5798 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5799 .dac_nids = alc262_dac_nids,
5800 .hp_nid = 0x03,
5801 .dig_out_nid = ALC262_DIGOUT_NID,
5802 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5803 .channel_mode = alc262_modes,
5804 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005805 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01005806 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005807 [ALC262_HP_BPC] = {
5808 .mixers = { alc262_HP_BPC_mixer },
5809 .init_verbs = { alc262_HP_BPC_init_verbs },
5810 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5811 .dac_nids = alc262_dac_nids,
5812 .hp_nid = 0x03,
5813 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5814 .channel_mode = alc262_modes,
5815 .input_mux = &alc262_HP_capture_source,
5816 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005817};
5818
5819static int patch_alc262(struct hda_codec *codec)
5820{
5821 struct alc_spec *spec;
5822 int board_config;
5823 int err;
5824
5825 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5826 if (spec == NULL)
5827 return -ENOMEM;
5828
5829 codec->spec = spec;
5830#if 0
5831 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5832 {
5833 int tmp;
5834 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5835 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5836 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5837 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5838 }
5839#endif
5840
5841 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005842
Kailang Yangdf694da2005-12-05 19:42:22 +01005843 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005844 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5845 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005846 board_config = ALC262_AUTO;
5847 }
5848
5849 if (board_config == ALC262_AUTO) {
5850 /* automatic parse from the BIOS config */
5851 err = alc262_parse_auto_config(codec);
5852 if (err < 0) {
5853 alc_free(codec);
5854 return err;
5855 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005856 printk(KERN_INFO
5857 "hda_codec: Cannot set up configuration "
5858 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005859 board_config = ALC262_BASIC;
5860 }
5861 }
5862
5863 if (board_config != ALC262_AUTO)
5864 setup_preset(spec, &alc262_presets[board_config]);
5865
5866 spec->stream_name_analog = "ALC262 Analog";
5867 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5868 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5869
5870 spec->stream_name_digital = "ALC262 Digital";
5871 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5872 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5873
5874 if (! spec->adc_nids && spec->input_mux) {
5875 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005876 unsigned int wcap = get_wcaps(codec, 0x07);
5877
Kailang Yangdf694da2005-12-05 19:42:22 +01005878 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5879 if (wcap != AC_WID_AUD_IN) {
5880 spec->adc_nids = alc262_adc_nids_alt;
5881 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5882 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5883 spec->num_mixers++;
5884 } else {
5885 spec->adc_nids = alc262_adc_nids;
5886 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5887 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5888 spec->num_mixers++;
5889 }
5890 }
5891
5892 codec->patch_ops = alc_patch_ops;
5893 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005894 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01005895
Kailang Yangdf694da2005-12-05 19:42:22 +01005896 return 0;
5897}
5898
Kailang Yangdf694da2005-12-05 19:42:22 +01005899/*
5900 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5901 */
5902
5903/*
5904 * set the path ways for 2 channel output
5905 * need to set the codec line out and mic 1 pin widgets to inputs
5906 */
5907static struct hda_verb alc861_threestack_ch2_init[] = {
5908 /* set pin widget 1Ah (line in) for input */
5909 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5910 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5911 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5912
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005913 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5914#if 0
5915 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5916 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
5917#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005918 { } /* end */
5919};
5920/*
5921 * 6ch mode
5922 * need to set the codec line out and mic 1 pin widgets to outputs
5923 */
5924static struct hda_verb alc861_threestack_ch6_init[] = {
5925 /* set pin widget 1Ah (line in) for output (Back Surround)*/
5926 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5927 /* set pin widget 18h (mic1) for output (CLFE)*/
5928 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5929
5930 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005931 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005932
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005933 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
5934#if 0
5935 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
5936 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
5937#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005938 { } /* end */
5939};
5940
5941static struct hda_channel_mode alc861_threestack_modes[2] = {
5942 { 2, alc861_threestack_ch2_init },
5943 { 6, alc861_threestack_ch6_init },
5944};
5945
5946/* patch-ALC861 */
5947
5948static struct snd_kcontrol_new alc861_base_mixer[] = {
5949 /* output mixer control */
5950 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5951 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5952 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5953 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5954 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
5955
5956 /*Input mixer control */
5957 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5959 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5962 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5964 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5965 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5967
5968 /* Capture mixer control */
5969 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5970 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5971 {
5972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5973 .name = "Capture Source",
5974 .count = 1,
5975 .info = alc_mux_enum_info,
5976 .get = alc_mux_enum_get,
5977 .put = alc_mux_enum_put,
5978 },
5979 { } /* end */
5980};
5981
5982static struct snd_kcontrol_new alc861_3ST_mixer[] = {
5983 /* output mixer control */
5984 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5986 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5987 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5988 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
5989
5990 /* Input mixer control */
5991 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5992 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5993 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5994 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5995 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5996 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5998 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5999 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6001
6002 /* Capture mixer control */
6003 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6004 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6005 {
6006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6007 .name = "Capture Source",
6008 .count = 1,
6009 .info = alc_mux_enum_info,
6010 .get = alc_mux_enum_get,
6011 .put = alc_mux_enum_put,
6012 },
6013 {
6014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6015 .name = "Channel Mode",
6016 .info = alc_ch_mode_info,
6017 .get = alc_ch_mode_get,
6018 .put = alc_ch_mode_put,
6019 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6020 },
6021 { } /* end */
6022};
6023
6024/*
6025 * generic initialization of ADC, input mixers and output mixers
6026 */
6027static struct hda_verb alc861_base_init_verbs[] = {
6028 /*
6029 * Unmute ADC0 and set the default input to mic-in
6030 */
6031 /* port-A for surround (rear panel) */
6032 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6033 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6034 /* port-B for mic-in (rear panel) with vref */
6035 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6036 /* port-C for line-in (rear panel) */
6037 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6038 /* port-D for Front */
6039 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6040 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6041 /* port-E for HP out (front panel) */
6042 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6043 /* route front PCM to HP */
6044 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6045 /* port-F for mic-in (front panel) with vref */
6046 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6047 /* port-G for CLFE (rear panel) */
6048 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6049 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6050 /* port-H for side (rear panel) */
6051 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6052 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6053 /* CD-in */
6054 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6055 /* route front mic to ADC1*/
6056 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6057 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6058
6059 /* Unmute DAC0~3 & spdif out*/
6060 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6061 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6062 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6063 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6065
6066 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6067 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6068 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6069 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6070 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6071
6072 /* Unmute Stereo Mixer 15 */
6073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6076 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6077
6078 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6079 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6081 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6083 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6084 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6085 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6088
6089 { }
6090};
6091
6092static struct hda_verb alc861_threestack_init_verbs[] = {
6093 /*
6094 * Unmute ADC0 and set the default input to mic-in
6095 */
6096 /* port-A for surround (rear panel) */
6097 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6098 /* port-B for mic-in (rear panel) with vref */
6099 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6100 /* port-C for line-in (rear panel) */
6101 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6102 /* port-D for Front */
6103 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6104 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6105 /* port-E for HP out (front panel) */
6106 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6107 /* route front PCM to HP */
6108 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6109 /* port-F for mic-in (front panel) with vref */
6110 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6111 /* port-G for CLFE (rear panel) */
6112 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6113 /* port-H for side (rear panel) */
6114 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6115 /* CD-in */
6116 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6117 /* route front mic to ADC1*/
6118 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6120 /* Unmute DAC0~3 & spdif out*/
6121 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6122 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6123 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6124 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6126
6127 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6128 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6129 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6130 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6131 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6132
6133 /* Unmute Stereo Mixer 15 */
6134 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6138
6139 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6140 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6141 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6142 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6143 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6144 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6145 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6148 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6149 { }
6150};
6151/*
6152 * generic initialization of ADC, input mixers and output mixers
6153 */
6154static struct hda_verb alc861_auto_init_verbs[] = {
6155 /*
6156 * Unmute ADC0 and set the default input to mic-in
6157 */
6158// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6160
6161 /* Unmute DAC0~3 & spdif out*/
6162 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6163 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6164 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6165 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6167
6168 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6169 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6170 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6171 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6172 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6173
6174 /* Unmute Stereo Mixer 15 */
6175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6179
6180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6181 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6183 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6188
6189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6197
6198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6199
6200 { }
6201};
6202
6203/* pcm configuration: identiacal with ALC880 */
6204#define alc861_pcm_analog_playback alc880_pcm_analog_playback
6205#define alc861_pcm_analog_capture alc880_pcm_analog_capture
6206#define alc861_pcm_digital_playback alc880_pcm_digital_playback
6207#define alc861_pcm_digital_capture alc880_pcm_digital_capture
6208
6209
6210#define ALC861_DIGOUT_NID 0x07
6211
6212static struct hda_channel_mode alc861_8ch_modes[1] = {
6213 { 8, NULL }
6214};
6215
6216static hda_nid_t alc861_dac_nids[4] = {
6217 /* front, surround, clfe, side */
6218 0x03, 0x06, 0x05, 0x04
6219};
6220
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006221static hda_nid_t alc660_dac_nids[3] = {
6222 /* front, clfe, surround */
6223 0x03, 0x05, 0x06
6224};
6225
Kailang Yangdf694da2005-12-05 19:42:22 +01006226static hda_nid_t alc861_adc_nids[1] = {
6227 /* ADC0-2 */
6228 0x08,
6229};
6230
6231static struct hda_input_mux alc861_capture_source = {
6232 .num_items = 5,
6233 .items = {
6234 { "Mic", 0x0 },
6235 { "Front Mic", 0x3 },
6236 { "Line", 0x1 },
6237 { "CD", 0x4 },
6238 { "Mixer", 0x5 },
6239 },
6240};
6241
6242/* fill in the dac_nids table from the parsed pin configuration */
6243static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6244{
6245 int i;
6246 hda_nid_t nid;
6247
6248 spec->multiout.dac_nids = spec->private_dac_nids;
6249 for (i = 0; i < cfg->line_outs; i++) {
6250 nid = cfg->line_out_pins[i];
6251 if (nid) {
6252 if (i >= ARRAY_SIZE(alc861_dac_nids))
6253 continue;
6254 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6255 }
6256 }
6257 spec->multiout.num_dacs = cfg->line_outs;
6258 return 0;
6259}
6260
6261/* add playback controls from the parsed DAC table */
6262static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6263 const struct auto_pin_cfg *cfg)
6264{
6265 char name[32];
6266 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6267 hda_nid_t nid;
6268 int i, idx, err;
6269
6270 for (i = 0; i < cfg->line_outs; i++) {
6271 nid = spec->multiout.dac_nids[i];
6272 if (! nid)
6273 continue;
6274 if (nid == 0x05) {
6275 /* Center/LFE */
6276 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6277 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6278 return err;
6279 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6280 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6281 return err;
6282 } else {
6283 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6284 if (nid == alc861_dac_nids[idx])
6285 break;
6286 sprintf(name, "%s Playback Switch", chname[idx]);
6287 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6288 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6289 return err;
6290 }
6291 }
6292 return 0;
6293}
6294
6295static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6296{
6297 int err;
6298 hda_nid_t nid;
6299
6300 if (! pin)
6301 return 0;
6302
6303 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6304 nid = 0x03;
6305 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6306 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6307 return err;
6308 spec->multiout.hp_nid = nid;
6309 }
6310 return 0;
6311}
6312
6313/* create playback/capture controls for input pins */
6314static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6315{
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 struct hda_input_mux *imux = &spec->private_imux;
6317 int i, err, idx, idx1;
6318
6319 for (i = 0; i < AUTO_PIN_LAST; i++) {
6320 switch(cfg->input_pins[i]) {
6321 case 0x0c:
6322 idx1 = 1;
6323 idx = 2; // Line In
6324 break;
6325 case 0x0f:
6326 idx1 = 2;
6327 idx = 2; // Line In
6328 break;
6329 case 0x0d:
6330 idx1 = 0;
6331 idx = 1; // Mic In
6332 break;
6333 case 0x10:
6334 idx1 = 3;
6335 idx = 1; // Mic In
6336 break;
6337 case 0x11:
6338 idx1 = 4;
6339 idx = 0; // CD
6340 break;
6341 default:
6342 continue;
6343 }
6344
Takashi Iwai4a471b72005-12-07 13:56:29 +01006345 err = new_analog_input(spec, cfg->input_pins[i],
6346 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01006347 if (err < 0)
6348 return err;
6349
Takashi Iwai4a471b72005-12-07 13:56:29 +01006350 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006351 imux->items[imux->num_items].index = idx1;
6352 imux->num_items++;
6353 }
6354 return 0;
6355}
6356
6357static struct snd_kcontrol_new alc861_capture_mixer[] = {
6358 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6359 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6360
6361 {
6362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6363 /* The multiple "Capture Source" controls confuse alsamixer
6364 * So call somewhat different..
6365 *FIXME: the controls appear in the "playback" view!
6366 */
6367 /* .name = "Capture Source", */
6368 .name = "Input Source",
6369 .count = 1,
6370 .info = alc_mux_enum_info,
6371 .get = alc_mux_enum_get,
6372 .put = alc_mux_enum_put,
6373 },
6374 { } /* end */
6375};
6376
6377static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6378 int pin_type, int dac_idx)
6379{
6380 /* set as output */
6381
6382 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6383 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6384
6385}
6386
6387static void alc861_auto_init_multi_out(struct hda_codec *codec)
6388{
6389 struct alc_spec *spec = codec->spec;
6390 int i;
6391
6392 for (i = 0; i < spec->autocfg.line_outs; i++) {
6393 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6394 if (nid)
6395 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6396 }
6397}
6398
6399static void alc861_auto_init_hp_out(struct hda_codec *codec)
6400{
6401 struct alc_spec *spec = codec->spec;
6402 hda_nid_t pin;
6403
6404 pin = spec->autocfg.hp_pin;
6405 if (pin) /* connect to front */
6406 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6407}
6408
6409static void alc861_auto_init_analog_input(struct hda_codec *codec)
6410{
6411 struct alc_spec *spec = codec->spec;
6412 int i;
6413
6414 for (i = 0; i < AUTO_PIN_LAST; i++) {
6415 hda_nid_t nid = spec->autocfg.input_pins[i];
6416 if ((nid>=0x0c) && (nid <=0x11)) {
6417 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6418 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6419 }
6420 }
6421}
6422
6423/* parse the BIOS configuration and set up the alc_spec */
6424/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6425static int alc861_parse_auto_config(struct hda_codec *codec)
6426{
6427 struct alc_spec *spec = codec->spec;
6428 int err;
6429 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6430
6431 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6432 alc861_ignore)) < 0)
6433 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006434 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006435 return 0; /* can't find valid BIOS pin config */
6436
6437 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6438 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6439 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6440 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6441 return err;
6442
6443 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6444
6445 if (spec->autocfg.dig_out_pin)
6446 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6447
6448 if (spec->kctl_alloc)
6449 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6450
6451 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6452
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006453 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006454 spec->input_mux = &spec->private_imux;
6455
6456 spec->adc_nids = alc861_adc_nids;
6457 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6458 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6459 spec->num_mixers++;
6460
6461 return 1;
6462}
6463
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006464/* additional initialization for auto-configuration model */
6465static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006466{
Kailang Yangdf694da2005-12-05 19:42:22 +01006467 alc861_auto_init_multi_out(codec);
6468 alc861_auto_init_hp_out(codec);
6469 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006470}
6471
6472
6473/*
6474 * configuration and preset
6475 */
6476static struct hda_board_config alc861_cfg_tbl[] = {
6477 { .modelname = "3stack", .config = ALC861_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006478 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6479 .config = ALC861_3ST },
6480 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6481 .config = ALC660_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01006482 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6483 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6484 { .modelname = "auto", .config = ALC861_AUTO },
6485 {}
6486};
6487
6488static struct alc_config_preset alc861_presets[] = {
6489 [ALC861_3ST] = {
6490 .mixers = { alc861_3ST_mixer },
6491 .init_verbs = { alc861_threestack_init_verbs },
6492 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6493 .dac_nids = alc861_dac_nids,
6494 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6495 .channel_mode = alc861_threestack_modes,
6496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6497 .adc_nids = alc861_adc_nids,
6498 .input_mux = &alc861_capture_source,
6499 },
6500 [ALC861_3ST_DIG] = {
6501 .mixers = { alc861_base_mixer },
6502 .init_verbs = { alc861_threestack_init_verbs },
6503 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6504 .dac_nids = alc861_dac_nids,
6505 .dig_out_nid = ALC861_DIGOUT_NID,
6506 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6507 .channel_mode = alc861_threestack_modes,
6508 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6509 .adc_nids = alc861_adc_nids,
6510 .input_mux = &alc861_capture_source,
6511 },
6512 [ALC861_6ST_DIG] = {
6513 .mixers = { alc861_base_mixer },
6514 .init_verbs = { alc861_base_init_verbs },
6515 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6516 .dac_nids = alc861_dac_nids,
6517 .dig_out_nid = ALC861_DIGOUT_NID,
6518 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6519 .channel_mode = alc861_8ch_modes,
6520 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6521 .adc_nids = alc861_adc_nids,
6522 .input_mux = &alc861_capture_source,
6523 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006524 [ALC660_3ST] = {
6525 .mixers = { alc861_3ST_mixer },
6526 .init_verbs = { alc861_threestack_init_verbs },
6527 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6528 .dac_nids = alc660_dac_nids,
6529 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6530 .channel_mode = alc861_threestack_modes,
6531 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6532 .adc_nids = alc861_adc_nids,
6533 .input_mux = &alc861_capture_source,
6534 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006535};
6536
6537
6538static int patch_alc861(struct hda_codec *codec)
6539{
6540 struct alc_spec *spec;
6541 int board_config;
6542 int err;
6543
6544 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6545 if (spec == NULL)
6546 return -ENOMEM;
6547
6548 codec->spec = spec;
6549
6550 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006551
Kailang Yangdf694da2005-12-05 19:42:22 +01006552 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006553 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6554 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006555 board_config = ALC861_AUTO;
6556 }
6557
6558 if (board_config == ALC861_AUTO) {
6559 /* automatic parse from the BIOS config */
6560 err = alc861_parse_auto_config(codec);
6561 if (err < 0) {
6562 alc_free(codec);
6563 return err;
6564 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006565 printk(KERN_INFO
6566 "hda_codec: Cannot set up configuration "
6567 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006568 board_config = ALC861_3ST_DIG;
6569 }
6570 }
6571
6572 if (board_config != ALC861_AUTO)
6573 setup_preset(spec, &alc861_presets[board_config]);
6574
6575 spec->stream_name_analog = "ALC861 Analog";
6576 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6577 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6578
6579 spec->stream_name_digital = "ALC861 Digital";
6580 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6581 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6582
6583 codec->patch_ops = alc_patch_ops;
6584 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006585 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01006586
6587 return 0;
6588}
6589
6590/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006591 * patch entries
6592 */
6593struct hda_codec_preset snd_hda_preset_realtek[] = {
6594 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006595 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006596 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6597 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006598 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006599 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006600 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6601 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6602 .patch = patch_alc861 },
6603 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6604 .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006605 {} /* terminator */
6606};