blob: a1b6c9661d45daf3a20ce0953f00236629f6e570 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
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 Woithe7cf51e42006-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,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100104 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100105 ALC861_AUTO,
106 ALC861_MODEL_LAST,
107};
108
109/* ALC882 models */
110enum {
111 ALC882_3ST_DIG,
112 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200113 ALC882_ARIMA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100114 ALC882_AUTO,
115 ALC882_MODEL_LAST,
116};
117
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200118/* ALC883 models */
119enum {
120 ALC883_3ST_2ch_DIG,
121 ALC883_3ST_6ch_DIG,
122 ALC883_3ST_6ch,
123 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200124 ALC883_TARGA_DIG,
125 ALC883_TARGA_2ch_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200126 ALC888_DEMO_BOARD,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200127 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200128 ALC883_MEDION,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100129 ALC883_LAPTOP_EAPD,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200130 ALC883_AUTO,
131 ALC883_MODEL_LAST,
132};
133
Kailang Yangdf694da2005-12-05 19:42:22 +0100134/* for GPIO Poll */
135#define GPIO_MASK 0x03
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137struct alc_spec {
138 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100139 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 unsigned int num_mixers;
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200143 * don't forget NULL
144 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200145 */
146 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Takashi Iwai16ded522005-06-10 19:58:24 +0200148 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 struct hda_pcm_stream *stream_analog_playback;
150 struct hda_pcm_stream *stream_analog_capture;
151
Takashi Iwai16ded522005-06-10 19:58:24 +0200152 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 struct hda_pcm_stream *stream_digital_playback;
154 struct hda_pcm_stream *stream_digital_capture;
155
156 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200157 struct hda_multi_out multiout; /* playback set-up
158 * max_channels, dacs must be set
159 * dig_out_nid and hp_nid are optional
160 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162 /* capture */
163 unsigned int num_adc_nids;
164 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200165 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200168 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 const struct hda_input_mux *input_mux;
170 unsigned int cur_mux[3];
171
172 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100173 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200175 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
177 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100178 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200179
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200180 /* dynamic controls, init_verbs and input_mux */
181 struct auto_pin_cfg autocfg;
182 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100183 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200184 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100185 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100186
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100187 /* hooks */
188 void (*init_hook)(struct hda_codec *codec);
189 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
190
Takashi Iwai834be882006-03-01 14:16:17 +0100191 /* for pin sensing */
192 unsigned int sense_updated: 1;
193 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100194};
195
196/*
197 * configuration template - to be copied to the spec instance
198 */
199struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200200 struct snd_kcontrol_new *mixers[5]; /* should be identical size
201 * with spec
202 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100203 const struct hda_verb *init_verbs[5];
204 unsigned int num_dacs;
205 hda_nid_t *dac_nids;
206 hda_nid_t dig_out_nid; /* optional */
207 hda_nid_t hp_nid; /* optional */
208 unsigned int num_adc_nids;
209 hda_nid_t *adc_nids;
210 hda_nid_t dig_in_nid;
211 unsigned int num_channel_mode;
212 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200213 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200214 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100215 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100216 void (*unsol_event)(struct hda_codec *, unsigned int);
217 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218};
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221/*
222 * input MUX handling
223 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200224static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
225 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226{
227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
228 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200229 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
230 if (mux_idx >= spec->num_mux_defs)
231 mux_idx = 0;
232 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233}
234
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200235static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239 struct alc_spec *spec = codec->spec;
240 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
241
242 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
243 return 0;
244}
245
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200246static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
247 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248{
249 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
250 struct alc_spec *spec = codec->spec;
251 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200252 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
253 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200254 spec->adc_nids[adc_idx],
255 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256}
257
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200258
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259/*
260 * channel mode setting
261 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200262static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
263 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264{
265 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
266 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100267 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
268 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269}
270
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200271static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
272 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273{
274 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
275 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100276 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200277 spec->num_channel_mode,
278 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279}
280
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200281static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
282 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283{
284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
285 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200286 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
287 spec->num_channel_mode,
288 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200289 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200290 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
291 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292}
293
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100295 * Control the mode of pin widget settings via the mixer. "pc" is used
296 * instead of "%" to avoid consequences of accidently treating the % as
297 * being part of a format specifier. Maximum allowed length of a value is
298 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100299 *
300 * Note: some retasking pin complexes seem to ignore requests for input
301 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
302 * are requested. Therefore order this list so that this behaviour will not
303 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200304 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
305 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200306 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100307static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100308 "Mic 50pc bias", "Mic 80pc bias",
309 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100310};
311static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100312 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100313};
314/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200315 * in the pin being assumed to be exclusively an input or an output pin. In
316 * addition, "input" pins may or may not process the mic bias option
317 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
318 * accept requests for bias as of chip versions up to March 2006) and/or
319 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100320 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200321#define ALC_PIN_DIR_IN 0x00
322#define ALC_PIN_DIR_OUT 0x01
323#define ALC_PIN_DIR_INOUT 0x02
324#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
325#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100326
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200327/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100328 * For each direction the minimum and maximum values are given.
329 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200330static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100331 { 0, 2 }, /* ALC_PIN_DIR_IN */
332 { 3, 4 }, /* ALC_PIN_DIR_OUT */
333 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200334 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
335 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100336};
337#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
338#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
339#define alc_pin_mode_n_items(_dir) \
340 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
341
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200342static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
343 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200344{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100345 unsigned int item_num = uinfo->value.enumerated.item;
346 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
347
348 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200349 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100350 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
351
352 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
353 item_num = alc_pin_mode_min(dir);
354 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200355 return 0;
356}
357
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200358static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
359 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200360{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
363 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100364 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200365 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
367 AC_VERB_GET_PIN_WIDGET_CONTROL,
368 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200369
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100370 /* Find enumerated value for current pinctl setting */
371 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200372 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100373 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200374 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375 return 0;
376}
377
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200378static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
379 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100380{
381 signed int change;
382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
383 hda_nid_t nid = kcontrol->private_value & 0xffff;
384 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
385 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200386 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
387 AC_VERB_GET_PIN_WIDGET_CONTROL,
388 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100389
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100391 val = alc_pin_mode_min(dir);
392
393 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100394 if (change) {
395 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200396 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200397 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100398
399 /* Also enable the retasking pin's input/output as required
400 * for the requested pin mode. Enum values of 2 or less are
401 * input modes.
402 *
403 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200404 * reduces noise slightly (particularly on input) so we'll
405 * do it. However, having both input and output buffers
406 * enabled simultaneously doesn't seem to be problematic if
407 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100408 */
409 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200410 snd_hda_codec_write(codec, nid, 0,
411 AC_VERB_SET_AMP_GAIN_MUTE,
412 AMP_OUT_MUTE);
413 snd_hda_codec_write(codec, nid, 0,
414 AC_VERB_SET_AMP_GAIN_MUTE,
415 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100416 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417 snd_hda_codec_write(codec, nid, 0,
418 AC_VERB_SET_AMP_GAIN_MUTE,
419 AMP_IN_MUTE(0));
420 snd_hda_codec_write(codec, nid, 0,
421 AC_VERB_SET_AMP_GAIN_MUTE,
422 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100423 }
424 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200425 return change;
426}
427
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200429 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100430 .info = alc_pin_mode_info, \
431 .get = alc_pin_mode_get, \
432 .put = alc_pin_mode_put, \
433 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100434
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100435/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
436 * together using a mask with more than one bit set. This control is
437 * currently used only by the ALC260 test model. At this stage they are not
438 * needed for any "production" models.
439 */
440#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200441static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
442 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100443{
444 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
445 uinfo->count = 1;
446 uinfo->value.integer.min = 0;
447 uinfo->value.integer.max = 1;
448 return 0;
449}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200450static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100452{
453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
454 hda_nid_t nid = kcontrol->private_value & 0xffff;
455 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
456 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457 unsigned int val = snd_hda_codec_read(codec, nid, 0,
458 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100459
460 *valp = (val & mask) != 0;
461 return 0;
462}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100465{
466 signed int change;
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 hda_nid_t nid = kcontrol->private_value & 0xffff;
469 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
470 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
472 AC_VERB_GET_GPIO_DATA,
473 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100474
475 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
477 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100478 gpio_data &= ~mask;
479 else
480 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100482
483 return change;
484}
485#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
486 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
487 .info = alc_gpio_data_info, \
488 .get = alc_gpio_data_get, \
489 .put = alc_gpio_data_put, \
490 .private_value = nid | (mask<<16) }
491#endif /* CONFIG_SND_DEBUG */
492
Jonathan Woithe92621f12006-02-28 11:47:47 +0100493/* A switch control to allow the enabling of the digital IO pins on the
494 * ALC260. This is incredibly simplistic; the intention of this control is
495 * to provide something in the test model allowing digital outputs to be
496 * identified if present. If models are found which can utilise these
497 * outputs a more complete mixer control can be devised for those models if
498 * necessary.
499 */
500#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200501static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100503{
504 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
505 uinfo->count = 1;
506 uinfo->value.integer.min = 0;
507 uinfo->value.integer.max = 1;
508 return 0;
509}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200510static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
511 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100512{
513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
514 hda_nid_t nid = kcontrol->private_value & 0xffff;
515 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
516 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200517 unsigned int val = snd_hda_codec_read(codec, nid, 0,
518 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100519
520 *valp = (val & mask) != 0;
521 return 0;
522}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100525{
526 signed int change;
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 hda_nid_t nid = kcontrol->private_value & 0xffff;
529 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
530 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200531 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
532 AC_VERB_GET_DIGI_CONVERT,
533 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100534
535 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100537 if (val==0)
538 ctrl_data &= ~mask;
539 else
540 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
542 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100543
544 return change;
545}
546#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
547 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
548 .info = alc_spdif_ctrl_info, \
549 .get = alc_spdif_ctrl_get, \
550 .put = alc_spdif_ctrl_put, \
551 .private_value = nid | (mask<<16) }
552#endif /* CONFIG_SND_DEBUG */
553
Kailang Yangdf694da2005-12-05 19:42:22 +0100554/*
555 * set up from the preset table
556 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557static void setup_preset(struct alc_spec *spec,
558 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100559{
560 int i;
561
562 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
563 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
565 i++)
566 spec->init_verbs[spec->num_init_verbs++] =
567 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100568
569 spec->channel_mode = preset->channel_mode;
570 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200571 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100572
573 spec->multiout.max_channels = spec->channel_mode[0].channels;
574
575 spec->multiout.num_dacs = preset->num_dacs;
576 spec->multiout.dac_nids = preset->dac_nids;
577 spec->multiout.dig_out_nid = preset->dig_out_nid;
578 spec->multiout.hp_nid = preset->hp_nid;
579
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200580 spec->num_mux_defs = preset->num_mux_defs;
581 if (! spec->num_mux_defs)
582 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100583 spec->input_mux = preset->input_mux;
584
585 spec->num_adc_nids = preset->num_adc_nids;
586 spec->adc_nids = preset->adc_nids;
587 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100588
589 spec->unsol_event = preset->unsol_event;
590 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100591}
592
Takashi Iwai41e41f12005-06-08 14:48:49 +0200593/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200594 * ALC880 3-stack model
595 *
596 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
598 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 */
600
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200601static hda_nid_t alc880_dac_nids[4] = {
602 /* front, rear, clfe, rear_surr */
603 0x02, 0x05, 0x04, 0x03
604};
605
606static hda_nid_t alc880_adc_nids[3] = {
607 /* ADC0-2 */
608 0x07, 0x08, 0x09,
609};
610
611/* The datasheet says the node 0x07 is connected from inputs,
612 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100613 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200615static hda_nid_t alc880_adc_nids_alt[2] = {
616 /* ADC1-2 */
617 0x08, 0x09,
618};
619
620#define ALC880_DIGOUT_NID 0x06
621#define ALC880_DIGIN_NID 0x0a
622
623static struct hda_input_mux alc880_capture_source = {
624 .num_items = 4,
625 .items = {
626 { "Mic", 0x0 },
627 { "Front Mic", 0x3 },
628 { "Line", 0x2 },
629 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200631};
632
633/* channel source setting (2/6 channel selection for 3-stack) */
634/* 2ch mode */
635static struct hda_verb alc880_threestack_ch2_init[] = {
636 /* set line-in to input, mute it */
637 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
638 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
639 /* set mic-in to input vref 80%, mute it */
640 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
641 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 { } /* end */
643};
644
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200645/* 6ch mode */
646static struct hda_verb alc880_threestack_ch6_init[] = {
647 /* set line-in to output, unmute it */
648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
650 /* set mic-in to output, unmute it */
651 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
652 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
653 { } /* end */
654};
655
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100656static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200657 { 2, alc880_threestack_ch2_init },
658 { 6, alc880_threestack_ch6_init },
659};
660
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100661static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200662 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200664 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100665 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200666 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
667 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100668 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
669 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
672 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
673 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
676 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
677 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
678 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
679 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200681 {
682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
683 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100684 .info = alc_ch_mode_info,
685 .get = alc_ch_mode_get,
686 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200687 },
688 { } /* end */
689};
690
691/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100692static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200693 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
694 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
695 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
696 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
697 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
698 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
699 {
700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
701 /* The multiple "Capture Source" controls confuse alsamixer
702 * So call somewhat different..
703 * FIXME: the controls appear in the "playback" view!
704 */
705 /* .name = "Capture Source", */
706 .name = "Input Source",
707 .count = 3,
708 .info = alc_mux_enum_info,
709 .get = alc_mux_enum_get,
710 .put = alc_mux_enum_put,
711 },
712 { } /* end */
713};
714
715/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100716static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200717 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
718 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
719 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
720 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 {
722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
723 /* The multiple "Capture Source" controls confuse alsamixer
724 * So call somewhat different..
725 * FIXME: the controls appear in the "playback" view!
726 */
727 /* .name = "Capture Source", */
728 .name = "Input Source",
729 .count = 2,
730 .info = alc_mux_enum_info,
731 .get = alc_mux_enum_get,
732 .put = alc_mux_enum_put,
733 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 { } /* end */
735};
736
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200737
738
739/*
740 * ALC880 5-stack model
741 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200742 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
743 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200744 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
745 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
746 */
747
748/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100749static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200750 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100751 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 { } /* end */
753};
754
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200755/* channel source setting (6/8 channel selection for 5-stack) */
756/* 6ch mode */
757static struct hda_verb alc880_fivestack_ch6_init[] = {
758 /* set line-in to input, mute it */
759 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
760 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200761 { } /* end */
762};
763
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200764/* 8ch mode */
765static struct hda_verb alc880_fivestack_ch8_init[] = {
766 /* set line-in to output, unmute it */
767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
769 { } /* end */
770};
771
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100772static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200773 { 6, alc880_fivestack_ch6_init },
774 { 8, alc880_fivestack_ch8_init },
775};
776
777
778/*
779 * ALC880 6-stack model
780 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200781 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
782 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200783 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
784 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
785 */
786
787static hda_nid_t alc880_6st_dac_nids[4] = {
788 /* front, rear, clfe, rear_surr */
789 0x02, 0x03, 0x04, 0x05
790};
791
792static struct hda_input_mux alc880_6stack_capture_source = {
793 .num_items = 4,
794 .items = {
795 { "Mic", 0x0 },
796 { "Front Mic", 0x1 },
797 { "Line", 0x2 },
798 { "CD", 0x4 },
799 },
800};
801
802/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100803static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200804 { 8, NULL },
805};
806
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100807static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200808 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100809 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200810 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100811 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200812 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
813 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100814 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
815 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200816 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100817 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
820 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
821 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
824 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
825 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
826 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
827 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200828 {
829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
830 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100831 .info = alc_ch_mode_info,
832 .get = alc_ch_mode_get,
833 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200834 },
835 { } /* end */
836};
837
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200838
839/*
840 * ALC880 W810 model
841 *
842 * W810 has rear IO for:
843 * Front (DAC 02)
844 * Surround (DAC 03)
845 * Center/LFE (DAC 04)
846 * Digital out (06)
847 *
848 * The system also has a pair of internal speakers, and a headphone jack.
849 * These are both connected to Line2 on the codec, hence to DAC 02.
850 *
851 * There is a variable resistor to control the speaker or headphone
852 * volume. This is a hardware-only device without a software API.
853 *
854 * Plugging headphones in will disable the internal speakers. This is
855 * implemented in hardware, not via the driver using jack sense. In
856 * a similar fashion, plugging into the rear socket marked "front" will
857 * disable both the speakers and headphones.
858 *
859 * For input, there's a microphone jack, and an "audio in" jack.
860 * These may not do anything useful with this driver yet, because I
861 * haven't setup any initialization verbs for these yet...
862 */
863
864static hda_nid_t alc880_w810_dac_nids[3] = {
865 /* front, rear/surround, clfe */
866 0x02, 0x03, 0x04
867};
868
869/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100870static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200871 { 6, NULL }
872};
873
874/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100875static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200878 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100879 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200880 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
881 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
885 { } /* end */
886};
887
888
889/*
890 * Z710V model
891 *
892 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200893 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
894 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200895 */
896
897static hda_nid_t alc880_z71v_dac_nids[1] = {
898 0x02
899};
900#define ALC880_Z71V_HP_DAC 0x03
901
902/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100903static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200904 { 2, NULL }
905};
906
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100907static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100909 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200910 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100911 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200912 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
913 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
916 { } /* end */
917};
918
919
920/* FIXME! */
921/*
922 * ALC880 F1734 model
923 *
924 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
925 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
926 */
927
928static hda_nid_t alc880_f1734_dac_nids[1] = {
929 0x03
930};
931#define ALC880_F1734_HP_DAC 0x02
932
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100933static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200934 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100935 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200936 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100937 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
941 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200942 { } /* end */
943};
944
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200945
946/* FIXME! */
947/*
948 * ALC880 ASUS model
949 *
950 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
951 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
952 * Mic = 0x18, Line = 0x1a
953 */
954
955#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
956#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
957
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100958static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100962 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200973 {
974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
975 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100976 .info = alc_ch_mode_info,
977 .get = alc_ch_mode_get,
978 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200979 },
980 { } /* end */
981};
982
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200983/* FIXME! */
984/*
985 * ALC880 ASUS W1V model
986 *
987 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
988 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
989 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
990 */
991
992/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100993static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200994 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
995 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200996 { } /* end */
997};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200998
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200999/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001000static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001001 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1002 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1003 { } /* end */
1004};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001005
Kailang Yangdf694da2005-12-05 19:42:22 +01001006/* TCL S700 */
1007static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1008 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1012 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1015 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1016 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1017 {
1018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1019 /* The multiple "Capture Source" controls confuse alsamixer
1020 * So call somewhat different..
1021 * FIXME: the controls appear in the "playback" view!
1022 */
1023 /* .name = "Capture Source", */
1024 .name = "Input Source",
1025 .count = 1,
1026 .info = alc_mux_enum_info,
1027 .get = alc_mux_enum_get,
1028 .put = alc_mux_enum_put,
1029 },
1030 { } /* end */
1031};
1032
Kailang Yangccc656c2006-10-17 12:32:26 +02001033/* Uniwill */
1034static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1035 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1036 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1037 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1038 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1039 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1040 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1041 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1042 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1043 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1044 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1049 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1050 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1051 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1052 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1053 {
1054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1055 .name = "Channel Mode",
1056 .info = alc_ch_mode_info,
1057 .get = alc_ch_mode_get,
1058 .put = alc_ch_mode_put,
1059 },
1060 { } /* end */
1061};
1062
1063static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1064 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1065 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1066 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1067 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1069 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1070 { } /* end */
1071};
1072
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 */
1076static int alc_build_controls(struct hda_codec *codec)
1077{
1078 struct alc_spec *spec = codec->spec;
1079 int err;
1080 int i;
1081
1082 for (i = 0; i < spec->num_mixers; i++) {
1083 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1084 if (err < 0)
1085 return err;
1086 }
1087
1088 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001089 err = snd_hda_create_spdif_out_ctls(codec,
1090 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 if (err < 0)
1092 return err;
1093 }
1094 if (spec->dig_in_nid) {
1095 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1096 if (err < 0)
1097 return err;
1098 }
1099 return 0;
1100}
1101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001102
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103/*
1104 * initialize the codec volumes, etc
1105 */
1106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001107/*
1108 * generic initialization of ADC, input mixers and output mixers
1109 */
1110static struct hda_verb alc880_volume_init_verbs[] = {
1111 /*
1112 * Unmute ADC0-2 and set the default input to mic-in
1113 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001114 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001116 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001118 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001121 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1122 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001123 * Note: PASD motherboards uses the Line In 2 as the input for front
1124 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001126 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001133 /*
1134 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001136 /* set vol=0 to output mixers */
1137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1138 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1140 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1141 /* set up input amps for analog loopback */
1142 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001149 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151
1152 { }
1153};
1154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155/*
1156 * 3-stack pin configuration:
1157 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1158 */
1159static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1160 /*
1161 * preset connection lists of input pins
1162 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1163 */
1164 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1165 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1166 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1167
1168 /*
1169 * Set pin mode and muting
1170 */
1171 /* set front pin widgets 0x14 for output */
1172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1174 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1175 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1177 /* Mic2 (as headphone out) for HP output */
1178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1180 /* Line In pin widget for input */
1181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1183 /* Line2 (as front mic) pin widget for input and vref at 80% */
1184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1186 /* CD pin widget for input */
1187 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1188
1189 { }
1190};
1191
1192/*
1193 * 5-stack pin configuration:
1194 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1195 * line-in/side = 0x1a, f-mic = 0x1b
1196 */
1197static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1198 /*
1199 * preset connection lists of input pins
1200 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1201 */
1202 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1203 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1204
1205 /*
1206 * Set pin mode and muting
1207 */
1208 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1211 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1212 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001213 /* unmute pins for output (no gain on this amp) */
1214 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1216 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1217 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1218
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001220 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1222 /* Mic2 (as headphone out) for HP output */
1223 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001225 /* Line In pin widget for input */
1226 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1227 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1228 /* Line2 (as front mic) pin widget for input and vref at 80% */
1229 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1230 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1231 /* CD pin widget for input */
1232 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233
1234 { }
1235};
1236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001237/*
1238 * W810 pin configuration:
1239 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1240 */
1241static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 /* hphone/speaker input selector: front DAC */
1243 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1244
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1251
1252 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001253 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 { }
1256};
1257
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258/*
1259 * Z71V pin configuration:
1260 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1261 */
1262static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001267
Takashi Iwai16ded522005-06-10 19:58:24 +02001268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001271 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001272
1273 { }
1274};
1275
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001276/*
1277 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001278 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1279 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280 */
1281static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1282 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1283
Takashi Iwai16ded522005-06-10 19:58:24 +02001284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001288 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001289 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001290 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1292
Takashi Iwai16ded522005-06-10 19:58:24 +02001293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001295 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001299 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001301 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1302
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001303 { }
1304};
Takashi Iwai16ded522005-06-10 19:58:24 +02001305
Kailang Yangccc656c2006-10-17 12:32:26 +02001306/*
1307 * Uniwill pin configuration:
1308 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1309 * line = 0x1a
1310 */
1311static struct hda_verb alc880_uniwill_init_verbs[] = {
1312 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1313
1314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1318 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1319 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1320 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1321 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1328
1329 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1330 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1331 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1333 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1334 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1335 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1336 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1337 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1338
1339 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1340 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1341
1342 { }
1343};
1344
1345/*
1346* Uniwill P53
1347* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1348 */
1349static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1350 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1351
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1355 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1356 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1357 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1364
1365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1369 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1371
1372 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1373 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1374
1375 { }
1376};
1377
1378/* toggle speaker-output according to the hp-jack state */
1379static void alc880_uniwill_automute(struct hda_codec *codec)
1380{
1381 unsigned int present;
1382
1383 present = snd_hda_codec_read(codec, 0x14, 0,
1384 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1385 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1386 0x80, present ? 0x80 : 0);
1387 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1388 0x80, present ? 0x80 : 0);
1389 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1390 0x80, present ? 0x80 : 0);
1391 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1392 0x80, present ? 0x80 : 0);
1393
1394 present = snd_hda_codec_read(codec, 0x18, 0,
1395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1396 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1397 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1398}
1399
1400static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1401 unsigned int res)
1402{
1403 /* Looks like the unsol event is incompatible with the standard
1404 * definition. 4bit tag is placed at 28 bit!
1405 */
1406 if ((res >> 28) == ALC880_HP_EVENT ||
1407 (res >> 28) == ALC880_MIC_EVENT)
1408 alc880_uniwill_automute(codec);
1409}
1410
1411static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1412{
1413 unsigned int present;
1414
1415 present = snd_hda_codec_read(codec, 0x14, 0,
1416 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1417
1418 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1419 0x80, present ? 0x80 : 0);
1420 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1421 0x80, present ? 0x80 : 0);
1422}
1423
1424static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1425{
1426 unsigned int present;
1427
1428 present = snd_hda_codec_read(codec, 0x21, 0,
1429 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1430
1431 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1432 0x7f, present);
1433 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1434 0x7f, present);
1435
1436 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1437 0x7f, present);
1438 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1439 0x7f, present);
1440
1441}
1442static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1443 unsigned int res)
1444{
1445 /* Looks like the unsol event is incompatible with the standard
1446 * definition. 4bit tag is placed at 28 bit!
1447 */
1448 if ((res >> 28) == ALC880_HP_EVENT)
1449 alc880_uniwill_p53_hp_automute(codec);
1450 if ((res >> 28) == ALC880_DCVOL_EVENT)
1451 alc880_uniwill_p53_dcvol_automute(codec);
1452}
1453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001454/* FIXME! */
1455/*
1456 * F1734 pin configuration:
1457 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1458 */
1459static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1460 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1461 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1462 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1463 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1464
1465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469
1470 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1471 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1475 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1478 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001479
1480 { }
1481};
1482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001483/* FIXME! */
1484/*
1485 * ASUS pin configuration:
1486 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1487 */
1488static struct hda_verb alc880_pin_asus_init_verbs[] = {
1489 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1490 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1491 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1493
1494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502
1503 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1505 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1512
1513 { }
1514};
1515
1516/* Enable GPIO mask and set output */
1517static struct hda_verb alc880_gpio1_init_verbs[] = {
1518 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1519 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1520 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001521
1522 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001523};
1524
1525/* Enable GPIO mask and set output */
1526static struct hda_verb alc880_gpio2_init_verbs[] = {
1527 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1528 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1529 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001530
1531 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001532};
1533
Kailang Yangdf694da2005-12-05 19:42:22 +01001534/* Clevo m520g init */
1535static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1536 /* headphone output */
1537 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1538 /* line-out */
1539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1541 /* Line-in */
1542 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1544 /* CD */
1545 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1546 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1547 /* Mic1 (rear panel) */
1548 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1549 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1550 /* Mic2 (front panel) */
1551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1552 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1553 /* headphone */
1554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1556 /* change to EAPD mode */
1557 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1558 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1559
1560 { }
1561};
1562
1563static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001564 /* change to EAPD mode */
1565 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1566 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1567
Kailang Yangdf694da2005-12-05 19:42:22 +01001568 /* Headphone output */
1569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1570 /* Front output*/
1571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1572 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1573
1574 /* Line In pin widget for input */
1575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1576 /* CD pin widget for input */
1577 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1578 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1580
1581 /* change to EAPD mode */
1582 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1583 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1584
1585 { }
1586};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001587
1588/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001589 * LG m1 express dual
1590 *
1591 * Pin assignment:
1592 * Rear Line-In/Out (blue): 0x14
1593 * Build-in Mic-In: 0x15
1594 * Speaker-out: 0x17
1595 * HP-Out (green): 0x1b
1596 * Mic-In/Out (red): 0x19
1597 * SPDIF-Out: 0x1e
1598 */
1599
1600/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1601static hda_nid_t alc880_lg_dac_nids[3] = {
1602 0x05, 0x02, 0x03
1603};
1604
1605/* seems analog CD is not working */
1606static struct hda_input_mux alc880_lg_capture_source = {
1607 .num_items = 3,
1608 .items = {
1609 { "Mic", 0x1 },
1610 { "Line", 0x5 },
1611 { "Internal Mic", 0x6 },
1612 },
1613};
1614
1615/* 2,4,6 channel modes */
1616static struct hda_verb alc880_lg_ch2_init[] = {
1617 /* set line-in and mic-in to input */
1618 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1619 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1620 { }
1621};
1622
1623static struct hda_verb alc880_lg_ch4_init[] = {
1624 /* set line-in to out and mic-in to input */
1625 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1626 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1627 { }
1628};
1629
1630static struct hda_verb alc880_lg_ch6_init[] = {
1631 /* set line-in and mic-in to output */
1632 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1633 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1634 { }
1635};
1636
1637static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1638 { 2, alc880_lg_ch2_init },
1639 { 4, alc880_lg_ch4_init },
1640 { 6, alc880_lg_ch6_init },
1641};
1642
1643static struct snd_kcontrol_new alc880_lg_mixer[] = {
1644 /* FIXME: it's not really "master" but front channels */
1645 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1646 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1647 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1648 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1650 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1651 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1652 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1657 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1658 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1659 {
1660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1661 .name = "Channel Mode",
1662 .info = alc_ch_mode_info,
1663 .get = alc_ch_mode_get,
1664 .put = alc_ch_mode_put,
1665 },
1666 { } /* end */
1667};
1668
1669static struct hda_verb alc880_lg_init_verbs[] = {
1670 /* set capture source to mic-in */
1671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1674 /* mute all amp mixer inputs */
1675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1678 /* line-in to input */
1679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1681 /* built-in mic */
1682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 /* speaker-out */
1685 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1686 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 /* mic-in to input */
1688 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1689 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1690 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 /* HP-out */
1692 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1694 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 /* jack sense */
1696 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1697 { }
1698};
1699
1700/* toggle speaker-output according to the hp-jack state */
1701static void alc880_lg_automute(struct hda_codec *codec)
1702{
1703 unsigned int present;
1704
1705 present = snd_hda_codec_read(codec, 0x1b, 0,
1706 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1707 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1708 0x80, present ? 0x80 : 0);
1709 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1710 0x80, present ? 0x80 : 0);
1711}
1712
1713static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1714{
1715 /* Looks like the unsol event is incompatible with the standard
1716 * definition. 4bit tag is placed at 28 bit!
1717 */
1718 if ((res >> 28) == 0x01)
1719 alc880_lg_automute(codec);
1720}
1721
1722/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001723 * LG LW20
1724 *
1725 * Pin assignment:
1726 * Speaker-out: 0x14
1727 * Mic-In: 0x18
1728 * Built-in Mic-In: 0x19 (?)
1729 * HP-Out: 0x1b
1730 * SPDIF-Out: 0x1e
1731 */
1732
1733/* seems analog CD is not working */
1734static struct hda_input_mux alc880_lg_lw_capture_source = {
1735 .num_items = 2,
1736 .items = {
1737 { "Mic", 0x0 },
1738 { "Internal Mic", 0x1 },
1739 },
1740};
1741
1742static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1743 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1744 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1747 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1748 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1749 { } /* end */
1750};
1751
1752static struct hda_verb alc880_lg_lw_init_verbs[] = {
1753 /* set capture source to mic-in */
1754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1758 /* speaker-out */
1759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 /* HP-out */
1762 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1763 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 /* mic-in to input */
1766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1767 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1768 /* built-in mic */
1769 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1771 /* jack sense */
1772 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1773 { }
1774};
1775
1776/* toggle speaker-output according to the hp-jack state */
1777static void alc880_lg_lw_automute(struct hda_codec *codec)
1778{
1779 unsigned int present;
1780
1781 present = snd_hda_codec_read(codec, 0x1b, 0,
1782 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1783 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1784 0x80, present ? 0x80 : 0);
1785 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1786 0x80, present ? 0x80 : 0);
1787}
1788
1789static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1790{
1791 /* Looks like the unsol event is incompatible with the standard
1792 * definition. 4bit tag is placed at 28 bit!
1793 */
1794 if ((res >> 28) == 0x01)
1795 alc880_lg_lw_automute(codec);
1796}
1797
1798/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001799 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001801
Linus Torvalds1da177e2005-04-16 15:20:36 -07001802static int alc_init(struct hda_codec *codec)
1803{
1804 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805 unsigned int i;
1806
1807 for (i = 0; i < spec->num_init_verbs; i++)
1808 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001809
1810 if (spec->init_hook)
1811 spec->init_hook(codec);
1812
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 return 0;
1814}
1815
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001816static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1817{
1818 struct alc_spec *spec = codec->spec;
1819
1820 if (spec->unsol_event)
1821 spec->unsol_event(codec, res);
1822}
1823
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824#ifdef CONFIG_PM
1825/*
1826 * resume
1827 */
1828static int alc_resume(struct hda_codec *codec)
1829{
1830 struct alc_spec *spec = codec->spec;
1831 int i;
1832
1833 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836 if (spec->multiout.dig_out_nid)
1837 snd_hda_resume_spdif_out(codec);
1838 if (spec->dig_in_nid)
1839 snd_hda_resume_spdif_in(codec);
1840
1841 return 0;
1842}
1843#endif
1844
1845/*
1846 * Analog playback callbacks
1847 */
1848static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1849 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001850 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001851{
1852 struct alc_spec *spec = codec->spec;
1853 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1854}
1855
1856static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1857 struct hda_codec *codec,
1858 unsigned int stream_tag,
1859 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001860 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001861{
1862 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001863 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1864 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865}
1866
1867static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1868 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001869 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870{
1871 struct alc_spec *spec = codec->spec;
1872 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1873}
1874
1875/*
1876 * Digital out
1877 */
1878static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1879 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001880 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881{
1882 struct alc_spec *spec = codec->spec;
1883 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1884}
1885
1886static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1887 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001888 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001889{
1890 struct alc_spec *spec = codec->spec;
1891 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1892}
1893
1894/*
1895 * Analog capture
1896 */
1897static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1898 struct hda_codec *codec,
1899 unsigned int stream_tag,
1900 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001901 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902{
1903 struct alc_spec *spec = codec->spec;
1904
1905 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1906 stream_tag, 0, format);
1907 return 0;
1908}
1909
1910static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1911 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001912 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913{
1914 struct alc_spec *spec = codec->spec;
1915
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001916 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1917 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 return 0;
1919}
1920
1921
1922/*
1923 */
1924static struct hda_pcm_stream alc880_pcm_analog_playback = {
1925 .substreams = 1,
1926 .channels_min = 2,
1927 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001928 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 .ops = {
1930 .open = alc880_playback_pcm_open,
1931 .prepare = alc880_playback_pcm_prepare,
1932 .cleanup = alc880_playback_pcm_cleanup
1933 },
1934};
1935
1936static struct hda_pcm_stream alc880_pcm_analog_capture = {
1937 .substreams = 2,
1938 .channels_min = 2,
1939 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001940 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941 .ops = {
1942 .prepare = alc880_capture_pcm_prepare,
1943 .cleanup = alc880_capture_pcm_cleanup
1944 },
1945};
1946
1947static struct hda_pcm_stream alc880_pcm_digital_playback = {
1948 .substreams = 1,
1949 .channels_min = 2,
1950 .channels_max = 2,
1951 /* NID is set in alc_build_pcms */
1952 .ops = {
1953 .open = alc880_dig_playback_pcm_open,
1954 .close = alc880_dig_playback_pcm_close
1955 },
1956};
1957
1958static struct hda_pcm_stream alc880_pcm_digital_capture = {
1959 .substreams = 1,
1960 .channels_min = 2,
1961 .channels_max = 2,
1962 /* NID is set in alc_build_pcms */
1963};
1964
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001965/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1966static struct hda_pcm_stream alc_pcm_null_playback = {
1967 .substreams = 0,
1968 .channels_min = 0,
1969 .channels_max = 0,
1970};
1971
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972static int alc_build_pcms(struct hda_codec *codec)
1973{
1974 struct alc_spec *spec = codec->spec;
1975 struct hda_pcm *info = spec->pcm_rec;
1976 int i;
1977
1978 codec->num_pcms = 1;
1979 codec->pcm_info = info;
1980
1981 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001982 if (spec->stream_analog_playback) {
1983 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1984 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1985 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1986 }
1987 if (spec->stream_analog_capture) {
1988 snd_assert(spec->adc_nids, return -EINVAL);
1989 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1990 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1991 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001992
Takashi Iwai4a471b72005-12-07 13:56:29 +01001993 if (spec->channel_mode) {
1994 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1995 for (i = 0; i < spec->num_channel_mode; i++) {
1996 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1997 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1998 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 }
2000 }
2001
Takashi Iwaie08a0072006-09-07 17:52:14 +02002002 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002003 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002004 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002005 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002007 if (spec->multiout.dig_out_nid &&
2008 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2010 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2011 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002012 if (spec->dig_in_nid &&
2013 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002014 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2015 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2016 }
2017 }
2018
Takashi Iwaie08a0072006-09-07 17:52:14 +02002019 /* If the use of more than one ADC is requested for the current
2020 * model, configure a second analog capture-only PCM.
2021 */
2022 /* Additional Analaog capture for index #2 */
2023 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2024 spec->adc_nids) {
2025 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002026 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002027 info->name = spec->stream_name_analog;
2028 /* No playback stream for second PCM */
2029 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2030 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2031 if (spec->stream_analog_capture) {
2032 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2033 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2034 }
2035 }
2036
Linus Torvalds1da177e2005-04-16 15:20:36 -07002037 return 0;
2038}
2039
2040static void alc_free(struct hda_codec *codec)
2041{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042 struct alc_spec *spec = codec->spec;
2043 unsigned int i;
2044
2045 if (! spec)
2046 return;
2047
2048 if (spec->kctl_alloc) {
2049 for (i = 0; i < spec->num_kctl_used; i++)
2050 kfree(spec->kctl_alloc[i].name);
2051 kfree(spec->kctl_alloc);
2052 }
2053 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054}
2055
2056/*
2057 */
2058static struct hda_codec_ops alc_patch_ops = {
2059 .build_controls = alc_build_controls,
2060 .build_pcms = alc_build_pcms,
2061 .init = alc_init,
2062 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002063 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064#ifdef CONFIG_PM
2065 .resume = alc_resume,
2066#endif
2067};
2068
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002069
2070/*
2071 * Test configuration for debugging
2072 *
2073 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2074 * enum controls.
2075 */
2076#ifdef CONFIG_SND_DEBUG
2077static hda_nid_t alc880_test_dac_nids[4] = {
2078 0x02, 0x03, 0x04, 0x05
2079};
2080
2081static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002082 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002083 .items = {
2084 { "In-1", 0x0 },
2085 { "In-2", 0x1 },
2086 { "In-3", 0x2 },
2087 { "In-4", 0x3 },
2088 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002089 { "Front", 0x5 },
2090 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002091 },
2092};
2093
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002094static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002095 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002096 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002097 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002098 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002099};
2100
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002101static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2102 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002103{
2104 static char *texts[] = {
2105 "N/A", "Line Out", "HP Out",
2106 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2107 };
2108 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2109 uinfo->count = 1;
2110 uinfo->value.enumerated.items = 8;
2111 if (uinfo->value.enumerated.item >= 8)
2112 uinfo->value.enumerated.item = 7;
2113 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2114 return 0;
2115}
2116
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002117static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2118 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002119{
2120 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2121 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2122 unsigned int pin_ctl, item = 0;
2123
2124 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2125 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2126 if (pin_ctl & AC_PINCTL_OUT_EN) {
2127 if (pin_ctl & AC_PINCTL_HP_EN)
2128 item = 2;
2129 else
2130 item = 1;
2131 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2132 switch (pin_ctl & AC_PINCTL_VREFEN) {
2133 case AC_PINCTL_VREF_HIZ: item = 3; break;
2134 case AC_PINCTL_VREF_50: item = 4; break;
2135 case AC_PINCTL_VREF_GRD: item = 5; break;
2136 case AC_PINCTL_VREF_80: item = 6; break;
2137 case AC_PINCTL_VREF_100: item = 7; break;
2138 }
2139 }
2140 ucontrol->value.enumerated.item[0] = item;
2141 return 0;
2142}
2143
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002144static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2145 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002146{
2147 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2148 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2149 static unsigned int ctls[] = {
2150 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2151 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2152 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2153 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2154 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2155 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2156 };
2157 unsigned int old_ctl, new_ctl;
2158
2159 old_ctl = snd_hda_codec_read(codec, nid, 0,
2160 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2161 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2162 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002163 snd_hda_codec_write(codec, nid, 0,
2164 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002165 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002166 (ucontrol->value.enumerated.item[0] >= 3 ?
2167 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002168 return 1;
2169 }
2170 return 0;
2171}
2172
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002173static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2174 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002175{
2176 static char *texts[] = {
2177 "Front", "Surround", "CLFE", "Side"
2178 };
2179 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2180 uinfo->count = 1;
2181 uinfo->value.enumerated.items = 4;
2182 if (uinfo->value.enumerated.item >= 4)
2183 uinfo->value.enumerated.item = 3;
2184 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2185 return 0;
2186}
2187
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002188static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2189 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002190{
2191 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2192 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2193 unsigned int sel;
2194
2195 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2196 ucontrol->value.enumerated.item[0] = sel & 3;
2197 return 0;
2198}
2199
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002200static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2201 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002202{
2203 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2204 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2205 unsigned int sel;
2206
2207 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2208 if (ucontrol->value.enumerated.item[0] != sel) {
2209 sel = ucontrol->value.enumerated.item[0] & 3;
2210 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2211 return 1;
2212 }
2213 return 0;
2214}
2215
2216#define PIN_CTL_TEST(xname,nid) { \
2217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2218 .name = xname, \
2219 .info = alc_test_pin_ctl_info, \
2220 .get = alc_test_pin_ctl_get, \
2221 .put = alc_test_pin_ctl_put, \
2222 .private_value = nid \
2223 }
2224
2225#define PIN_SRC_TEST(xname,nid) { \
2226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2227 .name = xname, \
2228 .info = alc_test_pin_src_info, \
2229 .get = alc_test_pin_src_get, \
2230 .put = alc_test_pin_src_put, \
2231 .private_value = nid \
2232 }
2233
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002234static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002235 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2236 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2237 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2238 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002239 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2240 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2241 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2242 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002243 PIN_CTL_TEST("Front Pin Mode", 0x14),
2244 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2245 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2246 PIN_CTL_TEST("Side Pin Mode", 0x17),
2247 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2248 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2249 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2250 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2251 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2252 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2253 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2254 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2255 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2256 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2257 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2258 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2259 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2260 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2261 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2262 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002265 {
2266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2267 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002268 .info = alc_ch_mode_info,
2269 .get = alc_ch_mode_get,
2270 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002271 },
2272 { } /* end */
2273};
2274
2275static struct hda_verb alc880_test_init_verbs[] = {
2276 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002285 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002286 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2289 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002290 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2293 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2294 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002295 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2298 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2299 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002300 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2305 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002306 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2308 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2309 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2310 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002311 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002313 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002315 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002317 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002318 /* Analog input/passthru */
2319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002324 { }
2325};
2326#endif
2327
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328/*
2329 */
2330
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002331static const char *alc880_models[ALC880_MODEL_LAST] = {
2332 [ALC880_3ST] = "3stack",
2333 [ALC880_TCL_S700] = "tcl",
2334 [ALC880_3ST_DIG] = "3stack-digout",
2335 [ALC880_CLEVO] = "clevo",
2336 [ALC880_5ST] = "5stack",
2337 [ALC880_5ST_DIG] = "5stack-digout",
2338 [ALC880_W810] = "w810",
2339 [ALC880_Z71V] = "z71v",
2340 [ALC880_6ST] = "6stack",
2341 [ALC880_6ST_DIG] = "6stack-digout",
2342 [ALC880_ASUS] = "asus",
2343 [ALC880_ASUS_W1V] = "asus-w1v",
2344 [ALC880_ASUS_DIG] = "asus-dig",
2345 [ALC880_ASUS_DIG2] = "asus-dig2",
2346 [ALC880_UNIWILL_DIG] = "uniwill",
2347 [ALC880_F1734] = "F1734",
2348 [ALC880_LG] = "lg",
2349 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002350#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002351 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002352#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002353 [ALC880_AUTO] = "auto",
2354};
2355
2356static struct snd_pci_quirk alc880_cfg_tbl[] = {
2357 /* Broken BIOS configuration */
2358 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2359 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2360
2361 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2362 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2363 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2364 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2365 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2366 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2367 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2368 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2369
2370 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2371 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2372
2373 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2374 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2375 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2376 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2377 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2378 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2379 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2380 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2381 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2382 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2383 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_5ST),
2384 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2385 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2386 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2387 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2388
2389 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2390 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2391 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2392 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2393 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2394 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2395 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2396 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2397 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2398 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2399 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2400 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2401 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2402 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2403 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2404 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2405 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2406 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2407
2408 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2409 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2410 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2411 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2412
2413 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2414 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2415 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2416
2417 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2418 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2419 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2420 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2421
2422 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2423 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2424 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2425 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2426 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2427 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2428 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2429 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2430 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2431 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2432 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002433
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 {}
2435};
2436
Takashi Iwai16ded522005-06-10 19:58:24 +02002437/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002438 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002439 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002440static struct alc_config_preset alc880_presets[] = {
2441 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 .mixers = { alc880_three_stack_mixer },
2443 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002444 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002445 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002446 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2447 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002448 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002449 .input_mux = &alc880_capture_source,
2450 },
2451 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452 .mixers = { alc880_three_stack_mixer },
2453 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002454 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002455 .dac_nids = alc880_dac_nids,
2456 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002457 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2458 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002459 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002460 .input_mux = &alc880_capture_source,
2461 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002462 [ALC880_TCL_S700] = {
2463 .mixers = { alc880_tcl_s700_mixer },
2464 .init_verbs = { alc880_volume_init_verbs,
2465 alc880_pin_tcl_S700_init_verbs,
2466 alc880_gpio2_init_verbs },
2467 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2468 .dac_nids = alc880_dac_nids,
2469 .hp_nid = 0x03,
2470 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2471 .channel_mode = alc880_2_jack_modes,
2472 .input_mux = &alc880_capture_source,
2473 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002474 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002475 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2476 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002477 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2478 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002479 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2480 .channel_mode = alc880_fivestack_modes,
2481 .input_mux = &alc880_capture_source,
2482 },
2483 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2485 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002486 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2487 .dac_nids = alc880_dac_nids,
2488 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002489 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2490 .channel_mode = alc880_fivestack_modes,
2491 .input_mux = &alc880_capture_source,
2492 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002493 [ALC880_6ST] = {
2494 .mixers = { alc880_six_stack_mixer },
2495 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2496 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2497 .dac_nids = alc880_6st_dac_nids,
2498 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2499 .channel_mode = alc880_sixstack_modes,
2500 .input_mux = &alc880_6stack_capture_source,
2501 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002502 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002503 .mixers = { alc880_six_stack_mixer },
2504 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002505 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2506 .dac_nids = alc880_6st_dac_nids,
2507 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002508 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2509 .channel_mode = alc880_sixstack_modes,
2510 .input_mux = &alc880_6stack_capture_source,
2511 },
2512 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002514 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2515 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002516 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2517 .dac_nids = alc880_w810_dac_nids,
2518 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002519 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2520 .channel_mode = alc880_w810_modes,
2521 .input_mux = &alc880_capture_source,
2522 },
2523 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002524 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002525 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002526 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2527 .dac_nids = alc880_z71v_dac_nids,
2528 .dig_out_nid = ALC880_DIGOUT_NID,
2529 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2531 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002532 .input_mux = &alc880_capture_source,
2533 },
2534 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 .mixers = { alc880_f1734_mixer },
2536 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2537 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2538 .dac_nids = alc880_f1734_dac_nids,
2539 .hp_nid = 0x02,
2540 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2541 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002542 .input_mux = &alc880_capture_source,
2543 },
2544 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545 .mixers = { alc880_asus_mixer },
2546 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2547 alc880_gpio1_init_verbs },
2548 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2549 .dac_nids = alc880_asus_dac_nids,
2550 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2551 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002552 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002553 .input_mux = &alc880_capture_source,
2554 },
2555 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002556 .mixers = { alc880_asus_mixer },
2557 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2558 alc880_gpio1_init_verbs },
2559 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2560 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002561 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002562 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2563 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002564 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002565 .input_mux = &alc880_capture_source,
2566 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002567 [ALC880_ASUS_DIG2] = {
2568 .mixers = { alc880_asus_mixer },
2569 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2570 alc880_gpio2_init_verbs }, /* use GPIO2 */
2571 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2572 .dac_nids = alc880_asus_dac_nids,
2573 .dig_out_nid = ALC880_DIGOUT_NID,
2574 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2575 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002576 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002577 .input_mux = &alc880_capture_source,
2578 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002579 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002580 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2581 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2582 alc880_gpio1_init_verbs },
2583 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2584 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002585 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002586 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2587 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002588 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002589 .input_mux = &alc880_capture_source,
2590 },
2591 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002592 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002593 .init_verbs = { alc880_volume_init_verbs,
2594 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2596 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002597 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2599 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002600 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002601 .input_mux = &alc880_capture_source,
2602 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002603 [ALC880_UNIWILL] = {
2604 .mixers = { alc880_uniwill_mixer },
2605 .init_verbs = { alc880_volume_init_verbs,
2606 alc880_uniwill_init_verbs },
2607 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2608 .dac_nids = alc880_asus_dac_nids,
2609 .dig_out_nid = ALC880_DIGOUT_NID,
2610 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2611 .channel_mode = alc880_threestack_modes,
2612 .need_dac_fix = 1,
2613 .input_mux = &alc880_capture_source,
2614 .unsol_event = alc880_uniwill_unsol_event,
2615 .init_hook = alc880_uniwill_automute,
2616 },
2617 [ALC880_UNIWILL_P53] = {
2618 .mixers = { alc880_uniwill_p53_mixer },
2619 .init_verbs = { alc880_volume_init_verbs,
2620 alc880_uniwill_p53_init_verbs },
2621 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2622 .dac_nids = alc880_asus_dac_nids,
2623 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2624 .channel_mode = alc880_w810_modes,
2625 .input_mux = &alc880_capture_source,
2626 .unsol_event = alc880_uniwill_p53_unsol_event,
2627 .init_hook = alc880_uniwill_p53_hp_automute,
2628 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002629 [ALC880_CLEVO] = {
2630 .mixers = { alc880_three_stack_mixer },
2631 .init_verbs = { alc880_volume_init_verbs,
2632 alc880_pin_clevo_init_verbs },
2633 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2634 .dac_nids = alc880_dac_nids,
2635 .hp_nid = 0x03,
2636 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2637 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002638 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002639 .input_mux = &alc880_capture_source,
2640 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002641 [ALC880_LG] = {
2642 .mixers = { alc880_lg_mixer },
2643 .init_verbs = { alc880_volume_init_verbs,
2644 alc880_lg_init_verbs },
2645 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2646 .dac_nids = alc880_lg_dac_nids,
2647 .dig_out_nid = ALC880_DIGOUT_NID,
2648 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2649 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002650 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002651 .input_mux = &alc880_lg_capture_source,
2652 .unsol_event = alc880_lg_unsol_event,
2653 .init_hook = alc880_lg_automute,
2654 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002655 [ALC880_LG_LW] = {
2656 .mixers = { alc880_lg_lw_mixer },
2657 .init_verbs = { alc880_volume_init_verbs,
2658 alc880_lg_lw_init_verbs },
2659 .num_dacs = 1,
2660 .dac_nids = alc880_dac_nids,
2661 .dig_out_nid = ALC880_DIGOUT_NID,
2662 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2663 .channel_mode = alc880_2_jack_modes,
2664 .input_mux = &alc880_lg_lw_capture_source,
2665 .unsol_event = alc880_lg_lw_unsol_event,
2666 .init_hook = alc880_lg_lw_automute,
2667 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002668#ifdef CONFIG_SND_DEBUG
2669 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 .mixers = { alc880_test_mixer },
2671 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2673 .dac_nids = alc880_test_dac_nids,
2674 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2676 .channel_mode = alc880_test_modes,
2677 .input_mux = &alc880_test_capture_source,
2678 },
2679#endif
2680};
2681
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682/*
2683 * Automatic parse of I/O pins from the BIOS configuration
2684 */
2685
2686#define NUM_CONTROL_ALLOC 32
2687#define NUM_VERB_ALLOC 32
2688
2689enum {
2690 ALC_CTL_WIDGET_VOL,
2691 ALC_CTL_WIDGET_MUTE,
2692 ALC_CTL_BIND_MUTE,
2693};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002694static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2696 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002697 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698};
2699
2700/* add dynamic controls */
2701static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2702{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002703 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704
2705 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2706 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2707
2708 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2709 if (! knew)
2710 return -ENOMEM;
2711 if (spec->kctl_alloc) {
2712 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2713 kfree(spec->kctl_alloc);
2714 }
2715 spec->kctl_alloc = knew;
2716 spec->num_kctl_alloc = num;
2717 }
2718
2719 knew = &spec->kctl_alloc[spec->num_kctl_used];
2720 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002721 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 if (! knew->name)
2723 return -ENOMEM;
2724 knew->private_value = val;
2725 spec->num_kctl_used++;
2726 return 0;
2727}
2728
2729#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2730#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2731#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2732#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2733#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2734#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2735#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2736#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2737#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2738#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2739#define ALC880_PIN_CD_NID 0x1c
2740
2741/* fill in the dac_nids table from the parsed pin configuration */
2742static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2743{
2744 hda_nid_t nid;
2745 int assigned[4];
2746 int i, j;
2747
2748 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002749 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750
2751 /* check the pins hardwired to audio widget */
2752 for (i = 0; i < cfg->line_outs; i++) {
2753 nid = cfg->line_out_pins[i];
2754 if (alc880_is_fixed_pin(nid)) {
2755 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002756 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002757 assigned[idx] = 1;
2758 }
2759 }
2760 /* left pins can be connect to any audio widget */
2761 for (i = 0; i < cfg->line_outs; i++) {
2762 nid = cfg->line_out_pins[i];
2763 if (alc880_is_fixed_pin(nid))
2764 continue;
2765 /* search for an empty channel */
2766 for (j = 0; j < cfg->line_outs; j++) {
2767 if (! assigned[j]) {
2768 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2769 assigned[j] = 1;
2770 break;
2771 }
2772 }
2773 }
2774 spec->multiout.num_dacs = cfg->line_outs;
2775 return 0;
2776}
2777
2778/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002779static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2780 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781{
2782 char name[32];
2783 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2784 hda_nid_t nid;
2785 int i, err;
2786
2787 for (i = 0; i < cfg->line_outs; i++) {
2788 if (! spec->multiout.dac_nids[i])
2789 continue;
2790 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2791 if (i == 2) {
2792 /* Center/LFE */
2793 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2794 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2795 return err;
2796 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2797 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2798 return err;
2799 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2800 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2801 return err;
2802 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2803 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2804 return err;
2805 } else {
2806 sprintf(name, "%s Playback Volume", chname[i]);
2807 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2808 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2809 return err;
2810 sprintf(name, "%s Playback Switch", chname[i]);
2811 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2812 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2813 return err;
2814 }
2815 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002816 return 0;
2817}
2818
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002819/* add playback controls for speaker and HP outputs */
2820static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2821 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822{
2823 hda_nid_t nid;
2824 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002825 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002826
2827 if (! pin)
2828 return 0;
2829
2830 if (alc880_is_fixed_pin(pin)) {
2831 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002832 /* specify the DAC as the extra output */
2833 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002834 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002835 else
2836 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 /* control HP volume/switch on the output mixer amp */
2838 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002839 sprintf(name, "%s Playback Volume", pfx);
2840 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002841 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2842 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002843 sprintf(name, "%s Playback Switch", pfx);
2844 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2846 return err;
2847 } else if (alc880_is_multi_pin(pin)) {
2848 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002850 sprintf(name, "%s Playback Switch", pfx);
2851 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2853 return err;
2854 }
2855 return 0;
2856}
2857
2858/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002859static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2860 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861{
2862 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002863 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002864
2865 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002867 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868 return err;
2869 sprintf(name, "%s Playback Switch", ctlname);
2870 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002871 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002872 return err;
2873 return 0;
2874}
2875
2876/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002877static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2878 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002879{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002880 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002881 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882
2883 for (i = 0; i < AUTO_PIN_LAST; i++) {
2884 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002885 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002886 err = new_analog_input(spec, cfg->input_pins[i],
2887 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002888 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002889 if (err < 0)
2890 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002891 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002892 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2893 imux->num_items++;
2894 }
2895 }
2896 return 0;
2897}
2898
Kailang Yangdf694da2005-12-05 19:42:22 +01002899static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2900 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901 int dac_idx)
2902{
2903 /* set as output */
2904 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2905 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2906 /* need the manual connection? */
2907 if (alc880_is_multi_pin(nid)) {
2908 struct alc_spec *spec = codec->spec;
2909 int idx = alc880_multi_pin_idx(nid);
2910 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2911 AC_VERB_SET_CONNECT_SEL,
2912 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2913 }
2914}
2915
2916static void alc880_auto_init_multi_out(struct hda_codec *codec)
2917{
2918 struct alc_spec *spec = codec->spec;
2919 int i;
2920
2921 for (i = 0; i < spec->autocfg.line_outs; i++) {
2922 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2923 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2924 }
2925}
2926
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002927static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928{
2929 struct alc_spec *spec = codec->spec;
2930 hda_nid_t pin;
2931
Takashi Iwai82bc9552006-03-21 11:24:42 +01002932 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002933 if (pin) /* connect to front */
2934 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002935 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002936 if (pin) /* connect to front */
2937 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2938}
2939
2940static void alc880_auto_init_analog_input(struct hda_codec *codec)
2941{
2942 struct alc_spec *spec = codec->spec;
2943 int i;
2944
2945 for (i = 0; i < AUTO_PIN_LAST; i++) {
2946 hda_nid_t nid = spec->autocfg.input_pins[i];
2947 if (alc880_is_input_pin(nid)) {
2948 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2949 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2950 if (nid != ALC880_PIN_CD_NID)
2951 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2952 AMP_OUT_MUTE);
2953 }
2954 }
2955}
2956
2957/* parse the BIOS configuration and set up the alc_spec */
2958/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2959static int alc880_parse_auto_config(struct hda_codec *codec)
2960{
2961 struct alc_spec *spec = codec->spec;
2962 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002963 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002964
Kailang Yangdf694da2005-12-05 19:42:22 +01002965 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2966 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002968 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002970
2971 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2972 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002973 (err = alc880_auto_create_extra_out(spec,
2974 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002975 "Speaker")) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002976 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002977 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2979 return err;
2980
2981 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2982
2983 if (spec->autocfg.dig_out_pin)
2984 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2985 if (spec->autocfg.dig_in_pin)
2986 spec->dig_in_nid = ALC880_DIGIN_NID;
2987
2988 if (spec->kctl_alloc)
2989 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2990
2991 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2992
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002993 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994 spec->input_mux = &spec->private_imux;
2995
2996 return 1;
2997}
2998
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002999/* additional initialization for auto-configuration model */
3000static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003001{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003003 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005}
3006
3007/*
3008 * OK, here we have finally the patch for ALC880
3009 */
3010
Linus Torvalds1da177e2005-04-16 15:20:36 -07003011static int patch_alc880(struct hda_codec *codec)
3012{
3013 struct alc_spec *spec;
3014 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003015 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003016
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003017 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003018 if (spec == NULL)
3019 return -ENOMEM;
3020
3021 codec->spec = spec;
3022
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003023 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3024 alc880_models,
3025 alc880_cfg_tbl);
3026 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003027 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3028 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003029 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003030 }
3031
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003032 if (board_config == ALC880_AUTO) {
3033 /* automatic parse from the BIOS config */
3034 err = alc880_parse_auto_config(codec);
3035 if (err < 0) {
3036 alc_free(codec);
3037 return err;
3038 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003039 printk(KERN_INFO
3040 "hda_codec: Cannot set up configuration "
3041 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042 board_config = ALC880_3ST;
3043 }
3044 }
3045
Kailang Yangdf694da2005-12-05 19:42:22 +01003046 if (board_config != ALC880_AUTO)
3047 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003048
3049 spec->stream_name_analog = "ALC880 Analog";
3050 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3051 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3052
3053 spec->stream_name_digital = "ALC880 Digital";
3054 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3055 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3056
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057 if (! spec->adc_nids && spec->input_mux) {
3058 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003059 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3061 if (wcap != AC_WID_AUD_IN) {
3062 spec->adc_nids = alc880_adc_nids_alt;
3063 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3064 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3065 spec->num_mixers++;
3066 } else {
3067 spec->adc_nids = alc880_adc_nids;
3068 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3069 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3070 spec->num_mixers++;
3071 }
3072 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073
3074 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003075 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003076 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077
3078 return 0;
3079}
3080
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082/*
3083 * ALC260 support
3084 */
3085
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086static hda_nid_t alc260_dac_nids[1] = {
3087 /* front */
3088 0x02,
3089};
3090
3091static hda_nid_t alc260_adc_nids[1] = {
3092 /* ADC0 */
3093 0x04,
3094};
3095
Kailang Yangdf694da2005-12-05 19:42:22 +01003096static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 /* ADC1 */
3098 0x05,
3099};
3100
Kailang Yangdf694da2005-12-05 19:42:22 +01003101static hda_nid_t alc260_hp_adc_nids[2] = {
3102 /* ADC1, 0 */
3103 0x05, 0x04
3104};
3105
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003106/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3107 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3108 */
3109static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003110 /* ADC0, ADC1 */
3111 0x04, 0x05
3112};
3113
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003114#define ALC260_DIGOUT_NID 0x03
3115#define ALC260_DIGIN_NID 0x06
3116
3117static struct hda_input_mux alc260_capture_source = {
3118 .num_items = 4,
3119 .items = {
3120 { "Mic", 0x0 },
3121 { "Front Mic", 0x1 },
3122 { "Line", 0x2 },
3123 { "CD", 0x4 },
3124 },
3125};
3126
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003127/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003128 * headphone jack and the internal CD lines since these are the only pins at
3129 * which audio can appear. For flexibility, also allow the option of
3130 * recording the mixer output on the second ADC (ADC0 doesn't have a
3131 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003132 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003133static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3134 {
3135 .num_items = 3,
3136 .items = {
3137 { "Mic/Line", 0x0 },
3138 { "CD", 0x4 },
3139 { "Headphone", 0x2 },
3140 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003141 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003142 {
3143 .num_items = 4,
3144 .items = {
3145 { "Mic/Line", 0x0 },
3146 { "CD", 0x4 },
3147 { "Headphone", 0x2 },
3148 { "Mixer", 0x5 },
3149 },
3150 },
3151
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003152};
3153
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003154/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3155 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003156 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003157static struct hda_input_mux alc260_acer_capture_sources[2] = {
3158 {
3159 .num_items = 4,
3160 .items = {
3161 { "Mic", 0x0 },
3162 { "Line", 0x2 },
3163 { "CD", 0x4 },
3164 { "Headphone", 0x5 },
3165 },
3166 },
3167 {
3168 .num_items = 5,
3169 .items = {
3170 { "Mic", 0x0 },
3171 { "Line", 0x2 },
3172 { "CD", 0x4 },
3173 { "Headphone", 0x6 },
3174 { "Mixer", 0x5 },
3175 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003176 },
3177};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003178/*
3179 * This is just place-holder, so there's something for alc_build_pcms to look
3180 * at when it calculates the maximum number of channels. ALC260 has no mixer
3181 * element which allows changing the channel mode, so the verb list is
3182 * never used.
3183 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003184static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003185 { 2, NULL },
3186};
3187
Kailang Yangdf694da2005-12-05 19:42:22 +01003188
3189/* Mixer combinations
3190 *
3191 * basic: base_output + input + pc_beep + capture
3192 * HP: base_output + input + capture_alt
3193 * HP_3013: hp_3013 + input + capture
3194 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003195 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003196 */
3197
3198static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003199 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003200 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3202 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3203 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3204 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3205 { } /* end */
3206};
3207
3208static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003209 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3210 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3211 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3212 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3214 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003217 { } /* end */
3218};
3219
Kailang Yangdf694da2005-12-05 19:42:22 +01003220static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3221 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3222 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3223 { } /* end */
3224};
3225
3226static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3227 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3228 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3229 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3230 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3231 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3233 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3234 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003235 { } /* end */
3236};
3237
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003238/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3239 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3240 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003241static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003242 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003243 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003244 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003245 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3246 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3247 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3248 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003249 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003250 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3251 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3252 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003253 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003254 { } /* end */
3255};
3256
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003257/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3258 * versions of the ALC260 don't act on requests to enable mic bias from NID
3259 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3260 * datasheet doesn't mention this restriction. At this stage it's not clear
3261 * whether this behaviour is intentional or is a hardware bug in chip
3262 * revisions available in early 2006. Therefore for now allow the
3263 * "Headphone Jack Mode" control to span all choices, but if it turns out
3264 * that the lack of mic bias for this NID is intentional we could change the
3265 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3266 *
3267 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3268 * don't appear to make the mic bias available from the "line" jack, even
3269 * though the NID used for this jack (0x14) can supply it. The theory is
3270 * that perhaps Acer have included blocking capacitors between the ALC260
3271 * and the output jack. If this turns out to be the case for all such
3272 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3273 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003274 *
3275 * The C20x Tablet series have a mono internal speaker which is controlled
3276 * via the chip's Mono sum widget and pin complex, so include the necessary
3277 * controls for such models. On models without a "mono speaker" the control
3278 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003279 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003280static struct snd_kcontrol_new alc260_acer_mixer[] = {
3281 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3282 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003283 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003284 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3285 HDA_OUTPUT),
3286 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3287 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003288 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3289 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3291 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3292 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3293 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3294 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3295 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3296 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3297 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3298 { } /* end */
3299};
3300
Kailang Yangdf694da2005-12-05 19:42:22 +01003301/* capture mixer elements */
3302static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003303 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3304 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003305 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3306 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003307 {
3308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003309 /* The multiple "Capture Source" controls confuse alsamixer
3310 * So call somewhat different..
3311 * FIXME: the controls appear in the "playback" view!
3312 */
3313 /* .name = "Capture Source", */
3314 .name = "Input Source",
3315 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003316 .info = alc_mux_enum_info,
3317 .get = alc_mux_enum_get,
3318 .put = alc_mux_enum_put,
3319 },
3320 { } /* end */
3321};
3322
Kailang Yangdf694da2005-12-05 19:42:22 +01003323static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3324 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3325 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3326 {
3327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3328 /* The multiple "Capture Source" controls confuse alsamixer
3329 * So call somewhat different..
3330 * FIXME: the controls appear in the "playback" view!
3331 */
3332 /* .name = "Capture Source", */
3333 .name = "Input Source",
3334 .count = 1,
3335 .info = alc_mux_enum_info,
3336 .get = alc_mux_enum_get,
3337 .put = alc_mux_enum_put,
3338 },
3339 { } /* end */
3340};
3341
3342/*
3343 * initialization verbs
3344 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345static struct hda_verb alc260_init_verbs[] = {
3346 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003349 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003351 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003352 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003353 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003354 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003356 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003357 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003358 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003359 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003360 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003361 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003363 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3364 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003365 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003366 /* set connection select to line in (default select for this ADC) */
3367 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003368 /* mute capture amp left and right */
3369 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3370 /* set connection select to line in (default select for this ADC) */
3371 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003372 /* set vol=0 Line-Out mixer amp left and right */
3373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3374 /* unmute pin widget amp left and right (no gain on this amp) */
3375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3376 /* set vol=0 HP mixer amp left and right */
3377 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3378 /* unmute pin widget amp left and right (no gain on this amp) */
3379 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3380 /* set vol=0 Mono mixer amp left and right */
3381 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3382 /* unmute pin widget amp left and right (no gain on this amp) */
3383 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3384 /* unmute LINE-2 out pin */
3385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003387 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003389 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003391 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003394 /* mute Front out path */
3395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3397 /* mute Headphone out path */
3398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3400 /* mute Mono out path */
3401 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3402 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003403 { }
3404};
3405
Takashi Iwai474167d2006-05-17 17:17:43 +02003406#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003407static struct hda_verb alc260_hp_init_verbs[] = {
3408 /* Headphone and output */
3409 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3410 /* mono output */
3411 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3412 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3413 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3414 /* Mic2 (front panel) pin widget for input and vref at 80% */
3415 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3416 /* Line In pin widget for input */
3417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3418 /* Line-2 pin widget for output */
3419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3420 /* CD pin widget for input */
3421 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3422 /* unmute amp left and right */
3423 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3424 /* set connection select to line in (default select for this ADC) */
3425 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3426 /* unmute Line-Out mixer amp left and right (volume = 0) */
3427 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3428 /* mute pin widget amp left and right (no gain on this amp) */
3429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3430 /* unmute HP mixer amp left and right (volume = 0) */
3431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3432 /* mute pin widget amp left and right (no gain on this amp) */
3433 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3434 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3435 /* unmute CD */
3436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3437 /* unmute Line In */
3438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3439 /* unmute Mic */
3440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3441 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3442 /* Unmute Front out path */
3443 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3445 /* Unmute Headphone out path */
3446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3448 /* Unmute Mono out path */
3449 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3450 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3451 { }
3452};
Takashi Iwai474167d2006-05-17 17:17:43 +02003453#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003454
3455static struct hda_verb alc260_hp_3013_init_verbs[] = {
3456 /* Line out and output */
3457 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3458 /* mono output */
3459 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3460 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3461 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3462 /* Mic2 (front panel) pin widget for input and vref at 80% */
3463 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3464 /* Line In pin widget for input */
3465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3466 /* Headphone pin widget for output */
3467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3468 /* CD pin widget for input */
3469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3470 /* unmute amp left and right */
3471 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3472 /* set connection select to line in (default select for this ADC) */
3473 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3474 /* unmute Line-Out mixer amp left and right (volume = 0) */
3475 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3476 /* mute pin widget amp left and right (no gain on this amp) */
3477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3478 /* unmute HP mixer amp left and right (volume = 0) */
3479 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3480 /* mute pin widget amp left and right (no gain on this amp) */
3481 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3482 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3483 /* unmute CD */
3484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3485 /* unmute Line In */
3486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3487 /* unmute Mic */
3488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3489 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3490 /* Unmute Front out path */
3491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3493 /* Unmute Headphone out path */
3494 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3496 /* Unmute Mono out path */
3497 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3498 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3499 { }
3500};
3501
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003502/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003503 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3504 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003505 */
3506static struct hda_verb alc260_fujitsu_init_verbs[] = {
3507 /* Disable all GPIOs */
3508 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3509 /* Internal speaker is connected to headphone pin */
3510 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3511 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003513 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3514 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3515 /* Ensure all other unused pins are disabled and muted. */
3516 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003518 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003519 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003520 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003521 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003524
Jonathan Woithef7ace402006-02-28 11:46:14 +01003525 /* Disable digital (SPDIF) pins */
3526 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3527 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003528
Jonathan Woithef7ace402006-02-28 11:46:14 +01003529 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3530 * when acting as an output.
3531 */
3532 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3533
3534 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3541 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3542 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003544
Jonathan Woithef7ace402006-02-28 11:46:14 +01003545 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3546 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3547 /* Unmute Line1 pin widget output buffer since it starts as an output.
3548 * If the pin mode is changed by the user the pin mode control will
3549 * take care of enabling the pin's input/output buffers as needed.
3550 * Therefore there's no need to enable the input buffer at this
3551 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003552 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003553 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003554 /* Unmute input buffer of pin widget used for Line-in (no equiv
3555 * mixer ctrl)
3556 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003557 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003558
Jonathan Woithef7ace402006-02-28 11:46:14 +01003559 /* Mute capture amp left and right */
3560 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3561 /* Set ADC connection select to match default mixer setting - line
3562 * in (on mic1 pin)
3563 */
3564 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003565
Jonathan Woithef7ace402006-02-28 11:46:14 +01003566 /* Do the same for the second ADC: mute capture input amp and
3567 * set ADC connection to line in (on mic1 pin)
3568 */
3569 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3570 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003571
Jonathan Woithef7ace402006-02-28 11:46:14 +01003572 /* Mute all inputs to mixer widget (even unconnected ones) */
3573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003581
3582 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003583};
3584
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003585/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3586 * similar laptops (adapted from Fujitsu init verbs).
3587 */
3588static struct hda_verb alc260_acer_init_verbs[] = {
3589 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3590 * the headphone jack. Turn this on and rely on the standard mute
3591 * methods whenever the user wants to turn these outputs off.
3592 */
3593 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3594 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3595 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3596 /* Internal speaker/Headphone jack is connected to Line-out pin */
3597 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3598 /* Internal microphone/Mic jack is connected to Mic1 pin */
3599 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3600 /* Line In jack is connected to Line1 pin */
3601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003602 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3603 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003604 /* Ensure all other unused pins are disabled and muted. */
3605 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3606 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003607 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3608 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3611 /* Disable digital (SPDIF) pins */
3612 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3613 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3614
3615 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3616 * bus when acting as outputs.
3617 */
3618 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3619 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3620
3621 /* Start with output sum widgets muted and their output gains at min */
3622 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3623 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3625 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3628 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3629 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3630 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3631
3632 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3633 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003634 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3635 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003636 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3637 * inputs. If the pin mode is changed by the user the pin mode control
3638 * will take care of enabling the pin's input/output buffers as needed.
3639 * Therefore there's no need to enable the input buffer at this
3640 * stage.
3641 */
3642 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3644
3645 /* Mute capture amp left and right */
3646 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3647 /* Set ADC connection select to match default mixer setting - mic
3648 * (on mic1 pin)
3649 */
3650 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3651
3652 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003653 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003654 */
3655 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003656 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003657
3658 /* Mute all inputs to mixer widget (even unconnected ones) */
3659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3667
3668 { }
3669};
3670
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003671/* Test configuration for debugging, modelled after the ALC880 test
3672 * configuration.
3673 */
3674#ifdef CONFIG_SND_DEBUG
3675static hda_nid_t alc260_test_dac_nids[1] = {
3676 0x02,
3677};
3678static hda_nid_t alc260_test_adc_nids[2] = {
3679 0x04, 0x05,
3680};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003681/* For testing the ALC260, each input MUX needs its own definition since
3682 * the signal assignments are different. This assumes that the first ADC
3683 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003684 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003685static struct hda_input_mux alc260_test_capture_sources[2] = {
3686 {
3687 .num_items = 7,
3688 .items = {
3689 { "MIC1 pin", 0x0 },
3690 { "MIC2 pin", 0x1 },
3691 { "LINE1 pin", 0x2 },
3692 { "LINE2 pin", 0x3 },
3693 { "CD pin", 0x4 },
3694 { "LINE-OUT pin", 0x5 },
3695 { "HP-OUT pin", 0x6 },
3696 },
3697 },
3698 {
3699 .num_items = 8,
3700 .items = {
3701 { "MIC1 pin", 0x0 },
3702 { "MIC2 pin", 0x1 },
3703 { "LINE1 pin", 0x2 },
3704 { "LINE2 pin", 0x3 },
3705 { "CD pin", 0x4 },
3706 { "Mixer", 0x5 },
3707 { "LINE-OUT pin", 0x6 },
3708 { "HP-OUT pin", 0x7 },
3709 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003710 },
3711};
3712static struct snd_kcontrol_new alc260_test_mixer[] = {
3713 /* Output driver widgets */
3714 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3715 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3716 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3717 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3718 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3719 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3720
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003721 /* Modes for retasking pin widgets
3722 * Note: the ALC260 doesn't seem to act on requests to enable mic
3723 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3724 * mention this restriction. At this stage it's not clear whether
3725 * this behaviour is intentional or is a hardware bug in chip
3726 * revisions available at least up until early 2006. Therefore for
3727 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3728 * choices, but if it turns out that the lack of mic bias for these
3729 * NIDs is intentional we could change their modes from
3730 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3731 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003732 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3733 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3734 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3735 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3736 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3737 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3738
3739 /* Loopback mixer controls */
3740 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3741 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3742 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3743 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3744 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3745 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3746 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3747 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3748 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3749 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3750 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3751 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3752 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3753 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3754 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3755 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003756
3757 /* Controls for GPIO pins, assuming they are configured as outputs */
3758 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3759 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3760 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3761 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3762
Jonathan Woithe92621f12006-02-28 11:47:47 +01003763 /* Switches to allow the digital IO pins to be enabled. The datasheet
3764 * is ambigious as to which NID is which; testing on laptops which
3765 * make this output available should provide clarification.
3766 */
3767 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3768 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3769
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003770 { } /* end */
3771};
3772static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003773 /* Enable all GPIOs as outputs with an initial value of 0 */
3774 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3775 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3776 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3777
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003778 /* Enable retasking pins as output, initially without power amp */
3779 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3780 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3783 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3784 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3785
Jonathan Woithe92621f12006-02-28 11:47:47 +01003786 /* Disable digital (SPDIF) pins initially, but users can enable
3787 * them via a mixer switch. In the case of SPDIF-out, this initverb
3788 * payload also sets the generation to 0, output to be in "consumer"
3789 * PCM format, copyright asserted, no pre-emphasis and no validity
3790 * control.
3791 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003792 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3793 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3794
Jonathan Woithef7ace402006-02-28 11:46:14 +01003795 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003796 * OUT1 sum bus when acting as an output.
3797 */
3798 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3799 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3800 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3801 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3802
3803 /* Start with output sum widgets muted and their output gains at min */
3804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3808 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3810 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3811 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3812 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3813
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003814 /* Unmute retasking pin widget output buffers since the default
3815 * state appears to be output. As the pin mode is changed by the
3816 * user the pin mode control will take care of enabling the pin's
3817 * input/output buffers as needed.
3818 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003819 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3823 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3824 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3825 /* Also unmute the mono-out pin widget */
3826 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3827
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003828 /* Mute capture amp left and right */
3829 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003830 /* Set ADC connection select to match default mixer setting (mic1
3831 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003832 */
3833 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3834
3835 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003836 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003837 */
3838 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3839 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3840
3841 /* Mute all inputs to mixer widget (even unconnected ones) */
3842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3850
3851 { }
3852};
3853#endif
3854
Linus Torvalds1da177e2005-04-16 15:20:36 -07003855static struct hda_pcm_stream alc260_pcm_analog_playback = {
3856 .substreams = 1,
3857 .channels_min = 2,
3858 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003859};
3860
3861static struct hda_pcm_stream alc260_pcm_analog_capture = {
3862 .substreams = 1,
3863 .channels_min = 2,
3864 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003865};
3866
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003867#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3868#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3869
Kailang Yangdf694da2005-12-05 19:42:22 +01003870/*
3871 * for BIOS auto-configuration
3872 */
3873
3874static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3875 const char *pfx)
3876{
3877 hda_nid_t nid_vol;
3878 unsigned long vol_val, sw_val;
3879 char name[32];
3880 int err;
3881
3882 if (nid >= 0x0f && nid < 0x11) {
3883 nid_vol = nid - 0x7;
3884 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3885 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3886 } else if (nid == 0x11) {
3887 nid_vol = nid - 0x7;
3888 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3889 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3890 } else if (nid >= 0x12 && nid <= 0x15) {
3891 nid_vol = 0x08;
3892 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3893 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3894 } else
3895 return 0; /* N/A */
3896
3897 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3898 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3899 return err;
3900 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3901 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3902 return err;
3903 return 1;
3904}
3905
3906/* add playback controls from the parsed DAC table */
3907static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3908 const struct auto_pin_cfg *cfg)
3909{
3910 hda_nid_t nid;
3911 int err;
3912
3913 spec->multiout.num_dacs = 1;
3914 spec->multiout.dac_nids = spec->private_dac_nids;
3915 spec->multiout.dac_nids[0] = 0x02;
3916
3917 nid = cfg->line_out_pins[0];
3918 if (nid) {
3919 err = alc260_add_playback_controls(spec, nid, "Front");
3920 if (err < 0)
3921 return err;
3922 }
3923
Takashi Iwai82bc9552006-03-21 11:24:42 +01003924 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003925 if (nid) {
3926 err = alc260_add_playback_controls(spec, nid, "Speaker");
3927 if (err < 0)
3928 return err;
3929 }
3930
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003931 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003932 if (nid) {
3933 err = alc260_add_playback_controls(spec, nid, "Headphone");
3934 if (err < 0)
3935 return err;
3936 }
3937 return 0;
3938}
3939
3940/* create playback/capture controls for input pins */
3941static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3942 const struct auto_pin_cfg *cfg)
3943{
Kailang Yangdf694da2005-12-05 19:42:22 +01003944 struct hda_input_mux *imux = &spec->private_imux;
3945 int i, err, idx;
3946
3947 for (i = 0; i < AUTO_PIN_LAST; i++) {
3948 if (cfg->input_pins[i] >= 0x12) {
3949 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003950 err = new_analog_input(spec, cfg->input_pins[i],
3951 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003952 if (err < 0)
3953 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003954 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003955 imux->items[imux->num_items].index = idx;
3956 imux->num_items++;
3957 }
3958 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3959 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003960 err = new_analog_input(spec, cfg->input_pins[i],
3961 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003962 if (err < 0)
3963 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003964 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003965 imux->items[imux->num_items].index = idx;
3966 imux->num_items++;
3967 }
3968 }
3969 return 0;
3970}
3971
3972static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3973 hda_nid_t nid, int pin_type,
3974 int sel_idx)
3975{
3976 /* set as output */
3977 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3978 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3979 /* need the manual connection? */
3980 if (nid >= 0x12) {
3981 int idx = nid - 0x12;
3982 snd_hda_codec_write(codec, idx + 0x0b, 0,
3983 AC_VERB_SET_CONNECT_SEL, sel_idx);
3984
3985 }
3986}
3987
3988static void alc260_auto_init_multi_out(struct hda_codec *codec)
3989{
3990 struct alc_spec *spec = codec->spec;
3991 hda_nid_t nid;
3992
3993 nid = spec->autocfg.line_out_pins[0];
3994 if (nid)
3995 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3996
Takashi Iwai82bc9552006-03-21 11:24:42 +01003997 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003998 if (nid)
3999 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4000
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004001 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004002 if (nid)
4003 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4004}
4005
4006#define ALC260_PIN_CD_NID 0x16
4007static void alc260_auto_init_analog_input(struct hda_codec *codec)
4008{
4009 struct alc_spec *spec = codec->spec;
4010 int i;
4011
4012 for (i = 0; i < AUTO_PIN_LAST; i++) {
4013 hda_nid_t nid = spec->autocfg.input_pins[i];
4014 if (nid >= 0x12) {
4015 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4016 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4017 if (nid != ALC260_PIN_CD_NID)
4018 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4019 AMP_OUT_MUTE);
4020 }
4021 }
4022}
4023
4024/*
4025 * generic initialization of ADC, input mixers and output mixers
4026 */
4027static struct hda_verb alc260_volume_init_verbs[] = {
4028 /*
4029 * Unmute ADC0-1 and set the default input to mic-in
4030 */
4031 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4033 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4034 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4035
4036 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4037 * mixer widget
4038 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4039 * mic (mic 2)
4040 */
4041 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4043 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4044 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4047
4048 /*
4049 * Set up output mixers (0x08 - 0x0a)
4050 */
4051 /* set vol=0 to output mixers */
4052 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4053 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4054 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4055 /* set up input amps for analog loopback */
4056 /* Amp Indices: DAC = 0, mixer = 1 */
4057 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4061 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4062 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4063
4064 { }
4065};
4066
4067static int alc260_parse_auto_config(struct hda_codec *codec)
4068{
4069 struct alc_spec *spec = codec->spec;
4070 unsigned int wcap;
4071 int err;
4072 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4073
4074 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4075 alc260_ignore)) < 0)
4076 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004077 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4078 return err;
4079 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004080 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004081 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004082 return err;
4083
4084 spec->multiout.max_channels = 2;
4085
4086 if (spec->autocfg.dig_out_pin)
4087 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4088 if (spec->kctl_alloc)
4089 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4090
4091 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4092
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004093 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004094 spec->input_mux = &spec->private_imux;
4095
4096 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004097 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004098 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4099 if (wcap != AC_WID_AUD_IN) {
4100 spec->adc_nids = alc260_adc_nids_alt;
4101 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4102 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004103 } else {
4104 spec->adc_nids = alc260_adc_nids;
4105 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4106 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004107 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004108 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004109
4110 return 1;
4111}
4112
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004113/* additional initialization for auto-configuration model */
4114static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004115{
Kailang Yangdf694da2005-12-05 19:42:22 +01004116 alc260_auto_init_multi_out(codec);
4117 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004118}
4119
4120/*
4121 * ALC260 configurations
4122 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004123static const char *alc260_models[ALC260_MODEL_LAST] = {
4124 [ALC260_BASIC] = "basic",
4125 [ALC260_HP] = "hp",
4126 [ALC260_HP_3013] = "hp-3013",
4127 [ALC260_FUJITSU_S702X] = "fujitsu",
4128 [ALC260_ACER] = "acer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004129#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004130 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004131#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004132 [ALC260_AUTO] = "auto",
4133};
4134
4135static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004136 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004137 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4138 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4139 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4140 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4141 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4142 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4143 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4144 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4145 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4146 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4147 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4148 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4149 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Takashi Iwai16ded522005-06-10 19:58:24 +02004150 {}
4151};
4152
Kailang Yangdf694da2005-12-05 19:42:22 +01004153static struct alc_config_preset alc260_presets[] = {
4154 [ALC260_BASIC] = {
4155 .mixers = { alc260_base_output_mixer,
4156 alc260_input_mixer,
4157 alc260_pc_beep_mixer,
4158 alc260_capture_mixer },
4159 .init_verbs = { alc260_init_verbs },
4160 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4161 .dac_nids = alc260_dac_nids,
4162 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4163 .adc_nids = alc260_adc_nids,
4164 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4165 .channel_mode = alc260_modes,
4166 .input_mux = &alc260_capture_source,
4167 },
4168 [ALC260_HP] = {
4169 .mixers = { alc260_base_output_mixer,
4170 alc260_input_mixer,
4171 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004172 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004173 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4174 .dac_nids = alc260_dac_nids,
4175 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4176 .adc_nids = alc260_hp_adc_nids,
4177 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4178 .channel_mode = alc260_modes,
4179 .input_mux = &alc260_capture_source,
4180 },
4181 [ALC260_HP_3013] = {
4182 .mixers = { alc260_hp_3013_mixer,
4183 alc260_input_mixer,
4184 alc260_capture_alt_mixer },
4185 .init_verbs = { alc260_hp_3013_init_verbs },
4186 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4187 .dac_nids = alc260_dac_nids,
4188 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4189 .adc_nids = alc260_hp_adc_nids,
4190 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4191 .channel_mode = alc260_modes,
4192 .input_mux = &alc260_capture_source,
4193 },
4194 [ALC260_FUJITSU_S702X] = {
4195 .mixers = { alc260_fujitsu_mixer,
4196 alc260_capture_mixer },
4197 .init_verbs = { alc260_fujitsu_init_verbs },
4198 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4199 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004200 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4201 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004202 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4203 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004204 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4205 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004206 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004207 [ALC260_ACER] = {
4208 .mixers = { alc260_acer_mixer,
4209 alc260_capture_mixer },
4210 .init_verbs = { alc260_acer_init_verbs },
4211 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4212 .dac_nids = alc260_dac_nids,
4213 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4214 .adc_nids = alc260_dual_adc_nids,
4215 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4216 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004217 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4218 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004219 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004220#ifdef CONFIG_SND_DEBUG
4221 [ALC260_TEST] = {
4222 .mixers = { alc260_test_mixer,
4223 alc260_capture_mixer },
4224 .init_verbs = { alc260_test_init_verbs },
4225 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4226 .dac_nids = alc260_test_dac_nids,
4227 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4228 .adc_nids = alc260_test_adc_nids,
4229 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4230 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004231 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4232 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004233 },
4234#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004235};
4236
Linus Torvalds1da177e2005-04-16 15:20:36 -07004237static int patch_alc260(struct hda_codec *codec)
4238{
4239 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004240 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004241
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004242 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243 if (spec == NULL)
4244 return -ENOMEM;
4245
4246 codec->spec = spec;
4247
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004248 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4249 alc260_models,
4250 alc260_cfg_tbl);
4251 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004252 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4253 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004254 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004255 }
4256
Kailang Yangdf694da2005-12-05 19:42:22 +01004257 if (board_config == ALC260_AUTO) {
4258 /* automatic parse from the BIOS config */
4259 err = alc260_parse_auto_config(codec);
4260 if (err < 0) {
4261 alc_free(codec);
4262 return err;
4263 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004264 printk(KERN_INFO
4265 "hda_codec: Cannot set up configuration "
4266 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004267 board_config = ALC260_BASIC;
4268 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004269 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004270
Kailang Yangdf694da2005-12-05 19:42:22 +01004271 if (board_config != ALC260_AUTO)
4272 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004273
4274 spec->stream_name_analog = "ALC260 Analog";
4275 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4276 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4277
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004278 spec->stream_name_digital = "ALC260 Digital";
4279 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4280 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4281
Linus Torvalds1da177e2005-04-16 15:20:36 -07004282 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004283 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004284 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004285
4286 return 0;
4287}
4288
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289
Linus Torvalds1da177e2005-04-16 15:20:36 -07004290/*
4291 * ALC882 support
4292 *
4293 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4294 * configuration. Each pin widget can choose any input DACs and a mixer.
4295 * Each ADC is connected from a mixer of all inputs. This makes possible
4296 * 6-channel independent captures.
4297 *
4298 * In addition, an independent DAC for the multi-playback (not used in this
4299 * driver yet).
4300 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004301#define ALC882_DIGOUT_NID 0x06
4302#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004303
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004304static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004305 { 8, NULL }
4306};
4307
4308static hda_nid_t alc882_dac_nids[4] = {
4309 /* front, rear, clfe, rear_surr */
4310 0x02, 0x03, 0x04, 0x05
4311};
4312
Kailang Yangdf694da2005-12-05 19:42:22 +01004313/* identical with ALC880 */
4314#define alc882_adc_nids alc880_adc_nids
4315#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004316
4317/* input MUX */
4318/* FIXME: should be a matrix-type input source selection */
4319
4320static struct hda_input_mux alc882_capture_source = {
4321 .num_items = 4,
4322 .items = {
4323 { "Mic", 0x0 },
4324 { "Front Mic", 0x1 },
4325 { "Line", 0x2 },
4326 { "CD", 0x4 },
4327 },
4328};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004329#define alc882_mux_enum_info alc_mux_enum_info
4330#define alc882_mux_enum_get alc_mux_enum_get
4331
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004332static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004333{
4334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4335 struct alc_spec *spec = codec->spec;
4336 const struct hda_input_mux *imux = spec->input_mux;
4337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4338 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4339 hda_nid_t nid = capture_mixers[adc_idx];
4340 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4341 unsigned int i, idx;
4342
4343 idx = ucontrol->value.enumerated.item[0];
4344 if (idx >= imux->num_items)
4345 idx = imux->num_items - 1;
4346 if (*cur_val == idx && ! codec->in_resume)
4347 return 0;
4348 for (i = 0; i < imux->num_items; i++) {
4349 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4350 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4351 v | (imux->items[i].index << 8));
4352 }
4353 *cur_val = idx;
4354 return 1;
4355}
4356
Kailang Yangdf694da2005-12-05 19:42:22 +01004357/*
4358 * 6ch mode
4359 */
4360static struct hda_verb alc882_sixstack_ch6_init[] = {
4361 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4362 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4363 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4364 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4365 { } /* end */
4366};
4367
4368/*
4369 * 8ch mode
4370 */
4371static struct hda_verb alc882_sixstack_ch8_init[] = {
4372 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4373 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4374 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4375 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4376 { } /* end */
4377};
4378
4379static struct hda_channel_mode alc882_sixstack_modes[2] = {
4380 { 6, alc882_sixstack_ch6_init },
4381 { 8, alc882_sixstack_ch8_init },
4382};
4383
Linus Torvalds1da177e2005-04-16 15:20:36 -07004384/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4385 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4386 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004387static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004389 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004390 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004391 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004392 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4393 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004394 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4395 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004396 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004397 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4401 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4402 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4405 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4407 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4408 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004409 { } /* end */
4410};
4411
Kailang Yangdf694da2005-12-05 19:42:22 +01004412static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4413 {
4414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4415 .name = "Channel Mode",
4416 .info = alc_ch_mode_info,
4417 .get = alc_ch_mode_get,
4418 .put = alc_ch_mode_put,
4419 },
4420 { } /* end */
4421};
4422
Linus Torvalds1da177e2005-04-16 15:20:36 -07004423static struct hda_verb alc882_init_verbs[] = {
4424 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004428 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004432 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004436 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4439 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004440
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004441 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004450 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004451 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004452 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004454 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004456 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4460 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004461 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4463 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004464 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4466 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4467 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4468 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4469 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004470 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004471 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004472
4473 /* FIXME: use matrix-type input source selection */
4474 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4475 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004480 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004481 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004485 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4490 /* ADC1: mute amp left and right */
4491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004492 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004493 /* ADC2: mute amp left and right */
4494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004495 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004496 /* ADC3: mute amp left and right */
4497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004498 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004499
4500 { }
4501};
4502
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004503static struct hda_verb alc882_eapd_verbs[] = {
4504 /* change to EAPD mode */
4505 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004506 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004507 { }
4508};
4509
Kailang Yangdf694da2005-12-05 19:42:22 +01004510/*
4511 * generic initialization of ADC, input mixers and output mixers
4512 */
4513static struct hda_verb alc882_auto_init_verbs[] = {
4514 /*
4515 * Unmute ADC0-2 and set the default input to mic-in
4516 */
4517 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4519 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4520 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4521 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4523
4524 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4525 * mixer widget
4526 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4527 * mic (mic 2)
4528 */
4529 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4535
4536 /*
4537 * Set up output mixers (0x0c - 0x0f)
4538 */
4539 /* set vol=0 to output mixers */
4540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4544 /* set up input amps for analog loopback */
4545 /* Amp Indices: DAC = 0, mixer = 1 */
4546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4552 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4553 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4554 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4555 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4556
4557 /* FIXME: use matrix-type input source selection */
4558 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4559 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4564 /* Input mixer2 */
4565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4569 /* Input mixer3 */
4570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4574
4575 { }
4576};
4577
4578/* capture mixer elements */
4579static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4580 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4581 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4582 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4583 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4584 {
4585 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4586 /* The multiple "Capture Source" controls confuse alsamixer
4587 * So call somewhat different..
4588 * FIXME: the controls appear in the "playback" view!
4589 */
4590 /* .name = "Capture Source", */
4591 .name = "Input Source",
4592 .count = 2,
4593 .info = alc882_mux_enum_info,
4594 .get = alc882_mux_enum_get,
4595 .put = alc882_mux_enum_put,
4596 },
4597 { } /* end */
4598};
4599
4600static struct snd_kcontrol_new alc882_capture_mixer[] = {
4601 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4602 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4603 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4604 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4605 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4606 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4607 {
4608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4609 /* The multiple "Capture Source" controls confuse alsamixer
4610 * So call somewhat different..
4611 * FIXME: the controls appear in the "playback" view!
4612 */
4613 /* .name = "Capture Source", */
4614 .name = "Input Source",
4615 .count = 3,
4616 .info = alc882_mux_enum_info,
4617 .get = alc882_mux_enum_get,
4618 .put = alc882_mux_enum_put,
4619 },
4620 { } /* end */
4621};
4622
4623/* pcm configuration: identiacal with ALC880 */
4624#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4625#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4626#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4627#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4628
4629/*
4630 * configuration and preset
4631 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004632static const char *alc882_models[ALC882_MODEL_LAST] = {
4633 [ALC882_3ST_DIG] = "3stack-dig",
4634 [ALC882_6ST_DIG] = "6stack-dig",
4635 [ALC882_ARIMA] = "arima",
4636 [ALC882_AUTO] = "auto",
4637};
4638
4639static struct snd_pci_quirk alc882_cfg_tbl[] = {
4640 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
4641 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
4642 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
4643 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01004644 {}
4645};
4646
4647static struct alc_config_preset alc882_presets[] = {
4648 [ALC882_3ST_DIG] = {
4649 .mixers = { alc882_base_mixer },
4650 .init_verbs = { alc882_init_verbs },
4651 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4652 .dac_nids = alc882_dac_nids,
4653 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004654 .dig_in_nid = ALC882_DIGIN_NID,
4655 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4656 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004657 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004658 .input_mux = &alc882_capture_source,
4659 },
4660 [ALC882_6ST_DIG] = {
4661 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4662 .init_verbs = { alc882_init_verbs },
4663 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4664 .dac_nids = alc882_dac_nids,
4665 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004666 .dig_in_nid = ALC882_DIGIN_NID,
4667 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4668 .channel_mode = alc882_sixstack_modes,
4669 .input_mux = &alc882_capture_source,
4670 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004671 [ALC882_ARIMA] = {
4672 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4673 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4674 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4675 .dac_nids = alc882_dac_nids,
4676 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4677 .channel_mode = alc882_sixstack_modes,
4678 .input_mux = &alc882_capture_source,
4679 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004680};
4681
4682
4683/*
4684 * BIOS auto configuration
4685 */
4686static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4687 hda_nid_t nid, int pin_type,
4688 int dac_idx)
4689{
4690 /* set as output */
4691 struct alc_spec *spec = codec->spec;
4692 int idx;
4693
4694 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4695 idx = 4;
4696 else
4697 idx = spec->multiout.dac_nids[dac_idx] - 2;
4698
4699 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4700 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4701 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4702
4703}
4704
4705static void alc882_auto_init_multi_out(struct hda_codec *codec)
4706{
4707 struct alc_spec *spec = codec->spec;
4708 int i;
4709
4710 for (i = 0; i <= HDA_SIDE; i++) {
4711 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4712 if (nid)
4713 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4714 }
4715}
4716
4717static void alc882_auto_init_hp_out(struct hda_codec *codec)
4718{
4719 struct alc_spec *spec = codec->spec;
4720 hda_nid_t pin;
4721
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004722 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004723 if (pin) /* connect to front */
4724 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4725}
4726
4727#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4728#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4729
4730static void alc882_auto_init_analog_input(struct hda_codec *codec)
4731{
4732 struct alc_spec *spec = codec->spec;
4733 int i;
4734
4735 for (i = 0; i < AUTO_PIN_LAST; i++) {
4736 hda_nid_t nid = spec->autocfg.input_pins[i];
4737 if (alc882_is_input_pin(nid)) {
4738 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4739 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4740 if (nid != ALC882_PIN_CD_NID)
4741 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4742 AMP_OUT_MUTE);
4743 }
4744 }
4745}
4746
4747/* almost identical with ALC880 parser... */
4748static int alc882_parse_auto_config(struct hda_codec *codec)
4749{
4750 struct alc_spec *spec = codec->spec;
4751 int err = alc880_parse_auto_config(codec);
4752
4753 if (err < 0)
4754 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004755 else if (err > 0)
4756 /* hack - override the init verbs */
4757 spec->init_verbs[0] = alc882_auto_init_verbs;
4758 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004759}
4760
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004761/* additional initialization for auto-configuration model */
4762static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004763{
Kailang Yangdf694da2005-12-05 19:42:22 +01004764 alc882_auto_init_multi_out(codec);
4765 alc882_auto_init_hp_out(codec);
4766 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004767}
4768
Linus Torvalds1da177e2005-04-16 15:20:36 -07004769static int patch_alc882(struct hda_codec *codec)
4770{
4771 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004772 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004773
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004774 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004775 if (spec == NULL)
4776 return -ENOMEM;
4777
Linus Torvalds1da177e2005-04-16 15:20:36 -07004778 codec->spec = spec;
4779
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004780 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
4781 alc882_models,
4782 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004783
Kailang Yangdf694da2005-12-05 19:42:22 +01004784 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004785 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4786 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 board_config = ALC882_AUTO;
4788 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004789
Kailang Yangdf694da2005-12-05 19:42:22 +01004790 if (board_config == ALC882_AUTO) {
4791 /* automatic parse from the BIOS config */
4792 err = alc882_parse_auto_config(codec);
4793 if (err < 0) {
4794 alc_free(codec);
4795 return err;
4796 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004797 printk(KERN_INFO
4798 "hda_codec: Cannot set up configuration "
4799 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004800 board_config = ALC882_3ST_DIG;
4801 }
4802 }
4803
4804 if (board_config != ALC882_AUTO)
4805 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004806
4807 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4809 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004810
4811 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004812 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4813 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814
Kailang Yangdf694da2005-12-05 19:42:22 +01004815 if (! spec->adc_nids && spec->input_mux) {
4816 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004817 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4819 if (wcap != AC_WID_AUD_IN) {
4820 spec->adc_nids = alc882_adc_nids_alt;
4821 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4822 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4823 spec->num_mixers++;
4824 } else {
4825 spec->adc_nids = alc882_adc_nids;
4826 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4827 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4828 spec->num_mixers++;
4829 }
4830 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831
4832 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004833 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004834 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004835
4836 return 0;
4837}
4838
4839/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004840 * ALC883 support
4841 *
4842 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4843 * configuration. Each pin widget can choose any input DACs and a mixer.
4844 * Each ADC is connected from a mixer of all inputs. This makes possible
4845 * 6-channel independent captures.
4846 *
4847 * In addition, an independent DAC for the multi-playback (not used in this
4848 * driver yet).
4849 */
4850#define ALC883_DIGOUT_NID 0x06
4851#define ALC883_DIGIN_NID 0x0a
4852
4853static hda_nid_t alc883_dac_nids[4] = {
4854 /* front, rear, clfe, rear_surr */
4855 0x02, 0x04, 0x03, 0x05
4856};
4857
4858static hda_nid_t alc883_adc_nids[2] = {
4859 /* ADC1-2 */
4860 0x08, 0x09,
4861};
4862/* input MUX */
4863/* FIXME: should be a matrix-type input source selection */
4864
4865static struct hda_input_mux alc883_capture_source = {
4866 .num_items = 4,
4867 .items = {
4868 { "Mic", 0x0 },
4869 { "Front Mic", 0x1 },
4870 { "Line", 0x2 },
4871 { "CD", 0x4 },
4872 },
4873};
4874#define alc883_mux_enum_info alc_mux_enum_info
4875#define alc883_mux_enum_get alc_mux_enum_get
4876
4877static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4878 struct snd_ctl_elem_value *ucontrol)
4879{
4880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4881 struct alc_spec *spec = codec->spec;
4882 const struct hda_input_mux *imux = spec->input_mux;
4883 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4884 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4885 hda_nid_t nid = capture_mixers[adc_idx];
4886 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4887 unsigned int i, idx;
4888
4889 idx = ucontrol->value.enumerated.item[0];
4890 if (idx >= imux->num_items)
4891 idx = imux->num_items - 1;
4892 if (*cur_val == idx && ! codec->in_resume)
4893 return 0;
4894 for (i = 0; i < imux->num_items; i++) {
4895 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4896 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4897 v | (imux->items[i].index << 8));
4898 }
4899 *cur_val = idx;
4900 return 1;
4901}
4902/*
4903 * 2ch mode
4904 */
4905static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4906 { 2, NULL }
4907};
4908
4909/*
4910 * 2ch mode
4911 */
4912static struct hda_verb alc883_3ST_ch2_init[] = {
4913 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4914 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4915 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4916 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4917 { } /* end */
4918};
4919
4920/*
4921 * 6ch mode
4922 */
4923static struct hda_verb alc883_3ST_ch6_init[] = {
4924 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4925 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4926 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4927 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4928 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4929 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4930 { } /* end */
4931};
4932
4933static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4934 { 2, alc883_3ST_ch2_init },
4935 { 6, alc883_3ST_ch6_init },
4936};
4937
4938/*
4939 * 6ch mode
4940 */
4941static struct hda_verb alc883_sixstack_ch6_init[] = {
4942 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4943 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4944 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4945 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4946 { } /* end */
4947};
4948
4949/*
4950 * 8ch mode
4951 */
4952static struct hda_verb alc883_sixstack_ch8_init[] = {
4953 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4954 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4955 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4956 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4957 { } /* end */
4958};
4959
4960static struct hda_channel_mode alc883_sixstack_modes[2] = {
4961 { 6, alc883_sixstack_ch6_init },
4962 { 8, alc883_sixstack_ch8_init },
4963};
4964
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004965static struct hda_verb alc883_medion_eapd_verbs[] = {
4966 /* eanable EAPD on medion laptop */
4967 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4968 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
4969 { }
4970};
4971
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004972/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4973 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4974 */
4975
4976static struct snd_kcontrol_new alc883_base_mixer[] = {
4977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4980 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4981 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4982 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4983 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4984 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4985 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4986 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4996 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4997 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5000 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5001 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5002 {
5003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5004 /* .name = "Capture Source", */
5005 .name = "Input Source",
5006 .count = 2,
5007 .info = alc883_mux_enum_info,
5008 .get = alc883_mux_enum_get,
5009 .put = alc883_mux_enum_put,
5010 },
5011 { } /* end */
5012};
5013
5014static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5016 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5018 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5019 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5020 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5021 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5024 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5025 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5026 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5027 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5030 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5031 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5032 {
5033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5034 /* .name = "Capture Source", */
5035 .name = "Input Source",
5036 .count = 2,
5037 .info = alc883_mux_enum_info,
5038 .get = alc883_mux_enum_get,
5039 .put = alc883_mux_enum_put,
5040 },
5041 { } /* end */
5042};
5043
5044static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5048 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5049 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5051 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5052 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5061 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5062 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5063 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5064 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5065 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5066 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5067 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5068 {
5069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5070 /* .name = "Capture Source", */
5071 .name = "Input Source",
5072 .count = 2,
5073 .info = alc883_mux_enum_info,
5074 .get = alc883_mux_enum_get,
5075 .put = alc883_mux_enum_put,
5076 },
5077 { } /* end */
5078};
5079
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005080static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5082 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5083 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5084 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5085 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5086 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5087 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5088 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5092 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5093 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5096 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5097 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5098 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5099 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5100 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5101 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5102
5103 {
5104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5105 /* .name = "Capture Source", */
5106 .name = "Input Source",
5107 .count = 1,
5108 .info = alc883_mux_enum_info,
5109 .get = alc883_mux_enum_get,
5110 .put = alc883_mux_enum_put,
5111 },
5112 { } /* end */
5113};
5114
Kailang Yangccc656c2006-10-17 12:32:26 +02005115static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5120 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5122 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5124 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5131 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5132 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5133 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5134 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5135 {
5136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5137 /* .name = "Capture Source", */
5138 .name = "Input Source",
5139 .count = 2,
5140 .info = alc883_mux_enum_info,
5141 .get = alc883_mux_enum_get,
5142 .put = alc883_mux_enum_put,
5143 },
5144 { } /* end */
5145};
5146
5147static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5148 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5150 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5151 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5152 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5155 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5156 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5157 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5158 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5159 {
5160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5161 /* .name = "Capture Source", */
5162 .name = "Input Source",
5163 .count = 2,
5164 .info = alc883_mux_enum_info,
5165 .get = alc883_mux_enum_get,
5166 .put = alc883_mux_enum_put,
5167 },
5168 { } /* end */
5169};
5170
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005171static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5172 {
5173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5174 .name = "Channel Mode",
5175 .info = alc_ch_mode_info,
5176 .get = alc_ch_mode_get,
5177 .put = alc_ch_mode_put,
5178 },
5179 { } /* end */
5180};
5181
5182static struct hda_verb alc883_init_verbs[] = {
5183 /* ADC1: mute amp left and right */
5184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5185 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5186 /* ADC2: mute amp left and right */
5187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5188 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5189 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5193 /* Rear mixer */
5194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5197 /* CLFE mixer */
5198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5200 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5201 /* Side mixer */
5202 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5205
5206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5211
5212 /* Front Pin: output 0 (0x0c) */
5213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5214 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5215 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5216 /* Rear Pin: output 1 (0x0d) */
5217 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5219 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5220 /* CLFE Pin: output 2 (0x0e) */
5221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5223 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5224 /* Side Pin: output 3 (0x0f) */
5225 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5227 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5228 /* Mic (rear) pin: input vref at 80% */
5229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5231 /* Front Mic pin: input vref at 80% */
5232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5234 /* Line In pin: input */
5235 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5237 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5240 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5241 /* CD pin widget for input */
5242 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5243
5244 /* FIXME: use matrix-type input source selection */
5245 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5246 /* Input mixer2 */
5247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5251 /* Input mixer3 */
5252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5256 { }
5257};
5258
Kailang Yangccc656c2006-10-17 12:32:26 +02005259static struct hda_verb alc883_tagra_verbs[] = {
5260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5262
5263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5264 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5265
5266 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5267 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5269
5270 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5271 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5272 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5273 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5274
5275 { } /* end */
5276};
5277
5278/* toggle speaker-output according to the hp-jack state */
5279static void alc883_tagra_automute(struct hda_codec *codec)
5280{
5281 unsigned int present;
5282
5283 present = snd_hda_codec_read(codec, 0x14, 0,
5284 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5285 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5286 0x80, present ? 0x80 : 0);
5287 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5288 0x80, present ? 0x80 : 0);
5289 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5290}
5291
5292static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5293{
5294 if ((res >> 26) == ALC880_HP_EVENT)
5295 alc883_tagra_automute(codec);
5296}
5297
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005298/*
5299 * generic initialization of ADC, input mixers and output mixers
5300 */
5301static struct hda_verb alc883_auto_init_verbs[] = {
5302 /*
5303 * Unmute ADC0-2 and set the default input to mic-in
5304 */
5305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5307 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309
5310 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5311 * mixer widget
5312 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5313 * mic (mic 2)
5314 */
5315 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5321
5322 /*
5323 * Set up output mixers (0x0c - 0x0f)
5324 */
5325 /* set vol=0 to output mixers */
5326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5330 /* set up input amps for analog loopback */
5331 /* Amp Indices: DAC = 0, mixer = 1 */
5332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5340 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5341 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5342
5343 /* FIXME: use matrix-type input source selection */
5344 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5345 /* Input mixer1 */
5346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5349 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5351 /* Input mixer2 */
5352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5355 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5357
5358 { }
5359};
5360
5361/* capture mixer elements */
5362static struct snd_kcontrol_new alc883_capture_mixer[] = {
5363 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5364 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5365 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5366 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5367 {
5368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5369 /* The multiple "Capture Source" controls confuse alsamixer
5370 * So call somewhat different..
5371 * FIXME: the controls appear in the "playback" view!
5372 */
5373 /* .name = "Capture Source", */
5374 .name = "Input Source",
5375 .count = 2,
5376 .info = alc882_mux_enum_info,
5377 .get = alc882_mux_enum_get,
5378 .put = alc882_mux_enum_put,
5379 },
5380 { } /* end */
5381};
5382
5383/* pcm configuration: identiacal with ALC880 */
5384#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5385#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5386#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5387#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5388
5389/*
5390 * configuration and preset
5391 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005392static const char *alc883_models[ALC883_MODEL_LAST] = {
5393 [ALC883_3ST_2ch_DIG] = "3stack-dig",
5394 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
5395 [ALC883_3ST_6ch] = "3stack-6ch",
5396 [ALC883_6ST_DIG] = "6stack-dig",
5397 [ALC883_TARGA_DIG] = "targa-dig",
5398 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
5399 [ALC888_DEMO_BOARD] = "6stack-dig-demo",
5400 [ALC883_ACER] = "acer",
5401 [ALC883_MEDION] = "medion",
5402 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
5403 [ALC883_AUTO] = "auto",
5404};
5405
5406static struct snd_pci_quirk alc883_cfg_tbl[] = {
5407 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
5408 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5409 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5410 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
5411 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5412 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
5413 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
5414 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
5415 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
5416 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
5417 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
5418 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
5419 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
5420 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
5421 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
5422 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
5423 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
5424 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5425 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5426 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005427 {}
5428};
5429
5430static struct alc_config_preset alc883_presets[] = {
5431 [ALC883_3ST_2ch_DIG] = {
5432 .mixers = { alc883_3ST_2ch_mixer },
5433 .init_verbs = { alc883_init_verbs },
5434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5435 .dac_nids = alc883_dac_nids,
5436 .dig_out_nid = ALC883_DIGOUT_NID,
5437 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5438 .adc_nids = alc883_adc_nids,
5439 .dig_in_nid = ALC883_DIGIN_NID,
5440 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5441 .channel_mode = alc883_3ST_2ch_modes,
5442 .input_mux = &alc883_capture_source,
5443 },
5444 [ALC883_3ST_6ch_DIG] = {
5445 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5446 .init_verbs = { alc883_init_verbs },
5447 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5448 .dac_nids = alc883_dac_nids,
5449 .dig_out_nid = ALC883_DIGOUT_NID,
5450 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5451 .adc_nids = alc883_adc_nids,
5452 .dig_in_nid = ALC883_DIGIN_NID,
5453 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5454 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005455 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005456 .input_mux = &alc883_capture_source,
5457 },
5458 [ALC883_3ST_6ch] = {
5459 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5460 .init_verbs = { alc883_init_verbs },
5461 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5462 .dac_nids = alc883_dac_nids,
5463 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5464 .adc_nids = alc883_adc_nids,
5465 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5466 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005467 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005468 .input_mux = &alc883_capture_source,
5469 },
5470 [ALC883_6ST_DIG] = {
5471 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5472 .init_verbs = { alc883_init_verbs },
5473 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5474 .dac_nids = alc883_dac_nids,
5475 .dig_out_nid = ALC883_DIGOUT_NID,
5476 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5477 .adc_nids = alc883_adc_nids,
5478 .dig_in_nid = ALC883_DIGIN_NID,
5479 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5480 .channel_mode = alc883_sixstack_modes,
5481 .input_mux = &alc883_capture_source,
5482 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005483 [ALC883_TARGA_DIG] = {
5484 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5485 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5486 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5487 .dac_nids = alc883_dac_nids,
5488 .dig_out_nid = ALC883_DIGOUT_NID,
5489 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5490 .adc_nids = alc883_adc_nids,
5491 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5492 .channel_mode = alc883_3ST_6ch_modes,
5493 .need_dac_fix = 1,
5494 .input_mux = &alc883_capture_source,
5495 .unsol_event = alc883_tagra_unsol_event,
5496 .init_hook = alc883_tagra_automute,
5497 },
5498 [ALC883_TARGA_2ch_DIG] = {
5499 .mixers = { alc883_tagra_2ch_mixer},
5500 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5502 .dac_nids = alc883_dac_nids,
5503 .dig_out_nid = ALC883_DIGOUT_NID,
5504 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5505 .adc_nids = alc883_adc_nids,
5506 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5507 .channel_mode = alc883_3ST_2ch_modes,
5508 .input_mux = &alc883_capture_source,
5509 .unsol_event = alc883_tagra_unsol_event,
5510 .init_hook = alc883_tagra_automute,
5511 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005512 [ALC888_DEMO_BOARD] = {
5513 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5514 .init_verbs = { alc883_init_verbs },
5515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5516 .dac_nids = alc883_dac_nids,
5517 .dig_out_nid = ALC883_DIGOUT_NID,
5518 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5519 .adc_nids = alc883_adc_nids,
5520 .dig_in_nid = ALC883_DIGIN_NID,
5521 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5522 .channel_mode = alc883_sixstack_modes,
5523 .input_mux = &alc883_capture_source,
5524 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02005525 [ALC883_ACER] = {
5526 .mixers = { alc883_base_mixer,
5527 alc883_chmode_mixer },
5528 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5529 * and the headphone jack. Turn this on and rely on the
5530 * standard mute methods whenever the user wants to turn
5531 * these outputs off.
5532 */
5533 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5535 .dac_nids = alc883_dac_nids,
5536 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5537 .adc_nids = alc883_adc_nids,
5538 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5539 .channel_mode = alc883_3ST_2ch_modes,
5540 .input_mux = &alc883_capture_source,
5541 },
Tobin Davisc07584c2006-10-13 12:32:16 +02005542 [ALC883_MEDION] = {
5543 .mixers = { alc883_fivestack_mixer,
5544 alc883_chmode_mixer },
5545 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005546 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02005547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5548 .dac_nids = alc883_dac_nids,
5549 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5550 .adc_nids = alc883_adc_nids,
5551 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5552 .channel_mode = alc883_sixstack_modes,
5553 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005554 },
5555 [ALC883_LAPTOP_EAPD] = {
5556 .mixers = { alc883_base_mixer,
5557 alc883_chmode_mixer },
5558 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
5559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5560 .dac_nids = alc883_dac_nids,
5561 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5562 .adc_nids = alc883_adc_nids,
5563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5564 .channel_mode = alc883_3ST_2ch_modes,
5565 .input_mux = &alc883_capture_source,
5566 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005567};
5568
5569
5570/*
5571 * BIOS auto configuration
5572 */
5573static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5574 hda_nid_t nid, int pin_type,
5575 int dac_idx)
5576{
5577 /* set as output */
5578 struct alc_spec *spec = codec->spec;
5579 int idx;
5580
5581 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5582 idx = 4;
5583 else
5584 idx = spec->multiout.dac_nids[dac_idx] - 2;
5585
5586 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5587 pin_type);
5588 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5589 AMP_OUT_UNMUTE);
5590 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5591
5592}
5593
5594static void alc883_auto_init_multi_out(struct hda_codec *codec)
5595{
5596 struct alc_spec *spec = codec->spec;
5597 int i;
5598
5599 for (i = 0; i <= HDA_SIDE; i++) {
5600 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5601 if (nid)
5602 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5603 }
5604}
5605
5606static void alc883_auto_init_hp_out(struct hda_codec *codec)
5607{
5608 struct alc_spec *spec = codec->spec;
5609 hda_nid_t pin;
5610
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005611 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005612 if (pin) /* connect to front */
5613 /* use dac 0 */
5614 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5615}
5616
5617#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5618#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5619
5620static void alc883_auto_init_analog_input(struct hda_codec *codec)
5621{
5622 struct alc_spec *spec = codec->spec;
5623 int i;
5624
5625 for (i = 0; i < AUTO_PIN_LAST; i++) {
5626 hda_nid_t nid = spec->autocfg.input_pins[i];
5627 if (alc883_is_input_pin(nid)) {
5628 snd_hda_codec_write(codec, nid, 0,
5629 AC_VERB_SET_PIN_WIDGET_CONTROL,
5630 (i <= AUTO_PIN_FRONT_MIC ?
5631 PIN_VREF80 : PIN_IN));
5632 if (nid != ALC883_PIN_CD_NID)
5633 snd_hda_codec_write(codec, nid, 0,
5634 AC_VERB_SET_AMP_GAIN_MUTE,
5635 AMP_OUT_MUTE);
5636 }
5637 }
5638}
5639
5640/* almost identical with ALC880 parser... */
5641static int alc883_parse_auto_config(struct hda_codec *codec)
5642{
5643 struct alc_spec *spec = codec->spec;
5644 int err = alc880_parse_auto_config(codec);
5645
5646 if (err < 0)
5647 return err;
5648 else if (err > 0)
5649 /* hack - override the init verbs */
5650 spec->init_verbs[0] = alc883_auto_init_verbs;
5651 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5652 spec->num_mixers++;
5653 return err;
5654}
5655
5656/* additional initialization for auto-configuration model */
5657static void alc883_auto_init(struct hda_codec *codec)
5658{
5659 alc883_auto_init_multi_out(codec);
5660 alc883_auto_init_hp_out(codec);
5661 alc883_auto_init_analog_input(codec);
5662}
5663
5664static int patch_alc883(struct hda_codec *codec)
5665{
5666 struct alc_spec *spec;
5667 int err, board_config;
5668
5669 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5670 if (spec == NULL)
5671 return -ENOMEM;
5672
5673 codec->spec = spec;
5674
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005675 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
5676 alc883_models,
5677 alc883_cfg_tbl);
5678 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005679 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5680 "trying auto-probe from BIOS...\n");
5681 board_config = ALC883_AUTO;
5682 }
5683
5684 if (board_config == ALC883_AUTO) {
5685 /* automatic parse from the BIOS config */
5686 err = alc883_parse_auto_config(codec);
5687 if (err < 0) {
5688 alc_free(codec);
5689 return err;
5690 } else if (! err) {
5691 printk(KERN_INFO
5692 "hda_codec: Cannot set up configuration "
5693 "from BIOS. Using base mode...\n");
5694 board_config = ALC883_3ST_2ch_DIG;
5695 }
5696 }
5697
5698 if (board_config != ALC883_AUTO)
5699 setup_preset(spec, &alc883_presets[board_config]);
5700
5701 spec->stream_name_analog = "ALC883 Analog";
5702 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5703 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5704
5705 spec->stream_name_digital = "ALC883 Digital";
5706 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5707 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5708
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005709 if (! spec->adc_nids && spec->input_mux) {
5710 spec->adc_nids = alc883_adc_nids;
5711 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5712 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005713
5714 codec->patch_ops = alc_patch_ops;
5715 if (board_config == ALC883_AUTO)
5716 spec->init_hook = alc883_auto_init;
5717
5718 return 0;
5719}
5720
5721/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 * ALC262 support
5723 */
5724
5725#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5726#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5727
5728#define alc262_dac_nids alc260_dac_nids
5729#define alc262_adc_nids alc882_adc_nids
5730#define alc262_adc_nids_alt alc882_adc_nids_alt
5731
5732#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005733#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005734
5735static struct snd_kcontrol_new alc262_base_mixer[] = {
5736 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5737 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5738 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5739 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5740 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5741 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5744 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5746 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5747 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5748 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5749 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5750 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5751 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005752 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005753};
5754
Kailang Yangccc656c2006-10-17 12:32:26 +02005755static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
5756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5757 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5764 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5765 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5766 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5767 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5768 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
5769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5770 { } /* end */
5771};
5772
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005773static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5774 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5775 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5777 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5778 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5779
5780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5782 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5783 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5786 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5787 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5788 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5789 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5790 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5791 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5792 { } /* end */
5793};
5794
Kailang Yangdf694da2005-12-05 19:42:22 +01005795#define alc262_capture_mixer alc882_capture_mixer
5796#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5797
5798/*
5799 * generic initialization of ADC, input mixers and output mixers
5800 */
5801static struct hda_verb alc262_init_verbs[] = {
5802 /*
5803 * Unmute ADC0-2 and set the default input to mic-in
5804 */
5805 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5806 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5807 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5811
5812 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5813 * mixer widget
5814 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5815 * mic (mic 2)
5816 */
5817 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5819 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5820 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5822 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5823
5824 /*
5825 * Set up output mixers (0x0c - 0x0e)
5826 */
5827 /* set vol=0 to output mixers */
5828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5830 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5831 /* set up input amps for analog loopback */
5832 /* Amp Indices: DAC = 0, mixer = 1 */
5833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5837 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5839
5840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5842 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5843 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5844 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5846
5847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5852
5853 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5854 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5855
5856 /* FIXME: use matrix-type input source selection */
5857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5858 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5863 /* Input mixer2 */
5864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5868 /* Input mixer3 */
5869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5873
5874 { }
5875};
5876
Kailang Yangccc656c2006-10-17 12:32:26 +02005877static struct hda_verb alc262_hippo_unsol_verbs[] = {
5878 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5880 {}
5881};
5882
5883static struct hda_verb alc262_hippo1_unsol_verbs[] = {
5884 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5885 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5886 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5887
5888 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5889 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5890 {}
5891};
5892
5893/* mute/unmute internal speaker according to the hp jack and mute state */
5894static void alc262_hippo_automute(struct hda_codec *codec, int force)
5895{
5896 struct alc_spec *spec = codec->spec;
5897 unsigned int mute;
5898
5899 if (force || ! spec->sense_updated) {
5900 unsigned int present;
5901 /* need to execute and sync at first */
5902 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
5903 present = snd_hda_codec_read(codec, 0x15, 0,
5904 AC_VERB_GET_PIN_SENSE, 0);
5905 spec->jack_present = (present & 0x80000000) != 0;
5906 spec->sense_updated = 1;
5907 }
5908 if (spec->jack_present) {
5909 /* mute internal speaker */
5910 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5911 0x80, 0x80);
5912 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5913 0x80, 0x80);
5914 } else {
5915 /* unmute internal speaker if necessary */
5916 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
5917 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5918 0x80, mute & 0x80);
5919 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
5920 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5921 0x80, mute & 0x80);
5922 }
5923}
5924
5925/* unsolicited event for HP jack sensing */
5926static void alc262_hippo_unsol_event(struct hda_codec *codec,
5927 unsigned int res)
5928{
5929 if ((res >> 26) != ALC880_HP_EVENT)
5930 return;
5931 alc262_hippo_automute(codec, 1);
5932}
5933
5934static void alc262_hippo1_automute(struct hda_codec *codec, int force)
5935{
5936 struct alc_spec *spec = codec->spec;
5937 unsigned int mute;
5938
5939 if (force || ! spec->sense_updated) {
5940 unsigned int present;
5941 /* need to execute and sync at first */
5942 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
5943 present = snd_hda_codec_read(codec, 0x1b, 0,
5944 AC_VERB_GET_PIN_SENSE, 0);
5945 spec->jack_present = (present & 0x80000000) != 0;
5946 spec->sense_updated = 1;
5947 }
5948 if (spec->jack_present) {
5949 /* mute internal speaker */
5950 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5951 0x80, 0x80);
5952 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5953 0x80, 0x80);
5954 } else {
5955 /* unmute internal speaker if necessary */
5956 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
5957 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5958 0x80, mute & 0x80);
5959 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
5960 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5961 0x80, mute & 0x80);
5962 }
5963}
5964
5965/* unsolicited event for HP jack sensing */
5966static void alc262_hippo1_unsol_event(struct hda_codec *codec,
5967 unsigned int res)
5968{
5969 if ((res >> 26) != ALC880_HP_EVENT)
5970 return;
5971 alc262_hippo1_automute(codec, 1);
5972}
5973
Takashi Iwai834be882006-03-01 14:16:17 +01005974/*
5975 * fujitsu model
5976 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5977 */
5978
5979#define ALC_HP_EVENT 0x37
5980
5981static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5982 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5984 {}
5985};
5986
5987static struct hda_input_mux alc262_fujitsu_capture_source = {
5988 .num_items = 2,
5989 .items = {
5990 { "Mic", 0x0 },
5991 { "CD", 0x4 },
5992 },
5993};
5994
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005995static struct hda_input_mux alc262_HP_capture_source = {
5996 .num_items = 5,
5997 .items = {
5998 { "Mic", 0x0 },
5999 { "Front Mic", 0x3 },
6000 { "Line", 0x2 },
6001 { "CD", 0x4 },
6002 { "AUX IN", 0x6 },
6003 },
6004};
6005
Takashi Iwai834be882006-03-01 14:16:17 +01006006/* mute/unmute internal speaker according to the hp jack and mute state */
6007static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6008{
6009 struct alc_spec *spec = codec->spec;
6010 unsigned int mute;
6011
6012 if (force || ! spec->sense_updated) {
6013 unsigned int present;
6014 /* need to execute and sync at first */
6015 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6016 present = snd_hda_codec_read(codec, 0x14, 0,
6017 AC_VERB_GET_PIN_SENSE, 0);
6018 spec->jack_present = (present & 0x80000000) != 0;
6019 spec->sense_updated = 1;
6020 }
6021 if (spec->jack_present) {
6022 /* mute internal speaker */
6023 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6024 0x80, 0x80);
6025 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6026 0x80, 0x80);
6027 } else {
6028 /* unmute internal speaker if necessary */
6029 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6030 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6031 0x80, mute & 0x80);
6032 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6033 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6034 0x80, mute & 0x80);
6035 }
6036}
6037
6038/* unsolicited event for HP jack sensing */
6039static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6040 unsigned int res)
6041{
6042 if ((res >> 26) != ALC_HP_EVENT)
6043 return;
6044 alc262_fujitsu_automute(codec, 1);
6045}
6046
6047/* bind volumes of both NID 0x0c and 0x0d */
6048static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6049 struct snd_ctl_elem_value *ucontrol)
6050{
6051 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6052 long *valp = ucontrol->value.integer.value;
6053 int change;
6054
6055 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6056 0x7f, valp[0] & 0x7f);
6057 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6058 0x7f, valp[1] & 0x7f);
6059 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6060 0x7f, valp[0] & 0x7f);
6061 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6062 0x7f, valp[1] & 0x7f);
6063 return change;
6064}
6065
6066/* bind hp and internal speaker mute (with plug check) */
6067static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6068 struct snd_ctl_elem_value *ucontrol)
6069{
6070 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6071 long *valp = ucontrol->value.integer.value;
6072 int change;
6073
6074 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6075 0x80, valp[0] ? 0 : 0x80);
6076 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6077 0x80, valp[1] ? 0 : 0x80);
6078 if (change || codec->in_resume)
6079 alc262_fujitsu_automute(codec, codec->in_resume);
6080 return change;
6081}
6082
6083static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6084 {
6085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6086 .name = "Master Playback Volume",
6087 .info = snd_hda_mixer_amp_volume_info,
6088 .get = snd_hda_mixer_amp_volume_get,
6089 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02006090 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01006091 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6092 },
6093 {
6094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6095 .name = "Master Playback Switch",
6096 .info = snd_hda_mixer_amp_switch_info,
6097 .get = snd_hda_mixer_amp_switch_get,
6098 .put = alc262_fujitsu_master_sw_put,
6099 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6100 },
6101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6103 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6106 { } /* end */
6107};
6108
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006109/* additional init verbs for Benq laptops */
6110static struct hda_verb alc262_EAPD_verbs[] = {
6111 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6112 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6113 {}
6114};
6115
Kailang Yangdf694da2005-12-05 19:42:22 +01006116/* add playback controls from the parsed DAC table */
6117static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6118{
6119 hda_nid_t nid;
6120 int err;
6121
6122 spec->multiout.num_dacs = 1; /* only use one dac */
6123 spec->multiout.dac_nids = spec->private_dac_nids;
6124 spec->multiout.dac_nids[0] = 2;
6125
6126 nid = cfg->line_out_pins[0];
6127 if (nid) {
6128 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6129 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6130 return err;
6131 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6132 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6133 return err;
6134 }
6135
Takashi Iwai82bc9552006-03-21 11:24:42 +01006136 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006137 if (nid) {
6138 if (nid == 0x16) {
6139 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6140 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6141 return err;
6142 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6143 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6144 return err;
6145 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006146 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6147 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6148 return err;
6149 }
6150 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006151 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006152 if (nid) {
6153 /* spec->multiout.hp_nid = 2; */
6154 if (nid == 0x16) {
6155 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6156 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6157 return err;
6158 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6159 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6160 return err;
6161 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006162 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6163 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6164 return err;
6165 }
6166 }
6167 return 0;
6168}
6169
6170/* identical with ALC880 */
6171#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6172
6173/*
6174 * generic initialization of ADC, input mixers and output mixers
6175 */
6176static struct hda_verb alc262_volume_init_verbs[] = {
6177 /*
6178 * Unmute ADC0-2 and set the default input to mic-in
6179 */
6180 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6181 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6182 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6184 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186
6187 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6188 * mixer widget
6189 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6190 * mic (mic 2)
6191 */
6192 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6196 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6198
6199 /*
6200 * Set up output mixers (0x0c - 0x0f)
6201 */
6202 /* set vol=0 to output mixers */
6203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6206
6207 /* set up input amps for analog loopback */
6208 /* Amp Indices: DAC = 0, mixer = 1 */
6209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6211 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6212 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6213 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6214 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6215
6216 /* FIXME: use matrix-type input source selection */
6217 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6218 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6223 /* Input mixer2 */
6224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6228 /* Input mixer3 */
6229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6233
6234 { }
6235};
6236
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006237static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6238 /*
6239 * Unmute ADC0-2 and set the default input to mic-in
6240 */
6241 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6243 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6244 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6245 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6246 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6247
6248 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6249 * mixer widget
6250 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6251 * mic (mic 2)
6252 */
6253 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6261
6262 /*
6263 * Set up output mixers (0x0c - 0x0e)
6264 */
6265 /* set vol=0 to output mixers */
6266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6267 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6269
6270 /* set up input amps for analog loopback */
6271 /* Amp Indices: DAC = 0, mixer = 1 */
6272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6278
6279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6281 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6282
6283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6285
6286 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6288
6289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6292 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6294
6295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6297 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6299 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6300 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6301
6302
6303 /* FIXME: use matrix-type input source selection */
6304 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6305 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6309 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6310 /* Input mixer2 */
6311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6315 /* Input mixer3 */
6316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6320
6321 { }
6322};
6323
Kailang Yangdf694da2005-12-05 19:42:22 +01006324/* pcm configuration: identiacal with ALC880 */
6325#define alc262_pcm_analog_playback alc880_pcm_analog_playback
6326#define alc262_pcm_analog_capture alc880_pcm_analog_capture
6327#define alc262_pcm_digital_playback alc880_pcm_digital_playback
6328#define alc262_pcm_digital_capture alc880_pcm_digital_capture
6329
6330/*
6331 * BIOS auto configuration
6332 */
6333static int alc262_parse_auto_config(struct hda_codec *codec)
6334{
6335 struct alc_spec *spec = codec->spec;
6336 int err;
6337 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6338
6339 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6340 alc262_ignore)) < 0)
6341 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006342 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006343 return 0; /* can't find valid BIOS pin config */
6344 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6345 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6346 return err;
6347
6348 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6349
6350 if (spec->autocfg.dig_out_pin)
6351 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6352 if (spec->autocfg.dig_in_pin)
6353 spec->dig_in_nid = ALC262_DIGIN_NID;
6354
6355 if (spec->kctl_alloc)
6356 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6357
6358 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006359 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006360 spec->input_mux = &spec->private_imux;
6361
6362 return 1;
6363}
6364
6365#define alc262_auto_init_multi_out alc882_auto_init_multi_out
6366#define alc262_auto_init_hp_out alc882_auto_init_hp_out
6367#define alc262_auto_init_analog_input alc882_auto_init_analog_input
6368
6369
6370/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006371static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006372{
Kailang Yangdf694da2005-12-05 19:42:22 +01006373 alc262_auto_init_multi_out(codec);
6374 alc262_auto_init_hp_out(codec);
6375 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006376}
6377
6378/*
6379 * configuration and preset
6380 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006381static const char *alc262_models[ALC262_MODEL_LAST] = {
6382 [ALC262_BASIC] = "basic",
6383 [ALC262_HIPPO] = "hippo",
6384 [ALC262_HIPPO_1] = "hippo_1",
6385 [ALC262_FUJITSU] = "fujitsu",
6386 [ALC262_HP_BPC] = "hp-bpc",
6387 [ALC262_BENQ_ED8] = "benq",
6388 [ALC262_AUTO] = "auto",
6389};
6390
6391static struct snd_pci_quirk alc262_cfg_tbl[] = {
6392 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
6393 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
6394 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
6395 SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC),
6396 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
6397 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
6398 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
6399 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
6400 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
6401 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yangdf694da2005-12-05 19:42:22 +01006402 {}
6403};
6404
6405static struct alc_config_preset alc262_presets[] = {
6406 [ALC262_BASIC] = {
6407 .mixers = { alc262_base_mixer },
6408 .init_verbs = { alc262_init_verbs },
6409 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6410 .dac_nids = alc262_dac_nids,
6411 .hp_nid = 0x03,
6412 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6413 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006414 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01006415 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006416 [ALC262_HIPPO] = {
6417 .mixers = { alc262_base_mixer },
6418 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
6419 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6420 .dac_nids = alc262_dac_nids,
6421 .hp_nid = 0x03,
6422 .dig_out_nid = ALC262_DIGOUT_NID,
6423 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6424 .channel_mode = alc262_modes,
6425 .input_mux = &alc262_capture_source,
6426 .unsol_event = alc262_hippo_unsol_event,
6427 },
6428 [ALC262_HIPPO_1] = {
6429 .mixers = { alc262_hippo1_mixer },
6430 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
6431 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6432 .dac_nids = alc262_dac_nids,
6433 .hp_nid = 0x02,
6434 .dig_out_nid = ALC262_DIGOUT_NID,
6435 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6436 .channel_mode = alc262_modes,
6437 .input_mux = &alc262_capture_source,
6438 .unsol_event = alc262_hippo1_unsol_event,
6439 },
Takashi Iwai834be882006-03-01 14:16:17 +01006440 [ALC262_FUJITSU] = {
6441 .mixers = { alc262_fujitsu_mixer },
6442 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
6443 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6444 .dac_nids = alc262_dac_nids,
6445 .hp_nid = 0x03,
6446 .dig_out_nid = ALC262_DIGOUT_NID,
6447 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6448 .channel_mode = alc262_modes,
6449 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006450 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01006451 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006452 [ALC262_HP_BPC] = {
6453 .mixers = { alc262_HP_BPC_mixer },
6454 .init_verbs = { alc262_HP_BPC_init_verbs },
6455 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6456 .dac_nids = alc262_dac_nids,
6457 .hp_nid = 0x03,
6458 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6459 .channel_mode = alc262_modes,
6460 .input_mux = &alc262_HP_capture_source,
6461 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006462 [ALC262_BENQ_ED8] = {
6463 .mixers = { alc262_base_mixer },
6464 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
6465 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6466 .dac_nids = alc262_dac_nids,
6467 .hp_nid = 0x03,
6468 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6469 .channel_mode = alc262_modes,
6470 .input_mux = &alc262_capture_source,
6471 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006472};
6473
6474static int patch_alc262(struct hda_codec *codec)
6475{
6476 struct alc_spec *spec;
6477 int board_config;
6478 int err;
6479
6480 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6481 if (spec == NULL)
6482 return -ENOMEM;
6483
6484 codec->spec = spec;
6485#if 0
6486 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6487 {
6488 int tmp;
6489 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6490 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6491 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6492 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6493 }
6494#endif
6495
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006496 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
6497 alc262_models,
6498 alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006499
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006500 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006501 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6502 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006503 board_config = ALC262_AUTO;
6504 }
6505
6506 if (board_config == ALC262_AUTO) {
6507 /* automatic parse from the BIOS config */
6508 err = alc262_parse_auto_config(codec);
6509 if (err < 0) {
6510 alc_free(codec);
6511 return err;
6512 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006513 printk(KERN_INFO
6514 "hda_codec: Cannot set up configuration "
6515 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006516 board_config = ALC262_BASIC;
6517 }
6518 }
6519
6520 if (board_config != ALC262_AUTO)
6521 setup_preset(spec, &alc262_presets[board_config]);
6522
6523 spec->stream_name_analog = "ALC262 Analog";
6524 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6525 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6526
6527 spec->stream_name_digital = "ALC262 Digital";
6528 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6529 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6530
6531 if (! spec->adc_nids && spec->input_mux) {
6532 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006533 unsigned int wcap = get_wcaps(codec, 0x07);
6534
Kailang Yangdf694da2005-12-05 19:42:22 +01006535 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6536 if (wcap != AC_WID_AUD_IN) {
6537 spec->adc_nids = alc262_adc_nids_alt;
6538 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6539 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6540 spec->num_mixers++;
6541 } else {
6542 spec->adc_nids = alc262_adc_nids;
6543 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6544 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6545 spec->num_mixers++;
6546 }
6547 }
6548
6549 codec->patch_ops = alc_patch_ops;
6550 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006551 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01006552
Kailang Yangdf694da2005-12-05 19:42:22 +01006553 return 0;
6554}
6555
Kailang Yangdf694da2005-12-05 19:42:22 +01006556/*
6557 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6558 */
6559
6560/*
6561 * set the path ways for 2 channel output
6562 * need to set the codec line out and mic 1 pin widgets to inputs
6563 */
6564static struct hda_verb alc861_threestack_ch2_init[] = {
6565 /* set pin widget 1Ah (line in) for input */
6566 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6567 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6568 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6569
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006570 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6571#if 0
6572 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6574#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006575 { } /* end */
6576};
6577/*
6578 * 6ch mode
6579 * need to set the codec line out and mic 1 pin widgets to outputs
6580 */
6581static struct hda_verb alc861_threestack_ch6_init[] = {
6582 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6583 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6584 /* set pin widget 18h (mic1) for output (CLFE)*/
6585 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6586
6587 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006588 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006589
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006590 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6591#if 0
6592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6593 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6594#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006595 { } /* end */
6596};
6597
6598static struct hda_channel_mode alc861_threestack_modes[2] = {
6599 { 2, alc861_threestack_ch2_init },
6600 { 6, alc861_threestack_ch6_init },
6601};
Takashi Iwai22309c32006-08-09 16:57:28 +02006602/* Set mic1 as input and unmute the mixer */
6603static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6604 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6605 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6606 { } /* end */
6607};
6608/* Set mic1 as output and mute mixer */
6609static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6610 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6611 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6612 { } /* end */
6613};
6614
6615static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6616 { 2, alc861_uniwill_m31_ch2_init },
6617 { 4, alc861_uniwill_m31_ch4_init },
6618};
Kailang Yangdf694da2005-12-05 19:42:22 +01006619
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006620/* Set mic1 and line-in as input and unmute the mixer */
6621static struct hda_verb alc861_asus_ch2_init[] = {
6622 /* set pin widget 1Ah (line in) for input */
6623 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6624 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6625 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6626
6627 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6628#if 0
6629 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6631#endif
6632 { } /* end */
6633};
6634/* Set mic1 nad line-in as output and mute mixer */
6635static struct hda_verb alc861_asus_ch6_init[] = {
6636 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6637 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6638 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6639 /* set pin widget 18h (mic1) for output (CLFE)*/
6640 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6641 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6642 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6643 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6644
6645 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6646#if 0
6647 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6649#endif
6650 { } /* end */
6651};
6652
6653static struct hda_channel_mode alc861_asus_modes[2] = {
6654 { 2, alc861_asus_ch2_init },
6655 { 6, alc861_asus_ch6_init },
6656};
6657
Kailang Yangdf694da2005-12-05 19:42:22 +01006658/* patch-ALC861 */
6659
6660static struct snd_kcontrol_new alc861_base_mixer[] = {
6661 /* output mixer control */
6662 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6663 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6664 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6665 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6666 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6667
6668 /*Input mixer control */
6669 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6670 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6671 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6672 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6673 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6674 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6676 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6677 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6679
6680 /* Capture mixer control */
6681 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6682 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6683 {
6684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6685 .name = "Capture Source",
6686 .count = 1,
6687 .info = alc_mux_enum_info,
6688 .get = alc_mux_enum_get,
6689 .put = alc_mux_enum_put,
6690 },
6691 { } /* end */
6692};
6693
6694static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6695 /* output mixer control */
6696 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6697 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6698 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6699 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6700 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6701
6702 /* Input mixer control */
6703 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6704 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6705 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6706 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6707 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6708 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6710 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6713
6714 /* Capture mixer control */
6715 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6716 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6717 {
6718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6719 .name = "Capture Source",
6720 .count = 1,
6721 .info = alc_mux_enum_info,
6722 .get = alc_mux_enum_get,
6723 .put = alc_mux_enum_put,
6724 },
6725 {
6726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6727 .name = "Channel Mode",
6728 .info = alc_ch_mode_info,
6729 .get = alc_ch_mode_get,
6730 .put = alc_ch_mode_put,
6731 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6732 },
6733 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02006734};
6735
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006736static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02006737 /* output mixer control */
6738 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6740 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6741
6742 /*Capture mixer control */
6743 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6744 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6745 {
6746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6747 .name = "Capture Source",
6748 .count = 1,
6749 .info = alc_mux_enum_info,
6750 .get = alc_mux_enum_get,
6751 .put = alc_mux_enum_put,
6752 },
6753
6754 { } /* end */
6755};
6756
Takashi Iwai22309c32006-08-09 16:57:28 +02006757static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6758 /* output mixer control */
6759 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6760 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6761 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6762 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6763 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6764
6765 /* Input mixer control */
6766 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6767 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6768 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6769 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6770 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6771 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6773 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6774 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6776
6777 /* Capture mixer control */
6778 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6779 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6780 {
6781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6782 .name = "Capture Source",
6783 .count = 1,
6784 .info = alc_mux_enum_info,
6785 .get = alc_mux_enum_get,
6786 .put = alc_mux_enum_put,
6787 },
6788 {
6789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6790 .name = "Channel Mode",
6791 .info = alc_ch_mode_info,
6792 .get = alc_ch_mode_get,
6793 .put = alc_ch_mode_put,
6794 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6795 },
6796 { } /* end */
6797};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006798
6799static struct snd_kcontrol_new alc861_asus_mixer[] = {
6800 /* output mixer control */
6801 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6802 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6803 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6804 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6805 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6806
6807 /* Input mixer control */
6808 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6809 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6810 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6811 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6812 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6813 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6815 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
6818
6819 /* Capture mixer control */
6820 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6821 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6822 {
6823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6824 .name = "Capture Source",
6825 .count = 1,
6826 .info = alc_mux_enum_info,
6827 .get = alc_mux_enum_get,
6828 .put = alc_mux_enum_put,
6829 },
6830 {
6831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6832 .name = "Channel Mode",
6833 .info = alc_ch_mode_info,
6834 .get = alc_ch_mode_get,
6835 .put = alc_ch_mode_put,
6836 .private_value = ARRAY_SIZE(alc861_asus_modes),
6837 },
6838 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01006839};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006840
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01006841/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006842static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01006843 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6844 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6845 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
6846 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
6847 { }
6848};
6849
Kailang Yangdf694da2005-12-05 19:42:22 +01006850/*
6851 * generic initialization of ADC, input mixers and output mixers
6852 */
6853static struct hda_verb alc861_base_init_verbs[] = {
6854 /*
6855 * Unmute ADC0 and set the default input to mic-in
6856 */
6857 /* port-A for surround (rear panel) */
6858 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6859 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6860 /* port-B for mic-in (rear panel) with vref */
6861 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6862 /* port-C for line-in (rear panel) */
6863 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6864 /* port-D for Front */
6865 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6866 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6867 /* port-E for HP out (front panel) */
6868 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6869 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01006870 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006871 /* port-F for mic-in (front panel) with vref */
6872 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6873 /* port-G for CLFE (rear panel) */
6874 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6875 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6876 /* port-H for side (rear panel) */
6877 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6878 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6879 /* CD-in */
6880 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6881 /* route front mic to ADC1*/
6882 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6883 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6884
6885 /* Unmute DAC0~3 & spdif out*/
6886 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6887 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6888 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6889 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6891
6892 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6893 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6894 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6895 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6896 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6897
6898 /* Unmute Stereo Mixer 15 */
6899 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6903
6904 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6905 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6906 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6910 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6914
6915 { }
6916};
6917
6918static struct hda_verb alc861_threestack_init_verbs[] = {
6919 /*
6920 * Unmute ADC0 and set the default input to mic-in
6921 */
6922 /* port-A for surround (rear panel) */
6923 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6924 /* port-B for mic-in (rear panel) with vref */
6925 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6926 /* port-C for line-in (rear panel) */
6927 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6928 /* port-D for Front */
6929 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6930 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6931 /* port-E for HP out (front panel) */
6932 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6933 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01006934 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006935 /* port-F for mic-in (front panel) with vref */
6936 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6937 /* port-G for CLFE (rear panel) */
6938 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6939 /* port-H for side (rear panel) */
6940 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6941 /* CD-in */
6942 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6943 /* route front mic to ADC1*/
6944 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6946 /* Unmute DAC0~3 & spdif out*/
6947 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6948 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6949 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6950 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6952
6953 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6954 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6955 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6956 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6957 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6958
6959 /* Unmute Stereo Mixer 15 */
6960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6964
6965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6966 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6968 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6970 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6973 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6975 { }
6976};
Takashi Iwai22309c32006-08-09 16:57:28 +02006977
6978static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6979 /*
6980 * Unmute ADC0 and set the default input to mic-in
6981 */
6982 /* port-A for surround (rear panel) */
6983 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6984 /* port-B for mic-in (rear panel) with vref */
6985 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6986 /* port-C for line-in (rear panel) */
6987 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6988 /* port-D for Front */
6989 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6990 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6991 /* port-E for HP out (front panel) */
6992 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6993 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01006994 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02006995 /* port-F for mic-in (front panel) with vref */
6996 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6997 /* port-G for CLFE (rear panel) */
6998 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6999 /* port-H for side (rear panel) */
7000 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7001 /* CD-in */
7002 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7003 /* route front mic to ADC1*/
7004 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7006 /* Unmute DAC0~3 & spdif out*/
7007 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7008 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7009 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7010 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7011 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7012
7013 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7014 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7015 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7016 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7017 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7018
7019 /* Unmute Stereo Mixer 15 */
7020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7023 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7024
7025 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7026 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7027 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7028 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7029 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7030 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7031 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7032 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7033 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7035 { }
7036};
7037
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007038static struct hda_verb alc861_asus_init_verbs[] = {
7039 /*
7040 * Unmute ADC0 and set the default input to mic-in
7041 */
7042 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
7043 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7044 /* route front PCM to HP */
7045 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
7046 /* port-B for mic-in (rear panel) with vref */
7047 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7048 /* port-C for line-in (rear panel) */
7049 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7050 /* port-D for Front */
7051 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7052 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7053 /* port-E for HP out (front panel) */
7054 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
7055 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01007056 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007057 /* port-F for mic-in (front panel) with vref */
7058 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7059 /* port-G for CLFE (rear panel) */
7060 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7061 /* port-H for side (rear panel) */
7062 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7063 /* CD-in */
7064 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7065 /* route front mic to ADC1*/
7066 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7068 /* Unmute DAC0~3 & spdif out*/
7069 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7070 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7071 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7072 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7074 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7075 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7076 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7077 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7078 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7079
7080 /* Unmute Stereo Mixer 15 */
7081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
7085
7086 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7087 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7089 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7093 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7094 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
7095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7096 { }
7097};
7098
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01007099/* additional init verbs for ASUS laptops */
7100static struct hda_verb alc861_asus_laptop_init_verbs[] = {
7101 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
7102 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
7103 { }
7104};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007105
Kailang Yangdf694da2005-12-05 19:42:22 +01007106/*
7107 * generic initialization of ADC, input mixers and output mixers
7108 */
7109static struct hda_verb alc861_auto_init_verbs[] = {
7110 /*
7111 * Unmute ADC0 and set the default input to mic-in
7112 */
7113// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7115
7116 /* Unmute DAC0~3 & spdif out*/
7117 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7118 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7119 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7120 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7122
7123 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7124 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7125 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7126 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7127 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7128
7129 /* Unmute Stereo Mixer 15 */
7130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7134
7135 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7136 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7137 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7138 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7139 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7141 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7142 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7143
7144 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7145 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7146 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7148 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7150 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7151 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7152
7153 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7154
7155 { }
7156};
7157
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007158static struct hda_verb alc861_toshiba_init_verbs[] = {
7159 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7160
7161 { }
7162};
7163
7164/* toggle speaker-output according to the hp-jack state */
7165static void alc861_toshiba_automute(struct hda_codec *codec)
7166{
7167 unsigned int present;
7168
7169 present = snd_hda_codec_read(codec, 0x0f, 0,
7170 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7171 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7172 0x80, present ? 0x80 : 0);
7173 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7174 0x80, present ? 0x80 : 0);
7175 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7176 0x80, present ? 0 : 0x80);
7177 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7178 0x80, present ? 0 : 0x80);
7179}
7180
7181static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7182 unsigned int res)
7183{
7184 /* Looks like the unsol event is incompatible with the standard
7185 * definition. 6bit tag is placed at 26 bit!
7186 */
7187 if ((res >> 26) == ALC880_HP_EVENT)
7188 alc861_toshiba_automute(codec);
7189}
7190
Kailang Yangdf694da2005-12-05 19:42:22 +01007191/* pcm configuration: identiacal with ALC880 */
7192#define alc861_pcm_analog_playback alc880_pcm_analog_playback
7193#define alc861_pcm_analog_capture alc880_pcm_analog_capture
7194#define alc861_pcm_digital_playback alc880_pcm_digital_playback
7195#define alc861_pcm_digital_capture alc880_pcm_digital_capture
7196
7197
7198#define ALC861_DIGOUT_NID 0x07
7199
7200static struct hda_channel_mode alc861_8ch_modes[1] = {
7201 { 8, NULL }
7202};
7203
7204static hda_nid_t alc861_dac_nids[4] = {
7205 /* front, surround, clfe, side */
7206 0x03, 0x06, 0x05, 0x04
7207};
7208
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007209static hda_nid_t alc660_dac_nids[3] = {
7210 /* front, clfe, surround */
7211 0x03, 0x05, 0x06
7212};
7213
Kailang Yangdf694da2005-12-05 19:42:22 +01007214static hda_nid_t alc861_adc_nids[1] = {
7215 /* ADC0-2 */
7216 0x08,
7217};
7218
7219static struct hda_input_mux alc861_capture_source = {
7220 .num_items = 5,
7221 .items = {
7222 { "Mic", 0x0 },
7223 { "Front Mic", 0x3 },
7224 { "Line", 0x1 },
7225 { "CD", 0x4 },
7226 { "Mixer", 0x5 },
7227 },
7228};
7229
7230/* fill in the dac_nids table from the parsed pin configuration */
7231static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7232{
7233 int i;
7234 hda_nid_t nid;
7235
7236 spec->multiout.dac_nids = spec->private_dac_nids;
7237 for (i = 0; i < cfg->line_outs; i++) {
7238 nid = cfg->line_out_pins[i];
7239 if (nid) {
7240 if (i >= ARRAY_SIZE(alc861_dac_nids))
7241 continue;
7242 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7243 }
7244 }
7245 spec->multiout.num_dacs = cfg->line_outs;
7246 return 0;
7247}
7248
7249/* add playback controls from the parsed DAC table */
7250static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7251 const struct auto_pin_cfg *cfg)
7252{
7253 char name[32];
7254 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7255 hda_nid_t nid;
7256 int i, idx, err;
7257
7258 for (i = 0; i < cfg->line_outs; i++) {
7259 nid = spec->multiout.dac_nids[i];
7260 if (! nid)
7261 continue;
7262 if (nid == 0x05) {
7263 /* Center/LFE */
7264 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7265 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7266 return err;
7267 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7268 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7269 return err;
7270 } else {
7271 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7272 if (nid == alc861_dac_nids[idx])
7273 break;
7274 sprintf(name, "%s Playback Switch", chname[idx]);
7275 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7276 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7277 return err;
7278 }
7279 }
7280 return 0;
7281}
7282
7283static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7284{
7285 int err;
7286 hda_nid_t nid;
7287
7288 if (! pin)
7289 return 0;
7290
7291 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7292 nid = 0x03;
7293 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7294 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7295 return err;
7296 spec->multiout.hp_nid = nid;
7297 }
7298 return 0;
7299}
7300
7301/* create playback/capture controls for input pins */
7302static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7303{
Kailang Yangdf694da2005-12-05 19:42:22 +01007304 struct hda_input_mux *imux = &spec->private_imux;
7305 int i, err, idx, idx1;
7306
7307 for (i = 0; i < AUTO_PIN_LAST; i++) {
7308 switch(cfg->input_pins[i]) {
7309 case 0x0c:
7310 idx1 = 1;
7311 idx = 2; // Line In
7312 break;
7313 case 0x0f:
7314 idx1 = 2;
7315 idx = 2; // Line In
7316 break;
7317 case 0x0d:
7318 idx1 = 0;
7319 idx = 1; // Mic In
7320 break;
7321 case 0x10:
7322 idx1 = 3;
7323 idx = 1; // Mic In
7324 break;
7325 case 0x11:
7326 idx1 = 4;
7327 idx = 0; // CD
7328 break;
7329 default:
7330 continue;
7331 }
7332
Takashi Iwai4a471b72005-12-07 13:56:29 +01007333 err = new_analog_input(spec, cfg->input_pins[i],
7334 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01007335 if (err < 0)
7336 return err;
7337
Takashi Iwai4a471b72005-12-07 13:56:29 +01007338 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01007339 imux->items[imux->num_items].index = idx1;
7340 imux->num_items++;
7341 }
7342 return 0;
7343}
7344
7345static struct snd_kcontrol_new alc861_capture_mixer[] = {
7346 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7347 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7348
7349 {
7350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7351 /* The multiple "Capture Source" controls confuse alsamixer
7352 * So call somewhat different..
7353 *FIXME: the controls appear in the "playback" view!
7354 */
7355 /* .name = "Capture Source", */
7356 .name = "Input Source",
7357 .count = 1,
7358 .info = alc_mux_enum_info,
7359 .get = alc_mux_enum_get,
7360 .put = alc_mux_enum_put,
7361 },
7362 { } /* end */
7363};
7364
7365static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7366 int pin_type, int dac_idx)
7367{
7368 /* set as output */
7369
7370 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7371 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
7372
7373}
7374
7375static void alc861_auto_init_multi_out(struct hda_codec *codec)
7376{
7377 struct alc_spec *spec = codec->spec;
7378 int i;
7379
7380 for (i = 0; i < spec->autocfg.line_outs; i++) {
7381 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7382 if (nid)
7383 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
7384 }
7385}
7386
7387static void alc861_auto_init_hp_out(struct hda_codec *codec)
7388{
7389 struct alc_spec *spec = codec->spec;
7390 hda_nid_t pin;
7391
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007392 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007393 if (pin) /* connect to front */
7394 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
7395}
7396
7397static void alc861_auto_init_analog_input(struct hda_codec *codec)
7398{
7399 struct alc_spec *spec = codec->spec;
7400 int i;
7401
7402 for (i = 0; i < AUTO_PIN_LAST; i++) {
7403 hda_nid_t nid = spec->autocfg.input_pins[i];
7404 if ((nid>=0x0c) && (nid <=0x11)) {
7405 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7406 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
7407 }
7408 }
7409}
7410
7411/* parse the BIOS configuration and set up the alc_spec */
7412/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
7413static int alc861_parse_auto_config(struct hda_codec *codec)
7414{
7415 struct alc_spec *spec = codec->spec;
7416 int err;
7417 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7418
7419 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7420 alc861_ignore)) < 0)
7421 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01007422 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007423 return 0; /* can't find valid BIOS pin config */
7424
7425 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
7426 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007427 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
Kailang Yangdf694da2005-12-05 19:42:22 +01007428 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
7429 return err;
7430
7431 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7432
7433 if (spec->autocfg.dig_out_pin)
7434 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
7435
7436 if (spec->kctl_alloc)
7437 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7438
7439 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
7440
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007441 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007442 spec->input_mux = &spec->private_imux;
7443
7444 spec->adc_nids = alc861_adc_nids;
7445 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
7446 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
7447 spec->num_mixers++;
7448
7449 return 1;
7450}
7451
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007452/* additional initialization for auto-configuration model */
7453static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007454{
Kailang Yangdf694da2005-12-05 19:42:22 +01007455 alc861_auto_init_multi_out(codec);
7456 alc861_auto_init_hp_out(codec);
7457 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007458}
7459
7460
7461/*
7462 * configuration and preset
7463 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007464static const char *alc861_models[ALC861_MODEL_LAST] = {
7465 [ALC861_3ST] = "3stack",
7466 [ALC660_3ST] = "3stack-660",
7467 [ALC861_3ST_DIG] = "3stack-dig",
7468 [ALC861_6ST_DIG] = "6stack-dig",
7469 [ALC861_UNIWILL_M31] = "uniwill-m31",
7470 [ALC861_TOSHIBA] = "toshiba",
7471 [ALC861_ASUS] = "asus",
7472 [ALC861_ASUS_LAPTOP] = "asus-laptop",
7473 [ALC861_AUTO] = "auto",
7474};
7475
7476static struct snd_pci_quirk alc861_cfg_tbl[] = {
7477 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7478 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7479 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7480 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
7481 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
7482 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
7483 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01007484 {}
7485};
7486
7487static struct alc_config_preset alc861_presets[] = {
7488 [ALC861_3ST] = {
7489 .mixers = { alc861_3ST_mixer },
7490 .init_verbs = { alc861_threestack_init_verbs },
7491 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7492 .dac_nids = alc861_dac_nids,
7493 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7494 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007495 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7497 .adc_nids = alc861_adc_nids,
7498 .input_mux = &alc861_capture_source,
7499 },
7500 [ALC861_3ST_DIG] = {
7501 .mixers = { alc861_base_mixer },
7502 .init_verbs = { alc861_threestack_init_verbs },
7503 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7504 .dac_nids = alc861_dac_nids,
7505 .dig_out_nid = ALC861_DIGOUT_NID,
7506 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7507 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007508 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007509 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7510 .adc_nids = alc861_adc_nids,
7511 .input_mux = &alc861_capture_source,
7512 },
7513 [ALC861_6ST_DIG] = {
7514 .mixers = { alc861_base_mixer },
7515 .init_verbs = { alc861_base_init_verbs },
7516 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7517 .dac_nids = alc861_dac_nids,
7518 .dig_out_nid = ALC861_DIGOUT_NID,
7519 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
7520 .channel_mode = alc861_8ch_modes,
7521 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7522 .adc_nids = alc861_adc_nids,
7523 .input_mux = &alc861_capture_source,
7524 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007525 [ALC660_3ST] = {
7526 .mixers = { alc861_3ST_mixer },
7527 .init_verbs = { alc861_threestack_init_verbs },
7528 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
7529 .dac_nids = alc660_dac_nids,
7530 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7531 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007532 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007533 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7534 .adc_nids = alc861_adc_nids,
7535 .input_mux = &alc861_capture_source,
7536 },
Takashi Iwai22309c32006-08-09 16:57:28 +02007537 [ALC861_UNIWILL_M31] = {
7538 .mixers = { alc861_uniwill_m31_mixer },
7539 .init_verbs = { alc861_uniwill_m31_init_verbs },
7540 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7541 .dac_nids = alc861_dac_nids,
7542 .dig_out_nid = ALC861_DIGOUT_NID,
7543 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
7544 .channel_mode = alc861_uniwill_m31_modes,
7545 .need_dac_fix = 1,
7546 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7547 .adc_nids = alc861_adc_nids,
7548 .input_mux = &alc861_capture_source,
7549 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007550 [ALC861_TOSHIBA] = {
7551 .mixers = { alc861_toshiba_mixer },
7552 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
7553 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7554 .dac_nids = alc861_dac_nids,
7555 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7556 .channel_mode = alc883_3ST_2ch_modes,
7557 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7558 .adc_nids = alc861_adc_nids,
7559 .input_mux = &alc861_capture_source,
7560 .unsol_event = alc861_toshiba_unsol_event,
7561 .init_hook = alc861_toshiba_automute,
7562 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007563 [ALC861_ASUS] = {
7564 .mixers = { alc861_asus_mixer },
7565 .init_verbs = { alc861_asus_init_verbs },
7566 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7567 .dac_nids = alc861_dac_nids,
7568 .dig_out_nid = ALC861_DIGOUT_NID,
7569 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
7570 .channel_mode = alc861_asus_modes,
7571 .need_dac_fix = 1,
7572 .hp_nid = 0x06,
7573 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7574 .adc_nids = alc861_adc_nids,
7575 .input_mux = &alc861_capture_source,
7576 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01007577 [ALC861_ASUS_LAPTOP] = {
7578 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
7579 .init_verbs = { alc861_asus_init_verbs,
7580 alc861_asus_laptop_init_verbs },
7581 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7582 .dac_nids = alc861_dac_nids,
7583 .dig_out_nid = ALC861_DIGOUT_NID,
7584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7585 .channel_mode = alc883_3ST_2ch_modes,
7586 .need_dac_fix = 1,
7587 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7588 .adc_nids = alc861_adc_nids,
7589 .input_mux = &alc861_capture_source,
7590 },
7591};
Kailang Yangdf694da2005-12-05 19:42:22 +01007592
7593
7594static int patch_alc861(struct hda_codec *codec)
7595{
7596 struct alc_spec *spec;
7597 int board_config;
7598 int err;
7599
7600 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
7601 if (spec == NULL)
7602 return -ENOMEM;
7603
7604 codec->spec = spec;
7605
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007606 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7607 alc861_models,
7608 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007609
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007610 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007611 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
7612 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007613 board_config = ALC861_AUTO;
7614 }
7615
7616 if (board_config == ALC861_AUTO) {
7617 /* automatic parse from the BIOS config */
7618 err = alc861_parse_auto_config(codec);
7619 if (err < 0) {
7620 alc_free(codec);
7621 return err;
7622 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007623 printk(KERN_INFO
7624 "hda_codec: Cannot set up configuration "
7625 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007626 board_config = ALC861_3ST_DIG;
7627 }
7628 }
7629
7630 if (board_config != ALC861_AUTO)
7631 setup_preset(spec, &alc861_presets[board_config]);
7632
7633 spec->stream_name_analog = "ALC861 Analog";
7634 spec->stream_analog_playback = &alc861_pcm_analog_playback;
7635 spec->stream_analog_capture = &alc861_pcm_analog_capture;
7636
7637 spec->stream_name_digital = "ALC861 Digital";
7638 spec->stream_digital_playback = &alc861_pcm_digital_playback;
7639 spec->stream_digital_capture = &alc861_pcm_digital_capture;
7640
7641 codec->patch_ops = alc_patch_ops;
7642 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007643 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01007644
7645 return 0;
7646}
7647
7648/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07007649 * patch entries
7650 */
7651struct hda_codec_preset snd_hda_preset_realtek[] = {
7652 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007653 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007654 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
7655 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007656 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007657 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007658 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
7659 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
7660 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007661 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007662 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007663 { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007664 {} /* terminator */
7665};