blob: aeb408cbe1ef74f9c831d4517a20add5b18193a2 [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 Woithe7cf51e482006-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
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010076#ifdef CONFIG_SND_DEBUG
77 ALC260_TEST,
78#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010079 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020080 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081};
82
Kailang Yangdf694da2005-12-05 19:42:22 +010083/* ALC262 models */
84enum {
85 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020086 ALC262_HIPPO,
87 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010088 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020089 ALC262_HP_BPC,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020090 ALC262_BENQ_ED8,
Kailang Yangdf694da2005-12-05 19:42:22 +010091 ALC262_AUTO,
92 ALC262_MODEL_LAST /* last tag */
93};
94
95/* ALC861 models */
96enum {
97 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020098 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +010099 ALC861_3ST_DIG,
100 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200101 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200102 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200103 ALC861_ASUS,
Kailang Yangdf694da2005-12-05 19:42:22 +0100104 ALC861_AUTO,
105 ALC861_MODEL_LAST,
106};
107
108/* ALC882 models */
109enum {
110 ALC882_3ST_DIG,
111 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200112 ALC882_ARIMA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC882_AUTO,
114 ALC882_MODEL_LAST,
115};
116
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200117/* ALC883 models */
118enum {
119 ALC883_3ST_2ch_DIG,
120 ALC883_3ST_6ch_DIG,
121 ALC883_3ST_6ch,
122 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200123 ALC883_TARGA_DIG,
124 ALC883_TARGA_2ch_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200125 ALC888_DEMO_BOARD,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200126 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200127 ALC883_MEDION,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100128 ALC883_LAPTOP_EAPD,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200129 ALC883_AUTO,
130 ALC883_MODEL_LAST,
131};
132
Kailang Yangdf694da2005-12-05 19:42:22 +0100133/* for GPIO Poll */
134#define GPIO_MASK 0x03
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136struct alc_spec {
137 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100138 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 unsigned int num_mixers;
140
Kailang Yangdf694da2005-12-05 19:42:22 +0100141 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200142 * don't forget NULL
143 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200144 */
145 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Takashi Iwai16ded522005-06-10 19:58:24 +0200147 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 struct hda_pcm_stream *stream_analog_playback;
149 struct hda_pcm_stream *stream_analog_capture;
150
Takashi Iwai16ded522005-06-10 19:58:24 +0200151 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 struct hda_pcm_stream *stream_digital_playback;
153 struct hda_pcm_stream *stream_digital_capture;
154
155 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200156 struct hda_multi_out multiout; /* playback set-up
157 * max_channels, dacs must be set
158 * dig_out_nid and hp_nid are optional
159 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161 /* capture */
162 unsigned int num_adc_nids;
163 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200164 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
166 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200167 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 const struct hda_input_mux *input_mux;
169 unsigned int cur_mux[3];
170
171 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100172 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200174 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100177 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200178
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200179 /* dynamic controls, init_verbs and input_mux */
180 struct auto_pin_cfg autocfg;
181 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100182 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200183 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100184 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100185
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100186 /* hooks */
187 void (*init_hook)(struct hda_codec *codec);
188 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
189
Takashi Iwai834be882006-03-01 14:16:17 +0100190 /* for pin sensing */
191 unsigned int sense_updated: 1;
192 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100193};
194
195/*
196 * configuration template - to be copied to the spec instance
197 */
198struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200199 struct snd_kcontrol_new *mixers[5]; /* should be identical size
200 * with spec
201 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100202 const struct hda_verb *init_verbs[5];
203 unsigned int num_dacs;
204 hda_nid_t *dac_nids;
205 hda_nid_t dig_out_nid; /* optional */
206 hda_nid_t hp_nid; /* optional */
207 unsigned int num_adc_nids;
208 hda_nid_t *adc_nids;
209 hda_nid_t dig_in_nid;
210 unsigned int num_channel_mode;
211 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200212 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200213 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100214 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100215 void (*unsol_event)(struct hda_codec *, unsigned int);
216 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217};
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220/*
221 * input MUX handling
222 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200223static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
224 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225{
226 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
227 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200228 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
229 if (mux_idx >= spec->num_mux_defs)
230 mux_idx = 0;
231 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232}
233
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200234static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
235 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236{
237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
238 struct alc_spec *spec = codec->spec;
239 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
240
241 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
242 return 0;
243}
244
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200245static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct alc_spec *spec = codec->spec;
250 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200251 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
252 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200253 spec->adc_nids[adc_idx],
254 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255}
256
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258/*
259 * channel mode setting
260 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200261static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
262 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263{
264 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
265 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100266 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
267 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268}
269
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200270static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
271 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272{
273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
274 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100275 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200276 spec->num_channel_mode,
277 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278}
279
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200280static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
281 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282{
283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
284 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200285 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
286 spec->num_channel_mode,
287 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200288 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200289 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
290 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291}
292
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100294 * Control the mode of pin widget settings via the mixer. "pc" is used
295 * instead of "%" to avoid consequences of accidently treating the % as
296 * being part of a format specifier. Maximum allowed length of a value is
297 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100298 *
299 * Note: some retasking pin complexes seem to ignore requests for input
300 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
301 * are requested. Therefore order this list so that this behaviour will not
302 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200303 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
304 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200305 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100306static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100307 "Mic 50pc bias", "Mic 80pc bias",
308 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100309};
310static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100311 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100312};
313/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200314 * in the pin being assumed to be exclusively an input or an output pin. In
315 * addition, "input" pins may or may not process the mic bias option
316 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
317 * accept requests for bias as of chip versions up to March 2006) and/or
318 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100319 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200320#define ALC_PIN_DIR_IN 0x00
321#define ALC_PIN_DIR_OUT 0x01
322#define ALC_PIN_DIR_INOUT 0x02
323#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
324#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100325
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200326/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100327 * For each direction the minimum and maximum values are given.
328 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200329static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100330 { 0, 2 }, /* ALC_PIN_DIR_IN */
331 { 3, 4 }, /* ALC_PIN_DIR_OUT */
332 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200333 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
334 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100335};
336#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
337#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
338#define alc_pin_mode_n_items(_dir) \
339 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
340
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200341static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
342 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200343{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100344 unsigned int item_num = uinfo->value.enumerated.item;
345 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
346
347 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200348 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100349 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
350
351 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
352 item_num = alc_pin_mode_min(dir);
353 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200354 return 0;
355}
356
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
358 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200359{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100360 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200361 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
362 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100363 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200364 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200365 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
366 AC_VERB_GET_PIN_WIDGET_CONTROL,
367 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200368
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100369 /* Find enumerated value for current pinctl setting */
370 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200371 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374 return 0;
375}
376
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200377static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
378 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100379{
380 signed int change;
381 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
382 hda_nid_t nid = kcontrol->private_value & 0xffff;
383 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
384 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200385 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
386 AC_VERB_GET_PIN_WIDGET_CONTROL,
387 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100388
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200389 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100390 val = alc_pin_mode_min(dir);
391
392 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100393 if (change) {
394 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200395 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200396 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100397
398 /* Also enable the retasking pin's input/output as required
399 * for the requested pin mode. Enum values of 2 or less are
400 * input modes.
401 *
402 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200403 * reduces noise slightly (particularly on input) so we'll
404 * do it. However, having both input and output buffers
405 * enabled simultaneously doesn't seem to be problematic if
406 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100407 */
408 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200409 snd_hda_codec_write(codec, nid, 0,
410 AC_VERB_SET_AMP_GAIN_MUTE,
411 AMP_OUT_MUTE);
412 snd_hda_codec_write(codec, nid, 0,
413 AC_VERB_SET_AMP_GAIN_MUTE,
414 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100415 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200416 snd_hda_codec_write(codec, nid, 0,
417 AC_VERB_SET_AMP_GAIN_MUTE,
418 AMP_IN_MUTE(0));
419 snd_hda_codec_write(codec, nid, 0,
420 AC_VERB_SET_AMP_GAIN_MUTE,
421 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100422 }
423 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200424 return change;
425}
426
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200428 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429 .info = alc_pin_mode_info, \
430 .get = alc_pin_mode_get, \
431 .put = alc_pin_mode_put, \
432 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100433
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100434/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
435 * together using a mask with more than one bit set. This control is
436 * currently used only by the ALC260 test model. At this stage they are not
437 * needed for any "production" models.
438 */
439#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100442{
443 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
444 uinfo->count = 1;
445 uinfo->value.integer.min = 0;
446 uinfo->value.integer.max = 1;
447 return 0;
448}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100451{
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 hda_nid_t nid = kcontrol->private_value & 0xffff;
454 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
455 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456 unsigned int val = snd_hda_codec_read(codec, nid, 0,
457 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100458
459 *valp = (val & mask) != 0;
460 return 0;
461}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100464{
465 signed int change;
466 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
467 hda_nid_t nid = kcontrol->private_value & 0xffff;
468 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
469 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
471 AC_VERB_GET_GPIO_DATA,
472 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100473
474 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200475 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
476 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100477 gpio_data &= ~mask;
478 else
479 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200480 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100481
482 return change;
483}
484#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
485 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
486 .info = alc_gpio_data_info, \
487 .get = alc_gpio_data_get, \
488 .put = alc_gpio_data_put, \
489 .private_value = nid | (mask<<16) }
490#endif /* CONFIG_SND_DEBUG */
491
Jonathan Woithe92621f12006-02-28 11:47:47 +0100492/* A switch control to allow the enabling of the digital IO pins on the
493 * ALC260. This is incredibly simplistic; the intention of this control is
494 * to provide something in the test model allowing digital outputs to be
495 * identified if present. If models are found which can utilise these
496 * outputs a more complete mixer control can be devised for those models if
497 * necessary.
498 */
499#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200500static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
501 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100502{
503 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
504 uinfo->count = 1;
505 uinfo->value.integer.min = 0;
506 uinfo->value.integer.max = 1;
507 return 0;
508}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200509static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100511{
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 hda_nid_t nid = kcontrol->private_value & 0xffff;
514 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
515 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516 unsigned int val = snd_hda_codec_read(codec, nid, 0,
517 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100518
519 *valp = (val & mask) != 0;
520 return 0;
521}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200522static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100524{
525 signed int change;
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 hda_nid_t nid = kcontrol->private_value & 0xffff;
528 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
529 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
531 AC_VERB_GET_DIGI_CONVERT,
532 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100533
534 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100536 if (val==0)
537 ctrl_data &= ~mask;
538 else
539 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
541 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100542
543 return change;
544}
545#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
546 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
547 .info = alc_spdif_ctrl_info, \
548 .get = alc_spdif_ctrl_get, \
549 .put = alc_spdif_ctrl_put, \
550 .private_value = nid | (mask<<16) }
551#endif /* CONFIG_SND_DEBUG */
552
Kailang Yangdf694da2005-12-05 19:42:22 +0100553/*
554 * set up from the preset table
555 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556static void setup_preset(struct alc_spec *spec,
557 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100558{
559 int i;
560
561 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
562 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
564 i++)
565 spec->init_verbs[spec->num_init_verbs++] =
566 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100567
568 spec->channel_mode = preset->channel_mode;
569 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200570 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100571
572 spec->multiout.max_channels = spec->channel_mode[0].channels;
573
574 spec->multiout.num_dacs = preset->num_dacs;
575 spec->multiout.dac_nids = preset->dac_nids;
576 spec->multiout.dig_out_nid = preset->dig_out_nid;
577 spec->multiout.hp_nid = preset->hp_nid;
578
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200579 spec->num_mux_defs = preset->num_mux_defs;
580 if (! spec->num_mux_defs)
581 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100582 spec->input_mux = preset->input_mux;
583
584 spec->num_adc_nids = preset->num_adc_nids;
585 spec->adc_nids = preset->adc_nids;
586 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100587
588 spec->unsol_event = preset->unsol_event;
589 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100590}
591
Takashi Iwai41e41f12005-06-08 14:48:49 +0200592/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200593 * ALC880 3-stack model
594 *
595 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
597 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 */
599
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200600static hda_nid_t alc880_dac_nids[4] = {
601 /* front, rear, clfe, rear_surr */
602 0x02, 0x05, 0x04, 0x03
603};
604
605static hda_nid_t alc880_adc_nids[3] = {
606 /* ADC0-2 */
607 0x07, 0x08, 0x09,
608};
609
610/* The datasheet says the node 0x07 is connected from inputs,
611 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100612 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200614static hda_nid_t alc880_adc_nids_alt[2] = {
615 /* ADC1-2 */
616 0x08, 0x09,
617};
618
619#define ALC880_DIGOUT_NID 0x06
620#define ALC880_DIGIN_NID 0x0a
621
622static struct hda_input_mux alc880_capture_source = {
623 .num_items = 4,
624 .items = {
625 { "Mic", 0x0 },
626 { "Front Mic", 0x3 },
627 { "Line", 0x2 },
628 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200630};
631
632/* channel source setting (2/6 channel selection for 3-stack) */
633/* 2ch mode */
634static struct hda_verb alc880_threestack_ch2_init[] = {
635 /* set line-in to input, mute it */
636 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
637 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
638 /* set mic-in to input vref 80%, mute it */
639 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
640 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 { } /* end */
642};
643
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200644/* 6ch mode */
645static struct hda_verb alc880_threestack_ch6_init[] = {
646 /* set line-in to output, unmute it */
647 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
648 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
649 /* set mic-in to output, unmute it */
650 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
651 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
652 { } /* end */
653};
654
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100655static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200656 { 2, alc880_threestack_ch2_init },
657 { 6, alc880_threestack_ch6_init },
658};
659
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100660static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200661 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100662 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200663 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100664 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200665 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
666 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100667 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
668 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
670 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
677 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
678 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200680 {
681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
682 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100683 .info = alc_ch_mode_info,
684 .get = alc_ch_mode_get,
685 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200686 },
687 { } /* end */
688};
689
690/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100691static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200692 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
693 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
694 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
695 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
696 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
697 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
698 {
699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
700 /* The multiple "Capture Source" controls confuse alsamixer
701 * So call somewhat different..
702 * FIXME: the controls appear in the "playback" view!
703 */
704 /* .name = "Capture Source", */
705 .name = "Input Source",
706 .count = 3,
707 .info = alc_mux_enum_info,
708 .get = alc_mux_enum_get,
709 .put = alc_mux_enum_put,
710 },
711 { } /* end */
712};
713
714/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100715static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200716 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
717 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
718 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
719 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 {
721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
722 /* The multiple "Capture Source" controls confuse alsamixer
723 * So call somewhat different..
724 * FIXME: the controls appear in the "playback" view!
725 */
726 /* .name = "Capture Source", */
727 .name = "Input Source",
728 .count = 2,
729 .info = alc_mux_enum_info,
730 .get = alc_mux_enum_get,
731 .put = alc_mux_enum_put,
732 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 { } /* end */
734};
735
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200736
737
738/*
739 * ALC880 5-stack model
740 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200741 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
742 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200743 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
744 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
745 */
746
747/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100748static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200749 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100750 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 { } /* end */
752};
753
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200754/* channel source setting (6/8 channel selection for 5-stack) */
755/* 6ch mode */
756static struct hda_verb alc880_fivestack_ch6_init[] = {
757 /* set line-in to input, mute it */
758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
759 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200760 { } /* end */
761};
762
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200763/* 8ch mode */
764static struct hda_verb alc880_fivestack_ch8_init[] = {
765 /* set line-in to output, unmute it */
766 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
767 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
768 { } /* end */
769};
770
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100771static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200772 { 6, alc880_fivestack_ch6_init },
773 { 8, alc880_fivestack_ch8_init },
774};
775
776
777/*
778 * ALC880 6-stack model
779 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200780 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
781 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200782 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
783 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
784 */
785
786static hda_nid_t alc880_6st_dac_nids[4] = {
787 /* front, rear, clfe, rear_surr */
788 0x02, 0x03, 0x04, 0x05
789};
790
791static struct hda_input_mux alc880_6stack_capture_source = {
792 .num_items = 4,
793 .items = {
794 { "Mic", 0x0 },
795 { "Front Mic", 0x1 },
796 { "Line", 0x2 },
797 { "CD", 0x4 },
798 },
799};
800
801/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100802static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200803 { 8, NULL },
804};
805
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100806static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200809 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100810 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200815 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100816 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
825 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
826 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200827 {
828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
829 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100830 .info = alc_ch_mode_info,
831 .get = alc_ch_mode_get,
832 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200833 },
834 { } /* end */
835};
836
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200837
838/*
839 * ALC880 W810 model
840 *
841 * W810 has rear IO for:
842 * Front (DAC 02)
843 * Surround (DAC 03)
844 * Center/LFE (DAC 04)
845 * Digital out (06)
846 *
847 * The system also has a pair of internal speakers, and a headphone jack.
848 * These are both connected to Line2 on the codec, hence to DAC 02.
849 *
850 * There is a variable resistor to control the speaker or headphone
851 * volume. This is a hardware-only device without a software API.
852 *
853 * Plugging headphones in will disable the internal speakers. This is
854 * implemented in hardware, not via the driver using jack sense. In
855 * a similar fashion, plugging into the rear socket marked "front" will
856 * disable both the speakers and headphones.
857 *
858 * For input, there's a microphone jack, and an "audio in" jack.
859 * These may not do anything useful with this driver yet, because I
860 * haven't setup any initialization verbs for these yet...
861 */
862
863static hda_nid_t alc880_w810_dac_nids[3] = {
864 /* front, rear/surround, clfe */
865 0x02, 0x03, 0x04
866};
867
868/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100869static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200870 { 6, NULL }
871};
872
873/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100874static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
880 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
882 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
884 { } /* end */
885};
886
887
888/*
889 * Z710V model
890 *
891 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200892 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
893 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200894 */
895
896static hda_nid_t alc880_z71v_dac_nids[1] = {
897 0x02
898};
899#define ALC880_Z71V_HP_DAC 0x03
900
901/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100902static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200903 { 2, NULL }
904};
905
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100906static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200907 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200909 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100910 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200911 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
912 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
915 { } /* end */
916};
917
918
919/* FIXME! */
920/*
921 * ALC880 F1734 model
922 *
923 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
924 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
925 */
926
927static hda_nid_t alc880_f1734_dac_nids[1] = {
928 0x03
929};
930#define ALC880_F1734_HP_DAC 0x02
931
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100932static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200933 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100934 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200935 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100936 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200937 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
938 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200941 { } /* end */
942};
943
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200944
945/* FIXME! */
946/*
947 * ALC880 ASUS model
948 *
949 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
950 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
951 * Mic = 0x18, Line = 0x1a
952 */
953
954#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
955#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
956
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100957static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200958 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100961 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200966 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
967 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200972 {
973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
974 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100975 .info = alc_ch_mode_info,
976 .get = alc_ch_mode_get,
977 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200978 },
979 { } /* end */
980};
981
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200982/* FIXME! */
983/*
984 * ALC880 ASUS W1V model
985 *
986 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
987 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
988 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
989 */
990
991/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100992static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200993 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
994 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200995 { } /* end */
996};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200997
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200998/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100999static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001000 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1001 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1002 { } /* end */
1003};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001004
Kailang Yangdf694da2005-12-05 19:42:22 +01001005/* TCL S700 */
1006static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1007 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1010 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1011 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1014 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1015 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1016 {
1017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1018 /* The multiple "Capture Source" controls confuse alsamixer
1019 * So call somewhat different..
1020 * FIXME: the controls appear in the "playback" view!
1021 */
1022 /* .name = "Capture Source", */
1023 .name = "Input Source",
1024 .count = 1,
1025 .info = alc_mux_enum_info,
1026 .get = alc_mux_enum_get,
1027 .put = alc_mux_enum_put,
1028 },
1029 { } /* end */
1030};
1031
Kailang Yangccc656c2006-10-17 12:32:26 +02001032/* Uniwill */
1033static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1034 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1035 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1036 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1037 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1038 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1039 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1040 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1041 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1050 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1051 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1052 {
1053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1054 .name = "Channel Mode",
1055 .info = alc_ch_mode_info,
1056 .get = alc_ch_mode_get,
1057 .put = alc_ch_mode_put,
1058 },
1059 { } /* end */
1060};
1061
1062static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1063 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1064 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1065 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1066 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1069 { } /* end */
1070};
1071
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 */
1075static int alc_build_controls(struct hda_codec *codec)
1076{
1077 struct alc_spec *spec = codec->spec;
1078 int err;
1079 int i;
1080
1081 for (i = 0; i < spec->num_mixers; i++) {
1082 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1083 if (err < 0)
1084 return err;
1085 }
1086
1087 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001088 err = snd_hda_create_spdif_out_ctls(codec,
1089 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 if (err < 0)
1091 return err;
1092 }
1093 if (spec->dig_in_nid) {
1094 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1095 if (err < 0)
1096 return err;
1097 }
1098 return 0;
1099}
1100
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001101
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102/*
1103 * initialize the codec volumes, etc
1104 */
1105
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001106/*
1107 * generic initialization of ADC, input mixers and output mixers
1108 */
1109static struct hda_verb alc880_volume_init_verbs[] = {
1110 /*
1111 * Unmute ADC0-2 and set the default input to mic-in
1112 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001113 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001117 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001120 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1121 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001122 * Note: PASD motherboards uses the Line In 2 as the input for front
1123 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001132 /*
1133 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001135 /* set vol=0 to output mixers */
1136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1139 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1140 /* set up input amps for analog loopback */
1141 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001148 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1149 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150
1151 { }
1152};
1153
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001154/*
1155 * 3-stack pin configuration:
1156 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1157 */
1158static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1159 /*
1160 * preset connection lists of input pins
1161 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1162 */
1163 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1164 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1165 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1166
1167 /*
1168 * Set pin mode and muting
1169 */
1170 /* set front pin widgets 0x14 for output */
1171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1172 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1173 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1174 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1175 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1176 /* Mic2 (as headphone out) for HP output */
1177 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1178 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1179 /* Line In pin widget for input */
1180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1182 /* Line2 (as front mic) pin widget for input and vref at 80% */
1183 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1184 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1185 /* CD pin widget for input */
1186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1187
1188 { }
1189};
1190
1191/*
1192 * 5-stack pin configuration:
1193 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1194 * line-in/side = 0x1a, f-mic = 0x1b
1195 */
1196static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1197 /*
1198 * preset connection lists of input pins
1199 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1200 */
1201 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1202 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1203
1204 /*
1205 * Set pin mode and muting
1206 */
1207 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1211 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001212 /* unmute pins for output (no gain on this amp) */
1213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1215 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1217
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001219 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1221 /* Mic2 (as headphone out) for HP output */
1222 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001224 /* Line In pin widget for input */
1225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1227 /* Line2 (as front mic) pin widget for input and vref at 80% */
1228 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1229 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1230 /* CD pin widget for input */
1231 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232
1233 { }
1234};
1235
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001236/*
1237 * W810 pin configuration:
1238 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1239 */
1240static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 /* hphone/speaker input selector: front DAC */
1242 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1245 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1249 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1250
1251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001252 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 { }
1255};
1256
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001257/*
1258 * Z71V pin configuration:
1259 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1260 */
1261static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001266
Takashi Iwai16ded522005-06-10 19:58:24 +02001267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001271
1272 { }
1273};
1274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001275/*
1276 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001277 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1278 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001279 */
1280static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1281 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1282
Takashi Iwai16ded522005-06-10 19:58:24 +02001283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001287 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001289 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291
Takashi Iwai16ded522005-06-10 19:58:24 +02001292 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001294 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001295 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001296 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001298 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001299 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001300 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001302 { }
1303};
Takashi Iwai16ded522005-06-10 19:58:24 +02001304
Kailang Yangccc656c2006-10-17 12:32:26 +02001305/*
1306 * Uniwill pin configuration:
1307 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1308 * line = 0x1a
1309 */
1310static struct hda_verb alc880_uniwill_init_verbs[] = {
1311 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1312
1313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1317 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1318 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1319 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1320 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1327
1328 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1329 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1331 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1332 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1334 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1335 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1336 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1337
1338 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1339 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1340
1341 { }
1342};
1343
1344/*
1345* Uniwill P53
1346* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1347 */
1348static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1349 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1350
1351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1356 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1363
1364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1368 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1369 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1370
1371 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1372 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1373
1374 { }
1375};
1376
1377/* toggle speaker-output according to the hp-jack state */
1378static void alc880_uniwill_automute(struct hda_codec *codec)
1379{
1380 unsigned int present;
1381
1382 present = snd_hda_codec_read(codec, 0x14, 0,
1383 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1384 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1385 0x80, present ? 0x80 : 0);
1386 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1387 0x80, present ? 0x80 : 0);
1388 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1389 0x80, present ? 0x80 : 0);
1390 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1391 0x80, present ? 0x80 : 0);
1392
1393 present = snd_hda_codec_read(codec, 0x18, 0,
1394 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1395 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1396 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1397}
1398
1399static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1400 unsigned int res)
1401{
1402 /* Looks like the unsol event is incompatible with the standard
1403 * definition. 4bit tag is placed at 28 bit!
1404 */
1405 if ((res >> 28) == ALC880_HP_EVENT ||
1406 (res >> 28) == ALC880_MIC_EVENT)
1407 alc880_uniwill_automute(codec);
1408}
1409
1410static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1411{
1412 unsigned int present;
1413
1414 present = snd_hda_codec_read(codec, 0x14, 0,
1415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1416
1417 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1418 0x80, present ? 0x80 : 0);
1419 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1420 0x80, present ? 0x80 : 0);
1421}
1422
1423static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1424{
1425 unsigned int present;
1426
1427 present = snd_hda_codec_read(codec, 0x21, 0,
1428 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1429
1430 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1431 0x7f, present);
1432 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1433 0x7f, present);
1434
1435 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1436 0x7f, present);
1437 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1438 0x7f, present);
1439
1440}
1441static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1442 unsigned int res)
1443{
1444 /* Looks like the unsol event is incompatible with the standard
1445 * definition. 4bit tag is placed at 28 bit!
1446 */
1447 if ((res >> 28) == ALC880_HP_EVENT)
1448 alc880_uniwill_p53_hp_automute(codec);
1449 if ((res >> 28) == ALC880_DCVOL_EVENT)
1450 alc880_uniwill_p53_dcvol_automute(codec);
1451}
1452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001453/* FIXME! */
1454/*
1455 * F1734 pin configuration:
1456 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1457 */
1458static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1459 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1460 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1461 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1463
1464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468
1469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001478
1479 { }
1480};
1481
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001482/* FIXME! */
1483/*
1484 * ASUS pin configuration:
1485 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1486 */
1487static struct hda_verb alc880_pin_asus_init_verbs[] = {
1488 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1489 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1490 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1491 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1492
1493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501
1502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1511
1512 { }
1513};
1514
1515/* Enable GPIO mask and set output */
1516static struct hda_verb alc880_gpio1_init_verbs[] = {
1517 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1518 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1519 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001520
1521 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001522};
1523
1524/* Enable GPIO mask and set output */
1525static struct hda_verb alc880_gpio2_init_verbs[] = {
1526 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1527 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1528 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001529
1530 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001531};
1532
Kailang Yangdf694da2005-12-05 19:42:22 +01001533/* Clevo m520g init */
1534static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1535 /* headphone output */
1536 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1537 /* line-out */
1538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1539 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1540 /* Line-in */
1541 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1542 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1543 /* CD */
1544 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1545 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1546 /* Mic1 (rear panel) */
1547 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1549 /* Mic2 (front panel) */
1550 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1551 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1552 /* headphone */
1553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1555 /* change to EAPD mode */
1556 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1557 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1558
1559 { }
1560};
1561
1562static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001563 /* change to EAPD mode */
1564 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1565 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1566
Kailang Yangdf694da2005-12-05 19:42:22 +01001567 /* Headphone output */
1568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1569 /* Front output*/
1570 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1572
1573 /* Line In pin widget for input */
1574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1575 /* CD pin widget for input */
1576 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1577 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1578 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1579
1580 /* change to EAPD mode */
1581 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1582 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1583
1584 { }
1585};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001586
1587/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001588 * LG m1 express dual
1589 *
1590 * Pin assignment:
1591 * Rear Line-In/Out (blue): 0x14
1592 * Build-in Mic-In: 0x15
1593 * Speaker-out: 0x17
1594 * HP-Out (green): 0x1b
1595 * Mic-In/Out (red): 0x19
1596 * SPDIF-Out: 0x1e
1597 */
1598
1599/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1600static hda_nid_t alc880_lg_dac_nids[3] = {
1601 0x05, 0x02, 0x03
1602};
1603
1604/* seems analog CD is not working */
1605static struct hda_input_mux alc880_lg_capture_source = {
1606 .num_items = 3,
1607 .items = {
1608 { "Mic", 0x1 },
1609 { "Line", 0x5 },
1610 { "Internal Mic", 0x6 },
1611 },
1612};
1613
1614/* 2,4,6 channel modes */
1615static struct hda_verb alc880_lg_ch2_init[] = {
1616 /* set line-in and mic-in to input */
1617 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1618 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1619 { }
1620};
1621
1622static struct hda_verb alc880_lg_ch4_init[] = {
1623 /* set line-in to out and mic-in to input */
1624 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1625 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1626 { }
1627};
1628
1629static struct hda_verb alc880_lg_ch6_init[] = {
1630 /* set line-in and mic-in to output */
1631 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1632 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1633 { }
1634};
1635
1636static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1637 { 2, alc880_lg_ch2_init },
1638 { 4, alc880_lg_ch4_init },
1639 { 6, alc880_lg_ch6_init },
1640};
1641
1642static struct snd_kcontrol_new alc880_lg_mixer[] = {
1643 /* FIXME: it's not really "master" but front channels */
1644 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1645 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1646 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1647 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1648 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1649 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1650 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1651 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1654 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1655 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1656 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1657 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1658 {
1659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1660 .name = "Channel Mode",
1661 .info = alc_ch_mode_info,
1662 .get = alc_ch_mode_get,
1663 .put = alc_ch_mode_put,
1664 },
1665 { } /* end */
1666};
1667
1668static struct hda_verb alc880_lg_init_verbs[] = {
1669 /* set capture source to mic-in */
1670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1673 /* mute all amp mixer inputs */
1674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1677 /* line-in to input */
1678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1680 /* built-in mic */
1681 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1683 /* speaker-out */
1684 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1685 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1686 /* mic-in to input */
1687 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1688 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 /* HP-out */
1691 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 /* jack sense */
1695 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1696 { }
1697};
1698
1699/* toggle speaker-output according to the hp-jack state */
1700static void alc880_lg_automute(struct hda_codec *codec)
1701{
1702 unsigned int present;
1703
1704 present = snd_hda_codec_read(codec, 0x1b, 0,
1705 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1706 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1707 0x80, present ? 0x80 : 0);
1708 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1709 0x80, present ? 0x80 : 0);
1710}
1711
1712static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1713{
1714 /* Looks like the unsol event is incompatible with the standard
1715 * definition. 4bit tag is placed at 28 bit!
1716 */
1717 if ((res >> 28) == 0x01)
1718 alc880_lg_automute(codec);
1719}
1720
1721/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001722 * LG LW20
1723 *
1724 * Pin assignment:
1725 * Speaker-out: 0x14
1726 * Mic-In: 0x18
1727 * Built-in Mic-In: 0x19 (?)
1728 * HP-Out: 0x1b
1729 * SPDIF-Out: 0x1e
1730 */
1731
1732/* seems analog CD is not working */
1733static struct hda_input_mux alc880_lg_lw_capture_source = {
1734 .num_items = 2,
1735 .items = {
1736 { "Mic", 0x0 },
1737 { "Internal Mic", 0x1 },
1738 },
1739};
1740
1741static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1742 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1743 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1746 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1747 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1748 { } /* end */
1749};
1750
1751static struct hda_verb alc880_lg_lw_init_verbs[] = {
1752 /* set capture source to mic-in */
1753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1757 /* speaker-out */
1758 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1760 /* HP-out */
1761 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1762 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1763 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1764 /* mic-in to input */
1765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1767 /* built-in mic */
1768 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1770 /* jack sense */
1771 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1772 { }
1773};
1774
1775/* toggle speaker-output according to the hp-jack state */
1776static void alc880_lg_lw_automute(struct hda_codec *codec)
1777{
1778 unsigned int present;
1779
1780 present = snd_hda_codec_read(codec, 0x1b, 0,
1781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1782 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1783 0x80, present ? 0x80 : 0);
1784 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1785 0x80, present ? 0x80 : 0);
1786}
1787
1788static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1789{
1790 /* Looks like the unsol event is incompatible with the standard
1791 * definition. 4bit tag is placed at 28 bit!
1792 */
1793 if ((res >> 28) == 0x01)
1794 alc880_lg_lw_automute(codec);
1795}
1796
1797/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001798 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001799 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001800
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801static int alc_init(struct hda_codec *codec)
1802{
1803 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001804 unsigned int i;
1805
1806 for (i = 0; i < spec->num_init_verbs; i++)
1807 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001808
1809 if (spec->init_hook)
1810 spec->init_hook(codec);
1811
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812 return 0;
1813}
1814
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001815static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1816{
1817 struct alc_spec *spec = codec->spec;
1818
1819 if (spec->unsol_event)
1820 spec->unsol_event(codec, res);
1821}
1822
Linus Torvalds1da177e2005-04-16 15:20:36 -07001823#ifdef CONFIG_PM
1824/*
1825 * resume
1826 */
1827static int alc_resume(struct hda_codec *codec)
1828{
1829 struct alc_spec *spec = codec->spec;
1830 int i;
1831
1832 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 if (spec->multiout.dig_out_nid)
1836 snd_hda_resume_spdif_out(codec);
1837 if (spec->dig_in_nid)
1838 snd_hda_resume_spdif_in(codec);
1839
1840 return 0;
1841}
1842#endif
1843
1844/*
1845 * Analog playback callbacks
1846 */
1847static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1848 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001849 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850{
1851 struct alc_spec *spec = codec->spec;
1852 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1853}
1854
1855static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1856 struct hda_codec *codec,
1857 unsigned int stream_tag,
1858 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001859 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860{
1861 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001862 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1863 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001864}
1865
1866static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1867 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001868 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869{
1870 struct alc_spec *spec = codec->spec;
1871 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1872}
1873
1874/*
1875 * Digital out
1876 */
1877static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1878 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001879 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001880{
1881 struct alc_spec *spec = codec->spec;
1882 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1883}
1884
1885static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1886 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001887 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888{
1889 struct alc_spec *spec = codec->spec;
1890 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1891}
1892
1893/*
1894 * Analog capture
1895 */
1896static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1897 struct hda_codec *codec,
1898 unsigned int stream_tag,
1899 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001900 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901{
1902 struct alc_spec *spec = codec->spec;
1903
1904 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1905 stream_tag, 0, format);
1906 return 0;
1907}
1908
1909static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1910 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001911 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912{
1913 struct alc_spec *spec = codec->spec;
1914
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001915 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1916 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917 return 0;
1918}
1919
1920
1921/*
1922 */
1923static struct hda_pcm_stream alc880_pcm_analog_playback = {
1924 .substreams = 1,
1925 .channels_min = 2,
1926 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001927 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 .ops = {
1929 .open = alc880_playback_pcm_open,
1930 .prepare = alc880_playback_pcm_prepare,
1931 .cleanup = alc880_playback_pcm_cleanup
1932 },
1933};
1934
1935static struct hda_pcm_stream alc880_pcm_analog_capture = {
1936 .substreams = 2,
1937 .channels_min = 2,
1938 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001939 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940 .ops = {
1941 .prepare = alc880_capture_pcm_prepare,
1942 .cleanup = alc880_capture_pcm_cleanup
1943 },
1944};
1945
1946static struct hda_pcm_stream alc880_pcm_digital_playback = {
1947 .substreams = 1,
1948 .channels_min = 2,
1949 .channels_max = 2,
1950 /* NID is set in alc_build_pcms */
1951 .ops = {
1952 .open = alc880_dig_playback_pcm_open,
1953 .close = alc880_dig_playback_pcm_close
1954 },
1955};
1956
1957static struct hda_pcm_stream alc880_pcm_digital_capture = {
1958 .substreams = 1,
1959 .channels_min = 2,
1960 .channels_max = 2,
1961 /* NID is set in alc_build_pcms */
1962};
1963
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001964/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1965static struct hda_pcm_stream alc_pcm_null_playback = {
1966 .substreams = 0,
1967 .channels_min = 0,
1968 .channels_max = 0,
1969};
1970
Linus Torvalds1da177e2005-04-16 15:20:36 -07001971static int alc_build_pcms(struct hda_codec *codec)
1972{
1973 struct alc_spec *spec = codec->spec;
1974 struct hda_pcm *info = spec->pcm_rec;
1975 int i;
1976
1977 codec->num_pcms = 1;
1978 codec->pcm_info = info;
1979
1980 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001981 if (spec->stream_analog_playback) {
1982 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1983 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1984 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1985 }
1986 if (spec->stream_analog_capture) {
1987 snd_assert(spec->adc_nids, return -EINVAL);
1988 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1989 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1990 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991
Takashi Iwai4a471b72005-12-07 13:56:29 +01001992 if (spec->channel_mode) {
1993 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1994 for (i = 0; i < spec->num_channel_mode; i++) {
1995 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1996 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1997 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998 }
1999 }
2000
Takashi Iwaie08a0072006-09-07 17:52:14 +02002001 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002003 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002004 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002006 if (spec->multiout.dig_out_nid &&
2007 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002008 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2009 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2010 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002011 if (spec->dig_in_nid &&
2012 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2014 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2015 }
2016 }
2017
Takashi Iwaie08a0072006-09-07 17:52:14 +02002018 /* If the use of more than one ADC is requested for the current
2019 * model, configure a second analog capture-only PCM.
2020 */
2021 /* Additional Analaog capture for index #2 */
2022 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2023 spec->adc_nids) {
2024 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002025 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002026 info->name = spec->stream_name_analog;
2027 /* No playback stream for second PCM */
2028 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2029 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2030 if (spec->stream_analog_capture) {
2031 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2032 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2033 }
2034 }
2035
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036 return 0;
2037}
2038
2039static void alc_free(struct hda_codec *codec)
2040{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041 struct alc_spec *spec = codec->spec;
2042 unsigned int i;
2043
2044 if (! spec)
2045 return;
2046
2047 if (spec->kctl_alloc) {
2048 for (i = 0; i < spec->num_kctl_used; i++)
2049 kfree(spec->kctl_alloc[i].name);
2050 kfree(spec->kctl_alloc);
2051 }
2052 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053}
2054
2055/*
2056 */
2057static struct hda_codec_ops alc_patch_ops = {
2058 .build_controls = alc_build_controls,
2059 .build_pcms = alc_build_pcms,
2060 .init = alc_init,
2061 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002062 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063#ifdef CONFIG_PM
2064 .resume = alc_resume,
2065#endif
2066};
2067
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002068
2069/*
2070 * Test configuration for debugging
2071 *
2072 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2073 * enum controls.
2074 */
2075#ifdef CONFIG_SND_DEBUG
2076static hda_nid_t alc880_test_dac_nids[4] = {
2077 0x02, 0x03, 0x04, 0x05
2078};
2079
2080static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002081 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002082 .items = {
2083 { "In-1", 0x0 },
2084 { "In-2", 0x1 },
2085 { "In-3", 0x2 },
2086 { "In-4", 0x3 },
2087 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002088 { "Front", 0x5 },
2089 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002090 },
2091};
2092
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002093static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002094 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002095 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002096 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002097 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002098};
2099
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002100static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2101 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002102{
2103 static char *texts[] = {
2104 "N/A", "Line Out", "HP Out",
2105 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2106 };
2107 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2108 uinfo->count = 1;
2109 uinfo->value.enumerated.items = 8;
2110 if (uinfo->value.enumerated.item >= 8)
2111 uinfo->value.enumerated.item = 7;
2112 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2113 return 0;
2114}
2115
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002116static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2117 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002118{
2119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2120 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2121 unsigned int pin_ctl, item = 0;
2122
2123 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2124 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2125 if (pin_ctl & AC_PINCTL_OUT_EN) {
2126 if (pin_ctl & AC_PINCTL_HP_EN)
2127 item = 2;
2128 else
2129 item = 1;
2130 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2131 switch (pin_ctl & AC_PINCTL_VREFEN) {
2132 case AC_PINCTL_VREF_HIZ: item = 3; break;
2133 case AC_PINCTL_VREF_50: item = 4; break;
2134 case AC_PINCTL_VREF_GRD: item = 5; break;
2135 case AC_PINCTL_VREF_80: item = 6; break;
2136 case AC_PINCTL_VREF_100: item = 7; break;
2137 }
2138 }
2139 ucontrol->value.enumerated.item[0] = item;
2140 return 0;
2141}
2142
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002143static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2144 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002145{
2146 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2147 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2148 static unsigned int ctls[] = {
2149 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2150 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2151 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2152 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2153 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2154 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2155 };
2156 unsigned int old_ctl, new_ctl;
2157
2158 old_ctl = snd_hda_codec_read(codec, nid, 0,
2159 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2160 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2161 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002162 snd_hda_codec_write(codec, nid, 0,
2163 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002164 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002165 (ucontrol->value.enumerated.item[0] >= 3 ?
2166 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002167 return 1;
2168 }
2169 return 0;
2170}
2171
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002172static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2173 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002174{
2175 static char *texts[] = {
2176 "Front", "Surround", "CLFE", "Side"
2177 };
2178 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2179 uinfo->count = 1;
2180 uinfo->value.enumerated.items = 4;
2181 if (uinfo->value.enumerated.item >= 4)
2182 uinfo->value.enumerated.item = 3;
2183 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2184 return 0;
2185}
2186
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002187static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2188 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002189{
2190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2191 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2192 unsigned int sel;
2193
2194 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2195 ucontrol->value.enumerated.item[0] = sel & 3;
2196 return 0;
2197}
2198
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002199static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2200 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002201{
2202 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2203 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2204 unsigned int sel;
2205
2206 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2207 if (ucontrol->value.enumerated.item[0] != sel) {
2208 sel = ucontrol->value.enumerated.item[0] & 3;
2209 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2210 return 1;
2211 }
2212 return 0;
2213}
2214
2215#define PIN_CTL_TEST(xname,nid) { \
2216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2217 .name = xname, \
2218 .info = alc_test_pin_ctl_info, \
2219 .get = alc_test_pin_ctl_get, \
2220 .put = alc_test_pin_ctl_put, \
2221 .private_value = nid \
2222 }
2223
2224#define PIN_SRC_TEST(xname,nid) { \
2225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2226 .name = xname, \
2227 .info = alc_test_pin_src_info, \
2228 .get = alc_test_pin_src_get, \
2229 .put = alc_test_pin_src_put, \
2230 .private_value = nid \
2231 }
2232
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002233static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2235 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2236 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2237 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002238 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2239 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2240 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2241 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002242 PIN_CTL_TEST("Front Pin Mode", 0x14),
2243 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2244 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2245 PIN_CTL_TEST("Side Pin Mode", 0x17),
2246 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2247 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2248 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2249 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2250 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2251 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2252 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2253 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2254 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2255 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2256 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2257 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2258 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2259 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2260 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2261 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2262 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2263 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002264 {
2265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2266 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002267 .info = alc_ch_mode_info,
2268 .get = alc_ch_mode_get,
2269 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002270 },
2271 { } /* end */
2272};
2273
2274static struct hda_verb alc880_test_init_verbs[] = {
2275 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002284 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002285 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2286 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002289 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002290 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2293 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002294 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2298 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002299 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2303 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002305 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002310 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002312 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002314 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002315 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002316 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002317 /* Analog input/passthru */
2318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002323 { }
2324};
2325#endif
2326
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327/*
2328 */
2329
2330static struct hda_board_config alc880_cfg_tbl[] = {
2331 /* Back 3 jack, front 2 jack */
2332 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002333 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2334 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2335 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2336 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2337 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2338 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2339 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2340 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2341 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2342 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2343 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2344 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2345 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2346 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2347 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2348 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2349 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2350 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002351 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
2352 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002353 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002354 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002355 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2356 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2357 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2358 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2359 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2360 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2361 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2362 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2363 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2364 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2365 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2366 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2367 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002368 /* TCL S700 */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002369 { .modelname = "tcl", .config = ALC880_TCL_S700 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002370 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371
2372 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002373 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002374 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002375 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376
2377 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2378 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002379 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe3c2005-08-15 20:01:40 +02002380 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Takashi Iwai5a053d02006-07-25 14:51:15 +02002381
2382 /* Clevo laptops */
2383 { .modelname = "clevo", .config = ALC880_CLEVO },
2384 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2385 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2386 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2387 .config = ALC880_CLEVO }, /* Clevo m665n */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388
2389 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002390 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2391 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2392 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393
2394 /* Back 5 jack, front 2 jack */
2395 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002396 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2397 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2398 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2399 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002400 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401
2402 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2403 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002404 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2405 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2406 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2407 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2408 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2409 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2410 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2411 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002412 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002413 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2414 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002415 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002416 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002417 /* note subvendor = 0 below */
2418 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419
2420 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002421 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002423 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002424 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002425
Takashi Iwaib6482d42005-06-27 15:32:43 +02002426 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002427 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002428 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002429 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002430
2431 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002432 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2433 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2434 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2435 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002436 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2437 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2438 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2439 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002440 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002441 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002442 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Tobin Davisa2ee4702006-11-16 16:24:35 +01002443 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST_DIG }, /* Gigabyte K8N51 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002444
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002446 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2447 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2448 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2449 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002450 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002451 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
Danny Tholenf5a5ffa2006-08-08 18:59:07 +02002452 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
Takashi Iwai16ded522005-06-10 19:58:24 +02002453 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2454 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2455 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2456 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002457 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
Takashi Iwai16ded522005-06-10 19:58:24 +02002458 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002459 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
Takashi Iwai84f34302006-03-21 19:12:53 +01002460 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002461 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002462 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002463
2464 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
Kailang Yangccc656c2006-10-17 12:32:26 +02002465 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2466 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9070, .config = ALC880_UNIWILL },
2467 { .pci_subvendor = 0x1734, .pci_subdevice = 0x10ac, .config = ALC880_UNIWILL },
2468 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9077, .config = ALC880_UNIWILL_P53 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002469
2470 { .modelname = "F1734", .config = ALC880_F1734 },
2471 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002472 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002473
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002474 { .modelname = "lg", .config = ALC880_LG },
2475 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
Takashi Iwai886da862006-05-02 18:17:57 +02002476 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002477
Takashi Iwaid6815182006-03-23 16:06:23 +01002478 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2479 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
Takashi Iwaicd417d42006-09-06 16:03:11 +02002480 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
Takashi Iwaid6815182006-03-23 16:06:23 +01002481
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002482#ifdef CONFIG_SND_DEBUG
2483 { .modelname = "test", .config = ALC880_TEST },
2484#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002485 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002486
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 {}
2488};
2489
Takashi Iwai16ded522005-06-10 19:58:24 +02002490/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002491 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002492 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002493static struct alc_config_preset alc880_presets[] = {
2494 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002495 .mixers = { alc880_three_stack_mixer },
2496 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002497 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002498 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002499 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2500 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002501 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002502 .input_mux = &alc880_capture_source,
2503 },
2504 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002505 .mixers = { alc880_three_stack_mixer },
2506 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002507 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002508 .dac_nids = alc880_dac_nids,
2509 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002510 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2511 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002512 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002513 .input_mux = &alc880_capture_source,
2514 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002515 [ALC880_TCL_S700] = {
2516 .mixers = { alc880_tcl_s700_mixer },
2517 .init_verbs = { alc880_volume_init_verbs,
2518 alc880_pin_tcl_S700_init_verbs,
2519 alc880_gpio2_init_verbs },
2520 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2521 .dac_nids = alc880_dac_nids,
2522 .hp_nid = 0x03,
2523 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2524 .channel_mode = alc880_2_jack_modes,
2525 .input_mux = &alc880_capture_source,
2526 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002527 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002528 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2529 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002530 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2531 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002532 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2533 .channel_mode = alc880_fivestack_modes,
2534 .input_mux = &alc880_capture_source,
2535 },
2536 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2538 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002539 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2540 .dac_nids = alc880_dac_nids,
2541 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002542 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2543 .channel_mode = alc880_fivestack_modes,
2544 .input_mux = &alc880_capture_source,
2545 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002546 [ALC880_6ST] = {
2547 .mixers = { alc880_six_stack_mixer },
2548 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2549 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2550 .dac_nids = alc880_6st_dac_nids,
2551 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2552 .channel_mode = alc880_sixstack_modes,
2553 .input_mux = &alc880_6stack_capture_source,
2554 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002555 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002556 .mixers = { alc880_six_stack_mixer },
2557 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002558 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2559 .dac_nids = alc880_6st_dac_nids,
2560 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002561 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2562 .channel_mode = alc880_sixstack_modes,
2563 .input_mux = &alc880_6stack_capture_source,
2564 },
2565 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002566 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002567 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2568 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002569 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2570 .dac_nids = alc880_w810_dac_nids,
2571 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002572 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2573 .channel_mode = alc880_w810_modes,
2574 .input_mux = &alc880_capture_source,
2575 },
2576 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002578 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002579 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2580 .dac_nids = alc880_z71v_dac_nids,
2581 .dig_out_nid = ALC880_DIGOUT_NID,
2582 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002583 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2584 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002585 .input_mux = &alc880_capture_source,
2586 },
2587 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 .mixers = { alc880_f1734_mixer },
2589 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2590 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2591 .dac_nids = alc880_f1734_dac_nids,
2592 .hp_nid = 0x02,
2593 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2594 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002595 .input_mux = &alc880_capture_source,
2596 },
2597 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 .mixers = { alc880_asus_mixer },
2599 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2600 alc880_gpio1_init_verbs },
2601 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2602 .dac_nids = alc880_asus_dac_nids,
2603 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2604 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002605 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002606 .input_mux = &alc880_capture_source,
2607 },
2608 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002609 .mixers = { alc880_asus_mixer },
2610 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2611 alc880_gpio1_init_verbs },
2612 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2613 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002614 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002615 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2616 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002617 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002618 .input_mux = &alc880_capture_source,
2619 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002620 [ALC880_ASUS_DIG2] = {
2621 .mixers = { alc880_asus_mixer },
2622 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2623 alc880_gpio2_init_verbs }, /* use GPIO2 */
2624 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2625 .dac_nids = alc880_asus_dac_nids,
2626 .dig_out_nid = ALC880_DIGOUT_NID,
2627 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2628 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002629 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002630 .input_mux = &alc880_capture_source,
2631 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002632 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2634 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2635 alc880_gpio1_init_verbs },
2636 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2637 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002639 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2640 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002641 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002642 .input_mux = &alc880_capture_source,
2643 },
2644 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002645 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002646 .init_verbs = { alc880_volume_init_verbs,
2647 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2649 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002650 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002651 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2652 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002653 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002654 .input_mux = &alc880_capture_source,
2655 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002656 [ALC880_UNIWILL] = {
2657 .mixers = { alc880_uniwill_mixer },
2658 .init_verbs = { alc880_volume_init_verbs,
2659 alc880_uniwill_init_verbs },
2660 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2661 .dac_nids = alc880_asus_dac_nids,
2662 .dig_out_nid = ALC880_DIGOUT_NID,
2663 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2664 .channel_mode = alc880_threestack_modes,
2665 .need_dac_fix = 1,
2666 .input_mux = &alc880_capture_source,
2667 .unsol_event = alc880_uniwill_unsol_event,
2668 .init_hook = alc880_uniwill_automute,
2669 },
2670 [ALC880_UNIWILL_P53] = {
2671 .mixers = { alc880_uniwill_p53_mixer },
2672 .init_verbs = { alc880_volume_init_verbs,
2673 alc880_uniwill_p53_init_verbs },
2674 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2675 .dac_nids = alc880_asus_dac_nids,
2676 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2677 .channel_mode = alc880_w810_modes,
2678 .input_mux = &alc880_capture_source,
2679 .unsol_event = alc880_uniwill_p53_unsol_event,
2680 .init_hook = alc880_uniwill_p53_hp_automute,
2681 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002682 [ALC880_CLEVO] = {
2683 .mixers = { alc880_three_stack_mixer },
2684 .init_verbs = { alc880_volume_init_verbs,
2685 alc880_pin_clevo_init_verbs },
2686 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2687 .dac_nids = alc880_dac_nids,
2688 .hp_nid = 0x03,
2689 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2690 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002691 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002692 .input_mux = &alc880_capture_source,
2693 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002694 [ALC880_LG] = {
2695 .mixers = { alc880_lg_mixer },
2696 .init_verbs = { alc880_volume_init_verbs,
2697 alc880_lg_init_verbs },
2698 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2699 .dac_nids = alc880_lg_dac_nids,
2700 .dig_out_nid = ALC880_DIGOUT_NID,
2701 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2702 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002703 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002704 .input_mux = &alc880_lg_capture_source,
2705 .unsol_event = alc880_lg_unsol_event,
2706 .init_hook = alc880_lg_automute,
2707 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002708 [ALC880_LG_LW] = {
2709 .mixers = { alc880_lg_lw_mixer },
2710 .init_verbs = { alc880_volume_init_verbs,
2711 alc880_lg_lw_init_verbs },
2712 .num_dacs = 1,
2713 .dac_nids = alc880_dac_nids,
2714 .dig_out_nid = ALC880_DIGOUT_NID,
2715 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2716 .channel_mode = alc880_2_jack_modes,
2717 .input_mux = &alc880_lg_lw_capture_source,
2718 .unsol_event = alc880_lg_lw_unsol_event,
2719 .init_hook = alc880_lg_lw_automute,
2720 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002721#ifdef CONFIG_SND_DEBUG
2722 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723 .mixers = { alc880_test_mixer },
2724 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2726 .dac_nids = alc880_test_dac_nids,
2727 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2729 .channel_mode = alc880_test_modes,
2730 .input_mux = &alc880_test_capture_source,
2731 },
2732#endif
2733};
2734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735/*
2736 * Automatic parse of I/O pins from the BIOS configuration
2737 */
2738
2739#define NUM_CONTROL_ALLOC 32
2740#define NUM_VERB_ALLOC 32
2741
2742enum {
2743 ALC_CTL_WIDGET_VOL,
2744 ALC_CTL_WIDGET_MUTE,
2745 ALC_CTL_BIND_MUTE,
2746};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002747static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002748 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2749 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002750 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002751};
2752
2753/* add dynamic controls */
2754static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2755{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002756 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002757
2758 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2759 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2760
2761 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2762 if (! knew)
2763 return -ENOMEM;
2764 if (spec->kctl_alloc) {
2765 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2766 kfree(spec->kctl_alloc);
2767 }
2768 spec->kctl_alloc = knew;
2769 spec->num_kctl_alloc = num;
2770 }
2771
2772 knew = &spec->kctl_alloc[spec->num_kctl_used];
2773 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002774 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002775 if (! knew->name)
2776 return -ENOMEM;
2777 knew->private_value = val;
2778 spec->num_kctl_used++;
2779 return 0;
2780}
2781
2782#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2783#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2784#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2785#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2786#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2787#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2788#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2789#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2790#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2791#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2792#define ALC880_PIN_CD_NID 0x1c
2793
2794/* fill in the dac_nids table from the parsed pin configuration */
2795static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2796{
2797 hda_nid_t nid;
2798 int assigned[4];
2799 int i, j;
2800
2801 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002802 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803
2804 /* check the pins hardwired to audio widget */
2805 for (i = 0; i < cfg->line_outs; i++) {
2806 nid = cfg->line_out_pins[i];
2807 if (alc880_is_fixed_pin(nid)) {
2808 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002809 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002810 assigned[idx] = 1;
2811 }
2812 }
2813 /* left pins can be connect to any audio widget */
2814 for (i = 0; i < cfg->line_outs; i++) {
2815 nid = cfg->line_out_pins[i];
2816 if (alc880_is_fixed_pin(nid))
2817 continue;
2818 /* search for an empty channel */
2819 for (j = 0; j < cfg->line_outs; j++) {
2820 if (! assigned[j]) {
2821 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2822 assigned[j] = 1;
2823 break;
2824 }
2825 }
2826 }
2827 spec->multiout.num_dacs = cfg->line_outs;
2828 return 0;
2829}
2830
2831/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002832static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2833 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002834{
2835 char name[32];
2836 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2837 hda_nid_t nid;
2838 int i, err;
2839
2840 for (i = 0; i < cfg->line_outs; i++) {
2841 if (! spec->multiout.dac_nids[i])
2842 continue;
2843 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2844 if (i == 2) {
2845 /* Center/LFE */
2846 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2847 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2848 return err;
2849 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2850 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2851 return err;
2852 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2853 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2854 return err;
2855 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2856 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2857 return err;
2858 } else {
2859 sprintf(name, "%s Playback Volume", chname[i]);
2860 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2861 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2862 return err;
2863 sprintf(name, "%s Playback Switch", chname[i]);
2864 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2865 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2866 return err;
2867 }
2868 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002869 return 0;
2870}
2871
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002872/* add playback controls for speaker and HP outputs */
2873static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2874 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002875{
2876 hda_nid_t nid;
2877 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002878 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002879
2880 if (! pin)
2881 return 0;
2882
2883 if (alc880_is_fixed_pin(pin)) {
2884 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002885 /* specify the DAC as the extra output */
2886 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002887 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002888 else
2889 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002890 /* control HP volume/switch on the output mixer amp */
2891 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002892 sprintf(name, "%s Playback Volume", pfx);
2893 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2895 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002896 sprintf(name, "%s Playback Switch", pfx);
2897 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2899 return err;
2900 } else if (alc880_is_multi_pin(pin)) {
2901 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002902 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002903 sprintf(name, "%s Playback Switch", pfx);
2904 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002905 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2906 return err;
2907 }
2908 return 0;
2909}
2910
2911/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002912static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2913 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002914{
2915 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002916 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002917
2918 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002919 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002920 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002921 return err;
2922 sprintf(name, "%s Playback Switch", ctlname);
2923 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002924 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002925 return err;
2926 return 0;
2927}
2928
2929/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002930static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2931 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002932{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002933 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002934 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002935
2936 for (i = 0; i < AUTO_PIN_LAST; i++) {
2937 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002938 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002939 err = new_analog_input(spec, cfg->input_pins[i],
2940 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002941 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002942 if (err < 0)
2943 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002944 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002945 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2946 imux->num_items++;
2947 }
2948 }
2949 return 0;
2950}
2951
Kailang Yangdf694da2005-12-05 19:42:22 +01002952static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2953 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954 int dac_idx)
2955{
2956 /* set as output */
2957 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2958 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2959 /* need the manual connection? */
2960 if (alc880_is_multi_pin(nid)) {
2961 struct alc_spec *spec = codec->spec;
2962 int idx = alc880_multi_pin_idx(nid);
2963 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2964 AC_VERB_SET_CONNECT_SEL,
2965 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2966 }
2967}
2968
2969static void alc880_auto_init_multi_out(struct hda_codec *codec)
2970{
2971 struct alc_spec *spec = codec->spec;
2972 int i;
2973
2974 for (i = 0; i < spec->autocfg.line_outs; i++) {
2975 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2976 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2977 }
2978}
2979
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002980static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002981{
2982 struct alc_spec *spec = codec->spec;
2983 hda_nid_t pin;
2984
Takashi Iwai82bc9552006-03-21 11:24:42 +01002985 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002986 if (pin) /* connect to front */
2987 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002988 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002989 if (pin) /* connect to front */
2990 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2991}
2992
2993static void alc880_auto_init_analog_input(struct hda_codec *codec)
2994{
2995 struct alc_spec *spec = codec->spec;
2996 int i;
2997
2998 for (i = 0; i < AUTO_PIN_LAST; i++) {
2999 hda_nid_t nid = spec->autocfg.input_pins[i];
3000 if (alc880_is_input_pin(nid)) {
3001 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3002 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3003 if (nid != ALC880_PIN_CD_NID)
3004 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3005 AMP_OUT_MUTE);
3006 }
3007 }
3008}
3009
3010/* parse the BIOS configuration and set up the alc_spec */
3011/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3012static int alc880_parse_auto_config(struct hda_codec *codec)
3013{
3014 struct alc_spec *spec = codec->spec;
3015 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003016 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017
Kailang Yangdf694da2005-12-05 19:42:22 +01003018 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3019 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003020 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003021 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003022 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003023
3024 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
3025 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01003026 (err = alc880_auto_create_extra_out(spec,
3027 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003028 "Speaker")) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003029 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003030 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003031 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3032 return err;
3033
3034 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3035
3036 if (spec->autocfg.dig_out_pin)
3037 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3038 if (spec->autocfg.dig_in_pin)
3039 spec->dig_in_nid = ALC880_DIGIN_NID;
3040
3041 if (spec->kctl_alloc)
3042 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3043
3044 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3045
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003046 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 spec->input_mux = &spec->private_imux;
3048
3049 return 1;
3050}
3051
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003052/* additional initialization for auto-configuration model */
3053static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003055 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003056 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003058}
3059
3060/*
3061 * OK, here we have finally the patch for ALC880
3062 */
3063
Linus Torvalds1da177e2005-04-16 15:20:36 -07003064static int patch_alc880(struct hda_codec *codec)
3065{
3066 struct alc_spec *spec;
3067 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003068 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003070 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003071 if (spec == NULL)
3072 return -ENOMEM;
3073
3074 codec->spec = spec;
3075
3076 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02003077 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003078 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3079 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003081 }
3082
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003083 if (board_config == ALC880_AUTO) {
3084 /* automatic parse from the BIOS config */
3085 err = alc880_parse_auto_config(codec);
3086 if (err < 0) {
3087 alc_free(codec);
3088 return err;
3089 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003090 printk(KERN_INFO
3091 "hda_codec: Cannot set up configuration "
3092 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003093 board_config = ALC880_3ST;
3094 }
3095 }
3096
Kailang Yangdf694da2005-12-05 19:42:22 +01003097 if (board_config != ALC880_AUTO)
3098 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003099
3100 spec->stream_name_analog = "ALC880 Analog";
3101 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3102 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3103
3104 spec->stream_name_digital = "ALC880 Digital";
3105 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3106 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3107
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 if (! spec->adc_nids && spec->input_mux) {
3109 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003110 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3112 if (wcap != AC_WID_AUD_IN) {
3113 spec->adc_nids = alc880_adc_nids_alt;
3114 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3115 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3116 spec->num_mixers++;
3117 } else {
3118 spec->adc_nids = alc880_adc_nids;
3119 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3120 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3121 spec->num_mixers++;
3122 }
3123 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003124
3125 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003127 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003128
3129 return 0;
3130}
3131
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133/*
3134 * ALC260 support
3135 */
3136
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137static hda_nid_t alc260_dac_nids[1] = {
3138 /* front */
3139 0x02,
3140};
3141
3142static hda_nid_t alc260_adc_nids[1] = {
3143 /* ADC0 */
3144 0x04,
3145};
3146
Kailang Yangdf694da2005-12-05 19:42:22 +01003147static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003148 /* ADC1 */
3149 0x05,
3150};
3151
Kailang Yangdf694da2005-12-05 19:42:22 +01003152static hda_nid_t alc260_hp_adc_nids[2] = {
3153 /* ADC1, 0 */
3154 0x05, 0x04
3155};
3156
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003157/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3158 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3159 */
3160static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003161 /* ADC0, ADC1 */
3162 0x04, 0x05
3163};
3164
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165#define ALC260_DIGOUT_NID 0x03
3166#define ALC260_DIGIN_NID 0x06
3167
3168static struct hda_input_mux alc260_capture_source = {
3169 .num_items = 4,
3170 .items = {
3171 { "Mic", 0x0 },
3172 { "Front Mic", 0x1 },
3173 { "Line", 0x2 },
3174 { "CD", 0x4 },
3175 },
3176};
3177
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003178/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003179 * headphone jack and the internal CD lines since these are the only pins at
3180 * which audio can appear. For flexibility, also allow the option of
3181 * recording the mixer output on the second ADC (ADC0 doesn't have a
3182 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003183 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003184static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3185 {
3186 .num_items = 3,
3187 .items = {
3188 { "Mic/Line", 0x0 },
3189 { "CD", 0x4 },
3190 { "Headphone", 0x2 },
3191 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003192 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003193 {
3194 .num_items = 4,
3195 .items = {
3196 { "Mic/Line", 0x0 },
3197 { "CD", 0x4 },
3198 { "Headphone", 0x2 },
3199 { "Mixer", 0x5 },
3200 },
3201 },
3202
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003203};
3204
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003205/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3206 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003207 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003208static struct hda_input_mux alc260_acer_capture_sources[2] = {
3209 {
3210 .num_items = 4,
3211 .items = {
3212 { "Mic", 0x0 },
3213 { "Line", 0x2 },
3214 { "CD", 0x4 },
3215 { "Headphone", 0x5 },
3216 },
3217 },
3218 {
3219 .num_items = 5,
3220 .items = {
3221 { "Mic", 0x0 },
3222 { "Line", 0x2 },
3223 { "CD", 0x4 },
3224 { "Headphone", 0x6 },
3225 { "Mixer", 0x5 },
3226 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003227 },
3228};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003229/*
3230 * This is just place-holder, so there's something for alc_build_pcms to look
3231 * at when it calculates the maximum number of channels. ALC260 has no mixer
3232 * element which allows changing the channel mode, so the verb list is
3233 * never used.
3234 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003235static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003236 { 2, NULL },
3237};
3238
Kailang Yangdf694da2005-12-05 19:42:22 +01003239
3240/* Mixer combinations
3241 *
3242 * basic: base_output + input + pc_beep + capture
3243 * HP: base_output + input + capture_alt
3244 * HP_3013: hp_3013 + input + capture
3245 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003246 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003247 */
3248
3249static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003250 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003251 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003252 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3253 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3254 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3255 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3256 { } /* end */
3257};
3258
3259static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3261 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3262 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3263 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3265 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3266 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3267 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003268 { } /* end */
3269};
3270
Kailang Yangdf694da2005-12-05 19:42:22 +01003271static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3272 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3273 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3274 { } /* end */
3275};
3276
3277static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3278 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3279 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3280 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3281 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3284 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3285 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003286 { } /* end */
3287};
3288
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003289/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3290 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3291 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003292static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003293 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003294 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003295 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003296 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3297 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3298 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3299 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003300 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003301 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3302 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3303 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003304 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003305 { } /* end */
3306};
3307
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003308/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3309 * versions of the ALC260 don't act on requests to enable mic bias from NID
3310 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3311 * datasheet doesn't mention this restriction. At this stage it's not clear
3312 * whether this behaviour is intentional or is a hardware bug in chip
3313 * revisions available in early 2006. Therefore for now allow the
3314 * "Headphone Jack Mode" control to span all choices, but if it turns out
3315 * that the lack of mic bias for this NID is intentional we could change the
3316 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3317 *
3318 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3319 * don't appear to make the mic bias available from the "line" jack, even
3320 * though the NID used for this jack (0x14) can supply it. The theory is
3321 * that perhaps Acer have included blocking capacitors between the ALC260
3322 * and the output jack. If this turns out to be the case for all such
3323 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3324 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3325 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003326static struct snd_kcontrol_new alc260_acer_mixer[] = {
3327 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3328 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003329 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003330 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3331 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3333 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3334 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3335 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3336 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3337 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3338 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3339 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3340 { } /* end */
3341};
3342
Kailang Yangdf694da2005-12-05 19:42:22 +01003343/* capture mixer elements */
3344static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003345 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3346 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003347 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3348 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003349 {
3350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003351 /* The multiple "Capture Source" controls confuse alsamixer
3352 * So call somewhat different..
3353 * FIXME: the controls appear in the "playback" view!
3354 */
3355 /* .name = "Capture Source", */
3356 .name = "Input Source",
3357 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003358 .info = alc_mux_enum_info,
3359 .get = alc_mux_enum_get,
3360 .put = alc_mux_enum_put,
3361 },
3362 { } /* end */
3363};
3364
Kailang Yangdf694da2005-12-05 19:42:22 +01003365static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3366 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3367 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3368 {
3369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3370 /* The multiple "Capture Source" controls confuse alsamixer
3371 * So call somewhat different..
3372 * FIXME: the controls appear in the "playback" view!
3373 */
3374 /* .name = "Capture Source", */
3375 .name = "Input Source",
3376 .count = 1,
3377 .info = alc_mux_enum_info,
3378 .get = alc_mux_enum_get,
3379 .put = alc_mux_enum_put,
3380 },
3381 { } /* end */
3382};
3383
3384/*
3385 * initialization verbs
3386 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003387static struct hda_verb alc260_init_verbs[] = {
3388 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003392 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003393 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003395 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003396 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003399 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003400 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003401 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003402 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003403 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003404 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003405 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3406 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003407 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003408 /* set connection select to line in (default select for this ADC) */
3409 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003410 /* mute capture amp left and right */
3411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3412 /* set connection select to line in (default select for this ADC) */
3413 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003414 /* set vol=0 Line-Out mixer amp left and right */
3415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3416 /* unmute pin widget amp left and right (no gain on this amp) */
3417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3418 /* set vol=0 HP mixer amp left and right */
3419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3420 /* unmute pin widget amp left and right (no gain on this amp) */
3421 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3422 /* set vol=0 Mono mixer amp left and right */
3423 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3424 /* unmute pin widget amp left and right (no gain on this amp) */
3425 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3426 /* unmute LINE-2 out pin */
3427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003429 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003431 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003433 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003435 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003436 /* mute Front out path */
3437 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3439 /* mute Headphone out path */
3440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3442 /* mute Mono out path */
3443 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445 { }
3446};
3447
Takashi Iwai474167d2006-05-17 17:17:43 +02003448#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003449static struct hda_verb alc260_hp_init_verbs[] = {
3450 /* Headphone and output */
3451 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3452 /* mono output */
3453 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3454 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3455 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3456 /* Mic2 (front panel) pin widget for input and vref at 80% */
3457 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3458 /* Line In pin widget for input */
3459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3460 /* Line-2 pin widget for output */
3461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3462 /* CD pin widget for input */
3463 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3464 /* unmute amp left and right */
3465 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3466 /* set connection select to line in (default select for this ADC) */
3467 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3468 /* unmute Line-Out mixer amp left and right (volume = 0) */
3469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3470 /* mute pin widget amp left and right (no gain on this amp) */
3471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3472 /* unmute HP mixer amp left and right (volume = 0) */
3473 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3474 /* mute pin widget amp left and right (no gain on this amp) */
3475 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3476 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3477 /* unmute CD */
3478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3479 /* unmute Line In */
3480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3481 /* unmute Mic */
3482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3483 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3484 /* Unmute Front out path */
3485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3487 /* Unmute Headphone out path */
3488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3490 /* Unmute Mono out path */
3491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3493 { }
3494};
Takashi Iwai474167d2006-05-17 17:17:43 +02003495#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003496
3497static struct hda_verb alc260_hp_3013_init_verbs[] = {
3498 /* Line out and output */
3499 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3500 /* mono output */
3501 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3502 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3503 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3504 /* Mic2 (front panel) pin widget for input and vref at 80% */
3505 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3506 /* Line In pin widget for input */
3507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3508 /* Headphone pin widget for output */
3509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3510 /* CD pin widget for input */
3511 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3512 /* unmute amp left and right */
3513 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3514 /* set connection select to line in (default select for this ADC) */
3515 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3516 /* unmute Line-Out mixer amp left and right (volume = 0) */
3517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3518 /* mute pin widget amp left and right (no gain on this amp) */
3519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3520 /* unmute HP mixer amp left and right (volume = 0) */
3521 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3522 /* mute pin widget amp left and right (no gain on this amp) */
3523 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3524 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3525 /* unmute CD */
3526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3527 /* unmute Line In */
3528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3529 /* unmute Mic */
3530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3531 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3532 /* Unmute Front out path */
3533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3535 /* Unmute Headphone out path */
3536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3538 /* Unmute Mono out path */
3539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3540 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3541 { }
3542};
3543
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003544/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003545 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3546 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003547 */
3548static struct hda_verb alc260_fujitsu_init_verbs[] = {
3549 /* Disable all GPIOs */
3550 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3551 /* Internal speaker is connected to headphone pin */
3552 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3553 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003555 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3556 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3557 /* Ensure all other unused pins are disabled and muted. */
3558 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3559 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003560 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003561 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003562 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003563 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3564 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003566
Jonathan Woithef7ace402006-02-28 11:46:14 +01003567 /* Disable digital (SPDIF) pins */
3568 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3569 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003570
Jonathan Woithef7ace402006-02-28 11:46:14 +01003571 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3572 * when acting as an output.
3573 */
3574 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3575
3576 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003577 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3579 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3581 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3582 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3583 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3584 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3585 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003586
Jonathan Woithef7ace402006-02-28 11:46:14 +01003587 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3588 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3589 /* Unmute Line1 pin widget output buffer since it starts as an output.
3590 * If the pin mode is changed by the user the pin mode control will
3591 * take care of enabling the pin's input/output buffers as needed.
3592 * Therefore there's no need to enable the input buffer at this
3593 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003594 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003595 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003596 /* Unmute input buffer of pin widget used for Line-in (no equiv
3597 * mixer ctrl)
3598 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003599 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003600
Jonathan Woithef7ace402006-02-28 11:46:14 +01003601 /* Mute capture amp left and right */
3602 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3603 /* Set ADC connection select to match default mixer setting - line
3604 * in (on mic1 pin)
3605 */
3606 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003607
Jonathan Woithef7ace402006-02-28 11:46:14 +01003608 /* Do the same for the second ADC: mute capture input amp and
3609 * set ADC connection to line in (on mic1 pin)
3610 */
3611 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3612 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003613
Jonathan Woithef7ace402006-02-28 11:46:14 +01003614 /* Mute all inputs to mixer widget (even unconnected ones) */
3615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003623
3624 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003625};
3626
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003627/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3628 * similar laptops (adapted from Fujitsu init verbs).
3629 */
3630static struct hda_verb alc260_acer_init_verbs[] = {
3631 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3632 * the headphone jack. Turn this on and rely on the standard mute
3633 * methods whenever the user wants to turn these outputs off.
3634 */
3635 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3636 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3637 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3638 /* Internal speaker/Headphone jack is connected to Line-out pin */
3639 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3640 /* Internal microphone/Mic jack is connected to Mic1 pin */
3641 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3642 /* Line In jack is connected to Line1 pin */
3643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3644 /* Ensure all other unused pins are disabled and muted. */
3645 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3646 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3647 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3648 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3649 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3650 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3653 /* Disable digital (SPDIF) pins */
3654 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3655 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3656
3657 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3658 * bus when acting as outputs.
3659 */
3660 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3661 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3662
3663 /* Start with output sum widgets muted and their output gains at min */
3664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3665 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3666 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3671 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3672 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3673
3674 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3675 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3676 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3677 * inputs. If the pin mode is changed by the user the pin mode control
3678 * will take care of enabling the pin's input/output buffers as needed.
3679 * Therefore there's no need to enable the input buffer at this
3680 * stage.
3681 */
3682 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3684
3685 /* Mute capture amp left and right */
3686 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3687 /* Set ADC connection select to match default mixer setting - mic
3688 * (on mic1 pin)
3689 */
3690 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3691
3692 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003693 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003694 */
3695 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003696 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003697
3698 /* Mute all inputs to mixer widget (even unconnected ones) */
3699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3704 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3705 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3707
3708 { }
3709};
3710
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003711/* Test configuration for debugging, modelled after the ALC880 test
3712 * configuration.
3713 */
3714#ifdef CONFIG_SND_DEBUG
3715static hda_nid_t alc260_test_dac_nids[1] = {
3716 0x02,
3717};
3718static hda_nid_t alc260_test_adc_nids[2] = {
3719 0x04, 0x05,
3720};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003721/* For testing the ALC260, each input MUX needs its own definition since
3722 * the signal assignments are different. This assumes that the first ADC
3723 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003724 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003725static struct hda_input_mux alc260_test_capture_sources[2] = {
3726 {
3727 .num_items = 7,
3728 .items = {
3729 { "MIC1 pin", 0x0 },
3730 { "MIC2 pin", 0x1 },
3731 { "LINE1 pin", 0x2 },
3732 { "LINE2 pin", 0x3 },
3733 { "CD pin", 0x4 },
3734 { "LINE-OUT pin", 0x5 },
3735 { "HP-OUT pin", 0x6 },
3736 },
3737 },
3738 {
3739 .num_items = 8,
3740 .items = {
3741 { "MIC1 pin", 0x0 },
3742 { "MIC2 pin", 0x1 },
3743 { "LINE1 pin", 0x2 },
3744 { "LINE2 pin", 0x3 },
3745 { "CD pin", 0x4 },
3746 { "Mixer", 0x5 },
3747 { "LINE-OUT pin", 0x6 },
3748 { "HP-OUT pin", 0x7 },
3749 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003750 },
3751};
3752static struct snd_kcontrol_new alc260_test_mixer[] = {
3753 /* Output driver widgets */
3754 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3755 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3756 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3757 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3758 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3759 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3760
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003761 /* Modes for retasking pin widgets
3762 * Note: the ALC260 doesn't seem to act on requests to enable mic
3763 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3764 * mention this restriction. At this stage it's not clear whether
3765 * this behaviour is intentional or is a hardware bug in chip
3766 * revisions available at least up until early 2006. Therefore for
3767 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3768 * choices, but if it turns out that the lack of mic bias for these
3769 * NIDs is intentional we could change their modes from
3770 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3771 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003772 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3773 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3774 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3775 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3776 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3777 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3778
3779 /* Loopback mixer controls */
3780 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3781 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3782 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3783 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3784 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3785 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3786 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3787 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3788 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3789 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3790 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3791 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3792 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3793 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3794 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3795 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003796
3797 /* Controls for GPIO pins, assuming they are configured as outputs */
3798 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3799 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3800 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3801 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3802
Jonathan Woithe92621f12006-02-28 11:47:47 +01003803 /* Switches to allow the digital IO pins to be enabled. The datasheet
3804 * is ambigious as to which NID is which; testing on laptops which
3805 * make this output available should provide clarification.
3806 */
3807 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3808 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3809
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003810 { } /* end */
3811};
3812static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003813 /* Enable all GPIOs as outputs with an initial value of 0 */
3814 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3815 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3816 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3817
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003818 /* Enable retasking pins as output, initially without power amp */
3819 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3820 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3823 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3824 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3825
Jonathan Woithe92621f12006-02-28 11:47:47 +01003826 /* Disable digital (SPDIF) pins initially, but users can enable
3827 * them via a mixer switch. In the case of SPDIF-out, this initverb
3828 * payload also sets the generation to 0, output to be in "consumer"
3829 * PCM format, copyright asserted, no pre-emphasis and no validity
3830 * control.
3831 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003832 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3833 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3834
Jonathan Woithef7ace402006-02-28 11:46:14 +01003835 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003836 * OUT1 sum bus when acting as an output.
3837 */
3838 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3839 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3840 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3841 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3842
3843 /* Start with output sum widgets muted and their output gains at min */
3844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3850 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3852 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3853
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003854 /* Unmute retasking pin widget output buffers since the default
3855 * state appears to be output. As the pin mode is changed by the
3856 * user the pin mode control will take care of enabling the pin's
3857 * input/output buffers as needed.
3858 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003859 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3860 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3863 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3864 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3865 /* Also unmute the mono-out pin widget */
3866 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3867
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003868 /* Mute capture amp left and right */
3869 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003870 /* Set ADC connection select to match default mixer setting (mic1
3871 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003872 */
3873 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3874
3875 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003876 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003877 */
3878 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3879 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3880
3881 /* Mute all inputs to mixer widget (even unconnected ones) */
3882 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3890
3891 { }
3892};
3893#endif
3894
Linus Torvalds1da177e2005-04-16 15:20:36 -07003895static struct hda_pcm_stream alc260_pcm_analog_playback = {
3896 .substreams = 1,
3897 .channels_min = 2,
3898 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003899};
3900
3901static struct hda_pcm_stream alc260_pcm_analog_capture = {
3902 .substreams = 1,
3903 .channels_min = 2,
3904 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003905};
3906
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003907#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3908#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3909
Kailang Yangdf694da2005-12-05 19:42:22 +01003910/*
3911 * for BIOS auto-configuration
3912 */
3913
3914static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3915 const char *pfx)
3916{
3917 hda_nid_t nid_vol;
3918 unsigned long vol_val, sw_val;
3919 char name[32];
3920 int err;
3921
3922 if (nid >= 0x0f && nid < 0x11) {
3923 nid_vol = nid - 0x7;
3924 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3925 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3926 } else if (nid == 0x11) {
3927 nid_vol = nid - 0x7;
3928 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3929 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3930 } else if (nid >= 0x12 && nid <= 0x15) {
3931 nid_vol = 0x08;
3932 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3933 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3934 } else
3935 return 0; /* N/A */
3936
3937 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3938 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3939 return err;
3940 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3941 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3942 return err;
3943 return 1;
3944}
3945
3946/* add playback controls from the parsed DAC table */
3947static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3948 const struct auto_pin_cfg *cfg)
3949{
3950 hda_nid_t nid;
3951 int err;
3952
3953 spec->multiout.num_dacs = 1;
3954 spec->multiout.dac_nids = spec->private_dac_nids;
3955 spec->multiout.dac_nids[0] = 0x02;
3956
3957 nid = cfg->line_out_pins[0];
3958 if (nid) {
3959 err = alc260_add_playback_controls(spec, nid, "Front");
3960 if (err < 0)
3961 return err;
3962 }
3963
Takashi Iwai82bc9552006-03-21 11:24:42 +01003964 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003965 if (nid) {
3966 err = alc260_add_playback_controls(spec, nid, "Speaker");
3967 if (err < 0)
3968 return err;
3969 }
3970
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003971 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003972 if (nid) {
3973 err = alc260_add_playback_controls(spec, nid, "Headphone");
3974 if (err < 0)
3975 return err;
3976 }
3977 return 0;
3978}
3979
3980/* create playback/capture controls for input pins */
3981static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3982 const struct auto_pin_cfg *cfg)
3983{
Kailang Yangdf694da2005-12-05 19:42:22 +01003984 struct hda_input_mux *imux = &spec->private_imux;
3985 int i, err, idx;
3986
3987 for (i = 0; i < AUTO_PIN_LAST; i++) {
3988 if (cfg->input_pins[i] >= 0x12) {
3989 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003990 err = new_analog_input(spec, cfg->input_pins[i],
3991 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003992 if (err < 0)
3993 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003994 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003995 imux->items[imux->num_items].index = idx;
3996 imux->num_items++;
3997 }
3998 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3999 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004000 err = new_analog_input(spec, cfg->input_pins[i],
4001 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004002 if (err < 0)
4003 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004004 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004005 imux->items[imux->num_items].index = idx;
4006 imux->num_items++;
4007 }
4008 }
4009 return 0;
4010}
4011
4012static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4013 hda_nid_t nid, int pin_type,
4014 int sel_idx)
4015{
4016 /* set as output */
4017 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4018 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4019 /* need the manual connection? */
4020 if (nid >= 0x12) {
4021 int idx = nid - 0x12;
4022 snd_hda_codec_write(codec, idx + 0x0b, 0,
4023 AC_VERB_SET_CONNECT_SEL, sel_idx);
4024
4025 }
4026}
4027
4028static void alc260_auto_init_multi_out(struct hda_codec *codec)
4029{
4030 struct alc_spec *spec = codec->spec;
4031 hda_nid_t nid;
4032
4033 nid = spec->autocfg.line_out_pins[0];
4034 if (nid)
4035 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4036
Takashi Iwai82bc9552006-03-21 11:24:42 +01004037 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004038 if (nid)
4039 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4040
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004041 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004042 if (nid)
4043 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4044}
4045
4046#define ALC260_PIN_CD_NID 0x16
4047static void alc260_auto_init_analog_input(struct hda_codec *codec)
4048{
4049 struct alc_spec *spec = codec->spec;
4050 int i;
4051
4052 for (i = 0; i < AUTO_PIN_LAST; i++) {
4053 hda_nid_t nid = spec->autocfg.input_pins[i];
4054 if (nid >= 0x12) {
4055 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4056 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4057 if (nid != ALC260_PIN_CD_NID)
4058 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4059 AMP_OUT_MUTE);
4060 }
4061 }
4062}
4063
4064/*
4065 * generic initialization of ADC, input mixers and output mixers
4066 */
4067static struct hda_verb alc260_volume_init_verbs[] = {
4068 /*
4069 * Unmute ADC0-1 and set the default input to mic-in
4070 */
4071 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4072 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4073 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4074 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4075
4076 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4077 * mixer widget
4078 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4079 * mic (mic 2)
4080 */
4081 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4087
4088 /*
4089 * Set up output mixers (0x08 - 0x0a)
4090 */
4091 /* set vol=0 to output mixers */
4092 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4093 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4095 /* set up input amps for analog loopback */
4096 /* Amp Indices: DAC = 0, mixer = 1 */
4097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4101 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4102 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4103
4104 { }
4105};
4106
4107static int alc260_parse_auto_config(struct hda_codec *codec)
4108{
4109 struct alc_spec *spec = codec->spec;
4110 unsigned int wcap;
4111 int err;
4112 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4113
4114 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4115 alc260_ignore)) < 0)
4116 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004117 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4118 return err;
4119 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004120 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004121 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004122 return err;
4123
4124 spec->multiout.max_channels = 2;
4125
4126 if (spec->autocfg.dig_out_pin)
4127 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4128 if (spec->kctl_alloc)
4129 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4130
4131 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4132
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004133 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004134 spec->input_mux = &spec->private_imux;
4135
4136 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004137 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004138 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4139 if (wcap != AC_WID_AUD_IN) {
4140 spec->adc_nids = alc260_adc_nids_alt;
4141 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4142 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004143 } else {
4144 spec->adc_nids = alc260_adc_nids;
4145 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4146 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004147 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004148 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004149
4150 return 1;
4151}
4152
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004153/* additional initialization for auto-configuration model */
4154static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004155{
Kailang Yangdf694da2005-12-05 19:42:22 +01004156 alc260_auto_init_multi_out(codec);
4157 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004158}
4159
4160/*
4161 * ALC260 configurations
4162 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004163static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01004164 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01004165 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
4166 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai3206b9c2006-05-10 16:33:11 +02004167 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
4168 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02004169 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
4170 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01004171 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
4172 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02004173 { .modelname = "hp", .config = ALC260_HP },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004174 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
Takashi Iwai25b6c432006-08-08 13:01:14 +02004175 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004176 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
Takashi Iwai766a6c32006-05-26 14:58:29 +02004177 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004178 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
4179 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
4180 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
4181 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
4182 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
4183 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004184 { .modelname = "acer", .config = ALC260_ACER },
4185 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004186#ifdef CONFIG_SND_DEBUG
4187 { .modelname = "test", .config = ALC260_TEST },
4188#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004189 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02004190 {}
4191};
4192
Kailang Yangdf694da2005-12-05 19:42:22 +01004193static struct alc_config_preset alc260_presets[] = {
4194 [ALC260_BASIC] = {
4195 .mixers = { alc260_base_output_mixer,
4196 alc260_input_mixer,
4197 alc260_pc_beep_mixer,
4198 alc260_capture_mixer },
4199 .init_verbs = { alc260_init_verbs },
4200 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4201 .dac_nids = alc260_dac_nids,
4202 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4203 .adc_nids = alc260_adc_nids,
4204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4205 .channel_mode = alc260_modes,
4206 .input_mux = &alc260_capture_source,
4207 },
4208 [ALC260_HP] = {
4209 .mixers = { alc260_base_output_mixer,
4210 alc260_input_mixer,
4211 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004212 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004213 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4214 .dac_nids = alc260_dac_nids,
4215 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4216 .adc_nids = alc260_hp_adc_nids,
4217 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4218 .channel_mode = alc260_modes,
4219 .input_mux = &alc260_capture_source,
4220 },
4221 [ALC260_HP_3013] = {
4222 .mixers = { alc260_hp_3013_mixer,
4223 alc260_input_mixer,
4224 alc260_capture_alt_mixer },
4225 .init_verbs = { alc260_hp_3013_init_verbs },
4226 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4227 .dac_nids = alc260_dac_nids,
4228 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4229 .adc_nids = alc260_hp_adc_nids,
4230 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4231 .channel_mode = alc260_modes,
4232 .input_mux = &alc260_capture_source,
4233 },
4234 [ALC260_FUJITSU_S702X] = {
4235 .mixers = { alc260_fujitsu_mixer,
4236 alc260_capture_mixer },
4237 .init_verbs = { alc260_fujitsu_init_verbs },
4238 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4239 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004240 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4241 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004242 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4243 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004244 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4245 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004246 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004247 [ALC260_ACER] = {
4248 .mixers = { alc260_acer_mixer,
4249 alc260_capture_mixer },
4250 .init_verbs = { alc260_acer_init_verbs },
4251 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4252 .dac_nids = alc260_dac_nids,
4253 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4254 .adc_nids = alc260_dual_adc_nids,
4255 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4256 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004257 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4258 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004259 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004260#ifdef CONFIG_SND_DEBUG
4261 [ALC260_TEST] = {
4262 .mixers = { alc260_test_mixer,
4263 alc260_capture_mixer },
4264 .init_verbs = { alc260_test_init_verbs },
4265 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4266 .dac_nids = alc260_test_dac_nids,
4267 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4268 .adc_nids = alc260_test_adc_nids,
4269 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4270 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004271 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4272 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004273 },
4274#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004275};
4276
Linus Torvalds1da177e2005-04-16 15:20:36 -07004277static int patch_alc260(struct hda_codec *codec)
4278{
4279 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004280 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004281
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004282 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004283 if (spec == NULL)
4284 return -ENOMEM;
4285
4286 codec->spec = spec;
4287
Takashi Iwai16ded522005-06-10 19:58:24 +02004288 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4289 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004290 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4291 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004292 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004293 }
4294
Kailang Yangdf694da2005-12-05 19:42:22 +01004295 if (board_config == ALC260_AUTO) {
4296 /* automatic parse from the BIOS config */
4297 err = alc260_parse_auto_config(codec);
4298 if (err < 0) {
4299 alc_free(codec);
4300 return err;
4301 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004302 printk(KERN_INFO
4303 "hda_codec: Cannot set up configuration "
4304 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004305 board_config = ALC260_BASIC;
4306 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004307 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004308
Kailang Yangdf694da2005-12-05 19:42:22 +01004309 if (board_config != ALC260_AUTO)
4310 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004311
4312 spec->stream_name_analog = "ALC260 Analog";
4313 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4314 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4315
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004316 spec->stream_name_digital = "ALC260 Digital";
4317 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4318 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4319
Linus Torvalds1da177e2005-04-16 15:20:36 -07004320 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004321 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004322 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004323
4324 return 0;
4325}
4326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327
Linus Torvalds1da177e2005-04-16 15:20:36 -07004328/*
4329 * ALC882 support
4330 *
4331 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4332 * configuration. Each pin widget can choose any input DACs and a mixer.
4333 * Each ADC is connected from a mixer of all inputs. This makes possible
4334 * 6-channel independent captures.
4335 *
4336 * In addition, an independent DAC for the multi-playback (not used in this
4337 * driver yet).
4338 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004339#define ALC882_DIGOUT_NID 0x06
4340#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004341
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004342static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004343 { 8, NULL }
4344};
4345
4346static hda_nid_t alc882_dac_nids[4] = {
4347 /* front, rear, clfe, rear_surr */
4348 0x02, 0x03, 0x04, 0x05
4349};
4350
Kailang Yangdf694da2005-12-05 19:42:22 +01004351/* identical with ALC880 */
4352#define alc882_adc_nids alc880_adc_nids
4353#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004354
4355/* input MUX */
4356/* FIXME: should be a matrix-type input source selection */
4357
4358static struct hda_input_mux alc882_capture_source = {
4359 .num_items = 4,
4360 .items = {
4361 { "Mic", 0x0 },
4362 { "Front Mic", 0x1 },
4363 { "Line", 0x2 },
4364 { "CD", 0x4 },
4365 },
4366};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004367#define alc882_mux_enum_info alc_mux_enum_info
4368#define alc882_mux_enum_get alc_mux_enum_get
4369
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004370static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004371{
4372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4373 struct alc_spec *spec = codec->spec;
4374 const struct hda_input_mux *imux = spec->input_mux;
4375 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4376 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4377 hda_nid_t nid = capture_mixers[adc_idx];
4378 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4379 unsigned int i, idx;
4380
4381 idx = ucontrol->value.enumerated.item[0];
4382 if (idx >= imux->num_items)
4383 idx = imux->num_items - 1;
4384 if (*cur_val == idx && ! codec->in_resume)
4385 return 0;
4386 for (i = 0; i < imux->num_items; i++) {
4387 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4388 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4389 v | (imux->items[i].index << 8));
4390 }
4391 *cur_val = idx;
4392 return 1;
4393}
4394
Kailang Yangdf694da2005-12-05 19:42:22 +01004395/*
4396 * 6ch mode
4397 */
4398static struct hda_verb alc882_sixstack_ch6_init[] = {
4399 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4400 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4401 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4402 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4403 { } /* end */
4404};
4405
4406/*
4407 * 8ch mode
4408 */
4409static struct hda_verb alc882_sixstack_ch8_init[] = {
4410 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4411 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4412 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4413 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4414 { } /* end */
4415};
4416
4417static struct hda_channel_mode alc882_sixstack_modes[2] = {
4418 { 6, alc882_sixstack_ch6_init },
4419 { 8, alc882_sixstack_ch8_init },
4420};
4421
Linus Torvalds1da177e2005-04-16 15:20:36 -07004422/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4423 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4424 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004425static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004426 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004427 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004428 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004429 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004430 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4431 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004432 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4433 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004434 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004435 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004436 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4437 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4438 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4439 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4440 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4441 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4442 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4443 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4445 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4446 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004447 { } /* end */
4448};
4449
Kailang Yangdf694da2005-12-05 19:42:22 +01004450static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4451 {
4452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4453 .name = "Channel Mode",
4454 .info = alc_ch_mode_info,
4455 .get = alc_ch_mode_get,
4456 .put = alc_ch_mode_put,
4457 },
4458 { } /* end */
4459};
4460
Linus Torvalds1da177e2005-04-16 15:20:36 -07004461static struct hda_verb alc882_init_verbs[] = {
4462 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004466 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004470 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004474 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004482 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004484 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004485 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004486 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004488 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004489 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004490 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004491 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004494 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004495 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4498 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004499 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4501 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4504 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4507 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004508 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004509 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004510
4511 /* FIXME: use matrix-type input source selection */
4512 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4513 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004518 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004523 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4528 /* ADC1: mute amp left and right */
4529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004530 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004531 /* ADC2: mute amp left and right */
4532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004533 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004534 /* ADC3: mute amp left and right */
4535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004537
4538 { }
4539};
4540
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004541static struct hda_verb alc882_eapd_verbs[] = {
4542 /* change to EAPD mode */
4543 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004544 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004545 { }
4546};
4547
Kailang Yangdf694da2005-12-05 19:42:22 +01004548/*
4549 * generic initialization of ADC, input mixers and output mixers
4550 */
4551static struct hda_verb alc882_auto_init_verbs[] = {
4552 /*
4553 * Unmute ADC0-2 and set the default input to mic-in
4554 */
4555 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4557 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4559 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4561
4562 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4563 * mixer widget
4564 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4565 * mic (mic 2)
4566 */
4567 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4573
4574 /*
4575 * Set up output mixers (0x0c - 0x0f)
4576 */
4577 /* set vol=0 to output mixers */
4578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4581 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4582 /* set up input amps for analog loopback */
4583 /* Amp Indices: DAC = 0, mixer = 1 */
4584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4592 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4593 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4594
4595 /* FIXME: use matrix-type input source selection */
4596 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4597 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4602 /* Input mixer2 */
4603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4607 /* Input mixer3 */
4608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4612
4613 { }
4614};
4615
4616/* capture mixer elements */
4617static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4618 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4619 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4620 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4621 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4622 {
4623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4624 /* The multiple "Capture Source" controls confuse alsamixer
4625 * So call somewhat different..
4626 * FIXME: the controls appear in the "playback" view!
4627 */
4628 /* .name = "Capture Source", */
4629 .name = "Input Source",
4630 .count = 2,
4631 .info = alc882_mux_enum_info,
4632 .get = alc882_mux_enum_get,
4633 .put = alc882_mux_enum_put,
4634 },
4635 { } /* end */
4636};
4637
4638static struct snd_kcontrol_new alc882_capture_mixer[] = {
4639 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4640 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4641 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4642 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4643 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4644 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4645 {
4646 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4647 /* The multiple "Capture Source" controls confuse alsamixer
4648 * So call somewhat different..
4649 * FIXME: the controls appear in the "playback" view!
4650 */
4651 /* .name = "Capture Source", */
4652 .name = "Input Source",
4653 .count = 3,
4654 .info = alc882_mux_enum_info,
4655 .get = alc882_mux_enum_get,
4656 .put = alc882_mux_enum_put,
4657 },
4658 { } /* end */
4659};
4660
4661/* pcm configuration: identiacal with ALC880 */
4662#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4663#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4664#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4665#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4666
4667/*
4668 * configuration and preset
4669 */
4670static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004671 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4672 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004673 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4674 .config = ALC882_6ST_DIG }, /* MSI */
4675 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4676 .config = ALC882_6ST_DIG }, /* Foxconn */
4677 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4678 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004679 { .modelname = "arima", .config = ALC882_ARIMA },
4680 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4681 .config = ALC882_ARIMA }, /* Arima W820Di1 */
Takashi Iwai1494a922006-01-31 10:58:46 +01004682 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004683 {}
4684};
4685
4686static struct alc_config_preset alc882_presets[] = {
4687 [ALC882_3ST_DIG] = {
4688 .mixers = { alc882_base_mixer },
4689 .init_verbs = { alc882_init_verbs },
4690 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4691 .dac_nids = alc882_dac_nids,
4692 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004693 .dig_in_nid = ALC882_DIGIN_NID,
4694 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4695 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004696 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004697 .input_mux = &alc882_capture_source,
4698 },
4699 [ALC882_6ST_DIG] = {
4700 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4701 .init_verbs = { alc882_init_verbs },
4702 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4703 .dac_nids = alc882_dac_nids,
4704 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004705 .dig_in_nid = ALC882_DIGIN_NID,
4706 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4707 .channel_mode = alc882_sixstack_modes,
4708 .input_mux = &alc882_capture_source,
4709 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004710 [ALC882_ARIMA] = {
4711 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4712 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4713 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4714 .dac_nids = alc882_dac_nids,
4715 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4716 .channel_mode = alc882_sixstack_modes,
4717 .input_mux = &alc882_capture_source,
4718 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004719};
4720
4721
4722/*
4723 * BIOS auto configuration
4724 */
4725static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4726 hda_nid_t nid, int pin_type,
4727 int dac_idx)
4728{
4729 /* set as output */
4730 struct alc_spec *spec = codec->spec;
4731 int idx;
4732
4733 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4734 idx = 4;
4735 else
4736 idx = spec->multiout.dac_nids[dac_idx] - 2;
4737
4738 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4740 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4741
4742}
4743
4744static void alc882_auto_init_multi_out(struct hda_codec *codec)
4745{
4746 struct alc_spec *spec = codec->spec;
4747 int i;
4748
4749 for (i = 0; i <= HDA_SIDE; i++) {
4750 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4751 if (nid)
4752 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4753 }
4754}
4755
4756static void alc882_auto_init_hp_out(struct hda_codec *codec)
4757{
4758 struct alc_spec *spec = codec->spec;
4759 hda_nid_t pin;
4760
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004761 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004762 if (pin) /* connect to front */
4763 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4764}
4765
4766#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4767#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4768
4769static void alc882_auto_init_analog_input(struct hda_codec *codec)
4770{
4771 struct alc_spec *spec = codec->spec;
4772 int i;
4773
4774 for (i = 0; i < AUTO_PIN_LAST; i++) {
4775 hda_nid_t nid = spec->autocfg.input_pins[i];
4776 if (alc882_is_input_pin(nid)) {
4777 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4778 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4779 if (nid != ALC882_PIN_CD_NID)
4780 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4781 AMP_OUT_MUTE);
4782 }
4783 }
4784}
4785
4786/* almost identical with ALC880 parser... */
4787static int alc882_parse_auto_config(struct hda_codec *codec)
4788{
4789 struct alc_spec *spec = codec->spec;
4790 int err = alc880_parse_auto_config(codec);
4791
4792 if (err < 0)
4793 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004794 else if (err > 0)
4795 /* hack - override the init verbs */
4796 spec->init_verbs[0] = alc882_auto_init_verbs;
4797 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004798}
4799
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004800/* additional initialization for auto-configuration model */
4801static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004802{
Kailang Yangdf694da2005-12-05 19:42:22 +01004803 alc882_auto_init_multi_out(codec);
4804 alc882_auto_init_hp_out(codec);
4805 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004806}
4807
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808static int patch_alc882(struct hda_codec *codec)
4809{
4810 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004811 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004813 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814 if (spec == NULL)
4815 return -ENOMEM;
4816
Linus Torvalds1da177e2005-04-16 15:20:36 -07004817 codec->spec = spec;
4818
Kailang Yangdf694da2005-12-05 19:42:22 +01004819 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004820
Kailang Yangdf694da2005-12-05 19:42:22 +01004821 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004822 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4823 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004824 board_config = ALC882_AUTO;
4825 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004826
Kailang Yangdf694da2005-12-05 19:42:22 +01004827 if (board_config == ALC882_AUTO) {
4828 /* automatic parse from the BIOS config */
4829 err = alc882_parse_auto_config(codec);
4830 if (err < 0) {
4831 alc_free(codec);
4832 return err;
4833 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004834 printk(KERN_INFO
4835 "hda_codec: Cannot set up configuration "
4836 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004837 board_config = ALC882_3ST_DIG;
4838 }
4839 }
4840
4841 if (board_config != ALC882_AUTO)
4842 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004843
4844 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004845 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4846 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847
4848 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004849 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4850 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004851
Kailang Yangdf694da2005-12-05 19:42:22 +01004852 if (! spec->adc_nids && spec->input_mux) {
4853 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004854 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004855 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4856 if (wcap != AC_WID_AUD_IN) {
4857 spec->adc_nids = alc882_adc_nids_alt;
4858 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4859 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4860 spec->num_mixers++;
4861 } else {
4862 spec->adc_nids = alc882_adc_nids;
4863 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4864 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4865 spec->num_mixers++;
4866 }
4867 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004868
4869 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004870 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004871 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004872
4873 return 0;
4874}
4875
4876/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004877 * ALC883 support
4878 *
4879 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4880 * configuration. Each pin widget can choose any input DACs and a mixer.
4881 * Each ADC is connected from a mixer of all inputs. This makes possible
4882 * 6-channel independent captures.
4883 *
4884 * In addition, an independent DAC for the multi-playback (not used in this
4885 * driver yet).
4886 */
4887#define ALC883_DIGOUT_NID 0x06
4888#define ALC883_DIGIN_NID 0x0a
4889
4890static hda_nid_t alc883_dac_nids[4] = {
4891 /* front, rear, clfe, rear_surr */
4892 0x02, 0x04, 0x03, 0x05
4893};
4894
4895static hda_nid_t alc883_adc_nids[2] = {
4896 /* ADC1-2 */
4897 0x08, 0x09,
4898};
4899/* input MUX */
4900/* FIXME: should be a matrix-type input source selection */
4901
4902static struct hda_input_mux alc883_capture_source = {
4903 .num_items = 4,
4904 .items = {
4905 { "Mic", 0x0 },
4906 { "Front Mic", 0x1 },
4907 { "Line", 0x2 },
4908 { "CD", 0x4 },
4909 },
4910};
4911#define alc883_mux_enum_info alc_mux_enum_info
4912#define alc883_mux_enum_get alc_mux_enum_get
4913
4914static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4915 struct snd_ctl_elem_value *ucontrol)
4916{
4917 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4918 struct alc_spec *spec = codec->spec;
4919 const struct hda_input_mux *imux = spec->input_mux;
4920 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4921 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4922 hda_nid_t nid = capture_mixers[adc_idx];
4923 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4924 unsigned int i, idx;
4925
4926 idx = ucontrol->value.enumerated.item[0];
4927 if (idx >= imux->num_items)
4928 idx = imux->num_items - 1;
4929 if (*cur_val == idx && ! codec->in_resume)
4930 return 0;
4931 for (i = 0; i < imux->num_items; i++) {
4932 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4933 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4934 v | (imux->items[i].index << 8));
4935 }
4936 *cur_val = idx;
4937 return 1;
4938}
4939/*
4940 * 2ch mode
4941 */
4942static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4943 { 2, NULL }
4944};
4945
4946/*
4947 * 2ch mode
4948 */
4949static struct hda_verb alc883_3ST_ch2_init[] = {
4950 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4951 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4952 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4953 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4954 { } /* end */
4955};
4956
4957/*
4958 * 6ch mode
4959 */
4960static struct hda_verb alc883_3ST_ch6_init[] = {
4961 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4962 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4963 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4964 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4965 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4966 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4967 { } /* end */
4968};
4969
4970static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4971 { 2, alc883_3ST_ch2_init },
4972 { 6, alc883_3ST_ch6_init },
4973};
4974
4975/*
4976 * 6ch mode
4977 */
4978static struct hda_verb alc883_sixstack_ch6_init[] = {
4979 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4980 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4981 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4982 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4983 { } /* end */
4984};
4985
4986/*
4987 * 8ch mode
4988 */
4989static struct hda_verb alc883_sixstack_ch8_init[] = {
4990 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4991 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4992 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4993 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4994 { } /* end */
4995};
4996
4997static struct hda_channel_mode alc883_sixstack_modes[2] = {
4998 { 6, alc883_sixstack_ch6_init },
4999 { 8, alc883_sixstack_ch8_init },
5000};
5001
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005002static struct hda_verb alc883_medion_eapd_verbs[] = {
5003 /* eanable EAPD on medion laptop */
5004 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5005 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5006 { }
5007};
5008
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005009/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5010 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5011 */
5012
5013static struct snd_kcontrol_new alc883_base_mixer[] = {
5014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5015 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5017 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5022 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5023 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5025 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5026 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5033 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5034 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5035 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5036 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5037 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5038 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5039 {
5040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5041 /* .name = "Capture Source", */
5042 .name = "Input Source",
5043 .count = 2,
5044 .info = alc883_mux_enum_info,
5045 .get = alc883_mux_enum_get,
5046 .put = alc883_mux_enum_put,
5047 },
5048 { } /* end */
5049};
5050
5051static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5054 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5063 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5064 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5065 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5066 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5067 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5068 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5069 {
5070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5071 /* .name = "Capture Source", */
5072 .name = "Input Source",
5073 .count = 2,
5074 .info = alc883_mux_enum_info,
5075 .get = alc883_mux_enum_get,
5076 .put = alc883_mux_enum_put,
5077 },
5078 { } /* end */
5079};
5080
5081static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5082 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5084 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5085 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5086 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5087 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5088 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5089 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5094 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5099 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5100 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5101 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5102 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5103 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5104 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5105 {
5106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5107 /* .name = "Capture Source", */
5108 .name = "Input Source",
5109 .count = 2,
5110 .info = alc883_mux_enum_info,
5111 .get = alc883_mux_enum_get,
5112 .put = alc883_mux_enum_put,
5113 },
5114 { } /* end */
5115};
5116
Tobin Davisc07584c2006-10-13 12:32:16 +02005117static snd_kcontrol_new_t alc883_fivestack_mixer[] = {
5118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5119 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5120 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5121 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5122 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5123 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5124 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5125 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5135 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5136 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5137 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5138 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5139
5140 {
5141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5142 /* .name = "Capture Source", */
5143 .name = "Input Source",
5144 .count = 1,
5145 .info = alc883_mux_enum_info,
5146 .get = alc883_mux_enum_get,
5147 .put = alc883_mux_enum_put,
5148 },
5149 { } /* end */
5150};
5151
Kailang Yangccc656c2006-10-17 12:32:26 +02005152static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5153 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5155 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5156 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5157 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5158 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5159 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5160 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5161 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5164 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5165 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5168 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5169 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5170 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5171 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5172 {
5173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5174 /* .name = "Capture Source", */
5175 .name = "Input Source",
5176 .count = 2,
5177 .info = alc883_mux_enum_info,
5178 .get = alc883_mux_enum_get,
5179 .put = alc883_mux_enum_put,
5180 },
5181 { } /* end */
5182};
5183
5184static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5187 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5192 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5193 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5194 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5195 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5196 {
5197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5198 /* .name = "Capture Source", */
5199 .name = "Input Source",
5200 .count = 2,
5201 .info = alc883_mux_enum_info,
5202 .get = alc883_mux_enum_get,
5203 .put = alc883_mux_enum_put,
5204 },
5205 { } /* end */
5206};
5207
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005208static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5209 {
5210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5211 .name = "Channel Mode",
5212 .info = alc_ch_mode_info,
5213 .get = alc_ch_mode_get,
5214 .put = alc_ch_mode_put,
5215 },
5216 { } /* end */
5217};
5218
5219static struct hda_verb alc883_init_verbs[] = {
5220 /* ADC1: mute amp left and right */
5221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5223 /* ADC2: mute amp left and right */
5224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5225 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5226 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5230 /* Rear mixer */
5231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5234 /* CLFE mixer */
5235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5238 /* Side mixer */
5239 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5242
5243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5248
5249 /* Front Pin: output 0 (0x0c) */
5250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5252 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5253 /* Rear Pin: output 1 (0x0d) */
5254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5257 /* CLFE Pin: output 2 (0x0e) */
5258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5260 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5261 /* Side Pin: output 3 (0x0f) */
5262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5264 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5265 /* Mic (rear) pin: input vref at 80% */
5266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5268 /* Front Mic pin: input vref at 80% */
5269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5271 /* Line In pin: input */
5272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5274 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5275 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5276 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5277 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5278 /* CD pin widget for input */
5279 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5280
5281 /* FIXME: use matrix-type input source selection */
5282 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5283 /* Input mixer2 */
5284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5288 /* Input mixer3 */
5289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5293 { }
5294};
5295
Kailang Yangccc656c2006-10-17 12:32:26 +02005296static struct hda_verb alc883_tagra_verbs[] = {
5297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5299
5300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5302
5303 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5304 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5305 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5306
5307 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5308 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5309 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5310 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5311
5312 { } /* end */
5313};
5314
5315/* toggle speaker-output according to the hp-jack state */
5316static void alc883_tagra_automute(struct hda_codec *codec)
5317{
5318 unsigned int present;
5319
5320 present = snd_hda_codec_read(codec, 0x14, 0,
5321 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5322 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5323 0x80, present ? 0x80 : 0);
5324 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5325 0x80, present ? 0x80 : 0);
5326 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5327}
5328
5329static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5330{
5331 if ((res >> 26) == ALC880_HP_EVENT)
5332 alc883_tagra_automute(codec);
5333}
5334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005335/*
5336 * generic initialization of ADC, input mixers and output mixers
5337 */
5338static struct hda_verb alc883_auto_init_verbs[] = {
5339 /*
5340 * Unmute ADC0-2 and set the default input to mic-in
5341 */
5342 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5344 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5346
5347 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5348 * mixer widget
5349 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5350 * mic (mic 2)
5351 */
5352 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5358
5359 /*
5360 * Set up output mixers (0x0c - 0x0f)
5361 */
5362 /* set vol=0 to output mixers */
5363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5366 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5367 /* set up input amps for analog loopback */
5368 /* Amp Indices: DAC = 0, mixer = 1 */
5369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5376 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5377 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5378 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5379
5380 /* FIXME: use matrix-type input source selection */
5381 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5382 /* Input mixer1 */
5383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5386 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5388 /* Input mixer2 */
5389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5392 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5394
5395 { }
5396};
5397
5398/* capture mixer elements */
5399static struct snd_kcontrol_new alc883_capture_mixer[] = {
5400 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5401 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5402 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5403 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5404 {
5405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5406 /* The multiple "Capture Source" controls confuse alsamixer
5407 * So call somewhat different..
5408 * FIXME: the controls appear in the "playback" view!
5409 */
5410 /* .name = "Capture Source", */
5411 .name = "Input Source",
5412 .count = 2,
5413 .info = alc882_mux_enum_info,
5414 .get = alc882_mux_enum_get,
5415 .put = alc882_mux_enum_put,
5416 },
5417 { } /* end */
5418};
5419
5420/* pcm configuration: identiacal with ALC880 */
5421#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5422#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5423#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5424#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5425
5426/*
5427 * configuration and preset
5428 */
5429static struct hda_board_config alc883_cfg_tbl[] = {
5430 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005431 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5432 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5433 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5434 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5435 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
Kailang Yangccc656c2006-10-17 12:32:26 +02005436 .config = ALC883_3ST_6ch },
5437 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
5438 .config = ALC883_3ST_6ch }, /* D102GGC */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005439 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005440 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5441 .config = ALC883_6ST_DIG }, /* MSI */
Leonard Norrgårde22a9a82007-01-01 19:00:54 +02005442 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
5443 .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005444 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5445 .config = ALC883_6ST_DIG }, /* Foxconn */
Kailang Yangccc656c2006-10-17 12:32:26 +02005446 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7187,
5447 .config = ALC883_6ST_DIG }, /* MSI */
5448 { .modelname = "targa-dig", .config = ALC883_TARGA_DIG },
5449 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
5450 .config = ALC883_TARGA_DIG }, /* MSI */
5451 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fcc,
5452 .config = ALC883_TARGA_DIG }, /* MSI */
5453 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc1,
5454 .config = ALC883_TARGA_DIG }, /* MSI */
5455 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc3,
5456 .config = ALC883_TARGA_DIG }, /* MSI */
5457 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
5458 .config = ALC883_TARGA_DIG }, /* MSI */
5459 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4319,
5460 .config = ALC883_TARGA_DIG }, /* MSI */
5461 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3ef9,
5462 .config = ALC883_TARGA_DIG }, /* MSI */
5463 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4324,
5464 .config = ALC883_TARGA_DIG }, /* MSI */
5465 { .modelname = "targa-2ch-dig", .config = ALC883_TARGA_2ch_DIG },
5466 { .pci_subvendor = 0x1462, .pci_subdevice = 0x0579,
5467 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5468 { .pci_subvendor = 0x1462, .pci_subdevice = 0xa422,
5469 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5470 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3b7f,
5471 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005472 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02005473 { .modelname = "acer", .config = ALC883_ACER },
5474 { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
5475 .config = ALC883_ACER },
Tobin Davis7a997952006-09-26 15:30:10 +02005476 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
5477 .config = ALC883_ACER },
5478 { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
5479 .config = ALC883_ACER },
Tobin Davisc07584c2006-10-13 12:32:16 +02005480 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
Takashi Iwai35f60832006-10-13 12:46:10 +02005481 .modelname = "medion", .config = ALC883_MEDION },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005482 { .modelname = "laptop-eapd", .config = ALC883_LAPTOP_EAPD },
Tobin Davis761ccb22006-11-20 12:02:56 +01005483 { .pci_subvendor = 0x1071, .pci_subdevice = 0x8258,
5484 .config = ALC883_LAPTOP_EAPD }, /* Evesham Voyager C530RD */
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005485 { .pci_subvendor = 0x1558, .pci_subdevice = 0,
5486 .config = ALC883_LAPTOP_EAPD }, /* Clevo */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005487 { .modelname = "auto", .config = ALC883_AUTO },
5488 {}
5489};
5490
5491static struct alc_config_preset alc883_presets[] = {
5492 [ALC883_3ST_2ch_DIG] = {
5493 .mixers = { alc883_3ST_2ch_mixer },
5494 .init_verbs = { alc883_init_verbs },
5495 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5496 .dac_nids = alc883_dac_nids,
5497 .dig_out_nid = ALC883_DIGOUT_NID,
5498 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5499 .adc_nids = alc883_adc_nids,
5500 .dig_in_nid = ALC883_DIGIN_NID,
5501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5502 .channel_mode = alc883_3ST_2ch_modes,
5503 .input_mux = &alc883_capture_source,
5504 },
5505 [ALC883_3ST_6ch_DIG] = {
5506 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5507 .init_verbs = { alc883_init_verbs },
5508 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5509 .dac_nids = alc883_dac_nids,
5510 .dig_out_nid = ALC883_DIGOUT_NID,
5511 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5512 .adc_nids = alc883_adc_nids,
5513 .dig_in_nid = ALC883_DIGIN_NID,
5514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5515 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005516 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005517 .input_mux = &alc883_capture_source,
5518 },
5519 [ALC883_3ST_6ch] = {
5520 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5521 .init_verbs = { alc883_init_verbs },
5522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5523 .dac_nids = alc883_dac_nids,
5524 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5525 .adc_nids = alc883_adc_nids,
5526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5527 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005528 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005529 .input_mux = &alc883_capture_source,
5530 },
5531 [ALC883_6ST_DIG] = {
5532 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5533 .init_verbs = { alc883_init_verbs },
5534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5535 .dac_nids = alc883_dac_nids,
5536 .dig_out_nid = ALC883_DIGOUT_NID,
5537 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5538 .adc_nids = alc883_adc_nids,
5539 .dig_in_nid = ALC883_DIGIN_NID,
5540 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5541 .channel_mode = alc883_sixstack_modes,
5542 .input_mux = &alc883_capture_source,
5543 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005544 [ALC883_TARGA_DIG] = {
5545 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5546 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5548 .dac_nids = alc883_dac_nids,
5549 .dig_out_nid = ALC883_DIGOUT_NID,
5550 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5551 .adc_nids = alc883_adc_nids,
5552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5553 .channel_mode = alc883_3ST_6ch_modes,
5554 .need_dac_fix = 1,
5555 .input_mux = &alc883_capture_source,
5556 .unsol_event = alc883_tagra_unsol_event,
5557 .init_hook = alc883_tagra_automute,
5558 },
5559 [ALC883_TARGA_2ch_DIG] = {
5560 .mixers = { alc883_tagra_2ch_mixer},
5561 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5563 .dac_nids = alc883_dac_nids,
5564 .dig_out_nid = ALC883_DIGOUT_NID,
5565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5566 .adc_nids = alc883_adc_nids,
5567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5568 .channel_mode = alc883_3ST_2ch_modes,
5569 .input_mux = &alc883_capture_source,
5570 .unsol_event = alc883_tagra_unsol_event,
5571 .init_hook = alc883_tagra_automute,
5572 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005573 [ALC888_DEMO_BOARD] = {
5574 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5575 .init_verbs = { alc883_init_verbs },
5576 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5577 .dac_nids = alc883_dac_nids,
5578 .dig_out_nid = ALC883_DIGOUT_NID,
5579 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5580 .adc_nids = alc883_adc_nids,
5581 .dig_in_nid = ALC883_DIGIN_NID,
5582 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5583 .channel_mode = alc883_sixstack_modes,
5584 .input_mux = &alc883_capture_source,
5585 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02005586 [ALC883_ACER] = {
5587 .mixers = { alc883_base_mixer,
5588 alc883_chmode_mixer },
5589 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5590 * and the headphone jack. Turn this on and rely on the
5591 * standard mute methods whenever the user wants to turn
5592 * these outputs off.
5593 */
5594 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5596 .dac_nids = alc883_dac_nids,
5597 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5598 .adc_nids = alc883_adc_nids,
5599 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5600 .channel_mode = alc883_3ST_2ch_modes,
5601 .input_mux = &alc883_capture_source,
5602 },
Tobin Davisc07584c2006-10-13 12:32:16 +02005603 [ALC883_MEDION] = {
5604 .mixers = { alc883_fivestack_mixer,
5605 alc883_chmode_mixer },
5606 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005607 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02005608 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5609 .dac_nids = alc883_dac_nids,
5610 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5611 .adc_nids = alc883_adc_nids,
5612 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5613 .channel_mode = alc883_sixstack_modes,
5614 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005615 },
5616 [ALC883_LAPTOP_EAPD] = {
5617 .mixers = { alc883_base_mixer,
5618 alc883_chmode_mixer },
5619 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
5620 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5621 .dac_nids = alc883_dac_nids,
5622 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5623 .adc_nids = alc883_adc_nids,
5624 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5625 .channel_mode = alc883_3ST_2ch_modes,
5626 .input_mux = &alc883_capture_source,
5627 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005628};
5629
5630
5631/*
5632 * BIOS auto configuration
5633 */
5634static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5635 hda_nid_t nid, int pin_type,
5636 int dac_idx)
5637{
5638 /* set as output */
5639 struct alc_spec *spec = codec->spec;
5640 int idx;
5641
5642 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5643 idx = 4;
5644 else
5645 idx = spec->multiout.dac_nids[dac_idx] - 2;
5646
5647 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5648 pin_type);
5649 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5650 AMP_OUT_UNMUTE);
5651 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5652
5653}
5654
5655static void alc883_auto_init_multi_out(struct hda_codec *codec)
5656{
5657 struct alc_spec *spec = codec->spec;
5658 int i;
5659
5660 for (i = 0; i <= HDA_SIDE; i++) {
5661 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5662 if (nid)
5663 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5664 }
5665}
5666
5667static void alc883_auto_init_hp_out(struct hda_codec *codec)
5668{
5669 struct alc_spec *spec = codec->spec;
5670 hda_nid_t pin;
5671
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005672 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005673 if (pin) /* connect to front */
5674 /* use dac 0 */
5675 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5676}
5677
5678#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5679#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5680
5681static void alc883_auto_init_analog_input(struct hda_codec *codec)
5682{
5683 struct alc_spec *spec = codec->spec;
5684 int i;
5685
5686 for (i = 0; i < AUTO_PIN_LAST; i++) {
5687 hda_nid_t nid = spec->autocfg.input_pins[i];
5688 if (alc883_is_input_pin(nid)) {
5689 snd_hda_codec_write(codec, nid, 0,
5690 AC_VERB_SET_PIN_WIDGET_CONTROL,
5691 (i <= AUTO_PIN_FRONT_MIC ?
5692 PIN_VREF80 : PIN_IN));
5693 if (nid != ALC883_PIN_CD_NID)
5694 snd_hda_codec_write(codec, nid, 0,
5695 AC_VERB_SET_AMP_GAIN_MUTE,
5696 AMP_OUT_MUTE);
5697 }
5698 }
5699}
5700
5701/* almost identical with ALC880 parser... */
5702static int alc883_parse_auto_config(struct hda_codec *codec)
5703{
5704 struct alc_spec *spec = codec->spec;
5705 int err = alc880_parse_auto_config(codec);
5706
5707 if (err < 0)
5708 return err;
5709 else if (err > 0)
5710 /* hack - override the init verbs */
5711 spec->init_verbs[0] = alc883_auto_init_verbs;
5712 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5713 spec->num_mixers++;
5714 return err;
5715}
5716
5717/* additional initialization for auto-configuration model */
5718static void alc883_auto_init(struct hda_codec *codec)
5719{
5720 alc883_auto_init_multi_out(codec);
5721 alc883_auto_init_hp_out(codec);
5722 alc883_auto_init_analog_input(codec);
5723}
5724
5725static int patch_alc883(struct hda_codec *codec)
5726{
5727 struct alc_spec *spec;
5728 int err, board_config;
5729
5730 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5731 if (spec == NULL)
5732 return -ENOMEM;
5733
5734 codec->spec = spec;
5735
5736 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5737 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5738 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5739 "trying auto-probe from BIOS...\n");
5740 board_config = ALC883_AUTO;
5741 }
5742
5743 if (board_config == ALC883_AUTO) {
5744 /* automatic parse from the BIOS config */
5745 err = alc883_parse_auto_config(codec);
5746 if (err < 0) {
5747 alc_free(codec);
5748 return err;
5749 } else if (! err) {
5750 printk(KERN_INFO
5751 "hda_codec: Cannot set up configuration "
5752 "from BIOS. Using base mode...\n");
5753 board_config = ALC883_3ST_2ch_DIG;
5754 }
5755 }
5756
5757 if (board_config != ALC883_AUTO)
5758 setup_preset(spec, &alc883_presets[board_config]);
5759
5760 spec->stream_name_analog = "ALC883 Analog";
5761 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5762 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5763
5764 spec->stream_name_digital = "ALC883 Digital";
5765 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5766 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5767
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005768 if (! spec->adc_nids && spec->input_mux) {
5769 spec->adc_nids = alc883_adc_nids;
5770 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5771 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005772
5773 codec->patch_ops = alc_patch_ops;
5774 if (board_config == ALC883_AUTO)
5775 spec->init_hook = alc883_auto_init;
5776
5777 return 0;
5778}
5779
5780/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005781 * ALC262 support
5782 */
5783
5784#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5785#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5786
5787#define alc262_dac_nids alc260_dac_nids
5788#define alc262_adc_nids alc882_adc_nids
5789#define alc262_adc_nids_alt alc882_adc_nids_alt
5790
5791#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005792#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005793
5794static struct snd_kcontrol_new alc262_base_mixer[] = {
5795 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5796 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5801 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5802 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5803 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5804 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5805 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5806 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5809 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5810 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005812};
5813
Kailang Yangccc656c2006-10-17 12:32:26 +02005814static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
5815 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5816 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5825 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5826 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5827 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
5828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5829 { } /* end */
5830};
5831
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005832static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5833 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5834 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5836 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5837 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5838
5839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5843 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5844 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5847 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5848 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5849 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5850 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5851 { } /* end */
5852};
5853
Kailang Yangdf694da2005-12-05 19:42:22 +01005854#define alc262_capture_mixer alc882_capture_mixer
5855#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5856
5857/*
5858 * generic initialization of ADC, input mixers and output mixers
5859 */
5860static struct hda_verb alc262_init_verbs[] = {
5861 /*
5862 * Unmute ADC0-2 and set the default input to mic-in
5863 */
5864 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5866 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5868 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5870
5871 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5872 * mixer widget
5873 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5874 * mic (mic 2)
5875 */
5876 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5882
5883 /*
5884 * Set up output mixers (0x0c - 0x0e)
5885 */
5886 /* set vol=0 to output mixers */
5887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5890 /* set up input amps for analog loopback */
5891 /* Amp Indices: DAC = 0, mixer = 1 */
5892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5898
5899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5902 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5903 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5905
5906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5908 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5910 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5911
5912 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5914
5915 /* FIXME: use matrix-type input source selection */
5916 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5917 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5922 /* Input mixer2 */
5923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5927 /* Input mixer3 */
5928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5932
5933 { }
5934};
5935
Kailang Yangccc656c2006-10-17 12:32:26 +02005936static struct hda_verb alc262_hippo_unsol_verbs[] = {
5937 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5939 {}
5940};
5941
5942static struct hda_verb alc262_hippo1_unsol_verbs[] = {
5943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5944 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5946
5947 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5948 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5949 {}
5950};
5951
5952/* mute/unmute internal speaker according to the hp jack and mute state */
5953static void alc262_hippo_automute(struct hda_codec *codec, int force)
5954{
5955 struct alc_spec *spec = codec->spec;
5956 unsigned int mute;
5957
5958 if (force || ! spec->sense_updated) {
5959 unsigned int present;
5960 /* need to execute and sync at first */
5961 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
5962 present = snd_hda_codec_read(codec, 0x15, 0,
5963 AC_VERB_GET_PIN_SENSE, 0);
5964 spec->jack_present = (present & 0x80000000) != 0;
5965 spec->sense_updated = 1;
5966 }
5967 if (spec->jack_present) {
5968 /* mute internal speaker */
5969 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5970 0x80, 0x80);
5971 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5972 0x80, 0x80);
5973 } else {
5974 /* unmute internal speaker if necessary */
5975 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
5976 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5977 0x80, mute & 0x80);
5978 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
5979 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5980 0x80, mute & 0x80);
5981 }
5982}
5983
5984/* unsolicited event for HP jack sensing */
5985static void alc262_hippo_unsol_event(struct hda_codec *codec,
5986 unsigned int res)
5987{
5988 if ((res >> 26) != ALC880_HP_EVENT)
5989 return;
5990 alc262_hippo_automute(codec, 1);
5991}
5992
5993static void alc262_hippo1_automute(struct hda_codec *codec, int force)
5994{
5995 struct alc_spec *spec = codec->spec;
5996 unsigned int mute;
5997
5998 if (force || ! spec->sense_updated) {
5999 unsigned int present;
6000 /* need to execute and sync at first */
6001 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
6002 present = snd_hda_codec_read(codec, 0x1b, 0,
6003 AC_VERB_GET_PIN_SENSE, 0);
6004 spec->jack_present = (present & 0x80000000) != 0;
6005 spec->sense_updated = 1;
6006 }
6007 if (spec->jack_present) {
6008 /* mute internal speaker */
6009 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6010 0x80, 0x80);
6011 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6012 0x80, 0x80);
6013 } else {
6014 /* unmute internal speaker if necessary */
6015 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
6016 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6017 0x80, mute & 0x80);
6018 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
6019 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6020 0x80, mute & 0x80);
6021 }
6022}
6023
6024/* unsolicited event for HP jack sensing */
6025static void alc262_hippo1_unsol_event(struct hda_codec *codec,
6026 unsigned int res)
6027{
6028 if ((res >> 26) != ALC880_HP_EVENT)
6029 return;
6030 alc262_hippo1_automute(codec, 1);
6031}
6032
Takashi Iwai834be882006-03-01 14:16:17 +01006033/*
6034 * fujitsu model
6035 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
6036 */
6037
6038#define ALC_HP_EVENT 0x37
6039
6040static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
6041 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
6042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6043 {}
6044};
6045
6046static struct hda_input_mux alc262_fujitsu_capture_source = {
6047 .num_items = 2,
6048 .items = {
6049 { "Mic", 0x0 },
6050 { "CD", 0x4 },
6051 },
6052};
6053
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006054static struct hda_input_mux alc262_HP_capture_source = {
6055 .num_items = 5,
6056 .items = {
6057 { "Mic", 0x0 },
6058 { "Front Mic", 0x3 },
6059 { "Line", 0x2 },
6060 { "CD", 0x4 },
6061 { "AUX IN", 0x6 },
6062 },
6063};
6064
Takashi Iwai834be882006-03-01 14:16:17 +01006065/* mute/unmute internal speaker according to the hp jack and mute state */
6066static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6067{
6068 struct alc_spec *spec = codec->spec;
6069 unsigned int mute;
6070
6071 if (force || ! spec->sense_updated) {
6072 unsigned int present;
6073 /* need to execute and sync at first */
6074 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6075 present = snd_hda_codec_read(codec, 0x14, 0,
6076 AC_VERB_GET_PIN_SENSE, 0);
6077 spec->jack_present = (present & 0x80000000) != 0;
6078 spec->sense_updated = 1;
6079 }
6080 if (spec->jack_present) {
6081 /* mute internal speaker */
6082 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6083 0x80, 0x80);
6084 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6085 0x80, 0x80);
6086 } else {
6087 /* unmute internal speaker if necessary */
6088 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6089 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6090 0x80, mute & 0x80);
6091 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6092 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6093 0x80, mute & 0x80);
6094 }
6095}
6096
6097/* unsolicited event for HP jack sensing */
6098static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6099 unsigned int res)
6100{
6101 if ((res >> 26) != ALC_HP_EVENT)
6102 return;
6103 alc262_fujitsu_automute(codec, 1);
6104}
6105
6106/* bind volumes of both NID 0x0c and 0x0d */
6107static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6108 struct snd_ctl_elem_value *ucontrol)
6109{
6110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6111 long *valp = ucontrol->value.integer.value;
6112 int change;
6113
6114 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6115 0x7f, valp[0] & 0x7f);
6116 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6117 0x7f, valp[1] & 0x7f);
6118 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6119 0x7f, valp[0] & 0x7f);
6120 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6121 0x7f, valp[1] & 0x7f);
6122 return change;
6123}
6124
6125/* bind hp and internal speaker mute (with plug check) */
6126static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6127 struct snd_ctl_elem_value *ucontrol)
6128{
6129 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6130 long *valp = ucontrol->value.integer.value;
6131 int change;
6132
6133 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6134 0x80, valp[0] ? 0 : 0x80);
6135 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6136 0x80, valp[1] ? 0 : 0x80);
6137 if (change || codec->in_resume)
6138 alc262_fujitsu_automute(codec, codec->in_resume);
6139 return change;
6140}
6141
6142static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6143 {
6144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6145 .name = "Master Playback Volume",
6146 .info = snd_hda_mixer_amp_volume_info,
6147 .get = snd_hda_mixer_amp_volume_get,
6148 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02006149 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01006150 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6151 },
6152 {
6153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6154 .name = "Master Playback Switch",
6155 .info = snd_hda_mixer_amp_switch_info,
6156 .get = snd_hda_mixer_amp_switch_get,
6157 .put = alc262_fujitsu_master_sw_put,
6158 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6159 },
6160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6165 { } /* end */
6166};
6167
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006168/* additional init verbs for Benq laptops */
6169static struct hda_verb alc262_EAPD_verbs[] = {
6170 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6171 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6172 {}
6173};
6174
Kailang Yangdf694da2005-12-05 19:42:22 +01006175/* add playback controls from the parsed DAC table */
6176static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6177{
6178 hda_nid_t nid;
6179 int err;
6180
6181 spec->multiout.num_dacs = 1; /* only use one dac */
6182 spec->multiout.dac_nids = spec->private_dac_nids;
6183 spec->multiout.dac_nids[0] = 2;
6184
6185 nid = cfg->line_out_pins[0];
6186 if (nid) {
6187 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6188 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6189 return err;
6190 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6191 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6192 return err;
6193 }
6194
Takashi Iwai82bc9552006-03-21 11:24:42 +01006195 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006196 if (nid) {
6197 if (nid == 0x16) {
6198 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6199 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6200 return err;
6201 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6202 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6203 return err;
6204 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006205 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6206 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6207 return err;
6208 }
6209 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006210 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 if (nid) {
6212 /* spec->multiout.hp_nid = 2; */
6213 if (nid == 0x16) {
6214 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6215 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6216 return err;
6217 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6218 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6219 return err;
6220 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6222 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6223 return err;
6224 }
6225 }
6226 return 0;
6227}
6228
6229/* identical with ALC880 */
6230#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6231
6232/*
6233 * generic initialization of ADC, input mixers and output mixers
6234 */
6235static struct hda_verb alc262_volume_init_verbs[] = {
6236 /*
6237 * Unmute ADC0-2 and set the default input to mic-in
6238 */
6239 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6241 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6243 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6245
6246 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6247 * mixer widget
6248 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6249 * mic (mic 2)
6250 */
6251 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6257
6258 /*
6259 * Set up output mixers (0x0c - 0x0f)
6260 */
6261 /* set vol=0 to output mixers */
6262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6265
6266 /* set up input amps for analog loopback */
6267 /* Amp Indices: DAC = 0, mixer = 1 */
6268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6271 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6272 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6274
6275 /* FIXME: use matrix-type input source selection */
6276 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6277 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6282 /* Input mixer2 */
6283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6287 /* Input mixer3 */
6288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6292
6293 { }
6294};
6295
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006296static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6297 /*
6298 * Unmute ADC0-2 and set the default input to mic-in
6299 */
6300 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6302 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6306
6307 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6308 * mixer widget
6309 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6310 * mic (mic 2)
6311 */
6312 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6320
6321 /*
6322 * Set up output mixers (0x0c - 0x0e)
6323 */
6324 /* set vol=0 to output mixers */
6325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6328
6329 /* set up input amps for analog loopback */
6330 /* Amp Indices: DAC = 0, mixer = 1 */
6331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6337
6338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6341
6342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6344
6345 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6347
6348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6351 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6352 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6353
6354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6358 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6359 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6360
6361
6362 /* FIXME: use matrix-type input source selection */
6363 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6364 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6369 /* Input mixer2 */
6370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6374 /* Input mixer3 */
6375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6379
6380 { }
6381};
6382
Kailang Yangdf694da2005-12-05 19:42:22 +01006383/* pcm configuration: identiacal with ALC880 */
6384#define alc262_pcm_analog_playback alc880_pcm_analog_playback
6385#define alc262_pcm_analog_capture alc880_pcm_analog_capture
6386#define alc262_pcm_digital_playback alc880_pcm_digital_playback
6387#define alc262_pcm_digital_capture alc880_pcm_digital_capture
6388
6389/*
6390 * BIOS auto configuration
6391 */
6392static int alc262_parse_auto_config(struct hda_codec *codec)
6393{
6394 struct alc_spec *spec = codec->spec;
6395 int err;
6396 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6397
6398 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6399 alc262_ignore)) < 0)
6400 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006401 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006402 return 0; /* can't find valid BIOS pin config */
6403 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6404 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6405 return err;
6406
6407 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6408
6409 if (spec->autocfg.dig_out_pin)
6410 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6411 if (spec->autocfg.dig_in_pin)
6412 spec->dig_in_nid = ALC262_DIGIN_NID;
6413
6414 if (spec->kctl_alloc)
6415 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6416
6417 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006418 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006419 spec->input_mux = &spec->private_imux;
6420
6421 return 1;
6422}
6423
6424#define alc262_auto_init_multi_out alc882_auto_init_multi_out
6425#define alc262_auto_init_hp_out alc882_auto_init_hp_out
6426#define alc262_auto_init_analog_input alc882_auto_init_analog_input
6427
6428
6429/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006430static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006431{
Kailang Yangdf694da2005-12-05 19:42:22 +01006432 alc262_auto_init_multi_out(codec);
6433 alc262_auto_init_hp_out(codec);
6434 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006435}
6436
6437/*
6438 * configuration and preset
6439 */
6440static struct hda_board_config alc262_cfg_tbl[] = {
6441 { .modelname = "basic", .config = ALC262_BASIC },
Kailang Yangccc656c2006-10-17 12:32:26 +02006442 { .modelname = "hippo",
6443 .pci_subvendor =0x1002, .pci_subdevice = 0x437b,
6444 .config = ALC262_HIPPO},
Takashi Iwaid1f67542006-11-14 12:30:52 +01006445 { .modelname = "hippo",
6446 .pci_subvendor = 0x104d, .pci_subdevice = 0x8203,
6447 .config = ALC262_HIPPO }, /* Sony UX-90s */
Kailang Yangccc656c2006-10-17 12:32:26 +02006448 { .modelname = "hippo_1",
6449 .pci_subvendor =0x17ff, .pci_subdevice = 0x058f,
6450 .config = ALC262_HIPPO_1},
Takashi Iwai834be882006-03-01 14:16:17 +01006451 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006452 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
6453 .config = ALC262_FUJITSU },
Takashi Iwai6d177ba72006-07-25 14:51:15 +02006454 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
John W. Linville282e0c82006-11-06 12:01:53 +01006455 { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006456 .config = ALC262_HP_BPC }, /* xw4400 */
Takashi Iwaiefeccac2006-10-24 14:57:52 +02006457 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
6458 .config = ALC262_HP_BPC }, /* q965 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006459 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
6460 .config = ALC262_HP_BPC }, /* xw6400 */
6461 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
6462 .config = ALC262_HP_BPC }, /* xw8400 */
6463 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
6464 .config = ALC262_HP_BPC }, /* xw9400 */
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006465 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
6466 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
6467 .config = ALC262_BENQ_ED8 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006468 { .modelname = "auto", .config = ALC262_AUTO },
6469 {}
6470};
6471
6472static struct alc_config_preset alc262_presets[] = {
6473 [ALC262_BASIC] = {
6474 .mixers = { alc262_base_mixer },
6475 .init_verbs = { alc262_init_verbs },
6476 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6477 .dac_nids = alc262_dac_nids,
6478 .hp_nid = 0x03,
6479 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6480 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006481 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01006482 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006483 [ALC262_HIPPO] = {
6484 .mixers = { alc262_base_mixer },
6485 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
6486 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6487 .dac_nids = alc262_dac_nids,
6488 .hp_nid = 0x03,
6489 .dig_out_nid = ALC262_DIGOUT_NID,
6490 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6491 .channel_mode = alc262_modes,
6492 .input_mux = &alc262_capture_source,
6493 .unsol_event = alc262_hippo_unsol_event,
6494 },
6495 [ALC262_HIPPO_1] = {
6496 .mixers = { alc262_hippo1_mixer },
6497 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
6498 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6499 .dac_nids = alc262_dac_nids,
6500 .hp_nid = 0x02,
6501 .dig_out_nid = ALC262_DIGOUT_NID,
6502 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6503 .channel_mode = alc262_modes,
6504 .input_mux = &alc262_capture_source,
6505 .unsol_event = alc262_hippo1_unsol_event,
6506 },
Takashi Iwai834be882006-03-01 14:16:17 +01006507 [ALC262_FUJITSU] = {
6508 .mixers = { alc262_fujitsu_mixer },
6509 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
6510 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6511 .dac_nids = alc262_dac_nids,
6512 .hp_nid = 0x03,
6513 .dig_out_nid = ALC262_DIGOUT_NID,
6514 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6515 .channel_mode = alc262_modes,
6516 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006517 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01006518 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006519 [ALC262_HP_BPC] = {
6520 .mixers = { alc262_HP_BPC_mixer },
6521 .init_verbs = { alc262_HP_BPC_init_verbs },
6522 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6523 .dac_nids = alc262_dac_nids,
6524 .hp_nid = 0x03,
6525 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6526 .channel_mode = alc262_modes,
6527 .input_mux = &alc262_HP_capture_source,
6528 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006529 [ALC262_BENQ_ED8] = {
6530 .mixers = { alc262_base_mixer },
6531 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
6532 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6533 .dac_nids = alc262_dac_nids,
6534 .hp_nid = 0x03,
6535 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6536 .channel_mode = alc262_modes,
6537 .input_mux = &alc262_capture_source,
6538 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006539};
6540
6541static int patch_alc262(struct hda_codec *codec)
6542{
6543 struct alc_spec *spec;
6544 int board_config;
6545 int err;
6546
6547 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6548 if (spec == NULL)
6549 return -ENOMEM;
6550
6551 codec->spec = spec;
6552#if 0
6553 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6554 {
6555 int tmp;
6556 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6557 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6558 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6559 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6560 }
6561#endif
6562
6563 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006564
Kailang Yangdf694da2005-12-05 19:42:22 +01006565 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006566 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6567 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006568 board_config = ALC262_AUTO;
6569 }
6570
6571 if (board_config == ALC262_AUTO) {
6572 /* automatic parse from the BIOS config */
6573 err = alc262_parse_auto_config(codec);
6574 if (err < 0) {
6575 alc_free(codec);
6576 return err;
6577 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006578 printk(KERN_INFO
6579 "hda_codec: Cannot set up configuration "
6580 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006581 board_config = ALC262_BASIC;
6582 }
6583 }
6584
6585 if (board_config != ALC262_AUTO)
6586 setup_preset(spec, &alc262_presets[board_config]);
6587
6588 spec->stream_name_analog = "ALC262 Analog";
6589 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6590 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6591
6592 spec->stream_name_digital = "ALC262 Digital";
6593 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6594 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6595
6596 if (! spec->adc_nids && spec->input_mux) {
6597 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006598 unsigned int wcap = get_wcaps(codec, 0x07);
6599
Kailang Yangdf694da2005-12-05 19:42:22 +01006600 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6601 if (wcap != AC_WID_AUD_IN) {
6602 spec->adc_nids = alc262_adc_nids_alt;
6603 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6604 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6605 spec->num_mixers++;
6606 } else {
6607 spec->adc_nids = alc262_adc_nids;
6608 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6609 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6610 spec->num_mixers++;
6611 }
6612 }
6613
6614 codec->patch_ops = alc_patch_ops;
6615 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006616 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01006617
Kailang Yangdf694da2005-12-05 19:42:22 +01006618 return 0;
6619}
6620
Kailang Yangdf694da2005-12-05 19:42:22 +01006621/*
6622 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6623 */
6624
6625/*
6626 * set the path ways for 2 channel output
6627 * need to set the codec line out and mic 1 pin widgets to inputs
6628 */
6629static struct hda_verb alc861_threestack_ch2_init[] = {
6630 /* set pin widget 1Ah (line in) for input */
6631 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6632 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6633 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6634
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6636#if 0
6637 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6638 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6639#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 { } /* end */
6641};
6642/*
6643 * 6ch mode
6644 * need to set the codec line out and mic 1 pin widgets to outputs
6645 */
6646static struct hda_verb alc861_threestack_ch6_init[] = {
6647 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6648 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6649 /* set pin widget 18h (mic1) for output (CLFE)*/
6650 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6651
6652 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006653 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006654
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006655 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6656#if 0
6657 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6658 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6659#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006660 { } /* end */
6661};
6662
6663static struct hda_channel_mode alc861_threestack_modes[2] = {
6664 { 2, alc861_threestack_ch2_init },
6665 { 6, alc861_threestack_ch6_init },
6666};
Takashi Iwai22309c32006-08-09 16:57:28 +02006667/* Set mic1 as input and unmute the mixer */
6668static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6670 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6671 { } /* end */
6672};
6673/* Set mic1 as output and mute mixer */
6674static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6675 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6676 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6677 { } /* end */
6678};
6679
6680static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6681 { 2, alc861_uniwill_m31_ch2_init },
6682 { 4, alc861_uniwill_m31_ch4_init },
6683};
Kailang Yangdf694da2005-12-05 19:42:22 +01006684
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006685/* Set mic1 and line-in as input and unmute the mixer */
6686static struct hda_verb alc861_asus_ch2_init[] = {
6687 /* set pin widget 1Ah (line in) for input */
6688 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6689 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6690 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6691
6692 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6693#if 0
6694 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6695 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6696#endif
6697 { } /* end */
6698};
6699/* Set mic1 nad line-in as output and mute mixer */
6700static struct hda_verb alc861_asus_ch6_init[] = {
6701 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6702 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6703 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6704 /* set pin widget 18h (mic1) for output (CLFE)*/
6705 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6706 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6707 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6708 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6709
6710 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6711#if 0
6712 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6713 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6714#endif
6715 { } /* end */
6716};
6717
6718static struct hda_channel_mode alc861_asus_modes[2] = {
6719 { 2, alc861_asus_ch2_init },
6720 { 6, alc861_asus_ch6_init },
6721};
6722
Kailang Yangdf694da2005-12-05 19:42:22 +01006723/* patch-ALC861 */
6724
6725static struct snd_kcontrol_new alc861_base_mixer[] = {
6726 /* output mixer control */
6727 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6728 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6729 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6730 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6731 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6732
6733 /*Input mixer control */
6734 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6735 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6736 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6737 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6738 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6739 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6741 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6742 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6744
6745 /* Capture mixer control */
6746 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6747 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6748 {
6749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6750 .name = "Capture Source",
6751 .count = 1,
6752 .info = alc_mux_enum_info,
6753 .get = alc_mux_enum_get,
6754 .put = alc_mux_enum_put,
6755 },
6756 { } /* end */
6757};
6758
6759static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6760 /* output mixer control */
6761 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6762 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6763 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6764 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6765 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6766
6767 /* Input mixer control */
6768 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6769 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6770 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6771 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6773 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6775 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6778
6779 /* Capture mixer control */
6780 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6781 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6782 {
6783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6784 .name = "Capture Source",
6785 .count = 1,
6786 .info = alc_mux_enum_info,
6787 .get = alc_mux_enum_get,
6788 .put = alc_mux_enum_put,
6789 },
6790 {
6791 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6792 .name = "Channel Mode",
6793 .info = alc_ch_mode_info,
6794 .get = alc_ch_mode_get,
6795 .put = alc_ch_mode_put,
6796 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6797 },
6798 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02006799};
6800
6801static snd_kcontrol_new_t alc861_toshiba_mixer[] = {
6802 /* output mixer control */
6803 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6805 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6806
6807 /*Capture mixer control */
6808 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6809 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6810 {
6811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6812 .name = "Capture Source",
6813 .count = 1,
6814 .info = alc_mux_enum_info,
6815 .get = alc_mux_enum_get,
6816 .put = alc_mux_enum_put,
6817 },
6818
6819 { } /* end */
6820};
6821
Takashi Iwai22309c32006-08-09 16:57:28 +02006822static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6823 /* output mixer control */
6824 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6825 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6826 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6827 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6828 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6829
6830 /* Input mixer control */
6831 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6832 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6833 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6834 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6835 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6836 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6838 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6841
6842 /* Capture mixer control */
6843 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6844 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6845 {
6846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6847 .name = "Capture Source",
6848 .count = 1,
6849 .info = alc_mux_enum_info,
6850 .get = alc_mux_enum_get,
6851 .put = alc_mux_enum_put,
6852 },
6853 {
6854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6855 .name = "Channel Mode",
6856 .info = alc_ch_mode_info,
6857 .get = alc_ch_mode_get,
6858 .put = alc_ch_mode_put,
6859 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6860 },
6861 { } /* end */
6862};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006863
6864static struct snd_kcontrol_new alc861_asus_mixer[] = {
6865 /* output mixer control */
6866 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6867 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6868 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6869 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6870 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6871
6872 /* Input mixer control */
6873 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6874 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6875 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6876 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6878 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6880 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
6883
6884 /* Capture mixer control */
6885 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6886 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6887 {
6888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6889 .name = "Capture Source",
6890 .count = 1,
6891 .info = alc_mux_enum_info,
6892 .get = alc_mux_enum_get,
6893 .put = alc_mux_enum_put,
6894 },
6895 {
6896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6897 .name = "Channel Mode",
6898 .info = alc_ch_mode_info,
6899 .get = alc_ch_mode_get,
6900 .put = alc_ch_mode_put,
6901 .private_value = ARRAY_SIZE(alc861_asus_modes),
6902 },
6903 { }
6904};
6905
Kailang Yangdf694da2005-12-05 19:42:22 +01006906
6907/*
6908 * generic initialization of ADC, input mixers and output mixers
6909 */
6910static struct hda_verb alc861_base_init_verbs[] = {
6911 /*
6912 * Unmute ADC0 and set the default input to mic-in
6913 */
6914 /* port-A for surround (rear panel) */
6915 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6916 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6917 /* port-B for mic-in (rear panel) with vref */
6918 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6919 /* port-C for line-in (rear panel) */
6920 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6921 /* port-D for Front */
6922 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6923 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 /* port-E for HP out (front panel) */
6925 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6926 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01006927 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006928 /* port-F for mic-in (front panel) with vref */
6929 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6930 /* port-G for CLFE (rear panel) */
6931 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6932 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6933 /* port-H for side (rear panel) */
6934 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6935 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6936 /* CD-in */
6937 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6938 /* route front mic to ADC1*/
6939 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6940 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6941
6942 /* Unmute DAC0~3 & spdif out*/
6943 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6944 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6945 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6946 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6948
6949 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6950 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6951 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6952 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6953 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6954
6955 /* Unmute Stereo Mixer 15 */
6956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6960
6961 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6962 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6963 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6964 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6965 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6967 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6968 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6969 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6970 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6971
6972 { }
6973};
6974
6975static struct hda_verb alc861_threestack_init_verbs[] = {
6976 /*
6977 * Unmute ADC0 and set the default input to mic-in
6978 */
6979 /* port-A for surround (rear panel) */
6980 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6981 /* port-B for mic-in (rear panel) with vref */
6982 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6983 /* port-C for line-in (rear panel) */
6984 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6985 /* port-D for Front */
6986 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6987 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6988 /* port-E for HP out (front panel) */
6989 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6990 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01006991 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006992 /* port-F for mic-in (front panel) with vref */
6993 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6994 /* port-G for CLFE (rear panel) */
6995 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6996 /* port-H for side (rear panel) */
6997 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6998 /* CD-in */
6999 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7000 /* route front mic to ADC1*/
7001 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7002 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7003 /* Unmute DAC0~3 & spdif out*/
7004 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7005 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7006 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7007 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7008 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7009
7010 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7011 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7012 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7013 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7014 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7015
7016 /* Unmute Stereo Mixer 15 */
7017 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7018 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7021
7022 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7025 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7029 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7032 { }
7033};
Takashi Iwai22309c32006-08-09 16:57:28 +02007034
7035static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7036 /*
7037 * Unmute ADC0 and set the default input to mic-in
7038 */
7039 /* port-A for surround (rear panel) */
7040 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7041 /* port-B for mic-in (rear panel) with vref */
7042 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7043 /* port-C for line-in (rear panel) */
7044 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7045 /* port-D for Front */
7046 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7047 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7048 /* port-E for HP out (front panel) */
7049 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
7050 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01007051 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02007052 /* port-F for mic-in (front panel) with vref */
7053 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7054 /* port-G for CLFE (rear panel) */
7055 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7056 /* port-H for side (rear panel) */
7057 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7058 /* CD-in */
7059 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7060 /* route front mic to ADC1*/
7061 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7063 /* Unmute DAC0~3 & spdif out*/
7064 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7065 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7066 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7067 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7069
7070 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7071 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7072 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7073 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7074 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7075
7076 /* Unmute Stereo Mixer 15 */
7077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7081
7082 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7083 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7085 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7086 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7087 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7088 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7089 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7092 { }
7093};
7094
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007095static struct hda_verb alc861_asus_init_verbs[] = {
7096 /*
7097 * Unmute ADC0 and set the default input to mic-in
7098 */
7099 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
7100 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7101 /* route front PCM to HP */
7102 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
7103 /* port-B for mic-in (rear panel) with vref */
7104 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7105 /* port-C for line-in (rear panel) */
7106 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7107 /* port-D for Front */
7108 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7109 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7110 /* port-E for HP out (front panel) */
7111 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
7112 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01007113 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007114 /* port-F for mic-in (front panel) with vref */
7115 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7116 /* port-G for CLFE (rear panel) */
7117 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7118 /* port-H for side (rear panel) */
7119 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7120 /* CD-in */
7121 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7122 /* route front mic to ADC1*/
7123 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7125 /* Unmute DAC0~3 & spdif out*/
7126 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7127 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7128 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7129 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7131 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7132 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7133 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7134 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7135 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7136
7137 /* Unmute Stereo Mixer 15 */
7138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
7142
7143 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7145 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7146 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7147 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7149 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7150 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7151 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
7152 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7153 { }
7154};
7155
7156
Kailang Yangdf694da2005-12-05 19:42:22 +01007157/*
7158 * generic initialization of ADC, input mixers and output mixers
7159 */
7160static struct hda_verb alc861_auto_init_verbs[] = {
7161 /*
7162 * Unmute ADC0 and set the default input to mic-in
7163 */
7164// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7166
7167 /* Unmute DAC0~3 & spdif out*/
7168 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7169 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7170 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7171 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7173
7174 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7175 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7176 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7177 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7178 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7179
7180 /* Unmute Stereo Mixer 15 */
7181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7185
7186 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7187 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7188 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7191 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7194
7195 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7196 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7197 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7198 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7200 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7203
7204 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7205
7206 { }
7207};
7208
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007209static struct hda_verb alc861_toshiba_init_verbs[] = {
7210 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7211
7212 { }
7213};
7214
7215/* toggle speaker-output according to the hp-jack state */
7216static void alc861_toshiba_automute(struct hda_codec *codec)
7217{
7218 unsigned int present;
7219
7220 present = snd_hda_codec_read(codec, 0x0f, 0,
7221 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7222 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7223 0x80, present ? 0x80 : 0);
7224 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7225 0x80, present ? 0x80 : 0);
7226 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7227 0x80, present ? 0 : 0x80);
7228 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7229 0x80, present ? 0 : 0x80);
7230}
7231
7232static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7233 unsigned int res)
7234{
7235 /* Looks like the unsol event is incompatible with the standard
7236 * definition. 6bit tag is placed at 26 bit!
7237 */
7238 if ((res >> 26) == ALC880_HP_EVENT)
7239 alc861_toshiba_automute(codec);
7240}
7241
Kailang Yangdf694da2005-12-05 19:42:22 +01007242/* pcm configuration: identiacal with ALC880 */
7243#define alc861_pcm_analog_playback alc880_pcm_analog_playback
7244#define alc861_pcm_analog_capture alc880_pcm_analog_capture
7245#define alc861_pcm_digital_playback alc880_pcm_digital_playback
7246#define alc861_pcm_digital_capture alc880_pcm_digital_capture
7247
7248
7249#define ALC861_DIGOUT_NID 0x07
7250
7251static struct hda_channel_mode alc861_8ch_modes[1] = {
7252 { 8, NULL }
7253};
7254
7255static hda_nid_t alc861_dac_nids[4] = {
7256 /* front, surround, clfe, side */
7257 0x03, 0x06, 0x05, 0x04
7258};
7259
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007260static hda_nid_t alc660_dac_nids[3] = {
7261 /* front, clfe, surround */
7262 0x03, 0x05, 0x06
7263};
7264
Kailang Yangdf694da2005-12-05 19:42:22 +01007265static hda_nid_t alc861_adc_nids[1] = {
7266 /* ADC0-2 */
7267 0x08,
7268};
7269
7270static struct hda_input_mux alc861_capture_source = {
7271 .num_items = 5,
7272 .items = {
7273 { "Mic", 0x0 },
7274 { "Front Mic", 0x3 },
7275 { "Line", 0x1 },
7276 { "CD", 0x4 },
7277 { "Mixer", 0x5 },
7278 },
7279};
7280
7281/* fill in the dac_nids table from the parsed pin configuration */
7282static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7283{
7284 int i;
7285 hda_nid_t nid;
7286
7287 spec->multiout.dac_nids = spec->private_dac_nids;
7288 for (i = 0; i < cfg->line_outs; i++) {
7289 nid = cfg->line_out_pins[i];
7290 if (nid) {
7291 if (i >= ARRAY_SIZE(alc861_dac_nids))
7292 continue;
7293 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7294 }
7295 }
7296 spec->multiout.num_dacs = cfg->line_outs;
7297 return 0;
7298}
7299
7300/* add playback controls from the parsed DAC table */
7301static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7302 const struct auto_pin_cfg *cfg)
7303{
7304 char name[32];
7305 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7306 hda_nid_t nid;
7307 int i, idx, err;
7308
7309 for (i = 0; i < cfg->line_outs; i++) {
7310 nid = spec->multiout.dac_nids[i];
7311 if (! nid)
7312 continue;
7313 if (nid == 0x05) {
7314 /* Center/LFE */
7315 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7316 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7317 return err;
7318 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7319 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7320 return err;
7321 } else {
7322 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7323 if (nid == alc861_dac_nids[idx])
7324 break;
7325 sprintf(name, "%s Playback Switch", chname[idx]);
7326 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7327 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7328 return err;
7329 }
7330 }
7331 return 0;
7332}
7333
7334static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7335{
7336 int err;
7337 hda_nid_t nid;
7338
7339 if (! pin)
7340 return 0;
7341
7342 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7343 nid = 0x03;
7344 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7345 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7346 return err;
7347 spec->multiout.hp_nid = nid;
7348 }
7349 return 0;
7350}
7351
7352/* create playback/capture controls for input pins */
7353static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7354{
Kailang Yangdf694da2005-12-05 19:42:22 +01007355 struct hda_input_mux *imux = &spec->private_imux;
7356 int i, err, idx, idx1;
7357
7358 for (i = 0; i < AUTO_PIN_LAST; i++) {
7359 switch(cfg->input_pins[i]) {
7360 case 0x0c:
7361 idx1 = 1;
7362 idx = 2; // Line In
7363 break;
7364 case 0x0f:
7365 idx1 = 2;
7366 idx = 2; // Line In
7367 break;
7368 case 0x0d:
7369 idx1 = 0;
7370 idx = 1; // Mic In
7371 break;
7372 case 0x10:
7373 idx1 = 3;
7374 idx = 1; // Mic In
7375 break;
7376 case 0x11:
7377 idx1 = 4;
7378 idx = 0; // CD
7379 break;
7380 default:
7381 continue;
7382 }
7383
Takashi Iwai4a471b72005-12-07 13:56:29 +01007384 err = new_analog_input(spec, cfg->input_pins[i],
7385 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01007386 if (err < 0)
7387 return err;
7388
Takashi Iwai4a471b72005-12-07 13:56:29 +01007389 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01007390 imux->items[imux->num_items].index = idx1;
7391 imux->num_items++;
7392 }
7393 return 0;
7394}
7395
7396static struct snd_kcontrol_new alc861_capture_mixer[] = {
7397 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7398 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7399
7400 {
7401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7402 /* The multiple "Capture Source" controls confuse alsamixer
7403 * So call somewhat different..
7404 *FIXME: the controls appear in the "playback" view!
7405 */
7406 /* .name = "Capture Source", */
7407 .name = "Input Source",
7408 .count = 1,
7409 .info = alc_mux_enum_info,
7410 .get = alc_mux_enum_get,
7411 .put = alc_mux_enum_put,
7412 },
7413 { } /* end */
7414};
7415
7416static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7417 int pin_type, int dac_idx)
7418{
7419 /* set as output */
7420
7421 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7422 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
7423
7424}
7425
7426static void alc861_auto_init_multi_out(struct hda_codec *codec)
7427{
7428 struct alc_spec *spec = codec->spec;
7429 int i;
7430
7431 for (i = 0; i < spec->autocfg.line_outs; i++) {
7432 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7433 if (nid)
7434 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
7435 }
7436}
7437
7438static void alc861_auto_init_hp_out(struct hda_codec *codec)
7439{
7440 struct alc_spec *spec = codec->spec;
7441 hda_nid_t pin;
7442
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007443 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007444 if (pin) /* connect to front */
7445 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
7446}
7447
7448static void alc861_auto_init_analog_input(struct hda_codec *codec)
7449{
7450 struct alc_spec *spec = codec->spec;
7451 int i;
7452
7453 for (i = 0; i < AUTO_PIN_LAST; i++) {
7454 hda_nid_t nid = spec->autocfg.input_pins[i];
7455 if ((nid>=0x0c) && (nid <=0x11)) {
7456 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7457 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
7458 }
7459 }
7460}
7461
7462/* parse the BIOS configuration and set up the alc_spec */
7463/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
7464static int alc861_parse_auto_config(struct hda_codec *codec)
7465{
7466 struct alc_spec *spec = codec->spec;
7467 int err;
7468 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7469
7470 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7471 alc861_ignore)) < 0)
7472 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01007473 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007474 return 0; /* can't find valid BIOS pin config */
7475
7476 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
7477 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007478 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
Kailang Yangdf694da2005-12-05 19:42:22 +01007479 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
7480 return err;
7481
7482 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7483
7484 if (spec->autocfg.dig_out_pin)
7485 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
7486
7487 if (spec->kctl_alloc)
7488 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7489
7490 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
7491
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007492 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007493 spec->input_mux = &spec->private_imux;
7494
7495 spec->adc_nids = alc861_adc_nids;
7496 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
7497 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
7498 spec->num_mixers++;
7499
7500 return 1;
7501}
7502
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007503/* additional initialization for auto-configuration model */
7504static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007505{
Kailang Yangdf694da2005-12-05 19:42:22 +01007506 alc861_auto_init_multi_out(codec);
7507 alc861_auto_init_hp_out(codec);
7508 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007509}
7510
7511
7512/*
7513 * configuration and preset
7514 */
7515static struct hda_board_config alc861_cfg_tbl[] = {
7516 { .modelname = "3stack", .config = ALC861_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007517 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
7518 .config = ALC861_3ST },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007519 { .modelname = "3stack-660", .config = ALC660_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007520 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
7521 .config = ALC660_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01007522 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
7523 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
Takashi Iwai22309c32006-08-09 16:57:28 +02007524 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
7525 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
7526 .config = ALC861_UNIWILL_M31 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007527 { .modelname = "toshiba", .config = ALC861_TOSHIBA },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007528 { .pci_subvendor = 0x1179, .pci_subdevice = 0xff10,
7529 .config = ALC861_TOSHIBA },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007530 { .modelname = "asus", .config = ALC861_ASUS},
7531 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1393,
7532 .config = ALC861_ASUS },
7533 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1338,
7534 .config = ALC861_ASUS },
Kailang Yangdf694da2005-12-05 19:42:22 +01007535 { .modelname = "auto", .config = ALC861_AUTO },
7536 {}
7537};
7538
7539static struct alc_config_preset alc861_presets[] = {
7540 [ALC861_3ST] = {
7541 .mixers = { alc861_3ST_mixer },
7542 .init_verbs = { alc861_threestack_init_verbs },
7543 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7544 .dac_nids = alc861_dac_nids,
7545 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7546 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007547 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007548 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7549 .adc_nids = alc861_adc_nids,
7550 .input_mux = &alc861_capture_source,
7551 },
7552 [ALC861_3ST_DIG] = {
7553 .mixers = { alc861_base_mixer },
7554 .init_verbs = { alc861_threestack_init_verbs },
7555 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7556 .dac_nids = alc861_dac_nids,
7557 .dig_out_nid = ALC861_DIGOUT_NID,
7558 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7559 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007560 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007561 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7562 .adc_nids = alc861_adc_nids,
7563 .input_mux = &alc861_capture_source,
7564 },
7565 [ALC861_6ST_DIG] = {
7566 .mixers = { alc861_base_mixer },
7567 .init_verbs = { alc861_base_init_verbs },
7568 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7569 .dac_nids = alc861_dac_nids,
7570 .dig_out_nid = ALC861_DIGOUT_NID,
7571 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
7572 .channel_mode = alc861_8ch_modes,
7573 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7574 .adc_nids = alc861_adc_nids,
7575 .input_mux = &alc861_capture_source,
7576 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007577 [ALC660_3ST] = {
7578 .mixers = { alc861_3ST_mixer },
7579 .init_verbs = { alc861_threestack_init_verbs },
7580 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
7581 .dac_nids = alc660_dac_nids,
7582 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7583 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007584 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007585 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7586 .adc_nids = alc861_adc_nids,
7587 .input_mux = &alc861_capture_source,
7588 },
Takashi Iwai22309c32006-08-09 16:57:28 +02007589 [ALC861_UNIWILL_M31] = {
7590 .mixers = { alc861_uniwill_m31_mixer },
7591 .init_verbs = { alc861_uniwill_m31_init_verbs },
7592 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7593 .dac_nids = alc861_dac_nids,
7594 .dig_out_nid = ALC861_DIGOUT_NID,
7595 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
7596 .channel_mode = alc861_uniwill_m31_modes,
7597 .need_dac_fix = 1,
7598 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7599 .adc_nids = alc861_adc_nids,
7600 .input_mux = &alc861_capture_source,
7601 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007602 [ALC861_TOSHIBA] = {
7603 .mixers = { alc861_toshiba_mixer },
7604 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
7605 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7606 .dac_nids = alc861_dac_nids,
7607 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7608 .channel_mode = alc883_3ST_2ch_modes,
7609 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7610 .adc_nids = alc861_adc_nids,
7611 .input_mux = &alc861_capture_source,
7612 .unsol_event = alc861_toshiba_unsol_event,
7613 .init_hook = alc861_toshiba_automute,
7614 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007615 [ALC861_ASUS] = {
7616 .mixers = { alc861_asus_mixer },
7617 .init_verbs = { alc861_asus_init_verbs },
7618 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7619 .dac_nids = alc861_dac_nids,
7620 .dig_out_nid = ALC861_DIGOUT_NID,
7621 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
7622 .channel_mode = alc861_asus_modes,
7623 .need_dac_fix = 1,
7624 .hp_nid = 0x06,
7625 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7626 .adc_nids = alc861_adc_nids,
7627 .input_mux = &alc861_capture_source,
7628 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007629};
7630
7631
7632static int patch_alc861(struct hda_codec *codec)
7633{
7634 struct alc_spec *spec;
7635 int board_config;
7636 int err;
7637
7638 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
7639 if (spec == NULL)
7640 return -ENOMEM;
7641
7642 codec->spec = spec;
7643
7644 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007645
Kailang Yangdf694da2005-12-05 19:42:22 +01007646 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007647 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
7648 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007649 board_config = ALC861_AUTO;
7650 }
7651
7652 if (board_config == ALC861_AUTO) {
7653 /* automatic parse from the BIOS config */
7654 err = alc861_parse_auto_config(codec);
7655 if (err < 0) {
7656 alc_free(codec);
7657 return err;
7658 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007659 printk(KERN_INFO
7660 "hda_codec: Cannot set up configuration "
7661 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007662 board_config = ALC861_3ST_DIG;
7663 }
7664 }
7665
7666 if (board_config != ALC861_AUTO)
7667 setup_preset(spec, &alc861_presets[board_config]);
7668
7669 spec->stream_name_analog = "ALC861 Analog";
7670 spec->stream_analog_playback = &alc861_pcm_analog_playback;
7671 spec->stream_analog_capture = &alc861_pcm_analog_capture;
7672
7673 spec->stream_name_digital = "ALC861 Digital";
7674 spec->stream_digital_playback = &alc861_pcm_digital_playback;
7675 spec->stream_digital_capture = &alc861_pcm_digital_capture;
7676
7677 codec->patch_ops = alc_patch_ops;
7678 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007679 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01007680
7681 return 0;
7682}
7683
7684/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07007685 * patch entries
7686 */
7687struct hda_codec_preset snd_hda_preset_realtek[] = {
7688 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007689 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007690 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
7691 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007692 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007693 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007694 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
7695 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
7696 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007697 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007698 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007699 { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007700 {} /* terminator */
7701};